sibujs 4.6.0 → 4.7.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 (79) hide show
  1. package/README.md +1 -1
  2. package/dist/browser.cjs +18 -5
  3. package/dist/browser.js +4 -4
  4. package/dist/build.cjs +1956 -1007
  5. package/dist/build.d.cts +133 -44
  6. package/dist/build.d.ts +133 -44
  7. package/dist/build.js +1368 -569
  8. package/dist/cdn.dev.global.js +12 -12
  9. package/dist/cdn.full.dev.global.js +11 -11
  10. package/dist/cdn.full.global.js +10 -10
  11. package/dist/cdn.global.js +12 -12
  12. package/dist/{chunk-SXXVZMKZ.js → chunk-2BPG2XDA.js} +5 -5
  13. package/dist/{chunk-BAAG6ZTI.js → chunk-3QWBSL5R.js} +4 -4
  14. package/dist/{chunk-5MT6SJ3P.js → chunk-4AWA2PVD.js} +2 -2
  15. package/dist/{chunk-JSXPZCET.js → chunk-7LUJQAOJ.js} +1 -1
  16. package/dist/{chunk-3ISI6ACU.js → chunk-BC2SECJD.js} +1 -1
  17. package/dist/{chunk-DKGBBKOF.js → chunk-BSY63EM6.js} +2 -2
  18. package/dist/{chunk-7NCARGJW.js → chunk-DKXRACVN.js} +3 -3
  19. package/dist/{chunk-47M47FOM.js → chunk-FNJXNGYZ.js} +1 -1
  20. package/dist/{chunk-D33YTSX5.js → chunk-FQRUXCEE.js} +5 -4
  21. package/dist/{chunk-5Q4R7HCL.js → chunk-JWKYU5GV.js} +11 -2
  22. package/dist/{chunk-QE4TTDU3.js → chunk-RUSSKG6G.js} +12 -11
  23. package/dist/{chunk-UZQ6ALFS.js → chunk-SLM3IA34.js} +1 -1
  24. package/dist/{chunk-XRRZKZYX.js → chunk-UNWRJRKC.js} +1 -1
  25. package/dist/{chunk-VVWPJ543.js → chunk-UOL2ECCS.js} +40 -11
  26. package/dist/{chunk-ORMZXBKQ.js → chunk-VZSG24LS.js} +3 -3
  27. package/dist/{chunk-XC4MEKGA.js → chunk-WEQ3DMVL.js} +8 -2
  28. package/dist/{chunk-PK6FK2G2.js → chunk-WOLJZUFQ.js} +176 -27
  29. package/dist/{chunk-7GQCWFOE.js → chunk-XYV3EDB7.js} +143 -74
  30. package/dist/{chunk-AIF3Z2T7.js → chunk-XZR4PXRE.js} +3 -3
  31. package/dist/{chunk-HYXDKS4N.js → chunk-Z3OHK6QT.js} +4 -4
  32. package/dist/{chunk-OXUY2A6L.js → chunk-ZVL7TY4K.js} +2 -2
  33. package/dist/{contracts-DRIuclVT.d.ts → contracts-CLqzJnOV.d.ts} +28 -17
  34. package/dist/{contracts-DRIuclVT.d.cts → contracts-CTOJXu-x.d.cts} +28 -17
  35. package/dist/data.cjs +198 -39
  36. package/dist/data.d.cts +119 -3
  37. package/dist/data.d.ts +119 -3
  38. package/dist/data.js +5 -5
  39. package/dist/devtools.cjs +18 -5
  40. package/dist/devtools.js +4 -4
  41. package/dist/ecosystem.cjs +64 -23
  42. package/dist/ecosystem.d.cts +2 -1
  43. package/dist/ecosystem.d.ts +2 -1
  44. package/dist/ecosystem.js +7 -7
  45. package/dist/extras.cjs +236 -49
  46. package/dist/extras.d.cts +3 -2
  47. package/dist/extras.d.ts +3 -2
  48. package/dist/extras.js +20 -20
  49. package/dist/index.cjs +259 -108
  50. package/dist/index.d.cts +193 -168
  51. package/dist/index.d.ts +193 -168
  52. package/dist/index.js +10 -10
  53. package/dist/motion.cjs +12 -4
  54. package/dist/motion.js +3 -3
  55. package/dist/patterns.cjs +28 -15
  56. package/dist/patterns.d.cts +2 -1
  57. package/dist/patterns.d.ts +2 -1
  58. package/dist/patterns.js +5 -5
  59. package/dist/performance.cjs +18 -5
  60. package/dist/performance.js +4 -4
  61. package/dist/plugins.cjs +118 -34
  62. package/dist/plugins.d.cts +124 -11
  63. package/dist/plugins.d.ts +124 -11
  64. package/dist/plugins.js +68 -26
  65. package/dist/ssr.cjs +54 -13
  66. package/dist/ssr.js +7 -7
  67. package/dist/{tagFactory-DFstCLQV.d.cts → tagFactory-8qL9LCIx.d.cts} +58 -19
  68. package/dist/{tagFactory-DkaNVUNV.d.ts → tagFactory-BL2fymez.d.ts} +58 -19
  69. package/dist/testing.cjs +15 -2
  70. package/dist/testing.js +2 -2
  71. package/dist/types-CJFViL6Q.d.cts +26 -0
  72. package/dist/types-CJFViL6Q.d.ts +26 -0
  73. package/dist/ui.cjs +28 -15
  74. package/dist/ui.d.cts +2 -1
  75. package/dist/ui.d.ts +2 -1
  76. package/dist/ui.js +7 -7
  77. package/dist/widgets.cjs +22 -14
  78. package/dist/widgets.js +6 -6
  79. package/package.json +4 -2
package/dist/plugins.d.ts CHANGED
@@ -1,9 +1,20 @@
1
+ import { A as Accessor } from './signal-EotCj4hS.js';
2
+ import { N as NodeChildren } from './types-CJFViL6Q.js';
1
3
  import { T as TrustedHTML } from './ssr-Bli9XRW5.js';
2
4
  export { P as PluginContext, a as PluginInstallCancelledError, b as PluginRegistry, S as SibuPlugin, c as createPlugin, d as createPluginRegistry, i as inject, e as isPluginInstallCancelledError, p as plugin, r as resetPlugins, s as setDefaultPluginRegistry, t as triggerPluginError, f as triggerPluginMount, g as triggerPluginUnmount } from './plugin-DVgSnTfK.js';
3
5
  export { L as LazyModule, M as Migration, a as MigrationStorageError, P as PackageExportTarget, S as SemVer, V as VERSION, b as bundlerMetadata, c as checkCompatibility, d as compareSemVer, e as createBootSequence, f as createBundle, g as createMigrationRunner, h as createModuleRegistry, i as createSSRCache, j as createTestHarness, k as deferNonCritical, l as env, m as healthCheck, n as lazyModule, p as packageInfo, o as parseSemVer, q as preloadCritical, r as prerenderRoutes, s as satisfies } from './startup-BLfSeL15.js';
4
6
 
5
7
  type Translations = Record<string, string>;
6
- type Params$1 = Record<string, string | number>;
8
+ /**
9
+ * Interpolation parameters for `t()`, `translated()` and `Trans()`.
10
+ *
11
+ * A value may be a GETTER (a signal accessor or any `() => value`). Getters are
12
+ * called at lookup time, so inside a binding the parameter is tracked exactly
13
+ * like the locale: `translated("hello", { name: userName })` re-renders when
14
+ * either `userName` or the locale changes.
15
+ */
16
+ type TranslationParams = Record<string, string | number | (() => string | number)>;
17
+ type Params$1 = TranslationParams;
7
18
  /**
8
19
  * Set the active locale.
9
20
  *
@@ -56,21 +67,72 @@ declare function getLocale(): string;
56
67
  * because the assignment form would invoke the inherited `__proto__` setter for
57
68
  * a locale of that name instead of registering it. Locale names and translation
58
69
  * keys are treated literally throughout — see PROTOTYPE SAFETY above.
70
+ *
71
+ * NOTIFY. Every registration bumps the dictionary revision, so bindings that
72
+ * already rendered a key re-run and pick the new message up — the order of
73
+ * `setLocale()` and `registerTranslations()` no longer matters. The bump comes
74
+ * after publication, so a re-running binding can only ever see the new
75
+ * dictionary.
59
76
  */
60
77
  declare function registerTranslations(locale: string, messages: Translations): void;
61
78
  /**
62
79
  * Translate `key` in the current locale, falling back to the key itself when it
63
80
  * is not registered. A registered empty string is a translation and is returned
64
81
  * unchanged; the previous `|| key` discarded it and returned the key.
82
+ *
83
+ * `t()` returns a STRING — a snapshot. It is live only when it is read inside a
84
+ * binding (`span(() => t("hello"))`), because that binding is what re-runs.
85
+ * Called directly in a component body, `span(t("hello"))` renders the message
86
+ * once and never updates. For anything on screen prefer {@link translated},
87
+ * which hands the binding a getter and works for text children and attributes
88
+ * alike. `t()` remains the right call for one-off strings: event handlers,
89
+ * `confirm()` prompts, log lines, server renders.
90
+ *
91
+ * Parameter getters are resolved on every call, so `t("hi", { name: userName })`
92
+ * inside a binding tracks `userName` too.
65
93
  */
66
94
  declare function t(key: string, params?: Params$1): string;
67
95
  /**
68
- * Trans component — renders a translated string reactively.
69
- * Automatically updates when the client locale changes. During SSR it renders
70
- * once, using the locale belonging to the current request.
96
+ * A LIVE translation: returns a getter that re-reads the message every time a
97
+ * binding calls it. Pass it anywhere the tag factories accept a reactive value
98
+ * — a text child or any attribute — and only that one text node or attribute
99
+ * updates when the locale changes, when messages for it are registered later,
100
+ * or when a getter parameter changes. The surrounding elements are never
101
+ * rebuilt, so focus, typed input values and element identity survive a language
102
+ * switch.
103
+ *
104
+ * During SSR the binding evaluates once, using the locale of the current
105
+ * request.
106
+ *
107
+ * @param key Translation key
108
+ * @param params Optional interpolation parameters; values may be getters
109
+ * @returns An accessor producing the translated string
110
+ *
111
+ * @example
112
+ * ```ts
113
+ * const [userName] = signal("Ada");
114
+ *
115
+ * header([
116
+ * h1(translated("app.title")),
117
+ * span(translated("greeting", { name: userName })),
118
+ * input({ placeholder: translated("search.placeholder"), "aria-label": translated("search.label") }),
119
+ * ]);
120
+ *
121
+ * setLocale("es"); // text and attributes update in place — no re-render
122
+ * ```
123
+ */
124
+ declare function translated(key: string, params?: Params$1): Accessor<string>;
125
+ /**
126
+ * Trans component — renders a translated string reactively inside a `<span>`.
127
+ * Automatically updates when the client locale changes, when messages for the
128
+ * active locale are registered, and when a getter parameter changes. During SSR
129
+ * it renders once, using the locale belonging to the current request.
130
+ *
131
+ * When no wrapper element is wanted, pass {@link translated} straight to the
132
+ * parent instead: `p(translated("greeting"))`.
71
133
  *
72
134
  * @param key Translation key
73
- * @param params Optional interpolation parameters
135
+ * @param params Optional interpolation parameters; values may be getters
74
136
  * @returns An HTMLElement (span) that reactively shows the translated text
75
137
  *
76
138
  * @example
@@ -78,8 +140,8 @@ declare function t(key: string, params?: Params$1): string;
78
140
  * registerTranslations("en", { greeting: "Hello, {name}!" });
79
141
  * registerTranslations("es", { greeting: "Hola, {name}!" });
80
142
  *
81
- * div([Trans("greeting", { name: "World" })]);
82
- * // When locale changes, the text updates automatically
143
+ * div([Trans("greeting", { name: userName })]);
144
+ * // When the locale or userName changes, the text updates automatically
83
145
  * ```
84
146
  */
85
147
  declare function Trans(key: string, params?: Params$1): HTMLElement;
@@ -98,6 +160,9 @@ declare function hasTranslation(key: string): boolean;
98
160
  *
99
161
  * Own enumerable keys, so a locale is listed exactly when it was registered -
100
162
  * including one named `"__proto__"`, which publication now stores literally.
163
+ *
164
+ * Read inside a binding the list is live: registering a new locale re-runs it,
165
+ * so a language picker built from it picks up lazily loaded locales.
101
166
  */
102
167
  declare function getAvailableLocales(): string[];
103
168
 
@@ -127,6 +192,41 @@ interface RouteBase {
127
192
  readonly children?: RouteDef[];
128
193
  readonly beforeEnter?: Guard | Guard[];
129
194
  readonly alias?: string | string[];
195
+ /**
196
+ * Identity of the mounted instance of this route's component.
197
+ *
198
+ * When a navigation stays on this route but the key changes, the outlet
199
+ * disposes the old instance (running its `onUnmount` / `onCleanup`
200
+ * callbacks and releasing its bindings) and mounts a fresh one — so a page
201
+ * that reads `route().params.id` once at setup always sees the right id.
202
+ *
203
+ * **Default:** the path params this record declares in its *own* path (and
204
+ * aliases). `/records/1` → `/records/2` remounts; `?tab=a` → `?tab=b` or a
205
+ * hash change does not. A parent layout is not remounted when only a child's
206
+ * param changes — the child's `Outlet()` remounts the child instead. A
207
+ * record with no params of its own is never remounted by a param change, and
208
+ * a `*` tail (`pathMatch`) is not part of the default: a catch-all keeps its
209
+ * instance and reads `pathMatch` reactively (`key: (r) => r.params.pathMatch`
210
+ * remounts per path).
211
+ *
212
+ * **Override:** return any string derived from the route. Return a constant
213
+ * to keep one long-lived instance across param changes (the instance must
214
+ * then read params reactively, e.g. `routerState().params()` or
215
+ * `() => route().params.id`). Include query values to also remount on a
216
+ * query change.
217
+ *
218
+ * Called untracked with the committed route. Ignored by `KeepAliveRoute()`,
219
+ * which already keeps one instance per full location.
220
+ *
221
+ * @example
222
+ * ```ts
223
+ * // Keep one instance for every record; the page reads params reactively.
224
+ * { path: "/records/:id", component: RecordPage, key: () => "record" }
225
+ * // Also remount when ?tab changes.
226
+ * { path: "/records/:id", component: RecordPage, key: (r) => `${r.params.id}|${r.query.tab ?? ""}` }
227
+ * ```
228
+ */
229
+ readonly key?: (route: RouteContext) => string;
130
230
  }
131
231
  interface ComponentRoute extends RouteBase {
132
232
  readonly component: Component;
@@ -367,6 +467,11 @@ declare function setRoutes(routes: RouteDef[]): void;
367
467
  /**
368
468
  * Read the current route as a plain snapshot.
369
469
  *
470
+ * Reading it once in a route component's setup is safe: when a navigation
471
+ * changes that route's own params, the outlet mounts a fresh instance (see
472
+ * `RouteBase.key`). Inside a getter — `() => route().params.id` — the read is
473
+ * reactive, which is what a long-lived layout or a constant-`key` route needs.
474
+ *
370
475
  * @returns The active {@link RouteContext} (path, params, query, hash).
371
476
  * @throws If no router has been created yet.
372
477
  */
@@ -456,7 +561,10 @@ declare function beforeResolve(guard: NavigationGuard): () => void;
456
561
  declare function afterEach(hook: (to: RouteContext, from: RouteContext) => void): () => void;
457
562
  /**
458
563
  * The route outlet: renders whichever component matches the current route, and
459
- * swaps it on every navigation.
564
+ * swaps it when the top-level matched record or its instance key changes. By
565
+ * default the key is that record's own path params, so `/records/1` →
566
+ * `/records/2` mounts a fresh instance while a query- or hash-only change keeps
567
+ * the current one (see `RouteBase.key`).
460
568
  *
461
569
  * @returns A Comment anchor that manages the matched component. Like every
462
570
  * factory here it hands back a live node the caller can insert directly.
@@ -525,11 +633,11 @@ declare function RouterLink(props: {
525
633
  activeClass?: string;
526
634
  exactActiveClass?: string;
527
635
  /** @deprecated Pass children positionally: `RouterLink(props, children)`. */
528
- nodes?: string | Node | (string | Node)[];
636
+ nodes?: NodeChildren;
529
637
  target?: string;
530
638
  rel?: string;
531
639
  [key: string]: unknown;
532
- }, children?: string | Node | (string | Node)[]): HTMLAnchorElement;
640
+ }, children?: NodeChildren): HTMLAnchorElement;
533
641
  /**
534
642
  * Async boundary for code-split / deferred content.
535
643
  *
@@ -617,6 +725,11 @@ declare function __removeRouterPagehideHandler(): void;
617
725
  /**
618
726
  * Outlet renders the child route component within a layout.
619
727
  * Use inside a parent route's component to render matched children.
728
+ *
729
+ * The child is remounted when the matched child record changes or when its
730
+ * instance key does — by default the params declared below the top-level
731
+ * record, so a child-only param change remounts the child and leaves the
732
+ * layout in place (see `RouteBase.key`).
620
733
  */
621
734
  declare function Outlet(): Node;
622
735
  /**
@@ -782,4 +895,4 @@ declare function createSSRRouter(routes: SSRRouteDef[]): {
782
895
  }) => string;
783
896
  };
784
897
 
785
- export { type AsyncComponent, type AsyncRoute, type Component, type ComponentRoute, type Guard, type GuardResult, KeepAliveRoute, type LazyComponent, type LazyRoute, type NavigationFailure, type NavigationFailureReason, type NavigationGuard, type NavigationNext, type NavigationResult, type NavigationTarget, Outlet, type Params, type RedirectRoute, Route, type RouteBase, type RouteContext, type RouteDef, type RouteMeta, type RouteTransitionOptions, RouterLink, type RouterOptions, type RouterPlugin, type SSRRouteDef, type SSRRouteState, type ScrollBehavior, type ScrollPosition, SibuRouter, Suspense, Trans, __getNavigationEpoch, __removeRouterPagehideHandler, addRoute, afterEach, back, beforeEach, beforeResolve, buildURL, createMemoryRouter, createRouter, createSSRRouter, deserializeRouteState, destroyRouter, forward, getAvailableLocales, getLocale, getRouteInfo, getRouteTransition, go, hasRoute, hasTranslation, hydrateRouter, lazy, navigate, preloadRoute, push, registerTranslations, removeRoute, renderRouteToDocument, renderRouteToString, replace, resolveServerRoute, route, router, routerPlugin, routerState, serializeRouteState, setLocale, setRouteTransition, setRoutes, t };
898
+ export { type AsyncComponent, type AsyncRoute, type Component, type ComponentRoute, type Guard, type GuardResult, KeepAliveRoute, type LazyComponent, type LazyRoute, type NavigationFailure, type NavigationFailureReason, type NavigationGuard, type NavigationNext, type NavigationResult, type NavigationTarget, Outlet, type Params, type RedirectRoute, Route, type RouteBase, type RouteContext, type RouteDef, type RouteMeta, type RouteTransitionOptions, RouterLink, type RouterOptions, type RouterPlugin, type SSRRouteDef, type SSRRouteState, type ScrollBehavior, type ScrollPosition, SibuRouter, Suspense, Trans, type TranslationParams, __getNavigationEpoch, __removeRouterPagehideHandler, addRoute, afterEach, back, beforeEach, beforeResolve, buildURL, createMemoryRouter, createRouter, createSSRRouter, deserializeRouteState, destroyRouter, forward, getAvailableLocales, getLocale, getRouteInfo, getRouteTransition, go, hasRoute, hasTranslation, hydrateRouter, lazy, navigate, preloadRoute, push, registerTranslations, removeRoute, renderRouteToDocument, renderRouteToString, replace, resolveServerRoute, route, router, routerPlugin, routerState, serializeRouteState, setLocale, setRouteTransition, setRoutes, t, translated };
package/dist/plugins.js CHANGED
@@ -19,7 +19,7 @@ import {
19
19
  preloadCritical,
20
20
  prerenderRoutes,
21
21
  satisfies
22
- } from "./chunk-5MT6SJ3P.js";
22
+ } from "./chunk-4AWA2PVD.js";
23
23
  import {
24
24
  isUnsafeKey
25
25
  } from "./chunk-H3SRKIYX.js";
@@ -38,16 +38,17 @@ import {
38
38
  } from "./chunk-J6FW5TV6.js";
39
39
  import {
40
40
  span
41
- } from "./chunk-JSXPZCET.js";
41
+ } from "./chunk-7LUJQAOJ.js";
42
42
  import {
43
43
  escapeScriptJson,
44
44
  renderToString,
45
45
  serializeHeadEntry
46
46
  } from "./chunk-HURREPU2.js";
47
47
  import {
48
+ appendChildren,
48
49
  resolveClassValue
49
- } from "./chunk-VVWPJ543.js";
50
- import "./chunk-47M47FOM.js";
50
+ } from "./chunk-UOL2ECCS.js";
51
+ import "./chunk-FNJXNGYZ.js";
51
52
  import {
52
53
  isUrlAttribute,
53
54
  sanitizeStyleAttribute,
@@ -59,17 +60,18 @@ import {
59
60
  } from "./chunk-7ZHH77QA.js";
60
61
  import {
61
62
  effect
62
- } from "./chunk-XC4MEKGA.js";
63
+ } from "./chunk-WEQ3DMVL.js";
63
64
  import {
64
65
  getRequestStore
65
66
  } from "./chunk-7XHATCIH.js";
66
67
  import "./chunk-5HZXGZ6T.js";
67
68
  import {
68
69
  signal
69
- } from "./chunk-D33YTSX5.js";
70
+ } from "./chunk-FQRUXCEE.js";
70
71
  import {
71
- track
72
- } from "./chunk-5Q4R7HCL.js";
72
+ track,
73
+ untracked
74
+ } from "./chunk-JWKYU5GV.js";
73
75
  import {
74
76
  devWarn,
75
77
  dispose,
@@ -80,14 +82,20 @@ import {
80
82
  // src/plugins/i18n.ts
81
83
  var _i18n = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.i18n.v1"), () => ({
82
84
  locale: signal("en"),
83
- locales: /* @__PURE__ */ Object.create(null)
85
+ locales: /* @__PURE__ */ Object.create(null),
86
+ revision: signal(0)
84
87
  }));
85
88
  var [clientLocale, setClientLocale] = _i18n.locale;
86
89
  var locales = _i18n.locales;
90
+ var [revision, setRevision] = _i18n.revision ?? (_i18n.revision = signal(0));
87
91
  function dictionaryFor(locale) {
88
92
  return Object.hasOwn(locales, locale) ? locales[locale] : void 0;
89
93
  }
94
+ function trackDictionaries() {
95
+ if (!getRequestStore()) revision();
96
+ }
90
97
  function lookup(key) {
98
+ trackDictionaries();
91
99
  const dictionary = dictionaryFor(getLocale());
92
100
  if (dictionary === void 0 || !Object.hasOwn(dictionary, key)) return void 0;
93
101
  const message = dictionary[key];
@@ -117,18 +125,29 @@ function registerTranslations(locale, messages) {
117
125
  enumerable: true,
118
126
  configurable: true
119
127
  });
128
+ setRevision((n) => n + 1);
129
+ }
130
+ function resolveParam(params, name) {
131
+ if (!Object.hasOwn(params, name)) return "";
132
+ const raw = params[name];
133
+ const value = typeof raw === "function" ? raw() : raw;
134
+ return value == null ? "" : String(value);
120
135
  }
121
136
  function t(key, params) {
122
137
  const message = lookup(key) ?? key;
123
- return params ? message.replace(/\{(\w+)\}/g, (_, p) => String(params[p] ?? "")) : message;
138
+ return params ? message.replace(/\{(\w+)\}/g, (_, p) => resolveParam(params, p)) : message;
139
+ }
140
+ function translated(key, params) {
141
+ return () => t(key, params);
124
142
  }
125
143
  function Trans(key, params) {
126
- return span(() => t(key, params));
144
+ return span(translated(key, params));
127
145
  }
128
146
  function hasTranslation(key) {
129
147
  return lookup(key) !== void 0;
130
148
  }
131
149
  function getAvailableLocales() {
150
+ trackDictionaries();
132
151
  return Object.keys(locales);
133
152
  }
134
153
 
@@ -1302,6 +1321,30 @@ function afterEach(hook) {
1302
1321
  return _routerRef.current.afterEach(hook);
1303
1322
  }
1304
1323
  var routeCleanups = [];
1324
+ var ownParamNamesCache = /* @__PURE__ */ new WeakMap();
1325
+ function ownParamNames(record) {
1326
+ const cached = ownParamNamesCache.get(record);
1327
+ if (cached) return cached;
1328
+ const aliases = record.alias == null ? [] : Array.isArray(record.alias) ? record.alias : [record.alias];
1329
+ const names = /* @__PURE__ */ new Set();
1330
+ for (const pattern of [record.path, ...aliases]) {
1331
+ for (const m of pattern.matchAll(/\/:([^/]+)/g)) {
1332
+ names.add(m[1].endsWith("?") ? m[1].slice(0, -1) : m[1]);
1333
+ }
1334
+ }
1335
+ const result = [...names];
1336
+ ownParamNamesCache.set(record, result);
1337
+ return result;
1338
+ }
1339
+ function instanceKey(owner, records, route2) {
1340
+ const custom = owner.key;
1341
+ if (custom) return untracked(() => String(custom(route2)));
1342
+ const parts = [];
1343
+ for (const record of records) {
1344
+ for (const name of ownParamNames(record)) parts.push(name, route2.params[name] ?? null);
1345
+ }
1346
+ return JSON.stringify(parts);
1347
+ }
1305
1348
  function Route() {
1306
1349
  const anchor = document.createComment("route-outlet");
1307
1350
  let currentNode = null;
@@ -1309,6 +1352,7 @@ function Route() {
1309
1352
  let errorNode = null;
1310
1353
  let navSeq = 0;
1311
1354
  let currentTopRoute = null;
1355
+ let currentKey = null;
1312
1356
  let routeTorn = false;
1313
1357
  const commitTarget = (seq) => routeTorn || seq !== navSeq ? null : anchor.parentNode;
1314
1358
  const release = (node) => {
@@ -1400,11 +1444,13 @@ function Route() {
1400
1444
  const match = _routerRef.current["matcher"].match(route2.path);
1401
1445
  if (!match) {
1402
1446
  currentTopRoute = null;
1447
+ currentKey = null;
1403
1448
  cleanupNodes();
1404
1449
  return;
1405
1450
  }
1406
1451
  const routeDef = match.matched[0] || match.route;
1407
- if (routeDef === currentTopRoute && currentNode) {
1452
+ const key = instanceKey(routeDef, [routeDef], route2);
1453
+ if (routeDef === currentTopRoute && key === currentKey && currentNode) {
1408
1454
  return;
1409
1455
  }
1410
1456
  if ("redirect" in routeDef) {
@@ -1432,6 +1478,7 @@ function Route() {
1432
1478
  }
1433
1479
  if (node) {
1434
1480
  currentTopRoute = routeDef;
1481
+ currentKey = key;
1435
1482
  cleanupNodes();
1436
1483
  parent.insertBefore(node, anchor.nextSibling);
1437
1484
  currentNode = node;
@@ -1469,6 +1516,7 @@ function Route() {
1469
1516
  routeTeardown();
1470
1517
  cleanupNodes();
1471
1518
  currentTopRoute = null;
1519
+ currentKey = null;
1472
1520
  };
1473
1521
  registerDisposer(anchor, routeCleanup);
1474
1522
  routeCleanups.push(routeCleanup);
@@ -1655,19 +1703,7 @@ function RouterLink(props, children) {
1655
1703
  }
1656
1704
  }
1657
1705
  });
1658
- if (typeof content === "string") {
1659
- link.textContent = content;
1660
- } else if (content instanceof Node) {
1661
- link.appendChild(content);
1662
- } else if (Array.isArray(content)) {
1663
- content.forEach((child) => {
1664
- if (typeof child === "string") {
1665
- link.appendChild(document.createTextNode(child));
1666
- } else if (child instanceof Node) {
1667
- link.appendChild(child);
1668
- }
1669
- });
1670
- }
1706
+ if (content !== void 0) appendChildren(link, content);
1671
1707
  const onLinkClick = (e) => {
1672
1708
  if (e.defaultPrevented || target || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) {
1673
1709
  return;
@@ -1829,6 +1865,7 @@ function Outlet() {
1829
1865
  const anchor = document.createComment("route-outlet-nested");
1830
1866
  let currentNode = null;
1831
1867
  let currentChild = null;
1868
+ let currentKey = null;
1832
1869
  let navSeq = 0;
1833
1870
  let outletTorn = false;
1834
1871
  const clearCurrent = () => {
@@ -1838,6 +1875,7 @@ function Outlet() {
1838
1875
  currentNode = null;
1839
1876
  }
1840
1877
  currentChild = null;
1878
+ currentKey = null;
1841
1879
  };
1842
1880
  const commitTarget = (seq) => outletTorn || seq !== navSeq ? null : anchor.parentNode;
1843
1881
  const release = (node) => {
@@ -1858,7 +1896,8 @@ function Outlet() {
1858
1896
  clearCurrent();
1859
1897
  return;
1860
1898
  }
1861
- if (childRoute === currentChild && currentNode) return;
1899
+ const key = instanceKey(childRoute, route2.matched.slice(1), route2);
1900
+ if (childRoute === currentChild && key === currentKey && currentNode) return;
1862
1901
  try {
1863
1902
  const cacheKey = `${route2.path}\0${childRoute.path}`;
1864
1903
  const plan = await _routerRef.current.loadPlan(childRoute, cacheKey);
@@ -1874,6 +1913,7 @@ function Outlet() {
1874
1913
  parent.insertBefore(node, anchor.nextSibling);
1875
1914
  currentNode = node;
1876
1915
  currentChild = childRoute;
1916
+ currentKey = key;
1877
1917
  } catch (error) {
1878
1918
  if (outletTorn || seq !== navSeq) return;
1879
1919
  console.error("[Outlet] Failed to render child route:", error);
@@ -1896,6 +1936,7 @@ function Outlet() {
1896
1936
  currentNode = null;
1897
1937
  }
1898
1938
  currentChild = null;
1939
+ currentKey = null;
1899
1940
  };
1900
1941
  registerDisposer(anchor, outletCleanup);
1901
1942
  routeCleanups.push(outletCleanup);
@@ -2312,6 +2353,7 @@ export {
2312
2353
  setRouteTransition,
2313
2354
  setRoutes,
2314
2355
  t,
2356
+ translated,
2315
2357
  triggerPluginError,
2316
2358
  triggerPluginMount,
2317
2359
  triggerPluginUnmount
package/dist/ssr.cjs CHANGED
@@ -1712,7 +1712,7 @@ function forEachSubscriber(signal2, visit) {
1712
1712
  }
1713
1713
 
1714
1714
  // src/reactivity/track.ts
1715
- var _runtimeVersion = true ? "4.6.0" : "dev";
1715
+ var _runtimeVersion = true ? "4.7.0" : "dev";
1716
1716
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
1717
1717
  function resolveReactiveApi() {
1718
1718
  const g2 = globalThis;
@@ -1768,6 +1768,14 @@ var getSubscriberCount2 = API.getSubscriberCount;
1768
1768
  var getSubscriberDeps2 = API.getSubscriberDeps;
1769
1769
  var forEachSubscriber2 = API.forEachSubscriber;
1770
1770
 
1771
+ // src/core/devtoolsHook.ts
1772
+ function emitDevtools(hook, event, payload) {
1773
+ try {
1774
+ hook.emit(event, payload);
1775
+ } catch {
1776
+ }
1777
+ }
1778
+
1771
1779
  // src/core/signals/effect.ts
1772
1780
  var _g = globalThis;
1773
1781
  var MAX_RERUNS = 100;
@@ -1883,12 +1891,17 @@ function effect(effectFn, options) {
1883
1891
  try {
1884
1892
  retrack2(ctx.bodyFn, ctx.subscriber);
1885
1893
  if (ctx.rerunPending) drainReruns(ctx);
1894
+ } catch (err) {
1895
+ ctx.disposed = true;
1896
+ if (ctx.userCleanups.length > 0) flushUserCleanups(ctx);
1897
+ cleanup2(ctx.subscriber);
1898
+ throw err;
1886
1899
  } finally {
1887
1900
  ctx.running = false;
1888
1901
  ctx.rerunPending = false;
1889
1902
  }
1890
1903
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
1891
- if (hook) hook.emit("effect:create", { effectFn });
1904
+ if (hook) emitDevtools(hook, "effect:create", { effectFn });
1892
1905
  return () => disposeEffect(ctx);
1893
1906
  }
1894
1907
 
@@ -2256,7 +2269,7 @@ function signal(initial, options) {
2256
2269
  state2.__v++;
2257
2270
  if (DEV) {
2258
2271
  const hook = _g2.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
2259
- if (hook) hook.emit("signal:update", { signal: state2, name: debugName, oldValue: prev, newValue });
2272
+ if (hook) emitDevtools(hook, "signal:update", { signal: state2, name: debugName, oldValue: prev, newValue });
2260
2273
  }
2261
2274
  if (!enqueueBatchedSignal(state2)) {
2262
2275
  notifySubscribers2(state2);
@@ -2270,7 +2283,7 @@ function signal(initial, options) {
2270
2283
  state2.value = newValue;
2271
2284
  state2.__v++;
2272
2285
  const hook = _g2.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
2273
- if (hook) hook.emit("signal:update", { signal: state2, name: debugName, oldValue: prev, newValue });
2286
+ if (hook) emitDevtools(hook, "signal:update", { signal: state2, name: debugName, oldValue: prev, newValue });
2274
2287
  if (!enqueueBatchedSignal(state2)) {
2275
2288
  notifySubscribers2(state2);
2276
2289
  }
@@ -2289,7 +2302,7 @@ function signal(initial, options) {
2289
2302
  }
2290
2303
  if (DEV) {
2291
2304
  const hook = _g2.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
2292
- if (hook) hook.emit("signal:create", { signal: state2, name: debugName, getter: get, initial });
2305
+ if (hook) emitDevtools(hook, "signal:create", { signal: state2, name: debugName, getter: get, initial });
2293
2306
  }
2294
2307
  return [get, set];
2295
2308
  }
@@ -2812,8 +2825,34 @@ function toKebab(prop) {
2812
2825
  }
2813
2826
  function applyStyle(el, style2) {
2814
2827
  if (typeof style2 === "function") {
2828
+ const getter = style2;
2829
+ let written = [];
2830
+ let wroteString = false;
2815
2831
  const teardown = reactiveBinding2(() => {
2816
- el.setAttribute("style", sanitizeStyleAttribute(String(style2()), { element: el }));
2832
+ const value = getter();
2833
+ if (value === null || typeof value !== "object") {
2834
+ written = [];
2835
+ wroteString = true;
2836
+ el.setAttribute("style", sanitizeStyleAttribute(String(value), { element: el }));
2837
+ return;
2838
+ }
2839
+ const decl = el.style;
2840
+ if (wroteString) {
2841
+ el.removeAttribute("style");
2842
+ wroteString = false;
2843
+ }
2844
+ const next = [];
2845
+ for (const prop in value) {
2846
+ const val = value[prop];
2847
+ if (val == null) continue;
2848
+ const name = toKebab(prop);
2849
+ next.push(name);
2850
+ decl.setProperty(name, sanitizeCSSValue(String(val), { property: name, element: el }));
2851
+ }
2852
+ for (let i2 = 0; i2 < written.length; i2++) {
2853
+ if (next.indexOf(written[i2]) === -1) decl.removeProperty(written[i2]);
2854
+ }
2855
+ written = next;
2817
2856
  }, el);
2818
2857
  registerDisposer(el, teardown);
2819
2858
  return;
@@ -2844,7 +2883,9 @@ function applyClass(el, cls) {
2844
2883
  }
2845
2884
  if (typeof cls === "function") {
2846
2885
  const teardown = reactiveBinding2(() => {
2847
- el.setAttribute("class", cls());
2886
+ const value = cls();
2887
+ if (value == null || value === false) el.removeAttribute("class");
2888
+ else el.setAttribute("class", value);
2848
2889
  }, el);
2849
2890
  registerDisposer(el, teardown);
2850
2891
  return;
@@ -2926,7 +2967,7 @@ function appendChildren(el, nodes) {
2926
2967
  }
2927
2968
  }
2928
2969
  }
2929
- var tagFactory = (tag, ns) => {
2970
+ function tagFactory(tag, ns) {
2930
2971
  const blocked = isBlockedTag(tag);
2931
2972
  return (first, second) => {
2932
2973
  if (blocked) {
@@ -2975,7 +3016,9 @@ var tagFactory = (tag, ns) => {
2975
3016
  const pClass = props.class;
2976
3017
  if (pClass != null) applyClass(el, pClass);
2977
3018
  const pId = props.id;
2978
- if (pId != null) {
3019
+ if (typeof pId === "function") {
3020
+ registerDisposer(el, bindAttribute(el, "id", pId));
3021
+ } else if (pId != null) {
2979
3022
  if (DEV && typeof pId === "string" && CLOBBER_RISKY_IDS.has(pId.toLowerCase())) {
2980
3023
  devWarn(
2981
3024
  `tagFactory: element id="${pId}" matches a common global and may cause DOM clobbering. Avoid setting ids from untrusted input.`
@@ -3025,12 +3068,10 @@ var tagFactory = (tag, ns) => {
3025
3068
  }
3026
3069
  }
3027
3070
  }
3028
- if (props.onElement && typeof props.onElement === "function") {
3029
- props.onElement(el);
3030
- }
3071
+ if (typeof props.onElement === "function") props.onElement(el);
3031
3072
  return el;
3032
3073
  };
3033
- };
3074
+ }
3034
3075
 
3035
3076
  // src/core/rendering/html.ts
3036
3077
  var html = tagFactory("html");
package/dist/ssr.js CHANGED
@@ -23,9 +23,9 @@ import {
23
23
  wasm,
24
24
  worker,
25
25
  workerFn
26
- } from "./chunk-ORMZXBKQ.js";
26
+ } from "./chunk-VZSG24LS.js";
27
27
  import "./chunk-52XFPGSN.js";
28
- import "./chunk-JSXPZCET.js";
28
+ import "./chunk-7LUJQAOJ.js";
29
29
  import {
30
30
  collectStream,
31
31
  deserializeState,
@@ -46,14 +46,14 @@ import {
46
46
  suspenseSwapScript,
47
47
  trustHTML
48
48
  } from "./chunk-HURREPU2.js";
49
- import "./chunk-VVWPJ543.js";
50
- import "./chunk-47M47FOM.js";
49
+ import "./chunk-UOL2ECCS.js";
50
+ import "./chunk-FNJXNGYZ.js";
51
51
  import "./chunk-2INLLLMZ.js";
52
52
  import "./chunk-7ZHH77QA.js";
53
- import "./chunk-XC4MEKGA.js";
53
+ import "./chunk-WEQ3DMVL.js";
54
54
  import "./chunk-7XHATCIH.js";
55
- import "./chunk-D33YTSX5.js";
56
- import "./chunk-5Q4R7HCL.js";
55
+ import "./chunk-FQRUXCEE.js";
56
+ import "./chunk-JWKYU5GV.js";
57
57
  import "./chunk-NYNYSPK7.js";
58
58
  export {
59
59
  Head,