PluginRegistry

View source

Internal registry that tracks plugin instances staged for an App.

Most API users interact with this registry through App#registerPlugin rather than calling it directly. Each plugin is identified by the TypeId returned by Plugin#name. The registry preserves insertion order, rejects duplicate IDs, visits plugins added during lifecycle passes, and validates declared dependencies before finalization.

Examples

import { App, Plugin } from '@wimaengine/app'

class ChildPlugin extends Plugin {}

class ParentPlugin extends Plugin {
  register(app) {
    // The child is appended after the parent during the same pass.
    app.registerPlugin(new ChildPlugin())
  }
}

new App()
  .registerPlugin(new ParentPlugin())
  .setRunner(() => {})
  .run()
// Both lifecycle hooks visit ChildPlugin after ParentPlugin.

Constructor


constructor()

Properties


parents: Map<TypeId, TypeId>

View source

Parent IDs for plugins registered from another plugin hook.

A child ID maps to the active parent ID. Direct app registrations have no entry. The map is used only to format duplicate-registration traces; it is not used for dependency validation or lifecycle ordering.

Default: ...

Methods


add(plugin: Plugin): void

View source

Adds a plugin instance in insertion order.

The plugin’s Plugin#name supplies its identity. When called from an active plugin hook, the current stack entry is recorded as the new plugin’s parent for duplicate-registration diagnostics. A duplicate ID throws before the list or ID set is changed.

Parameters

NameDescriptionDefault
plugin——

Throws

When the plugin’s ID is already registered.

enter(pluginId: TypeId): void

View source

Marks a plugin hook as active for nested-registration tracking.

This pushes the ID onto PluginRegistry#stack; it does not register or validate a plugin by itself.

Parameters

NameDescriptionDefault
pluginId——

leave(): void

View source

Leaves the most recently entered plugin hook.

register(app: App): void

View source

Runs each plugin’s registration hook in insertion order.

The list is allowed to grow during this pass, so plugins registered from a running Plugin#register hook are visited later in the same pass. Each hook runs with its ID on PluginRegistry#stack; this method does not validate dependencies or run finish hooks.

Parameters

NameDescriptionDefault
app——

finish(app: App): void

View source

Runs each plugin’s finish hook in insertion order.

Plugins added while a finish hook runs are appended and visited later in this same pass. Dependency validation has already happened before this method is called, so plugins added here are not included in that earlier validation pass.

Parameters

NameDescriptionDefault
app——

assertDependencies(app: App): void

View source

Validates the plugin dependencies declared by Plugin#requires.

Every registered plugin is asked for its required IDs, and each ID is checked through App#hasPlugin. This method does not load missing plugins, reorder hooks, or interpret dependencies as lifecycle order.

Parameters

NameDescriptionDefault
app——

Throws

When a required plugin ID is not registered with the app.