/** * @deijose/nix-ionic / setup.ts — v2 modular setup * * Architecture (Nix Ionic 2): * * initializeNixIonic(options) — configures Ionic Core once; returns a * handle with status/diagnostics. Safe to * call again (no-op after first init, but * validates incompatible config changes). * * registerIonicComponents(...definers) — incremental & idempotent. Always * registers new definers, skips already- * registered custom elements. Works for * lazy route loading. * * registerIonicons(map) — incremental with collision diagnostics. * Merges new icons into the global set; * warns on name collisions. * * setupNixIonic(options) — backward-compatible facade that calls all * three. Existing apps work unchanged. * * Key changes vs v1.x: * - No more `isInitialized` blocking: `registerIonicComponents` and * `registerIonicons` are always incremental. * - No `unpkg@latest` default asset path: uses official `setAssetPath` from * ionicons. CDN is opt-in only. * - SSR-safe: no `window` access at module load; guards in each function. * - Returns a handle with diagnostics from `initializeNixIonic`. */ import { addIcons, setAssetPath } from "ionicons"; export type ComponentDefiner = () => void; export type IconDefinitionMap = Record; export interface SetupNixIonicOptions { /** @deprecated Use `icons` mode in `initializeNixIonic` instead. */ iconAssetPath?: string; components?: ComponentDefiner[]; icons?: IconDefinitionMap; } export interface InitializeOptions { /** * Icon asset strategy: * - "inline" (default): icons are inlined via addIcons; no remote fetch. * - "assets": use setAssetPath to a local URL; icons fetched on demand. * - object with `mode: "assets"` and `path` for explicit local path. */ icons?: "inline" | "assets" | { mode: "assets"; path: string; }; /** Ionic mode override: "ios" | "md" | undefined (auto-detect). */ mode?: "ios" | "md"; } export interface SetupHandle { /** True if this call performed the initialization; false if already init. */ readonly initialized: boolean; /** Diagnostics collected during initialization. */ readonly diagnostics: string[]; } /** * Initialize Ionic Core for Nix.js. Configures the runtime once. * * Subsequent calls are no-ops for the core init, but `registerIonicComponents` * and `registerIonicons` remain incremental regardless. * * Returns a handle with diagnostics. */ export declare function initializeNixIonic(options?: InitializeOptions): SetupHandle; /** * Register additional Ionic custom element definers. Incremental and * idempotent — always processes new definers, safe to call from lazy routes. * * @example * ```ts * // In a lazy route module: * import { defineCustomElement as defineIonDatetime } from "@ionic/core/components/ion-datetime.js"; * registerIonicComponents(defineIonDatetime); * ``` */ export declare function registerIonicComponents(...definers: ComponentDefiner[]): void; /** * Register additional Ionicons by name → SVG string mapping. Incremental * with collision diagnostics. * * @example * ```ts * import { registerIonicons } from "@deijose/nix-ionic"; * import { home, homeOutline } from "ionicons/icons"; * * registerIonicons({ home, "home-outline": homeOutline }); * ``` */ export declare function registerIonicons(map: IconDefinitionMap): void; /** * Backward-compatible facade. Calls `initializeNixIonic`, then registers * any extra components and icons passed via options. * * Existing v1.x apps work unchanged. New apps should prefer the granular * functions (`initializeNixIonic` + `registerIonicComponents` + `registerIonicons`) * for lazy loading and HMR support. * * @deprecated Prefer `initializeNixIonic` + `registerIonicComponents` + `registerIonicons` for new code. */ export declare function setupNixIonic(options?: SetupNixIonicOptions): void; export { addIcons, setAssetPath };