Skip to main content

Namespaces module

📖 Description

The Namespaces class is used to load runner block bundles.

▶️ Functions


🔧 get

Retrieves the namespace for the specified identifier (or the default namespace if the identifier is omitted).

Signature

get(identifier?: string): INamespace

Parameters

NameTypeOptionalDescription
identifierstringNoSpecifies the identifier of the namespace to retrieve.

Return value

Returns the INamespace object that holds the blocks for the namespace.


🔧 isAvailable

Retrieves if a namespace exists for the specified identifier.

Signature

isAvailable(identifier?: string): boolean

Parameters

NameTypeOptionalDescription
identifierstringNoSpecifies the identifier of the namespace to check.

Return value

Returns true if the namespace exists.


🔧 loadUMD

Loads a block bundle using UMD code.

danger

Loading UMD code from a string is unsafe! Only use when the source of the UMD code is trusted. When you are using a Content Security Policy (CSP) configuration, make sure script-src 'unsafe-eval' is allowed.

Signature

loadUMD(umd: string): boolean

Parameters

NameTypeOptionalDescription
umdstringNoSpecifies the UMD code to load.

Return value

Returns true if the UMD code was successfully loaded.


🔧 loadURL

Loads a block bundle from an URL.

info

The UMD bundle is loaded using trusted-types with a policy named tripetto#runner. Please read the Content Security Policy guide for more information.

Signature

loadURL(url: string, done?: (succeeded: boolean) => void): void

Parameters

NameTypeOptionalDescription
urlstringNoSpecifies the URL of the UMD block bundle to load.
done(succeeded: boolean) => voidYesCallback function that is invoked when the loading is completed.

🔧 mount

Mounts (activates) a namespace context. All blocks that self-register when this namespace is mounted will become part of the namespace.

tip

You can also use the shorthand mountNamespace function.

Signature

mount(identifier?: string): void

Parameters

NameTypeOptionalDescription
identifierstringNoSpecifies the identifier of the namespace to mount.

🔧 unload

Unloads the specified namespace.

Signature

unload(identifier?: string): boolean

Parameters

NameTypeOptionalDescription
identifierstringNoSpecifies the identifier of the namespace to unload.

Return value

Returns true when the namespace is unloaded.


🔧 unmount

Unmounts (deactivates) the active namespace context.

tip

You can also use the shorthand unmountNamespace function.

Signature

unmount(): void