ultralight-godot SHOWCASEshabbywu/ultralight-godot

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

MemberTypeDefault
namespaceString—

Methods

namespaceString

Caller-selected JavaScript global name. Read-only.

Default: — · Accessors: get_namespace() · Read-only

create

create(namespace: String) → UltralightAPI static

Create 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 const

Return namespace.

is_closed

is_closed() → bool const

Return whether this registry has been closed.

register_function

register_function(name: String, function: Callable, options: UltralightBindingOptions = null) → UltralightResult

Register 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) → UltralightResult

Register 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) → UltralightResult

Register or replace a Godot object, Array or Dictionary. Apply optional member, read-only and copy settings. Nil is rejected.

unregister

unregister(name: String) → void

Remove this registration from all attached views and revoke its old proxies.

attach

attach(view: Object) → UltralightResult

Attach to an UltralightView, immediately if a document exists and automatically on later documents. Idempotent; return an error for namespace conflicts.

detach

detach(view: Object) → void

Remove this registry from the given View and revoke its namespace without closing the View. Idempotent.

close

close() → void

Detach all views, revoke proxies and clear definitions. Idempotent.

View class documentation source ↗

Godot screenshot · Press Esc to close Open original image ↗