sibujs 1.0.0-beta.1
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/LICENSE +21 -0
- package/README.md +1630 -0
- package/dist/browser.cjs +815 -0
- package/dist/browser.d.cts +174 -0
- package/dist/browser.d.ts +174 -0
- package/dist/browser.js +458 -0
- package/dist/build.cjs +4970 -0
- package/dist/build.d.cts +630 -0
- package/dist/build.d.ts +630 -0
- package/dist/build.js +2478 -0
- package/dist/cdn.global.js +115 -0
- package/dist/chunk-27QC4FPL.js +67 -0
- package/dist/chunk-2ABBWCGC.js +65 -0
- package/dist/chunk-2MUNQYZ7.js +26 -0
- package/dist/chunk-2PSPKNUI.js +1711 -0
- package/dist/chunk-35CDLDX5.js +1758 -0
- package/dist/chunk-36MU4CFV.js +41 -0
- package/dist/chunk-3FIQOFI6.js +182 -0
- package/dist/chunk-3GHNC2BN.js +28 -0
- package/dist/chunk-3HLWWEPU.js +909 -0
- package/dist/chunk-3IVI3J54.js +252 -0
- package/dist/chunk-3KZ72WNW.js +944 -0
- package/dist/chunk-4AU64SQV.js +182 -0
- package/dist/chunk-4MOK7HAR.js +84 -0
- package/dist/chunk-4QK6FBDH.js +1429 -0
- package/dist/chunk-566Z7HXB.js +737 -0
- package/dist/chunk-5CRBB7XP.js +358 -0
- package/dist/chunk-5G67D3IZ.js +168 -0
- package/dist/chunk-5NCPAWBE.js +99 -0
- package/dist/chunk-5O2RKXR3.js +1444 -0
- package/dist/chunk-6BTBDO6A.js +633 -0
- package/dist/chunk-6IWEHW57.js +43 -0
- package/dist/chunk-6JGMNCD6.js +282 -0
- package/dist/chunk-6QRLJNXR.js +1425 -0
- package/dist/chunk-7HM5UE5T.js +270 -0
- package/dist/chunk-7JOLTGUH.js +58 -0
- package/dist/chunk-7MCWJCQK.js +909 -0
- package/dist/chunk-7RIIFP3E.js +1758 -0
- package/dist/chunk-7UASYN3G.js +254 -0
- package/dist/chunk-7W2WYHDI.js +741 -0
- package/dist/chunk-7Y35RDSJ.js +872 -0
- package/dist/chunk-A65GFJBL.js +65 -0
- package/dist/chunk-AD6ZIEDK.js +67 -0
- package/dist/chunk-AK5Y72F3.js +1426 -0
- package/dist/chunk-APOMMWH4.js +282 -0
- package/dist/chunk-ARZVTWIQ.js +1750 -0
- package/dist/chunk-AWWBM2BI.js +664 -0
- package/dist/chunk-AX5VEQTY.js +58 -0
- package/dist/chunk-AYTXVOW3.js +1708 -0
- package/dist/chunk-BG4A246G.js +1746 -0
- package/dist/chunk-BNFJJA2L.js +1425 -0
- package/dist/chunk-BPKPBVU5.js +59 -0
- package/dist/chunk-BPKPPSXC.js +282 -0
- package/dist/chunk-BPWKKK7F.js +1711 -0
- package/dist/chunk-CCKX6YTC.js +1735 -0
- package/dist/chunk-CIF5Z3MP.js +58 -0
- package/dist/chunk-CSXYU7IO.js +457 -0
- package/dist/chunk-D6JD4FDC.js +26 -0
- package/dist/chunk-E7NGA7X2.js +59 -0
- package/dist/chunk-EEPPJKAE.js +443 -0
- package/dist/chunk-EJMYGAGQ.js +717 -0
- package/dist/chunk-EL6Z5MDY.js +55 -0
- package/dist/chunk-EP7VRLEB.js +41 -0
- package/dist/chunk-ETMEC6FH.js +99 -0
- package/dist/chunk-EZ2WHYVL.js +65 -0
- package/dist/chunk-EZRVMSZK.js +67 -0
- package/dist/chunk-F2TRGINX.js +254 -0
- package/dist/chunk-F5JCIH3Q.js +642 -0
- package/dist/chunk-FGK3JKMN.js +909 -0
- package/dist/chunk-FQWPKSTD.js +1437 -0
- package/dist/chunk-FWHVLMCI.js +26 -0
- package/dist/chunk-GBEYQRO2.js +303 -0
- package/dist/chunk-GBLES3NK.js +248 -0
- package/dist/chunk-GQVGUQW6.js +1436 -0
- package/dist/chunk-HCV2T76T.js +457 -0
- package/dist/chunk-HS7ZKVPR.js +182 -0
- package/dist/chunk-HXDVV7HZ.js +909 -0
- package/dist/chunk-IB23VMO3.js +1746 -0
- package/dist/chunk-IEMZ7RTT.js +99 -0
- package/dist/chunk-IPGRSN42.js +1750 -0
- package/dist/chunk-IVMOK2QN.js +1750 -0
- package/dist/chunk-JCLGQO7T.js +443 -0
- package/dist/chunk-JDXL7KDB.js +1436 -0
- package/dist/chunk-JIIFW636.js +270 -0
- package/dist/chunk-JWGEEH7H.js +944 -0
- package/dist/chunk-K2BESAG7.js +1688 -0
- package/dist/chunk-K2U5YGF4.js +877 -0
- package/dist/chunk-K45FQ4Y4.js +175 -0
- package/dist/chunk-K7BPE427.js +1432 -0
- package/dist/chunk-KL3266RS.js +26 -0
- package/dist/chunk-KNN4P7DZ.js +84 -0
- package/dist/chunk-KP2DZH5Q.js +254 -0
- package/dist/chunk-KZHAJSQR.js +1636 -0
- package/dist/chunk-LBKGHMQV.js +1750 -0
- package/dist/chunk-LBTEPL7A.js +1731 -0
- package/dist/chunk-LEBBPTDB.js +1444 -0
- package/dist/chunk-LLH63WVQ.js +98 -0
- package/dist/chunk-LWVR2C4G.js +1711 -0
- package/dist/chunk-M3MDTVV2.js +896 -0
- package/dist/chunk-M5GNLDEO.js +303 -0
- package/dist/chunk-MFHVGKET.js +267 -0
- package/dist/chunk-MGWSG3PM.js +358 -0
- package/dist/chunk-MJNB47HB.js +19 -0
- package/dist/chunk-MLKGABMK.js +9 -0
- package/dist/chunk-MQWTY3JY.js +944 -0
- package/dist/chunk-MZZOQHNI.js +642 -0
- package/dist/chunk-NIHWGZS4.js +1426 -0
- package/dist/chunk-NSVVHQK5.js +41 -0
- package/dist/chunk-NVI2WE7D.js +443 -0
- package/dist/chunk-O7QBO3PH.js +58 -0
- package/dist/chunk-OAUPQBO2.js +270 -0
- package/dist/chunk-OB2LMD7C.js +297 -0
- package/dist/chunk-OHEYBWQU.js +58 -0
- package/dist/chunk-OI6OXUHJ.js +443 -0
- package/dist/chunk-OX2VMRMV.js +633 -0
- package/dist/chunk-P4FYE5TX.js +866 -0
- package/dist/chunk-P5KFWM4H.js +98 -0
- package/dist/chunk-PUMLE7RJ.js +1711 -0
- package/dist/chunk-Q4MFANBF.js +282 -0
- package/dist/chunk-QLEKZMMU.js +282 -0
- package/dist/chunk-RGGNGVO3.js +98 -0
- package/dist/chunk-RKJDRVV6.js +443 -0
- package/dist/chunk-S5BHU353.js +43 -0
- package/dist/chunk-SHQUSFH7.js +1426 -0
- package/dist/chunk-SMB4DBMD.js +182 -0
- package/dist/chunk-SNYHQP3D.js +743 -0
- package/dist/chunk-T24L3TBF.js +1717 -0
- package/dist/chunk-TAQNSOKT.js +692 -0
- package/dist/chunk-TDNY4SUA.js +41 -0
- package/dist/chunk-TNNF56IQ.js +1750 -0
- package/dist/chunk-TR7E6LYX.js +457 -0
- package/dist/chunk-URWUFH45.js +98 -0
- package/dist/chunk-UUSIH3XH.js +1429 -0
- package/dist/chunk-UYFNXLKR.js +1436 -0
- package/dist/chunk-V6F7KUWD.js +270 -0
- package/dist/chunk-VCZLXRMR.js +254 -0
- package/dist/chunk-VDHXSSBT.js +1426 -0
- package/dist/chunk-VM4QMKVK.js +254 -0
- package/dist/chunk-VWGYKYL2.js +737 -0
- package/dist/chunk-VX2OFBJN.js +1426 -0
- package/dist/chunk-VXVIE6DG.js +84 -0
- package/dist/chunk-W4OH7HG4.js +40 -0
- package/dist/chunk-WBVJX4GZ.js +98 -0
- package/dist/chunk-WDU2ZV4I.js +1426 -0
- package/dist/chunk-X6VUCICU.js +457 -0
- package/dist/chunk-XAY7FM7Y.js +618 -0
- package/dist/chunk-XJZ5Z2CM.js +642 -0
- package/dist/chunk-XKVFQTJJ.js +254 -0
- package/dist/chunk-XRLFASCY.js +22 -0
- package/dist/chunk-XYU6TZOW.js +182 -0
- package/dist/chunk-Y745CBVB.js +944 -0
- package/dist/chunk-YLBJSXYY.js +944 -0
- package/dist/chunk-YQJIKVPZ.js +1429 -0
- package/dist/chunk-YRM2VCZF.js +457 -0
- package/dist/chunk-YS33KBVJ.js +944 -0
- package/dist/chunk-Z27DZPDG.js +41 -0
- package/dist/chunk-ZXQ5NAEN.js +32 -0
- package/dist/contracts-B552GopR.d.cts +245 -0
- package/dist/contracts-B552GopR.d.ts +245 -0
- package/dist/contracts-Bg1ECISC.d.cts +245 -0
- package/dist/contracts-Bg1ECISC.d.ts +245 -0
- package/dist/contracts-CMriKJ6P.d.cts +245 -0
- package/dist/contracts-CMriKJ6P.d.ts +245 -0
- package/dist/contracts-DOrhwbke.d.cts +245 -0
- package/dist/contracts-DOrhwbke.d.ts +245 -0
- package/dist/data.cjs +1373 -0
- package/dist/data.d.cts +434 -0
- package/dist/data.d.ts +434 -0
- package/dist/data.js +945 -0
- package/dist/devtools.cjs +1357 -0
- package/dist/devtools.d.cts +473 -0
- package/dist/devtools.d.ts +473 -0
- package/dist/devtools.js +1084 -0
- package/dist/ecosystem.cjs +1046 -0
- package/dist/ecosystem.d.cts +247 -0
- package/dist/ecosystem.d.ts +247 -0
- package/dist/ecosystem.js +369 -0
- package/dist/extras.cjs +8457 -0
- package/dist/extras.d.cts +2356 -0
- package/dist/extras.d.ts +2356 -0
- package/dist/extras.js +5152 -0
- package/dist/index.cjs +2648 -0
- package/dist/index.d.cts +869 -0
- package/dist/index.d.ts +869 -0
- package/dist/index.js +386 -0
- package/dist/motion.cjs +604 -0
- package/dist/motion.d.cts +146 -0
- package/dist/motion.d.ts +146 -0
- package/dist/motion.js +346 -0
- package/dist/patterns.cjs +815 -0
- package/dist/patterns.d.cts +163 -0
- package/dist/patterns.d.ts +163 -0
- package/dist/patterns.js +296 -0
- package/dist/performance.cjs +927 -0
- package/dist/performance.d.cts +416 -0
- package/dist/performance.d.ts +416 -0
- package/dist/performance.js +654 -0
- package/dist/plugins.cjs +2487 -0
- package/dist/plugins.d.cts +393 -0
- package/dist/plugins.d.ts +393 -0
- package/dist/plugins.js +1504 -0
- package/dist/signal-BnWpq6WB.d.cts +5 -0
- package/dist/signal-BnWpq6WB.d.ts +5 -0
- package/dist/src/components/ErrorBoundary.d.ts +15 -0
- package/dist/src/components/ErrorBoundary.js +119 -0
- package/dist/src/core/catch.d.ts +11 -0
- package/dist/src/core/catch.js +28 -0
- package/dist/src/core/each.d.ts +13 -0
- package/dist/src/core/each.js +68 -0
- package/dist/src/core/for.d.ts +12 -0
- package/dist/src/core/for.js +67 -0
- package/dist/src/core/html.d.ts +137 -0
- package/dist/src/core/html.js +155 -0
- package/dist/src/core/htmlIf.d.ts +11 -0
- package/dist/src/core/htmlIf.js +18 -0
- package/dist/src/core/lazy.d.ts +7 -0
- package/dist/src/core/lazy.js +16 -0
- package/dist/src/core/mount.d.ts +7 -0
- package/dist/src/core/mount.js +12 -0
- package/dist/src/core/slots.d.ts +3 -0
- package/dist/src/core/slots.js +3 -0
- package/dist/src/core/suspense.d.ts +10 -0
- package/dist/src/core/suspense.js +33 -0
- package/dist/src/core/tagFactory.d.ts +13 -0
- package/dist/src/core/tagFactory.js +86 -0
- package/dist/src/core/test.d.ts +11 -0
- package/dist/src/core/test.js +28 -0
- package/dist/src/core/types.d.ts +2 -0
- package/dist/src/core/types.js +1 -0
- package/dist/src/core/useComputed.d.ts +6 -0
- package/dist/src/core/useComputed.js +30 -0
- package/dist/src/core/useEffect.d.ts +6 -0
- package/dist/src/core/useEffect.js +23 -0
- package/dist/src/core/useState.d.ts +10 -0
- package/dist/src/core/useState.js +34 -0
- package/dist/src/core/useStore.d.ts +19 -0
- package/dist/src/core/useStore.js +53 -0
- package/dist/src/core/useWatch.d.ts +8 -0
- package/dist/src/core/useWatch.js +23 -0
- package/dist/src/plugins/i18n.d.ts +6 -0
- package/dist/src/plugins/i18n.js +16 -0
- package/dist/src/plugins/router.d.ts +188 -0
- package/dist/src/plugins/router.js +1178 -0
- package/dist/src/reactivity/bindAttribute.d.ts +5 -0
- package/dist/src/reactivity/bindAttribute.js +31 -0
- package/dist/src/reactivity/bindChildNode.d.ts +10 -0
- package/dist/src/reactivity/bindChildNode.js +46 -0
- package/dist/src/reactivity/bindTextNode.d.ts +10 -0
- package/dist/src/reactivity/bindTextNode.js +27 -0
- package/dist/src/reactivity/signal.d.ts +3 -0
- package/dist/src/reactivity/signal.js +1 -0
- package/dist/src/reactivity/track.d.ts +18 -0
- package/dist/src/reactivity/track.js +73 -0
- package/dist/src/reactivity/useComputed.d.ts +6 -0
- package/dist/src/reactivity/useComputed.js +30 -0
- package/dist/src/reactivity/useEffect.d.ts +6 -0
- package/dist/src/reactivity/useEffect.js +23 -0
- package/dist/src/reactivity/useState.d.ts +10 -0
- package/dist/src/reactivity/useState.js +34 -0
- package/dist/src/reactivity/useStore.d.ts +19 -0
- package/dist/src/reactivity/useStore.js +53 -0
- package/dist/src/reactivity/useWatch.d.ts +8 -0
- package/dist/src/reactivity/useWatch.js +23 -0
- package/dist/src/utils/sanitize.d.ts +1 -0
- package/dist/src/utils/sanitize.js +8 -0
- package/dist/ssr-27FOM46T.js +35 -0
- package/dist/ssr-GFUTTSJD.js +22 -0
- package/dist/ssr-K7DCR6BZ.js +35 -0
- package/dist/ssr-O6LFMRFP.js +35 -0
- package/dist/ssr-QZEVGMMK.js +35 -0
- package/dist/ssr-SGVBCAGC.js +35 -0
- package/dist/ssr-UB2IXCYX.js +35 -0
- package/dist/ssr-XBZQNV4O.js +22 -0
- package/dist/ssr-Y76FSXDU.js +35 -0
- package/dist/ssr-YQJ4AYBD.js +35 -0
- package/dist/ssr.cjs +1757 -0
- package/dist/ssr.d.cts +478 -0
- package/dist/ssr.d.ts +478 -0
- package/dist/ssr.js +743 -0
- package/dist/tagFactory-CZPO4RXF.d.cts +34 -0
- package/dist/tagFactory-CZPO4RXF.d.ts +34 -0
- package/dist/tagFactory-CgImPVMY.d.cts +22 -0
- package/dist/tagFactory-CgImPVMY.d.ts +22 -0
- package/dist/tagFactory-Cw1iv5if.d.cts +22 -0
- package/dist/tagFactory-Cw1iv5if.d.ts +22 -0
- package/dist/tagFactory-DeAXq9ef.d.cts +30 -0
- package/dist/tagFactory-DeAXq9ef.d.ts +30 -0
- package/dist/tagFactory-SkY0a7L1.d.cts +22 -0
- package/dist/tagFactory-SkY0a7L1.d.ts +22 -0
- package/dist/testing.cjs +1919 -0
- package/dist/testing.d.cts +491 -0
- package/dist/testing.d.ts +491 -0
- package/dist/testing.js +1862 -0
- package/dist/ui.cjs +1497 -0
- package/dist/ui.d.cts +264 -0
- package/dist/ui.d.ts +264 -0
- package/dist/ui.js +900 -0
- package/dist/widgets.cjs +919 -0
- package/dist/widgets.d.cts +165 -0
- package/dist/widgets.d.ts +165 -0
- package/dist/widgets.js +545 -0
- package/package.json +134 -0
|
@@ -0,0 +1,927 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// performance.ts
|
|
21
|
+
var performance_exports = {};
|
|
22
|
+
__export(performance_exports, {
|
|
23
|
+
DOMPool: () => DOMPool,
|
|
24
|
+
Features: () => Features,
|
|
25
|
+
Priority: () => Priority,
|
|
26
|
+
block: () => block,
|
|
27
|
+
cloneTemplate: () => cloneTemplate,
|
|
28
|
+
conditional: () => conditional,
|
|
29
|
+
createChunkRegistry: () => createChunkRegistry,
|
|
30
|
+
deferredValue: () => deferredValue,
|
|
31
|
+
denormalize: () => denormalize,
|
|
32
|
+
devOnly: () => devOnly,
|
|
33
|
+
domPool: () => domPool,
|
|
34
|
+
flushScheduler: () => flushScheduler,
|
|
35
|
+
hoistable: () => hoistable,
|
|
36
|
+
lazyChunk: () => lazyChunk,
|
|
37
|
+
noSideEffect: () => noSideEffect,
|
|
38
|
+
normalize: () => normalize,
|
|
39
|
+
normalizedStore: () => normalizedStore,
|
|
40
|
+
pendingTasks: () => pendingTasks,
|
|
41
|
+
precompile: () => precompile,
|
|
42
|
+
prefetch: () => prefetch,
|
|
43
|
+
preloadImage: () => preloadImage,
|
|
44
|
+
preloadModule: () => preloadModule,
|
|
45
|
+
preloadModules: () => preloadModules,
|
|
46
|
+
preloadResource: () => preloadResource,
|
|
47
|
+
processInChunks: () => processInChunks,
|
|
48
|
+
pure: () => pure,
|
|
49
|
+
resetIdCounter: () => resetIdCounter,
|
|
50
|
+
scheduleUpdate: () => scheduleUpdate,
|
|
51
|
+
setIdPrefix: () => setIdPrefix,
|
|
52
|
+
startTransition: () => startTransition,
|
|
53
|
+
staticTemplate: () => staticTemplate,
|
|
54
|
+
transitionState: () => transitionState,
|
|
55
|
+
uniqueId: () => uniqueId,
|
|
56
|
+
yieldToMain: () => yieldToMain
|
|
57
|
+
});
|
|
58
|
+
module.exports = __toCommonJS(performance_exports);
|
|
59
|
+
|
|
60
|
+
// src/performance/scheduler.ts
|
|
61
|
+
var Priority = {
|
|
62
|
+
IMMEDIATE: 0,
|
|
63
|
+
USER_BLOCKING: 1,
|
|
64
|
+
NORMAL: 2,
|
|
65
|
+
LOW: 3,
|
|
66
|
+
IDLE: 4
|
|
67
|
+
};
|
|
68
|
+
var taskIdCounter = 0;
|
|
69
|
+
var taskQueue = [];
|
|
70
|
+
var isProcessing = false;
|
|
71
|
+
var frameId = null;
|
|
72
|
+
function insertTask(task) {
|
|
73
|
+
let i = taskQueue.length;
|
|
74
|
+
while (i > 0 && taskQueue[i - 1].priority > task.priority) {
|
|
75
|
+
i--;
|
|
76
|
+
}
|
|
77
|
+
taskQueue.splice(i, 0, task);
|
|
78
|
+
}
|
|
79
|
+
function processQueue() {
|
|
80
|
+
if (isProcessing || taskQueue.length === 0) return;
|
|
81
|
+
isProcessing = true;
|
|
82
|
+
const startTime = performance.now();
|
|
83
|
+
const timeSlice = 5;
|
|
84
|
+
while (taskQueue.length > 0) {
|
|
85
|
+
const task = taskQueue[0];
|
|
86
|
+
if (task.cancelled) {
|
|
87
|
+
taskQueue.shift();
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (task.priority > Priority.IMMEDIATE && performance.now() - startTime > timeSlice) {
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
taskQueue.shift();
|
|
94
|
+
try {
|
|
95
|
+
task.callback();
|
|
96
|
+
} catch (e) {
|
|
97
|
+
console.error("[Scheduler] Task error:", e);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
isProcessing = false;
|
|
101
|
+
if (taskQueue.length > 0) {
|
|
102
|
+
scheduleFrame();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function scheduleFrame() {
|
|
106
|
+
if (frameId !== null) return;
|
|
107
|
+
const nextTask = taskQueue.find((t) => !t.cancelled);
|
|
108
|
+
if (!nextTask) return;
|
|
109
|
+
if (nextTask.priority <= Priority.USER_BLOCKING) {
|
|
110
|
+
queueMicrotask(() => {
|
|
111
|
+
frameId = null;
|
|
112
|
+
processQueue();
|
|
113
|
+
});
|
|
114
|
+
frameId = -1;
|
|
115
|
+
} else if (nextTask.priority === Priority.IDLE) {
|
|
116
|
+
if (typeof requestIdleCallback !== "undefined") {
|
|
117
|
+
frameId = requestIdleCallback(() => {
|
|
118
|
+
frameId = null;
|
|
119
|
+
processQueue();
|
|
120
|
+
});
|
|
121
|
+
} else {
|
|
122
|
+
frameId = setTimeout(() => {
|
|
123
|
+
frameId = null;
|
|
124
|
+
processQueue();
|
|
125
|
+
}, 50);
|
|
126
|
+
}
|
|
127
|
+
} else {
|
|
128
|
+
frameId = requestAnimationFrame(() => {
|
|
129
|
+
frameId = null;
|
|
130
|
+
processQueue();
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function scheduleUpdate(priority, callback) {
|
|
135
|
+
const task = {
|
|
136
|
+
id: taskIdCounter++,
|
|
137
|
+
priority,
|
|
138
|
+
callback,
|
|
139
|
+
cancelled: false
|
|
140
|
+
};
|
|
141
|
+
if (priority === Priority.IMMEDIATE) {
|
|
142
|
+
try {
|
|
143
|
+
callback();
|
|
144
|
+
} catch (e) {
|
|
145
|
+
console.error("[Scheduler] Immediate task error:", e);
|
|
146
|
+
}
|
|
147
|
+
return () => {
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
insertTask(task);
|
|
151
|
+
scheduleFrame();
|
|
152
|
+
return () => {
|
|
153
|
+
task.cancelled = true;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function flushScheduler() {
|
|
157
|
+
while (taskQueue.length > 0) {
|
|
158
|
+
const task = taskQueue.shift();
|
|
159
|
+
if (!task) break;
|
|
160
|
+
if (!task.cancelled) {
|
|
161
|
+
task.callback();
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
isProcessing = false;
|
|
165
|
+
frameId = null;
|
|
166
|
+
}
|
|
167
|
+
function pendingTasks() {
|
|
168
|
+
return taskQueue.filter((t) => !t.cancelled).length;
|
|
169
|
+
}
|
|
170
|
+
function yieldToMain() {
|
|
171
|
+
if (typeof globalThis !== "undefined" && "scheduler" in globalThis && typeof globalThis.scheduler?.yield === "function") {
|
|
172
|
+
return globalThis.scheduler.yield();
|
|
173
|
+
}
|
|
174
|
+
return new Promise((resolve) => {
|
|
175
|
+
setTimeout(resolve, 0);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
async function processInChunks(items, processor, chunkSize = 50) {
|
|
179
|
+
for (let i = 0; i < items.length; i++) {
|
|
180
|
+
processor(items[i], i);
|
|
181
|
+
if (i > 0 && i % chunkSize === 0) {
|
|
182
|
+
await yieldToMain();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// src/reactivity/track.ts
|
|
188
|
+
var subscriberStack = [];
|
|
189
|
+
var currentSubscriber = null;
|
|
190
|
+
var signalSubscribers = /* @__PURE__ */ new WeakMap();
|
|
191
|
+
var SUBS = "__s";
|
|
192
|
+
var notifyDepth = 0;
|
|
193
|
+
var pendingQueue = [];
|
|
194
|
+
var pendingSet = /* @__PURE__ */ new Set();
|
|
195
|
+
var suspendDepth = 0;
|
|
196
|
+
var trackingSuspended = false;
|
|
197
|
+
function suspendTracking() {
|
|
198
|
+
if (suspendDepth === 0) {
|
|
199
|
+
subscriberStack.push(null);
|
|
200
|
+
currentSubscriber = null;
|
|
201
|
+
trackingSuspended = true;
|
|
202
|
+
}
|
|
203
|
+
suspendDepth++;
|
|
204
|
+
}
|
|
205
|
+
function resumeTracking() {
|
|
206
|
+
suspendDepth--;
|
|
207
|
+
if (suspendDepth === 0) {
|
|
208
|
+
subscriberStack.pop();
|
|
209
|
+
currentSubscriber = subscriberStack[subscriberStack.length - 1] || null;
|
|
210
|
+
trackingSuspended = false;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function recordDependency(signal2) {
|
|
214
|
+
if (!currentSubscriber) return;
|
|
215
|
+
let deps = currentSubscriber._deps;
|
|
216
|
+
if (!deps) {
|
|
217
|
+
deps = /* @__PURE__ */ new Set();
|
|
218
|
+
currentSubscriber._deps = deps;
|
|
219
|
+
}
|
|
220
|
+
if (!deps.has(signal2)) {
|
|
221
|
+
deps.add(signal2);
|
|
222
|
+
let subs = signal2[SUBS];
|
|
223
|
+
if (!subs) {
|
|
224
|
+
subs = /* @__PURE__ */ new Set();
|
|
225
|
+
signalSubscribers.set(signal2, subs);
|
|
226
|
+
signal2[SUBS] = subs;
|
|
227
|
+
}
|
|
228
|
+
subs.add(currentSubscriber);
|
|
229
|
+
if (subs.size === 1) {
|
|
230
|
+
signal2.__f = currentSubscriber;
|
|
231
|
+
} else if (signal2.__f !== void 0) {
|
|
232
|
+
signal2.__f = void 0;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
function propagateDirty(sub) {
|
|
237
|
+
sub();
|
|
238
|
+
let sig = sub._sig;
|
|
239
|
+
let suspended = false;
|
|
240
|
+
if (sig && sig._g) {
|
|
241
|
+
const sDeps = sub._deps;
|
|
242
|
+
if (sDeps && sDeps.size === 1) {
|
|
243
|
+
suspendTracking();
|
|
244
|
+
suspended = true;
|
|
245
|
+
const s = sig;
|
|
246
|
+
s._d = false;
|
|
247
|
+
s._v = s._g();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
while (sig) {
|
|
251
|
+
const first = sig.__f;
|
|
252
|
+
if (first) {
|
|
253
|
+
if (first._c) {
|
|
254
|
+
const nSig = first._sig;
|
|
255
|
+
nSig._d = true;
|
|
256
|
+
if (suspended && nSig._g) {
|
|
257
|
+
const fDeps = first._deps;
|
|
258
|
+
if (fDeps && fDeps.size === 1) {
|
|
259
|
+
nSig._d = false;
|
|
260
|
+
nSig._v = nSig._g();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
sig = nSig;
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (!pendingSet.has(first)) {
|
|
267
|
+
pendingSet.add(first);
|
|
268
|
+
pendingQueue.push(first);
|
|
269
|
+
}
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
const subs = sig[SUBS];
|
|
273
|
+
if (!subs) break;
|
|
274
|
+
let nextSig;
|
|
275
|
+
for (const s of subs) {
|
|
276
|
+
if (s._c) {
|
|
277
|
+
s();
|
|
278
|
+
const nSig = s._sig;
|
|
279
|
+
if (nSig && !nextSig) {
|
|
280
|
+
nextSig = nSig;
|
|
281
|
+
} else if (nSig) {
|
|
282
|
+
propagateDirty(s);
|
|
283
|
+
}
|
|
284
|
+
} else if (!pendingSet.has(s)) {
|
|
285
|
+
pendingSet.add(s);
|
|
286
|
+
pendingQueue.push(s);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
sig = nextSig;
|
|
290
|
+
}
|
|
291
|
+
if (suspended) resumeTracking();
|
|
292
|
+
}
|
|
293
|
+
function notifySubscribers(signal2) {
|
|
294
|
+
const first = signal2.__f;
|
|
295
|
+
if (first) {
|
|
296
|
+
if (notifyDepth > 0) {
|
|
297
|
+
if (first._c) {
|
|
298
|
+
propagateDirty(first);
|
|
299
|
+
} else if (!pendingSet.has(first)) {
|
|
300
|
+
pendingSet.add(first);
|
|
301
|
+
pendingQueue.push(first);
|
|
302
|
+
}
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
notifyDepth++;
|
|
306
|
+
try {
|
|
307
|
+
if (first._c) {
|
|
308
|
+
propagateDirty(first);
|
|
309
|
+
} else {
|
|
310
|
+
first();
|
|
311
|
+
}
|
|
312
|
+
let i = 0;
|
|
313
|
+
while (i < pendingQueue.length) {
|
|
314
|
+
pendingQueue[i]();
|
|
315
|
+
i++;
|
|
316
|
+
}
|
|
317
|
+
} finally {
|
|
318
|
+
pendingQueue.length = 0;
|
|
319
|
+
pendingSet.clear();
|
|
320
|
+
notifyDepth--;
|
|
321
|
+
}
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
const subs = signal2[SUBS];
|
|
325
|
+
if (!subs || subs.size === 0) return;
|
|
326
|
+
if (notifyDepth > 0) {
|
|
327
|
+
for (const sub of subs) {
|
|
328
|
+
if (sub._c) {
|
|
329
|
+
propagateDirty(sub);
|
|
330
|
+
} else if (!pendingSet.has(sub)) {
|
|
331
|
+
pendingSet.add(sub);
|
|
332
|
+
pendingQueue.push(sub);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
notifyDepth++;
|
|
338
|
+
try {
|
|
339
|
+
let directCount = 0;
|
|
340
|
+
for (const sub of subs) {
|
|
341
|
+
pendingQueue[directCount++] = sub;
|
|
342
|
+
}
|
|
343
|
+
for (let i2 = 0; i2 < directCount; i2++) {
|
|
344
|
+
if (pendingQueue[i2]._c) {
|
|
345
|
+
propagateDirty(pendingQueue[i2]);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
for (let i2 = 0; i2 < directCount; i2++) {
|
|
349
|
+
if (!pendingQueue[i2]._c) {
|
|
350
|
+
if (!pendingSet.has(pendingQueue[i2])) {
|
|
351
|
+
pendingQueue[i2]();
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
let i = directCount;
|
|
356
|
+
while (i < pendingQueue.length) {
|
|
357
|
+
pendingQueue[i]();
|
|
358
|
+
i++;
|
|
359
|
+
}
|
|
360
|
+
} finally {
|
|
361
|
+
pendingQueue.length = 0;
|
|
362
|
+
pendingSet.clear();
|
|
363
|
+
notifyDepth--;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// src/reactivity/batch.ts
|
|
368
|
+
var batchDepth = 0;
|
|
369
|
+
var pendingSignals = /* @__PURE__ */ new Set();
|
|
370
|
+
function enqueueBatchedSignal(signal2) {
|
|
371
|
+
if (batchDepth === 0) return false;
|
|
372
|
+
pendingSignals.add(signal2);
|
|
373
|
+
return true;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// src/core/signals/signal.ts
|
|
377
|
+
function signal(initial, options) {
|
|
378
|
+
const state = { value: initial };
|
|
379
|
+
const debugName = options?.name;
|
|
380
|
+
if (debugName) {
|
|
381
|
+
state.__name = debugName;
|
|
382
|
+
}
|
|
383
|
+
function get() {
|
|
384
|
+
recordDependency(state);
|
|
385
|
+
return state.value;
|
|
386
|
+
}
|
|
387
|
+
get.__signal = state;
|
|
388
|
+
if (debugName) get.__name = debugName;
|
|
389
|
+
function set(next) {
|
|
390
|
+
const newValue = typeof next === "function" ? next(state.value) : next;
|
|
391
|
+
if (Object.is(newValue, state.value)) return;
|
|
392
|
+
const oldValue = state.value;
|
|
393
|
+
state.value = newValue;
|
|
394
|
+
const hook2 = globalThis.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
395
|
+
if (hook2) hook2.emit("signal:update", { signal: state, name: debugName, oldValue, newValue });
|
|
396
|
+
if (!enqueueBatchedSignal(state)) {
|
|
397
|
+
notifySubscribers(state);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
const hook = globalThis.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
401
|
+
if (hook) hook.emit("signal:create", { signal: state, name: debugName, getter: get, initial });
|
|
402
|
+
return [get, set];
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// src/performance/concurrent.ts
|
|
406
|
+
function startTransition(callback) {
|
|
407
|
+
scheduleUpdate(Priority.NORMAL, callback);
|
|
408
|
+
}
|
|
409
|
+
function deferredValue(getter) {
|
|
410
|
+
const [deferred, setDeferred] = signal(getter());
|
|
411
|
+
const sync = () => {
|
|
412
|
+
const current = getter();
|
|
413
|
+
setDeferred(current);
|
|
414
|
+
};
|
|
415
|
+
scheduleUpdate(Priority.LOW, sync);
|
|
416
|
+
return () => {
|
|
417
|
+
scheduleUpdate(Priority.LOW, sync);
|
|
418
|
+
return deferred();
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
function transitionState() {
|
|
422
|
+
const [isPending, setIsPending] = signal(false);
|
|
423
|
+
function transition(callback) {
|
|
424
|
+
setIsPending(true);
|
|
425
|
+
scheduleUpdate(Priority.NORMAL, () => {
|
|
426
|
+
callback();
|
|
427
|
+
scheduleUpdate(Priority.NORMAL, () => {
|
|
428
|
+
setIsPending(false);
|
|
429
|
+
});
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
return [isPending, transition];
|
|
433
|
+
}
|
|
434
|
+
var idCounter = 0;
|
|
435
|
+
var idPrefix = "sibu";
|
|
436
|
+
function resetIdCounter() {
|
|
437
|
+
idCounter = 0;
|
|
438
|
+
}
|
|
439
|
+
function setIdPrefix(prefix) {
|
|
440
|
+
idPrefix = prefix;
|
|
441
|
+
}
|
|
442
|
+
function uniqueId(suffix) {
|
|
443
|
+
const id = `${idPrefix}-${idCounter++}`;
|
|
444
|
+
return suffix ? `${id}-${suffix}` : id;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// src/performance/domRecycler.ts
|
|
448
|
+
var DOMPool = class {
|
|
449
|
+
constructor(maxSize = 50) {
|
|
450
|
+
this.pools = /* @__PURE__ */ new Map();
|
|
451
|
+
this.maxSize = maxSize;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Get a recycled element or create a new one.
|
|
455
|
+
*/
|
|
456
|
+
acquire(tag) {
|
|
457
|
+
const pool = this.pools.get(tag);
|
|
458
|
+
if (pool && pool.length > 0) {
|
|
459
|
+
const el = pool.pop();
|
|
460
|
+
return el;
|
|
461
|
+
}
|
|
462
|
+
return document.createElement(tag);
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Return an element to the pool for reuse.
|
|
466
|
+
* Clears attributes, children, and event listeners.
|
|
467
|
+
*/
|
|
468
|
+
release(element) {
|
|
469
|
+
const tag = element.tagName.toLowerCase();
|
|
470
|
+
let pool = this.pools.get(tag);
|
|
471
|
+
if (!pool) {
|
|
472
|
+
pool = [];
|
|
473
|
+
this.pools.set(tag, pool);
|
|
474
|
+
}
|
|
475
|
+
if (pool.length >= this.maxSize) return;
|
|
476
|
+
element.innerHTML = "";
|
|
477
|
+
element.className = "";
|
|
478
|
+
element.removeAttribute("style");
|
|
479
|
+
element.removeAttribute("id");
|
|
480
|
+
const attrs = Array.from(element.attributes);
|
|
481
|
+
for (const attr of attrs) {
|
|
482
|
+
element.removeAttribute(attr.name);
|
|
483
|
+
}
|
|
484
|
+
const clean = element.cloneNode(false);
|
|
485
|
+
pool.push(clean);
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Clear all pools.
|
|
489
|
+
*/
|
|
490
|
+
clear() {
|
|
491
|
+
this.pools.clear();
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Get pool statistics.
|
|
495
|
+
*/
|
|
496
|
+
stats() {
|
|
497
|
+
const result = {};
|
|
498
|
+
for (const [tag, pool] of this.pools) {
|
|
499
|
+
result[tag] = pool.length;
|
|
500
|
+
}
|
|
501
|
+
return result;
|
|
502
|
+
}
|
|
503
|
+
};
|
|
504
|
+
var domPool = new DOMPool();
|
|
505
|
+
var preloadedResources = /* @__PURE__ */ new Set();
|
|
506
|
+
function preloadResource(url, type = "fetch") {
|
|
507
|
+
if (preloadedResources.has(url)) return;
|
|
508
|
+
preloadedResources.add(url);
|
|
509
|
+
const link = document.createElement("link");
|
|
510
|
+
link.rel = "preload";
|
|
511
|
+
link.href = url;
|
|
512
|
+
switch (type) {
|
|
513
|
+
case "script":
|
|
514
|
+
link.setAttribute("as", "script");
|
|
515
|
+
break;
|
|
516
|
+
case "style":
|
|
517
|
+
link.setAttribute("as", "style");
|
|
518
|
+
break;
|
|
519
|
+
case "image":
|
|
520
|
+
link.setAttribute("as", "image");
|
|
521
|
+
break;
|
|
522
|
+
default:
|
|
523
|
+
link.setAttribute("as", "fetch");
|
|
524
|
+
link.setAttribute("crossorigin", "anonymous");
|
|
525
|
+
}
|
|
526
|
+
document.head.appendChild(link);
|
|
527
|
+
}
|
|
528
|
+
function prefetch(url) {
|
|
529
|
+
if (preloadedResources.has(url)) return;
|
|
530
|
+
preloadedResources.add(url);
|
|
531
|
+
const link = document.createElement("link");
|
|
532
|
+
link.rel = "prefetch";
|
|
533
|
+
link.href = url;
|
|
534
|
+
document.head.appendChild(link);
|
|
535
|
+
}
|
|
536
|
+
function preloadImage(src) {
|
|
537
|
+
return new Promise((resolve, reject) => {
|
|
538
|
+
const img = new Image();
|
|
539
|
+
img.onload = () => resolve(img);
|
|
540
|
+
img.onerror = reject;
|
|
541
|
+
img.src = src;
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// src/performance/bundleOptimize.ts
|
|
546
|
+
function pure(fn) {
|
|
547
|
+
return fn();
|
|
548
|
+
}
|
|
549
|
+
function conditional(condition, loader) {
|
|
550
|
+
if (condition) return loader();
|
|
551
|
+
return void 0;
|
|
552
|
+
}
|
|
553
|
+
var Features = {
|
|
554
|
+
SSR: typeof window === "undefined",
|
|
555
|
+
DEV: typeof process !== "undefined" && process.env?.NODE_ENV !== "production",
|
|
556
|
+
BROWSER: typeof window !== "undefined"
|
|
557
|
+
};
|
|
558
|
+
function devOnly(fn) {
|
|
559
|
+
if (typeof process !== "undefined" && process.env?.NODE_ENV !== "production") {
|
|
560
|
+
fn();
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
function noSideEffect(fn) {
|
|
564
|
+
return fn;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// src/performance/compiled.ts
|
|
568
|
+
function staticTemplate(html) {
|
|
569
|
+
const template = document.createElement("template");
|
|
570
|
+
template.innerHTML = html.trim();
|
|
571
|
+
return template.content.firstElementChild;
|
|
572
|
+
}
|
|
573
|
+
function cloneTemplate(template) {
|
|
574
|
+
return template.content.cloneNode(true);
|
|
575
|
+
}
|
|
576
|
+
function precompile(templateHtml, hydrate) {
|
|
577
|
+
const tpl = document.createElement("template");
|
|
578
|
+
tpl.innerHTML = templateHtml.trim();
|
|
579
|
+
return (props) => {
|
|
580
|
+
const el = tpl.content.firstElementChild?.cloneNode(true);
|
|
581
|
+
hydrate(el, props);
|
|
582
|
+
return el;
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
function hoistable(value) {
|
|
586
|
+
return value;
|
|
587
|
+
}
|
|
588
|
+
function block(factory) {
|
|
589
|
+
return factory();
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// src/performance/normalize.ts
|
|
593
|
+
function normalizedStore(schema) {
|
|
594
|
+
const idKey = schema.idKey || "id";
|
|
595
|
+
const [getState, setState] = signal({
|
|
596
|
+
ids: [],
|
|
597
|
+
entities: {}
|
|
598
|
+
});
|
|
599
|
+
function add(entity) {
|
|
600
|
+
const id = String(entity[idKey]);
|
|
601
|
+
setState((prev) => {
|
|
602
|
+
const ids = prev.ids.includes(id) ? prev.ids : [...prev.ids, id];
|
|
603
|
+
return {
|
|
604
|
+
ids,
|
|
605
|
+
entities: { ...prev.entities, [id]: entity }
|
|
606
|
+
};
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
function addMany(entities) {
|
|
610
|
+
setState((prev) => {
|
|
611
|
+
const nextIds = [...prev.ids];
|
|
612
|
+
const nextEntities = { ...prev.entities };
|
|
613
|
+
for (const entity of entities) {
|
|
614
|
+
const id = String(entity[idKey]);
|
|
615
|
+
if (!nextIds.includes(id)) {
|
|
616
|
+
nextIds.push(id);
|
|
617
|
+
}
|
|
618
|
+
nextEntities[id] = entity;
|
|
619
|
+
}
|
|
620
|
+
return { ids: nextIds, entities: nextEntities };
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
function get(id) {
|
|
624
|
+
const state = getState();
|
|
625
|
+
return state.entities[id];
|
|
626
|
+
}
|
|
627
|
+
function getAll() {
|
|
628
|
+
const state = getState();
|
|
629
|
+
return state.ids.map((id) => state.entities[id]);
|
|
630
|
+
}
|
|
631
|
+
function update(id, partial) {
|
|
632
|
+
setState((prev) => {
|
|
633
|
+
const existing = prev.entities[id];
|
|
634
|
+
if (!existing) return prev;
|
|
635
|
+
return {
|
|
636
|
+
ids: prev.ids,
|
|
637
|
+
entities: {
|
|
638
|
+
...prev.entities,
|
|
639
|
+
[id]: { ...existing, ...partial }
|
|
640
|
+
}
|
|
641
|
+
};
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
function remove(id) {
|
|
645
|
+
setState((prev) => {
|
|
646
|
+
if (!prev.entities[id]) return prev;
|
|
647
|
+
const { [id]: _, ...remainingEntities } = prev.entities;
|
|
648
|
+
return {
|
|
649
|
+
ids: prev.ids.filter((existingId) => existingId !== id),
|
|
650
|
+
entities: remainingEntities
|
|
651
|
+
};
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
function select(predicate) {
|
|
655
|
+
const state = getState();
|
|
656
|
+
return state.ids.map((id) => state.entities[id]).filter(predicate);
|
|
657
|
+
}
|
|
658
|
+
return { add, addMany, get, getAll, update, remove, select, getState };
|
|
659
|
+
}
|
|
660
|
+
function normalize(data, schema) {
|
|
661
|
+
const entities = {};
|
|
662
|
+
const idKey = schema.idKey || "id";
|
|
663
|
+
function ensureTable(name) {
|
|
664
|
+
if (!entities[name]) {
|
|
665
|
+
entities[name] = {};
|
|
666
|
+
}
|
|
667
|
+
return entities[name];
|
|
668
|
+
}
|
|
669
|
+
function normalizeEntity(entity, entitySchema) {
|
|
670
|
+
const entityIdKey = entitySchema.idKey || "id";
|
|
671
|
+
const id = String(entity[entityIdKey]);
|
|
672
|
+
const table = ensureTable(entitySchema.name);
|
|
673
|
+
const flat = { ...entity };
|
|
674
|
+
if (entitySchema.relations) {
|
|
675
|
+
for (const [field, relationType] of Object.entries(entitySchema.relations)) {
|
|
676
|
+
const value = entity[field];
|
|
677
|
+
if (value == null) continue;
|
|
678
|
+
const relSchema = { name: relationType, idKey };
|
|
679
|
+
if (Array.isArray(value)) {
|
|
680
|
+
flat[field] = value.map((item) => normalizeEntity(item, relSchema));
|
|
681
|
+
} else if (typeof value === "object") {
|
|
682
|
+
flat[field] = normalizeEntity(value, relSchema);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
table[id] = flat;
|
|
687
|
+
return id;
|
|
688
|
+
}
|
|
689
|
+
if (Array.isArray(data)) {
|
|
690
|
+
const result2 = data.map((item) => normalizeEntity(item, schema));
|
|
691
|
+
return { result: result2, entities };
|
|
692
|
+
}
|
|
693
|
+
const result = normalizeEntity(data, schema);
|
|
694
|
+
return { result, entities };
|
|
695
|
+
}
|
|
696
|
+
function denormalize(id, entities, schema) {
|
|
697
|
+
const table = entities[schema.name];
|
|
698
|
+
if (!table) return void 0;
|
|
699
|
+
const entity = table[id];
|
|
700
|
+
if (!entity) return void 0;
|
|
701
|
+
const idKey = schema.idKey || "id";
|
|
702
|
+
const result = { ...entity };
|
|
703
|
+
if (schema.relations) {
|
|
704
|
+
for (const [field, relationType] of Object.entries(schema.relations)) {
|
|
705
|
+
const value = entity[field];
|
|
706
|
+
if (value == null) continue;
|
|
707
|
+
const relSchema = { name: relationType, idKey };
|
|
708
|
+
if (Array.isArray(value)) {
|
|
709
|
+
result[field] = value.map((relId) => denormalize(relId, entities, relSchema));
|
|
710
|
+
} else if (typeof value === "string") {
|
|
711
|
+
result[field] = denormalize(value, entities, relSchema);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
return result;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
// src/performance/chunkLoader.ts
|
|
719
|
+
function createChunkRegistry(config = {}) {
|
|
720
|
+
const {
|
|
721
|
+
maxCacheSize = 50,
|
|
722
|
+
cacheTTL = 0,
|
|
723
|
+
retries = 2,
|
|
724
|
+
retryDelay = 1e3,
|
|
725
|
+
timeout = 1e4,
|
|
726
|
+
onLoadStart,
|
|
727
|
+
onLoadEnd,
|
|
728
|
+
onLoadError
|
|
729
|
+
} = config;
|
|
730
|
+
const cache = /* @__PURE__ */ new Map();
|
|
731
|
+
const pending = /* @__PURE__ */ new Map();
|
|
732
|
+
const preloaded = /* @__PURE__ */ new Set();
|
|
733
|
+
function evict() {
|
|
734
|
+
if (cache.size < maxCacheSize) return;
|
|
735
|
+
let oldest = null;
|
|
736
|
+
let oldestTime = Infinity;
|
|
737
|
+
for (const [key, entry] of cache) {
|
|
738
|
+
if (entry.timestamp < oldestTime) {
|
|
739
|
+
oldestTime = entry.timestamp;
|
|
740
|
+
oldest = key;
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
if (oldest) cache.delete(oldest);
|
|
744
|
+
}
|
|
745
|
+
function isValid(entry) {
|
|
746
|
+
if (cacheTTL === 0) return true;
|
|
747
|
+
return Date.now() - entry.timestamp < cacheTTL;
|
|
748
|
+
}
|
|
749
|
+
async function loadWithRetry(id, loader, attempt = 0) {
|
|
750
|
+
try {
|
|
751
|
+
const result = await (timeout > 0 ? Promise.race([
|
|
752
|
+
loader(),
|
|
753
|
+
new Promise(
|
|
754
|
+
(_, reject) => setTimeout(() => reject(new Error(`Chunk '${id}' loading timed out after ${timeout}ms`)), timeout)
|
|
755
|
+
)
|
|
756
|
+
]) : loader());
|
|
757
|
+
return result;
|
|
758
|
+
} catch (err) {
|
|
759
|
+
if (attempt < retries) {
|
|
760
|
+
await new Promise((r) => setTimeout(r, retryDelay * (attempt + 1)));
|
|
761
|
+
return loadWithRetry(id, loader, attempt + 1);
|
|
762
|
+
}
|
|
763
|
+
throw err;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
return {
|
|
767
|
+
/**
|
|
768
|
+
* Load a chunk by ID. Uses cache if available, otherwise loads via the provided loader.
|
|
769
|
+
*/
|
|
770
|
+
async load(id, loader) {
|
|
771
|
+
const cached = cache.get(id);
|
|
772
|
+
if (cached && isValid(cached)) {
|
|
773
|
+
cached.accessCount++;
|
|
774
|
+
return cached.value;
|
|
775
|
+
}
|
|
776
|
+
const pendingLoad = pending.get(id);
|
|
777
|
+
if (pendingLoad) return pendingLoad;
|
|
778
|
+
onLoadStart?.(id);
|
|
779
|
+
const loadPromise = loadWithRetry(id, loader).then((value) => {
|
|
780
|
+
evict();
|
|
781
|
+
cache.set(id, { value, timestamp: Date.now(), accessCount: 1 });
|
|
782
|
+
pending.delete(id);
|
|
783
|
+
onLoadEnd?.(id);
|
|
784
|
+
return value;
|
|
785
|
+
}).catch((err) => {
|
|
786
|
+
pending.delete(id);
|
|
787
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
788
|
+
onLoadError?.(id, error);
|
|
789
|
+
throw error;
|
|
790
|
+
});
|
|
791
|
+
pending.set(id, loadPromise);
|
|
792
|
+
return loadPromise;
|
|
793
|
+
},
|
|
794
|
+
/**
|
|
795
|
+
* Preload a chunk without blocking. Silently caches for later use.
|
|
796
|
+
*/
|
|
797
|
+
preload(id, loader) {
|
|
798
|
+
if (cache.has(id) || pending.has(id) || preloaded.has(id)) return;
|
|
799
|
+
preloaded.add(id);
|
|
800
|
+
this.load(id, loader).catch(() => {
|
|
801
|
+
});
|
|
802
|
+
},
|
|
803
|
+
/**
|
|
804
|
+
* Preload multiple chunks in parallel.
|
|
805
|
+
*/
|
|
806
|
+
preloadAll(entries) {
|
|
807
|
+
for (const entry of entries) {
|
|
808
|
+
this.preload(entry.id, entry.loader);
|
|
809
|
+
}
|
|
810
|
+
},
|
|
811
|
+
/**
|
|
812
|
+
* Check if a chunk is cached and valid.
|
|
813
|
+
*/
|
|
814
|
+
has(id) {
|
|
815
|
+
const entry = cache.get(id);
|
|
816
|
+
return !!entry && isValid(entry);
|
|
817
|
+
},
|
|
818
|
+
/**
|
|
819
|
+
* Get a cached chunk synchronously. Returns undefined if not cached.
|
|
820
|
+
*/
|
|
821
|
+
get(id) {
|
|
822
|
+
const entry = cache.get(id);
|
|
823
|
+
if (entry && isValid(entry)) {
|
|
824
|
+
entry.accessCount++;
|
|
825
|
+
return entry.value;
|
|
826
|
+
}
|
|
827
|
+
return void 0;
|
|
828
|
+
},
|
|
829
|
+
/**
|
|
830
|
+
* Invalidate a cached chunk.
|
|
831
|
+
*/
|
|
832
|
+
invalidate(id) {
|
|
833
|
+
cache.delete(id);
|
|
834
|
+
},
|
|
835
|
+
/**
|
|
836
|
+
* Clear all cached chunks.
|
|
837
|
+
*/
|
|
838
|
+
clear() {
|
|
839
|
+
cache.clear();
|
|
840
|
+
preloaded.clear();
|
|
841
|
+
},
|
|
842
|
+
/**
|
|
843
|
+
* Get cache statistics.
|
|
844
|
+
*/
|
|
845
|
+
stats() {
|
|
846
|
+
return {
|
|
847
|
+
size: cache.size,
|
|
848
|
+
maxSize: maxCacheSize,
|
|
849
|
+
pending: pending.size,
|
|
850
|
+
preloaded: preloaded.size
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
};
|
|
854
|
+
}
|
|
855
|
+
function lazyChunk(id, loader, registry, fallback) {
|
|
856
|
+
return () => {
|
|
857
|
+
const cached = registry.get(id);
|
|
858
|
+
if (cached) return cached();
|
|
859
|
+
const container = document.createElement("div");
|
|
860
|
+
container.setAttribute("data-chunk", id);
|
|
861
|
+
if (fallback) {
|
|
862
|
+
container.appendChild(fallback());
|
|
863
|
+
}
|
|
864
|
+
registry.load(id, async () => {
|
|
865
|
+
const mod = await loader();
|
|
866
|
+
return typeof mod === "function" ? mod : mod.default;
|
|
867
|
+
}).then((component) => {
|
|
868
|
+
container.innerHTML = "";
|
|
869
|
+
container.appendChild(component());
|
|
870
|
+
}).catch((err) => {
|
|
871
|
+
container.innerHTML = "";
|
|
872
|
+
const errorEl = document.createElement("div");
|
|
873
|
+
errorEl.textContent = `Failed to load chunk '${id}': ${err.message}`;
|
|
874
|
+
container.appendChild(errorEl);
|
|
875
|
+
});
|
|
876
|
+
return container;
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
function preloadModule(url) {
|
|
880
|
+
if (typeof document === "undefined") return;
|
|
881
|
+
const existing = document.querySelector(`link[href="${url}"][rel="modulepreload"]`);
|
|
882
|
+
if (existing) return;
|
|
883
|
+
const link = document.createElement("link");
|
|
884
|
+
link.rel = "modulepreload";
|
|
885
|
+
link.href = url;
|
|
886
|
+
document.head.appendChild(link);
|
|
887
|
+
}
|
|
888
|
+
function preloadModules(urls) {
|
|
889
|
+
urls.forEach(preloadModule);
|
|
890
|
+
}
|
|
891
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
892
|
+
0 && (module.exports = {
|
|
893
|
+
DOMPool,
|
|
894
|
+
Features,
|
|
895
|
+
Priority,
|
|
896
|
+
block,
|
|
897
|
+
cloneTemplate,
|
|
898
|
+
conditional,
|
|
899
|
+
createChunkRegistry,
|
|
900
|
+
deferredValue,
|
|
901
|
+
denormalize,
|
|
902
|
+
devOnly,
|
|
903
|
+
domPool,
|
|
904
|
+
flushScheduler,
|
|
905
|
+
hoistable,
|
|
906
|
+
lazyChunk,
|
|
907
|
+
noSideEffect,
|
|
908
|
+
normalize,
|
|
909
|
+
normalizedStore,
|
|
910
|
+
pendingTasks,
|
|
911
|
+
precompile,
|
|
912
|
+
prefetch,
|
|
913
|
+
preloadImage,
|
|
914
|
+
preloadModule,
|
|
915
|
+
preloadModules,
|
|
916
|
+
preloadResource,
|
|
917
|
+
processInChunks,
|
|
918
|
+
pure,
|
|
919
|
+
resetIdCounter,
|
|
920
|
+
scheduleUpdate,
|
|
921
|
+
setIdPrefix,
|
|
922
|
+
startTransition,
|
|
923
|
+
staticTemplate,
|
|
924
|
+
transitionState,
|
|
925
|
+
uniqueId,
|
|
926
|
+
yieldToMain
|
|
927
|
+
});
|