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,7 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
globalSingleton
|
|
3
|
+
} from "./chunk-7ZHH77QA.js";
|
|
1
4
|
import {
|
|
2
5
|
div,
|
|
3
6
|
span
|
|
4
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-5K6RVA2S.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-
|
|
15
|
+
} from "./chunk-23VT3KZB.js";
|
|
16
|
+
import {
|
|
17
|
+
registerDisposer
|
|
18
|
+
} from "./chunk-5VGSK6D2.js";
|
|
13
19
|
import {
|
|
14
20
|
batch,
|
|
15
21
|
signal
|
|
16
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-IWFE4AHO.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 =
|
|
379
|
-
|
|
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 =
|
|
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
|
-
|
|
819
|
-
|
|
820
|
-
|
|
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
|
-
|
|
826
|
-
|
|
827
|
-
|
|
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
|
-
|
|
843
|
-
x: window.scrollX,
|
|
844
|
-
|
|
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);
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
} from "./chunk-H3SRKIYX.js";
|
|
4
4
|
import {
|
|
5
5
|
effect
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-23VT3KZB.js";
|
|
7
7
|
import {
|
|
8
8
|
batch,
|
|
9
9
|
signal
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-IWFE4AHO.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
|
-
|
|
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,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
bindAttribute
|
|
3
|
-
} from "./chunk-
|
|
4
|
-
import {
|
|
5
|
-
dispose,
|
|
6
|
-
registerDisposer
|
|
7
|
-
} from "./chunk-5VGSK6D2.js";
|
|
3
|
+
} from "./chunk-SBPUXWCE.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-
|
|
16
|
+
} from "./chunk-UOMYIAG6.js";
|
|
17
17
|
import {
|
|
18
18
|
devWarn,
|
|
19
19
|
isDev
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
// src/core/ssr-context.ts
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
var SSR_KEY = /* @__PURE__ */ Symbol.for("sibujs.ssr.v1");
|
|
3
|
+
function detectSSRShared() {
|
|
4
|
+
let detected = null;
|
|
5
|
+
try {
|
|
6
|
+
if (typeof process !== "undefined" && process.versions && process.versions.node) {
|
|
7
|
+
let mod = null;
|
|
8
|
+
const getBuiltin = process.getBuiltinModule;
|
|
9
|
+
if (typeof getBuiltin === "function") {
|
|
10
|
+
mod = getBuiltin("node:async_hooks");
|
|
11
|
+
} else {
|
|
12
|
+
const req = Function("return typeof require==='function'?require:null")();
|
|
13
|
+
if (req) mod = req("node:async_hooks");
|
|
14
|
+
}
|
|
15
|
+
if (mod) detected = new mod.AsyncLocalStorage();
|
|
12
16
|
}
|
|
13
|
-
|
|
17
|
+
} catch {
|
|
18
|
+
detected = null;
|
|
14
19
|
}
|
|
15
|
-
|
|
16
|
-
als = null;
|
|
20
|
+
return { als: detected, fallbackStore: { ssr: false, suspenseIdCounter: 0 } };
|
|
17
21
|
}
|
|
18
|
-
var
|
|
22
|
+
var _shared = globalThis[SSR_KEY] ?? (globalThis[SSR_KEY] = detectSSRShared());
|
|
23
|
+
var als = _shared.als;
|
|
24
|
+
var fallbackStore = _shared.fallbackStore;
|
|
19
25
|
function getSSRStore() {
|
|
20
26
|
if (als) {
|
|
21
27
|
const s = als.getStore();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isSSR
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-S3NFJO6L.js";
|
|
4
4
|
import {
|
|
5
5
|
resumeTracking,
|
|
6
6
|
suspendTracking,
|
|
7
7
|
track
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-UOMYIAG6.js";
|
|
9
9
|
import {
|
|
10
10
|
devAssert
|
|
11
11
|
} from "./chunk-COY6PUD2.js";
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createPlugin
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WWV3SJ3L.js";
|
|
4
4
|
import {
|
|
5
5
|
tagFactory
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-RZKGMHH4.js";
|
|
7
7
|
import {
|
|
8
8
|
derived
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-F3HO2MP7.js";
|
|
10
10
|
import {
|
|
11
11
|
effect
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-23VT3KZB.js";
|
|
13
13
|
import {
|
|
14
14
|
batch,
|
|
15
15
|
signal
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-IWFE4AHO.js";
|
|
17
17
|
|
|
18
18
|
// src/ecosystem/adapters/mobx.ts
|
|
19
19
|
function mobXAdapter(options) {
|
|
@@ -419,7 +419,7 @@ function forEachSubscriber(signal, visit) {
|
|
|
419
419
|
|
|
420
420
|
// src/reactivity/track.ts
|
|
421
421
|
var _isDev2 = isDev();
|
|
422
|
-
var _runtimeVersion =
|
|
422
|
+
var _runtimeVersion = true ? "3.3.3" : "dev";
|
|
423
423
|
var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
|
|
424
424
|
function resolveReactiveApi() {
|
|
425
425
|
const g = globalThis;
|
|
@@ -4,14 +4,14 @@ import {
|
|
|
4
4
|
} from "./chunk-H3SRKIYX.js";
|
|
5
5
|
import {
|
|
6
6
|
derived
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-F3HO2MP7.js";
|
|
8
8
|
import {
|
|
9
9
|
effect
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-23VT3KZB.js";
|
|
11
11
|
import {
|
|
12
12
|
batch,
|
|
13
13
|
signal
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-IWFE4AHO.js";
|
|
15
15
|
|
|
16
16
|
// src/patterns/machine.ts
|
|
17
17
|
function machine(config) {
|
|
@@ -73,7 +73,14 @@ function machine(config) {
|
|
|
73
73
|
|
|
74
74
|
// src/patterns/persist.ts
|
|
75
75
|
function persisted(key, initial, options = {}) {
|
|
76
|
-
const storage =
|
|
76
|
+
const storage = (() => {
|
|
77
|
+
try {
|
|
78
|
+
if (options.session) return typeof sessionStorage !== "undefined" ? sessionStorage : null;
|
|
79
|
+
return typeof localStorage !== "undefined" ? localStorage : null;
|
|
80
|
+
} catch {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
})();
|
|
77
84
|
const serialize = options.serialize || JSON.stringify;
|
|
78
85
|
const safeReviver = (k, v) => isUnsafeKey(k) ? void 0 : v;
|
|
79
86
|
const deserialize = options.deserialize || ((raw) => JSON.parse(raw, safeReviver));
|
|
@@ -82,7 +89,7 @@ function persisted(key, initial, options = {}) {
|
|
|
82
89
|
const syncTabs = options.session ? false : options.syncTabs ?? true;
|
|
83
90
|
let restored = initial;
|
|
84
91
|
try {
|
|
85
|
-
let raw = storage.getItem(key);
|
|
92
|
+
let raw = storage ? storage.getItem(key) : null;
|
|
86
93
|
if (raw !== null) {
|
|
87
94
|
if (decrypt) raw = decrypt(raw);
|
|
88
95
|
const parsed = deserialize(raw);
|
|
@@ -98,12 +105,12 @@ function persisted(key, initial, options = {}) {
|
|
|
98
105
|
try {
|
|
99
106
|
let serialized = serialize(current);
|
|
100
107
|
if (encrypt) serialized = encrypt(serialized);
|
|
101
|
-
storage
|
|
108
|
+
storage?.setItem(key, serialized);
|
|
102
109
|
} catch {
|
|
103
110
|
}
|
|
104
111
|
});
|
|
105
112
|
let storageListener = null;
|
|
106
|
-
if (syncTabs && typeof window !== "undefined") {
|
|
113
|
+
if (syncTabs && storage && typeof window !== "undefined") {
|
|
107
114
|
storageListener = (e) => {
|
|
108
115
|
if (e.storageArea !== storage || e.key !== key) return;
|
|
109
116
|
if (e.newValue === null) {
|
|
@@ -406,7 +413,7 @@ function globalStore(config) {
|
|
|
406
413
|
next();
|
|
407
414
|
}
|
|
408
415
|
function select(selector) {
|
|
409
|
-
return
|
|
416
|
+
return () => selector(getState());
|
|
410
417
|
}
|
|
411
418
|
function subscribe(callback) {
|
|
412
419
|
listeners.add(callback);
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "./chunk-
|
|
2
|
+
globalSingleton
|
|
3
|
+
} from "./chunk-7ZHH77QA.js";
|
|
4
4
|
import {
|
|
5
5
|
sanitizeUrl
|
|
6
6
|
} from "./chunk-L3GAGWCC.js";
|
|
7
7
|
import {
|
|
8
8
|
effect
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-23VT3KZB.js";
|
|
10
|
+
import {
|
|
11
|
+
dispose
|
|
12
|
+
} from "./chunk-5VGSK6D2.js";
|
|
10
13
|
import {
|
|
11
14
|
signal
|
|
12
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-IWFE4AHO.js";
|
|
13
16
|
import {
|
|
14
17
|
devWarn,
|
|
15
18
|
isDev
|
|
@@ -23,12 +26,15 @@ var Priority = {
|
|
|
23
26
|
LOW: 3,
|
|
24
27
|
IDLE: 4
|
|
25
28
|
};
|
|
26
|
-
var
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
var _sched = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.scheduler.v1"), () => ({
|
|
30
|
+
taskIdCounter: 0,
|
|
31
|
+
taskQueue: [],
|
|
32
|
+
isProcessing: false,
|
|
33
|
+
scheduledKind: null,
|
|
34
|
+
scheduledHandle: null,
|
|
35
|
+
microtaskScheduled: false
|
|
36
|
+
}));
|
|
37
|
+
var taskQueue = _sched.taskQueue;
|
|
32
38
|
function insertTask(task) {
|
|
33
39
|
let i = taskQueue.length;
|
|
34
40
|
while (i > 0 && taskQueue[i - 1].priority > task.priority) {
|
|
@@ -37,8 +43,8 @@ function insertTask(task) {
|
|
|
37
43
|
taskQueue.splice(i, 0, task);
|
|
38
44
|
}
|
|
39
45
|
function processQueue() {
|
|
40
|
-
if (isProcessing || taskQueue.length === 0) return;
|
|
41
|
-
isProcessing = true;
|
|
46
|
+
if (_sched.isProcessing || taskQueue.length === 0) return;
|
|
47
|
+
_sched.isProcessing = true;
|
|
42
48
|
const startTime = performance.now();
|
|
43
49
|
const timeSlice = 5;
|
|
44
50
|
while (taskQueue.length > 0) {
|
|
@@ -57,64 +63,69 @@ function processQueue() {
|
|
|
57
63
|
console.error("[Scheduler] Task error:", e);
|
|
58
64
|
}
|
|
59
65
|
}
|
|
60
|
-
isProcessing = false;
|
|
66
|
+
_sched.isProcessing = false;
|
|
61
67
|
if (taskQueue.length > 0) {
|
|
62
68
|
scheduleFrame();
|
|
63
69
|
}
|
|
64
70
|
}
|
|
65
71
|
var TIER_SPEED = { microtask: 0, frame: 1, timeout: 2, idle: 3 };
|
|
66
72
|
function cancelScheduled() {
|
|
67
|
-
if (scheduledHandle !== null) {
|
|
68
|
-
if (scheduledKind === "frame") cancelAnimationFrame(scheduledHandle);
|
|
69
|
-
else if (scheduledKind === "idle" && typeof cancelIdleCallback !== "undefined")
|
|
70
|
-
|
|
73
|
+
if (_sched.scheduledHandle !== null) {
|
|
74
|
+
if (_sched.scheduledKind === "frame") cancelAnimationFrame(_sched.scheduledHandle);
|
|
75
|
+
else if (_sched.scheduledKind === "idle" && typeof cancelIdleCallback !== "undefined")
|
|
76
|
+
cancelIdleCallback(_sched.scheduledHandle);
|
|
77
|
+
else if (_sched.scheduledKind === "timeout") clearTimeout(_sched.scheduledHandle);
|
|
71
78
|
}
|
|
72
|
-
scheduledHandle = null;
|
|
73
|
-
scheduledKind = null;
|
|
79
|
+
_sched.scheduledHandle = null;
|
|
80
|
+
_sched.scheduledKind = null;
|
|
74
81
|
}
|
|
75
82
|
function scheduleFrame() {
|
|
76
83
|
const nextTask = taskQueue.find((t) => !t.cancelled);
|
|
77
84
|
if (!nextTask) return;
|
|
78
|
-
const desired = nextTask.priority <= Priority.USER_BLOCKING ? "microtask" : nextTask.priority === Priority.IDLE ? typeof requestIdleCallback !== "undefined" ? "idle" : "timeout" :
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
85
|
+
const desired = nextTask.priority <= Priority.USER_BLOCKING ? "microtask" : nextTask.priority === Priority.IDLE ? typeof requestIdleCallback !== "undefined" ? "idle" : "timeout" : (
|
|
86
|
+
// NORMAL/LOW prefer a frame, but rAF is absent under SSR — fall back
|
|
87
|
+
// to a timeout so startTransition()/deferredValue() don't throw.
|
|
88
|
+
typeof requestAnimationFrame !== "undefined" ? "frame" : "timeout"
|
|
89
|
+
);
|
|
90
|
+
if (_sched.microtaskScheduled) return;
|
|
91
|
+
if (_sched.scheduledKind !== null) {
|
|
92
|
+
if (TIER_SPEED[_sched.scheduledKind] <= TIER_SPEED[desired]) return;
|
|
82
93
|
cancelScheduled();
|
|
83
94
|
}
|
|
84
95
|
if (desired === "microtask") {
|
|
85
|
-
microtaskScheduled = true;
|
|
86
|
-
scheduledKind = "microtask";
|
|
96
|
+
_sched.microtaskScheduled = true;
|
|
97
|
+
_sched.scheduledKind = "microtask";
|
|
87
98
|
queueMicrotask(() => {
|
|
88
|
-
microtaskScheduled = false;
|
|
89
|
-
scheduledKind = null;
|
|
99
|
+
_sched.microtaskScheduled = false;
|
|
100
|
+
_sched.scheduledKind = null;
|
|
90
101
|
processQueue();
|
|
91
102
|
});
|
|
92
103
|
} else if (desired === "idle") {
|
|
93
|
-
scheduledKind = "idle";
|
|
94
|
-
scheduledHandle = requestIdleCallback(() => {
|
|
95
|
-
scheduledKind = null;
|
|
96
|
-
scheduledHandle = null;
|
|
104
|
+
_sched.scheduledKind = "idle";
|
|
105
|
+
_sched.scheduledHandle = requestIdleCallback(() => {
|
|
106
|
+
_sched.scheduledKind = null;
|
|
107
|
+
_sched.scheduledHandle = null;
|
|
97
108
|
processQueue();
|
|
98
109
|
});
|
|
99
110
|
} else if (desired === "timeout") {
|
|
100
|
-
scheduledKind = "timeout";
|
|
101
|
-
scheduledHandle = setTimeout(() => {
|
|
102
|
-
scheduledKind = null;
|
|
103
|
-
scheduledHandle = null;
|
|
111
|
+
_sched.scheduledKind = "timeout";
|
|
112
|
+
_sched.scheduledHandle = setTimeout(() => {
|
|
113
|
+
_sched.scheduledKind = null;
|
|
114
|
+
_sched.scheduledHandle = null;
|
|
104
115
|
processQueue();
|
|
105
116
|
}, 50);
|
|
106
117
|
} else {
|
|
107
|
-
scheduledKind = "frame";
|
|
108
|
-
scheduledHandle = requestAnimationFrame(() => {
|
|
109
|
-
scheduledKind = null;
|
|
110
|
-
scheduledHandle = null;
|
|
118
|
+
_sched.scheduledKind = "frame";
|
|
119
|
+
_sched.scheduledHandle = requestAnimationFrame(() => {
|
|
120
|
+
_sched.scheduledKind = null;
|
|
121
|
+
_sched.scheduledHandle = null;
|
|
111
122
|
processQueue();
|
|
112
123
|
});
|
|
113
124
|
}
|
|
114
125
|
}
|
|
115
126
|
function scheduleUpdate(priority, callback) {
|
|
116
127
|
const task = {
|
|
117
|
-
id: taskIdCounter++,
|
|
128
|
+
id: _sched.taskIdCounter++,
|
|
118
129
|
priority,
|
|
119
130
|
callback,
|
|
120
131
|
cancelled: false
|
|
@@ -135,15 +146,15 @@ function scheduleUpdate(priority, callback) {
|
|
|
135
146
|
};
|
|
136
147
|
}
|
|
137
148
|
function flushScheduler() {
|
|
138
|
-
if (scheduledHandle !== null) {
|
|
139
|
-
if (scheduledKind === "frame") cancelAnimationFrame(scheduledHandle);
|
|
140
|
-
else if (scheduledKind === "idle" && typeof cancelIdleCallback !== "undefined") {
|
|
141
|
-
cancelIdleCallback(scheduledHandle);
|
|
142
|
-
} else if (scheduledKind === "timeout") clearTimeout(scheduledHandle);
|
|
143
|
-
}
|
|
144
|
-
scheduledHandle = null;
|
|
145
|
-
scheduledKind = null;
|
|
146
|
-
microtaskScheduled = false;
|
|
149
|
+
if (_sched.scheduledHandle !== null) {
|
|
150
|
+
if (_sched.scheduledKind === "frame") cancelAnimationFrame(_sched.scheduledHandle);
|
|
151
|
+
else if (_sched.scheduledKind === "idle" && typeof cancelIdleCallback !== "undefined") {
|
|
152
|
+
cancelIdleCallback(_sched.scheduledHandle);
|
|
153
|
+
} else if (_sched.scheduledKind === "timeout") clearTimeout(_sched.scheduledHandle);
|
|
154
|
+
}
|
|
155
|
+
_sched.scheduledHandle = null;
|
|
156
|
+
_sched.scheduledKind = null;
|
|
157
|
+
_sched.microtaskScheduled = false;
|
|
147
158
|
while (taskQueue.length > 0) {
|
|
148
159
|
const task = taskQueue.shift();
|
|
149
160
|
if (!task) break;
|
|
@@ -151,7 +162,7 @@ function flushScheduler() {
|
|
|
151
162
|
task.callback();
|
|
152
163
|
}
|
|
153
164
|
}
|
|
154
|
-
isProcessing = false;
|
|
165
|
+
_sched.isProcessing = false;
|
|
155
166
|
}
|
|
156
167
|
function pendingTasks() {
|
|
157
168
|
return taskQueue.filter((t) => !t.cancelled).length;
|
|
@@ -199,16 +210,18 @@ function transitionState() {
|
|
|
199
210
|
}
|
|
200
211
|
return [isPending, transition];
|
|
201
212
|
}
|
|
202
|
-
var
|
|
203
|
-
|
|
213
|
+
var _ids = globalSingleton(/* @__PURE__ */ Symbol.for("sibujs.uniqueId.v1"), () => ({
|
|
214
|
+
counter: 0,
|
|
215
|
+
prefix: "sibu"
|
|
216
|
+
}));
|
|
204
217
|
function resetIdCounter() {
|
|
205
|
-
|
|
218
|
+
_ids.counter = 0;
|
|
206
219
|
}
|
|
207
220
|
function setIdPrefix(prefix) {
|
|
208
|
-
|
|
221
|
+
_ids.prefix = prefix;
|
|
209
222
|
}
|
|
210
223
|
function uniqueId(suffix) {
|
|
211
|
-
const id = `${
|
|
224
|
+
const id = `${_ids.prefix}-${_ids.counter++}`;
|
|
212
225
|
return suffix ? `${id}-${suffix}` : id;
|
|
213
226
|
}
|
|
214
227
|
|
|
@@ -446,7 +459,6 @@ function normalizedStore(schema) {
|
|
|
446
459
|
}
|
|
447
460
|
function normalize(data, schema) {
|
|
448
461
|
const entities = {};
|
|
449
|
-
const idKey = schema.idKey || "id";
|
|
450
462
|
function ensureTable(name) {
|
|
451
463
|
if (!entities[name]) {
|
|
452
464
|
entities[name] = {};
|
|
@@ -462,7 +474,7 @@ function normalize(data, schema) {
|
|
|
462
474
|
for (const [field, relationType] of Object.entries(entitySchema.relations)) {
|
|
463
475
|
const value = entity[field];
|
|
464
476
|
if (value == null) continue;
|
|
465
|
-
const relSchema = { name: relationType
|
|
477
|
+
const relSchema = { name: relationType };
|
|
466
478
|
if (Array.isArray(value)) {
|
|
467
479
|
flat[field] = value.map((item) => normalizeEntity(item, relSchema));
|
|
468
480
|
} else if (typeof value === "object") {
|
|
@@ -485,13 +497,12 @@ function denormalize(id, entities, schema) {
|
|
|
485
497
|
if (!table) return void 0;
|
|
486
498
|
const entity = table[id];
|
|
487
499
|
if (!entity) return void 0;
|
|
488
|
-
const idKey = schema.idKey || "id";
|
|
489
500
|
const result = { ...entity };
|
|
490
501
|
if (schema.relations) {
|
|
491
502
|
for (const [field, relationType] of Object.entries(schema.relations)) {
|
|
492
503
|
const value = entity[field];
|
|
493
504
|
if (value == null) continue;
|
|
494
|
-
const relSchema = { name: relationType
|
|
505
|
+
const relSchema = { name: relationType };
|
|
495
506
|
if (Array.isArray(value)) {
|
|
496
507
|
result[field] = value.map((relId) => denormalize(relId, entities, relSchema));
|
|
497
508
|
} else if (typeof value === "string") {
|