eleva 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/eleva-plugins.cjs +25 -21
- package/dist/eleva-plugins.cjs.map +1 -1
- package/dist/eleva-plugins.js +25 -21
- package/dist/eleva-plugins.js.map +1 -1
- package/dist/eleva-plugins.umd.js +25 -21
- package/dist/eleva-plugins.umd.js.map +1 -1
- package/dist/eleva-plugins.umd.min.js +1 -1
- package/dist/eleva-plugins.umd.min.js.map +1 -1
- package/dist/eleva.cjs +9 -13
- package/dist/eleva.cjs.map +1 -1
- package/dist/eleva.d.cts +4 -15
- package/dist/eleva.d.cts.map +1 -1
- package/dist/eleva.d.ts +4 -15
- package/dist/eleva.d.ts.map +1 -1
- package/dist/eleva.js +9 -13
- package/dist/eleva.js.map +1 -1
- package/dist/eleva.umd.js +9 -13
- package/dist/eleva.umd.js.map +1 -1
- package/dist/eleva.umd.min.js +1 -1
- package/dist/eleva.umd.min.js.map +1 -1
- package/dist/plugins/attr.cjs +2 -2
- package/dist/plugins/attr.cjs.map +1 -1
- package/dist/plugins/attr.js +2 -2
- package/dist/plugins/attr.js.map +1 -1
- package/dist/plugins/attr.umd.js +2 -2
- package/dist/plugins/attr.umd.js.map +1 -1
- package/dist/plugins/attr.umd.min.js +1 -1
- package/dist/plugins/attr.umd.min.js.map +1 -1
- package/dist/plugins/router.cjs +23 -19
- package/dist/plugins/router.cjs.map +1 -1
- package/dist/plugins/router.js +23 -19
- package/dist/plugins/router.js.map +1 -1
- package/dist/plugins/router.umd.js +23 -19
- package/dist/plugins/router.umd.js.map +1 -1
- package/dist/plugins/router.umd.min.js +1 -1
- package/dist/plugins/router.umd.min.js.map +1 -1
- package/dist/plugins/store.cjs +2 -2
- package/dist/plugins/store.cjs.map +1 -1
- package/dist/plugins/store.js +2 -2
- package/dist/plugins/store.js.map +1 -1
- package/dist/plugins/store.umd.js +2 -2
- package/dist/plugins/store.umd.js.map +1 -1
- package/dist/plugins/store.umd.min.js +1 -1
- package/dist/plugins/store.umd.min.js.map +1 -1
- package/package.json +5 -5
- package/src/core/Eleva.js +4 -11
- package/src/modules/TemplateEngine.js +3 -3
- package/src/plugins/Attr.js +1 -1
- package/src/plugins/Router.js +24 -21
- package/src/plugins/Store.js +1 -1
- package/types/core/Eleva.d.ts +2 -13
- package/types/core/Eleva.d.ts.map +1 -1
- package/types/modules/TemplateEngine.d.ts +1 -1
- package/types/modules/TemplateEngine.d.ts.map +1 -1
- package/types/plugins/Router.d.ts.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.umd.min.js","sources":["../../src/plugins/Router.js"],"sourcesContent":["\"use strict\";\n\n/**\n * @module eleva/plugins/router\n * @fileoverview Client-side router plugin with hash, history, and query modes,\n * navigation guards, and lifecycle hooks.\n */\n\n// ============================================================================\n// TYPE DEFINITIONS\n// ============================================================================\n\n// -----------------------------------------------------------------------------\n// External Type Imports\n// -----------------------------------------------------------------------------\n\n/**\n * Type imports from the Eleva core library.\n * @typedef {import('eleva').Eleva} Eleva\n * @typedef {import('eleva').ComponentDefinition} ComponentDefinition\n * @typedef {import('eleva').Emitter} Emitter\n * @typedef {import('eleva').MountResult} MountResult\n * @typedef {import('eleva').UnsubscribeFunction} UnsubscribeFunction\n */\n\n/**\n * Generic type import.\n * @template T\n * @typedef {import('eleva').Signal<T>} Signal\n */\n\n// -----------------------------------------------------------------------------\n// Router Events\n// -----------------------------------------------------------------------------\n\n/**\n * Fired when the router initialization completes successfully.\n * @event router:ready\n * @type {Router}\n */\n\n/**\n * Fired when an error occurs during navigation or route handling.\n * @event router:error\n * @type {Error}\n */\n\n/**\n * Fired when no matching route is found for the requested path.\n * @event router:notFound\n * @type {{to: RouteLocation, from: RouteLocation | null, path: string}}\n */\n\n/**\n * Fired before guards run, allowing plugins to block or redirect navigation.\n * @event router:beforeEach\n * @type {NavigationContext}\n */\n\n/**\n * Fired before component resolution, allowing plugins to modify the resolve context.\n * @event router:beforeResolve\n * @type {ResolveContext}\n */\n\n/**\n * Fired after components are resolved successfully.\n * @event router:afterResolve\n * @type {ResolveContext}\n */\n\n/**\n * Fired after leaving the previous route.\n * @event router:afterLeave\n * @type {{to: RouteLocation, from: RouteLocation}}\n */\n\n/**\n * Fired before DOM rendering begins.\n * @event router:beforeRender\n * @type {RenderContext}\n */\n\n/**\n * Fired after DOM rendering completes.\n * @event router:afterRender\n * @type {RenderContext}\n */\n\n/**\n * Fired after render for scroll behavior handling.\n * @event router:scroll\n * @type {ScrollContext}\n */\n\n/**\n * Fired after entering the new route.\n * @event router:afterEnter\n * @type {{to: RouteLocation, from: RouteLocation | null}}\n */\n\n/**\n * Fired after navigation completes successfully.\n * @event router:afterEach\n * @type {{to: RouteLocation, from: RouteLocation | null}}\n */\n\n/**\n * Fired when a route is dynamically added.\n * @event router:routeAdded\n * @type {RouteDefinition}\n */\n\n/**\n * Fired when a route is dynamically removed.\n * @event router:routeRemoved\n * @type {RouteDefinition}\n */\n\n// -----------------------------------------------------------------------------\n// Router Data Types\n// -----------------------------------------------------------------------------\n\n/**\n * The routing mode determines how the router manages URL state.\n * - `hash`: Uses URL hash (e.g., `/#/path`) - works without server config\n * - `history`: Uses HTML5 History API (e.g., `/path`) - requires server config\n * - `query`: Uses query parameters (e.g., `?view=/path`) - useful for embedded apps\n * @typedef {'hash' | 'history' | 'query'} RouterMode\n */\n\n/**\n * Route parameters extracted from the URL path.\n * @typedef {Record<string, string>} RouteParams\n * @description Key-value pairs extracted from dynamic route segments (e.g., `/users/:id` → `{ id: '123' }`).\n */\n\n/**\n * Query parameters from the URL query string.\n * @typedef {Record<string, string>} QueryParams\n * @description Key-value pairs from the URL query string (e.g., `?page=1&sort=name`).\n */\n\n/**\n * Navigation input parameters supporting multiple value types.\n * @typedef {Record<string, string | number | boolean>} NavigationParams\n * @description Parameters passed to navigation functions, automatically converted to strings in URLs.\n */\n\n/**\n * Function signature for programmatic navigation.\n * @typedef {(location: string | NavigationTarget, params?: NavigationParams) => Promise<boolean>} NavigateFunction\n * @description Returns true if navigation succeeded, false if blocked by a guard.\n */\n\n/**\n * Router configuration options.\n * @typedef {Object} RouterOptions\n * @property {RouterMode} [mode='hash']\n * The routing mode to use.\n * @property {string} [queryParam='view']\n * Query parameter name for 'query' mode.\n * @property {string} [viewSelector='view']\n * Base selector for the view element.\n * @property {string} mount\n * CSS selector for the mount point element.\n * @property {RouteDefinition[]} routes\n * Array of route definitions.\n * @property {RouteComponent} [globalLayout]\n * Default layout for all routes.\n * @property {NavigationGuard} [onBeforeEach]\n * Global navigation guard.\n * @property {boolean} [autoStart=true]\n * Whether to start the router automatically.\n * @description Configuration options for the Router plugin.\n */\n\n/**\n * Object describing a navigation target for `router.navigate()`.\n * @typedef {Object} NavigationTarget\n * @property {string} path\n * The target path (can include params like '/users/:id').\n * @property {NavigationParams} [params]\n * Route parameters to inject.\n * @property {NavigationParams} [query]\n * Query parameters to append.\n * @property {boolean} [replace=false]\n * Whether to replace current history entry.\n * @property {unknown} [state]\n * History state to pass.\n * @description Object describing a navigation target for `router.navigate()`.\n */\n\n/**\n * Saved scroll position.\n * @typedef {Object} ScrollPosition\n * @property {number} x\n * Horizontal scroll position.\n * @property {number} y\n * Vertical scroll position.\n * @description Represents a saved scroll position.\n */\n\n/**\n * Internal representation of a parsed route path segment.\n * @typedef {Object} RouteSegment\n * @property {'static' | 'param'} type\n * The segment type.\n * @property {string} [value]\n * The segment value (static segments).\n * @property {string} [name]\n * The parameter name (param segments).\n * @description Internal representation of a parsed route path segment.\n * @private\n */\n\n/**\n * Result of matching a path against route definitions.\n * @typedef {Object} RouteMatch\n * @property {RouteDefinition} route\n * The matched route definition.\n * @property {RouteParams} params\n * The extracted route parameters.\n * @description Result of matching a path against route definitions.\n * @private\n */\n\n/**\n * Arbitrary metadata attached to routes for use in guards and components.\n * @typedef {Record<string, unknown>} RouteMeta\n * @description Common properties include:\n * - `requiresAuth: boolean` - Whether the route requires authentication\n * - `title: string` - Page title for the route\n * - `roles: string[]` - Required user roles\n * @example\n * {\n * path: '/admin',\n * component: AdminPage,\n * meta: { requiresAuth: true, roles: ['admin'], title: 'Admin Dashboard' }\n * }\n */\n\n/**\n * Interface for the router's error handling system.\n * @typedef {Object} RouterErrorHandler\n * @property {(error: Error, context: string, details?: Record<string, unknown>) => void} handle\n * Throws a formatted error.\n * @property {(message: string, details?: Record<string, unknown>) => void} warn\n * Logs a warning.\n * @property {(message: string, error: Error, details?: Record<string, unknown>) => void} log\n * Logs an error without throwing.\n * @description Interface for the router's error handling system.\n */\n\n// -----------------------------------------------------------------------------\n// Event Callback Types\n// -----------------------------------------------------------------------------\n\n/**\n * Callback for `router:beforeEach` event.\n * @callback NavigationContextCallback\n * @param {NavigationContext} context\n * The navigation context (can be modified to block/redirect).\n * @returns {void | Promise<void>}\n * @description Modify context to control navigation flow.\n */\n\n/**\n * Callback for `router:beforeResolve` and `router:afterResolve` events.\n * @callback ResolveContextCallback\n * @param {ResolveContext} context\n * The resolve context (can be modified to block/redirect).\n * @returns {void | Promise<void>}\n * @description Callback for `router:beforeResolve` and `router:afterResolve` events.\n */\n\n/**\n * Callback for `router:beforeRender` and `router:afterRender` events.\n * @callback RenderContextCallback\n * @param {RenderContext} context\n * The render context.\n * @returns {void | Promise<void>}\n * @description Callback for `router:beforeRender` and `router:afterRender` events.\n */\n\n/**\n * Callback for `router:scroll` event.\n * @callback ScrollContextCallback\n * @param {ScrollContext} context\n * The scroll context with saved position info.\n * @returns {void | Promise<void>}\n * @description Use to implement custom scroll behavior.\n */\n\n/**\n * Callback for `router:afterEnter`, `router:afterLeave`, `router:afterEach` events.\n * @callback RouteChangeCallback\n * @param {RouteLocation} to\n * The target route location.\n * @param {RouteLocation | null} from\n * The source route location.\n * @returns {void | Promise<void>}\n * @description Callback for `router:afterEnter`, `router:afterLeave`, `router:afterEach` events.\n */\n\n/**\n * Router context injected into component setup as `ctx.router`.\n * @typedef {Object} RouterContext\n * @property {NavigateFunction} navigate\n * Programmatic navigation function.\n * @property {Signal<RouteLocation | null>} current\n * Reactive signal for current route.\n * @property {Signal<RouteLocation | null>} previous\n * Reactive signal for previous route.\n * @property {RouteParams} params\n * Current route params (getter).\n * @property {QueryParams} query\n * Current route query (getter).\n * @property {string} path\n * Current route path (getter).\n * @property {string} fullUrl\n * Current routed URL string (getter).\n * @property {RouteMeta} meta\n * Current route meta (getter).\n * @description Injected into component setup as `ctx.router`.\n */\n\n/**\n * Callback for `router:error` event.\n * @callback RouterErrorCallback\n * @param {Error} error\n * The error that occurred.\n * @param {RouteLocation} [to]\n * The target route (if available).\n * @param {RouteLocation | null} [from]\n * The source route (if available).\n * @returns {void | Promise<void>}\n * @description Callback for `router:error` event.\n */\n\n/**\n * Callback for `router:ready` event.\n * @callback RouterReadyCallback\n * @param {Router} router\n * The router instance.\n * @returns {void | Promise<void>}\n * @description Callback for `router:ready` event.\n */\n\n/**\n * Callback for `router:routeAdded` event.\n * @callback RouteAddedCallback\n * @param {RouteDefinition} route\n * The added route definition.\n * @returns {void | Promise<void>}\n * @description Callback for `router:routeAdded` event.\n */\n\n/**\n * Callback for `router:routeRemoved` event.\n * @callback RouteRemovedCallback\n * @param {RouteDefinition} route\n * The removed route definition.\n * @returns {void | Promise<void>}\n * @description Callback for `router:routeRemoved` event.\n */\n\n// ============================================================================\n// CORE IMPLEMENTATION\n// ============================================================================\n\n/**\n * Simple error handler for the core router.\n * @private\n */\nconst CoreErrorHandler = {\n /**\n * Handles router errors with basic formatting.\n * @param {Error} error - The error to handle.\n * @param {string} context - The context where the error occurred.\n * @param {Record<string, unknown>} details - Additional error details.\n * @throws {Error} The formatted error.\n */\n handle(error, context, details = {}) {\n const message = `[ElevaRouter] ${context}: ${error.message}`;\n const formattedError = new Error(message);\n\n // Preserve original error details\n formattedError.originalError = error;\n formattedError.context = context;\n formattedError.details = details;\n\n console.error(message, { error, context, details });\n throw formattedError;\n },\n\n /**\n * Logs a warning without throwing an error.\n * @param {string} message - The warning message.\n * @param {Record<string, unknown>} details - Additional warning details.\n */\n warn(message, details = {}) {\n console.warn(`[ElevaRouter] ${message}`, details);\n },\n\n /**\n * Logs an error without throwing.\n * @param {string} message - The error message.\n * @param {Error} error - The original error.\n * @param {Record<string, unknown>} details - Additional error details.\n */\n log(message, error, details = {}) {\n console.error(`[ElevaRouter] ${message}`, { error, details });\n },\n};\n\n/**\n * Represents the current or target location in the router.\n * @typedef {Object} RouteLocation\n * @property {string} path\n * The path of the route (e.g., '/users/123').\n * @property {QueryParams} query\n * Query parameters as key-value pairs.\n * @property {string} fullUrl\n * The routed URL string (path plus query).\n * @property {RouteParams} params\n * Dynamic route parameters.\n * @property {RouteMeta} meta\n * Metadata associated with the matched route.\n * @property {string} [name]\n * The optional name of the matched route.\n * @property {RouteDefinition} matched\n * The raw route definition that was matched.\n * @description Represents the current or target location in the router.\n */\n\n/**\n * Return value of a navigation guard.\n * - `true` or `undefined/void`: Allow navigation\n * - `false`: Abort navigation\n * - `string`: Redirect to path\n * - `NavigationTarget`: Redirect with options\n * @typedef {boolean | string | NavigationTarget | void} NavigationGuardResult\n */\n\n/**\n * Navigation guard function that controls navigation flow.\n * @callback NavigationGuard\n * @param {RouteLocation} to\n * The target route location.\n * @param {RouteLocation | null} from\n * The source route location (null on initial).\n * @returns {NavigationGuardResult | Promise<NavigationGuardResult>}\n * @description A function that controls navigation flow. Runs before navigation is confirmed.\n * @example\n * // Simple auth guard\n * const authGuard = (to, from) => {\n * if (to.meta.requiresAuth && !isLoggedIn()) {\n * return '/login'; // Redirect\n * }\n * // Allow navigation (implicit return undefined)\n * };\n */\n\n/**\n * Navigation hook for side effects. Does not affect navigation flow.\n * @callback NavigationHook\n * @param {RouteLocation} to\n * The target route location.\n * @param {RouteLocation | null} from\n * The source route location.\n * @returns {void | Promise<void>}\n * @description A lifecycle hook for side effects. Does not affect navigation flow.\n * @example\n * // Analytics hook\n * const analyticsHook = (to, from) => {\n * analytics.trackPageView(to.path);\n * };\n */\n\n/**\n * Interface for router plugins.\n * @typedef {Object} RouterPlugin\n * @property {string} name\n * Unique plugin identifier.\n * @property {string} [version]\n * Plugin version (recommended to match router version).\n * @property {(router: Router, options?: Record<string, unknown>) => void} install\n * Installation function.\n * @property {(router: Router) => void | Promise<void>} [destroy]\n * Cleanup function called on router.destroy().\n * @description Interface for router plugins. Plugins can extend router functionality.\n * @example\n * const AnalyticsPlugin = {\n * name: 'analytics',\n * version: '1.0.0',\n * install(router, options) {\n * router.emitter.on('router:afterEach', (to, from) => {\n * analytics.track(to.path);\n * });\n * }\n * };\n */\n\n/**\n * Context object for navigation events that plugins can modify.\n * @typedef {Object} NavigationContext\n * @property {RouteLocation} to\n * The target route location.\n * @property {RouteLocation | null} from\n * The source route location.\n * @property {boolean} cancelled\n * Whether navigation has been cancelled.\n * @property {string | NavigationTarget | null} redirectTo\n * Redirect target if set.\n * @description Passed to navigation events. Plugins can modify to control navigation flow.\n */\n\n/**\n * Context object for component resolution events.\n * @typedef {Object} ResolveContext\n * @property {RouteLocation} to\n * The target route location.\n * @property {RouteLocation | null} from\n * The source route location.\n * @property {RouteDefinition} route\n * The matched route definition.\n * @property {ComponentDefinition | null} layoutComponent\n * The resolved layout component (available in afterResolve).\n * @property {ComponentDefinition | null} pageComponent\n * The resolved page component (available in afterResolve).\n * @property {boolean} cancelled\n * Whether navigation has been cancelled.\n * @property {string | NavigationTarget | null} redirectTo\n * Redirect target if set.\n * @description Passed to component resolution events.\n */\n\n/**\n * Context object for render events.\n * @typedef {Object} RenderContext\n * @property {RouteLocation} to\n * The target route location.\n * @property {RouteLocation | null} from\n * The source route location.\n * @property {ComponentDefinition | null} layoutComponent\n * The layout component being rendered.\n * @property {ComponentDefinition} pageComponent\n * The page component being rendered.\n * @description Passed to render events.\n */\n\n/**\n * Context object for scroll events.\n * @typedef {Object} ScrollContext\n * @property {RouteLocation} to\n * The target route location.\n * @property {RouteLocation | null} from\n * The source route location.\n * @property {{x: number, y: number} | null} savedPosition\n * Saved position (back/forward nav).\n * @description Passed to scroll events for plugins to handle scroll behavior.\n */\n\n/**\n * A component that can be rendered for a route.\n * - `string`: Name of a registered component\n * - `ComponentDefinition`: Inline component definition\n * - `() => ComponentDefinition`: Factory function returning a component\n * - `() => Promise<ComponentDefinition>`: Async factory function\n * - `() => Promise<{default: ComponentDefinition}>`: Lazy-loaded module (e.g., `() => import('./Page.js')`)\n * @typedef {string | ComponentDefinition | (() => ComponentDefinition | Promise<ComponentDefinition | {default: ComponentDefinition}>)} RouteComponent\n */\n\n/**\n * Defines a route in the application.\n * @typedef {Object} RouteDefinition\n * @property {string} path\n * URL path pattern. Supports:\n * - Static: '/about'\n * - Dynamic params: '/users/:id'\n * - Wildcard: '*' (catch-all, conventionally last)\n * @property {RouteComponent} component\n * The component to render for this route.\n * @property {RouteComponent} [layout]\n * Optional layout component to wrap the route component.\n * @property {string} [name]\n * Optional route name for programmatic navigation.\n * @property {RouteMeta} [meta]\n * Optional metadata (auth flags, titles, etc.).\n * @property {NavigationGuard} [beforeEnter]\n * Route-specific guard before entering.\n * @property {NavigationHook} [afterEnter]\n * Hook after entering and component is mounted.\n * @property {NavigationGuard} [beforeLeave]\n * Guard before leaving this route.\n * @property {NavigationHook} [afterLeave]\n * Hook after leaving and component is unmounted.\n * @property {RouteSegment[]} [segments]\n * Internal: parsed path segments (added by router).\n * @description Defines a route in the application.\n * @note Nested routes are not supported. Use shared layouts with flat routes instead.\n * @example\n * // Static route\n * { path: '/about', component: AboutPage }\n *\n * // Dynamic route with params\n * { path: '/users/:id', component: UserPage, meta: { requiresAuth: true } }\n *\n * // Lazy-loaded route with layout\n * {\n * path: '/dashboard',\n * component: () => import('./Dashboard.js'),\n * layout: DashboardLayout,\n * beforeEnter: (to, from) => isLoggedIn() || '/login'\n * }\n *\n * // Catch-all 404 route (conventionally last)\n * { path: '*', component: NotFoundPage }\n */\n\n/**\n * @class 🛤️ Router\n * @classdesc A powerful, reactive, and flexible Router Plugin for Eleva.\n * This class manages all routing logic, including state, navigation, and rendering.\n *\n * ## Features\n * - Multiple routing modes (hash, history, query)\n * - Reactive route state via Signals\n * - Navigation guards and lifecycle hooks\n * - Lazy-loaded components\n * - Layout system\n * - Plugin architecture\n * - Scroll position management\n *\n * ## Events Reference\n * | Event | Callback Type | Can Block | Description |\n * |-------|--------------|-----------|-------------|\n * | `router:ready` | {@link RouterReadyCallback} | No | Router initialized |\n * | `router:beforeEach` | {@link NavigationContextCallback} | Yes | Before guards run |\n * | `router:beforeResolve` | {@link ResolveContextCallback} | Yes | Before component loading |\n * | `router:afterResolve` | {@link ResolveContextCallback} | No | After components loaded |\n * | `router:afterLeave` | {@link RouteChangeCallback} | No | After leaving route |\n * | `router:beforeRender` | {@link RenderContextCallback} | No | Before DOM update |\n * | `router:afterRender` | {@link RenderContextCallback} | No | After DOM update |\n * | `router:scroll` | {@link ScrollContextCallback} | No | For scroll behavior |\n * | `router:afterEnter` | {@link RouteChangeCallback} | No | After entering route |\n * | `router:afterEach` | {@link RouteChangeCallback} | No | Navigation complete |\n * | `router:error` | {@link RouterErrorCallback} | No | Navigation error |\n * | `router:routeAdded` | {@link RouteAddedCallback} | No | Dynamic route added |\n * | `router:routeRemoved` | {@link RouteRemovedCallback} | No | Dynamic route removed |\n *\n * ## Reactive Signals\n * - `currentRoute: Signal<RouteLocation | null>` - Current route info\n * - `previousRoute: Signal<RouteLocation | null>` - Previous route info\n * - `currentParams: Signal<RouteParams>` - Current route params\n * - `currentQuery: Signal<QueryParams>` - Current query params\n * - `currentLayout: Signal<MountResult | null>` - Mounted layout instance\n * - `currentView: Signal<MountResult | null>` - Mounted view instance\n * - `isReady: Signal<boolean>` - Router readiness state\n *\n * @note Internal API Access Policy:\n * As a core Eleva plugin, the Router may access internal Eleva APIs (prefixed with _)\n * such as `eleva._components`. This is intentional and these internal APIs are\n * considered stable for official plugins. Third-party plugins should avoid\n * accessing internal APIs as they may change without notice.\n *\n * @example\n * // Basic setup\n * const router = new Router(eleva, {\n * mode: 'hash',\n * mount: '#app',\n * routes: [\n * { path: '/', component: HomePage },\n * { path: '/users/:id', component: UserPage },\n * { path: '*', component: NotFoundPage }\n * ]\n * });\n *\n * // Start router\n * await router.start();\n *\n * // Navigate programmatically\n * const success = await router.navigate('/users/123');\n *\n * // Watch for route changes\n * router.currentRoute.watch((route) => {\n * document.title = route?.meta?.title || 'My App';\n * });\n *\n * @private\n */\nclass Router {\n /**\n * Creates an instance of the Router.\n * @param {Eleva} eleva - The Eleva framework instance.\n * @param {RouterOptions} options - The configuration options for the router.\n * @throws {Error} If the routing mode is invalid.\n */\n constructor(eleva, options = {}) {\n /** @type {Eleva} The Eleva framework instance. */\n this.eleva = eleva;\n\n /** @type {RouterOptions} The merged router options. */\n this.options = {\n mode: \"hash\",\n queryParam: \"view\",\n viewSelector: \"view\",\n ...options,\n };\n\n /** @private @type {RouteDefinition[]} The processed list of route definitions. */\n this.routes = this._processRoutes(options.routes || []);\n\n /** @private @type {Emitter} The shared Eleva event emitter for global hooks. */\n this.emitter = this.eleva.emitter;\n\n /** @private @type {boolean} A flag indicating if the router has been started. */\n this.isStarted = false;\n\n /** @private @type {boolean} A flag to prevent navigation loops from history events. */\n this._isNavigating = false;\n\n /** @private @type {number} Counter for tracking navigation operations to prevent race conditions. */\n this._navigationId = 0;\n\n /** @private @type {UnsubscribeFunction[]} A collection of cleanup functions for event listeners. */\n this.eventListeners = [];\n\n /** @type {Signal<RouteLocation | null>} A reactive signal holding the current route's information. */\n this.currentRoute = new this.eleva.signal(null);\n\n /** @type {Signal<RouteLocation | null>} A reactive signal holding the previous route's information. */\n this.previousRoute = new this.eleva.signal(null);\n\n /** @type {Signal<RouteParams>} A reactive signal holding the current route's parameters. */\n this.currentParams = new this.eleva.signal({});\n\n /** @type {Signal<QueryParams>} A reactive signal holding the current route's query parameters. */\n this.currentQuery = new this.eleva.signal({});\n\n /** @type {Signal<MountResult | null>} A reactive signal for the currently mounted layout instance. */\n this.currentLayout = new this.eleva.signal(null);\n\n /** @type {Signal<MountResult | null>} A reactive signal for the currently mounted view (page) instance. */\n this.currentView = new this.eleva.signal(null);\n\n /** @type {Signal<boolean>} A reactive signal indicating if the router is ready (started and initial navigation complete). */\n this.isReady = new this.eleva.signal(false);\n\n /** @private @type {Map<string, RouterPlugin>} Map of registered plugins by name. */\n this.plugins = new Map();\n\n /** @private @type {NavigationGuard[]} Array of global before-each navigation guards. */\n this._beforeEachGuards = [];\n\n // If onBeforeEach was provided in options, add it to the guards array\n if (options.onBeforeEach) {\n this._beforeEachGuards.push(options.onBeforeEach);\n }\n\n /** @type {RouterErrorHandler} The error handler instance. Can be overridden by plugins. */\n this.errorHandler = CoreErrorHandler;\n\n /** @private @type {Map<string, {x: number, y: number}>} Saved scroll positions by route path. */\n this._scrollPositions = new Map();\n\n this._validateOptions();\n }\n\n /**\n * Validates the provided router options.\n * @private\n * @throws {Error} If the routing mode is invalid.\n */\n _validateOptions() {\n if (![\"hash\", \"query\", \"history\"].includes(this.options.mode)) {\n this.errorHandler.handle(\n new Error(\n `Invalid routing mode: ${this.options.mode}. Must be \"hash\", \"query\", or \"history\".`\n ),\n \"Configuration validation failed\"\n );\n }\n }\n\n /**\n * Pre-processes route definitions to parse their path segments for efficient matching.\n * @private\n * @param {RouteDefinition[]} routes - The raw route definitions.\n * @returns {RouteDefinition[]} The processed routes.\n */\n _processRoutes(routes) {\n const processedRoutes = [];\n for (const route of routes) {\n try {\n processedRoutes.push({\n ...route,\n segments: this._parsePathIntoSegments(route.path),\n });\n } catch (error) {\n this.errorHandler.warn(\n `Invalid path in route definition \"${route.path || \"undefined\"}\": ${error.message}`,\n { route, error }\n );\n }\n }\n return processedRoutes;\n }\n\n /**\n * Parses a route path string into an array of static and parameter segments.\n * @private\n * @param {string} path - The path pattern to parse.\n * @returns {{type: 'static' | 'param', value?: string, name?: string}[]} An array of segment objects.\n * @throws {Error} If the route path is not a valid string.\n */\n _parsePathIntoSegments(path) {\n if (!path || typeof path !== \"string\") {\n this.errorHandler.handle(\n new Error(\"Route path must be a non-empty string\"),\n \"Path parsing failed\",\n { path }\n );\n }\n\n const normalizedPath = path.replace(/\\/+/g, \"/\").replace(/\\/$/, \"\") || \"/\";\n\n if (normalizedPath === \"/\") {\n return [];\n }\n\n return normalizedPath\n .split(\"/\")\n .filter(Boolean)\n .map((segment) => {\n if (segment.startsWith(\":\")) {\n const paramName = segment.substring(1);\n if (!paramName) {\n this.errorHandler.handle(\n new Error(`Invalid parameter segment: ${segment}`),\n \"Path parsing failed\",\n { segment, path }\n );\n }\n return { type: \"param\", name: paramName };\n }\n return { type: \"static\", value: segment };\n });\n }\n\n /**\n * Finds the view element within a container using multiple selector strategies.\n * @private\n * @param {HTMLElement} container - The parent element to search within.\n * @returns {HTMLElement} The found view element or the container itself as a fallback.\n */\n _findViewElement(container) {\n const selector = this.options.viewSelector;\n return (\n container.querySelector(`#${selector}`) ||\n container.querySelector(`.${selector}`) ||\n container.querySelector(`[data-${selector}]`) ||\n container.querySelector(selector) ||\n container\n );\n }\n\n /**\n * Starts the router, initializes event listeners, and performs the initial navigation.\n * @returns {Promise<Router>} The router instance for method chaining.\n * @listens window:hashchange In hash mode, triggers route changes.\n * @listens window:popstate In history/query mode, triggers route changes.\n * @emits router:ready When initialization completes successfully.\n * @see destroy - Stop the router and clean up listeners.\n * @see navigate - Programmatically navigate to a route.\n *\n * @example\n * // Basic usage\n * await router.start();\n *\n * // Method chaining\n * await router.start().then(r => r.navigate('/home'));\n *\n * // Reactive readiness\n * router.isReady.watch((ready) => {\n * if (ready) console.log('Router is ready!');\n * });\n */\n async start() {\n if (this.isStarted) {\n this.errorHandler.warn(\"Router is already started\");\n return this;\n }\n if (typeof window === \"undefined\") {\n this.errorHandler.warn(\n \"Router start skipped: `window` object not available (SSR environment)\"\n );\n return this;\n }\n if (\n typeof document !== \"undefined\" &&\n !document.querySelector(this.options.mount)\n ) {\n this.errorHandler.warn(\n `Mount element \"${this.options.mount}\" was not found in the DOM. The router will not start.`,\n { mountSelector: this.options.mount }\n );\n return this;\n }\n const handler = () => this._handleRouteChange();\n if (this.options.mode === \"hash\") {\n window.addEventListener(\"hashchange\", handler);\n this.eventListeners.push(() =>\n window.removeEventListener(\"hashchange\", handler)\n );\n } else {\n window.addEventListener(\"popstate\", handler);\n this.eventListeners.push(() =>\n window.removeEventListener(\"popstate\", handler)\n );\n }\n this.isStarted = true;\n // Initial navigation is not a popstate event\n await this._handleRouteChange(false);\n // Set isReady to true after initial navigation completes\n this.isReady.value = true;\n await this.emitter.emit(\"router:ready\", this);\n return this;\n }\n\n /**\n * Stops the router and cleans up event listeners.\n * Unmounts the current layout instance if present.\n * @async\n * @returns {Promise<void>}\n * @see start - Restart the router after destroying.\n */\n async destroy() {\n if (!this.isStarted) return;\n\n // Clean up plugins\n for (const plugin of this.plugins.values()) {\n if (typeof plugin.destroy === \"function\") {\n try {\n await plugin.destroy(this);\n } catch (error) {\n this.errorHandler.log(`Plugin ${plugin.name} destroy failed`, error);\n }\n }\n }\n\n this.eventListeners.forEach((cleanup) => cleanup());\n this.eventListeners = [];\n if (this.currentLayout.value) {\n await this.currentLayout.value.unmount();\n }\n this.isStarted = false;\n this.isReady.value = false;\n }\n\n /**\n * Alias for destroy(). Stops the router and cleans up all resources.\n * Provided for semantic consistency (start/stop pattern).\n * @async\n * @returns {Promise<void>}\n *\n * @example\n * await router.start();\n * // ... later\n * await router.stop();\n */\n async stop() {\n return this.destroy();\n }\n\n /**\n * Programmatically navigates to a new route.\n * @async\n * @param {string | NavigationTarget} location - The target location as a path string or navigation target object.\n * @param {NavigationParams} [params] - Route parameters (only used when location is a string).\n * @returns {Promise<boolean>} True if navigation succeeded, false if blocked by guards or failed.\n * @emits router:error When navigation fails due to an exception.\n * @see start - Initialize the router before navigating.\n * @see currentRoute - Access the current route after navigation.\n *\n * @example\n * // Basic navigation\n * await router.navigate('/users/123');\n *\n * // Check if navigation succeeded\n * const success = await router.navigate('/protected');\n * if (!success) {\n * console.log('Navigation was blocked by a guard');\n * }\n *\n * // Navigate with options\n * await router.navigate({\n * path: '/users/:id',\n * params: { id: '123' },\n * query: { tab: 'profile' },\n * replace: true\n * });\n */\n async navigate(location, params = {}) {\n try {\n const target =\n typeof location === \"string\" ? { path: location, params } : location;\n let path = this._buildPath(target.path, target.params || {});\n const query = target.query || {};\n\n if (Object.keys(query).length > 0) {\n const queryString = new URLSearchParams(query).toString();\n if (queryString) path += `?${queryString}`;\n }\n\n if (this._isSameRoute(path, target.params, query)) {\n return true; // Already at this route, consider it successful\n }\n\n const navigationSuccessful = await this._proceedWithNavigation(path);\n\n if (navigationSuccessful) {\n // Increment navigation ID and capture it for this navigation\n const currentNavId = ++this._navigationId;\n this._isNavigating = true;\n\n const state = target.state || {};\n const replace = target.replace || false;\n const historyMethod = replace ? \"replaceState\" : \"pushState\";\n\n if (this.options.mode === \"hash\") {\n if (replace) {\n const newUrl = `${window.location.pathname}${window.location.search}#${path}`;\n window.history.replaceState(state, \"\", newUrl);\n } else {\n window.location.hash = path;\n }\n } else {\n const url =\n this.options.mode === \"query\" ? this._buildQueryUrl(path) : path;\n history[historyMethod](state, \"\", url);\n }\n\n // Only reset the flag if no newer navigation has started\n queueMicrotask(() => {\n if (this._navigationId === currentNavId) {\n this._isNavigating = false;\n }\n });\n }\n\n return navigationSuccessful;\n } catch (error) {\n this.errorHandler.log(\"Navigation failed\", error);\n await this.emitter.emit(\"router:error\", error);\n return false;\n }\n }\n\n /**\n * Builds a URL for query mode.\n * @private\n * @param {string} path - The path to set as the query parameter.\n * @returns {string} The full URL with the updated query string.\n */\n _buildQueryUrl(path) {\n const urlParams = new URLSearchParams(window.location.search);\n urlParams.set(this.options.queryParam, path.split(\"?\")[0]);\n return `${window.location.pathname}?${urlParams.toString()}`;\n }\n\n /**\n * Checks if the target route is identical to the current route.\n * @private\n * @param {string} path - The target path with query string.\n * @param {object} params - The target params.\n * @param {object} query - The target query.\n * @returns {boolean} True if the routes are the same.\n */\n _isSameRoute(path, params, query) {\n const current = this.currentRoute.value;\n if (!current) return false;\n const [targetPath, queryString] = path.split(\"?\");\n const targetQuery = query || this._parseQuery(queryString || \"\");\n return (\n current.path === targetPath &&\n JSON.stringify(current.params) === JSON.stringify(params || {}) &&\n JSON.stringify(current.query) === JSON.stringify(targetQuery)\n );\n }\n\n /**\n * Injects dynamic parameters into a path string.\n * Replaces `:param` placeholders with URL-encoded values from the params object.\n *\n * @private\n * @param {string} path - The path pattern containing `:param` placeholders.\n * @param {RouteParams} params - Key-value pairs to inject into the path.\n * @returns {string} The path with all parameters replaced.\n *\n * @example\n * this._buildPath('/users/:id/posts/:postId', { id: '123', postId: '456' });\n * // Returns: '/users/123/posts/456'\n */\n _buildPath(path, params) {\n let result = path;\n for (const [key, value] of Object.entries(params)) {\n // Fix: Handle special characters and ensure proper encoding\n const encodedValue = encodeURIComponent(String(value));\n result = result.replace(new RegExp(`:${key}\\\\b`, \"g\"), encodedValue);\n }\n return result;\n }\n\n /**\n * The handler for browser-initiated route changes (e.g., back/forward buttons).\n *\n * @private\n * @async\n * @param {boolean} [isPopState=true] - Whether this is a popstate event (back/forward navigation).\n * @returns {Promise<void>}\n * @emits router:error When route change handling fails.\n */\n async _handleRouteChange(isPopState = true) {\n if (this._isNavigating) return;\n\n try {\n const from = this.currentRoute.value;\n const toLocation = this._getCurrentLocation();\n\n const navigationSuccessful = await this._proceedWithNavigation(\n toLocation.fullUrl,\n isPopState\n );\n\n // If navigation was blocked by a guard, revert the URL change\n if (!navigationSuccessful && from) {\n this.navigate({ path: from.path, query: from.query, replace: true });\n }\n } catch (error) {\n this.errorHandler.log(\"Route change handling failed\", error, {\n currentUrl: typeof window !== \"undefined\" ? window.location.href : \"\",\n });\n await this.emitter.emit(\"router:error\", error);\n }\n }\n\n /**\n * Manages the core navigation lifecycle. Runs guards before committing changes.\n *\n * @private\n * @async\n * @param {string} fullPath - The full path (e.g., '/users/123?foo=bar') to navigate to.\n * @param {boolean} [isPopState=false] - Whether this navigation was triggered by popstate (back/forward).\n * @returns {Promise<boolean>} `true` if navigation succeeded, `false` if aborted.\n * @emits router:notFound When no matching route is found.\n * @emits router:beforeResolve Before component resolution (can block/redirect).\n * @emits router:afterResolve After components are resolved.\n * @emits router:afterLeave After leaving the previous route.\n * @emits router:beforeRender Before DOM rendering.\n * @emits router:afterRender After DOM rendering completes.\n * @emits router:scroll After render, for scroll behavior handling.\n * @emits router:afterEnter After entering the new route.\n * @emits router:afterEach After navigation completes successfully.\n * @emits router:error When an error occurs during navigation.\n * @see _runGuards - Guard execution.\n * @see _resolveComponents - Component resolution.\n * @see _render - DOM rendering.\n */\n async _proceedWithNavigation(fullPath, isPopState = false) {\n const from = this.currentRoute.value;\n const [path, queryString] = (fullPath || \"/\").split(\"?\");\n const toLocation = {\n path: path.startsWith(\"/\") ? path : `/${path}`,\n query: this._parseQuery(queryString),\n fullUrl: fullPath,\n };\n\n let toMatch = this._matchRoute(toLocation.path);\n\n if (!toMatch) {\n const notFoundRoute = this.routes.find((route) => route.path === \"*\");\n if (notFoundRoute) {\n toMatch = {\n route: notFoundRoute,\n params: {\n pathMatch: decodeURIComponent(toLocation.path.substring(1)),\n },\n };\n } else {\n await this.emitter.emit(\n \"router:error\",\n new Error(`Route not found: ${toLocation.path}`),\n toLocation,\n from\n );\n return false;\n }\n }\n\n const to = {\n ...toLocation,\n params: toMatch.params,\n meta: toMatch.route.meta || {},\n name: toMatch.route.name,\n matched: toMatch.route,\n };\n\n try {\n // 1. Run all *pre-navigation* guards.\n const canNavigate = await this._runGuards(to, from, toMatch.route);\n if (!canNavigate) return false;\n\n // 2. Save current scroll position before navigating away\n if (from && typeof window !== \"undefined\") {\n this._scrollPositions.set(from.path, {\n x: window.scrollX || window.pageXOffset || 0,\n y: window.scrollY || window.pageYOffset || 0,\n });\n }\n\n // 3. Emit beforeResolve event - plugins can show loading indicators\n /** @type {ResolveContext} */\n const resolveContext = {\n to,\n from,\n route: toMatch.route,\n layoutComponent: null,\n pageComponent: null,\n cancelled: false,\n redirectTo: null,\n };\n await this.emitter.emit(\"router:beforeResolve\", resolveContext);\n\n // Check if resolution was cancelled or redirected\n if (resolveContext.cancelled) return false;\n if (resolveContext.redirectTo) {\n this.navigate(resolveContext.redirectTo);\n return false;\n }\n\n // 4. Resolve async components *before* touching the DOM.\n const { layoutComponent, pageComponent } = await this._resolveComponents(\n toMatch.route\n );\n\n // 5. Emit afterResolve event - plugins can hide loading indicators\n resolveContext.layoutComponent = layoutComponent;\n resolveContext.pageComponent = pageComponent;\n await this.emitter.emit(\"router:afterResolve\", resolveContext);\n\n // 6. Unmount the previous view/layout.\n if (from) {\n const toLayout = toMatch.route.layout || this.options.globalLayout;\n const fromLayout = from.matched.layout || this.options.globalLayout;\n\n const tryUnmount = async (instance) => {\n if (!instance) return;\n\n try {\n await instance.unmount();\n } catch (error) {\n this.errorHandler.warn(\"Error during component unmount\", {\n error,\n instance,\n });\n }\n };\n\n if (toLayout !== fromLayout) {\n await tryUnmount(this.currentLayout.value);\n this.currentLayout.value = null;\n } else {\n await tryUnmount(this.currentView.value);\n this.currentView.value = null;\n }\n\n // Call `afterLeave` hook *after* the old component has been unmounted.\n if (from.matched.afterLeave) {\n await from.matched.afterLeave(to, from);\n }\n await this.emitter.emit(\"router:afterLeave\", to, from);\n }\n\n // 7. Update reactive state.\n this.previousRoute.value = from;\n this.currentRoute.value = to;\n this.currentParams.value = to.params || {};\n this.currentQuery.value = to.query || {};\n\n // 8. Emit beforeRender event - plugins can add transitions\n /** @type {RenderContext} */\n const renderContext = {\n to,\n from,\n layoutComponent,\n pageComponent,\n };\n await this.emitter.emit(\"router:beforeRender\", renderContext);\n\n // 9. Render the new components.\n await this._render(layoutComponent, pageComponent);\n\n // 10. Emit afterRender event - plugins can trigger animations\n await this.emitter.emit(\"router:afterRender\", renderContext);\n\n // 11. Emit scroll event - plugins can handle scroll restoration\n /** @type {ScrollContext} */\n const scrollContext = {\n to,\n from,\n savedPosition: isPopState\n ? this._scrollPositions.get(to.path) || null\n : null,\n };\n await this.emitter.emit(\"router:scroll\", scrollContext);\n\n // 12. Run post-navigation hooks.\n if (toMatch.route.afterEnter) {\n await toMatch.route.afterEnter(to, from);\n }\n await this.emitter.emit(\"router:afterEnter\", to, from);\n await this.emitter.emit(\"router:afterEach\", to, from);\n\n return true;\n } catch (error) {\n this.errorHandler.log(\"Error during navigation\", error, { to, from });\n await this.emitter.emit(\"router:error\", error, to, from);\n return false;\n }\n }\n\n /**\n * Executes all applicable navigation guards for a transition in order.\n * Guards are executed in the following order:\n * 1. Global beforeEach event (emitter-based, can block via context)\n * 2. Global beforeEach guards (registered via onBeforeEach)\n * 3. Route-specific beforeLeave guard (from the route being left)\n * 4. Route-specific beforeEnter guard (from the route being entered)\n *\n * @private\n * @param {RouteLocation} to - The target route location.\n * @param {RouteLocation | null} from - The current route location (null on initial navigation).\n * @param {RouteDefinition} route - The matched route definition.\n * @returns {Promise<boolean>} `false` if navigation should be aborted.\n * @emits router:beforeEach Before guards run (can block/redirect via context).\n */\n async _runGuards(to, from, route) {\n // Create navigation context that plugins can modify to block navigation\n /** @type {NavigationContext} */\n const navContext = {\n to,\n from,\n cancelled: false,\n redirectTo: null,\n };\n\n // Emit beforeEach event with context - plugins can block by modifying context\n await this.emitter.emit(\"router:beforeEach\", navContext);\n\n // Check if navigation was cancelled or redirected by event listeners\n if (navContext.cancelled) return false;\n if (navContext.redirectTo) {\n this.navigate(navContext.redirectTo);\n return false;\n }\n\n // Collect all guards in execution order\n const guards = [\n ...this._beforeEachGuards,\n ...(from && from.matched.beforeLeave ? [from.matched.beforeLeave] : []),\n ...(route.beforeEnter ? [route.beforeEnter] : []),\n ];\n\n for (const guard of guards) {\n const result = await guard(to, from);\n if (result === false) return false;\n if (typeof result === \"string\" || typeof result === \"object\") {\n this.navigate(result);\n return false;\n }\n }\n return true;\n }\n\n /**\n * Resolves a string component definition to a component object.\n * @private\n * @param {string} def - The component name to resolve.\n * @returns {ComponentDefinition} The resolved component.\n * @throws {Error} If the component is not registered.\n *\n * @note Core plugins (Router, Attr, Store) may access eleva._components\n * directly. This is intentional and stable for official Eleva plugins shipped\n * with the framework. Third-party plugins should use eleva.component() for\n * registration and avoid direct access to internal APIs.\n */\n _resolveStringComponent(def) {\n const componentDef = this.eleva._components.get(def);\n if (!componentDef) {\n this.errorHandler.handle(\n new Error(`Component \"${def}\" not registered.`),\n \"Component resolution failed\",\n {\n componentName: def,\n availableComponents: Array.from(this.eleva._components.keys()),\n }\n );\n }\n return componentDef;\n }\n\n /**\n * Resolves a function component definition to a component object.\n * @private\n * @async\n * @param {() => ComponentDefinition | Promise<ComponentDefinition | { default: ComponentDefinition }>} def - The function to resolve.\n * @returns {Promise<ComponentDefinition>} The resolved component.\n * @throws {Error} If the function fails to load the component.\n */\n async _resolveFunctionComponent(def) {\n try {\n const funcStr = def.toString();\n const isAsyncImport =\n funcStr.includes(\"import(\") || funcStr.startsWith(\"() =>\");\n\n const result = await def();\n return isAsyncImport ? result.default || result : result;\n } catch (error) {\n this.errorHandler.handle(\n new Error(`Failed to load async component: ${error.message}`),\n \"Component resolution failed\",\n { function: def.toString(), error }\n );\n }\n }\n\n /**\n * Validates a component definition object.\n * @private\n * @param {unknown} def - The component definition to validate.\n * @returns {ComponentDefinition} The validated component.\n * @throws {Error} If the component definition is invalid.\n */\n _validateComponentDefinition(def) {\n if (!def || typeof def !== \"object\") {\n this.errorHandler.handle(\n new Error(`Invalid component definition: ${typeof def}`),\n \"Component validation failed\",\n { definition: def }\n );\n }\n\n if (\n typeof def.template !== \"function\" &&\n typeof def.template !== \"string\"\n ) {\n this.errorHandler.handle(\n new Error(\"Component missing template property\"),\n \"Component validation failed\",\n { definition: def }\n );\n }\n\n return def;\n }\n\n /**\n * Resolves a component definition to a component object.\n * @private\n * @param {unknown} def - The component definition to resolve.\n * @returns {Promise<ComponentDefinition | null>} The resolved component or null.\n */\n async _resolveComponent(def) {\n if (def === null || def === undefined) {\n return null;\n }\n\n if (typeof def === \"string\") {\n return this._resolveStringComponent(def);\n }\n\n if (typeof def === \"function\") {\n return await this._resolveFunctionComponent(def);\n }\n\n if (def && typeof def === \"object\") {\n return this._validateComponentDefinition(def);\n }\n\n this.errorHandler.handle(\n new Error(`Invalid component definition: ${typeof def}`),\n \"Component resolution failed\",\n { definition: def }\n );\n }\n\n /**\n * Asynchronously resolves the layout and page components for a route.\n * @private\n * @async\n * @param {RouteDefinition} route - The route to resolve components for.\n * @returns {Promise<{layoutComponent: ComponentDefinition | null, pageComponent: ComponentDefinition}>}\n * @throws {Error} If page component cannot be resolved.\n */\n async _resolveComponents(route) {\n const effectiveLayout = route.layout || this.options.globalLayout;\n\n try {\n const [layoutComponent, pageComponent] = await Promise.all([\n this._resolveComponent(effectiveLayout),\n this._resolveComponent(route.component),\n ]);\n\n if (!pageComponent) {\n this.errorHandler.handle(\n new Error(\n `Page component is null or undefined for route: ${route.path}`\n ),\n \"Component resolution failed\",\n { route: route.path }\n );\n }\n\n return { layoutComponent, pageComponent };\n } catch (error) {\n this.errorHandler.log(\n `Error resolving components for route ${route.path}`,\n error,\n { route: route.path }\n );\n throw error;\n }\n }\n\n /**\n * Renders the components for the current route into the DOM.\n *\n * Rendering algorithm:\n * 1. Find the mount element using options.mount selector\n * 2. If layoutComponent exists:\n * a. Mount layout to mount element\n * b. Find view element within layout (using viewSelector)\n * c. Mount page component to view element\n * 3. If no layoutComponent:\n * a. Mount page component directly to mount element\n * b. Set currentLayout to null\n *\n * @private\n * @async\n * @param {ComponentDefinition | null} layoutComponent - The pre-loaded layout component.\n * @param {ComponentDefinition} pageComponent - The pre-loaded page component.\n * @returns {Promise<void>}\n * @throws {Error} If mount element is not found in the DOM.\n * @throws {Error} If component mounting fails (propagated from eleva.mount).\n */\n async _render(layoutComponent, pageComponent) {\n const mountEl = document.querySelector(this.options.mount);\n if (!mountEl) {\n this.errorHandler.handle(\n new Error(`Mount element \"${this.options.mount}\" not found.`),\n { mountSelector: this.options.mount }\n );\n }\n\n if (layoutComponent) {\n const layoutInstance = await this.eleva.mount(\n mountEl,\n this._wrapComponentWithChildren(layoutComponent)\n );\n this.currentLayout.value = layoutInstance;\n const viewEl = this._findViewElement(layoutInstance.container);\n const viewInstance = await this.eleva.mount(\n viewEl,\n this._wrapComponentWithChildren(pageComponent)\n );\n this.currentView.value = viewInstance;\n } else {\n const viewInstance = await this.eleva.mount(\n mountEl,\n this._wrapComponentWithChildren(pageComponent)\n );\n this.currentView.value = viewInstance;\n this.currentLayout.value = null;\n }\n }\n\n /**\n * Creates a getter function for router context properties.\n * @private\n * @param {string} property - The property name to access.\n * @param {unknown} defaultValue - The default value if property is undefined.\n * @returns {() => unknown} A getter function.\n */\n _createRouteGetter(property, defaultValue) {\n return () => this.currentRoute.value?.[property] ?? defaultValue;\n }\n\n /**\n * Wraps a component definition to inject router-specific context into its setup function.\n * @private\n * @param {ComponentDefinition} component - The component to wrap.\n * @returns {ComponentDefinition} The wrapped component definition.\n */\n _wrapComponent(component) {\n const originalSetup = component.setup;\n const self = this;\n\n return {\n ...component,\n async setup(ctx) {\n /** @type {RouterContext} */\n ctx.router = {\n navigate: self.navigate.bind(self),\n current: self.currentRoute,\n previous: self.previousRoute,\n\n // Route property getters\n get params() {\n return self._createRouteGetter(\"params\", {})();\n },\n get query() {\n return self._createRouteGetter(\"query\", {})();\n },\n get path() {\n return self._createRouteGetter(\"path\", \"/\")();\n },\n get fullUrl() {\n return self._createRouteGetter(\"fullUrl\", window.location.href)();\n },\n get meta() {\n return self._createRouteGetter(\"meta\", {})();\n },\n };\n\n return originalSetup ? await originalSetup(ctx) : {};\n },\n };\n }\n\n /**\n * Recursively wraps all child components to ensure they have access to router context.\n * String component references are returned as-is (context injected during mount).\n * Objects are wrapped with router context and their children are recursively wrapped.\n *\n * @private\n * @param {ComponentDefinition | string} component - The component to wrap (can be a definition object or a registered component name).\n * @returns {ComponentDefinition | string} The wrapped component definition or the original string reference.\n * @see _wrapComponent - Single component wrapping.\n */\n _wrapComponentWithChildren(component) {\n // If the component is a string (registered component name), return as-is\n // The router context will be injected when the component is resolved during mounting\n if (typeof component === \"string\") {\n return component;\n }\n\n // If not a valid component object, return as-is\n if (!component || typeof component !== \"object\") {\n return component;\n }\n\n const wrappedComponent = this._wrapComponent(component);\n\n // If the component has children, wrap them too\n if (\n wrappedComponent.children &&\n typeof wrappedComponent.children === \"object\"\n ) {\n const wrappedChildren = {};\n for (const [selector, childComponent] of Object.entries(\n wrappedComponent.children\n )) {\n wrappedChildren[selector] =\n this._wrapComponentWithChildren(childComponent);\n }\n wrappedComponent.children = wrappedChildren;\n }\n\n return wrappedComponent;\n }\n\n /**\n * Gets the current location information from the browser's window object.\n * @private\n * @returns {Omit<RouteLocation, 'params' | 'meta' | 'name' | 'matched'>}\n */\n _getCurrentLocation() {\n if (typeof window === \"undefined\")\n return { path: \"/\", query: {}, fullUrl: \"\" };\n let path, queryString, fullUrl;\n switch (this.options.mode) {\n case \"hash\":\n fullUrl = window.location.hash.slice(1) || \"/\";\n [path, queryString] = fullUrl.split(\"?\");\n break;\n case \"query\":\n const urlParams = new URLSearchParams(window.location.search);\n path = urlParams.get(this.options.queryParam) || \"/\";\n queryString = window.location.search.slice(1);\n fullUrl = path;\n break;\n default: // 'history' mode\n path = window.location.pathname || \"/\";\n queryString = window.location.search.slice(1);\n fullUrl = `${path}${queryString ? \"?\" + queryString : \"\"}`;\n }\n return {\n path: path.startsWith(\"/\") ? path : `/${path}`,\n query: this._parseQuery(queryString),\n fullUrl,\n };\n }\n\n /**\n * Parses a query string into a key-value object.\n * Uses URLSearchParams for robust parsing of encoded values.\n *\n * @private\n * @param {string} queryString - The query string to parse (without leading '?').\n * @returns {QueryParams} Key-value pairs from the query string.\n *\n * @example\n * this._parseQuery('foo=bar&baz=qux');\n * // Returns: { foo: 'bar', baz: 'qux' }\n */\n _parseQuery(queryString) {\n const query = {};\n if (queryString) {\n new URLSearchParams(queryString).forEach((value, key) => {\n query[key] = value;\n });\n }\n return query;\n }\n\n /**\n * Matches a given path against the registered routes.\n * @private\n * @param {string} path - The path to match.\n * @returns {{route: RouteDefinition, params: Object<string, string>} | null} The matched route and its params, or null.\n */\n _matchRoute(path) {\n const pathSegments = path.split(\"/\").filter(Boolean);\n\n for (const route of this.routes) {\n // Handle the root path as a special case.\n if (route.path === \"/\") {\n if (pathSegments.length === 0) return { route, params: {} };\n continue;\n }\n\n if (route.segments.length !== pathSegments.length) continue;\n\n const params = {};\n let isMatch = true;\n for (let i = 0; i < route.segments.length; i++) {\n const routeSegment = route.segments[i];\n const pathSegment = pathSegments[i];\n if (routeSegment.type === \"param\") {\n params[routeSegment.name] = decodeURIComponent(pathSegment);\n } else if (routeSegment.value !== pathSegment) {\n isMatch = false;\n break;\n }\n }\n if (isMatch) return { route, params };\n }\n return null;\n }\n\n // ============================================\n // Dynamic Route Management API\n // ============================================\n\n /**\n * Adds a new route dynamically at runtime.\n * The route will be processed and available for navigation immediately.\n * Routes are inserted before the wildcard (*) route if one exists.\n *\n * @param {RouteDefinition} route - The route definition to add.\n * @param {RouteDefinition} [parentRoute] - Optional parent route to add as a child (not yet implemented).\n * @returns {() => void} A function to remove the added route (returns no-op if route was invalid).\n * @emits router:routeAdded When a route is successfully added.\n *\n * @example\n * // Add a route dynamically\n * const removeRoute = router.addRoute({\n * path: '/dynamic',\n * component: DynamicPage,\n * meta: { title: 'Dynamic Page' }\n * });\n *\n * // Later, remove the route\n * removeRoute();\n */\n addRoute(route, parentRoute = null) {\n if (!route || !route.path) {\n this.errorHandler.warn(\"Invalid route definition: missing path\", {\n route,\n });\n return () => {};\n }\n\n // Check if route already exists\n if (this.hasRoute(route.path)) {\n this.errorHandler.warn(`Route \"${route.path}\" already exists`, { route });\n return () => {};\n }\n\n // Process the route (parse segments)\n const processedRoute = {\n ...route,\n segments: this._parsePathIntoSegments(route.path),\n };\n\n // Add to routes array (before wildcard if exists)\n const wildcardIndex = this.routes.findIndex((r) => r.path === \"*\");\n if (wildcardIndex !== -1) {\n this.routes.splice(wildcardIndex, 0, processedRoute);\n } else {\n this.routes.push(processedRoute);\n }\n\n // Emit event for plugins\n this.emitter.emit(\"router:routeAdded\", processedRoute);\n\n // Return removal function\n return () => this.removeRoute(route.path);\n }\n\n /**\n * Removes a route by its path.\n *\n * @param {string} path - The path of the route to remove.\n * @returns {boolean} True if the route was removed, false if not found.\n * @emits router:routeRemoved When a route is successfully removed.\n *\n * @example\n * router.removeRoute('/dynamic');\n */\n removeRoute(path) {\n const index = this.routes.findIndex((r) => r.path === path);\n if (index === -1) {\n return false;\n }\n\n const [removedRoute] = this.routes.splice(index, 1);\n\n // Emit event for plugins\n this.emitter.emit(\"router:routeRemoved\", removedRoute);\n\n return true;\n }\n\n /**\n * Checks if a route with the given path exists.\n *\n * @param {string} path - The path to check.\n * @returns {boolean} True if the route exists.\n *\n * @example\n * if (router.hasRoute('/users/:id')) {\n * console.log('User route exists');\n * }\n */\n hasRoute(path) {\n return this.routes.some((r) => r.path === path);\n }\n\n /**\n * Gets all registered routes.\n *\n * @returns {RouteDefinition[]} A copy of the routes array.\n *\n * @example\n * const routes = router.getRoutes();\n * console.log('Available routes:', routes.map(r => r.path));\n */\n getRoutes() {\n return [...this.routes];\n }\n\n /**\n * Gets a route by its path.\n *\n * @param {string} path - The path of the route to get.\n * @returns {RouteDefinition | undefined} The route definition or undefined.\n *\n * @example\n * const route = router.getRoute('/users/:id');\n * if (route) {\n * console.log('Route meta:', route.meta);\n * }\n */\n getRoute(path) {\n return this.routes.find((r) => r.path === path);\n }\n\n // ============================================\n // Hook Registration Methods\n // ============================================\n\n /**\n * Registers a global pre-navigation guard.\n * Multiple guards can be registered and will be executed in order.\n * Guards can also be registered via the emitter using `router:beforeEach` event.\n *\n * @param {NavigationGuard} guard - The guard function to register.\n * @returns {() => void} A function to unregister the guard.\n *\n * @example\n * // Register a guard\n * const unregister = router.onBeforeEach((to, from) => {\n * if (to.meta.requiresAuth && !isAuthenticated()) {\n * return '/login';\n * }\n * });\n *\n * // Later, unregister the guard\n * unregister();\n */\n onBeforeEach(guard) {\n this._beforeEachGuards.push(guard);\n return () => {\n const index = this._beforeEachGuards.indexOf(guard);\n if (index > -1) {\n this._beforeEachGuards.splice(index, 1);\n }\n };\n }\n /**\n * Registers a global hook that runs after a new route component has been mounted.\n * @param {NavigationHook} hook - The hook function to register.\n * @returns {() => void} A function to unregister the hook.\n * @listens router:afterEnter\n */\n onAfterEnter(hook) {\n return this.emitter.on(\"router:afterEnter\", hook);\n }\n\n /**\n * Registers a global hook that runs after a route component has been unmounted.\n * @param {NavigationHook} hook - The hook function to register.\n * @returns {() => void} A function to unregister the hook.\n * @listens router:afterLeave\n */\n onAfterLeave(hook) {\n return this.emitter.on(\"router:afterLeave\", hook);\n }\n\n /**\n * Registers a global hook that runs after a navigation has been confirmed and all hooks have completed.\n * @param {NavigationHook} hook - The hook function to register.\n * @returns {() => void} A function to unregister the hook.\n * @listens router:afterEach\n */\n onAfterEach(hook) {\n return this.emitter.on(\"router:afterEach\", hook);\n }\n\n /**\n * Registers a global error handler for navigation errors.\n * @param {(error: Error, to?: RouteLocation, from?: RouteLocation) => void} handler - The error handler function.\n * @returns {() => void} A function to unregister the handler.\n * @listens router:error\n */\n onError(handler) {\n return this.emitter.on(\"router:error\", handler);\n }\n\n /**\n * Registers a plugin with the router.\n * Logs a warning if the plugin is already registered.\n *\n * @param {RouterPlugin} plugin - The plugin to register (must have install method).\n * @param {Record<string, unknown>} [options={}] - Options to pass to plugin.install().\n * @returns {void}\n * @throws {Error} If plugin does not have an install method.\n */\n use(plugin, options = {}) {\n if (typeof plugin.install !== \"function\") {\n this.errorHandler.handle(\n new Error(\"Plugin must have an install method\"),\n \"Plugin registration failed\",\n { plugin }\n );\n }\n\n // Check if plugin is already registered\n if (this.plugins.has(plugin.name)) {\n this.errorHandler.warn(`Plugin \"${plugin.name}\" is already registered`, {\n existingPlugin: this.plugins.get(plugin.name),\n });\n return;\n }\n\n this.plugins.set(plugin.name, plugin);\n plugin.install(this, options);\n }\n\n /**\n * Gets all registered plugins.\n * @returns {RouterPlugin[]} Array of registered plugins.\n */\n getPlugins() {\n return Array.from(this.plugins.values());\n }\n\n /**\n * Gets a plugin by name.\n * @param {string} name - The plugin name.\n * @returns {RouterPlugin | undefined} The plugin or undefined.\n */\n getPlugin(name) {\n return this.plugins.get(name);\n }\n\n /**\n * Removes a plugin from the router.\n * @param {string} name - The plugin name.\n * @returns {boolean} True if the plugin was removed.\n */\n removePlugin(name) {\n const plugin = this.plugins.get(name);\n if (!plugin) return false;\n\n // Call destroy if available\n if (typeof plugin.destroy === \"function\") {\n try {\n plugin.destroy(this);\n } catch (error) {\n this.errorHandler.log(`Plugin ${name} destroy failed`, error);\n }\n }\n\n return this.plugins.delete(name);\n }\n\n /**\n * Sets a custom error handler. Used by error handling plugins.\n * Logs a warning if the provided handler is invalid (missing required methods).\n * @param {RouterErrorHandler} errorHandler - The error handler object with handle, warn, and log methods.\n * @returns {void}\n */\n setErrorHandler(errorHandler) {\n if (\n errorHandler &&\n typeof errorHandler.handle === \"function\" &&\n typeof errorHandler.warn === \"function\" &&\n typeof errorHandler.log === \"function\"\n ) {\n this.errorHandler = errorHandler;\n } else {\n console.warn(\n \"[ElevaRouter] Invalid error handler provided. Must have handle, warn, and log methods.\"\n );\n }\n }\n}\n\n/**\n * @class 🚀 RouterPlugin\n * @classdesc A powerful, reactive, and flexible Router Plugin for Eleva applications.\n * This plugin provides comprehensive client-side routing functionality including:\n * - Multiple routing modes (hash, history, query)\n * - Navigation guards and lifecycle hooks\n * - Reactive state management\n * - Component resolution and lazy loading\n * - Layout and page component separation\n * - Plugin system for extensibility\n * - Advanced error handling\n *\n * @example\n * // Install the plugin\n * const app = new Eleva(\"myApp\");\n *\n * const HomePage = { template: () => `<h1>Home</h1>` };\n * const AboutPage = { template: () => `<h1>About Us</h1>` };\n * const UserPage = {\n * template: (ctx) => `<h1>User: ${ctx.router.params.id}</h1>`\n * };\n *\n * app.use(RouterPlugin, {\n * mount: '#app',\n * mode: 'hash',\n * routes: [\n * { path: '/', component: HomePage },\n * { path: '/about', component: AboutPage },\n * { path: '/users/:id', component: UserPage }\n * ]\n * });\n */\nexport const RouterPlugin = {\n /**\n * Unique identifier for the plugin\n * @type {string}\n */\n name: \"router\",\n\n /**\n * Plugin version\n * @type {string}\n */\n version: \"1.1.0\",\n\n /**\n * Plugin description\n * @type {string}\n */\n description: \"Client-side routing for Eleva applications\",\n\n /**\n * Installs the RouterPlugin into an Eleva instance.\n *\n * @public\n * @param {Eleva} eleva - The Eleva instance.\n * @param {RouterOptions} options - Router configuration options.\n * @param {string} options.mount - A CSS selector for the main element where the app is mounted.\n * @param {RouteDefinition[]} options.routes - An array of route definitions.\n * @param {'hash' | 'query' | 'history'} [options.mode='hash'] - The routing mode.\n * @param {string} [options.queryParam='view'] - The query parameter to use in 'query' mode.\n * @param {string} [options.viewSelector='view'] - Base selector for the view element (matched as #id, .class, [data-*], or raw selector).\n * @param {boolean} [options.autoStart=true] - Whether to start the router automatically.\n * @param {NavigationGuard} [options.onBeforeEach] - A global guard executed before every navigation.\n * @param {RouteComponent} [options.globalLayout] - A global layout for all routes.\n * @returns {Router} The created router instance.\n * @throws {Error} If 'mount' option is not provided.\n * @throws {Error} If 'routes' option is not an array.\n * @throws {Error} If component registration fails during route processing.\n * @description\n * Registers route/layout components, sets `eleva.router`, and adds helpers\n * (`eleva.navigate`, `eleva.getCurrentRoute`, `eleva.getRouteParams`, `eleva.getRouteQuery`).\n * When `autoStart` is enabled, startup is scheduled via microtask.\n *\n * @example\n * // main.js\n * import Eleva from 'eleva';\n * import { RouterPlugin } from './plugins/RouterPlugin.js';\n *\n * const app = new Eleva('myApp');\n *\n * const HomePage = { template: () => `<h1>Home</h1>` };\n * const AboutPage = { template: () => `<h1>About Us</h1>` };\n *\n * app.use(RouterPlugin, {\n * mount: '#app',\n * routes: [\n * { path: '/', component: HomePage },\n * { path: '/about', component: AboutPage }\n * ]\n * });\n */\n install(eleva, options = {}) {\n if (!options.mount) {\n throw new Error(\"[RouterPlugin] 'mount' option is required\");\n }\n\n if (!options.routes || !Array.isArray(options.routes)) {\n throw new Error(\"[RouterPlugin] 'routes' option must be an array\");\n }\n\n /**\n * Registers a component definition with the Eleva instance.\n * This method handles both inline component objects and pre-registered component names.\n *\n * @inner\n * @param {unknown} def - The component definition to register.\n * @param {string} type - The type of component for naming (e.g., \"Route\", \"Layout\").\n * @returns {string | null} The registered component name or null if no definition provided.\n */\n const register = (def, type) => {\n if (!def) return null;\n\n if (typeof def === \"object\" && def !== null && !def.name) {\n const name = `Eleva${type}Component_${Math.random()\n .toString(36)\n .slice(2, 11)}`;\n\n try {\n eleva.component(name, def);\n return name;\n } catch (error) {\n throw new Error(\n `[RouterPlugin] Failed to register ${type} component: ${error.message}`\n );\n }\n }\n return def;\n };\n\n if (options.globalLayout) {\n options.globalLayout = register(options.globalLayout, \"GlobalLayout\");\n }\n\n (options.routes || []).forEach((route) => {\n route.component = register(route.component, \"Route\");\n if (route.layout) {\n route.layout = register(route.layout, \"RouteLayout\");\n }\n });\n\n const router = new Router(eleva, options);\n /** @type {Router} */\n eleva.router = router;\n\n if (options.autoStart !== false) {\n queueMicrotask(() => router.start());\n }\n\n // Add plugin metadata to the Eleva instance\n if (!eleva.plugins) {\n eleva.plugins = new Map();\n }\n eleva.plugins.set(this.name, {\n name: this.name,\n version: this.version,\n description: this.description,\n options,\n });\n\n // Add utility methods for manual router access\n /** @type {NavigateFunction} */\n eleva.navigate = router.navigate.bind(router);\n /** @type {() => RouteLocation | null} */\n eleva.getCurrentRoute = () => router.currentRoute.value;\n /** @type {() => RouteParams} */\n eleva.getRouteParams = () => router.currentParams.value;\n /** @type {() => QueryParams} */\n eleva.getRouteQuery = () => router.currentQuery.value;\n\n return router;\n },\n\n /**\n * Uninstalls the plugin from the Eleva instance.\n *\n * @public\n * @async\n * @param {Eleva} eleva - The Eleva instance.\n * @returns {Promise<void>}\n * @description\n * Destroys the router instance, removes `eleva.router`, and deletes helper methods\n * (`eleva.navigate`, `eleva.getCurrentRoute`, `eleva.getRouteParams`, `eleva.getRouteQuery`).\n */\n async uninstall(eleva) {\n if (eleva.router) {\n await eleva.router.destroy();\n delete eleva.router;\n }\n\n // Remove plugin metadata\n if (eleva.plugins) {\n eleva.plugins.delete(this.name);\n }\n\n // Remove utility methods\n delete eleva.navigate;\n delete eleva.getCurrentRoute;\n delete eleva.getRouteParams;\n delete eleva.getRouteQuery;\n },\n};\n\n// Short name export for convenience\nexport { RouterPlugin as Router };\n"],"names":["CoreErrorHandler","handle","error","context","details","formattedError","Error","message","originalError","warn","log","Router","_validateOptions","includes","options","mode","errorHandler","_processRoutes","routes","processedRoutes","route","push","segments","_parsePathIntoSegments","path","normalizedPath","replace","split","filter","Boolean","map","segment","startsWith","paramName","substring","type","name","value","_findViewElement","container","selector","viewSelector","querySelector","start","isStarted","window","document","mount","mountSelector","handler","_handleRouteChange","addEventListener","eventListeners","removeEventListener","isReady","emitter","emit","destroy","plugin","plugins","values","forEach","cleanup","currentLayout","unmount","stop","navigate","location","params","target","_buildPath","query","Object","keys","length","queryString","URLSearchParams","toString","_isSameRoute","navigationSuccessful","_proceedWithNavigation","currentNavId","_navigationId","_isNavigating","state","newUrl","pathname","search","history","replaceState","hash","url","_buildQueryUrl","queueMicrotask","urlParams","set","queryParam","current","currentRoute","targetPath","targetQuery","_parseQuery","JSON","stringify","result","key","entries","encodedValue","encodeURIComponent","String","RegExp","isPopState","from","toLocation","_getCurrentLocation","fullUrl","currentUrl","href","fullPath","toMatch","_matchRoute","notFoundRoute","find","pathMatch","decodeURIComponent","to","meta","matched","_runGuards","_scrollPositions","x","scrollX","pageXOffset","y","scrollY","pageYOffset","resolveContext","layoutComponent","pageComponent","cancelled","redirectTo","_resolveComponents","toLayout","layout","globalLayout","fromLayout","tryUnmount","instance","currentView","afterLeave","previousRoute","currentParams","currentQuery","renderContext","_render","scrollContext","savedPosition","get","afterEnter","navContext","guard","_beforeEachGuards","beforeLeave","beforeEnter","_resolveStringComponent","def","componentDef","eleva","_components","componentName","availableComponents","Array","_resolveFunctionComponent","funcStr","isAsyncImport","default","function","_validateComponentDefinition","definition","template","_resolveComponent","effectiveLayout","Promise","all","component","mountEl","layoutInstance","_wrapComponentWithChildren","viewEl","viewInstance","_createRouteGetter","property","defaultValue","_wrapComponent","originalSetup","setup","self","ctx","router","bind","previous","wrappedComponent","children","wrappedChildren","childComponent","slice","pathSegments","isMatch","i","routeSegment","pathSegment","addRoute","parentRoute","hasRoute","processedRoute","wildcardIndex","findIndex","r","splice","removeRoute","index","removedRoute","some","getRoutes","getRoute","onBeforeEach","indexOf","onAfterEnter","hook","on","onAfterLeave","onAfterEach","onError","use","install","has","existingPlugin","getPlugins","getPlugin","removePlugin","delete","setErrorHandler","signal","Map","RouterPlugin","version","description","isArray","register","Math","random","autoStart","getCurrentRoute","getRouteParams","getRouteQuery","uninstall"],"mappings":"0CAuXA,IAAMA,EAAmB,CAQvBC,OAAOC,CAAK,CAAEC,CAAO,CAAEC,EAAU,CAAA,CAAE,EACjC,IACMC,EAAiB,AAAIC,MADX,CAAC,cAAc,EAAEH,EAAQ,EAAE,EAAED,EAAMK,OAAO,CAAA,CAAE,CAS5D,OALAF,EAAeG,aAAa,CAAGN,EAC/BG,EAAeF,OAAO,CAAGA,EACzBE,EAAeD,OAAO,CAAGA,EAGnBC,CACR,EAOAI,KAAKF,CAAO,CAAEH,EAAU,EAAE,EAE1B,EAQAM,IAAIH,CAAO,CAAEL,CAAK,CAAEE,EAAU,CAAA,CAAE,EAEhC,CACF,CAsRA,OAAMO,EAmFJC,kBAAmB,CACb,AAAC,CAAC,OAAQ,QAAS,UAAU,CAACC,QAAQ,CAAC,IAAI,CAACC,OAAO,CAACC,IAAI,GAC1D,IAAI,CAACC,YAAY,CAACf,MAAM,CACtB,AAAIK,MACF,CAAC,sBAAsB,EAAE,IAAI,CAACQ,OAAO,CAACC,IAAI,CAAC,wCAAwC,CAAC,EAEtF,kCAGN,CAQAE,eAAeC,CAAM,CAAE,CACrB,IAAMC,EAAkB,EAAE,CAC1B,IAAK,IAAMC,KAASF,EAClB,GAAI,CACFC,EAAgBE,I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AE1C,GAEA,IAAMuD,EAAS,IAAI3L,EAAO4J,EAAOzJ,GA6BjC,OA3BAyJ,EAAM+B,MAAM,CAAGA,EAEXxL,AAAsB,CAAA,IAAtBA,EAAQ6O,SAAS,EACnB9J,eAAe,IAAMyG,EAAO3J,KAAK,IAI/B,AAAC4H,EAAM5G,OAAO,EAChB4G,CAAAA,EAAM5G,OAAO,CAAG,IAAIwL,GAAAA,EAEtB5E,EAAM5G,OAAO,CAACoC,GAAG,CAAC,IAAI,CAAC3D,IAAI,CAAE,CAC3BA,KAAM,IAAI,CAACA,IAAI,CACfiN,QAAS,IAAI,CAACA,OAAO,CACrBC,YAAa,IAAI,CAACA,WAAW,CAC7BxO,QAAAA,CACF,GAIAyJ,EAAMrG,QAAQ,CAAGoI,EAAOpI,QAAQ,CAACqI,IAAI,CAACD,GAEtC/B,EAAMqF,eAAe,CAAG,IAAMtD,EAAOpG,YAAY,CAAC7D,KAAK,CAEvDkI,EAAMsF,cAAc,CAAG,IAAMvD,EAAO/C,aAAa,CAAClH,KAAK,CAEvDkI,EAAMuF,aAAa,CAAG,IAAMxD,EAAO9C,YAAY,CAACnH,KAAK,CAE9CiK,CACT,EAaA,MAAMyD,UAAUxF,CAAK,EACfA,EAAM+B,MAAM,GACd,MAAM/B,EAAM+B,MAAM,CAAC7I,OAAO,GAC1B,OAAO8G,EAAM+B,MAAM,EAIjB/B,EAAM5G,OAAO,EACf4G,EAAM5G,OAAO,CAACqL,MAAM,CAAC,IAAI,CAAC5M,IAAI,EAIhC,OAAOmI,EAAMrG,QAAQ,CACrB,OAAOqG,EAAMqF,eAAe,CAC5B,OAAOrF,EAAMsF,cAAc,CAC3B,OAAOtF,EAAMuF,aAAa,AAC5B,CACF"}
|
|
1
|
+
{"version":3,"file":"router.umd.min.js","sources":["../../src/plugins/Router.js"],"sourcesContent":["\"use strict\";\n\n/**\n * @module eleva/plugins/router\n * @fileoverview Client-side router plugin with hash, history, and query modes,\n * navigation guards, and lifecycle hooks.\n */\n\n// ============================================================================\n// TYPE DEFINITIONS\n// ============================================================================\n\n// -----------------------------------------------------------------------------\n// External Type Imports\n// -----------------------------------------------------------------------------\n\n/**\n * Type imports from the Eleva core library.\n * @typedef {import('eleva').Eleva} Eleva\n * @typedef {import('eleva').ComponentDefinition} ComponentDefinition\n * @typedef {import('eleva').Emitter} Emitter\n * @typedef {import('eleva').MountResult} MountResult\n * @typedef {import('eleva').UnsubscribeFunction} UnsubscribeFunction\n */\n\n/**\n * Generic type import.\n * @template T\n * @typedef {import('eleva').Signal<T>} Signal\n */\n\n// -----------------------------------------------------------------------------\n// Router Events\n// -----------------------------------------------------------------------------\n\n/**\n * Fired when the router initialization completes successfully.\n * @event router:ready\n * @type {Router}\n */\n\n/**\n * Fired when an error occurs during navigation or route handling.\n * @event router:error\n * @type {Error}\n */\n\n/**\n * Fired when no matching route is found for the requested path.\n * @event router:notFound\n * @type {{to: RouteLocation, from: RouteLocation | null, path: string}}\n */\n\n/**\n * Fired before guards run, allowing plugins to block or redirect navigation.\n * @event router:beforeEach\n * @type {NavigationContext}\n */\n\n/**\n * Fired before component resolution, allowing plugins to modify the resolve context.\n * @event router:beforeResolve\n * @type {ResolveContext}\n */\n\n/**\n * Fired after components are resolved successfully.\n * @event router:afterResolve\n * @type {ResolveContext}\n */\n\n/**\n * Fired after leaving the previous route.\n * @event router:afterLeave\n * @type {{to: RouteLocation, from: RouteLocation}}\n */\n\n/**\n * Fired before DOM rendering begins.\n * @event router:beforeRender\n * @type {RenderContext}\n */\n\n/**\n * Fired after DOM rendering completes.\n * @event router:afterRender\n * @type {RenderContext}\n */\n\n/**\n * Fired after render for scroll behavior handling.\n * @event router:scroll\n * @type {ScrollContext}\n */\n\n/**\n * Fired after entering the new route.\n * @event router:afterEnter\n * @type {{to: RouteLocation, from: RouteLocation | null}}\n */\n\n/**\n * Fired after navigation completes successfully.\n * @event router:afterEach\n * @type {{to: RouteLocation, from: RouteLocation | null}}\n */\n\n/**\n * Fired when a route is dynamically added.\n * @event router:routeAdded\n * @type {RouteDefinition}\n */\n\n/**\n * Fired when a route is dynamically removed.\n * @event router:routeRemoved\n * @type {RouteDefinition}\n */\n\n// -----------------------------------------------------------------------------\n// Router Data Types\n// -----------------------------------------------------------------------------\n\n/**\n * The routing mode determines how the router manages URL state.\n * - `hash`: Uses URL hash (e.g., `/#/path`) - works without server config\n * - `history`: Uses HTML5 History API (e.g., `/path`) - requires server config\n * - `query`: Uses query parameters (e.g., `?view=/path`) - useful for embedded apps\n * @typedef {'hash' | 'history' | 'query'} RouterMode\n */\n\n/**\n * Route parameters extracted from the URL path.\n * @typedef {Record<string, string>} RouteParams\n * @description Key-value pairs extracted from dynamic route segments (e.g., `/users/:id` → `{ id: '123' }`).\n */\n\n/**\n * Query parameters from the URL query string.\n * @typedef {Record<string, string>} QueryParams\n * @description Key-value pairs from the URL query string (e.g., `?page=1&sort=name`).\n */\n\n/**\n * Navigation input parameters supporting multiple value types.\n * @typedef {Record<string, string | number | boolean>} NavigationParams\n * @description Parameters passed to navigation functions, automatically converted to strings in URLs.\n */\n\n/**\n * Function signature for programmatic navigation.\n * @typedef {(location: string | NavigationTarget, params?: NavigationParams) => Promise<boolean>} NavigateFunction\n * @description Returns true if navigation succeeded, false if blocked by a guard.\n */\n\n/**\n * Router configuration options.\n * @typedef {Object} RouterOptions\n * @property {RouterMode} [mode='hash']\n * The routing mode to use.\n * @property {string} [queryParam='view']\n * Query parameter name for 'query' mode.\n * @property {string} [viewSelector='view']\n * Base selector for the view element.\n * @property {string} mount\n * CSS selector for the mount point element.\n * @property {RouteDefinition[]} routes\n * Array of route definitions.\n * @property {RouteComponent} [globalLayout]\n * Default layout for all routes.\n * @property {NavigationGuard} [onBeforeEach]\n * Global navigation guard.\n * @property {boolean} [autoStart=true]\n * Whether to start the router automatically.\n * @description Configuration options for the Router plugin.\n */\n\n/**\n * Object describing a navigation target for `router.navigate()`.\n * @typedef {Object} NavigationTarget\n * @property {string} path\n * The target path (can include params like '/users/:id').\n * @property {NavigationParams} [params]\n * Route parameters to inject.\n * @property {NavigationParams} [query]\n * Query parameters to append.\n * @property {boolean} [replace=false]\n * Whether to replace current history entry.\n * @property {unknown} [state]\n * History state to pass.\n * @description Object describing a navigation target for `router.navigate()`.\n */\n\n/**\n * Saved scroll position.\n * @typedef {Object} ScrollPosition\n * @property {number} x\n * Horizontal scroll position.\n * @property {number} y\n * Vertical scroll position.\n * @description Represents a saved scroll position.\n */\n\n/**\n * Internal representation of a parsed route path segment.\n * @typedef {Object} RouteSegment\n * @property {'static' | 'param'} type\n * The segment type.\n * @property {string} [value]\n * The segment value (static segments).\n * @property {string} [name]\n * The parameter name (param segments).\n * @description Internal representation of a parsed route path segment.\n * @private\n */\n\n/**\n * Result of matching a path against route definitions.\n * @typedef {Object} RouteMatch\n * @property {RouteDefinition} route\n * The matched route definition.\n * @property {RouteParams} params\n * The extracted route parameters.\n * @description Result of matching a path against route definitions.\n * @private\n */\n\n/**\n * Arbitrary metadata attached to routes for use in guards and components.\n * @typedef {Record<string, unknown>} RouteMeta\n * @description Common properties include:\n * - `requiresAuth: boolean` - Whether the route requires authentication\n * - `title: string` - Page title for the route\n * - `roles: string[]` - Required user roles\n * @example\n * {\n * path: '/admin',\n * component: AdminPage,\n * meta: { requiresAuth: true, roles: ['admin'], title: 'Admin Dashboard' }\n * }\n */\n\n/**\n * Interface for the router's error handling system.\n * @typedef {Object} RouterErrorHandler\n * @property {(error: Error, context: string, details?: Record<string, unknown>) => void} handle\n * Throws a formatted error.\n * @property {(message: string, details?: Record<string, unknown>) => void} warn\n * Logs a warning.\n * @property {(message: string, error: Error, details?: Record<string, unknown>) => void} log\n * Logs an error without throwing.\n * @description Interface for the router's error handling system.\n */\n\n// -----------------------------------------------------------------------------\n// Event Callback Types\n// -----------------------------------------------------------------------------\n\n/**\n * Callback for `router:beforeEach` event.\n * @callback NavigationContextCallback\n * @param {NavigationContext} context\n * The navigation context (can be modified to block/redirect).\n * @returns {void | Promise<void>}\n * @description Modify context to control navigation flow.\n */\n\n/**\n * Callback for `router:beforeResolve` and `router:afterResolve` events.\n * @callback ResolveContextCallback\n * @param {ResolveContext} context\n * The resolve context (can be modified to block/redirect).\n * @returns {void | Promise<void>}\n * @description Callback for `router:beforeResolve` and `router:afterResolve` events.\n */\n\n/**\n * Callback for `router:beforeRender` and `router:afterRender` events.\n * @callback RenderContextCallback\n * @param {RenderContext} context\n * The render context.\n * @returns {void | Promise<void>}\n * @description Callback for `router:beforeRender` and `router:afterRender` events.\n */\n\n/**\n * Callback for `router:scroll` event.\n * @callback ScrollContextCallback\n * @param {ScrollContext} context\n * The scroll context with saved position info.\n * @returns {void | Promise<void>}\n * @description Use to implement custom scroll behavior.\n */\n\n/**\n * Callback for `router:afterEnter`, `router:afterLeave`, `router:afterEach` events.\n * @callback RouteChangeCallback\n * @param {RouteLocation} to\n * The target route location.\n * @param {RouteLocation | null} from\n * The source route location.\n * @returns {void | Promise<void>}\n * @description Callback for `router:afterEnter`, `router:afterLeave`, `router:afterEach` events.\n */\n\n/**\n * Router context injected into component setup as `ctx.router`.\n * @typedef {Object} RouterContext\n * @property {NavigateFunction} navigate\n * Programmatic navigation function.\n * @property {Signal<RouteLocation | null>} current\n * Reactive signal for current route.\n * @property {Signal<RouteLocation | null>} previous\n * Reactive signal for previous route.\n * @property {RouteParams} params\n * Current route params (getter).\n * @property {QueryParams} query\n * Current route query (getter).\n * @property {string} path\n * Current route path (getter).\n * @property {string} fullUrl\n * Current routed URL string (getter).\n * @property {RouteMeta} meta\n * Current route meta (getter).\n * @description Injected into component setup as `ctx.router`.\n */\n\n/**\n * Callback for `router:error` event.\n * @callback RouterErrorCallback\n * @param {Error} error\n * The error that occurred.\n * @param {RouteLocation} [to]\n * The target route (if available).\n * @param {RouteLocation | null} [from]\n * The source route (if available).\n * @returns {void | Promise<void>}\n * @description Callback for `router:error` event.\n */\n\n/**\n * Callback for `router:ready` event.\n * @callback RouterReadyCallback\n * @param {Router} router\n * The router instance.\n * @returns {void | Promise<void>}\n * @description Callback for `router:ready` event.\n */\n\n/**\n * Callback for `router:routeAdded` event.\n * @callback RouteAddedCallback\n * @param {RouteDefinition} route\n * The added route definition.\n * @returns {void | Promise<void>}\n * @description Callback for `router:routeAdded` event.\n */\n\n/**\n * Callback for `router:routeRemoved` event.\n * @callback RouteRemovedCallback\n * @param {RouteDefinition} route\n * The removed route definition.\n * @returns {void | Promise<void>}\n * @description Callback for `router:routeRemoved` event.\n */\n\n// ============================================================================\n// CORE IMPLEMENTATION\n// ============================================================================\n\n/**\n * Simple error handler for the core router.\n * @private\n */\nconst CoreErrorHandler = {\n /**\n * Handles router errors with basic formatting.\n * @param {Error} error - The error to handle.\n * @param {string} context - The context where the error occurred.\n * @param {Record<string, unknown>} details - Additional error details.\n * @throws {Error} The formatted error.\n */\n handle(error, context, details = {}) {\n const message = `[ElevaRouter] ${context}: ${error.message}`;\n const formattedError = new Error(message);\n\n // Preserve original error details\n formattedError.originalError = error;\n formattedError.context = context;\n formattedError.details = details;\n\n console.error(message, { error, context, details });\n throw formattedError;\n },\n\n /**\n * Logs a warning without throwing an error.\n * @param {string} message - The warning message.\n * @param {Record<string, unknown>} details - Additional warning details.\n */\n warn(message, details = {}) {\n console.warn(`[ElevaRouter] ${message}`, details);\n },\n\n /**\n * Logs an error without throwing.\n * @param {string} message - The error message.\n * @param {Error} error - The original error.\n * @param {Record<string, unknown>} details - Additional error details.\n */\n log(message, error, details = {}) {\n console.error(`[ElevaRouter] ${message}`, { error, details });\n },\n};\n\n/**\n * Represents the current or target location in the router.\n * @typedef {Object} RouteLocation\n * @property {string} path\n * The path of the route (e.g., '/users/123').\n * @property {QueryParams} query\n * Query parameters as key-value pairs.\n * @property {string} fullUrl\n * The routed URL string (path plus query).\n * @property {RouteParams} params\n * Dynamic route parameters.\n * @property {RouteMeta} meta\n * Metadata associated with the matched route.\n * @property {string} [name]\n * The optional name of the matched route.\n * @property {RouteDefinition} matched\n * The raw route definition that was matched.\n * @description Represents the current or target location in the router.\n */\n\n/**\n * Return value of a navigation guard.\n * - `true` or `undefined/void`: Allow navigation\n * - `false`: Abort navigation\n * - `string`: Redirect to path\n * - `NavigationTarget`: Redirect with options\n * @typedef {boolean | string | NavigationTarget | void} NavigationGuardResult\n */\n\n/**\n * Navigation guard function that controls navigation flow.\n * @callback NavigationGuard\n * @param {RouteLocation} to\n * The target route location.\n * @param {RouteLocation | null} from\n * The source route location (null on initial).\n * @returns {NavigationGuardResult | Promise<NavigationGuardResult>}\n * @description A function that controls navigation flow. Runs before navigation is confirmed.\n * @example\n * // Simple auth guard\n * const authGuard = (to, from) => {\n * if (to.meta.requiresAuth && !isLoggedIn()) {\n * return '/login'; // Redirect\n * }\n * // Allow navigation (implicit return undefined)\n * };\n */\n\n/**\n * Navigation hook for side effects. Does not affect navigation flow.\n * @callback NavigationHook\n * @param {RouteLocation} to\n * The target route location.\n * @param {RouteLocation | null} from\n * The source route location.\n * @returns {void | Promise<void>}\n * @description A lifecycle hook for side effects. Does not affect navigation flow.\n * @example\n * // Analytics hook\n * const analyticsHook = (to, from) => {\n * analytics.trackPageView(to.path);\n * };\n */\n\n/**\n * Interface for router plugins.\n * @typedef {Object} RouterPlugin\n * @property {string} name\n * Unique plugin identifier.\n * @property {string} [version]\n * Plugin version (recommended to match router version).\n * @property {(router: Router, options?: Record<string, unknown>) => void} install\n * Installation function.\n * @property {(router: Router) => void | Promise<void>} [destroy]\n * Cleanup function called on router.destroy().\n * @description Interface for router plugins. Plugins can extend router functionality.\n * @example\n * const AnalyticsPlugin = {\n * name: 'analytics',\n * version: '1.0.0',\n * install(router, options) {\n * router.emitter.on('router:afterEach', (to, from) => {\n * analytics.track(to.path);\n * });\n * }\n * };\n */\n\n/**\n * Context object for navigation events that plugins can modify.\n * @typedef {Object} NavigationContext\n * @property {RouteLocation} to\n * The target route location.\n * @property {RouteLocation | null} from\n * The source route location.\n * @property {boolean} cancelled\n * Whether navigation has been cancelled.\n * @property {string | NavigationTarget | null} redirectTo\n * Redirect target if set.\n * @description Passed to navigation events. Plugins can modify to control navigation flow.\n */\n\n/**\n * Context object for component resolution events.\n * @typedef {Object} ResolveContext\n * @property {RouteLocation} to\n * The target route location.\n * @property {RouteLocation | null} from\n * The source route location.\n * @property {RouteDefinition} route\n * The matched route definition.\n * @property {ComponentDefinition | null} layoutComponent\n * The resolved layout component (available in afterResolve).\n * @property {ComponentDefinition | null} pageComponent\n * The resolved page component (available in afterResolve).\n * @property {boolean} cancelled\n * Whether navigation has been cancelled.\n * @property {string | NavigationTarget | null} redirectTo\n * Redirect target if set.\n * @description Passed to component resolution events.\n */\n\n/**\n * Context object for render events.\n * @typedef {Object} RenderContext\n * @property {RouteLocation} to\n * The target route location.\n * @property {RouteLocation | null} from\n * The source route location.\n * @property {ComponentDefinition | null} layoutComponent\n * The layout component being rendered.\n * @property {ComponentDefinition} pageComponent\n * The page component being rendered.\n * @description Passed to render events.\n */\n\n/**\n * Context object for scroll events.\n * @typedef {Object} ScrollContext\n * @property {RouteLocation} to\n * The target route location.\n * @property {RouteLocation | null} from\n * The source route location.\n * @property {{x: number, y: number} | null} savedPosition\n * Saved position (back/forward nav).\n * @description Passed to scroll events for plugins to handle scroll behavior.\n */\n\n/**\n * A component that can be rendered for a route.\n * - `string`: Name of a registered component\n * - `ComponentDefinition`: Inline component definition\n * - `() => ComponentDefinition`: Factory function returning a component\n * - `() => Promise<ComponentDefinition>`: Async factory function\n * - `() => Promise<{default: ComponentDefinition}>`: Lazy-loaded module (e.g., `() => import('./Page.js')`)\n * @typedef {string | ComponentDefinition | (() => ComponentDefinition | Promise<ComponentDefinition | {default: ComponentDefinition}>)} RouteComponent\n */\n\n/**\n * Defines a route in the application.\n * @typedef {Object} RouteDefinition\n * @property {string} path\n * URL path pattern. Supports:\n * - Static: '/about'\n * - Dynamic params: '/users/:id'\n * - Wildcard: '*' (catch-all, conventionally last)\n * @property {RouteComponent} component\n * The component to render for this route.\n * @property {RouteComponent} [layout]\n * Optional layout component to wrap the route component.\n * @property {string} [name]\n * Optional route name for programmatic navigation.\n * @property {RouteMeta} [meta]\n * Optional metadata (auth flags, titles, etc.).\n * @property {NavigationGuard} [beforeEnter]\n * Route-specific guard before entering.\n * @property {NavigationHook} [afterEnter]\n * Hook after entering and component is mounted.\n * @property {NavigationGuard} [beforeLeave]\n * Guard before leaving this route.\n * @property {NavigationHook} [afterLeave]\n * Hook after leaving and component is unmounted.\n * @property {RouteSegment[]} [segments]\n * Internal: parsed path segments (added by router).\n * @description Defines a route in the application.\n * @note Nested routes are not supported. Use shared layouts with flat routes instead.\n * @example\n * // Static route\n * { path: '/about', component: AboutPage }\n *\n * // Dynamic route with params\n * { path: '/users/:id', component: UserPage, meta: { requiresAuth: true } }\n *\n * // Lazy-loaded route with layout\n * {\n * path: '/dashboard',\n * component: () => import('./Dashboard.js'),\n * layout: DashboardLayout,\n * beforeEnter: (to, from) => isLoggedIn() || '/login'\n * }\n *\n * // Catch-all 404 route (conventionally last)\n * { path: '*', component: NotFoundPage }\n */\n\n/**\n * @class 🛤️ Router\n * @classdesc A powerful, reactive, and flexible Router Plugin for Eleva.\n * This class manages all routing logic, including state, navigation, and rendering.\n *\n * ## Features\n * - Multiple routing modes (hash, history, query)\n * - Reactive route state via Signals\n * - Navigation guards and lifecycle hooks\n * - Lazy-loaded components\n * - Layout system\n * - Plugin architecture\n * - Scroll position management\n *\n * ## Events Reference\n * | Event | Callback Type | Can Block | Description |\n * |-------|--------------|-----------|-------------|\n * | `router:ready` | {@link RouterReadyCallback} | No | Router initialized |\n * | `router:beforeEach` | {@link NavigationContextCallback} | Yes | Before guards run |\n * | `router:beforeResolve` | {@link ResolveContextCallback} | Yes | Before component loading |\n * | `router:afterResolve` | {@link ResolveContextCallback} | No | After components loaded |\n * | `router:afterLeave` | {@link RouteChangeCallback} | No | After leaving route |\n * | `router:beforeRender` | {@link RenderContextCallback} | No | Before DOM update |\n * | `router:afterRender` | {@link RenderContextCallback} | No | After DOM update |\n * | `router:scroll` | {@link ScrollContextCallback} | No | For scroll behavior |\n * | `router:afterEnter` | {@link RouteChangeCallback} | No | After entering route |\n * | `router:afterEach` | {@link RouteChangeCallback} | No | Navigation complete |\n * | `router:error` | {@link RouterErrorCallback} | No | Navigation error |\n * | `router:routeAdded` | {@link RouteAddedCallback} | No | Dynamic route added |\n * | `router:routeRemoved` | {@link RouteRemovedCallback} | No | Dynamic route removed |\n *\n * ## Reactive Signals\n * - `currentRoute: Signal<RouteLocation | null>` - Current route info\n * - `previousRoute: Signal<RouteLocation | null>` - Previous route info\n * - `currentParams: Signal<RouteParams>` - Current route params\n * - `currentQuery: Signal<QueryParams>` - Current query params\n * - `currentLayout: Signal<MountResult | null>` - Mounted layout instance\n * - `currentView: Signal<MountResult | null>` - Mounted view instance\n * - `isReady: Signal<boolean>` - Router readiness state\n *\n * @note Internal API Access Policy:\n * As a core Eleva plugin, the Router may access internal Eleva APIs (prefixed with _)\n * such as `eleva._components`. This is intentional and these internal APIs are\n * considered stable for official plugins. Third-party plugins should avoid\n * accessing internal APIs as they may change without notice.\n *\n * @example\n * // Basic setup\n * const router = new Router(eleva, {\n * mode: 'hash',\n * mount: '#app',\n * routes: [\n * { path: '/', component: HomePage },\n * { path: '/users/:id', component: UserPage },\n * { path: '*', component: NotFoundPage }\n * ]\n * });\n *\n * // Start router\n * await router.start();\n *\n * // Navigate programmatically\n * const success = await router.navigate('/users/123');\n *\n * // Watch for route changes\n * router.currentRoute.watch((route) => {\n * document.title = route?.meta?.title || 'My App';\n * });\n *\n * @private\n */\nclass Router {\n /**\n * Creates an instance of the Router.\n * @param {Eleva} eleva - The Eleva framework instance.\n * @param {RouterOptions} options - The configuration options for the router.\n * @throws {Error} If the routing mode is invalid.\n */\n constructor(eleva, options = {}) {\n /** @type {Eleva} The Eleva framework instance. */\n this.eleva = eleva;\n\n /** @type {RouterOptions} The merged router options. */\n this.options = {\n mode: \"hash\",\n queryParam: \"view\",\n viewSelector: \"view\",\n ...options,\n };\n\n /** @private @type {RouteDefinition[]} The processed list of route definitions. */\n this.routes = this._processRoutes(options.routes || []);\n\n /** @private @type {Emitter} The shared Eleva event emitter for global hooks. */\n this.emitter = this.eleva.emitter;\n\n /** @private @type {boolean} A flag indicating if the router has been started. */\n this.isStarted = false;\n\n /** @private @type {boolean} A flag to prevent navigation loops from history events. */\n this._isNavigating = false;\n\n /** @private @type {number} Counter for tracking navigation operations to prevent race conditions. */\n this._navigationId = 0;\n\n /** @private @type {UnsubscribeFunction[]} A collection of cleanup functions for event listeners. */\n this.eventListeners = [];\n\n /** @type {Signal<RouteLocation | null>} A reactive signal holding the current route's information. */\n this.currentRoute = new this.eleva.signal(null);\n\n /** @type {Signal<RouteLocation | null>} A reactive signal holding the previous route's information. */\n this.previousRoute = new this.eleva.signal(null);\n\n /** @type {Signal<RouteParams>} A reactive signal holding the current route's parameters. */\n this.currentParams = new this.eleva.signal({});\n\n /** @type {Signal<QueryParams>} A reactive signal holding the current route's query parameters. */\n this.currentQuery = new this.eleva.signal({});\n\n /** @type {Signal<MountResult | null>} A reactive signal for the currently mounted layout instance. */\n this.currentLayout = new this.eleva.signal(null);\n\n /** @type {Signal<MountResult | null>} A reactive signal for the currently mounted view (page) instance. */\n this.currentView = new this.eleva.signal(null);\n\n /** @type {Signal<boolean>} A reactive signal indicating if the router is ready (started and initial navigation complete). */\n this.isReady = new this.eleva.signal(false);\n\n /** @private @type {Map<string, RouterPlugin>} Map of registered plugins by name. */\n this.plugins = new Map();\n\n /** @private @type {NavigationGuard[]} Array of global before-each navigation guards. */\n this._beforeEachGuards = [];\n\n // If onBeforeEach was provided in options, add it to the guards array\n if (options.onBeforeEach) {\n this._beforeEachGuards.push(options.onBeforeEach);\n }\n\n /** @type {RouterErrorHandler} The error handler instance. Can be overridden by plugins. */\n this.errorHandler = CoreErrorHandler;\n\n /** @private @type {Map<string, {x: number, y: number}>} Saved scroll positions by route path. */\n this._scrollPositions = new Map();\n\n this._validateOptions();\n }\n\n /**\n * Validates the provided router options.\n * @private\n * @throws {Error} If the routing mode is invalid.\n */\n _validateOptions() {\n if (![\"hash\", \"query\", \"history\"].includes(this.options.mode)) {\n this.errorHandler.handle(\n new Error(\n `Invalid routing mode: ${this.options.mode}. Must be \"hash\", \"query\", or \"history\".`\n ),\n \"Configuration validation failed\"\n );\n }\n }\n\n /**\n * Pre-processes route definitions to parse their path segments for efficient matching.\n * @private\n * @param {RouteDefinition[]} routes - The raw route definitions.\n * @returns {RouteDefinition[]} The processed routes.\n */\n _processRoutes(routes) {\n const processedRoutes = [];\n for (const route of routes) {\n try {\n processedRoutes.push({\n ...route,\n segments: this._parsePathIntoSegments(route.path),\n });\n } catch (error) {\n this.errorHandler.warn(\n `Invalid path in route definition \"${route.path || \"undefined\"}\": ${error.message}`,\n { route, error }\n );\n }\n }\n return processedRoutes;\n }\n\n /**\n * Parses a route path string into an array of static and parameter segments.\n * @private\n * @param {string} path - The path pattern to parse.\n * @returns {{type: 'static' | 'param', value?: string, name?: string}[]} An array of segment objects.\n * @throws {Error} If the route path is not a valid string.\n */\n _parsePathIntoSegments(path) {\n if (!path || typeof path !== \"string\") {\n this.errorHandler.handle(\n new Error(\"Route path must be a non-empty string\"),\n \"Path parsing failed\",\n { path }\n );\n }\n\n const normalizedPath = path.replace(/\\/+/g, \"/\").replace(/\\/$/, \"\") || \"/\";\n\n if (normalizedPath === \"/\") {\n return [];\n }\n\n return normalizedPath\n .split(\"/\")\n .filter(Boolean)\n .map((segment) => {\n if (segment.startsWith(\":\")) {\n const paramName = segment.substring(1);\n if (!paramName) {\n this.errorHandler.handle(\n new Error(`Invalid parameter segment: ${segment}`),\n \"Path parsing failed\",\n { segment, path }\n );\n }\n return { type: \"param\", name: paramName };\n }\n return { type: \"static\", value: segment };\n });\n }\n\n /**\n * Finds the view element within a container using multiple selector strategies.\n * @private\n * @param {HTMLElement} container - The parent element to search within.\n * @returns {HTMLElement} The found view element or the container itself as a fallback.\n */\n _findViewElement(container) {\n const selector = this.options.viewSelector;\n return (\n container.querySelector(`#${selector}`) ||\n container.querySelector(`.${selector}`) ||\n container.querySelector(`[data-${selector}]`) ||\n container.querySelector(selector) ||\n container\n );\n }\n\n /**\n * Starts the router, initializes event listeners, and performs the initial navigation.\n * @returns {Promise<Router>} The router instance for method chaining.\n * @listens window:hashchange In hash mode, triggers route changes.\n * @listens window:popstate In history/query mode, triggers route changes.\n * @emits router:ready When initialization completes successfully.\n * @see destroy - Stop the router and clean up listeners.\n * @see navigate - Programmatically navigate to a route.\n *\n * @example\n * // Basic usage\n * await router.start();\n *\n * // Method chaining\n * await router.start().then(r => r.navigate('/home'));\n *\n * // Reactive readiness\n * router.isReady.watch((ready) => {\n * if (ready) console.log('Router is ready!');\n * });\n */\n async start() {\n if (this.isStarted) {\n this.errorHandler.warn(\"Router is already started\");\n return this;\n }\n if (typeof window === \"undefined\") {\n this.errorHandler.warn(\n \"Router start skipped: `window` object not available (SSR environment)\"\n );\n return this;\n }\n if (\n typeof document !== \"undefined\" &&\n !document.querySelector(this.options.mount)\n ) {\n this.errorHandler.warn(\n `Mount element \"${this.options.mount}\" was not found in the DOM. The router will not start.`,\n { mountSelector: this.options.mount }\n );\n return this;\n }\n const handler = () => this._handleRouteChange();\n if (this.options.mode === \"hash\") {\n window.addEventListener(\"hashchange\", handler);\n this.eventListeners.push(() =>\n window.removeEventListener(\"hashchange\", handler)\n );\n } else {\n window.addEventListener(\"popstate\", handler);\n this.eventListeners.push(() =>\n window.removeEventListener(\"popstate\", handler)\n );\n }\n this.isStarted = true;\n // Initial navigation is not a popstate event\n await this._handleRouteChange(false);\n // Set isReady to true after initial navigation completes\n this.isReady.value = true;\n await this.emitter.emit(\"router:ready\", this);\n return this;\n }\n\n /**\n * Stops the router and cleans up event listeners.\n * Unmounts the current layout instance if present.\n * @async\n * @returns {Promise<void>}\n * @see start - Restart the router after destroying.\n */\n async destroy() {\n if (!this.isStarted) return;\n\n // Clean up plugins\n for (const plugin of this.plugins.values()) {\n if (typeof plugin.destroy === \"function\") {\n try {\n await plugin.destroy(this);\n } catch (error) {\n this.errorHandler.log(`Plugin ${plugin.name} destroy failed`, error);\n }\n }\n }\n\n this.eventListeners.forEach((cleanup) => cleanup());\n this.eventListeners = [];\n if (this.currentLayout.value) {\n await this.currentLayout.value.unmount();\n }\n this.isStarted = false;\n this.isReady.value = false;\n }\n\n /**\n * Alias for destroy(). Stops the router and cleans up all resources.\n * Provided for semantic consistency (start/stop pattern).\n * @async\n * @returns {Promise<void>}\n *\n * @example\n * await router.start();\n * // ... later\n * await router.stop();\n */\n async stop() {\n return this.destroy();\n }\n\n /**\n * Programmatically navigates to a new route.\n * @async\n * @param {string | NavigationTarget} location - The target location as a path string or navigation target object.\n * @param {NavigationParams} [params] - Route parameters (only used when location is a string).\n * @returns {Promise<boolean>} True if navigation succeeded, false if blocked by guards or failed.\n * @emits router:error When navigation fails due to an exception.\n * @see start - Initialize the router before navigating.\n * @see currentRoute - Access the current route after navigation.\n *\n * @example\n * // Basic navigation\n * await router.navigate('/users/123');\n *\n * // Check if navigation succeeded\n * const success = await router.navigate('/protected');\n * if (!success) {\n * console.log('Navigation was blocked by a guard');\n * }\n *\n * // Navigate with options\n * await router.navigate({\n * path: '/users/:id',\n * params: { id: '123' },\n * query: { tab: 'profile' },\n * replace: true\n * });\n */\n async navigate(location, params = {}) {\n try {\n const target =\n typeof location === \"string\" ? { path: location, params } : location;\n let path = this._buildPath(target.path, target.params || {});\n const query = target.query || {};\n\n if (Object.keys(query).length > 0) {\n const queryString = new URLSearchParams(query).toString();\n if (queryString) path += `?${queryString}`;\n }\n\n if (this._isSameRoute(path, target.params, query)) {\n return true; // Already at this route, consider it successful\n }\n\n const navigationSuccessful = await this._proceedWithNavigation(path);\n\n if (navigationSuccessful) {\n // Increment navigation ID and capture it for this navigation\n const currentNavId = ++this._navigationId;\n this._isNavigating = true;\n\n try {\n const state = target.state || {};\n const replace = target.replace || false;\n const historyMethod = replace ? \"replaceState\" : \"pushState\";\n\n if (this.options.mode === \"hash\") {\n if (replace) {\n const newUrl = `${window.location.pathname}${window.location.search}#${path}`;\n window.history.replaceState(state, \"\", newUrl);\n } else {\n window.location.hash = path;\n }\n } else {\n const url =\n this.options.mode === \"query\" ? this._buildQueryUrl(path) : path;\n history[historyMethod](state, \"\", url);\n }\n } finally {\n // Always reset the flag via microtask, even if history manipulation throws\n // Only reset if no newer navigation has started\n queueMicrotask(() => {\n if (this._navigationId === currentNavId) {\n this._isNavigating = false;\n }\n });\n }\n }\n\n return navigationSuccessful;\n } catch (error) {\n this.errorHandler.log(\"Navigation failed\", error);\n await this.emitter.emit(\"router:error\", error);\n return false;\n }\n }\n\n /**\n * Builds a URL for query mode.\n * @private\n * @param {string} path - The path to set as the query parameter.\n * @returns {string} The full URL with the updated query string.\n */\n _buildQueryUrl(path) {\n const urlParams = new URLSearchParams(window.location.search);\n urlParams.set(this.options.queryParam, path.split(\"?\")[0]);\n return `${window.location.pathname}?${urlParams.toString()}`;\n }\n\n /**\n * Checks if the target route is identical to the current route.\n * @private\n * @param {string} path - The target path with query string.\n * @param {object} params - The target params.\n * @param {object} query - The target query.\n * @returns {boolean} True if the routes are the same.\n */\n _isSameRoute(path, params, query) {\n const current = this.currentRoute.value;\n if (!current) return false;\n const [targetPath, queryString] = path.split(\"?\");\n const targetQuery = query || this._parseQuery(queryString || \"\");\n return (\n current.path === targetPath &&\n JSON.stringify(current.params) === JSON.stringify(params || {}) &&\n JSON.stringify(current.query) === JSON.stringify(targetQuery)\n );\n }\n\n /**\n * Injects dynamic parameters into a path string.\n * Replaces `:param` placeholders with URL-encoded values from the params object.\n *\n * @private\n * @param {string} path - The path pattern containing `:param` placeholders.\n * @param {RouteParams} params - Key-value pairs to inject into the path.\n * @returns {string} The path with all parameters replaced.\n *\n * @example\n * this._buildPath('/users/:id/posts/:postId', { id: '123', postId: '456' });\n * // Returns: '/users/123/posts/456'\n */\n _buildPath(path, params) {\n let result = path;\n for (const [key, value] of Object.entries(params)) {\n // Fix: Handle special characters and ensure proper encoding\n const encodedValue = encodeURIComponent(String(value));\n result = result.replace(new RegExp(`:${key}\\\\b`, \"g\"), encodedValue);\n }\n return result;\n }\n\n /**\n * The handler for browser-initiated route changes (e.g., back/forward buttons).\n *\n * @private\n * @async\n * @param {boolean} [isPopState=true] - Whether this is a popstate event (back/forward navigation).\n * @returns {Promise<void>}\n * @emits router:error When route change handling fails.\n */\n async _handleRouteChange(isPopState = true) {\n if (this._isNavigating) return;\n\n try {\n const from = this.currentRoute.value;\n const toLocation = this._getCurrentLocation();\n\n const navigationSuccessful = await this._proceedWithNavigation(\n toLocation.fullUrl,\n isPopState\n );\n\n // If navigation was blocked by a guard, revert the URL change\n if (!navigationSuccessful && from) {\n this.navigate({ path: from.path, query: from.query, replace: true });\n }\n } catch (error) {\n this.errorHandler.log(\"Route change handling failed\", error, {\n currentUrl: typeof window !== \"undefined\" ? window.location.href : \"\",\n });\n await this.emitter.emit(\"router:error\", error);\n }\n }\n\n /**\n * Manages the core navigation lifecycle. Runs guards before committing changes.\n *\n * @private\n * @async\n * @param {string} fullPath - The full path (e.g., '/users/123?foo=bar') to navigate to.\n * @param {boolean} [isPopState=false] - Whether this navigation was triggered by popstate (back/forward).\n * @returns {Promise<boolean>} `true` if navigation succeeded, `false` if aborted.\n * @emits router:notFound When no matching route is found.\n * @emits router:beforeResolve Before component resolution (can block/redirect).\n * @emits router:afterResolve After components are resolved.\n * @emits router:afterLeave After leaving the previous route.\n * @emits router:beforeRender Before DOM rendering.\n * @emits router:afterRender After DOM rendering completes.\n * @emits router:scroll After render, for scroll behavior handling.\n * @emits router:afterEnter After entering the new route.\n * @emits router:afterEach After navigation completes successfully.\n * @emits router:error When an error occurs during navigation.\n * @see _runGuards - Guard execution.\n * @see _resolveComponents - Component resolution.\n * @see _render - DOM rendering.\n */\n async _proceedWithNavigation(fullPath, isPopState = false) {\n const from = this.currentRoute.value;\n const [path, queryString] = (fullPath || \"/\").split(\"?\");\n const toLocation = {\n path: path.startsWith(\"/\") ? path : `/${path}`,\n query: this._parseQuery(queryString),\n fullUrl: fullPath,\n };\n\n let toMatch = this._matchRoute(toLocation.path);\n\n if (!toMatch) {\n const notFoundRoute = this.routes.find((route) => route.path === \"*\");\n if (notFoundRoute) {\n toMatch = {\n route: notFoundRoute,\n params: {\n pathMatch: decodeURIComponent(toLocation.path.substring(1)),\n },\n };\n } else {\n await this.emitter.emit(\n \"router:error\",\n new Error(`Route not found: ${toLocation.path}`),\n toLocation,\n from\n );\n return false;\n }\n }\n\n const to = {\n ...toLocation,\n params: toMatch.params,\n meta: toMatch.route.meta || {},\n name: toMatch.route.name,\n matched: toMatch.route,\n };\n\n try {\n // 1. Run all *pre-navigation* guards.\n const canNavigate = await this._runGuards(to, from, toMatch.route);\n if (!canNavigate) return false;\n\n // 2. Save current scroll position before navigating away\n if (from && typeof window !== \"undefined\") {\n this._scrollPositions.set(from.path, {\n x: window.scrollX || window.pageXOffset || 0,\n y: window.scrollY || window.pageYOffset || 0,\n });\n }\n\n // 3. Emit beforeResolve event - plugins can show loading indicators\n /** @type {ResolveContext} */\n const resolveContext = {\n to,\n from,\n route: toMatch.route,\n layoutComponent: null,\n pageComponent: null,\n cancelled: false,\n redirectTo: null,\n };\n await this.emitter.emit(\"router:beforeResolve\", resolveContext);\n\n // Check if resolution was cancelled or redirected\n if (resolveContext.cancelled) return false;\n if (resolveContext.redirectTo) {\n this.navigate(resolveContext.redirectTo);\n return false;\n }\n\n // 4. Resolve async components *before* touching the DOM.\n const { layoutComponent, pageComponent } = await this._resolveComponents(\n toMatch.route\n );\n\n // 5. Emit afterResolve event - plugins can hide loading indicators\n resolveContext.layoutComponent = layoutComponent;\n resolveContext.pageComponent = pageComponent;\n await this.emitter.emit(\"router:afterResolve\", resolveContext);\n\n // 6. Unmount the previous view/layout.\n if (from) {\n const toLayout = toMatch.route.layout || this.options.globalLayout;\n const fromLayout = from.matched.layout || this.options.globalLayout;\n\n const tryUnmount = async (instance) => {\n if (!instance) return;\n\n try {\n await instance.unmount();\n } catch (error) {\n this.errorHandler.warn(\"Error during component unmount\", {\n error,\n instance,\n });\n }\n };\n\n if (toLayout !== fromLayout) {\n await tryUnmount(this.currentLayout.value);\n this.currentLayout.value = null;\n } else {\n await tryUnmount(this.currentView.value);\n this.currentView.value = null;\n }\n\n // Call `afterLeave` hook *after* the old component has been unmounted.\n if (from.matched.afterLeave) {\n await from.matched.afterLeave(to, from);\n }\n await this.emitter.emit(\"router:afterLeave\", to, from);\n }\n\n // 7. Update reactive state.\n this.previousRoute.value = from;\n this.currentRoute.value = to;\n this.currentParams.value = to.params || {};\n this.currentQuery.value = to.query || {};\n\n // 8. Emit beforeRender event - plugins can add transitions\n /** @type {RenderContext} */\n const renderContext = {\n to,\n from,\n layoutComponent,\n pageComponent,\n };\n await this.emitter.emit(\"router:beforeRender\", renderContext);\n\n // 9. Render the new components.\n await this._render(layoutComponent, pageComponent);\n\n // 10. Emit afterRender event - plugins can trigger animations\n await this.emitter.emit(\"router:afterRender\", renderContext);\n\n // 11. Emit scroll event - plugins can handle scroll restoration\n /** @type {ScrollContext} */\n const scrollContext = {\n to,\n from,\n savedPosition: isPopState\n ? this._scrollPositions.get(to.path) || null\n : null,\n };\n await this.emitter.emit(\"router:scroll\", scrollContext);\n\n // 12. Run post-navigation hooks.\n if (toMatch.route.afterEnter) {\n await toMatch.route.afterEnter(to, from);\n }\n await this.emitter.emit(\"router:afterEnter\", to, from);\n await this.emitter.emit(\"router:afterEach\", to, from);\n\n return true;\n } catch (error) {\n this.errorHandler.log(\"Error during navigation\", error, { to, from });\n await this.emitter.emit(\"router:error\", error, to, from);\n return false;\n }\n }\n\n /**\n * Executes all applicable navigation guards for a transition in order.\n * Guards are executed in the following order:\n * 1. Global beforeEach event (emitter-based, can block via context)\n * 2. Global beforeEach guards (registered via onBeforeEach)\n * 3. Route-specific beforeLeave guard (from the route being left)\n * 4. Route-specific beforeEnter guard (from the route being entered)\n *\n * @private\n * @param {RouteLocation} to - The target route location.\n * @param {RouteLocation | null} from - The current route location (null on initial navigation).\n * @param {RouteDefinition} route - The matched route definition.\n * @returns {Promise<boolean>} `false` if navigation should be aborted.\n * @emits router:beforeEach Before guards run (can block/redirect via context).\n */\n async _runGuards(to, from, route) {\n // Create navigation context that plugins can modify to block navigation\n /** @type {NavigationContext} */\n const navContext = {\n to,\n from,\n cancelled: false,\n redirectTo: null,\n };\n\n // Emit beforeEach event with context - plugins can block by modifying context\n await this.emitter.emit(\"router:beforeEach\", navContext);\n\n // Check if navigation was cancelled or redirected by event listeners\n if (navContext.cancelled) return false;\n if (navContext.redirectTo) {\n this.navigate(navContext.redirectTo);\n return false;\n }\n\n // Collect all guards in execution order\n const guards = [\n ...this._beforeEachGuards,\n ...(from && from.matched.beforeLeave ? [from.matched.beforeLeave] : []),\n ...(route.beforeEnter ? [route.beforeEnter] : []),\n ];\n\n for (const guard of guards) {\n const result = await guard(to, from);\n if (result === false) return false;\n if (typeof result === \"string\" || typeof result === \"object\") {\n this.navigate(result);\n return false;\n }\n }\n return true;\n }\n\n /**\n * Resolves a string component definition to a component object.\n * @private\n * @param {string} def - The component name to resolve.\n * @returns {ComponentDefinition} The resolved component.\n * @throws {Error} If the component is not registered.\n *\n * @note Core plugins (Router, Attr, Store) may access eleva._components\n * directly. This is intentional and stable for official Eleva plugins shipped\n * with the framework. Third-party plugins should use eleva.component() for\n * registration and avoid direct access to internal APIs.\n */\n _resolveStringComponent(def) {\n const componentDef = this.eleva._components.get(def);\n if (!componentDef) {\n this.errorHandler.handle(\n new Error(`Component \"${def}\" not registered.`),\n \"Component resolution failed\",\n {\n componentName: def,\n availableComponents: Array.from(this.eleva._components.keys()),\n }\n );\n }\n return componentDef;\n }\n\n /**\n * Resolves a function component definition to a component object.\n * @private\n * @async\n * @param {() => ComponentDefinition | Promise<ComponentDefinition | { default: ComponentDefinition }>} def - The function to resolve.\n * @returns {Promise<ComponentDefinition>} The resolved component.\n * @throws {Error} If the function fails to load the component.\n */\n async _resolveFunctionComponent(def) {\n try {\n const funcStr = def.toString();\n const isAsyncImport =\n funcStr.includes(\"import(\") || funcStr.startsWith(\"() =>\");\n\n const result = await def();\n return isAsyncImport ? result.default || result : result;\n } catch (error) {\n this.errorHandler.handle(\n new Error(`Failed to load async component: ${error.message}`),\n \"Component resolution failed\",\n { function: def.toString(), error }\n );\n }\n }\n\n /**\n * Validates a component definition object.\n * @private\n * @param {unknown} def - The component definition to validate.\n * @returns {ComponentDefinition} The validated component.\n * @throws {Error} If the component definition is invalid.\n */\n _validateComponentDefinition(def) {\n if (!def || typeof def !== \"object\") {\n this.errorHandler.handle(\n new Error(`Invalid component definition: ${typeof def}`),\n \"Component validation failed\",\n { definition: def }\n );\n }\n\n if (\n typeof def.template !== \"function\" &&\n typeof def.template !== \"string\"\n ) {\n this.errorHandler.handle(\n new Error(\"Component missing template property\"),\n \"Component validation failed\",\n { definition: def }\n );\n }\n\n return def;\n }\n\n /**\n * Resolves a component definition to a component object.\n * @private\n * @param {unknown} def - The component definition to resolve.\n * @returns {Promise<ComponentDefinition | null>} The resolved component or null.\n */\n async _resolveComponent(def) {\n if (def === null || def === undefined) {\n return null;\n }\n\n if (typeof def === \"string\") {\n return this._resolveStringComponent(def);\n }\n\n if (typeof def === \"function\") {\n return await this._resolveFunctionComponent(def);\n }\n\n if (def && typeof def === \"object\") {\n return this._validateComponentDefinition(def);\n }\n\n this.errorHandler.handle(\n new Error(`Invalid component definition: ${typeof def}`),\n \"Component resolution failed\",\n { definition: def }\n );\n }\n\n /**\n * Asynchronously resolves the layout and page components for a route.\n * @private\n * @async\n * @param {RouteDefinition} route - The route to resolve components for.\n * @returns {Promise<{layoutComponent: ComponentDefinition | null, pageComponent: ComponentDefinition}>}\n * @throws {Error} If page component cannot be resolved.\n */\n async _resolveComponents(route) {\n const effectiveLayout = route.layout || this.options.globalLayout;\n\n try {\n const [layoutComponent, pageComponent] = await Promise.all([\n this._resolveComponent(effectiveLayout),\n this._resolveComponent(route.component),\n ]);\n\n if (!pageComponent) {\n this.errorHandler.handle(\n new Error(\n `Page component is null or undefined for route: ${route.path}`\n ),\n \"Component resolution failed\",\n { route: route.path }\n );\n }\n\n return { layoutComponent, pageComponent };\n } catch (error) {\n this.errorHandler.log(\n `Error resolving components for route ${route.path}`,\n error,\n { route: route.path }\n );\n throw error;\n }\n }\n\n /**\n * Renders the components for the current route into the DOM.\n *\n * Rendering algorithm:\n * 1. Find the mount element using options.mount selector\n * 2. If layoutComponent exists:\n * a. Mount layout to mount element\n * b. Find view element within layout (using viewSelector)\n * c. Mount page component to view element\n * 3. If no layoutComponent:\n * a. Mount page component directly to mount element\n * b. Set currentLayout to null\n *\n * @private\n * @async\n * @param {ComponentDefinition | null} layoutComponent - The pre-loaded layout component.\n * @param {ComponentDefinition} pageComponent - The pre-loaded page component.\n * @returns {Promise<void>}\n * @throws {Error} If mount element is not found in the DOM.\n * @throws {Error} If component mounting fails (propagated from eleva.mount).\n */\n async _render(layoutComponent, pageComponent) {\n const mountEl = document.querySelector(this.options.mount);\n if (!mountEl) {\n this.errorHandler.handle(\n new Error(`Mount element \"${this.options.mount}\" not found.`),\n { mountSelector: this.options.mount }\n );\n }\n\n if (layoutComponent) {\n const layoutInstance = await this.eleva.mount(\n mountEl,\n this._wrapComponentWithChildren(layoutComponent)\n );\n this.currentLayout.value = layoutInstance;\n const viewEl = this._findViewElement(layoutInstance.container);\n const viewInstance = await this.eleva.mount(\n viewEl,\n this._wrapComponentWithChildren(pageComponent)\n );\n this.currentView.value = viewInstance;\n } else {\n const viewInstance = await this.eleva.mount(\n mountEl,\n this._wrapComponentWithChildren(pageComponent)\n );\n this.currentView.value = viewInstance;\n this.currentLayout.value = null;\n }\n }\n\n /**\n * Creates a getter function for router context properties.\n * @private\n * @param {string} property - The property name to access.\n * @param {unknown} defaultValue - The default value if property is undefined.\n * @returns {() => unknown} A getter function.\n */\n _createRouteGetter(property, defaultValue) {\n return () => this.currentRoute.value?.[property] ?? defaultValue;\n }\n\n /**\n * Wraps a component definition to inject router-specific context into its setup function.\n * @private\n * @param {ComponentDefinition} component - The component to wrap.\n * @returns {ComponentDefinition} The wrapped component definition.\n */\n _wrapComponent(component) {\n const originalSetup = component.setup;\n const self = this;\n\n return {\n ...component,\n async setup(ctx) {\n /** @type {RouterContext} */\n ctx.router = {\n navigate: self.navigate.bind(self),\n current: self.currentRoute,\n previous: self.previousRoute,\n\n // Route property getters\n get params() {\n return self._createRouteGetter(\"params\", {})();\n },\n get query() {\n return self._createRouteGetter(\"query\", {})();\n },\n get path() {\n return self._createRouteGetter(\"path\", \"/\")();\n },\n get fullUrl() {\n return self._createRouteGetter(\"fullUrl\", window.location.href)();\n },\n get meta() {\n return self._createRouteGetter(\"meta\", {})();\n },\n };\n\n return originalSetup ? await originalSetup(ctx) : {};\n },\n };\n }\n\n /**\n * Recursively wraps all child components to ensure they have access to router context.\n * String component references are returned as-is (context injected during mount).\n * Objects are wrapped with router context and their children are recursively wrapped.\n *\n * @private\n * @param {ComponentDefinition | string} component - The component to wrap (can be a definition object or a registered component name).\n * @returns {ComponentDefinition | string} The wrapped component definition or the original string reference.\n * @see _wrapComponent - Single component wrapping.\n */\n _wrapComponentWithChildren(component) {\n // If the component is a string (registered component name), return as-is\n // The router context will be injected when the component is resolved during mounting\n if (typeof component === \"string\") {\n return component;\n }\n\n // If not a valid component object, return as-is\n if (!component || typeof component !== \"object\") {\n return component;\n }\n\n const wrappedComponent = this._wrapComponent(component);\n\n // If the component has children, wrap them too\n if (\n wrappedComponent.children &&\n typeof wrappedComponent.children === \"object\"\n ) {\n const wrappedChildren = {};\n for (const [selector, childComponent] of Object.entries(\n wrappedComponent.children\n )) {\n wrappedChildren[selector] =\n this._wrapComponentWithChildren(childComponent);\n }\n wrappedComponent.children = wrappedChildren;\n }\n\n return wrappedComponent;\n }\n\n /**\n * Gets the current location information from the browser's window object.\n * @private\n * @returns {Omit<RouteLocation, 'params' | 'meta' | 'name' | 'matched'>}\n */\n _getCurrentLocation() {\n if (typeof window === \"undefined\")\n return { path: \"/\", query: {}, fullUrl: \"\" };\n let path, queryString, fullUrl;\n switch (this.options.mode) {\n case \"hash\":\n fullUrl = window.location.hash.slice(1) || \"/\";\n [path, queryString] = fullUrl.split(\"?\");\n break;\n case \"query\":\n const urlParams = new URLSearchParams(window.location.search);\n path = urlParams.get(this.options.queryParam) || \"/\";\n queryString = window.location.search.slice(1);\n fullUrl = path;\n break;\n default: // 'history' mode\n path = window.location.pathname || \"/\";\n queryString = window.location.search.slice(1);\n fullUrl = `${path}${queryString ? \"?\" + queryString : \"\"}`;\n }\n return {\n path: path.startsWith(\"/\") ? path : `/${path}`,\n query: this._parseQuery(queryString),\n fullUrl,\n };\n }\n\n /**\n * Parses a query string into a key-value object.\n * Uses URLSearchParams for robust parsing of encoded values.\n *\n * @private\n * @param {string} queryString - The query string to parse (without leading '?').\n * @returns {QueryParams} Key-value pairs from the query string.\n *\n * @example\n * this._parseQuery('foo=bar&baz=qux');\n * // Returns: { foo: 'bar', baz: 'qux' }\n */\n _parseQuery(queryString) {\n const query = {};\n if (queryString) {\n new URLSearchParams(queryString).forEach((value, key) => {\n query[key] = value;\n });\n }\n return query;\n }\n\n /**\n * Matches a given path against the registered routes.\n * @private\n * @param {string} path - The path to match.\n * @returns {{route: RouteDefinition, params: Object<string, string>} | null} The matched route and its params, or null.\n */\n _matchRoute(path) {\n const pathSegments = path.split(\"/\").filter(Boolean);\n\n for (const route of this.routes) {\n // Handle the root path as a special case.\n if (route.path === \"/\") {\n if (pathSegments.length === 0) return { route, params: {} };\n continue;\n }\n\n if (route.segments.length !== pathSegments.length) continue;\n\n const params = {};\n let isMatch = true;\n for (let i = 0; i < route.segments.length; i++) {\n const routeSegment = route.segments[i];\n const pathSegment = pathSegments[i];\n if (routeSegment.type === \"param\") {\n params[routeSegment.name] = decodeURIComponent(pathSegment);\n } else if (routeSegment.value !== pathSegment) {\n isMatch = false;\n break;\n }\n }\n if (isMatch) return { route, params };\n }\n return null;\n }\n\n // ============================================\n // Dynamic Route Management API\n // ============================================\n\n /**\n * Adds a new route dynamically at runtime.\n * The route will be processed and available for navigation immediately.\n * Routes are inserted before the wildcard (*) route if one exists.\n *\n * @param {RouteDefinition} route - The route definition to add.\n * @param {RouteDefinition} [parentRoute] - Optional parent route to add as a child (not yet implemented).\n * @returns {() => void} A function to remove the added route (returns no-op if route was invalid).\n * @emits router:routeAdded When a route is successfully added.\n *\n * @example\n * // Add a route dynamically\n * const removeRoute = router.addRoute({\n * path: '/dynamic',\n * component: DynamicPage,\n * meta: { title: 'Dynamic Page' }\n * });\n *\n * // Later, remove the route\n * removeRoute();\n */\n addRoute(route, parentRoute = null) {\n if (!route || !route.path) {\n this.errorHandler.warn(\"Invalid route definition: missing path\", {\n route,\n });\n return () => {};\n }\n\n // Check if route already exists\n if (this.hasRoute(route.path)) {\n this.errorHandler.warn(`Route \"${route.path}\" already exists`, { route });\n return () => {};\n }\n\n // Process the route (parse segments)\n const processedRoute = {\n ...route,\n segments: this._parsePathIntoSegments(route.path),\n };\n\n // Add to routes array (before wildcard if exists)\n const wildcardIndex = this.routes.findIndex((r) => r.path === \"*\");\n if (wildcardIndex !== -1) {\n this.routes.splice(wildcardIndex, 0, processedRoute);\n } else {\n this.routes.push(processedRoute);\n }\n\n // Emit event for plugins\n this.emitter.emit(\"router:routeAdded\", processedRoute);\n\n // Return removal function\n return () => this.removeRoute(route.path);\n }\n\n /**\n * Removes a route by its path.\n *\n * @param {string} path - The path of the route to remove.\n * @returns {boolean} True if the route was removed, false if not found.\n * @emits router:routeRemoved When a route is successfully removed.\n *\n * @example\n * router.removeRoute('/dynamic');\n */\n removeRoute(path) {\n const index = this.routes.findIndex((r) => r.path === path);\n if (index === -1) {\n return false;\n }\n\n const [removedRoute] = this.routes.splice(index, 1);\n\n // Emit event for plugins\n this.emitter.emit(\"router:routeRemoved\", removedRoute);\n\n return true;\n }\n\n /**\n * Checks if a route with the given path exists.\n *\n * @param {string} path - The path to check.\n * @returns {boolean} True if the route exists.\n *\n * @example\n * if (router.hasRoute('/users/:id')) {\n * console.log('User route exists');\n * }\n */\n hasRoute(path) {\n return this.routes.some((r) => r.path === path);\n }\n\n /**\n * Gets all registered routes.\n *\n * @returns {RouteDefinition[]} A copy of the routes array.\n *\n * @example\n * const routes = router.getRoutes();\n * console.log('Available routes:', routes.map(r => r.path));\n */\n getRoutes() {\n return [...this.routes];\n }\n\n /**\n * Gets a route by its path.\n *\n * @param {string} path - The path of the route to get.\n * @returns {RouteDefinition | undefined} The route definition or undefined.\n *\n * @example\n * const route = router.getRoute('/users/:id');\n * if (route) {\n * console.log('Route meta:', route.meta);\n * }\n */\n getRoute(path) {\n return this.routes.find((r) => r.path === path);\n }\n\n // ============================================\n // Hook Registration Methods\n // ============================================\n\n /**\n * Registers a global pre-navigation guard.\n * Multiple guards can be registered and will be executed in order.\n * Guards can also be registered via the emitter using `router:beforeEach` event.\n *\n * @param {NavigationGuard} guard - The guard function to register.\n * @returns {() => void} A function to unregister the guard.\n *\n * @example\n * // Register a guard\n * const unregister = router.onBeforeEach((to, from) => {\n * if (to.meta.requiresAuth && !isAuthenticated()) {\n * return '/login';\n * }\n * });\n *\n * // Later, unregister the guard\n * unregister();\n */\n onBeforeEach(guard) {\n this._beforeEachGuards.push(guard);\n return () => {\n const index = this._beforeEachGuards.indexOf(guard);\n if (index > -1) {\n this._beforeEachGuards.splice(index, 1);\n }\n };\n }\n /**\n * Registers a global hook that runs after a new route component has been mounted.\n * @param {NavigationHook} hook - The hook function to register.\n * @returns {() => void} A function to unregister the hook.\n * @listens router:afterEnter\n */\n onAfterEnter(hook) {\n return this.emitter.on(\"router:afterEnter\", hook);\n }\n\n /**\n * Registers a global hook that runs after a route component has been unmounted.\n * @param {NavigationHook} hook - The hook function to register.\n * @returns {() => void} A function to unregister the hook.\n * @listens router:afterLeave\n */\n onAfterLeave(hook) {\n return this.emitter.on(\"router:afterLeave\", hook);\n }\n\n /**\n * Registers a global hook that runs after a navigation has been confirmed and all hooks have completed.\n * @param {NavigationHook} hook - The hook function to register.\n * @returns {() => void} A function to unregister the hook.\n * @listens router:afterEach\n */\n onAfterEach(hook) {\n return this.emitter.on(\"router:afterEach\", hook);\n }\n\n /**\n * Registers a global error handler for navigation errors.\n * @param {(error: Error, to?: RouteLocation, from?: RouteLocation) => void} handler - The error handler function.\n * @returns {() => void} A function to unregister the handler.\n * @listens router:error\n */\n onError(handler) {\n return this.emitter.on(\"router:error\", handler);\n }\n\n /**\n * Registers a plugin with the router.\n * Logs a warning if the plugin is already registered.\n *\n * @param {RouterPlugin} plugin - The plugin to register (must have install method).\n * @param {Record<string, unknown>} [options={}] - Options to pass to plugin.install().\n * @returns {void}\n * @throws {Error} If plugin does not have an install method.\n */\n use(plugin, options = {}) {\n if (typeof plugin.install !== \"function\") {\n this.errorHandler.handle(\n new Error(\"Plugin must have an install method\"),\n \"Plugin registration failed\",\n { plugin }\n );\n }\n\n // Check if plugin is already registered\n if (this.plugins.has(plugin.name)) {\n this.errorHandler.warn(`Plugin \"${plugin.name}\" is already registered`, {\n existingPlugin: this.plugins.get(plugin.name),\n });\n return;\n }\n\n this.plugins.set(plugin.name, plugin);\n plugin.install(this, options);\n }\n\n /**\n * Gets all registered plugins.\n * @returns {RouterPlugin[]} Array of registered plugins.\n */\n getPlugins() {\n return Array.from(this.plugins.values());\n }\n\n /**\n * Gets a plugin by name.\n * @param {string} name - The plugin name.\n * @returns {RouterPlugin | undefined} The plugin or undefined.\n */\n getPlugin(name) {\n return this.plugins.get(name);\n }\n\n /**\n * Removes a plugin from the router.\n * @param {string} name - The plugin name.\n * @returns {boolean} True if the plugin was removed.\n */\n removePlugin(name) {\n const plugin = this.plugins.get(name);\n if (!plugin) return false;\n\n // Call destroy if available\n if (typeof plugin.destroy === \"function\") {\n try {\n plugin.destroy(this);\n } catch (error) {\n this.errorHandler.log(`Plugin ${name} destroy failed`, error);\n }\n }\n\n return this.plugins.delete(name);\n }\n\n /**\n * Sets a custom error handler. Used by error handling plugins.\n * Logs a warning if the provided handler is invalid (missing required methods).\n * @param {RouterErrorHandler} errorHandler - The error handler object with handle, warn, and log methods.\n * @returns {void}\n */\n setErrorHandler(errorHandler) {\n if (\n errorHandler &&\n typeof errorHandler.handle === \"function\" &&\n typeof errorHandler.warn === \"function\" &&\n typeof errorHandler.log === \"function\"\n ) {\n this.errorHandler = errorHandler;\n } else {\n console.warn(\n \"[ElevaRouter] Invalid error handler provided. Must have handle, warn, and log methods.\"\n );\n }\n }\n}\n\n/**\n * @class 🚀 RouterPlugin\n * @classdesc A powerful, reactive, and flexible Router Plugin for Eleva applications.\n * This plugin provides comprehensive client-side routing functionality including:\n * - Multiple routing modes (hash, history, query)\n * - Navigation guards and lifecycle hooks\n * - Reactive state management\n * - Component resolution and lazy loading\n * - Layout and page component separation\n * - Plugin system for extensibility\n * - Advanced error handling\n *\n * @example\n * // Install the plugin\n * const app = new Eleva(\"myApp\");\n *\n * const HomePage = { template: () => `<h1>Home</h1>` };\n * const AboutPage = { template: () => `<h1>About Us</h1>` };\n * const UserPage = {\n * template: (ctx) => `<h1>User: ${ctx.router.params.id}</h1>`\n * };\n *\n * app.use(RouterPlugin, {\n * mount: '#app',\n * mode: 'hash',\n * routes: [\n * { path: '/', component: HomePage },\n * { path: '/about', component: AboutPage },\n * { path: '/users/:id', component: UserPage }\n * ]\n * });\n */\nexport const RouterPlugin = {\n /**\n * Unique identifier for the plugin\n * @type {string}\n */\n name: \"router\",\n\n /**\n * Plugin version\n * @type {string}\n */\n version: \"1.1.1\",\n\n /**\n * Plugin description\n * @type {string}\n */\n description: \"Client-side routing for Eleva applications\",\n\n /**\n * Installs the RouterPlugin into an Eleva instance.\n *\n * @public\n * @param {Eleva} eleva - The Eleva instance.\n * @param {RouterOptions} options - Router configuration options.\n * @param {string} options.mount - A CSS selector for the main element where the app is mounted.\n * @param {RouteDefinition[]} options.routes - An array of route definitions.\n * @param {'hash' | 'query' | 'history'} [options.mode='hash'] - The routing mode.\n * @param {string} [options.queryParam='view'] - The query parameter to use in 'query' mode.\n * @param {string} [options.viewSelector='view'] - Base selector for the view element (matched as #id, .class, [data-*], or raw selector).\n * @param {boolean} [options.autoStart=true] - Whether to start the router automatically.\n * @param {NavigationGuard} [options.onBeforeEach] - A global guard executed before every navigation.\n * @param {RouteComponent} [options.globalLayout] - A global layout for all routes.\n * @returns {Router} The created router instance.\n * @throws {Error} If 'mount' option is not provided.\n * @throws {Error} If 'routes' option is not an array.\n * @throws {Error} If component registration fails during route processing.\n * @description\n * Registers route/layout components, sets `eleva.router`, and adds helpers\n * (`eleva.navigate`, `eleva.getCurrentRoute`, `eleva.getRouteParams`, `eleva.getRouteQuery`).\n * When `autoStart` is enabled, startup is scheduled via microtask.\n *\n * @example\n * // main.js\n * import Eleva from 'eleva';\n * import { RouterPlugin } from './plugins/RouterPlugin.js';\n *\n * const app = new Eleva('myApp');\n *\n * const HomePage = { template: () => `<h1>Home</h1>` };\n * const AboutPage = { template: () => `<h1>About Us</h1>` };\n *\n * app.use(RouterPlugin, {\n * mount: '#app',\n * routes: [\n * { path: '/', component: HomePage },\n * { path: '/about', component: AboutPage }\n * ]\n * });\n */\n install(eleva, options = {}) {\n if (!options.mount) {\n throw new Error(\"[RouterPlugin] 'mount' option is required\");\n }\n\n if (!options.routes || !Array.isArray(options.routes)) {\n throw new Error(\"[RouterPlugin] 'routes' option must be an array\");\n }\n\n /**\n * Registers a component definition with the Eleva instance.\n * This method handles both inline component objects and pre-registered component names.\n *\n * @inner\n * @param {unknown} def - The component definition to register.\n * @param {string} type - The type of component for naming (e.g., \"Route\", \"Layout\").\n * @returns {string | null} The registered component name or null if no definition provided.\n */\n const register = (def, type) => {\n if (!def) return null;\n\n if (typeof def === \"object\" && def !== null && !def.name) {\n const name = `Eleva${type}Component_${Math.random()\n .toString(36)\n .slice(2, 11)}`;\n\n try {\n eleva.component(name, def);\n return name;\n } catch (error) {\n throw new Error(\n `[RouterPlugin] Failed to register ${type} component: ${error.message}`\n );\n }\n }\n return def;\n };\n\n if (options.globalLayout) {\n options.globalLayout = register(options.globalLayout, \"GlobalLayout\");\n }\n\n (options.routes || []).forEach((route) => {\n route.component = register(route.component, \"Route\");\n if (route.layout) {\n route.layout = register(route.layout, \"RouteLayout\");\n }\n });\n\n const router = new Router(eleva, options);\n /** @type {Router} */\n eleva.router = router;\n\n if (options.autoStart !== false) {\n queueMicrotask(() => router.start());\n }\n\n // Add plugin metadata to the Eleva instance\n if (!eleva.plugins) {\n eleva.plugins = new Map();\n }\n eleva.plugins.set(this.name, {\n name: this.name,\n version: this.version,\n description: this.description,\n options,\n });\n\n // Add utility methods for manual router access\n /** @type {NavigateFunction} */\n eleva.navigate = router.navigate.bind(router);\n /** @type {() => RouteLocation | null} */\n eleva.getCurrentRoute = () => router.currentRoute.value;\n /** @type {() => RouteParams} */\n eleva.getRouteParams = () => router.currentParams.value;\n /** @type {() => QueryParams} */\n eleva.getRouteQuery = () => router.currentQuery.value;\n\n return router;\n },\n\n /**\n * Uninstalls the plugin from the Eleva instance.\n *\n * @public\n * @async\n * @param {Eleva} eleva - The Eleva instance.\n * @returns {Promise<void>}\n * @description\n * Destroys the router instance, removes `eleva.router`, and deletes helper methods\n * (`eleva.navigate`, `eleva.getCurrentRoute`, `eleva.getRouteParams`, `eleva.getRouteQuery`).\n */\n async uninstall(eleva) {\n if (eleva.router) {\n await eleva.router.destroy();\n delete eleva.router;\n }\n\n // Remove plugin metadata\n if (eleva.plugins) {\n eleva.plugins.delete(this.name);\n }\n\n // Remove utility methods\n delete eleva.navigate;\n delete eleva.getCurrentRoute;\n delete eleva.getRouteParams;\n delete eleva.getRouteQuery;\n },\n};\n\n// Short name export for convenience\nexport { RouterPlugin as Router };\n"],"names":["CoreErrorHandler","handle","error","context","details","formattedError","Error","message","originalError","warn","log","Router","_validateOptions","includes","options","mode","errorHandler","_processRoutes","routes","processedRoutes","route","push","segments","_parsePathIntoSegments","path","normalizedPath","replace","split","filter","Boolean","map","segment","startsWith","paramName","substring","type","name","value","_findViewElement","container","selector","viewSelector","querySelector","start","isStarted","window","document","mount","mountSelector","handler","_handleRouteChange","addEventListener","eventListeners","removeEventListener","isReady","emitter","emit","destroy","plugin","plugins","values","forEach","cleanup","currentLayout","unmount","stop","navigate","location","params","target","_buildPath","query","Object","keys","length","queryString","URLSearchParams","toString","_isSameRoute","navigationSuccessful","_proceedWithNavigation","currentNavId","_navigationId","_isNavigating","state","newUrl","pathname","search","history","replaceState","hash","url","_buildQueryUrl","queueMicrotask","urlParams","set","queryParam","current","currentRoute","targetPath","targetQuery","_parseQuery","JSON","stringify","result","key","entries","encodedValue","encodeURIComponent","String","RegExp","isPopState","from","toLocation","_getCurrentLocation","fullUrl","currentUrl","href","fullPath","toMatch","_matchRoute","notFoundRoute","find","pathMatch","decodeURIComponent","to","meta","matched","_runGuards","_scrollPositions","x","scrollX","pageXOffset","y","scrollY","pageYOffset","resolveContext","layoutComponent","pageComponent","cancelled","redirectTo","_resolveComponents","toLayout","layout","globalLayout","fromLayout","tryUnmount","instance","currentView","afterLeave","previousRoute","currentParams","currentQuery","renderContext","_render","scrollContext","savedPosition","get","afterEnter","navContext","guard","_beforeEachGuards","beforeLeave","beforeEnter","_resolveStringComponent","def","componentDef","eleva","_components","componentName","availableComponents","Array","_resolveFunctionComponent","funcStr","isAsyncImport","default","function","_validateComponentDefinition","definition","template","_resolveComponent","effectiveLayout","Promise","all","component","mountEl","layoutInstance","_wrapComponentWithChildren","viewEl","viewInstance","_createRouteGetter","property","defaultValue","_wrapComponent","originalSetup","setup","self","ctx","router","bind","previous","wrappedComponent","children","wrappedChildren","childComponent","slice","pathSegments","isMatch","i","routeSegment","pathSegment","addRoute","hasRoute","processedRoute","wildcardIndex","findIndex","r","splice","removeRoute","index","removedRoute","some","getRoutes","getRoute","onBeforeEach","indexOf","onAfterEnter","hook","on","onAfterLeave","onAfterEach","onError","use","install","has","existingPlugin","getPlugins","getPlugin","removePlugin","delete","setErrorHandler","signal","Map","RouterPlugin","version","description","isArray","register","Math","random","autoStart","getCurrentRoute","getRouteParams","getRouteQuery","uninstall"],"mappings":"0CAuXA,IAAMA,EAAmB,CAQvBC,OAAOC,CAAK,CAA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G,YAAY,CAAC7D,KAAK,CAEvDkI,EAAMqF,cAAc,CAAG,IAAMtD,EAAO/C,aAAa,CAAClH,KAAK,CAEvDkI,EAAMsF,aAAa,CAAG,IAAMvD,EAAO9C,YAAY,CAACnH,KAAK,CAE9CiK,CACT,EAaA,MAAMwD,UAAUvF,CAAK,EACfA,EAAM+B,MAAM,GACd,MAAM/B,EAAM+B,MAAM,CAAC7I,OAAO,GAC1B,OAAO8G,EAAM+B,MAAM,EAIjB/B,EAAM5G,OAAO,EACf4G,EAAM5G,OAAO,CAACoL,MAAM,CAAC,IAAI,CAAC3M,IAAI,EAIhC,OAAOmI,EAAMrG,QAAQ,CACrB,OAAOqG,EAAMoF,eAAe,CAC5B,OAAOpF,EAAMqF,cAAc,CAC3B,OAAOrF,EAAMsF,aAAa,AAC5B,CACF"}
|
package/dist/plugins/store.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! Eleva Store Plugin v1.1.
|
|
1
|
+
/*! Eleva Store Plugin v1.1.1 | MIT License | https://elevajs.com */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -251,7 +251,7 @@
|
|
|
251
251
|
/**
|
|
252
252
|
* Plugin version
|
|
253
253
|
* @type {string}
|
|
254
|
-
*/ version: "1.1.
|
|
254
|
+
*/ version: "1.1.1",
|
|
255
255
|
/**
|
|
256
256
|
* Plugin description
|
|
257
257
|
* @type {string}
|