eleva 1.0.0-rc.2 → 1.0.0-rc.4

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.
Files changed (41) hide show
  1. package/README.md +135 -2
  2. package/dist/eleva-plugins.cjs.js +1330 -0
  3. package/dist/eleva-plugins.cjs.js.map +1 -0
  4. package/dist/eleva-plugins.esm.js +1327 -0
  5. package/dist/eleva-plugins.esm.js.map +1 -0
  6. package/dist/eleva-plugins.umd.js +1336 -0
  7. package/dist/eleva-plugins.umd.js.map +1 -0
  8. package/dist/eleva-plugins.umd.min.js +3 -0
  9. package/dist/eleva-plugins.umd.min.js.map +1 -0
  10. package/dist/eleva.cjs.js +15 -34
  11. package/dist/eleva.cjs.js.map +1 -1
  12. package/dist/eleva.d.ts +0 -1
  13. package/dist/eleva.esm.js +15 -34
  14. package/dist/eleva.esm.js.map +1 -1
  15. package/dist/eleva.umd.js +15 -34
  16. package/dist/eleva.umd.js.map +1 -1
  17. package/dist/eleva.umd.min.js +2 -2
  18. package/dist/eleva.umd.min.js.map +1 -1
  19. package/dist/plugins/attr.umd.js +231 -0
  20. package/dist/plugins/attr.umd.js.map +1 -0
  21. package/dist/plugins/attr.umd.min.js +3 -0
  22. package/dist/plugins/attr.umd.min.js.map +1 -0
  23. package/dist/plugins/router.umd.js +1115 -0
  24. package/dist/plugins/router.umd.js.map +1 -0
  25. package/dist/plugins/router.umd.min.js +3 -0
  26. package/dist/plugins/router.umd.min.js.map +1 -0
  27. package/package.json +40 -1
  28. package/src/core/Eleva.js +6 -7
  29. package/src/modules/Renderer.js +8 -36
  30. package/src/plugins/Attr.js +252 -0
  31. package/src/plugins/Router.js +1217 -0
  32. package/src/plugins/index.js +34 -0
  33. package/types/core/Eleva.d.ts +0 -1
  34. package/types/core/Eleva.d.ts.map +1 -1
  35. package/types/modules/Renderer.d.ts.map +1 -1
  36. package/types/plugins/Attr.d.ts +28 -0
  37. package/types/plugins/Attr.d.ts.map +1 -0
  38. package/types/plugins/Router.d.ts +500 -0
  39. package/types/plugins/Router.d.ts.map +1 -0
  40. package/types/plugins/index.d.ts +3 -0
  41. package/types/plugins/index.d.ts.map +1 -0
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * @fileoverview Eleva Plugin System
5
+ *
6
+ * This module exports all official Eleva plugins. Plugins provide optional
7
+ * functionality that can be added to Eleva applications as needed.
8
+ *
9
+ * Tree-shaking is supported - only imported plugins will be included in your bundle.
10
+ *
11
+ * @example
12
+ * // Import specific plugins (recommended for optimal tree-shaking)
13
+ * import { Attr } from 'eleva/plugins';
14
+ *
15
+ * const app = new Eleva("myApp");
16
+ * app.use(Attr, {
17
+ * enableAria: true,
18
+ * enableData: true,
19
+ * enableBoolean: true,
20
+ * enableDynamic: true
21
+ * });
22
+ *
23
+ * @example
24
+ * // Import multiple plugins
25
+ * import { Attr, Router } from 'eleva/plugins';
26
+ *
27
+ * const app = new Eleva("myApp");
28
+ * app.use(Attr);
29
+ * app.use(Router);
30
+ */
31
+
32
+ // Export plugins with clean names
33
+ export { AttrPlugin as Attr } from "./Attr.js";
34
+ export { RouterPlugin as Router } from "./Router.js";
@@ -213,7 +213,6 @@ export class Eleva {
213
213
  *
214
214
  * @private
215
215
  * @param {HTMLElement} element - The DOM element to extract props from
216
- * @param {string} prefix - The prefix to look for in attributes
217
216
  * @returns {Record<string, string>} An object containing the extracted props
218
217
  * @example
219
218
  * // For an element with attributes:
@@ -1 +1 @@
1
- {"version":3,"file":"Eleva.d.ts","sourceRoot":"","sources":["../../src/core/Eleva.js"],"names":[],"mappings":"AAOA;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AAEH;;;;;;;;GAQG;AAEH;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH;IACE;;;;;;;;;;;;;;;;;;OAkBG;IACH,kBAfW,MAAM,WACN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7B;;;;;;eAMU,WAAW;;;;UAEX,gBAAgB;;;;aAEhB,MAAY,OAAO,CAAC,IAAI,CAAC;;;;;;aAMzB,CAAS,IAAK,EAAL,KAAK,EAAE,IAAuB,EAAvB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,IAAI;;;;UAE9C,MAAM;;wBAvEI,uBAAuB;uBADxB,sBAAsB;yBAEpB,wBAAwB"}
@@ -1 +1 @@
1
- {"version":3,"file":"Renderer.d.ts","sourceRoot":"","sources":["../../src/modules/Renderer.js"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IAMI;;;;OAIG;IACH,uBAAmD;IAGrD;;;;;;;;;OASG;IACH,2BANW,WAAW,WACX,MAAM,GACJ,IAAI,CAkBhB;IAED;;;;;;;OAOG;IACH,cAoDC;IAED;;;;;;;OAOG;IACH,mBAiBC;IAED;;;;;;;OAOG;IACH,oBAIC;IAED;;;;;;;OAOG;IACH,0BA8CC;IAED;;;;;;;OAOG;IACH,oBAoBC;IAED;;;;;;;;OAQG;IACH,sBAQC;IAED;;;;;;OAMG;IACH,oBAIC;CACF"}
1
+ {"version":3,"file":"Renderer.d.ts","sourceRoot":"","sources":["../../src/modules/Renderer.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH;IAMI;;;;OAIG;IACH,uBAAmD;IAGrD;;;;;;;;;OASG;IACH,2BANW,WAAW,WACX,MAAM,GACJ,IAAI,CAkBhB;IAED;;;;;;;OAOG;IACH,cAoDC;IAED;;;;;;;OAOG;IACH,mBAiBC;IAED;;;;;;;OAOG;IACH,oBAIC;IAED;;;;;;;OAOG;IACH,0BAyBC;IAED;;;;;;;OAOG;IACH,oBAoBC;IAED;;;;;;;;OAQG;IACH,sBAQC;IAED;;;;;;OAMG;IACH,oBAIC;CACF"}
@@ -0,0 +1,28 @@
1
+ export namespace AttrPlugin {
2
+ let name: string;
3
+ let version: string;
4
+ let description: string;
5
+ /**
6
+ * Installs the plugin into the Eleva instance
7
+ *
8
+ * @param {Object} eleva - The Eleva instance
9
+ * @param {Object} options - Plugin configuration options
10
+ * @param {boolean} [options.enableAria=true] - Enable ARIA attribute handling
11
+ * @param {boolean} [options.enableData=true] - Enable data attribute handling
12
+ * @param {boolean} [options.enableBoolean=true] - Enable boolean attribute handling
13
+ * @param {boolean} [options.enableDynamic=true] - Enable dynamic property detection
14
+ */
15
+ function install(eleva: Object, options?: {
16
+ enableAria?: boolean | undefined;
17
+ enableData?: boolean | undefined;
18
+ enableBoolean?: boolean | undefined;
19
+ enableDynamic?: boolean | undefined;
20
+ }): void;
21
+ /**
22
+ * Uninstalls the plugin from the Eleva instance
23
+ *
24
+ * @param {Object} eleva - The Eleva instance
25
+ */
26
+ function uninstall(eleva: Object): void;
27
+ }
28
+ //# sourceMappingURL=Attr.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Attr.d.ts","sourceRoot":"","sources":["../../src/plugins/Attr.js"],"names":[],"mappings":";cAyCY,MAAM;iBAMN,MAAM;qBAMN,MAAM;IAIhB;;;;;;;;;OASG;IACH,wBAPW,MAAM,YAEd;QAA0B,UAAU;QACV,UAAU;QACV,aAAa;QACb,aAAa;KACzC,QAmKA;IAED;;;;OAIG;IACH,0BAFW,MAAM,QAgBhB"}
@@ -0,0 +1,500 @@
1
+ export type RouterPlugin = {
2
+ /**
3
+ * - The plugin name.
4
+ */
5
+ name: string;
6
+ /**
7
+ * - The plugin version.
8
+ */
9
+ version?: string | undefined;
10
+ /**
11
+ * - The install function that receives the router instance.
12
+ */
13
+ install: Function;
14
+ /**
15
+ * - Optional cleanup function called when the router is destroyed.
16
+ */
17
+ destroy?: Function | undefined;
18
+ };
19
+ export namespace RouterPlugin {
20
+ let name: string;
21
+ let version: string;
22
+ let description: string;
23
+ /**
24
+ * Installs the RouterPlugin into an Eleva instance.
25
+ *
26
+ * @param {Eleva} eleva - The Eleva instance
27
+ * @param {RouterOptions} options - Router configuration options
28
+ * @param {string} options.mount - A CSS selector for the main element where the app is mounted
29
+ * @param {RouteDefinition[]} options.routes - An array of route definitions
30
+ * @param {'hash' | 'query' | 'history'} [options.mode='hash'] - The routing mode
31
+ * @param {string} [options.queryParam='page'] - The query parameter to use in 'query' mode
32
+ * @param {string} [options.viewSelector='view'] - The selector for the view element within a layout
33
+ * @param {boolean} [options.autoStart=true] - Whether to start the router automatically
34
+ * @param {NavigationGuard} [options.onBeforeEach] - A global guard executed before every navigation
35
+ * @param {string | ComponentDefinition | (() => Promise<{default: ComponentDefinition}>)} [options.globalLayout] - A global layout for all routes
36
+ *
37
+ * @example
38
+ * // main.js
39
+ * import Eleva from './eleva.js';
40
+ * import { RouterPlugin } from './plugins/RouterPlugin.js';
41
+ *
42
+ * const app = new Eleva('myApp');
43
+ *
44
+ * const HomePage = { template: () => `<h1>Home</h1>` };
45
+ * const AboutPage = { template: () => `<h1>About Us</h1>` };
46
+ *
47
+ * app.use(RouterPlugin, {
48
+ * mount: '#app',
49
+ * routes: [
50
+ * { path: '/', component: HomePage },
51
+ * { path: '/about', component: AboutPage }
52
+ * ]
53
+ * });
54
+ */
55
+ function install(eleva: Eleva, options?: RouterOptions): Router;
56
+ /**
57
+ * Uninstalls the plugin from the Eleva instance
58
+ *
59
+ * @param {Eleva} eleva - The Eleva instance
60
+ */
61
+ function uninstall(eleva: Eleva): Promise<void>;
62
+ }
63
+ export type Eleva = any;
64
+ export type Signal = any;
65
+ export type ComponentDefinition = any;
66
+ export type RouteLocation = {
67
+ /**
68
+ * - The path of the route (e.g., '/users/123').
69
+ */
70
+ path: string;
71
+ /**
72
+ * - An object representing the query parameters.
73
+ */
74
+ query: {
75
+ [x: string]: string;
76
+ };
77
+ /**
78
+ * - The complete URL including hash, path, and query string.
79
+ */
80
+ fullUrl: string;
81
+ /**
82
+ * - An object containing dynamic route parameters.
83
+ */
84
+ params: {
85
+ [x: string]: string;
86
+ };
87
+ /**
88
+ * - The meta object associated with the matched route.
89
+ */
90
+ meta: {
91
+ [x: string]: any;
92
+ };
93
+ /**
94
+ * - The optional name of the matched route.
95
+ */
96
+ name?: string | undefined;
97
+ /**
98
+ * - The raw route definition object that was matched.
99
+ */
100
+ matched: RouteDefinition;
101
+ };
102
+ /**
103
+ * A function that acts as a guard for navigation. It runs *before* the navigation is confirmed.
104
+ * It can return:
105
+ * - `true` or `undefined`: to allow navigation.
106
+ * - `false`: to abort the navigation.
107
+ * - a `string` (path) or a `location object`: to redirect to a new route.
108
+ */
109
+ export type NavigationGuard = (to: RouteLocation, from: RouteLocation | null) => boolean | string | {
110
+ path: string;
111
+ } | void | Promise<boolean | string | {
112
+ path: string;
113
+ } | void>;
114
+ /**
115
+ * A function that acts as a lifecycle hook, typically for side effects. It does not affect navigation flow.
116
+ */
117
+ export type NavigationHook = (...args: any[]) => void | Promise<void>;
118
+ export type RouteDefinition = {
119
+ /**
120
+ * - The URL path pattern (e.g., '/', '/about', '/users/:id', '*').
121
+ */
122
+ path: string;
123
+ /**
124
+ * - The component to render. Can be a registered name, a definition object, or an async import function.
125
+ */
126
+ component: string | ComponentDefinition | (() => Promise<{
127
+ default: ComponentDefinition;
128
+ }>);
129
+ /**
130
+ * - An optional layout component to wrap the route's component.
131
+ */
132
+ layout?: string | ComponentDefinition | (() => Promise<{
133
+ default: ComponentDefinition;
134
+ }>);
135
+ /**
136
+ * - An optional name for the route.
137
+ */
138
+ name?: string | undefined;
139
+ /**
140
+ * - Optional metadata for the route (e.g., for titles, auth flags).
141
+ */
142
+ meta?: {
143
+ [x: string]: any;
144
+ } | undefined;
145
+ /**
146
+ * - A route-specific guard executed before entering the route.
147
+ */
148
+ beforeEnter?: NavigationGuard | undefined;
149
+ /**
150
+ * - A hook executed *after* the route has been entered and the new component is mounted.
151
+ */
152
+ afterEnter?: NavigationHook | undefined;
153
+ /**
154
+ * - A guard executed *before* leaving the current route.
155
+ */
156
+ beforeLeave?: NavigationGuard | undefined;
157
+ /**
158
+ * - A hook executed *after* leaving the current route and its component has been unmounted.
159
+ */
160
+ afterLeave?: NavigationHook | undefined;
161
+ };
162
+ export type RouterOptions = {
163
+ /**
164
+ * - A CSS selector for the main element where the app is mounted.
165
+ */
166
+ mount: string;
167
+ /**
168
+ * - An array of route definitions.
169
+ */
170
+ routes: RouteDefinition[];
171
+ /**
172
+ * - The routing mode.
173
+ */
174
+ mode?: "hash" | "query" | "history" | undefined;
175
+ /**
176
+ * - The query parameter to use in 'query' mode.
177
+ */
178
+ queryParam?: string | undefined;
179
+ /**
180
+ * - The selector for the view element within a layout.
181
+ */
182
+ viewSelector?: string | undefined;
183
+ /**
184
+ * - Whether to start the router automatically.
185
+ */
186
+ autoStart?: boolean | undefined;
187
+ /**
188
+ * - A global guard executed before every navigation.
189
+ */
190
+ onBeforeEach?: NavigationGuard | undefined;
191
+ /**
192
+ * - A global layout for all routes. Can be overridden by a route's specific layout.
193
+ */
194
+ globalLayout?: string | ComponentDefinition | (() => Promise<{
195
+ default: ComponentDefinition;
196
+ }>);
197
+ };
198
+ /**
199
+ * @typedef {Object} RouteLocation
200
+ * @property {string} path - The path of the route (e.g., '/users/123').
201
+ * @property {Object<string, string>} query - An object representing the query parameters.
202
+ * @property {string} fullUrl - The complete URL including hash, path, and query string.
203
+ * @property {Object<string, string>} params - An object containing dynamic route parameters.
204
+ * @property {Object<string, any>} meta - The meta object associated with the matched route.
205
+ * @property {string} [name] - The optional name of the matched route.
206
+ * @property {RouteDefinition} matched - The raw route definition object that was matched.
207
+ */
208
+ /**
209
+ * @typedef {(to: RouteLocation, from: RouteLocation | null) => boolean | string | {path: string} | void | Promise<boolean | string | {path: string} | void>} NavigationGuard
210
+ * A function that acts as a guard for navigation. It runs *before* the navigation is confirmed.
211
+ * It can return:
212
+ * - `true` or `undefined`: to allow navigation.
213
+ * - `false`: to abort the navigation.
214
+ * - a `string` (path) or a `location object`: to redirect to a new route.
215
+ */
216
+ /**
217
+ * @typedef {(...args: any[]) => void | Promise<void>} NavigationHook
218
+ * A function that acts as a lifecycle hook, typically for side effects. It does not affect navigation flow.
219
+ */
220
+ /**
221
+ * @typedef {Object} RouterPlugin
222
+ * @property {string} name - The plugin name.
223
+ * @property {string} [version] - The plugin version.
224
+ * @property {Function} install - The install function that receives the router instance.
225
+ * @property {Function} [destroy] - Optional cleanup function called when the router is destroyed.
226
+ */
227
+ /**
228
+ * @typedef {Object} RouteDefinition
229
+ * @property {string} path - The URL path pattern (e.g., '/', '/about', '/users/:id', '*').
230
+ * @property {string | ComponentDefinition | (() => Promise<{default: ComponentDefinition}>)} component - The component to render. Can be a registered name, a definition object, or an async import function.
231
+ * @property {string | ComponentDefinition | (() => Promise<{default: ComponentDefinition}>)} [layout] - An optional layout component to wrap the route's component.
232
+ * @property {string} [name] - An optional name for the route.
233
+ * @property {Object<string, any>} [meta] - Optional metadata for the route (e.g., for titles, auth flags).
234
+ * @property {NavigationGuard} [beforeEnter] - A route-specific guard executed before entering the route.
235
+ * @property {NavigationHook} [afterEnter] - A hook executed *after* the route has been entered and the new component is mounted.
236
+ * @property {NavigationGuard} [beforeLeave] - A guard executed *before* leaving the current route.
237
+ * @property {NavigationHook} [afterLeave] - A hook executed *after* leaving the current route and its component has been unmounted.
238
+ */
239
+ /**
240
+ * @class Router
241
+ * @classdesc A powerful, reactive, and flexible Router Plugin for Eleva.js.
242
+ * This class manages all routing logic, including state, navigation, and rendering.
243
+ * @private
244
+ */
245
+ declare class Router {
246
+ /**
247
+ * Creates an instance of the Router.
248
+ * @param {Eleva} eleva - The Eleva framework instance.
249
+ * @param {RouterOptions} options - The configuration options for the router.
250
+ */
251
+ constructor(eleva: Eleva, options?: RouterOptions);
252
+ /** @type {Eleva} The Eleva framework instance. */
253
+ eleva: Eleva;
254
+ /** @type {RouterOptions} The merged router options. */
255
+ options: RouterOptions;
256
+ /** @private @type {RouteDefinition[]} The processed list of route definitions. */
257
+ private routes;
258
+ /** @private @type {import('eleva').Emitter} The shared Eleva event emitter for global hooks. */
259
+ private emitter;
260
+ /** @private @type {boolean} A flag indicating if the router has been started. */
261
+ private isStarted;
262
+ /** @private @type {boolean} A flag to prevent navigation loops from history events. */
263
+ private _isNavigating;
264
+ /** @private @type {Array<() => void>} A collection of cleanup functions for event listeners. */
265
+ private eventListeners;
266
+ /** @type {Signal<RouteLocation | null>} A reactive signal holding the current route's information. */
267
+ currentRoute: Signal<RouteLocation | null>;
268
+ /** @type {Signal<RouteLocation | null>} A reactive signal holding the previous route's information. */
269
+ previousRoute: Signal<RouteLocation | null>;
270
+ /** @type {Signal<Object<string, string>>} A reactive signal holding the current route's parameters. */
271
+ currentParams: Signal<{
272
+ [x: string]: string;
273
+ }>;
274
+ /** @type {Signal<Object<string, string>>} A reactive signal holding the current route's query parameters. */
275
+ currentQuery: Signal<{
276
+ [x: string]: string;
277
+ }>;
278
+ /** @type {Signal<import('eleva').MountResult | null>} A reactive signal for the currently mounted layout instance. */
279
+ currentLayout: Signal<any | null>;
280
+ /** @type {Signal<import('eleva').MountResult | null>} A reactive signal for the currently mounted view (page) instance. */
281
+ currentView: Signal<any | null>;
282
+ /** @private @type {Map<string, RouterPlugin>} Map of registered plugins by name. */
283
+ private plugins;
284
+ /** @type {Object} The error handler instance. Can be overridden by plugins. */
285
+ errorHandler: Object;
286
+ /**
287
+ * Validates the provided router options.
288
+ * @private
289
+ * @throws {Error} If the routing mode is invalid.
290
+ */
291
+ private _validateOptions;
292
+ /**
293
+ * Pre-processes route definitions to parse their path segments for efficient matching.
294
+ * @private
295
+ * @param {RouteDefinition[]} routes - The raw route definitions.
296
+ * @returns {RouteDefinition[]} The processed routes.
297
+ */
298
+ private _processRoutes;
299
+ /**
300
+ * Parses a route path string into an array of static and parameter segments.
301
+ * @private
302
+ * @param {string} path - The path pattern to parse.
303
+ * @returns {Array<{type: 'static' | 'param', value?: string, name?: string}>} An array of segment objects.
304
+ * @throws {Error} If the route path is not a valid string.
305
+ */
306
+ private _parsePathIntoSegments;
307
+ /**
308
+ * Finds the view element within a container using multiple selector strategies.
309
+ * @private
310
+ * @param {HTMLElement} container - The parent element to search within.
311
+ * @returns {HTMLElement} The found view element or the container itself as a fallback.
312
+ */
313
+ private _findViewElement;
314
+ /**
315
+ * Starts the router, initializes event listeners, and performs the initial navigation.
316
+ * @returns {Promise<void>}
317
+ */
318
+ start(): Promise<void>;
319
+ /**
320
+ * Stops the router and cleans up all event listeners and mounted components.
321
+ * @returns {Promise<void>}
322
+ */
323
+ destroy(): Promise<void>;
324
+ /**
325
+ * Programmatically navigates to a new route.
326
+ * @param {string | {path: string, query?: object, params?: object, replace?: boolean, state?: object}} location - The target location as a string or object.
327
+ * @param {object} [params] - Optional route parameters (for string-based location).
328
+ * @returns {Promise<void>}
329
+ */
330
+ navigate(location: string | {
331
+ path: string;
332
+ query?: object;
333
+ params?: object;
334
+ replace?: boolean;
335
+ state?: object;
336
+ }, params?: object): Promise<void>;
337
+ /**
338
+ * Builds a URL for query mode.
339
+ * @private
340
+ * @param {string} path - The path to set as the query parameter.
341
+ * @returns {string} The full URL with the updated query string.
342
+ */
343
+ private _buildQueryUrl;
344
+ /**
345
+ * Checks if the target route is identical to the current route.
346
+ * @private
347
+ * @param {string} path - The target path with query string.
348
+ * @param {object} params - The target params.
349
+ * @param {object} query - The target query.
350
+ * @returns {boolean} - True if the routes are the same.
351
+ */
352
+ private _isSameRoute;
353
+ /**
354
+ * Injects dynamic parameters into a path string.
355
+ * @private
356
+ */
357
+ private _buildPath;
358
+ /**
359
+ * The handler for browser-initiated route changes (e.g., back/forward buttons).
360
+ * @private
361
+ */
362
+ private _handleRouteChange;
363
+ /**
364
+ * Manages the core navigation lifecycle. Runs guards before committing changes.
365
+ * @private
366
+ * @param {string} fullPath - The full path (e.g., '/users/123?foo=bar') to navigate to.
367
+ * @returns {Promise<boolean>} - `true` if navigation succeeded, `false` if aborted.
368
+ */
369
+ private _proceedWithNavigation;
370
+ /**
371
+ * Executes all applicable navigation guards for a transition in order.
372
+ * @private
373
+ * @returns {Promise<boolean>} - `false` if navigation should be aborted.
374
+ */
375
+ private _runGuards;
376
+ /**
377
+ * Resolves a string component definition to a component object.
378
+ * @private
379
+ * @param {string} def - The component name to resolve.
380
+ * @returns {ComponentDefinition} The resolved component.
381
+ * @throws {Error} If the component is not registered.
382
+ */
383
+ private _resolveStringComponent;
384
+ /**
385
+ * Resolves a function component definition to a component object.
386
+ * @private
387
+ * @param {Function} def - The function to resolve.
388
+ * @returns {Promise<ComponentDefinition>} The resolved component.
389
+ * @throws {Error} If the function fails to load the component.
390
+ */
391
+ private _resolveFunctionComponent;
392
+ /**
393
+ * Validates a component definition object.
394
+ * @private
395
+ * @param {any} def - The component definition to validate.
396
+ * @returns {ComponentDefinition} The validated component.
397
+ * @throws {Error} If the component definition is invalid.
398
+ */
399
+ private _validateComponentDefinition;
400
+ /**
401
+ * Resolves a component definition to a component object.
402
+ * @private
403
+ * @param {any} def - The component definition to resolve.
404
+ * @returns {Promise<ComponentDefinition | null>} The resolved component or null.
405
+ */
406
+ private _resolveComponent;
407
+ /**
408
+ * Asynchronously resolves the layout and page components for a route.
409
+ * @private
410
+ * @param {RouteDefinition} route - The route to resolve components for.
411
+ * @returns {Promise<{layoutComponent: ComponentDefinition | null, pageComponent: ComponentDefinition}>}
412
+ */
413
+ private _resolveComponents;
414
+ /**
415
+ * Renders the components for the current route into the DOM.
416
+ * @private
417
+ * @param {ComponentDefinition | null} layoutComponent - The pre-loaded layout component.
418
+ * @param {ComponentDefinition} pageComponent - The pre-loaded page component.
419
+ */
420
+ private _render;
421
+ /**
422
+ * Creates a getter function for router context properties.
423
+ * @private
424
+ * @param {string} property - The property name to access.
425
+ * @param {any} defaultValue - The default value if property is undefined.
426
+ * @returns {Function} A getter function.
427
+ */
428
+ private _createRouteGetter;
429
+ /**
430
+ * Wraps a component definition to inject router-specific context into its setup function.
431
+ * @private
432
+ * @param {ComponentDefinition} component - The component to wrap.
433
+ * @returns {ComponentDefinition} The wrapped component definition.
434
+ */
435
+ private _wrapComponent;
436
+ /**
437
+ * Recursively wraps all child components to ensure they have access to router context.
438
+ * @private
439
+ * @param {ComponentDefinition} component - The component to wrap.
440
+ * @returns {ComponentDefinition} The wrapped component definition.
441
+ */
442
+ private _wrapComponentWithChildren;
443
+ /**
444
+ * Gets the current location information from the browser's window object.
445
+ * @private
446
+ * @returns {Omit<RouteLocation, 'params' | 'meta' | 'name' | 'matched'>}
447
+ */
448
+ private _getCurrentLocation;
449
+ /**
450
+ * Parses a query string into a key-value object.
451
+ * @private
452
+ */
453
+ private _parseQuery;
454
+ /**
455
+ * Matches a given path against the registered routes.
456
+ * @private
457
+ * @param {string} path - The path to match.
458
+ * @returns {{route: RouteDefinition, params: Object<string, string>} | null} The matched route and its params, or null.
459
+ */
460
+ private _matchRoute;
461
+ /** Registers a global pre-navigation guard. */
462
+ onBeforeEach(guard: any): void;
463
+ /** Registers a global hook that runs after a new route component has been mounted *if* the route has an `afterEnter` hook. */
464
+ onAfterEnter(hook: any): void;
465
+ /** Registers a global hook that runs after a route component has been unmounted *if* the route has an `afterLeave` hook. */
466
+ onAfterLeave(hook: any): void;
467
+ /** Registers a global hook that runs after a navigation has been confirmed and all hooks have completed. */
468
+ onAfterEach(hook: any): void;
469
+ /** Registers a global error handler for navigation. */
470
+ onError(handler: any): void;
471
+ /**
472
+ * Registers a plugin with the router.
473
+ * @param {RouterPlugin} plugin - The plugin to register.
474
+ */
475
+ use(plugin: RouterPlugin, options?: {}): void;
476
+ /**
477
+ * Gets all registered plugins.
478
+ * @returns {RouterPlugin[]} Array of registered plugins.
479
+ */
480
+ getPlugins(): RouterPlugin[];
481
+ /**
482
+ * Gets a plugin by name.
483
+ * @param {string} name - The plugin name.
484
+ * @returns {RouterPlugin | undefined} The plugin or undefined.
485
+ */
486
+ getPlugin(name: string): RouterPlugin | undefined;
487
+ /**
488
+ * Removes a plugin from the router.
489
+ * @param {string} name - The plugin name.
490
+ * @returns {boolean} True if the plugin was removed.
491
+ */
492
+ removePlugin(name: string): boolean;
493
+ /**
494
+ * Sets a custom error handler. Used by error handling plugins.
495
+ * @param {Object} errorHandler - The error handler object with handle, warn, and log methods.
496
+ */
497
+ setErrorHandler(errorHandler: Object): void;
498
+ }
499
+ export {};
500
+ //# sourceMappingURL=Router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Router.d.ts","sourceRoot":"","sources":["../../src/plugins/Router.js"],"names":[],"mappings":";;;;UAkFc,MAAM;;;;;;;;;;;;;;;cA69BR,MAAM;iBAMN,MAAM;qBAMN,MAAM;IAIhB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,wBA7BW,KAAK,YACL,aAAa,UAqGvB;IAED;;;;OAIG;IACH,0BAFW,KAAK,iBAkBf;;;;;;;;;UAtoCW,MAAM;;;;;;;;;;aAEN,MAAM;;;;;;;;;;;;;;;;;;;;aAIN,eAAe;;;;;;;;;8BAIhB,CAAC,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,KAAK,OAAO,GAAG,MAAM,GAAG;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,OAAO,GAAG,MAAM,GAAG;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GAAG,IAAI,CAAC;;;;6BAS/I,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;;;;;UAcvC,MAAM;;;;eACN,MAAM,GAAG,mBAAmB,GAAG,CAAC,MAAM,OAAO,CAAC;QAAC,OAAO,EAAE,mBAAmB,CAAA;KAAC,CAAC,CAAC;;;;aAC9E,MAAM,GAAG,mBAAmB,GAAG,CAAC,MAAM,OAAO,CAAC;QAAC,OAAO,EAAE,mBAAmB,CAAA;KAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAs6B9E,MAAM;;;;YACN,eAAe,EAAE;;;;;;;;;;;;;;;;;;;;;;;;mBAMjB,MAAM,GAAG,mBAAmB,GAAG,CAAC,MAAM,OAAO,CAAC;QAAC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M,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAC,WAC3F,MAAM,GACJ,OAAO,CAAC,IAAI,CAAC,CA8CzB;IAED;;;;;OAKG;IACH,uBAIC;IAED;;;;;;;OAOG;IACH,qBAUC;IAED;;;OAGG;IACH,mBAQC;IAED;;;OAGG;IACH,2BAaC;IAED;;;;;OAKG;IACH,+BAsGC;IAED;;;;OAIG;IACH,mBAeC;IAED;;;;;;OAMG;IACH,gCAaC;IAED;;;;;;OAMG;IACH,kCAeC;IAED;;;;;;OAMG;IACH,qCAqBC;IAED;;;;;OAKG;IACH,0BAsBC;IAED;;;;;OAKG;IACH,2BA4BC;IAED;;;;;OAKG;IACH,gBA6BC;IAED;;;;;;OAMG;IACH,2BAEC;IAED;;;;;OAKG;IACH,uBAiCC;IAED;;;;;OAKG;IACH,mCAmBC;IAED;;;;OAIG;IACH,4BAyBC;IAED;;;OAGG;IACH,oBAQC;IAED;;;;;OAKG;IACH,oBA2BC;IAED,+CAA+C;IAC/C,+BAEC;IACD,8HAA8H;IAC9H,8BAEC;IACD,4HAA4H;IAC5H,8BAEC;IACD,4GAA4G;IAC5G,6BAEC;IACD,uDAAuD;IACvD,4BAEC;IAED;;;OAGG;IACH,YAFW,YAAY,sBAqBtB;IAED;;;OAGG;IACH,cAFa,YAAY,EAAE,CAI1B;IAED;;;;OAIG;IACH,gBAHW,MAAM,GACJ,YAAY,GAAG,SAAS,CAIpC;IAED;;;;OAIG;IACH,mBAHW,MAAM,GACJ,OAAO,CAgBnB;IAED;;;OAGG;IACH,8BAFW,MAAM,QAehB;CACF"}
@@ -0,0 +1,3 @@
1
+ export { AttrPlugin as Attr } from "./Attr.js";
2
+ export { RouterPlugin as Router } from "./Router.js";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.js"],"names":[],"mappings":""}