Skip to main content

Specification overview

ZenTS is the JavaScript/TypeScript port of ZLua. CLR types, binding, overloads, marshaling, lifetime, and build configuration follow ZLua unless the JS language or host requires an explicit adaptation.

These pages define current contracts. Native platforms and Editors use official static V8; WebGL/WeChat use the platform VM. QuickJS is removed. See alignment and status.

1. Product model​

  • C#→JS uses JsAppDomain.GetFunction<T>(module, exportName); callers cache the delegate.
  • JS→CLR uses lazy CSharp[assembly][fullName]; recommended csharp: imports resolve to the same type object.
  • Use Type.Method, obj.Method, and new Type. Extracted instance closures require .call(receiver, ...).
  • No per-type Wrap allowlist is required, but metadata, AOT code, and calling bridges must exist.
  • TypeScript is an editing/build tool; emitted JavaScript executes at runtime.

IL2CPP keeps metadata, binding plans, overloads, and marshaling in C++. First binding caches member/default/closed-generic information. Mono uses reflection/Emit. Optimization must preserve selected overloads, declared views, value copies, and GC-safe reference writes.

BoundaryContract
Eventsadd_Event/remove_Event, no event subobject
CLR member missJS error with zents: prefix, subject to protocol probes
InheritanceBinding-time flattening; restricted lazy full-signature lookup
Short namesFrozen after binding; no register_method
XMLAOT assemblies only; no runtime registration/hot reload/Reload
BackendsNative V8 and HostJs, no QuickJS fallback
WrappersAbstract exotic/slot model, independent of physical SDK layout

undefined means missing; null means explicit reference/Nullable no-value. CLR null pushes null; void produces undefined. See default marshaling.

2. CLR hosts and engines​

JsAppDomain / IJsRuntime / zents / csharp:
|
CLR binding plans
/ \
Mono + Emit IL2CPP + C++
\ /
owned EngineApi
/ \
Native V8 HostJs (JS/WASM)
EnvironmentCLR hostEngine
Windows/macOS EditorMonoNative V8
Win64/macOS/Android PlayerIL2CPPNative V8
iOSIL2CPPJITless V8
WebGL/WeChatIL2CPP/WASMExisting platform VM

Unity 2022.3.x and later LTS, plus Tuanjie based on 2022.3, are supported. Backend selection is not validation of every device/version. Unsupported native targets have no old-engine fallback.

3. Specification map​

PageResponsibility
Host APIInitialize, Reset, GetFunction, errors
TypesNames, views, construction, inheritance
AlignmentZLua/JS decisions and platform status
OverloadsSignatures, GTAP, params, selection
Libraryzents and typeArg
Marshaling, membersConversions and dispatch
LifetimeGC, scopes, threads, Reset
Build/versionInstallation, SDKs, iteration
MigrationRetired APIs
ExtensionsConfiguration and competition
TypeScriptEmit, declarations, modules
Settings, Unity optimizationConfiguration
V8, boundary, HostJsEngine integration

4. Initialization​

Create host/adapter and generation; install loaders, libraries, type roots, and AOT tables. First type access builds bindings with frozen short names and lazy signatures. GetFunction binds ready exports without awaiting Promises. FramePump drains releases and applies scheduled Reset at EndOfFrame; edit-mode Editor applies it synchronously.

HostJs must preload required bundles/subpackages before synchronous entry. Reset rebuilds the managed script world, not the platform VM.