sibujs 4.0.1 → 4.2.0

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 (80) hide show
  1. package/README.md +29 -1
  2. package/dist/browser.cjs +21 -22
  3. package/dist/browser.js +6 -6
  4. package/dist/build.cjs +363 -110
  5. package/dist/build.js +15 -15
  6. package/dist/cdn.dev.global.js +398 -0
  7. package/dist/cdn.global.js +10 -10
  8. package/dist/{chunk-AD5YSZAN.js → chunk-2LOYNGBY.js} +2 -2
  9. package/dist/{chunk-VPP2FONR.js → chunk-2WLZ6757.js} +17 -10
  10. package/dist/{chunk-UNAYBND2.js → chunk-3VTSPNC5.js} +2 -2
  11. package/dist/{chunk-TIRZCERI.js → chunk-5DXA2J44.js} +1 -1
  12. package/dist/{chunk-QD4I7ZGZ.js → chunk-6ZGI3RBE.js} +149 -33
  13. package/dist/{chunk-JYXQCELN.js → chunk-7ALC7KGE.js} +13 -7
  14. package/dist/{chunk-XDOMTQHM.js → chunk-7VEC3UD2.js} +3 -3
  15. package/dist/{chunk-PTLJ7NQX.js → chunk-BMYYZWHX.js} +3 -3
  16. package/dist/{chunk-PHB3MCK4.js → chunk-BNKV4REK.js} +7 -8
  17. package/dist/{chunk-XET2RUJF.js → chunk-FOWBJZDL.js} +7 -8
  18. package/dist/{chunk-5BVKQX2F.js → chunk-GDUNQCCW.js} +4 -4
  19. package/dist/{chunk-TVURNWDK.js → chunk-HECVW343.js} +20 -9
  20. package/dist/{chunk-PHRH66Y7.js → chunk-HJEPKZ2O.js} +7 -8
  21. package/dist/{chunk-PJDSI2K7.js → chunk-HZEBO22J.js} +125 -42
  22. package/dist/{chunk-5INI7D2L.js → chunk-IXKSNWV5.js} +74 -11
  23. package/dist/{chunk-IKVUUE7D.js → chunk-KE4KWRDY.js} +3 -3
  24. package/dist/{chunk-AW6HPJ3L.js → chunk-KKLW7YWL.js} +1 -1
  25. package/dist/{chunk-XZMCVZW6.js → chunk-NEYWS4EX.js} +6 -6
  26. package/dist/{chunk-HYCCIYNS.js → chunk-NIOYEGBQ.js} +13 -14
  27. package/dist/{chunk-YLV26GAJ.js → chunk-OUWAIXIK.js} +3 -3
  28. package/dist/{chunk-E72G5JSK.js → chunk-P3DHXBR6.js} +1 -1
  29. package/dist/{chunk-J4WZMCIW.js → chunk-QCFLDD7C.js} +5 -5
  30. package/dist/{chunk-DHDZ7IVN.js → chunk-QKRPLZ2V.js} +7 -8
  31. package/dist/{chunk-52ERIVFD.js → chunk-QL4UREZO.js} +6 -6
  32. package/dist/{chunk-TNEHT3NG.js → chunk-SF3TB4K6.js} +8 -8
  33. package/dist/{chunk-HPXTUPJD.js → chunk-XZ2N525U.js} +6 -6
  34. package/dist/{customElement-CKLoO63w.d.ts → customElement-CNZxEB9G.d.cts} +77 -0
  35. package/dist/{customElement-CKLoO63w.d.cts → customElement-CNZxEB9G.d.ts} +77 -0
  36. package/dist/data.cjs +23 -25
  37. package/dist/data.js +9 -9
  38. package/dist/devtools.cjs +26 -23
  39. package/dist/devtools.d.cts +1 -1
  40. package/dist/devtools.d.ts +1 -1
  41. package/dist/devtools.js +8 -8
  42. package/dist/{dispose-4FZ6OFXR.js → dispose-46BOMMQJ.js} +2 -2
  43. package/dist/ecosystem.cjs +230 -68
  44. package/dist/ecosystem.js +11 -11
  45. package/dist/extras.cjs +251 -87
  46. package/dist/extras.d.cts +2 -2
  47. package/dist/extras.d.ts +2 -2
  48. package/dist/extras.js +25 -25
  49. package/dist/index.cjs +358 -104
  50. package/dist/index.d.cts +287 -34
  51. package/dist/index.d.ts +287 -34
  52. package/dist/index.js +17 -15
  53. package/dist/{introspect-RjLfIFpL.d.cts → introspect-D5xF-0Es.d.cts} +7 -0
  54. package/dist/{introspect-DOZfmC-4.d.ts → introspect-rSBIxEQi.d.ts} +7 -0
  55. package/dist/motion.cjs +21 -23
  56. package/dist/motion.js +5 -5
  57. package/dist/patterns.cjs +24 -25
  58. package/dist/patterns.d.cts +8 -0
  59. package/dist/patterns.d.ts +8 -0
  60. package/dist/patterns.js +7 -7
  61. package/dist/performance.cjs +24 -28
  62. package/dist/performance.js +9 -9
  63. package/dist/plugins.cjs +268 -87
  64. package/dist/plugins.d.cts +92 -0
  65. package/dist/plugins.d.ts +92 -0
  66. package/dist/plugins.js +18 -17
  67. package/dist/{ssr-JFP5535P.js → ssr-Y7XOEPEN.js} +5 -5
  68. package/dist/ssr.cjs +241 -80
  69. package/dist/ssr.js +12 -12
  70. package/dist/testing.cjs +19 -20
  71. package/dist/testing.js +5 -5
  72. package/dist/ui.cjs +106 -44
  73. package/dist/ui.d.cts +7 -1
  74. package/dist/ui.d.ts +7 -1
  75. package/dist/ui.js +10 -10
  76. package/dist/widgets.cjs +21 -22
  77. package/dist/widgets.d.cts +8 -0
  78. package/dist/widgets.d.ts +8 -0
  79. package/dist/widgets.js +9 -9
  80. package/package.json +11 -2
@@ -350,12 +350,34 @@ declare class SibuRouter {
350
350
  */
351
351
  get routeGetter(): () => RouteContext;
352
352
  }
353
+ /**
354
+ * Create the global router and make it the one `route()`, `navigate()` and
355
+ * `RouterLink` talk to. Any previously created router is destroyed first.
356
+ *
357
+ * @param routesOrOptions Either the route table, or the options object when
358
+ * routes are supplied later via {@link setRoutes}.
359
+ * @param options Router options when the first argument is the route table.
360
+ * @returns The created router instance.
361
+ */
353
362
  declare function createRouter(routesOrOptions: RouteDef[] | RouterOptions, options?: RouterOptions): SibuRouter;
354
363
  /**
355
364
  * Set routes on the global router (replaces existing routes).
356
365
  */
357
366
  declare function setRoutes(routes: RouteDef[]): void;
367
+ /**
368
+ * Read the current route as a plain snapshot.
369
+ *
370
+ * @returns The active {@link RouteContext} (path, params, query, hash).
371
+ * @throws If no router has been created yet.
372
+ */
358
373
  declare function route(): RouteContext;
374
+ /**
375
+ * Handle onto the global router's navigation surface.
376
+ *
377
+ * @returns An object exposing the current route plus `push`, `replace`, `go`,
378
+ * `back`, `forward` and the three guard registrars.
379
+ * @throws If no router has been created yet.
380
+ */
359
381
  declare function router(): {
360
382
  currentRoute: RouteContext;
361
383
  isReady: boolean;
@@ -369,18 +391,81 @@ declare function router(): {
369
391
  beforeResolve: (guard: NavigationGuard) => (() => void) | undefined;
370
392
  afterEach: (hook: (to: RouteContext, from: RouteContext) => void) => (() => void) | undefined;
371
393
  };
394
+ /**
395
+ * Navigate to a target, running every registered guard.
396
+ *
397
+ * @param to Path string or location descriptor.
398
+ * @param options `replace` swaps the current history entry instead of pushing;
399
+ * `state` is stored on the history entry.
400
+ * @returns A promise for the {@link NavigationResult} — resolved even when a
401
+ * guard cancels, so the outcome must be inspected rather than assumed.
402
+ * @throws If no router has been created yet.
403
+ */
372
404
  declare function navigate(to: NavigationTarget, options?: {
373
405
  replace?: boolean;
374
406
  state?: unknown;
375
407
  }): Promise<NavigationResult>;
408
+ /**
409
+ * Navigate by pushing a new history entry.
410
+ *
411
+ * @param to Path string or location descriptor.
412
+ * @returns A promise for the {@link NavigationResult}.
413
+ */
376
414
  declare function push(to: NavigationTarget): Promise<NavigationResult>;
415
+ /**
416
+ * Navigate by replacing the current history entry.
417
+ *
418
+ * @param to Path string or location descriptor.
419
+ * @returns A promise for the {@link NavigationResult}.
420
+ */
377
421
  declare function replace(to: NavigationTarget): Promise<NavigationResult>;
422
+ /**
423
+ * Move through history by a relative offset, as `history.go` does.
424
+ *
425
+ * @param delta Number of entries to move; negative goes back.
426
+ * @returns Nothing — history moves asynchronously, so nothing is awaited here.
427
+ */
378
428
  declare function go(delta: number): void;
429
+ /** Go back one history entry. Equivalent to `go(-1)`. */
379
430
  declare function back(): void;
431
+ /** Go forward one history entry. Equivalent to `go(1)`. */
380
432
  declare function forward(): void;
433
+ /**
434
+ * Register a guard that runs before every navigation is confirmed.
435
+ *
436
+ * @param guard Called with the target and current routes; return `false` to
437
+ * cancel, or a target to redirect.
438
+ * @returns An unregister function.
439
+ */
381
440
  declare function beforeEach(guard: NavigationGuard): () => void;
441
+ /**
442
+ * Register a guard that runs after `beforeEach` and after async components have
443
+ * resolved, but before the route commits.
444
+ *
445
+ * @param guard Called with the target and current routes.
446
+ * @returns An unregister function.
447
+ */
382
448
  declare function beforeResolve(guard: NavigationGuard): () => void;
449
+ /**
450
+ * Register a hook that runs after every confirmed navigation. It cannot cancel
451
+ * or redirect — by the time it runs the route has already committed.
452
+ *
453
+ * @param hook Called with the new and previous routes.
454
+ * @returns An unregister function.
455
+ */
383
456
  declare function afterEach(hook: (to: RouteContext, from: RouteContext) => void): () => void;
457
+ /**
458
+ * The route outlet: renders whichever component matches the current route, and
459
+ * swaps it on every navigation.
460
+ *
461
+ * @returns A Comment anchor that manages the matched component. Like every
462
+ * factory here it hands back a live node the caller can insert directly.
463
+ *
464
+ * TRAP — a navigation REBUILDS the outlet's subtree, so focus and selection
465
+ * inside the outgoing route are discarded. The runtime restores focus when the
466
+ * incoming route contains an element with the same `id`, `name` or
467
+ * `data-focus-key`, and warns in dev when it cannot.
468
+ */
384
469
  declare function Route(): Node;
385
470
  /**
386
471
  * A route outlet that caches rendered components using KeepAlive.
@@ -497,6 +582,13 @@ declare function preloadRoute(to: NavigationTarget): Promise<void>;
497
582
  * must stay superseded.
498
583
  */
499
584
  declare function __getNavigationEpoch(): number;
585
+ /**
586
+ * Whether a named route is registered.
587
+ *
588
+ * @param name The route's `name`.
589
+ * @returns `true` when a route with that name exists; `false` when it does not,
590
+ * and also when no router has been created yet.
591
+ */
500
592
  declare function hasRoute(name: string): boolean;
501
593
  /**
502
594
  * Gets route information by name
package/dist/plugins.d.ts CHANGED
@@ -350,12 +350,34 @@ declare class SibuRouter {
350
350
  */
351
351
  get routeGetter(): () => RouteContext;
352
352
  }
353
+ /**
354
+ * Create the global router and make it the one `route()`, `navigate()` and
355
+ * `RouterLink` talk to. Any previously created router is destroyed first.
356
+ *
357
+ * @param routesOrOptions Either the route table, or the options object when
358
+ * routes are supplied later via {@link setRoutes}.
359
+ * @param options Router options when the first argument is the route table.
360
+ * @returns The created router instance.
361
+ */
353
362
  declare function createRouter(routesOrOptions: RouteDef[] | RouterOptions, options?: RouterOptions): SibuRouter;
354
363
  /**
355
364
  * Set routes on the global router (replaces existing routes).
356
365
  */
357
366
  declare function setRoutes(routes: RouteDef[]): void;
367
+ /**
368
+ * Read the current route as a plain snapshot.
369
+ *
370
+ * @returns The active {@link RouteContext} (path, params, query, hash).
371
+ * @throws If no router has been created yet.
372
+ */
358
373
  declare function route(): RouteContext;
374
+ /**
375
+ * Handle onto the global router's navigation surface.
376
+ *
377
+ * @returns An object exposing the current route plus `push`, `replace`, `go`,
378
+ * `back`, `forward` and the three guard registrars.
379
+ * @throws If no router has been created yet.
380
+ */
359
381
  declare function router(): {
360
382
  currentRoute: RouteContext;
361
383
  isReady: boolean;
@@ -369,18 +391,81 @@ declare function router(): {
369
391
  beforeResolve: (guard: NavigationGuard) => (() => void) | undefined;
370
392
  afterEach: (hook: (to: RouteContext, from: RouteContext) => void) => (() => void) | undefined;
371
393
  };
394
+ /**
395
+ * Navigate to a target, running every registered guard.
396
+ *
397
+ * @param to Path string or location descriptor.
398
+ * @param options `replace` swaps the current history entry instead of pushing;
399
+ * `state` is stored on the history entry.
400
+ * @returns A promise for the {@link NavigationResult} — resolved even when a
401
+ * guard cancels, so the outcome must be inspected rather than assumed.
402
+ * @throws If no router has been created yet.
403
+ */
372
404
  declare function navigate(to: NavigationTarget, options?: {
373
405
  replace?: boolean;
374
406
  state?: unknown;
375
407
  }): Promise<NavigationResult>;
408
+ /**
409
+ * Navigate by pushing a new history entry.
410
+ *
411
+ * @param to Path string or location descriptor.
412
+ * @returns A promise for the {@link NavigationResult}.
413
+ */
376
414
  declare function push(to: NavigationTarget): Promise<NavigationResult>;
415
+ /**
416
+ * Navigate by replacing the current history entry.
417
+ *
418
+ * @param to Path string or location descriptor.
419
+ * @returns A promise for the {@link NavigationResult}.
420
+ */
377
421
  declare function replace(to: NavigationTarget): Promise<NavigationResult>;
422
+ /**
423
+ * Move through history by a relative offset, as `history.go` does.
424
+ *
425
+ * @param delta Number of entries to move; negative goes back.
426
+ * @returns Nothing — history moves asynchronously, so nothing is awaited here.
427
+ */
378
428
  declare function go(delta: number): void;
429
+ /** Go back one history entry. Equivalent to `go(-1)`. */
379
430
  declare function back(): void;
431
+ /** Go forward one history entry. Equivalent to `go(1)`. */
380
432
  declare function forward(): void;
433
+ /**
434
+ * Register a guard that runs before every navigation is confirmed.
435
+ *
436
+ * @param guard Called with the target and current routes; return `false` to
437
+ * cancel, or a target to redirect.
438
+ * @returns An unregister function.
439
+ */
381
440
  declare function beforeEach(guard: NavigationGuard): () => void;
441
+ /**
442
+ * Register a guard that runs after `beforeEach` and after async components have
443
+ * resolved, but before the route commits.
444
+ *
445
+ * @param guard Called with the target and current routes.
446
+ * @returns An unregister function.
447
+ */
382
448
  declare function beforeResolve(guard: NavigationGuard): () => void;
449
+ /**
450
+ * Register a hook that runs after every confirmed navigation. It cannot cancel
451
+ * or redirect — by the time it runs the route has already committed.
452
+ *
453
+ * @param hook Called with the new and previous routes.
454
+ * @returns An unregister function.
455
+ */
383
456
  declare function afterEach(hook: (to: RouteContext, from: RouteContext) => void): () => void;
457
+ /**
458
+ * The route outlet: renders whichever component matches the current route, and
459
+ * swaps it on every navigation.
460
+ *
461
+ * @returns A Comment anchor that manages the matched component. Like every
462
+ * factory here it hands back a live node the caller can insert directly.
463
+ *
464
+ * TRAP — a navigation REBUILDS the outlet's subtree, so focus and selection
465
+ * inside the outgoing route are discarded. The runtime restores focus when the
466
+ * incoming route contains an element with the same `id`, `name` or
467
+ * `data-focus-key`, and warns in dev when it cannot.
468
+ */
384
469
  declare function Route(): Node;
385
470
  /**
386
471
  * A route outlet that caches rendered components using KeepAlive.
@@ -497,6 +582,13 @@ declare function preloadRoute(to: NavigationTarget): Promise<void>;
497
582
  * must stay superseded.
498
583
  */
499
584
  declare function __getNavigationEpoch(): number;
585
+ /**
586
+ * Whether a named route is registered.
587
+ *
588
+ * @param name The route's `name`.
589
+ * @returns `true` when a route with that name exists; `false` when it does not,
590
+ * and also when no router has been created yet.
591
+ */
500
592
  declare function hasRoute(name: string): boolean;
501
593
  /**
502
594
  * Gets route information by name
package/dist/plugins.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  preloadCritical,
19
19
  prerenderRoutes,
20
20
  satisfies
21
- } from "./chunk-AW6HPJ3L.js";
21
+ } from "./chunk-KKLW7YWL.js";
22
22
  import {
23
23
  isUnsafeKey
24
24
  } from "./chunk-H3SRKIYX.js";
@@ -35,43 +35,45 @@ import {
35
35
  } from "./chunk-WWV3SJ3L.js";
36
36
  import {
37
37
  span
38
- } from "./chunk-E72G5JSK.js";
38
+ } from "./chunk-P3DHXBR6.js";
39
39
  import {
40
40
  escapeScriptJson,
41
41
  renderToString,
42
42
  serializeHeadEntry
43
- } from "./chunk-HYCCIYNS.js";
44
- import "./chunk-QD4I7ZGZ.js";
45
- import "./chunk-PHRH66Y7.js";
43
+ } from "./chunk-NIOYEGBQ.js";
44
+ import {
45
+ resolveClassValue
46
+ } from "./chunk-6ZGI3RBE.js";
47
+ import "./chunk-HJEPKZ2O.js";
46
48
  import {
47
49
  isUrlAttribute,
48
50
  sanitizeStyleAttribute,
49
51
  sanitizeUrl,
50
52
  stripControlChars
51
- } from "./chunk-5INI7D2L.js";
53
+ } from "./chunk-IXKSNWV5.js";
52
54
  import {
53
55
  globalSingleton
54
56
  } from "./chunk-7ZHH77QA.js";
55
57
  import {
56
58
  effect
57
- } from "./chunk-XDOMTQHM.js";
59
+ } from "./chunk-7VEC3UD2.js";
58
60
  import {
59
61
  getRequestStore
60
- } from "./chunk-TIRZCERI.js";
62
+ } from "./chunk-5DXA2J44.js";
61
63
  import {
62
64
  dispose,
63
65
  registerDisposer
64
- } from "./chunk-DHDZ7IVN.js";
66
+ } from "./chunk-QKRPLZ2V.js";
65
67
  import {
66
68
  signal
67
- } from "./chunk-TVURNWDK.js";
69
+ } from "./chunk-HECVW343.js";
68
70
  import {
69
71
  track
70
- } from "./chunk-JYXQCELN.js";
72
+ } from "./chunk-7ALC7KGE.js";
71
73
  import {
72
74
  devWarn,
73
75
  isDev
74
- } from "./chunk-VPP2FONR.js";
76
+ } from "./chunk-2WLZ6757.js";
75
77
 
76
78
  // src/plugins/i18n.ts
77
79
  var _i18n = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.i18n.v1"), () => ({
@@ -1591,7 +1593,6 @@ function RouterLink(props, children) {
1591
1593
  if (!_routerRef.current) throw new Error("Router not initialized. Call createRouter() first.");
1592
1594
  const { to, replace: replace2 = false, activeClass, exactActiveClass, nodes, target, rel, class: classAttr, ...attrs } = props;
1593
1595
  const content = children !== void 0 ? children : nodes;
1594
- const baseClass = typeof classAttr === "string" ? classAttr : "";
1595
1596
  const routeGetter = _routerRef.current.routeGetter;
1596
1597
  const rawHref = _routerRef.current["resolvePath"](to);
1597
1598
  const kind = classifyNavigationTarget(rawHref);
@@ -1627,7 +1628,7 @@ function RouterLink(props, children) {
1627
1628
  if (exactActiveClass) classes.push(exactActiveClass);
1628
1629
  else if (options.linkExactActiveClass) classes.push(options.linkExactActiveClass);
1629
1630
  }
1630
- link.className = [baseClass, ...classes].filter(Boolean).join(" ");
1631
+ link.className = [resolveClassValue(classAttr), ...classes].filter(Boolean).join(" ");
1631
1632
  });
1632
1633
  registerDisposer(link, effectCleanup);
1633
1634
  Object.entries(attrs).forEach(([key, value]) => {
@@ -1639,7 +1640,7 @@ function RouterLink(props, children) {
1639
1640
  const safe = sanitizeUrl(str);
1640
1641
  if (safe) link.setAttribute(key, safe);
1641
1642
  } else if (lkey === "style") {
1642
- link.setAttribute(key, sanitizeStyleAttribute(str));
1643
+ link.setAttribute(key, sanitizeStyleAttribute(str, { element: link }));
1643
1644
  } else {
1644
1645
  link.setAttribute(key, str);
1645
1646
  }
@@ -2191,8 +2192,8 @@ function hydrateRouter(routes, options) {
2191
2192
  const liveUrl = `${window.location.pathname}${window.location.search}${window.location.hash}`;
2192
2193
  const resolved = resolveServerRoute(liveUrl, routes);
2193
2194
  const bootstrapEpoch = __getNavigationEpoch();
2194
- import("./ssr-JFP5535P.js").then(async ({ hydrate }) => {
2195
- const { replaceChildrenSafely } = await import("./dispose-4FZ6OFXR.js");
2195
+ import("./ssr-Y7XOEPEN.js").then(async ({ hydrate }) => {
2196
+ const { replaceChildrenSafely } = await import("./dispose-46BOMMQJ.js");
2196
2197
  if (__getNavigationEpoch() !== bootstrapEpoch) return;
2197
2198
  if (resolved.component) {
2198
2199
  hydrate(resolved.component, container);
@@ -17,11 +17,11 @@ import {
17
17
  ssrSuspense,
18
18
  suspenseSwapScript,
19
19
  trustHTML
20
- } from "./chunk-HYCCIYNS.js";
21
- import "./chunk-5INI7D2L.js";
22
- import "./chunk-TIRZCERI.js";
23
- import "./chunk-DHDZ7IVN.js";
24
- import "./chunk-VPP2FONR.js";
20
+ } from "./chunk-NIOYEGBQ.js";
21
+ import "./chunk-IXKSNWV5.js";
22
+ import "./chunk-5DXA2J44.js";
23
+ import "./chunk-QKRPLZ2V.js";
24
+ import "./chunk-2WLZ6757.js";
25
25
  export {
26
26
  collectStream,
27
27
  deserializeState,