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

    Orchestrates the GeoLeaf module lifecycle.

    The registry is the single entry point for module management:

    • Modules are registered before init() is called.
    • On init(), the registry performs a topological sort of all registered modules and calls each module.init() in the resolved order.
    • On destroy(), modules are torn down in reverse initialisation order.

    The registry is exposed on the GeoLeaf namespace to allow third-party modules to self-register:

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

    const geojson = registry.get<GeoJSONModule>('geojson');
    interface IModuleRegistry {
        register(module: ICoreModule): void;
        init(
            adapter: IMapAdapter,
            config: IGeoLeafConfig,
            options?: ModuleInitOptions,
        ): Promise<void>;
        get<T extends ICoreModule = ICoreModule>(id: string): T;
        has(id: string): boolean;
        isInitialized(): boolean;
        getAll(): readonly ICoreModule[];
        getUISlots(): IModuleUISlot[];
        destroy(): void;
        getModuleSchema(id: string): IModuleSchema | null;
        getActiveModules(): readonly IModuleInfo[];
    }

    Implemented by

    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 true if init() has already been called on this registry.

      Use this guard before calling register() in contexts where the registry may have already been initialised (e.g. double-boot scenarios).

      Returns boolean

    • 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

    • 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

    • Returns a read-only snapshot of the modules that are running, in insertion order.

      Includes both built-in modules (registered before init()) and lazily registered plugin modules (registered after init()). Leaves out a module whose capability gate (isEnabled()) answers false and — under onModuleError: () => "continue" — a module whose init() failed and the modules skipped because they depend on it.

      Returns readonly IModuleInfo[]