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.cjs CHANGED
@@ -1425,6 +1425,7 @@ __export(plugins_exports, {
1425
1425
  setRouteTransition: () => setRouteTransition,
1426
1426
  setRoutes: () => setRoutes,
1427
1427
  t: () => t,
1428
+ translated: () => translated,
1428
1429
  triggerPluginError: () => triggerPluginError,
1429
1430
  triggerPluginMount: () => triggerPluginMount,
1430
1431
  triggerPluginUnmount: () => triggerPluginUnmount
@@ -2019,7 +2020,7 @@ function forEachSubscriber(signal2, visit) {
2019
2020
  }
2020
2021
 
2021
2022
  // src/reactivity/track.ts
2022
- var _runtimeVersion = true ? "4.6.0" : "dev";
2023
+ var _runtimeVersion = true ? "4.7.0" : "dev";
2023
2024
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
2024
2025
  function resolveReactiveApi() {
2025
2026
  const g2 = globalThis;
@@ -2303,8 +2304,34 @@ function toKebab(prop) {
2303
2304
  }
2304
2305
  function applyStyle(el, style2) {
2305
2306
  if (typeof style2 === "function") {
2307
+ const getter = style2;
2308
+ let written = [];
2309
+ let wroteString = false;
2306
2310
  const teardown = reactiveBinding2(() => {
2307
- el.setAttribute("style", sanitizeStyleAttribute(String(style2()), { element: el }));
2311
+ const value = getter();
2312
+ if (value === null || typeof value !== "object") {
2313
+ written = [];
2314
+ wroteString = true;
2315
+ el.setAttribute("style", sanitizeStyleAttribute(String(value), { element: el }));
2316
+ return;
2317
+ }
2318
+ const decl = el.style;
2319
+ if (wroteString) {
2320
+ el.removeAttribute("style");
2321
+ wroteString = false;
2322
+ }
2323
+ const next = [];
2324
+ for (const prop in value) {
2325
+ const val = value[prop];
2326
+ if (val == null) continue;
2327
+ const name = toKebab(prop);
2328
+ next.push(name);
2329
+ decl.setProperty(name, sanitizeCSSValue(String(val), { property: name, element: el }));
2330
+ }
2331
+ for (let i2 = 0; i2 < written.length; i2++) {
2332
+ if (next.indexOf(written[i2]) === -1) decl.removeProperty(written[i2]);
2333
+ }
2334
+ written = next;
2308
2335
  }, el);
2309
2336
  registerDisposer(el, teardown);
2310
2337
  return;
@@ -2330,7 +2357,7 @@ function applyStyle(el, style2) {
2330
2357
  }
2331
2358
  function resolveClassValue(cls) {
2332
2359
  if (typeof cls === "string") return cls;
2333
- if (typeof cls === "function") return cls();
2360
+ if (typeof cls === "function") return cls() || "";
2334
2361
  if (!cls) return "";
2335
2362
  let out = "";
2336
2363
  for (const name in cls) {
@@ -2347,7 +2374,9 @@ function applyClass(el, cls) {
2347
2374
  }
2348
2375
  if (typeof cls === "function") {
2349
2376
  const teardown = reactiveBinding2(() => {
2350
- el.setAttribute("class", cls());
2377
+ const value = cls();
2378
+ if (value == null || value === false) el.removeAttribute("class");
2379
+ else el.setAttribute("class", value);
2351
2380
  }, el);
2352
2381
  registerDisposer(el, teardown);
2353
2382
  return;
@@ -2429,7 +2458,7 @@ function appendChildren(el, nodes) {
2429
2458
  }
2430
2459
  }
2431
2460
  }
2432
- var tagFactory = (tag, ns) => {
2461
+ function tagFactory(tag, ns) {
2433
2462
  const blocked = isBlockedTag(tag);
2434
2463
  return (first, second) => {
2435
2464
  if (blocked) {
@@ -2478,7 +2507,9 @@ var tagFactory = (tag, ns) => {
2478
2507
  const pClass = props.class;
2479
2508
  if (pClass != null) applyClass(el, pClass);
2480
2509
  const pId = props.id;
2481
- if (pId != null) {
2510
+ if (typeof pId === "function") {
2511
+ registerDisposer(el, bindAttribute(el, "id", pId));
2512
+ } else if (pId != null) {
2482
2513
  if (DEV && typeof pId === "string" && CLOBBER_RISKY_IDS.has(pId.toLowerCase())) {
2483
2514
  devWarn(
2484
2515
  `tagFactory: element id="${pId}" matches a common global and may cause DOM clobbering. Avoid setting ids from untrusted input.`
@@ -2528,12 +2559,10 @@ var tagFactory = (tag, ns) => {
2528
2559
  }
2529
2560
  }
2530
2561
  }
2531
- if (props.onElement && typeof props.onElement === "function") {
2532
- props.onElement(el);
2533
- }
2562
+ if (typeof props.onElement === "function") props.onElement(el);
2534
2563
  return el;
2535
2564
  };
2536
- };
2565
+ }
2537
2566
 
2538
2567
  // src/core/rendering/html.ts
2539
2568
  var html = tagFactory("html");
@@ -2725,6 +2754,16 @@ var isBatching = API2.isBatching;
2725
2754
 
2726
2755
  // src/core/signals/signal.ts
2727
2756
  init_dev();
2757
+
2758
+ // src/core/devtoolsHook.ts
2759
+ function emitDevtools(hook, event, payload) {
2760
+ try {
2761
+ hook.emit(event, payload);
2762
+ } catch {
2763
+ }
2764
+ }
2765
+
2766
+ // src/core/signals/signal.ts
2728
2767
  var _g = globalThis;
2729
2768
  function signal(initial, options) {
2730
2769
  const state2 = {
@@ -2757,7 +2796,7 @@ function signal(initial, options) {
2757
2796
  state2.__v++;
2758
2797
  if (DEV) {
2759
2798
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
2760
- if (hook) hook.emit("signal:update", { signal: state2, name: debugName, oldValue: prev, newValue });
2799
+ if (hook) emitDevtools(hook, "signal:update", { signal: state2, name: debugName, oldValue: prev, newValue });
2761
2800
  }
2762
2801
  if (!enqueueBatchedSignal(state2)) {
2763
2802
  notifySubscribers2(state2);
@@ -2771,7 +2810,7 @@ function signal(initial, options) {
2771
2810
  state2.value = newValue;
2772
2811
  state2.__v++;
2773
2812
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
2774
- if (hook) hook.emit("signal:update", { signal: state2, name: debugName, oldValue: prev, newValue });
2813
+ if (hook) emitDevtools(hook, "signal:update", { signal: state2, name: debugName, oldValue: prev, newValue });
2775
2814
  if (!enqueueBatchedSignal(state2)) {
2776
2815
  notifySubscribers2(state2);
2777
2816
  }
@@ -2790,7 +2829,7 @@ function signal(initial, options) {
2790
2829
  }
2791
2830
  if (DEV) {
2792
2831
  const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
2793
- if (hook) hook.emit("signal:create", { signal: state2, name: debugName, getter: get, initial });
2832
+ if (hook) emitDevtools(hook, "signal:create", { signal: state2, name: debugName, getter: get, initial });
2794
2833
  }
2795
2834
  return [get, set];
2796
2835
  }
@@ -2807,14 +2846,20 @@ function globalSingleton(key, create) {
2807
2846
  // src/plugins/i18n.ts
2808
2847
  var _i18n = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.i18n.v1"), () => ({
2809
2848
  locale: signal("en"),
2810
- locales: /* @__PURE__ */ Object.create(null)
2849
+ locales: /* @__PURE__ */ Object.create(null),
2850
+ revision: signal(0)
2811
2851
  }));
2812
2852
  var [clientLocale, setClientLocale] = _i18n.locale;
2813
2853
  var locales = _i18n.locales;
2854
+ var [revision, setRevision] = _i18n.revision ?? (_i18n.revision = signal(0));
2814
2855
  function dictionaryFor(locale) {
2815
2856
  return Object.hasOwn(locales, locale) ? locales[locale] : void 0;
2816
2857
  }
2858
+ function trackDictionaries() {
2859
+ if (!getRequestStore()) revision();
2860
+ }
2817
2861
  function lookup(key) {
2862
+ trackDictionaries();
2818
2863
  const dictionary = dictionaryFor(getLocale());
2819
2864
  if (dictionary === void 0 || !Object.hasOwn(dictionary, key)) return void 0;
2820
2865
  const message = dictionary[key];
@@ -2844,18 +2889,29 @@ function registerTranslations(locale, messages) {
2844
2889
  enumerable: true,
2845
2890
  configurable: true
2846
2891
  });
2892
+ setRevision((n) => n + 1);
2893
+ }
2894
+ function resolveParam(params, name) {
2895
+ if (!Object.hasOwn(params, name)) return "";
2896
+ const raw = params[name];
2897
+ const value = typeof raw === "function" ? raw() : raw;
2898
+ return value == null ? "" : String(value);
2847
2899
  }
2848
2900
  function t(key, params) {
2849
2901
  const message = lookup(key) ?? key;
2850
- return params ? message.replace(/\{(\w+)\}/g, (_, p2) => String(params[p2] ?? "")) : message;
2902
+ return params ? message.replace(/\{(\w+)\}/g, (_, p2) => resolveParam(params, p2)) : message;
2903
+ }
2904
+ function translated(key, params) {
2905
+ return () => t(key, params);
2851
2906
  }
2852
2907
  function Trans(key, params) {
2853
- return span(() => t(key, params));
2908
+ return span(translated(key, params));
2854
2909
  }
2855
2910
  function hasTranslation(key) {
2856
2911
  return lookup(key) !== void 0;
2857
2912
  }
2858
2913
  function getAvailableLocales() {
2914
+ trackDictionaries();
2859
2915
  return Object.keys(locales);
2860
2916
  }
2861
2917
 
@@ -2981,12 +3037,17 @@ function effect(effectFn, options) {
2981
3037
  try {
2982
3038
  retrack2(ctx.bodyFn, ctx.subscriber);
2983
3039
  if (ctx.rerunPending) drainReruns(ctx);
3040
+ } catch (err) {
3041
+ ctx.disposed = true;
3042
+ if (ctx.userCleanups.length > 0) flushUserCleanups(ctx);
3043
+ cleanup2(ctx.subscriber);
3044
+ throw err;
2984
3045
  } finally {
2985
3046
  ctx.running = false;
2986
3047
  ctx.rerunPending = false;
2987
3048
  }
2988
3049
  const hook = _g2.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
2989
- if (hook) hook.emit("effect:create", { effectFn });
3050
+ if (hook) emitDevtools(hook, "effect:create", { effectFn });
2990
3051
  return () => disposeEffect(ctx);
2991
3052
  }
2992
3053
 
@@ -4161,6 +4222,30 @@ function afterEach(hook) {
4161
4222
  return _routerRef.current.afterEach(hook);
4162
4223
  }
4163
4224
  var routeCleanups = [];
4225
+ var ownParamNamesCache = /* @__PURE__ */ new WeakMap();
4226
+ function ownParamNames(record) {
4227
+ const cached = ownParamNamesCache.get(record);
4228
+ if (cached) return cached;
4229
+ const aliases = record.alias == null ? [] : Array.isArray(record.alias) ? record.alias : [record.alias];
4230
+ const names = /* @__PURE__ */ new Set();
4231
+ for (const pattern2 of [record.path, ...aliases]) {
4232
+ for (const m of pattern2.matchAll(/\/:([^/]+)/g)) {
4233
+ names.add(m[1].endsWith("?") ? m[1].slice(0, -1) : m[1]);
4234
+ }
4235
+ }
4236
+ const result = [...names];
4237
+ ownParamNamesCache.set(record, result);
4238
+ return result;
4239
+ }
4240
+ function instanceKey(owner, records, route2) {
4241
+ const custom = owner.key;
4242
+ if (custom) return untracked2(() => String(custom(route2)));
4243
+ const parts = [];
4244
+ for (const record of records) {
4245
+ for (const name of ownParamNames(record)) parts.push(name, route2.params[name] ?? null);
4246
+ }
4247
+ return JSON.stringify(parts);
4248
+ }
4164
4249
  function Route() {
4165
4250
  const anchor = document.createComment("route-outlet");
4166
4251
  let currentNode = null;
@@ -4168,6 +4253,7 @@ function Route() {
4168
4253
  let errorNode = null;
4169
4254
  let navSeq = 0;
4170
4255
  let currentTopRoute = null;
4256
+ let currentKey = null;
4171
4257
  let routeTorn = false;
4172
4258
  const commitTarget = (seq) => routeTorn || seq !== navSeq ? null : anchor.parentNode;
4173
4259
  const release = (node) => {
@@ -4259,11 +4345,13 @@ function Route() {
4259
4345
  const match = _routerRef.current["matcher"].match(route2.path);
4260
4346
  if (!match) {
4261
4347
  currentTopRoute = null;
4348
+ currentKey = null;
4262
4349
  cleanupNodes();
4263
4350
  return;
4264
4351
  }
4265
4352
  const routeDef = match.matched[0] || match.route;
4266
- if (routeDef === currentTopRoute && currentNode) {
4353
+ const key = instanceKey(routeDef, [routeDef], route2);
4354
+ if (routeDef === currentTopRoute && key === currentKey && currentNode) {
4267
4355
  return;
4268
4356
  }
4269
4357
  if ("redirect" in routeDef) {
@@ -4291,6 +4379,7 @@ function Route() {
4291
4379
  }
4292
4380
  if (node) {
4293
4381
  currentTopRoute = routeDef;
4382
+ currentKey = key;
4294
4383
  cleanupNodes();
4295
4384
  parent.insertBefore(node, anchor.nextSibling);
4296
4385
  currentNode = node;
@@ -4328,6 +4417,7 @@ function Route() {
4328
4417
  routeTeardown();
4329
4418
  cleanupNodes();
4330
4419
  currentTopRoute = null;
4420
+ currentKey = null;
4331
4421
  };
4332
4422
  registerDisposer(anchor, routeCleanup);
4333
4423
  routeCleanups.push(routeCleanup);
@@ -4514,19 +4604,7 @@ function RouterLink(props, children) {
4514
4604
  }
4515
4605
  }
4516
4606
  });
4517
- if (typeof content === "string") {
4518
- link2.textContent = content;
4519
- } else if (content instanceof Node) {
4520
- link2.appendChild(content);
4521
- } else if (Array.isArray(content)) {
4522
- content.forEach((child) => {
4523
- if (typeof child === "string") {
4524
- link2.appendChild(document.createTextNode(child));
4525
- } else if (child instanceof Node) {
4526
- link2.appendChild(child);
4527
- }
4528
- });
4529
- }
4607
+ if (content !== void 0) appendChildren(link2, content);
4530
4608
  const onLinkClick = (e) => {
4531
4609
  if (e.defaultPrevented || target || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) {
4532
4610
  return;
@@ -4688,6 +4766,7 @@ function Outlet() {
4688
4766
  const anchor = document.createComment("route-outlet-nested");
4689
4767
  let currentNode = null;
4690
4768
  let currentChild = null;
4769
+ let currentKey = null;
4691
4770
  let navSeq = 0;
4692
4771
  let outletTorn = false;
4693
4772
  const clearCurrent = () => {
@@ -4697,6 +4776,7 @@ function Outlet() {
4697
4776
  currentNode = null;
4698
4777
  }
4699
4778
  currentChild = null;
4779
+ currentKey = null;
4700
4780
  };
4701
4781
  const commitTarget = (seq) => outletTorn || seq !== navSeq ? null : anchor.parentNode;
4702
4782
  const release = (node) => {
@@ -4717,7 +4797,8 @@ function Outlet() {
4717
4797
  clearCurrent();
4718
4798
  return;
4719
4799
  }
4720
- if (childRoute === currentChild && currentNode) return;
4800
+ const key = instanceKey(childRoute, route2.matched.slice(1), route2);
4801
+ if (childRoute === currentChild && key === currentKey && currentNode) return;
4721
4802
  try {
4722
4803
  const cacheKey = `${route2.path}\0${childRoute.path}`;
4723
4804
  const plan = await _routerRef.current.loadPlan(childRoute, cacheKey);
@@ -4733,6 +4814,7 @@ function Outlet() {
4733
4814
  parent.insertBefore(node, anchor.nextSibling);
4734
4815
  currentNode = node;
4735
4816
  currentChild = childRoute;
4817
+ currentKey = key;
4736
4818
  } catch (error) {
4737
4819
  if (outletTorn || seq !== navSeq) return;
4738
4820
  console.error("[Outlet] Failed to render child route:", error);
@@ -4755,6 +4837,7 @@ function Outlet() {
4755
4837
  currentNode = null;
4756
4838
  }
4757
4839
  currentChild = null;
4840
+ currentKey = null;
4758
4841
  };
4759
4842
  registerDisposer(anchor, outletCleanup);
4760
4843
  routeCleanups.push(outletCleanup);
@@ -5498,7 +5581,7 @@ var CDN_ENTRY_POINTS = {
5498
5581
  };
5499
5582
  var packageInfo = {
5500
5583
  name: "sibujs",
5501
- version: true ? "4.6.0" : "dev",
5584
+ version: true ? "4.7.0" : "dev",
5502
5585
  entryPoints: MODULE_ENTRY_POINTS,
5503
5586
  /**
5504
5587
  * Generate the package.json `exports` map. Module entries resolve to the
@@ -5643,7 +5726,7 @@ var env = {
5643
5726
  };
5644
5727
 
5645
5728
  // src/plugins/versioning.ts
5646
- var VERSION = true ? "4.6.0" : "dev";
5729
+ var VERSION = true ? "4.7.0" : "dev";
5647
5730
  var NUM = "(?:0|[1-9]\\d*)";
5648
5731
  var PRE_ID = `(?:${NUM}|\\d*[a-zA-Z-][0-9a-zA-Z-]*)`;
5649
5732
  var BUILD_ID = "[0-9a-zA-Z-]+";
@@ -6241,6 +6324,7 @@ function createBootSequence() {
6241
6324
  setRouteTransition,
6242
6325
  setRoutes,
6243
6326
  t,
6327
+ translated,
6244
6328
  triggerPluginError,
6245
6329
  triggerPluginMount,
6246
6330
  triggerPluginUnmount
@@ -1,9 +1,20 @@
1
+ import { A as Accessor } from './signal-EotCj4hS.cjs';
2
+ import { N as NodeChildren } from './types-CJFViL6Q.cjs';
1
3
  import { T as TrustedHTML } from './ssr-Bli9XRW5.cjs';
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.cjs';
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.cjs';
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 };