Skip to content

@graphty/graphty-element / extend / AcceleratorRegistry

Class: AcceleratorRegistry ​

Defined in: graphty-element/src/acceleration/registry.ts:46

A set of accelerator factories.

There is one default instance, acceleratorRegistry, which is what the ./webgpu entry point registers into and what a controller reads when it is not given another. Tests make their own so that one test's fake accelerator is invisible to the next.

Constructors ​

Constructor ​

new AcceleratorRegistry(): AcceleratorRegistry

Returns ​

AcceleratorRegistry

Methods ​

clear() ​

clear(): void

Defined in: graphty-element/src/acceleration/registry.ts:149

Removes every factory.

Written for tests, which need each test to start from an empty registry.

Returns ​

void


has() ​

has(name): boolean

Defined in: graphty-element/src/acceleration/registry.ts:129

Reports whether a name is registered.

Parameters ​

name ​

string

The name to look for.

Returns ​

boolean

True when a factory is registered under it.


list() ​

list(): readonly AcceleratorRegistration[]

Defined in: graphty-element/src/acceleration/registry.ts:140

Every registered factory, in registration order.

A controller probes them in this order and attaches the first accelerator it gets, so the order is the preference order.

Returns ​

readonly AcceleratorRegistration[]

The registrations.


onChange() ​

onChange(listener): () => void

Defined in: graphty-element/src/acceleration/registry.ts:168

Subscribes to registration changes.

A controller that has already concluded "no accelerator is registered" listens here, so that an import "@graphty/graphty-element/webgpu" evaluated after the element was constructed still switches acceleration on without the consumer doing anything.

Parameters ​

listener ​

() => void

Called after every change, with no arguments.

Returns ​

The unsubscribe function.

() => void


register() ​

register(registration, options?): void

Defined in: graphty-element/src/acceleration/registry.ts:63

Registers a factory.

Registering the identical factory under the same name again is a no-op, which is what hot module replacement needs. A different factory under a taken name warns once and wins, unless strict was asked for, in which case it throws E_DUPLICATE_PLUGIN.

Parameters ​

registration ​

AcceleratorRegistration

The name, the backend and the factory.

options? ​

RegisterAcceleratorOptions

Whether a collision throws instead of replacing.

Returns ​

void

Throws ​

A GraphtyError with E_BAD_COMMAND when the registration is malformed, or with E_DUPLICATE_PLUGIN when strict was asked for and the name is taken by a different factory.


remove() ​

remove(name): boolean

Defined in: graphty-element/src/acceleration/registry.ts:115

Removes a factory.

Parameters ​

name ​

string

The name it was registered under.

Returns ​

boolean

True when something was removed.