API / CLASS REFERENCE
UltralightAPI
Inherits: RefCounted
Persistent application API registry with a caller-selected JavaScript namespace.
Create with create(namespace), register functions or objects, then attach to one or more UltralightView nodes. Namespaces are single ASCII JavaScript identifiers and must not collide with existing page globals. Registrations are installed before window_ready and page scripts on every new document. Shared containers are the default. Unregistering, detaching or closing also revokes cached JavaScript references. The reserved namespace member $bridge provides copy(value) and get/set(dictionary, key, ...). All bridge access must occur on the Godot main thread.
Properties
Methods
create(namespace: String) → UltralightAPI staticget_namespace() → String constis_closed() → bool constregister_function(name: String, function: Callable, options: UltralightBindingOptions = null) → UltralightResultregister_async(name: String, handler: Callable, options: UltralightBindingOptions = null) → UltralightResultregister_object(name: String, object: Variant, options: UltralightBindingOptions = null) → UltralightResultunregister(name: String) → voidattach(view: Object) → UltralightResultdetach(view: Object) → voidclose() → void
namespaceString
Caller-selected JavaScript global name. Read-only.
Default: — · Accessors: get_namespace() · Read-only
create
create(namespace: String) → UltralightAPI staticCreate a registry for one ASCII JavaScript identifier. Invalid or reserved identifiers return null. Does not export a global until attached.
get_namespace
get_namespace() → String constReturn namespace.
is_closed
is_closed() → bool constReturn whether this registry has been closed.
register_function
register_function(name: String, function: Callable, options: UltralightBindingOptions = null) → UltralightResultRegister or replace a synchronous callable. Shared conversion is the default for arguments and results. Return a Result for installation success.
register_async
register_async(name: String, handler: Callable, options: UltralightBindingOptions = null) → UltralightResultRegister a handler receiving (UltralightTask request, Array arguments). Resolve or reject the request on the main thread; JavaScript receives a Promise.
register_object
register_object(name: String, object: Variant, options: UltralightBindingOptions = null) → UltralightResultRegister or replace a Godot object, Array or Dictionary. Apply optional member, read-only and copy settings. Nil is rejected.
unregister
unregister(name: String) → voidRemove this registration from all attached views and revoke its old proxies.
attach
attach(view: Object) → UltralightResultAttach to an UltralightView, immediately if a document exists and automatically on later documents. Idempotent; return an error for namespace conflicts.
detach
detach(view: Object) → voidRemove this registry from the given View and revoke its namespace without closing the View. Idempotent.
close
close() → voidDetach all views, revoke proxies and clear definitions. Idempotent.