sibujs 3.3.2 → 3.4.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 (77) hide show
  1. package/dist/browser.cjs +21 -4
  2. package/dist/browser.js +4 -4
  3. package/dist/build.cjs +3343 -3009
  4. package/dist/build.js +12 -11
  5. package/dist/cdn.global.js +7 -7
  6. package/dist/{chunk-AEOLHSSQ.js → chunk-3DVGCW7O.js} +72 -25
  7. package/dist/{chunk-6TCOWMGY.js → chunk-3Z2NGWQI.js} +1 -1
  8. package/dist/chunk-7ZHH77QA.js +9 -0
  9. package/dist/{chunk-2ARSB7NG.js → chunk-APFRCIRI.js} +2906 -2569
  10. package/dist/{chunk-62V653X2.js → chunk-AXFWGY32.js} +79 -44
  11. package/dist/{chunk-N5TQVEKE.js → chunk-BUKYCWHX.js} +1 -1
  12. package/dist/{chunk-655B7MMR.js → chunk-CEBWDD63.js} +15 -8
  13. package/dist/{chunk-YUBEOWII.js → chunk-ELXMRSVN.js} +16 -5
  14. package/dist/{chunk-FJIRS3FM.js → chunk-F7HW2NI5.js} +1 -3
  15. package/dist/{chunk-P7C7SEJV.js → chunk-FKQG7FTY.js} +5 -5
  16. package/dist/{chunk-RLTFJYDN.js → chunk-H5FI5WDP.js} +1 -1
  17. package/dist/{chunk-G6N3LMO2.js → chunk-ITWCTZYH.js} +1 -1
  18. package/dist/{chunk-YUR5SX7F.js → chunk-JCO7AHNU.js} +70 -59
  19. package/dist/{chunk-ZEUP4TUD.js → chunk-JNGGM2XE.js} +6 -6
  20. package/dist/{chunk-QCFBIVIQ.js → chunk-K35BAR4P.js} +1 -1
  21. package/dist/{chunk-JCQG2I2G.js → chunk-KZBEVFXZ.js} +1 -1
  22. package/dist/{chunk-FJO2ZL4Q.js → chunk-OAVXAFAY.js} +73 -16
  23. package/dist/{chunk-A7CZH3GN.js → chunk-ODXVQ3CS.js} +41 -20
  24. package/dist/{chunk-4NJEAPLI.js → chunk-OOUQUCNN.js} +1 -1
  25. package/dist/{chunk-5VH3GIDX.js → chunk-RT3IYFN2.js} +1 -1
  26. package/dist/{chunk-Q46YIQYW.js → chunk-S3V6ZXPI.js} +22 -5
  27. package/dist/{chunk-IQJ36UTJ.js → chunk-WSGLJYFI.js} +31 -24
  28. package/dist/{chunk-3JHCYHWN.js → chunk-WWV3SJ3L.js} +19 -13
  29. package/dist/data.cjs +16 -2
  30. package/dist/data.js +7 -6
  31. package/dist/devtools.cjs +71 -21
  32. package/dist/devtools.d.cts +12 -5
  33. package/dist/devtools.d.ts +12 -5
  34. package/dist/devtools.js +6 -5
  35. package/dist/ecosystem.cjs +11 -2
  36. package/dist/ecosystem.d.cts +1 -1
  37. package/dist/ecosystem.d.ts +1 -1
  38. package/dist/ecosystem.js +10 -9
  39. package/dist/extras.cjs +454 -250
  40. package/dist/extras.d.cts +2 -2
  41. package/dist/extras.d.ts +2 -2
  42. package/dist/extras.js +26 -22
  43. package/dist/index.cjs +3385 -3045
  44. package/dist/index.d.cts +1179 -1057
  45. package/dist/index.d.ts +1179 -1057
  46. package/dist/index.js +32 -19
  47. package/dist/motion.cjs +223 -204
  48. package/dist/motion.d.cts +8 -1
  49. package/dist/motion.d.ts +8 -1
  50. package/dist/motion.js +6 -3
  51. package/dist/patterns.cjs +13 -6
  52. package/dist/patterns.d.cts +4 -1
  53. package/dist/patterns.d.ts +4 -1
  54. package/dist/patterns.js +5 -5
  55. package/dist/performance.cjs +70 -56
  56. package/dist/performance.js +6 -5
  57. package/dist/plugins.cjs +98 -42
  58. package/dist/plugins.d.cts +2 -1
  59. package/dist/plugins.d.ts +2 -1
  60. package/dist/plugins.js +89 -36
  61. package/dist/ssr.cjs +112 -91
  62. package/dist/ssr.d.cts +8 -1
  63. package/dist/ssr.d.ts +8 -1
  64. package/dist/ssr.js +9 -8
  65. package/dist/{tagFactory-S17H2qxu.d.ts → tagFactory-Bzupt4Pj.d.cts} +1 -1
  66. package/dist/{tagFactory-S17H2qxu.d.cts → tagFactory-Bzupt4Pj.d.ts} +1 -1
  67. package/dist/testing.cjs +18 -4
  68. package/dist/testing.js +18 -7
  69. package/dist/ui.cjs +322 -281
  70. package/dist/ui.d.cts +0 -20
  71. package/dist/ui.d.ts +0 -20
  72. package/dist/ui.js +27 -21
  73. package/dist/widgets.cjs +75 -13
  74. package/dist/widgets.d.cts +6 -1
  75. package/dist/widgets.d.ts +6 -1
  76. package/dist/widgets.js +7 -6
  77. package/package.json +4 -1
@@ -1,19 +1,19 @@
1
1
  import {
2
2
  bindAttribute
3
- } from "./chunk-QCFBIVIQ.js";
4
- import {
5
- dispose,
6
- registerDisposer
7
- } from "./chunk-5VGSK6D2.js";
3
+ } from "./chunk-K35BAR4P.js";
8
4
  import {
9
5
  isEventHandlerAttr,
10
6
  sanitizeAttributeString,
11
7
  sanitizeCSSValue
12
8
  } from "./chunk-L3GAGWCC.js";
9
+ import {
10
+ dispose,
11
+ registerDisposer
12
+ } from "./chunk-5VGSK6D2.js";
13
13
  import {
14
14
  reactiveBinding,
15
15
  track
16
- } from "./chunk-4NJEAPLI.js";
16
+ } from "./chunk-OOUQUCNN.js";
17
17
  import {
18
18
  devWarn,
19
19
  isDev
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-L3GAGWCC.js";
5
5
  import {
6
6
  reactiveBinding
7
- } from "./chunk-4NJEAPLI.js";
7
+ } from "./chunk-OOUQUCNN.js";
8
8
  import {
9
9
  devWarn,
10
10
  isDev
@@ -3,7 +3,7 @@ import {
3
3
  notifySubscribers,
4
4
  queueSignalNotification,
5
5
  recordDependency
6
- } from "./chunk-4NJEAPLI.js";
6
+ } from "./chunk-OOUQUCNN.js";
7
7
  import {
8
8
  isDev
9
9
  } from "./chunk-COY6PUD2.js";
@@ -1,22 +1,24 @@
1
1
  import {
2
2
  watch
3
- } from "./chunk-RLTFJYDN.js";
3
+ } from "./chunk-H5FI5WDP.js";
4
+ import {
5
+ createId
6
+ } from "./chunk-CCSJMTRN.js";
4
7
  import {
5
8
  derived
6
- } from "./chunk-G6N3LMO2.js";
9
+ } from "./chunk-ITWCTZYH.js";
7
10
  import {
8
11
  stripHtml
9
12
  } from "./chunk-L3GAGWCC.js";
10
13
  import {
11
14
  effect
12
- } from "./chunk-N5TQVEKE.js";
15
+ } from "./chunk-BUKYCWHX.js";
13
16
  import {
14
17
  batch,
15
18
  signal
16
- } from "./chunk-JCQG2I2G.js";
19
+ } from "./chunk-KZBEVFXZ.js";
17
20
 
18
21
  // src/widgets/Combobox.ts
19
- var comboboxIdCounter = 0;
20
22
  var boundComboboxes = /* @__PURE__ */ new WeakMap();
21
23
  function combobox(options) {
22
24
  const { items, filterFn, itemToString } = options;
@@ -77,7 +79,13 @@ function combobox(options) {
77
79
  function bind(els) {
78
80
  const existing = boundComboboxes.get(els.input);
79
81
  if (existing) return existing;
80
- const listboxId = `sibu-combobox-listbox-${++comboboxIdCounter}`;
82
+ const prevListboxId = els.listbox.id;
83
+ const prevListboxRole = els.listbox.getAttribute("role");
84
+ const prevListboxHidden = els.listbox.hidden;
85
+ const prevInputRole = els.input.getAttribute("role");
86
+ const prevInputAutocomplete = els.input.getAttribute("aria-autocomplete");
87
+ const prevInputControls = els.input.getAttribute("aria-controls");
88
+ const listboxId = createId("sibu-combobox-listbox");
81
89
  els.listbox.id = listboxId;
82
90
  els.listbox.setAttribute("role", "listbox");
83
91
  els.input.setAttribute("role", "combobox");
@@ -141,10 +149,14 @@ function combobox(options) {
141
149
  if (document.activeElement !== els.input) close();
142
150
  }, 100);
143
151
  };
152
+ const onListboxPointerDown = (e) => {
153
+ e.preventDefault();
154
+ };
144
155
  els.input.addEventListener("input", onInput);
145
156
  els.input.addEventListener("keydown", onKey);
146
157
  els.input.addEventListener("focus", onFocus);
147
158
  els.input.addEventListener("blur", onBlur);
159
+ els.listbox.addEventListener("mousedown", onListboxPointerDown);
148
160
  const teardown = () => {
149
161
  boundComboboxes.delete(els.input);
150
162
  fxTeardown();
@@ -152,10 +164,24 @@ function combobox(options) {
152
164
  els.input.removeEventListener("keydown", onKey);
153
165
  els.input.removeEventListener("focus", onFocus);
154
166
  els.input.removeEventListener("blur", onBlur);
167
+ els.listbox.removeEventListener("mousedown", onListboxPointerDown);
155
168
  if (blurTimer !== null) {
156
169
  clearTimeout(blurTimer);
157
170
  blurTimer = null;
158
171
  }
172
+ if (prevListboxId === "") els.listbox.removeAttribute("id");
173
+ else els.listbox.id = prevListboxId;
174
+ if (prevListboxRole === null) els.listbox.removeAttribute("role");
175
+ else els.listbox.setAttribute("role", prevListboxRole);
176
+ els.listbox.hidden = prevListboxHidden;
177
+ if (prevInputRole === null) els.input.removeAttribute("role");
178
+ else els.input.setAttribute("role", prevInputRole);
179
+ if (prevInputAutocomplete === null) els.input.removeAttribute("aria-autocomplete");
180
+ else els.input.setAttribute("aria-autocomplete", prevInputAutocomplete);
181
+ if (prevInputControls === null) els.input.removeAttribute("aria-controls");
182
+ else els.input.setAttribute("aria-controls", prevInputControls);
183
+ els.input.removeAttribute("aria-expanded");
184
+ els.input.removeAttribute("aria-activedescendant");
159
185
  };
160
186
  boundComboboxes.set(els.input, teardown);
161
187
  return teardown;
@@ -491,7 +517,6 @@ function accordion(options) {
491
517
  }
492
518
 
493
519
  // src/widgets/Popover.ts
494
- var popoverIdCounter = 0;
495
520
  var boundPopovers = /* @__PURE__ */ new WeakMap();
496
521
  function popover() {
497
522
  const [isOpen, setIsOpen] = signal(false);
@@ -507,7 +532,7 @@ function popover() {
507
532
  function bind(els) {
508
533
  const existing = boundPopovers.get(els.trigger);
509
534
  if (existing) return existing;
510
- const id = `sibu-popover-${++popoverIdCounter}`;
535
+ const id = createId("sibu-popover");
511
536
  const prevPopoverRole = els.popover.getAttribute("role");
512
537
  const prevPopoverId = els.popover.id;
513
538
  const prevLabelledBy = els.popover.getAttribute("aria-labelledby");
@@ -581,7 +606,6 @@ function popover() {
581
606
  }
582
607
 
583
608
  // src/widgets/Select.ts
584
- var selectIdCounter = 0;
585
609
  var boundSelects = /* @__PURE__ */ new WeakMap();
586
610
  function select(options) {
587
611
  const { items, multiple = false, itemToString, isDisabled } = options;
@@ -662,7 +686,11 @@ function select(options) {
662
686
  function bind(els) {
663
687
  const existing = boundSelects.get(els.listbox);
664
688
  if (existing) return existing;
665
- const listboxId = `sibu-select-${++selectIdCounter}`;
689
+ const prevId = els.listbox.id;
690
+ const prevRole = els.listbox.getAttribute("role");
691
+ const prevMultiselectable = els.listbox.getAttribute("aria-multiselectable");
692
+ const prevTabIndex = els.listbox.getAttribute("tabindex");
693
+ const listboxId = createId("sibu-select");
666
694
  els.listbox.id = listboxId;
667
695
  els.listbox.setAttribute("role", "listbox");
668
696
  els.listbox.setAttribute("aria-multiselectable", multiple ? "true" : "false");
@@ -722,6 +750,15 @@ function select(options) {
722
750
  fxTeardown();
723
751
  els.listbox.removeEventListener("keydown", onKey);
724
752
  if (typeTimer !== null) clearTimeout(typeTimer);
753
+ if (prevId === "") els.listbox.removeAttribute("id");
754
+ else els.listbox.id = prevId;
755
+ if (prevRole === null) els.listbox.removeAttribute("role");
756
+ else els.listbox.setAttribute("role", prevRole);
757
+ if (prevMultiselectable === null) els.listbox.removeAttribute("aria-multiselectable");
758
+ else els.listbox.setAttribute("aria-multiselectable", prevMultiselectable);
759
+ if (prevTabIndex === null) els.listbox.removeAttribute("tabindex");
760
+ else els.listbox.setAttribute("tabindex", prevTabIndex);
761
+ els.listbox.removeAttribute("aria-activedescendant");
725
762
  };
726
763
  boundSelects.set(els.listbox, teardown);
727
764
  return teardown;
@@ -746,7 +783,6 @@ function select(options) {
746
783
  }
747
784
 
748
785
  // src/widgets/Tooltip.ts
749
- var tooltipIdCounter = 0;
750
786
  var boundTriggers = /* @__PURE__ */ new WeakMap();
751
787
  function tooltip(options) {
752
788
  const delay = options?.delay ?? 0;
@@ -791,7 +827,7 @@ function tooltip(options) {
791
827
  function bind(els) {
792
828
  const existing = boundTriggers.get(els.trigger);
793
829
  if (existing) return existing;
794
- const id = `sibu-tooltip-${++tooltipIdCounter}`;
830
+ const id = createId("sibu-tooltip");
795
831
  els.tooltip.setAttribute("role", "tooltip");
796
832
  els.tooltip.id = id;
797
833
  const prevDescribedBy = els.trigger.getAttribute("aria-describedby");
@@ -851,7 +887,6 @@ function tooltip(options) {
851
887
  }
852
888
 
853
889
  // src/widgets/FileUpload.ts
854
- var fileUploadIdCounter = 0;
855
890
  var boundFileUploads = /* @__PURE__ */ new WeakMap();
856
891
  function fileUpload(options) {
857
892
  const accept = options?.accept;
@@ -923,7 +958,7 @@ function fileUpload(options) {
923
958
  function bind(els) {
924
959
  const existing = boundFileUploads.get(els.input);
925
960
  if (existing) return existing;
926
- const id = `sibu-fileupload-${++fileUploadIdCounter}`;
961
+ const id = createId("sibu-fileupload");
927
962
  const restore = [];
928
963
  if (accept) els.input.accept = accept;
929
964
  els.input.multiple = multiple;
@@ -1034,7 +1069,7 @@ function fileUpload(options) {
1034
1069
  }
1035
1070
 
1036
1071
  // src/widgets/contentEditable.ts
1037
- function contentEditable() {
1072
+ function contentEditable(element) {
1038
1073
  const [content, setContentInternal] = signal("");
1039
1074
  const [isFocused, setFocused] = signal(false);
1040
1075
  function setContent(input) {
@@ -1058,6 +1093,7 @@ function contentEditable() {
1058
1093
  const selection = window.getSelection();
1059
1094
  if (!selection || selection.rangeCount === 0 || selection.isCollapsed) return;
1060
1095
  const range = selection.getRangeAt(0);
1096
+ if (element && !element.contains(range.commonAncestorContainer)) return;
1061
1097
  const ancestor = range.commonAncestorContainer;
1062
1098
  const existingWrap = findAncestorByTag(
1063
1099
  ancestor instanceof HTMLElement ? ancestor : ancestor.parentElement,
@@ -1237,12 +1273,18 @@ function datePicker(options) {
1237
1273
  function bind(els) {
1238
1274
  const existing = boundDatePickers.get(els.grid);
1239
1275
  if (existing) return existing;
1276
+ const prevGridRole = els.grid.getAttribute("role");
1277
+ const prevGridTabIndex = els.grid.getAttribute("tabindex");
1278
+ const prevGridLabel = els.grid.getAttribute("aria-label");
1240
1279
  els.grid.setAttribute("role", "grid");
1241
1280
  if (els.grid.tabIndex < 0) els.grid.tabIndex = 0;
1281
+ let pendingFocus = false;
1242
1282
  const fxTeardown = effect(() => {
1243
1283
  const sel = selectedDate();
1244
1284
  const view = viewDate();
1245
1285
  const days = daysInMonth();
1286
+ els.grid.setAttribute("aria-label", view.toLocaleDateString(void 0, { month: "long", year: "numeric" }));
1287
+ let viewCell = null;
1246
1288
  for (const d of days) {
1247
1289
  const cell = els.cell(d.date);
1248
1290
  if (!cell) continue;
@@ -1250,7 +1292,13 @@ function datePicker(options) {
1250
1292
  cell.setAttribute("aria-selected", sel && isSameCalendarDay(sel, d.date) ? "true" : "false");
1251
1293
  if (d.isDisabled) cell.setAttribute("aria-disabled", "true");
1252
1294
  else cell.removeAttribute("aria-disabled");
1253
- cell.tabIndex = isSameCalendarDay(view, d.date) ? 0 : -1;
1295
+ const isView = isSameCalendarDay(view, d.date);
1296
+ cell.tabIndex = isView ? 0 : -1;
1297
+ if (isView) viewCell = cell;
1298
+ }
1299
+ if (pendingFocus && viewCell && typeof viewCell.focus === "function") {
1300
+ pendingFocus = false;
1301
+ viewCell.focus();
1254
1302
  }
1255
1303
  });
1256
1304
  function isSameCalendarDay(a, b) {
@@ -1260,6 +1308,9 @@ function datePicker(options) {
1260
1308
  setViewDate((prev) => new Date(prev.getFullYear(), prev.getMonth(), prev.getDate() + delta));
1261
1309
  }
1262
1310
  const onKey = (e) => {
1311
+ if (e.key === "ArrowLeft" || e.key === "ArrowRight" || e.key === "ArrowUp" || e.key === "ArrowDown" || e.key === "Home" || e.key === "End" || e.key === "PageUp" || e.key === "PageDown") {
1312
+ pendingFocus = true;
1313
+ }
1263
1314
  switch (e.key) {
1264
1315
  case "ArrowLeft":
1265
1316
  e.preventDefault();
@@ -1308,6 +1359,12 @@ function datePicker(options) {
1308
1359
  boundDatePickers.delete(els.grid);
1309
1360
  fxTeardown();
1310
1361
  els.grid.removeEventListener("keydown", onKey);
1362
+ if (prevGridRole === null) els.grid.removeAttribute("role");
1363
+ else els.grid.setAttribute("role", prevGridRole);
1364
+ if (prevGridTabIndex === null) els.grid.removeAttribute("tabindex");
1365
+ else els.grid.setAttribute("tabindex", prevGridTabIndex);
1366
+ if (prevGridLabel === null) els.grid.removeAttribute("aria-label");
1367
+ else els.grid.setAttribute("aria-label", prevGridLabel);
1311
1368
  };
1312
1369
  boundDatePickers.set(els.grid, teardown);
1313
1370
  return teardown;
@@ -1,7 +1,10 @@
1
1
  import {
2
2
  div,
3
3
  span
4
- } from "./chunk-6TCOWMGY.js";
4
+ } from "./chunk-3Z2NGWQI.js";
5
+ import {
6
+ globalSingleton
7
+ } from "./chunk-7ZHH77QA.js";
5
8
  import {
6
9
  isEventHandlerAttr,
7
10
  sanitizeUrl,
@@ -9,11 +12,14 @@ import {
9
12
  } from "./chunk-L3GAGWCC.js";
10
13
  import {
11
14
  effect
12
- } from "./chunk-N5TQVEKE.js";
15
+ } from "./chunk-BUKYCWHX.js";
16
+ import {
17
+ registerDisposer
18
+ } from "./chunk-5VGSK6D2.js";
13
19
  import {
14
20
  batch,
15
21
  signal
16
- } from "./chunk-JCQG2I2G.js";
22
+ } from "./chunk-KZBEVFXZ.js";
17
23
 
18
24
  // src/platform/head.ts
19
25
  var HEAD_URL_ATTRS = /* @__PURE__ */ new Set(["href", "src"]);
@@ -139,6 +145,7 @@ function Head(props) {
139
145
  }
140
146
  };
141
147
  apply();
148
+ registerDisposer(anchor, cleanup);
142
149
  return anchor;
143
150
  }
144
151
  function setStructuredData(data) {
@@ -375,8 +382,14 @@ function createWorkerPool(workerFn2, poolSize) {
375
382
  }
376
383
 
377
384
  // src/platform/wasm.ts
378
- var moduleCache = /* @__PURE__ */ new Map();
379
- var instanceCache = /* @__PURE__ */ new Map();
385
+ var moduleCache = globalSingleton(
386
+ /* @__PURE__ */ Symbol.for("sibujs.wasm.moduleCache.v1"),
387
+ () => /* @__PURE__ */ new Map()
388
+ );
389
+ var instanceCache = globalSingleton(
390
+ /* @__PURE__ */ Symbol.for("sibujs.wasm.instanceCache.v1"),
391
+ () => /* @__PURE__ */ new Map()
392
+ );
380
393
  function wasm(source, config = {}) {
381
394
  const [instance, setInstance] = signal(null);
382
395
  const [loading, setLoading] = signal(true);
@@ -537,7 +550,10 @@ function isWasmCached(key) {
537
550
  }
538
551
 
539
552
  // src/platform/microfrontend.ts
540
- var moduleCache2 = /* @__PURE__ */ new Map();
553
+ var moduleCache2 = globalSingleton(
554
+ /* @__PURE__ */ Symbol.for("sibujs.microfrontend.moduleCache.v1"),
555
+ () => /* @__PURE__ */ new Map()
556
+ );
541
557
  function createMicroApp(config) {
542
558
  const host = config.container ?? document.createElement("div");
543
559
  host.setAttribute("data-micro-app", config.name);
@@ -808,24 +824,30 @@ function createAction(actionFn) {
808
824
  const [data, setData] = signal(void 0);
809
825
  const [error, setError] = signal(void 0);
810
826
  const [loading, setLoading] = signal(false);
827
+ let activeRun = 0;
811
828
  const submit = async (input) => {
829
+ const runId = ++activeRun;
812
830
  batch(() => {
813
831
  setLoading(true);
814
832
  setError(void 0);
815
833
  });
816
834
  try {
817
835
  const result = await actionFn(input);
818
- batch(() => {
819
- setData(result);
820
- setLoading(false);
821
- });
836
+ if (runId === activeRun) {
837
+ batch(() => {
838
+ setData(result);
839
+ setLoading(false);
840
+ });
841
+ }
822
842
  return result;
823
843
  } catch (err) {
824
844
  const actionError = err instanceof Error ? err : new Error(String(err));
825
- batch(() => {
826
- setError(actionError);
827
- setLoading(false);
828
- });
845
+ if (runId === activeRun) {
846
+ batch(() => {
847
+ setError(actionError);
848
+ setLoading(false);
849
+ });
850
+ }
829
851
  throw actionError;
830
852
  }
831
853
  };
@@ -839,15 +861,14 @@ function scrollRestoration(options) {
839
861
  let popstateHandler = null;
840
862
  let currentKey = null;
841
863
  const save = (key) => {
842
- positions.set(key, {
843
- x: window.scrollX,
844
- y: window.scrollY
845
- });
864
+ if (typeof window !== "undefined") {
865
+ positions.set(key, { x: window.scrollX, y: window.scrollY });
866
+ }
846
867
  currentKey = key;
847
868
  };
848
869
  const restore = (key) => {
849
870
  const pos = positions.get(key);
850
- if (pos) {
871
+ if (pos && typeof window !== "undefined") {
851
872
  window.scrollTo(pos.x, pos.y);
852
873
  }
853
874
  currentKey = key;
@@ -855,7 +876,7 @@ function scrollRestoration(options) {
855
876
  const getPosition = (key) => {
856
877
  return positions.get(key);
857
878
  };
858
- if (mode === "auto") {
879
+ if (mode === "auto" && typeof window !== "undefined") {
859
880
  popstateHandler = () => {
860
881
  if (currentKey) {
861
882
  save(currentKey);
@@ -419,7 +419,7 @@ function forEachSubscriber(signal, visit) {
419
419
 
420
420
  // src/reactivity/track.ts
421
421
  var _isDev2 = isDev();
422
- var _runtimeVersion = true ? "3.3.2" : "dev";
422
+ var _runtimeVersion = true ? "3.4.0" : "dev";
423
423
  var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
424
424
  function resolveReactiveApi() {
425
425
  const g = globalThis;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  signal
3
- } from "./chunk-JCQG2I2G.js";
3
+ } from "./chunk-KZBEVFXZ.js";
4
4
 
5
5
  // src/core/rendering/context.ts
6
6
  function context(defaultValue) {
@@ -3,11 +3,11 @@ import {
3
3
  } from "./chunk-H3SRKIYX.js";
4
4
  import {
5
5
  effect
6
- } from "./chunk-N5TQVEKE.js";
6
+ } from "./chunk-BUKYCWHX.js";
7
7
  import {
8
8
  batch,
9
9
  signal
10
- } from "./chunk-JCQG2I2G.js";
10
+ } from "./chunk-KZBEVFXZ.js";
11
11
 
12
12
  // src/browser/media.ts
13
13
  function media(query) {
@@ -193,7 +193,7 @@ function battery() {
193
193
  let disposed = false;
194
194
  if (typeof navigator !== "undefined" && "getBattery" in navigator) {
195
195
  setSupported(true);
196
- navigator.getBattery().then((bm) => {
196
+ const batteryPromise = navigator.getBattery().then((bm) => {
197
197
  if (disposed) return;
198
198
  battery2 = bm;
199
199
  batch(() => {
@@ -211,6 +211,9 @@ function battery() {
211
211
  bm.addEventListener("chargingtimechange", onChargingTimeChange);
212
212
  bm.addEventListener("dischargingtimechange", onDischargingTimeChange);
213
213
  });
214
+ batteryPromise.catch(() => {
215
+ if (!disposed) setSupported(false);
216
+ });
214
217
  }
215
218
  function dispose() {
216
219
  disposed = true;
@@ -762,9 +765,17 @@ function wakeLock() {
762
765
  }
763
766
  const api = navigator.wakeLock;
764
767
  let sentinel = null;
768
+ let disposed = false;
765
769
  async function request() {
770
+ if (disposed) return;
766
771
  try {
767
- sentinel = await api.request("screen");
772
+ const s = await api.request("screen");
773
+ if (disposed) {
774
+ s.release().catch(() => {
775
+ });
776
+ return;
777
+ }
778
+ sentinel = s;
768
779
  setActive(true);
769
780
  sentinel.addEventListener("release", () => {
770
781
  setActive(false);
@@ -791,6 +802,7 @@ function wakeLock() {
791
802
  };
792
803
  document.addEventListener("visibilitychange", onVisibility);
793
804
  function dispose() {
805
+ disposed = true;
794
806
  document.removeEventListener("visibilitychange", onVisibility);
795
807
  release().catch((err) => {
796
808
  if (typeof console !== "undefined") {
@@ -822,6 +834,7 @@ function animationFrame(options = {}) {
822
834
  let id = null;
823
835
  let prev = -1;
824
836
  let start = -1;
837
+ let disposed = false;
825
838
  const minFrameMs = options.fpsLimit ? 1e3 / options.fpsLimit : 0;
826
839
  const step = (now) => {
827
840
  if (start < 0) start = now;
@@ -835,7 +848,7 @@ function animationFrame(options = {}) {
835
848
  id = requestAnimationFrame(step);
836
849
  };
837
850
  function resume() {
838
- if (id !== null) return;
851
+ if (disposed || id !== null) return;
839
852
  setRunning(true);
840
853
  id = requestAnimationFrame(step);
841
854
  }
@@ -849,6 +862,7 @@ function animationFrame(options = {}) {
849
862
  start = -1;
850
863
  }
851
864
  function dispose() {
865
+ disposed = true;
852
866
  pause();
853
867
  }
854
868
  if (options.immediate !== false) resume();
@@ -907,7 +921,9 @@ function bounds(target) {
907
921
  }
908
922
  };
909
923
  }
924
+ let disposed = false;
910
925
  function refresh() {
926
+ if (disposed) return;
911
927
  setRect(readRect(target));
912
928
  }
913
929
  refresh();
@@ -919,6 +935,7 @@ function bounds(target) {
919
935
  const onScroll = () => refresh();
920
936
  window.addEventListener("scroll", onScroll, { passive: true, capture: true });
921
937
  function dispose() {
938
+ disposed = true;
922
939
  resizeObserver?.disconnect();
923
940
  window.removeEventListener("scroll", onScroll, { capture: true });
924
941
  }
@@ -1,6 +1,9 @@
1
+ import {
2
+ registerDisposer
3
+ } from "./chunk-5VGSK6D2.js";
1
4
  import {
2
5
  signal
3
- } from "./chunk-JCQG2I2G.js";
6
+ } from "./chunk-KZBEVFXZ.js";
4
7
 
5
8
  // src/ui/transition.ts
6
9
  function transition(element, options = {}) {
@@ -74,6 +77,7 @@ function transition(element, options = {}) {
74
77
  }
75
78
  });
76
79
  }
80
+ registerDisposer(element, cancelPending);
77
81
  return { enter, leave };
78
82
  }
79
83
  function spring(element, keyframes, options = {}) {
@@ -89,8 +93,29 @@ function spring(element, keyframes, options = {}) {
89
93
  });
90
94
  }
91
95
 
96
+ // src/ui/reducedMotion.ts
97
+ function prefersReducedMotion() {
98
+ return typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
99
+ }
100
+ function reducedMotion() {
101
+ if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
102
+ const [reduced2] = signal(false);
103
+ return { reduced: reduced2, dispose: () => {
104
+ } };
105
+ }
106
+ const mql = window.matchMedia("(prefers-reduced-motion: reduce)");
107
+ const [reduced, setReduced] = signal(mql.matches);
108
+ const handler = (event) => {
109
+ setReduced(event.matches);
110
+ };
111
+ mql.addEventListener("change", handler);
112
+ function dispose() {
113
+ mql.removeEventListener("change", handler);
114
+ }
115
+ return { reduced, dispose };
116
+ }
117
+
92
118
  // src/ui/animationPresets.ts
93
- var prefersReducedMotion = () => typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
94
119
  function createPreset(keyframes, defaults, overrides) {
95
120
  const opts = {
96
121
  ...defaults,
@@ -259,6 +284,7 @@ function TransitionGroup(options) {
259
284
  if (options.leave) {
260
285
  await options.leave(el);
261
286
  }
287
+ positions.delete(el);
262
288
  setElements((prev) => prev.filter((e) => e !== el));
263
289
  }
264
290
  function track(newElements) {
@@ -325,27 +351,7 @@ function viewTransition(callback) {
325
351
  return { start, isTransitioning };
326
352
  }
327
353
 
328
- // src/ui/reducedMotion.ts
329
- function reducedMotion() {
330
- if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
331
- const [reduced2] = signal(false);
332
- return { reduced: reduced2, dispose: () => {
333
- } };
334
- }
335
- const mql = window.matchMedia("(prefers-reduced-motion: reduce)");
336
- const [reduced, setReduced] = signal(mql.matches);
337
- const handler = (event) => {
338
- setReduced(event.matches);
339
- };
340
- mql.addEventListener("change", handler);
341
- function dispose() {
342
- mql.removeEventListener("change", handler);
343
- }
344
- return { reduced, dispose };
345
- }
346
-
347
354
  // src/ui/springSignal.ts
348
- var prefersReducedMotion2 = () => typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
349
355
  function springSignal(initial, options) {
350
356
  const stiffness = options?.stiffness ?? 0.15;
351
357
  const damping = options?.damping ?? 0.8;
@@ -381,7 +387,7 @@ function springSignal(initial, options) {
381
387
  }
382
388
  function set(newTarget) {
383
389
  target = newTarget;
384
- if (prefersReducedMotion2()) {
390
+ if (prefersReducedMotion()) {
385
391
  current = newTarget;
386
392
  velocity = 0;
387
393
  if (rafId !== null) {
@@ -410,6 +416,8 @@ function springSignal(initial, options) {
410
416
  export {
411
417
  transition,
412
418
  spring,
419
+ prefersReducedMotion,
420
+ reducedMotion,
413
421
  fadeIn,
414
422
  fadeOut,
415
423
  slideIn,
@@ -426,6 +434,5 @@ export {
426
434
  sequence,
427
435
  TransitionGroup,
428
436
  viewTransition,
429
- reducedMotion,
430
437
  springSignal
431
438
  };