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

    The COMPLETE GeoLeaf.Config façade — single source of truth for its shape.

    ⚠️ The singleton is assembled in two stages, which is why this type exists. config-core.ts builds an object literal carrying only the lifecycle core; three sibling modules then graft the rest onto it at import time, as side effects (globals.config.ts imports them for that purpose alone):

    Module Grafts
    config-accessors.ts getAll get getModuleConfig set getSection getActiveProfile* isProfilePoiMappingEnabled
    config-loaders.ts loadUrl loadActiveProfileResources
    config-validation.ts _validateConfig

    Before S5 each grafting module redeclared its own partial interface and reached the singleton through an as unknown as cast — four declarations that ignored one another, two of them redeclaring _config, and no type anywhere describing a complete Config. They now all target this one. The single remaining widening cast lives in config-core.ts, where the two-stage assembly actually happens.

    interface ConfigFacade {
        _config: GeoLeafConfig;
        _isLoaded: boolean;
        _subModulesInitialized: boolean;
        _source: string | null;
        _options: { autoEvent: boolean };
        init(options?: ConfigInitOptions): Promise<GeoLeafConfig>;
        isLoaded(): boolean;
        getSource(): string | null;
        _initSubModules(): void;
        _applyConfig(cfg: Record<string, unknown> | null, source: string): void;
        _maybeFireLoadedEvent(): void;
        getAll(): GeoLeafConfig;
        get<T = unknown>(path: string, defaultValue?: T): T;
        getModuleConfig<T = unknown>(
            moduleId: string,
            key?: string,
            defaultValue?: T,
        ): T;
        set(path: string, value: unknown): void;
        getSection(sectionName: string, defaultValue?: unknown): unknown;
        getActiveProfileId(): string | null;
        getActiveProfile(): Record<string, unknown> | null;
        getActiveProfileMapping(): Record<string, unknown> | null;
        isProfilePoiMappingEnabled(): boolean;
        loadUrl(url: string, options?: LoadUrlOptions): Promise<GeoLeafConfig>;
        loadActiveProfileResources(
            options?: {
                headers?: Record<string, string>;
                strictContentType?: boolean;
            },
        ): Promise<GeoLeafConfig>;
        _validateConfig?: (cfg: GeoLeafConfig | null | undefined) => void;
    }
    Index

    Properties

    _config: GeoLeafConfig
    _isLoaded: boolean
    _subModulesInitialized: boolean
    _source: string | null
    _options: { autoEvent: boolean }
    _validateConfig?: (cfg: GeoLeafConfig | null | undefined) => void

    Methods

    • Loads the configuration and brings the sub-modules up.

      Three paths, in this order of precedence: an inline config is applied synchronously; a url is fetched; neither yields an empty configuration rather than an error — a map can boot with defaults. onLoaded fires on all three, and the DOM event only when autoEvent is left on.

      Parameters

      Returns Promise<GeoLeafConfig>

      await GeoLeaf.Config.init({
      url: "../data/geoleaf.config.json",
      autoEvent: true,
      onLoaded: (config) => {
      console.log("Config loaded:", config);
      },
      });
    • The complete configuration currently loaded.

      ⚠️ Through the ambient global, this returns a loose record: GeoLeafGlobal.Config is hand-typed and declares getAll(): Record<string, unknown>, not GeoLeafConfig. To read a field with its real type, use ConfigFacade.get — which is generic — or import Config from @geoleaf/core/kernel. Typing the ambient member from this interface is tracked as B-13.

      Returns GeoLeafConfig

      const config = GeoLeaf.Config.getAll();
      console.log(Object.keys(config));
    • Reads one field by dotted path, with a fallback when it is absent.

      Type Parameters

      • T = unknown

      Parameters

      • path: string
      • OptionaldefaultValue: T

      Returns T

      const theme = GeoLeaf.Config.get("ui.theme", "light");
      const zoom = GeoLeaf.Config.get("map.zoom", 10);
    • The active profile object, as resolved by ProfileManager, or null when none is active.

      Returns Record<string, unknown> | null

      const profile = GeoLeaf.Config.getActiveProfile();
      if (profile) {
      console.log("active profile loaded");
      }
    • Fetches a JSON configuration and applies it.

      Failure is contained, not thrown: an unreachable URL or invalid JSON is logged and the configuration already in place is returned, so a bad fetch degrades the map rather than breaking its boot. strictContentType rejects a response that is not application/json.

      Parameters

      Returns Promise<GeoLeafConfig>

      await GeoLeaf.Config.loadUrl("../data/config.json", {
      headers: { Authorization: "Bearer token" },
      });