GeoLeaf Core API - v3.19.0
    Preparing search index...

    Class ModuleRegistry

    Concrete implementation of IModuleRegistry.

    const registry = new ModuleRegistry();
    registry.register(new ConfigModule());
    registry.register(new GeoJSONModule());
    await registry.init(adapter, config);

    Implements

    Index
    • Registers a module descriptor with the registry.

      Idempotent: a module already registered under the same id wins, and a second call is a no-op.

      Registering after init() — a plugin whose bundle loads on demand — stores the module. A lifecycle module is not initialised for the application already running, which it joined by itself, but destroy() reaches it: it is torn down with the others, and initialised like them from the next init() on. A UI slot is not drawn before the next mount, the toolbar being built once per boot, and a warning says so.

      Throws a GeoLeafError when the module is neither a lifecycle module (init and destroy, both functions) nor a UI-only slot ({ id, ui }).

      Parameters

      Returns void

    • Resolves the dependency graph and initialises all registered modules in topological order.

      Rejects with a GeoLeafError if a circular dependency is detected — the message includes the full cycle path (e.g. "A → B → A") — or if a module declares a dependency that is not registered.

      Returns a Promise that resolves when all modules have completed init(). If any module's init() rejects, the returned Promise rejects with that error (subsequent modules are not initialised) — unless options.onModuleError answers "continue": the failure is then isolated to that module and to the modules that depend on it (see ModuleInitOptions).

      Parameters

      Returns Promise<void>

    • Retrieves a registered module by its id, cast to type T.

      Throws a GeoLeafError when no module with the given id is registered. Use has() first when presence is uncertain.

      Type Parameters

      Parameters

      • id: string

        The module's id string.

      Returns T

      GeoLeafError if no module with the given id exists.

      const geojson = registry.get<GeoJSONModule>('geojson');
      geojson.destroy();
    • Returns the schema of a registered module, or null if no module with the given id is registered.

      The returned object is a lightweight metadata view — it does not expose internal module state. IModuleSchema is enriched as capability schemas (config, capabilities, metadata) get defined.

      Parameters

      • id: string

        Module id (e.g. 'poi', 'route', 'search').

      Returns IModuleSchema | null

    • The modules that are actually RUNNING — not merely the ones registered.

      They were identical for as long as a switched-off capability was never registered: registerPresetModules filtered at Pass 2, so the map only ever held live modules and returning all of them was accurate by accident. 9.2 removed that filter — every capability module is now registered, and each decides in its own init() whether to run, so that a profile loaded after Pass 2 gets a say. Returning the whole map from a method called getActiveModules would, from that commit on, have answered « registered » to a question that asks « active ». The introspection surface would report capabilities that are switched off — silently, and to integrators.

      isEnabled() is not in ICoreModule, deliberately: it is put there by the wrapper in presets/apply-preset.ts, and the registry has no business learning what a capability gate is. Everything else — kernel modules, plugin UI slots, anything registered by hand — carries no gate, so it has nothing to be switched off by. Absent ⟹ active is therefore the correct default, not a lenient one.

      ⚠️ A wrapper answers false until its init() has run. Called mid-boot, this method lists the kernel only — which is the honest answer: nothing else has started yet.

      Under init(…, { onModuleError: () => "continue" }), a module whose init() threw, and every module skipped because it depends on one, are left out: a gate says whether a capability is switched on, not whether it started.

      Returns readonly IModuleInfo[]

    • Destroys the modules that started, in reverse initialisation order, and re-arms the registry: a later init() runs every module again.

      Each module's destroy() is called exactly once. Errors in individual destroy() calls are logged but do not interrupt the teardown sequence — all modules are destroyed regardless of individual failures. A module that never ran is not destroyed: one skipped because a module it depends on failed (see ModuleInitOptions), or one an initialisation stopped by shouldContinue never reached.

      Refused — logged, nothing torn down — while init() is still running.

      Returns void