sibujs 3.3.1 → 3.3.3
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.
- package/dist/browser.cjs +41 -18
- package/dist/browser.js +5 -5
- package/dist/build.cjs +57 -22
- package/dist/build.js +14 -14
- package/dist/cdn.global.js +7 -7
- package/dist/{chunk-MHBCEJQO.js → chunk-23VT3KZB.js} +2 -2
- package/dist/{chunk-WL7BIR6O.js → chunk-25LY5SRH.js} +31 -24
- package/dist/{chunk-37BUKSLH.js → chunk-5K6RVA2S.js} +1 -1
- package/dist/{chunk-AMIKDMLP.js → chunk-5Y34FWED.js} +17 -6
- package/dist/chunk-7ZHH77QA.js +9 -0
- package/dist/chunk-CCSJMTRN.js +15 -0
- package/dist/{chunk-R3QEDXFS.js → chunk-EX77FXTT.js} +1 -1
- package/dist/{chunk-WW6DAGGR.js → chunk-F3HO2MP7.js} +1 -1
- package/dist/{chunk-ZUVLC7TM.js → chunk-F7HW2NI5.js} +2 -4
- package/dist/{chunk-ULLTNDRA.js → chunk-IEYFHN5V.js} +72 -25
- package/dist/{chunk-Z37APKBV.js → chunk-IQN5W7GE.js} +73 -16
- package/dist/{chunk-WZG2SZOT.js → chunk-IWFE4AHO.js} +1 -1
- package/dist/{chunk-IKLYI3RF.js → chunk-MYXEBADX.js} +53 -23
- package/dist/{chunk-6LTFHJQG.js → chunk-QCQQ2N5H.js} +41 -20
- package/dist/{chunk-VOVVTOEA.js → chunk-QTOOBABV.js} +22 -5
- package/dist/{chunk-LU2MQXQQ.js → chunk-RZKGMHH4.js} +6 -6
- package/dist/{chunk-GOJMFRBL.js → chunk-S3NFJO6L.js} +20 -14
- package/dist/{chunk-NHKQKKZU.js → chunk-SBPUXWCE.js} +1 -1
- package/dist/{chunk-SLMFA3ZZ.js → chunk-TBDTU7UO.js} +2 -2
- package/dist/{chunk-4UUMSLSL.js → chunk-TVCCXPU2.js} +5 -5
- package/dist/{chunk-TEFZT5PJ.js → chunk-UOMYIAG6.js} +1 -1
- package/dist/{chunk-XH2RTYEQ.js → chunk-WFUUT6TG.js} +15 -8
- package/dist/{chunk-M5KBNOSJ.js → chunk-WTFMV2RU.js} +70 -59
- package/dist/{chunk-3JHCYHWN.js → chunk-WWV3SJ3L.js} +19 -13
- package/dist/{chunk-RYMOSG5B.js → chunk-Y35NQNLG.js} +90 -60
- package/dist/{chunk-F7FXQ3QS.js → chunk-ZXCZWMZT.js} +1 -1
- package/dist/data.cjs +36 -16
- package/dist/data.js +8 -7
- package/dist/devtools.cjs +91 -35
- package/dist/devtools.d.cts +12 -5
- package/dist/devtools.d.ts +12 -5
- package/dist/devtools.js +7 -6
- package/dist/ecosystem.cjs +31 -16
- package/dist/ecosystem.js +11 -10
- package/dist/extras.cjs +485 -280
- package/dist/extras.d.cts +1 -1
- package/dist/extras.d.ts +1 -1
- package/dist/extras.js +28 -24
- package/dist/index.cjs +59 -22
- package/dist/index.d.cts +24 -8
- package/dist/index.d.ts +24 -8
- package/dist/index.js +25 -21
- package/dist/motion.cjs +223 -204
- package/dist/motion.d.cts +8 -1
- package/dist/motion.d.ts +8 -1
- package/dist/motion.js +6 -3
- package/dist/patterns.cjs +33 -20
- package/dist/patterns.d.cts +4 -1
- package/dist/patterns.d.ts +4 -1
- package/dist/patterns.js +6 -6
- package/dist/performance.cjs +90 -70
- package/dist/performance.js +8 -7
- package/dist/plugins.cjs +207 -144
- package/dist/plugins.d.cts +2 -1
- package/dist/plugins.d.ts +2 -1
- package/dist/plugins.js +178 -124
- package/dist/{ssr-6D67RAVB.js → ssr-2PPULEK2.js} +2 -2
- package/dist/ssr.cjs +132 -105
- package/dist/ssr.d.cts +8 -1
- package/dist/ssr.d.ts +8 -1
- package/dist/ssr.js +11 -10
- package/dist/testing.cjs +38 -18
- package/dist/testing.js +19 -8
- package/dist/ui.cjs +337 -294
- package/dist/ui.d.cts +0 -20
- package/dist/ui.d.ts +0 -20
- package/dist/ui.js +30 -24
- package/dist/widgets.cjs +95 -27
- package/dist/widgets.d.cts +6 -1
- package/dist/widgets.d.ts +6 -1
- package/dist/widgets.js +8 -7
- package/package.json +1 -1
- package/dist/chunk-YT6HQ6AM.js +0 -14
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
globalSingleton
|
|
3
|
+
} from "./chunk-7ZHH77QA.js";
|
|
4
|
+
|
|
1
5
|
// src/plugins/plugin.ts
|
|
2
6
|
function createPluginRegistry() {
|
|
3
7
|
const installedPlugins = /* @__PURE__ */ new Set();
|
|
@@ -77,39 +81,41 @@ function createPluginRegistry() {
|
|
|
77
81
|
};
|
|
78
82
|
return registry;
|
|
79
83
|
}
|
|
80
|
-
var
|
|
81
|
-
|
|
84
|
+
var _defaults = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.plugins.defaultRegistry.v1"), () => ({
|
|
85
|
+
registry: createPluginRegistry(),
|
|
86
|
+
touched: false
|
|
87
|
+
}));
|
|
82
88
|
function createPlugin(name, install) {
|
|
83
89
|
return { name, install };
|
|
84
90
|
}
|
|
85
91
|
function plugin(plugin2, options) {
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
_defaults.touched = true;
|
|
93
|
+
_defaults.registry.plugin(plugin2, options);
|
|
88
94
|
}
|
|
89
95
|
function inject(key, defaultValue) {
|
|
90
|
-
return
|
|
96
|
+
return _defaults.registry.inject(key, defaultValue);
|
|
91
97
|
}
|
|
92
98
|
function triggerPluginMount(element) {
|
|
93
|
-
|
|
99
|
+
_defaults.registry.triggerMount(element);
|
|
94
100
|
}
|
|
95
101
|
function triggerPluginUnmount(element) {
|
|
96
|
-
|
|
102
|
+
_defaults.registry.triggerUnmount(element);
|
|
97
103
|
}
|
|
98
104
|
function triggerPluginError(error) {
|
|
99
|
-
|
|
105
|
+
_defaults.registry.triggerError(error);
|
|
100
106
|
}
|
|
101
107
|
function resetPlugins() {
|
|
102
|
-
|
|
103
|
-
|
|
108
|
+
_defaults.registry.reset();
|
|
109
|
+
_defaults.touched = false;
|
|
104
110
|
}
|
|
105
111
|
function setDefaultPluginRegistry(registry) {
|
|
106
|
-
if (
|
|
112
|
+
if (_defaults.touched && _defaults.registry.installedPlugins.size > 0) {
|
|
107
113
|
console.warn(
|
|
108
114
|
"[Plugin] Replacing default plugin registry while plugins are already installed on the singleton. This may indicate mixed singleton/registry usage."
|
|
109
115
|
);
|
|
110
116
|
}
|
|
111
|
-
|
|
112
|
-
|
|
117
|
+
_defaults.registry = registry;
|
|
118
|
+
_defaults.touched = true;
|
|
113
119
|
}
|
|
114
120
|
|
|
115
121
|
export {
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
+
import {
|
|
2
|
+
globalSingleton
|
|
3
|
+
} from "./chunk-7ZHH77QA.js";
|
|
1
4
|
import {
|
|
2
5
|
bindAttribute
|
|
3
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-SBPUXWCE.js";
|
|
4
7
|
import {
|
|
5
8
|
derived
|
|
6
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-F3HO2MP7.js";
|
|
10
|
+
import {
|
|
11
|
+
effect
|
|
12
|
+
} from "./chunk-23VT3KZB.js";
|
|
7
13
|
import {
|
|
8
14
|
dispose,
|
|
9
15
|
registerDisposer
|
|
10
16
|
} from "./chunk-5VGSK6D2.js";
|
|
11
|
-
import {
|
|
12
|
-
effect
|
|
13
|
-
} from "./chunk-MHBCEJQO.js";
|
|
14
17
|
import {
|
|
15
18
|
signal
|
|
16
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-IWFE4AHO.js";
|
|
17
20
|
import {
|
|
18
21
|
track
|
|
19
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-UOMYIAG6.js";
|
|
20
23
|
|
|
21
24
|
// src/ui/form.ts
|
|
22
25
|
function required(message = "This field is required") {
|
|
@@ -74,30 +77,46 @@ function custom(fn, message) {
|
|
|
74
77
|
return (value) => fn(value) ? null : message;
|
|
75
78
|
}
|
|
76
79
|
function bindField(field, extras) {
|
|
80
|
+
const readControlValue = (target) => {
|
|
81
|
+
if ("checked" in target && target.type === "checkbox") {
|
|
82
|
+
return target.checked;
|
|
83
|
+
}
|
|
84
|
+
if (target instanceof HTMLSelectElement && target.multiple) {
|
|
85
|
+
return Array.from(target.selectedOptions, (o) => o.value);
|
|
86
|
+
}
|
|
87
|
+
return target.value;
|
|
88
|
+
};
|
|
77
89
|
const fieldOn = {
|
|
78
|
-
input: (e) =>
|
|
79
|
-
|
|
80
|
-
if (target.type === "checkbox") {
|
|
81
|
-
field.set(target.checked);
|
|
82
|
-
} else {
|
|
83
|
-
field.set(target.value);
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
change: (e) => {
|
|
87
|
-
const target = e.target;
|
|
88
|
-
if ("checked" in target && target.type === "checkbox") {
|
|
89
|
-
field.set(target.checked);
|
|
90
|
-
} else {
|
|
91
|
-
field.set(target.value);
|
|
92
|
-
}
|
|
93
|
-
},
|
|
90
|
+
input: (e) => field.set(readControlValue(e.target)),
|
|
91
|
+
change: (e) => field.set(readControlValue(e.target)),
|
|
94
92
|
blur: () => field.touch()
|
|
95
93
|
};
|
|
96
|
-
const {
|
|
94
|
+
const {
|
|
95
|
+
on: extraOn,
|
|
96
|
+
value: _ignoreValue,
|
|
97
|
+
onElement: extraOnElement,
|
|
98
|
+
...restExtras
|
|
99
|
+
} = extras ?? {};
|
|
97
100
|
const mergedOn = extraOn && typeof extraOn === "object" ? { ...extraOn, ...fieldOn } : fieldOn;
|
|
101
|
+
const onElement = (el) => {
|
|
102
|
+
if (el instanceof HTMLSelectElement && el.multiple) {
|
|
103
|
+
const stop = effect(() => {
|
|
104
|
+
const v = field.value();
|
|
105
|
+
const selected = Array.isArray(v) ? v.map(String) : [];
|
|
106
|
+
for (const opt of Array.from(el.options)) {
|
|
107
|
+
opt.selected = selected.includes(opt.value);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
registerDisposer(el, stop);
|
|
111
|
+
}
|
|
112
|
+
if (typeof extraOnElement === "function") {
|
|
113
|
+
extraOnElement(el);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
98
116
|
return {
|
|
99
117
|
value: field.value,
|
|
100
118
|
on: mergedOn,
|
|
119
|
+
onElement,
|
|
101
120
|
...restExtras
|
|
102
121
|
};
|
|
103
122
|
}
|
|
@@ -154,9 +173,21 @@ function form(config) {
|
|
|
154
173
|
}
|
|
155
174
|
return true;
|
|
156
175
|
});
|
|
176
|
+
const valueEquals = (a, b) => {
|
|
177
|
+
if (Object.is(a, b)) return true;
|
|
178
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
179
|
+
return a.length === b.length && a.every((v, i) => Object.is(v, b[i]));
|
|
180
|
+
}
|
|
181
|
+
if (a && b && typeof a === "object" && typeof b === "object") {
|
|
182
|
+
const ak = Object.keys(a);
|
|
183
|
+
const bk = Object.keys(b);
|
|
184
|
+
return ak.length === bk.length && ak.every((k) => Object.is(a[k], b[k]));
|
|
185
|
+
}
|
|
186
|
+
return false;
|
|
187
|
+
};
|
|
157
188
|
const isDirty = derived(() => {
|
|
158
189
|
for (const [name, cfg] of fieldEntries) {
|
|
159
|
-
if (!
|
|
190
|
+
if (!valueEquals(fieldMap[name].value(), cfg.initial)) return true;
|
|
160
191
|
}
|
|
161
192
|
return false;
|
|
162
193
|
});
|
|
@@ -372,7 +403,6 @@ function inputMask(options) {
|
|
|
372
403
|
return /[^a-zA-Z0-9]/g;
|
|
373
404
|
}
|
|
374
405
|
const stripRegex = buildStripRegex();
|
|
375
|
-
const rawCharTest = options.pattern.includes("*") ? () => true : (c) => /[a-zA-Z0-9]/.test(c);
|
|
376
406
|
function bind(input) {
|
|
377
407
|
const onInput = () => {
|
|
378
408
|
const cursorBefore = input.selectionStart ?? input.value.length;
|
|
@@ -382,20 +412,14 @@ function inputMask(options) {
|
|
|
382
412
|
setValue(masked);
|
|
383
413
|
setRawValue(extractRaw(masked));
|
|
384
414
|
input.value = masked;
|
|
385
|
-
|
|
386
|
-
for (let i = 0; i < cursorBefore && i < oldValue.length; i++) {
|
|
387
|
-
if (rawCharTest(oldValue[i])) rawBefore++;
|
|
388
|
-
}
|
|
415
|
+
const rawBefore = oldValue.slice(0, cursorBefore).replace(stripRegex, "").length;
|
|
389
416
|
let newCursor = 0;
|
|
390
417
|
let counted = 0;
|
|
391
|
-
|
|
418
|
+
while (newCursor < masked.length && counted < rawBefore) {
|
|
392
419
|
if (newCursor < options.pattern.length && isSlot(options.pattern[newCursor])) {
|
|
393
420
|
counted++;
|
|
394
|
-
if (counted >= rawBefore) {
|
|
395
|
-
newCursor++;
|
|
396
|
-
break;
|
|
397
|
-
}
|
|
398
421
|
}
|
|
422
|
+
newCursor++;
|
|
399
423
|
}
|
|
400
424
|
try {
|
|
401
425
|
input.setSelectionRange(newCursor, newCursor);
|
|
@@ -594,14 +618,12 @@ function hotkey(combo, handler, options = {}) {
|
|
|
594
618
|
document.addEventListener("keydown", listener);
|
|
595
619
|
return () => document.removeEventListener("keydown", listener);
|
|
596
620
|
}
|
|
597
|
-
var
|
|
598
|
-
polite: [],
|
|
599
|
-
assertive:
|
|
600
|
-
};
|
|
601
|
-
var
|
|
602
|
-
|
|
603
|
-
assertive: false
|
|
604
|
-
};
|
|
621
|
+
var _announce = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.a11y.announce.v1"), () => ({
|
|
622
|
+
queues: { polite: [], assertive: [] },
|
|
623
|
+
draining: { polite: false, assertive: false }
|
|
624
|
+
}));
|
|
625
|
+
var announceQueues = _announce.queues;
|
|
626
|
+
var announceDraining = _announce.draining;
|
|
605
627
|
var ANNOUNCE_INTERVAL_MS = 150;
|
|
606
628
|
function ensureLiveRegion(priority) {
|
|
607
629
|
let region = document.getElementById(`sibu-announce-${priority}`);
|
|
@@ -643,7 +665,7 @@ function announce(message, priority = "polite") {
|
|
|
643
665
|
}
|
|
644
666
|
|
|
645
667
|
// src/ui/scopedStyle.ts
|
|
646
|
-
var
|
|
668
|
+
var _scope = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.scopedStyle.v1"), () => ({ n: 0 }));
|
|
647
669
|
function decodeCssEscapes(css) {
|
|
648
670
|
return css.replace(/\\([0-9a-f]{1,6})[ \t\n\r\f]?|\\([^\n])/gi, (_match, hex, ch) => {
|
|
649
671
|
if (hex) {
|
|
@@ -670,7 +692,7 @@ function sanitizeCSS(css) {
|
|
|
670
692
|
return sanitized;
|
|
671
693
|
}
|
|
672
694
|
function scopedStyle(css) {
|
|
673
|
-
const id = `sibu-s${
|
|
695
|
+
const id = `sibu-s${_scope.n++}`;
|
|
674
696
|
const attr = `data-${id}`;
|
|
675
697
|
const safeCss = sanitizeCSS(css);
|
|
676
698
|
const scopedCSS = safeCss.replace(/([^\r\n,{}]+)(,(?=[^}]*{)|\s*{)/g, (match, selector, delimiter) => {
|
|
@@ -777,13 +799,16 @@ function bindData(el, key, getter) {
|
|
|
777
799
|
}
|
|
778
800
|
|
|
779
801
|
// src/ui/dialog.ts
|
|
780
|
-
var
|
|
781
|
-
|
|
802
|
+
var _dlg = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.dialog.v1"), () => ({
|
|
803
|
+
stack: [],
|
|
804
|
+
listenerAttached: false
|
|
805
|
+
}));
|
|
806
|
+
var dialogStack = _dlg.stack;
|
|
782
807
|
function __resetDialogStack() {
|
|
783
808
|
while (dialogStack.length > 0) dialogStack.pop();
|
|
784
|
-
if (typeof window !== "undefined" &&
|
|
809
|
+
if (typeof window !== "undefined" && _dlg.listenerAttached) {
|
|
785
810
|
window.removeEventListener("keydown", handleGlobalKeydown);
|
|
786
|
-
|
|
811
|
+
_dlg.listenerAttached = false;
|
|
787
812
|
}
|
|
788
813
|
}
|
|
789
814
|
function handleGlobalKeydown(event) {
|
|
@@ -792,16 +817,16 @@ function handleGlobalKeydown(event) {
|
|
|
792
817
|
if (top) top.close();
|
|
793
818
|
}
|
|
794
819
|
function ensureGlobalListener() {
|
|
795
|
-
if (typeof window === "undefined" ||
|
|
820
|
+
if (typeof window === "undefined" || _dlg.listenerAttached) return;
|
|
796
821
|
window.addEventListener("keydown", handleGlobalKeydown);
|
|
797
|
-
|
|
822
|
+
_dlg.listenerAttached = true;
|
|
798
823
|
}
|
|
799
824
|
function removeGlobalListenerIfIdle() {
|
|
800
825
|
if (typeof window === "undefined") return;
|
|
801
|
-
if (!
|
|
826
|
+
if (!_dlg.listenerAttached) return;
|
|
802
827
|
if (dialogStack.length > 0) return;
|
|
803
828
|
window.removeEventListener("keydown", handleGlobalKeydown);
|
|
804
|
-
|
|
829
|
+
_dlg.listenerAttached = false;
|
|
805
830
|
}
|
|
806
831
|
function dialog() {
|
|
807
832
|
const [isOpen, setIsOpen] = signal(false);
|
|
@@ -927,6 +952,10 @@ function infiniteScroll(options) {
|
|
|
927
952
|
await onLoadMore();
|
|
928
953
|
} finally {
|
|
929
954
|
setLoading(false);
|
|
955
|
+
if (!disposed && observer && _current && hasMore()) {
|
|
956
|
+
observer.unobserve(_current);
|
|
957
|
+
observer.observe(_current);
|
|
958
|
+
}
|
|
930
959
|
}
|
|
931
960
|
}
|
|
932
961
|
const originalRef = sentinelRef;
|
|
@@ -966,29 +995,30 @@ function pagination(options) {
|
|
|
966
995
|
const total = options.totalItems();
|
|
967
996
|
return Math.max(1, Math.ceil(total / pageSizeValue));
|
|
968
997
|
});
|
|
998
|
+
const currentPage = derived(() => Math.min(Math.max(1, page()), totalPages()));
|
|
969
999
|
const startIndex = derived(() => {
|
|
970
|
-
return (
|
|
1000
|
+
return (currentPage() - 1) * pageSizeValue;
|
|
971
1001
|
});
|
|
972
1002
|
const endIndex = derived(() => {
|
|
973
|
-
const end =
|
|
1003
|
+
const end = currentPage() * pageSizeValue;
|
|
974
1004
|
const total = options.totalItems();
|
|
975
1005
|
return Math.min(end, total);
|
|
976
1006
|
});
|
|
977
1007
|
function next() {
|
|
978
|
-
if (
|
|
979
|
-
setPage((
|
|
1008
|
+
if (currentPage() < totalPages()) {
|
|
1009
|
+
setPage(currentPage() + 1);
|
|
980
1010
|
}
|
|
981
1011
|
}
|
|
982
1012
|
function prev() {
|
|
983
|
-
if (
|
|
984
|
-
setPage((
|
|
1013
|
+
if (currentPage() > 1) {
|
|
1014
|
+
setPage(currentPage() - 1);
|
|
985
1015
|
}
|
|
986
1016
|
}
|
|
987
1017
|
function goTo(target) {
|
|
988
1018
|
const clamped = Math.max(1, Math.min(target, totalPages()));
|
|
989
1019
|
setPage(clamped);
|
|
990
1020
|
}
|
|
991
|
-
return { page, pageSize, totalPages, next, prev, goTo, startIndex, endIndex };
|
|
1021
|
+
return { page: currentPage, pageSize, totalPages, next, prev, goTo, startIndex, endIndex };
|
|
992
1022
|
}
|
|
993
1023
|
|
|
994
1024
|
// src/ui/eventBus.ts
|
package/dist/data.cjs
CHANGED
|
@@ -482,7 +482,7 @@ function forEachSubscriber(signal2, visit) {
|
|
|
482
482
|
|
|
483
483
|
// src/reactivity/track.ts
|
|
484
484
|
var _isDev3 = isDev();
|
|
485
|
-
var _runtimeVersion =
|
|
485
|
+
var _runtimeVersion = true ? "3.3.3" : "dev";
|
|
486
486
|
var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
|
|
487
487
|
function resolveReactiveApi() {
|
|
488
488
|
const g = globalThis;
|
|
@@ -618,23 +618,29 @@ function derived(getter, options) {
|
|
|
618
618
|
}
|
|
619
619
|
|
|
620
620
|
// src/core/ssr-context.ts
|
|
621
|
-
var
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
621
|
+
var SSR_KEY = /* @__PURE__ */ Symbol.for("sibujs.ssr.v1");
|
|
622
|
+
function detectSSRShared() {
|
|
623
|
+
let detected = null;
|
|
624
|
+
try {
|
|
625
|
+
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
626
|
+
let mod = null;
|
|
627
|
+
const getBuiltin = process.getBuiltinModule;
|
|
628
|
+
if (typeof getBuiltin === "function") {
|
|
629
|
+
mod = getBuiltin("node:async_hooks");
|
|
630
|
+
} else {
|
|
631
|
+
const req = Function("return typeof require==='function'?require:null")();
|
|
632
|
+
if (req) mod = req("node:async_hooks");
|
|
633
|
+
}
|
|
634
|
+
if (mod) detected = new mod.AsyncLocalStorage();
|
|
631
635
|
}
|
|
632
|
-
|
|
636
|
+
} catch {
|
|
637
|
+
detected = null;
|
|
633
638
|
}
|
|
634
|
-
|
|
635
|
-
als = null;
|
|
639
|
+
return { als: detected, fallbackStore: { ssr: false, suspenseIdCounter: 0 } };
|
|
636
640
|
}
|
|
637
|
-
var
|
|
641
|
+
var _shared = globalThis[SSR_KEY] ?? (globalThis[SSR_KEY] = detectSSRShared());
|
|
642
|
+
var als = _shared.als;
|
|
643
|
+
var fallbackStore = _shared.fallbackStore;
|
|
638
644
|
function getSSRStore() {
|
|
639
645
|
if (als) {
|
|
640
646
|
const s = als.getStore();
|
|
@@ -898,6 +904,12 @@ function signal(initial, options) {
|
|
|
898
904
|
return [get, set];
|
|
899
905
|
}
|
|
900
906
|
|
|
907
|
+
// src/utils/globalSingleton.ts
|
|
908
|
+
function globalSingleton(key, create) {
|
|
909
|
+
const g = globalThis;
|
|
910
|
+
return g[key] ?? (g[key] = create());
|
|
911
|
+
}
|
|
912
|
+
|
|
901
913
|
// src/data/retry.ts
|
|
902
914
|
function calculateDelay(attempt, strategy, baseDelay, maxDelay, jitter) {
|
|
903
915
|
let delay;
|
|
@@ -959,7 +971,7 @@ async function withRetry(fn, options, onRetry, signal2) {
|
|
|
959
971
|
}
|
|
960
972
|
|
|
961
973
|
// src/data/query.ts
|
|
962
|
-
var globalQueryCache = /* @__PURE__ */ new Map();
|
|
974
|
+
var globalQueryCache = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.query.cache.v1"), () => /* @__PURE__ */ new Map());
|
|
963
975
|
function getActiveQueryCache() {
|
|
964
976
|
return getRequestScopedCache("query") ?? globalQueryCache;
|
|
965
977
|
}
|
|
@@ -1981,6 +1993,10 @@ function socket(url, options) {
|
|
|
1981
1993
|
}
|
|
1982
1994
|
function connect() {
|
|
1983
1995
|
if (disposed) return;
|
|
1996
|
+
if (typeof WebSocket === "undefined") {
|
|
1997
|
+
setStatus("closed");
|
|
1998
|
+
return;
|
|
1999
|
+
}
|
|
1984
2000
|
const safeUrl = validateWsUrl(getUrl());
|
|
1985
2001
|
if (safeUrl === null) {
|
|
1986
2002
|
setStatus("closed");
|
|
@@ -2101,6 +2117,10 @@ function stream(url, options) {
|
|
|
2101
2117
|
let attempts = 0;
|
|
2102
2118
|
function connect() {
|
|
2103
2119
|
if (disposed) return;
|
|
2120
|
+
if (typeof EventSource === "undefined") {
|
|
2121
|
+
setStatus("closed");
|
|
2122
|
+
return;
|
|
2123
|
+
}
|
|
2104
2124
|
const safeUrl = validateSseUrl(url);
|
|
2105
2125
|
if (safeUrl === null) {
|
|
2106
2126
|
setStatus("closed");
|
package/dist/data.js
CHANGED
|
@@ -20,14 +20,15 @@ import {
|
|
|
20
20
|
syncAdapter,
|
|
21
21
|
throttle,
|
|
22
22
|
withRetry
|
|
23
|
-
} from "./chunk-
|
|
24
|
-
import "./chunk-
|
|
25
|
-
import "./chunk-
|
|
23
|
+
} from "./chunk-5Y34FWED.js";
|
|
24
|
+
import "./chunk-7ZHH77QA.js";
|
|
25
|
+
import "./chunk-ZXCZWMZT.js";
|
|
26
|
+
import "./chunk-F3HO2MP7.js";
|
|
26
27
|
import "./chunk-L3GAGWCC.js";
|
|
27
|
-
import "./chunk-
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-
|
|
30
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-23VT3KZB.js";
|
|
29
|
+
import "./chunk-S3NFJO6L.js";
|
|
30
|
+
import "./chunk-IWFE4AHO.js";
|
|
31
|
+
import "./chunk-UOMYIAG6.js";
|
|
31
32
|
import "./chunk-COY6PUD2.js";
|
|
32
33
|
export {
|
|
33
34
|
__resetQueryCache,
|