GeoLeaf Core API - v3.0.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 after Sprint 3 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): 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

    Methods

    • Registers a module descriptor with the registry.

      Registration is only allowed before init() has been called. Throws a GeoLeafError if:

      • A module with the same id is already registered.
      • init() has already been called on this registry instance.

      Parameters

      Returns void

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

      Throws a GeoLeafError if a circular dependency is detected. The error message includes the full cycle path (e.g. "A → B → A").

      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).

      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

    • Collects and returns the ui slot of every module that declares one.

      Used by the UI orchestrator to build the mobile toolbar and the filter panel tabs without coupling the UI layer to specific module classes.

      Returns an empty array when no module declares a UI slot.

      Returns IModuleUISlot[]

    • Destroys all registered modules in reverse initialisation order.

      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.

      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 will be enriched in S2.1 when capability schemas (config, capabilities, metadata) are defined.

      Parameters

      • id: string

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

      Returns IModuleSchema | null

    • Returns a read-only snapshot of all registered modules in insertion order.

      Includes both built-in modules (registered before init()) and lazily registered plugin modules (registered after init()).

      Returns readonly IModuleInfo[]