sibujs 4.6.0 → 4.8.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 (94) hide show
  1. package/README.md +1 -1
  2. package/dist/browser.cjs +62 -8
  3. package/dist/browser.d.cts +23 -0
  4. package/dist/browser.d.ts +23 -0
  5. package/dist/browser.js +6 -5
  6. package/dist/build.cjs +2388 -1004
  7. package/dist/build.d.cts +147 -44
  8. package/dist/build.d.ts +147 -44
  9. package/dist/build.js +1410 -564
  10. package/dist/cdn.dev.global.js +14 -12
  11. package/dist/cdn.full.dev.global.js +15 -13
  12. package/dist/cdn.full.global.js +14 -12
  13. package/dist/cdn.global.js +12 -10
  14. package/dist/chunk-3ACAAQIN.js +224 -0
  15. package/dist/{chunk-7NCARGJW.js → chunk-44MTL7ED.js} +6 -6
  16. package/dist/{chunk-BAAG6ZTI.js → chunk-4WMSTZ7J.js} +8 -5
  17. package/dist/{chunk-H3SRKIYX.js → chunk-62BDYGAG.js} +8 -0
  18. package/dist/{chunk-DKGBBKOF.js → chunk-C5PEWEGH.js} +20 -5
  19. package/dist/{chunk-3ISI6ACU.js → chunk-C7AA2CZX.js} +1 -1
  20. package/dist/{chunk-UZQ6ALFS.js → chunk-CZPRSWSS.js} +1 -1
  21. package/dist/{chunk-D33YTSX5.js → chunk-DSID757X.js} +5 -4
  22. package/dist/{chunk-OXUY2A6L.js → chunk-EGUQLBHE.js} +22 -8
  23. package/dist/{chunk-2INLLLMZ.js → chunk-EXXSN3BW.js} +202 -26
  24. package/dist/{chunk-HURREPU2.js → chunk-FC6KCJSA.js} +87 -150
  25. package/dist/{chunk-HYXDKS4N.js → chunk-GSGNX35Q.js} +5 -5
  26. package/dist/{chunk-7GQCWFOE.js → chunk-J3YQ457H.js} +171 -85
  27. package/dist/{chunk-ORMZXBKQ.js → chunk-JUTFX2RM.js} +18 -10
  28. package/dist/{chunk-QE4TTDU3.js → chunk-KJ3UKABJ.js} +12 -11
  29. package/dist/{chunk-XRRZKZYX.js → chunk-LI4W3U6C.js} +1 -1
  30. package/dist/{chunk-47M47FOM.js → chunk-O6TRVMJI.js} +58 -6
  31. package/dist/{chunk-JSXPZCET.js → chunk-Q5J2LVKH.js} +1 -1
  32. package/dist/{chunk-5MT6SJ3P.js → chunk-QGMSESDD.js} +10 -5
  33. package/dist/{chunk-AIF3Z2T7.js → chunk-RGLPEBDE.js} +13 -10
  34. package/dist/{chunk-5Q4R7HCL.js → chunk-TQQUN4WR.js} +11 -2
  35. package/dist/{chunk-PK6FK2G2.js → chunk-UCNP3HVM.js} +183 -30
  36. package/dist/{chunk-XC4MEKGA.js → chunk-V3LHZSU5.js} +8 -2
  37. package/dist/{chunk-VVWPJ543.js → chunk-VWT3VXPL.js} +55 -20
  38. package/dist/{chunk-SXXVZMKZ.js → chunk-ZVLHNEEL.js} +17 -35
  39. package/dist/{contracts-DRIuclVT.d.cts → contracts-CLqzJnOV.d.ts} +28 -17
  40. package/dist/{contracts-DRIuclVT.d.ts → contracts-CTOJXu-x.d.cts} +28 -17
  41. package/dist/{customElement-MmInOW1U.d.ts → customElement-pYDKUzWl.d.cts} +11 -3
  42. package/dist/{customElement-MmInOW1U.d.cts → customElement-pYDKUzWl.d.ts} +11 -3
  43. package/dist/data.cjs +205 -39
  44. package/dist/data.d.cts +119 -3
  45. package/dist/data.d.ts +119 -3
  46. package/dist/data.js +6 -6
  47. package/dist/devtools.cjs +18 -5
  48. package/dist/devtools.js +5 -5
  49. package/dist/ecosystem.cjs +462 -58
  50. package/dist/ecosystem.d.cts +2 -1
  51. package/dist/ecosystem.d.ts +2 -1
  52. package/dist/ecosystem.js +9 -8
  53. package/dist/extras.cjs +852 -296
  54. package/dist/extras.d.cts +5 -4
  55. package/dist/extras.d.ts +5 -4
  56. package/dist/extras.js +24 -23
  57. package/dist/index.cjs +721 -176
  58. package/dist/index.d.cts +220 -169
  59. package/dist/index.d.ts +220 -169
  60. package/dist/index.js +16 -12
  61. package/dist/motion.cjs +12 -4
  62. package/dist/motion.js +3 -3
  63. package/dist/patterns.cjs +37 -21
  64. package/dist/patterns.d.cts +2 -1
  65. package/dist/patterns.d.ts +2 -1
  66. package/dist/patterns.js +6 -6
  67. package/dist/performance.cjs +48 -6
  68. package/dist/performance.d.cts +12 -2
  69. package/dist/performance.d.ts +12 -2
  70. package/dist/performance.js +8 -6
  71. package/dist/plugins.cjs +672 -261
  72. package/dist/plugins.d.cts +131 -13
  73. package/dist/plugins.d.ts +131 -13
  74. package/dist/plugins.js +83 -47
  75. package/dist/{ssr-XOTUASDO.js → ssr-5OWAH3U2.js} +4 -2
  76. package/dist/{ssr-Bli9XRW5.d.cts → ssr-C8hgIAw7.d.cts} +6 -0
  77. package/dist/{ssr-Bli9XRW5.d.ts → ssr-C8hgIAw7.d.ts} +6 -0
  78. package/dist/ssr.cjs +509 -142
  79. package/dist/ssr.d.cts +55 -5
  80. package/dist/ssr.d.ts +55 -5
  81. package/dist/ssr.js +11 -9
  82. package/dist/{tagFactory-DFstCLQV.d.cts → tagFactory-8qL9LCIx.d.cts} +58 -19
  83. package/dist/{tagFactory-DkaNVUNV.d.ts → tagFactory-BL2fymez.d.ts} +58 -19
  84. package/dist/testing.cjs +17 -4
  85. package/dist/testing.js +4 -4
  86. package/dist/types-CJFViL6Q.d.cts +26 -0
  87. package/dist/types-CJFViL6Q.d.ts +26 -0
  88. package/dist/ui.cjs +635 -254
  89. package/dist/ui.d.cts +3 -2
  90. package/dist/ui.d.ts +3 -2
  91. package/dist/ui.js +9 -8
  92. package/dist/widgets.cjs +22 -14
  93. package/dist/widgets.js +7 -7
  94. package/package.json +8 -5
package/dist/plugins.js CHANGED
@@ -19,10 +19,7 @@ import {
19
19
  preloadCritical,
20
20
  prerenderRoutes,
21
21
  satisfies
22
- } from "./chunk-5MT6SJ3P.js";
23
- import {
24
- isUnsafeKey
25
- } from "./chunk-H3SRKIYX.js";
22
+ } from "./chunk-QGMSESDD.js";
26
23
  import {
27
24
  PluginInstallCancelledError,
28
25
  createPlugin,
@@ -38,38 +35,45 @@ import {
38
35
  } from "./chunk-J6FW5TV6.js";
39
36
  import {
40
37
  span
41
- } from "./chunk-JSXPZCET.js";
38
+ } from "./chunk-Q5J2LVKH.js";
42
39
  import {
43
40
  escapeScriptJson,
44
41
  renderToString,
45
42
  serializeHeadEntry
46
- } from "./chunk-HURREPU2.js";
43
+ } from "./chunk-FC6KCJSA.js";
44
+ import {
45
+ isUnsafeKey,
46
+ readOwnGlobal
47
+ } from "./chunk-62BDYGAG.js";
47
48
  import {
49
+ appendChildren,
48
50
  resolveClassValue
49
- } from "./chunk-VVWPJ543.js";
50
- import "./chunk-47M47FOM.js";
51
+ } from "./chunk-VWT3VXPL.js";
51
52
  import {
52
- isUrlAttribute,
53
- sanitizeStyleAttribute,
54
- sanitizeUrl,
55
- stripControlChars
56
- } from "./chunk-2INLLLMZ.js";
53
+ setSafeAttribute
54
+ } from "./chunk-O6TRVMJI.js";
55
+ import "./chunk-3ACAAQIN.js";
57
56
  import {
58
57
  globalSingleton
59
58
  } from "./chunk-7ZHH77QA.js";
60
59
  import {
61
60
  effect
62
- } from "./chunk-XC4MEKGA.js";
61
+ } from "./chunk-V3LHZSU5.js";
62
+ import {
63
+ sanitizeUrl,
64
+ stripControlChars
65
+ } from "./chunk-EXXSN3BW.js";
63
66
  import {
64
67
  getRequestStore
65
68
  } from "./chunk-7XHATCIH.js";
66
69
  import "./chunk-5HZXGZ6T.js";
67
70
  import {
68
71
  signal
69
- } from "./chunk-D33YTSX5.js";
72
+ } from "./chunk-DSID757X.js";
70
73
  import {
71
- track
72
- } from "./chunk-5Q4R7HCL.js";
74
+ track,
75
+ untracked
76
+ } from "./chunk-TQQUN4WR.js";
73
77
  import {
74
78
  devWarn,
75
79
  dispose,
@@ -80,14 +84,20 @@ import {
80
84
  // src/plugins/i18n.ts
81
85
  var _i18n = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.i18n.v1"), () => ({
82
86
  locale: signal("en"),
83
- locales: /* @__PURE__ */ Object.create(null)
87
+ locales: /* @__PURE__ */ Object.create(null),
88
+ revision: signal(0)
84
89
  }));
85
90
  var [clientLocale, setClientLocale] = _i18n.locale;
86
91
  var locales = _i18n.locales;
92
+ var [revision, setRevision] = _i18n.revision ?? (_i18n.revision = signal(0));
87
93
  function dictionaryFor(locale) {
88
94
  return Object.hasOwn(locales, locale) ? locales[locale] : void 0;
89
95
  }
96
+ function trackDictionaries() {
97
+ if (!getRequestStore()) revision();
98
+ }
90
99
  function lookup(key) {
100
+ trackDictionaries();
91
101
  const dictionary = dictionaryFor(getLocale());
92
102
  if (dictionary === void 0 || !Object.hasOwn(dictionary, key)) return void 0;
93
103
  const message = dictionary[key];
@@ -108,6 +118,7 @@ function getLocale() {
108
118
  }
109
119
  return clientLocale();
110
120
  }
121
+ _i18n.getLocale ?? (_i18n.getLocale = getLocale);
111
122
  function registerTranslations(locale, messages) {
112
123
  const prepared = { ...messages };
113
124
  const merged = Object.assign(/* @__PURE__ */ Object.create(null), dictionaryFor(locale), prepared);
@@ -117,18 +128,29 @@ function registerTranslations(locale, messages) {
117
128
  enumerable: true,
118
129
  configurable: true
119
130
  });
131
+ setRevision((n) => n + 1);
132
+ }
133
+ function resolveParam(params, name) {
134
+ if (!Object.hasOwn(params, name)) return "";
135
+ const raw = params[name];
136
+ const value = typeof raw === "function" ? raw() : raw;
137
+ return value == null ? "" : String(value);
120
138
  }
121
139
  function t(key, params) {
122
140
  const message = lookup(key) ?? key;
123
- return params ? message.replace(/\{(\w+)\}/g, (_, p) => String(params[p] ?? "")) : message;
141
+ return params ? message.replace(/\{(\w+)\}/g, (_, p) => resolveParam(params, p)) : message;
142
+ }
143
+ function translated(key, params) {
144
+ return () => t(key, params);
124
145
  }
125
146
  function Trans(key, params) {
126
- return span(() => t(key, params));
147
+ return span(translated(key, params));
127
148
  }
128
149
  function hasTranslation(key) {
129
150
  return lookup(key) !== void 0;
130
151
  }
131
152
  function getAvailableLocales() {
153
+ trackDictionaries();
132
154
  return Object.keys(locales);
133
155
  }
134
156
 
@@ -1302,6 +1324,30 @@ function afterEach(hook) {
1302
1324
  return _routerRef.current.afterEach(hook);
1303
1325
  }
1304
1326
  var routeCleanups = [];
1327
+ var ownParamNamesCache = /* @__PURE__ */ new WeakMap();
1328
+ function ownParamNames(record) {
1329
+ const cached = ownParamNamesCache.get(record);
1330
+ if (cached) return cached;
1331
+ const aliases = record.alias == null ? [] : Array.isArray(record.alias) ? record.alias : [record.alias];
1332
+ const names = /* @__PURE__ */ new Set();
1333
+ for (const pattern of [record.path, ...aliases]) {
1334
+ for (const m of pattern.matchAll(/\/:([^/]+)/g)) {
1335
+ names.add(m[1].endsWith("?") ? m[1].slice(0, -1) : m[1]);
1336
+ }
1337
+ }
1338
+ const result = [...names];
1339
+ ownParamNamesCache.set(record, result);
1340
+ return result;
1341
+ }
1342
+ function instanceKey(owner, records, route2) {
1343
+ const custom = owner.key;
1344
+ if (custom) return untracked(() => String(custom(route2)));
1345
+ const parts = [];
1346
+ for (const record of records) {
1347
+ for (const name of ownParamNames(record)) parts.push(name, route2.params[name] ?? null);
1348
+ }
1349
+ return JSON.stringify(parts);
1350
+ }
1305
1351
  function Route() {
1306
1352
  const anchor = document.createComment("route-outlet");
1307
1353
  let currentNode = null;
@@ -1309,6 +1355,7 @@ function Route() {
1309
1355
  let errorNode = null;
1310
1356
  let navSeq = 0;
1311
1357
  let currentTopRoute = null;
1358
+ let currentKey = null;
1312
1359
  let routeTorn = false;
1313
1360
  const commitTarget = (seq) => routeTorn || seq !== navSeq ? null : anchor.parentNode;
1314
1361
  const release = (node) => {
@@ -1400,11 +1447,13 @@ function Route() {
1400
1447
  const match = _routerRef.current["matcher"].match(route2.path);
1401
1448
  if (!match) {
1402
1449
  currentTopRoute = null;
1450
+ currentKey = null;
1403
1451
  cleanupNodes();
1404
1452
  return;
1405
1453
  }
1406
1454
  const routeDef = match.matched[0] || match.route;
1407
- if (routeDef === currentTopRoute && currentNode) {
1455
+ const key = instanceKey(routeDef, [routeDef], route2);
1456
+ if (routeDef === currentTopRoute && key === currentKey && currentNode) {
1408
1457
  return;
1409
1458
  }
1410
1459
  if ("redirect" in routeDef) {
@@ -1432,6 +1481,7 @@ function Route() {
1432
1481
  }
1433
1482
  if (node) {
1434
1483
  currentTopRoute = routeDef;
1484
+ currentKey = key;
1435
1485
  cleanupNodes();
1436
1486
  parent.insertBefore(node, anchor.nextSibling);
1437
1487
  currentNode = node;
@@ -1469,6 +1519,7 @@ function Route() {
1469
1519
  routeTeardown();
1470
1520
  cleanupNodes();
1471
1521
  currentTopRoute = null;
1522
+ currentKey = null;
1472
1523
  };
1473
1524
  registerDisposer(anchor, routeCleanup);
1474
1525
  routeCleanups.push(routeCleanup);
@@ -1644,30 +1695,10 @@ function RouterLink(props, children) {
1644
1695
  const lkey = key.toLowerCase();
1645
1696
  if (lkey === "href" || lkey[0] === "o" && lkey[1] === "n") return;
1646
1697
  if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1647
- const str = String(value);
1648
- if (isUrlAttribute(lkey)) {
1649
- const safe = sanitizeUrl(str);
1650
- if (safe) link.setAttribute(key, safe);
1651
- } else if (lkey === "style") {
1652
- link.setAttribute(key, sanitizeStyleAttribute(str, { element: link }));
1653
- } else {
1654
- link.setAttribute(key, str);
1655
- }
1698
+ setSafeAttribute(link, key, String(value), { syncValueProperty: false, label: "RouterLink" });
1656
1699
  }
1657
1700
  });
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
- }
1701
+ if (content !== void 0) appendChildren(link, content);
1671
1702
  const onLinkClick = (e) => {
1672
1703
  if (e.defaultPrevented || target || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) {
1673
1704
  return;
@@ -1829,6 +1860,7 @@ function Outlet() {
1829
1860
  const anchor = document.createComment("route-outlet-nested");
1830
1861
  let currentNode = null;
1831
1862
  let currentChild = null;
1863
+ let currentKey = null;
1832
1864
  let navSeq = 0;
1833
1865
  let outletTorn = false;
1834
1866
  const clearCurrent = () => {
@@ -1838,6 +1870,7 @@ function Outlet() {
1838
1870
  currentNode = null;
1839
1871
  }
1840
1872
  currentChild = null;
1873
+ currentKey = null;
1841
1874
  };
1842
1875
  const commitTarget = (seq) => outletTorn || seq !== navSeq ? null : anchor.parentNode;
1843
1876
  const release = (node) => {
@@ -1858,7 +1891,8 @@ function Outlet() {
1858
1891
  clearCurrent();
1859
1892
  return;
1860
1893
  }
1861
- if (childRoute === currentChild && currentNode) return;
1894
+ const key = instanceKey(childRoute, route2.matched.slice(1), route2);
1895
+ if (childRoute === currentChild && key === currentKey && currentNode) return;
1862
1896
  try {
1863
1897
  const cacheKey = `${route2.path}\0${childRoute.path}`;
1864
1898
  const plan = await _routerRef.current.loadPlan(childRoute, cacheKey);
@@ -1874,6 +1908,7 @@ function Outlet() {
1874
1908
  parent.insertBefore(node, anchor.nextSibling);
1875
1909
  currentNode = node;
1876
1910
  currentChild = childRoute;
1911
+ currentKey = key;
1877
1912
  } catch (error) {
1878
1913
  if (outletTorn || seq !== navSeq) return;
1879
1914
  console.error("[Outlet] Failed to render child route:", error);
@@ -1896,6 +1931,7 @@ function Outlet() {
1896
1931
  currentNode = null;
1897
1932
  }
1898
1933
  currentChild = null;
1934
+ currentKey = null;
1899
1935
  };
1900
1936
  registerDisposer(anchor, outletCleanup);
1901
1937
  routeCleanups.push(outletCleanup);
@@ -2187,8 +2223,7 @@ function serializeRouteState(state, nonce) {
2187
2223
  return `<script${nonceAttr}>window.${SSR_ROUTE_STATE_KEY}=${json}</script>`;
2188
2224
  }
2189
2225
  function deserializeRouteState() {
2190
- if (typeof window === "undefined") return void 0;
2191
- return window[SSR_ROUTE_STATE_KEY];
2226
+ return readOwnGlobal(SSR_ROUTE_STATE_KEY);
2192
2227
  }
2193
2228
  function hydrateRouter(routes, options) {
2194
2229
  const serverState = deserializeRouteState();
@@ -2202,7 +2237,7 @@ function hydrateRouter(routes, options) {
2202
2237
  const liveUrl = `${window.location.pathname}${window.location.search}${window.location.hash}`;
2203
2238
  const resolved = resolveServerRoute(liveUrl, routes);
2204
2239
  const bootstrapEpoch = __getNavigationEpoch();
2205
- import("./ssr-XOTUASDO.js").then(async ({ hydrate }) => {
2240
+ import("./ssr-5OWAH3U2.js").then(async ({ hydrate }) => {
2206
2241
  const { replaceChildrenSafely } = await import("./dispose-GEIG2KOF.js");
2207
2242
  if (__getNavigationEpoch() !== bootstrapEpoch) return;
2208
2243
  if (resolved.component) {
@@ -2312,6 +2347,7 @@ export {
2312
2347
  setRouteTransition,
2313
2348
  setRoutes,
2314
2349
  t,
2350
+ translated,
2315
2351
  triggerPluginError,
2316
2352
  triggerPluginMount,
2317
2353
  triggerPluginUnmount
@@ -17,8 +17,10 @@ import {
17
17
  ssrSuspense,
18
18
  suspenseSwapScript,
19
19
  trustHTML
20
- } from "./chunk-HURREPU2.js";
21
- import "./chunk-2INLLLMZ.js";
20
+ } from "./chunk-FC6KCJSA.js";
21
+ import "./chunk-62BDYGAG.js";
22
+ import "./chunk-3ACAAQIN.js";
23
+ import "./chunk-EXXSN3BW.js";
22
24
  import "./chunk-7XHATCIH.js";
23
25
  import "./chunk-NYNYSPK7.js";
24
26
  export {
@@ -103,6 +103,12 @@ declare function renderToDocument(component: () => HTMLElement, options?: {
103
103
  title?: string;
104
104
  meta?: Record<string, string>[];
105
105
  links?: Record<string, string>[];
106
+ /**
107
+ * External script URLs appended to `<body>`. Each passes the scheme
108
+ * allowlist; an allowed URL is still code that runs with the page's
109
+ * authority, so this option is an explicit trust decision — first-party
110
+ * or pinned URLs only, never request-derived values.
111
+ */
106
112
  scripts?: string[];
107
113
  bodyAttrs?: Record<string, string>;
108
114
  /**
@@ -103,6 +103,12 @@ declare function renderToDocument(component: () => HTMLElement, options?: {
103
103
  title?: string;
104
104
  meta?: Record<string, string>[];
105
105
  links?: Record<string, string>[];
106
+ /**
107
+ * External script URLs appended to `<body>`. Each passes the scheme
108
+ * allowlist; an allowed URL is still code that runs with the page's
109
+ * authority, so this option is an explicit trust decision — first-party
110
+ * or pinned URLs only, never request-derived values.
111
+ */
106
112
  scripts?: string[];
107
113
  bodyAttrs?: Record<string, string>;
108
114
  /**