sibujs 4.5.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.cjs +309 -129
- package/dist/browser.d.cts +46 -14
- package/dist/browser.d.ts +46 -14
- package/dist/browser.js +8 -6
- package/dist/build.cjs +184 -72
- package/dist/build.js +15 -16
- package/dist/cdn.dev.global.js +12 -12
- package/dist/cdn.full.dev.global.js +11 -11
- package/dist/cdn.full.global.js +10 -10
- package/dist/cdn.global.js +12 -12
- package/dist/{chunk-IXKSNWV5.js → chunk-2INLLLMZ.js} +1 -1
- package/dist/chunk-3ISI6ACU.js +44 -0
- package/dist/{chunk-ONOHFDLG.js → chunk-47M47FOM.js} +3 -3
- package/dist/chunk-5HZXGZ6T.js +24 -0
- package/dist/{chunk-KKLW7YWL.js → chunk-5MT6SJ3P.js} +275 -144
- package/dist/{chunk-UGRX3S57.js → chunk-5Q4R7HCL.js} +12 -3
- package/dist/{chunk-S373NSMK.js → chunk-7GQCWFOE.js} +150 -59
- package/dist/{chunk-FTIR4QW2.js → chunk-7NCARGJW.js} +6 -8
- package/dist/{chunk-5DXA2J44.js → chunk-7XHATCIH.js} +5 -2
- package/dist/{chunk-VZKNK2V7.js → chunk-AIF3Z2T7.js} +296 -38
- package/dist/{chunk-4PMLNECI.js → chunk-BAAG6ZTI.js} +98 -29
- package/dist/{chunk-XZZOBQAY.js → chunk-D33YTSX5.js} +2 -2
- package/dist/{chunk-TBYTO6BS.js → chunk-DKGBBKOF.js} +136 -80
- package/dist/{chunk-NIOYEGBQ.js → chunk-HURREPU2.js} +27 -13
- package/dist/{chunk-GW3SCCZG.js → chunk-HYXDKS4N.js} +153 -110
- package/dist/chunk-J6FW5TV6.js +233 -0
- package/dist/{chunk-PCT43HW3.js → chunk-JSXPZCET.js} +1 -1
- package/dist/chunk-NYNYSPK7.js +318 -0
- package/dist/{chunk-RJE2BNI4.js → chunk-ORMZXBKQ.js} +108 -45
- package/dist/{chunk-OMJJM3KM.js → chunk-OXUY2A6L.js} +287 -130
- package/dist/{chunk-3JZ4L5TJ.js → chunk-PK6FK2G2.js} +181 -66
- package/dist/{chunk-RBTPLM32.js → chunk-QE4TTDU3.js} +2 -2
- package/dist/{chunk-2DCGACUU.js → chunk-SXXVZMKZ.js} +251 -66
- package/dist/{chunk-R25EFXXC.js → chunk-TUCPL2HB.js} +3 -3
- package/dist/{chunk-7LN645I6.js → chunk-UZQ6ALFS.js} +3 -3
- package/dist/{chunk-KEISJXBU.js → chunk-VVWPJ543.js} +6 -8
- package/dist/{chunk-RIXRAYIU.js → chunk-XC4MEKGA.js} +3 -3
- package/dist/{chunk-B3WHI2QA.js → chunk-XRRZKZYX.js} +55 -31
- package/dist/{contracts-DBdg9J_a.d.cts → contracts-DRIuclVT.d.cts} +10 -2
- package/dist/{contracts-DBdg9J_a.d.ts → contracts-DRIuclVT.d.ts} +10 -2
- package/dist/{customElement-OB9CIsc5.d.cts → customElement-MmInOW1U.d.cts} +21 -0
- package/dist/{customElement-OB9CIsc5.d.ts → customElement-MmInOW1U.d.ts} +21 -0
- package/dist/data.cjs +213 -117
- package/dist/data.d.cts +47 -9
- package/dist/data.d.ts +47 -9
- package/dist/data.js +12 -9
- package/dist/devtools.cjs +81 -57
- package/dist/devtools.js +7 -8
- package/dist/dispose-GEIG2KOF.js +28 -0
- package/dist/ecosystem.cjs +309 -104
- package/dist/ecosystem.d.cts +19 -3
- package/dist/ecosystem.d.ts +19 -3
- package/dist/ecosystem.js +12 -12
- package/dist/extras.cjs +2133 -863
- package/dist/extras.d.cts +10 -9
- package/dist/extras.d.ts +10 -9
- package/dist/extras.js +39 -28
- package/dist/index.cjs +184 -72
- package/dist/index.d.cts +22 -5
- package/dist/index.d.ts +22 -5
- package/dist/index.js +24 -27
- package/dist/motion.cjs +107 -41
- package/dist/motion.js +5 -5
- package/dist/patterns.cjs +317 -39
- package/dist/patterns.d.cts +27 -9
- package/dist/patterns.d.ts +27 -9
- package/dist/patterns.js +8 -8
- package/dist/performance.cjs +308 -216
- package/dist/performance.d.cts +2 -2
- package/dist/performance.d.ts +2 -2
- package/dist/performance.js +8 -9
- package/dist/plugin-DVgSnTfK.d.cts +112 -0
- package/dist/plugin-DVgSnTfK.d.ts +112 -0
- package/dist/plugins.cjs +549 -202
- package/dist/plugins.d.cts +3 -3
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +35 -23
- package/dist/signal-EotCj4hS.d.cts +110 -0
- package/dist/signal-EotCj4hS.d.ts +110 -0
- package/dist/{ssr-BiPRdZ6n.d.cts → ssr-Bli9XRW5.d.cts} +5 -0
- package/dist/{ssr-BiPRdZ6n.d.ts → ssr-Bli9XRW5.d.ts} +5 -0
- package/dist/{ssr-Y7XOEPEN.js → ssr-XOTUASDO.js} +4 -5
- package/dist/ssr.cjs +176 -72
- package/dist/ssr.d.cts +9 -3
- package/dist/ssr.d.ts +9 -3
- package/dist/ssr.js +11 -12
- package/dist/{startup-BMpaiMhP.d.ts → startup-BLfSeL15.d.cts} +73 -22
- package/dist/{startup-BMpaiMhP.d.cts → startup-BLfSeL15.d.ts} +73 -22
- package/dist/{tagFactory-DVoDpHye.d.ts → tagFactory-DFstCLQV.d.cts} +2 -100
- package/dist/{tagFactory-DVoDpHye.d.cts → tagFactory-DkaNVUNV.d.ts} +2 -100
- package/dist/testing.cjs +2484 -2185
- package/dist/testing.d.cts +56 -5
- package/dist/testing.d.ts +56 -5
- package/dist/testing.js +580 -307
- package/dist/ui.cjs +707 -317
- package/dist/ui.d.cts +40 -7
- package/dist/ui.d.ts +40 -7
- package/dist/ui.js +151 -56
- package/dist/widgets.cjs +246 -278
- package/dist/widgets.js +9 -10
- package/package.json +1 -1
- package/dist/chunk-2WLZ6757.js +0 -149
- package/dist/chunk-CCSJMTRN.js +0 -15
- package/dist/chunk-QKRPLZ2V.js +0 -108
- package/dist/chunk-VUF4ALSW.js +0 -60
- package/dist/chunk-WWV3SJ3L.js +0 -131
- package/dist/dispose-46BOMMQJ.js +0 -19
- package/dist/plugin-D30wlGW5.d.cts +0 -71
- package/dist/plugin-D30wlGW5.d.ts +0 -71
|
@@ -4,25 +4,42 @@ import {
|
|
|
4
4
|
} from "./chunk-H3SRKIYX.js";
|
|
5
5
|
import {
|
|
6
6
|
derived
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-QE4TTDU3.js";
|
|
8
8
|
import {
|
|
9
9
|
effect
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-XC4MEKGA.js";
|
|
11
11
|
import {
|
|
12
12
|
batch,
|
|
13
13
|
signal
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-D33YTSX5.js";
|
|
15
|
+
import {
|
|
16
|
+
DEV,
|
|
17
|
+
devWarn,
|
|
18
|
+
reportError
|
|
19
|
+
} from "./chunk-NYNYSPK7.js";
|
|
15
20
|
|
|
16
21
|
// src/patterns/machine.ts
|
|
17
22
|
function machine(config) {
|
|
18
23
|
const [state, setState] = signal(config.initial);
|
|
19
24
|
const [context, setContext] = signal(config.context || {});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
let currentState = config.initial;
|
|
26
|
+
let currentContext = context();
|
|
27
|
+
const queue = [];
|
|
28
|
+
let processing = false;
|
|
29
|
+
function drain() {
|
|
30
|
+
processing = true;
|
|
31
|
+
try {
|
|
32
|
+
while (queue.length > 0) {
|
|
33
|
+
step(queue.shift());
|
|
34
|
+
}
|
|
35
|
+
} catch (err) {
|
|
36
|
+
queue.length = 0;
|
|
37
|
+
throw err;
|
|
38
|
+
} finally {
|
|
39
|
+
processing = false;
|
|
40
|
+
}
|
|
23
41
|
}
|
|
24
|
-
function
|
|
25
|
-
const currentState = state();
|
|
42
|
+
function step(event) {
|
|
26
43
|
const stateDef = config.states[currentState];
|
|
27
44
|
if (!stateDef?.on) return;
|
|
28
45
|
const transition = stateDef.on[event];
|
|
@@ -37,28 +54,51 @@ function machine(config) {
|
|
|
37
54
|
guard = transition.guard;
|
|
38
55
|
action = transition.action;
|
|
39
56
|
}
|
|
40
|
-
const ctx =
|
|
57
|
+
const ctx = currentContext;
|
|
41
58
|
if (guard && !guard(ctx)) return;
|
|
42
59
|
if (stateDef.exit) {
|
|
43
60
|
stateDef.exit(ctx);
|
|
44
61
|
}
|
|
62
|
+
let nextContext = ctx;
|
|
45
63
|
if (action) {
|
|
46
64
|
const rawPatch = action(ctx);
|
|
47
|
-
|
|
48
|
-
setContext(next);
|
|
65
|
+
nextContext = { ...ctx, ...stripUnsafeKeys(rawPatch) };
|
|
49
66
|
}
|
|
50
|
-
|
|
67
|
+
currentState = target;
|
|
68
|
+
currentContext = nextContext;
|
|
69
|
+
batch(() => {
|
|
70
|
+
if (action) setContext(nextContext);
|
|
71
|
+
setState(target);
|
|
72
|
+
});
|
|
51
73
|
const targetDef = config.states[target];
|
|
52
74
|
if (targetDef?.entry) {
|
|
53
|
-
targetDef.entry(
|
|
75
|
+
targetDef.entry(currentContext);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function send(event) {
|
|
79
|
+
queue.push(event);
|
|
80
|
+
if (processing) return;
|
|
81
|
+
drain();
|
|
82
|
+
}
|
|
83
|
+
const initialDef = config.states[config.initial];
|
|
84
|
+
if (initialDef?.entry) {
|
|
85
|
+
processing = true;
|
|
86
|
+
try {
|
|
87
|
+
initialDef.entry(currentContext);
|
|
88
|
+
} catch (err) {
|
|
89
|
+
queue.length = 0;
|
|
90
|
+
throw err;
|
|
91
|
+
} finally {
|
|
92
|
+
processing = false;
|
|
54
93
|
}
|
|
94
|
+
if (queue.length > 0) drain();
|
|
55
95
|
}
|
|
56
96
|
function matches(s) {
|
|
57
97
|
return state() === s;
|
|
58
98
|
}
|
|
59
99
|
function can(event) {
|
|
60
|
-
const
|
|
61
|
-
const stateDef = config.states[
|
|
100
|
+
const currentState2 = state();
|
|
101
|
+
const stateDef = config.states[currentState2];
|
|
62
102
|
if (!stateDef?.on) return false;
|
|
63
103
|
const transition = stateDef.on[event];
|
|
64
104
|
if (!transition) return false;
|
|
@@ -441,6 +481,9 @@ function optimisticList(initialValue) {
|
|
|
441
481
|
|
|
442
482
|
// src/patterns/timeTravel.ts
|
|
443
483
|
function timeline(initial, maxHistory = 100) {
|
|
484
|
+
if (!Number.isSafeInteger(maxHistory) || maxHistory < 1) {
|
|
485
|
+
throw new RangeError(`[timeline] maxHistory must be a positive safe integer, got ${maxHistory}`);
|
|
486
|
+
}
|
|
444
487
|
const [history, setHistory] = signal([initial]);
|
|
445
488
|
const [index, setIndex] = signal(0);
|
|
446
489
|
const value = derived(() => history()[index()]);
|
|
@@ -495,6 +538,120 @@ function timeline(initial, maxHistory = 100) {
|
|
|
495
538
|
return { value, set, undo, redo, canUndo, canRedo, history, index, reset, jumpTo, dispose };
|
|
496
539
|
}
|
|
497
540
|
|
|
541
|
+
// src/utils/adoption.ts
|
|
542
|
+
var nativeThen = Promise.prototype.then;
|
|
543
|
+
function probeNative(target, onRejected, onOpen) {
|
|
544
|
+
let decided = false;
|
|
545
|
+
const decide = (rejected) => {
|
|
546
|
+
if (decided) return;
|
|
547
|
+
decided = true;
|
|
548
|
+
(rejected ? onRejected : onOpen)();
|
|
549
|
+
};
|
|
550
|
+
try {
|
|
551
|
+
Reflect.apply(nativeThen, target, [void 0, () => decide(true)]);
|
|
552
|
+
} catch {
|
|
553
|
+
queueMicrotask(() => decide(true));
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
queueMicrotask(() => decide(false));
|
|
557
|
+
}
|
|
558
|
+
function adopt(value) {
|
|
559
|
+
if (value === null || typeof value !== "object" && typeof value !== "function") return null;
|
|
560
|
+
let then;
|
|
561
|
+
try {
|
|
562
|
+
then = value.then;
|
|
563
|
+
} catch (error) {
|
|
564
|
+
return {
|
|
565
|
+
promise: Promise.reject(error),
|
|
566
|
+
failedEarly: true,
|
|
567
|
+
probe: (onRejected) => queueMicrotask(onRejected)
|
|
568
|
+
};
|
|
569
|
+
}
|
|
570
|
+
if (typeof then !== "function") return null;
|
|
571
|
+
let resolvePromise;
|
|
572
|
+
let rejectPromise;
|
|
573
|
+
const promise = new Promise((resolve, reject) => {
|
|
574
|
+
resolvePromise = resolve;
|
|
575
|
+
rejectPromise = reject;
|
|
576
|
+
});
|
|
577
|
+
let state = "invoking";
|
|
578
|
+
let nativeTarget;
|
|
579
|
+
const waiters = [];
|
|
580
|
+
const transition = (next) => {
|
|
581
|
+
state = next;
|
|
582
|
+
if (next === "invoking") return;
|
|
583
|
+
for (const waiter of waiters.splice(0)) waiter();
|
|
584
|
+
};
|
|
585
|
+
const fulfil = (result) => {
|
|
586
|
+
resolvePromise(result);
|
|
587
|
+
transition("fulfilled");
|
|
588
|
+
};
|
|
589
|
+
const fail = (error) => {
|
|
590
|
+
rejectPromise(error);
|
|
591
|
+
transition("rejected");
|
|
592
|
+
};
|
|
593
|
+
const follow = (result) => {
|
|
594
|
+
if (result === promise) {
|
|
595
|
+
fail(new TypeError("adopt: a thenable resolved to its own adoption"));
|
|
596
|
+
return;
|
|
597
|
+
}
|
|
598
|
+
if (result === null || typeof result !== "object" && typeof result !== "function") {
|
|
599
|
+
fulfil(result);
|
|
600
|
+
return;
|
|
601
|
+
}
|
|
602
|
+
let nextThen;
|
|
603
|
+
try {
|
|
604
|
+
nextThen = result.then;
|
|
605
|
+
} catch (error) {
|
|
606
|
+
fail(error);
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
if (typeof nextThen !== "function") {
|
|
610
|
+
fulfil(result);
|
|
611
|
+
return;
|
|
612
|
+
}
|
|
613
|
+
invokeLater(result, nextThen);
|
|
614
|
+
};
|
|
615
|
+
const invokeLater = (target, targetThen) => {
|
|
616
|
+
if (targetThen === nativeThen) {
|
|
617
|
+
nativeTarget = target;
|
|
618
|
+
transition("native");
|
|
619
|
+
} else {
|
|
620
|
+
transition("invoking");
|
|
621
|
+
}
|
|
622
|
+
queueMicrotask(() => {
|
|
623
|
+
let done = false;
|
|
624
|
+
const onResolve = (result) => {
|
|
625
|
+
if (done) return;
|
|
626
|
+
done = true;
|
|
627
|
+
follow(result);
|
|
628
|
+
};
|
|
629
|
+
const onReject = (error) => {
|
|
630
|
+
if (done) return;
|
|
631
|
+
done = true;
|
|
632
|
+
fail(error);
|
|
633
|
+
};
|
|
634
|
+
try {
|
|
635
|
+
Reflect.apply(targetThen, target, [onResolve, onReject]);
|
|
636
|
+
} catch (error) {
|
|
637
|
+
onReject(error);
|
|
638
|
+
}
|
|
639
|
+
if (!done && state === "invoking") transition("pending");
|
|
640
|
+
});
|
|
641
|
+
};
|
|
642
|
+
invokeLater(value, then);
|
|
643
|
+
const probe = (onRejected, onOpen) => {
|
|
644
|
+
const decide = () => {
|
|
645
|
+
if (state === "native") probeNative(nativeTarget, onRejected, onOpen);
|
|
646
|
+
else (state === "rejected" ? onRejected : onOpen)();
|
|
647
|
+
};
|
|
648
|
+
if (state === "native") probeNative(nativeTarget, onRejected, onOpen);
|
|
649
|
+
else if (state === "invoking") waiters.push(decide);
|
|
650
|
+
else queueMicrotask(state === "rejected" ? onRejected : onOpen);
|
|
651
|
+
};
|
|
652
|
+
return { promise, failedEarly: false, probe };
|
|
653
|
+
}
|
|
654
|
+
|
|
498
655
|
// src/patterns/globalStore.ts
|
|
499
656
|
function deepClone(value) {
|
|
500
657
|
if (typeof structuredClone === "function") {
|
|
@@ -529,8 +686,51 @@ function deepClone(value) {
|
|
|
529
686
|
function globalStore(config) {
|
|
530
687
|
const initialState = deepClone(config.state);
|
|
531
688
|
const [getState, setState] = signal({ ...initialState });
|
|
532
|
-
const
|
|
689
|
+
const subscriptions = /* @__PURE__ */ new Map();
|
|
533
690
|
const middlewares = config.middleware || [];
|
|
691
|
+
function notifyListeners(state) {
|
|
692
|
+
if (subscriptions.size === 0) return;
|
|
693
|
+
for (const subscription of Array.from(subscriptions.values())) {
|
|
694
|
+
if (!subscription.active) continue;
|
|
695
|
+
try {
|
|
696
|
+
subscription.callback(state);
|
|
697
|
+
} catch (err) {
|
|
698
|
+
reportError(err, { phase: "event", name: "globalStore(subscribe)" });
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
const operations = [];
|
|
703
|
+
let running = false;
|
|
704
|
+
function perform(operation, rethrowOwn = true) {
|
|
705
|
+
operations.push(operation);
|
|
706
|
+
if (running) return;
|
|
707
|
+
running = true;
|
|
708
|
+
let callerError;
|
|
709
|
+
let callerFailed = false;
|
|
710
|
+
try {
|
|
711
|
+
let first = true;
|
|
712
|
+
let cursor = 0;
|
|
713
|
+
while (cursor < operations.length) {
|
|
714
|
+
const next = operations[cursor];
|
|
715
|
+
operations[cursor++] = void 0;
|
|
716
|
+
try {
|
|
717
|
+
next();
|
|
718
|
+
} catch (err) {
|
|
719
|
+
if (first && rethrowOwn) {
|
|
720
|
+
callerFailed = true;
|
|
721
|
+
callerError = err;
|
|
722
|
+
} else {
|
|
723
|
+
reportError(err, { phase: "event", name: "globalStore(dispatch)" });
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
first = false;
|
|
727
|
+
}
|
|
728
|
+
} finally {
|
|
729
|
+
operations.length = 0;
|
|
730
|
+
running = false;
|
|
731
|
+
}
|
|
732
|
+
if (callerFailed) throw callerError;
|
|
733
|
+
}
|
|
534
734
|
function dispatch(action, payload) {
|
|
535
735
|
const actionFn = config.actions[action];
|
|
536
736
|
if (!actionFn) throw new Error(`Unknown action: ${String(action)}`);
|
|
@@ -539,38 +739,96 @@ function globalStore(config) {
|
|
|
539
739
|
const rawPatch = actionFn(current, payload);
|
|
540
740
|
const patch = stripUnsafeKeys(rawPatch);
|
|
541
741
|
setState({ ...current, ...patch });
|
|
542
|
-
|
|
543
|
-
for (const listener of listeners) {
|
|
544
|
-
listener(newState);
|
|
545
|
-
}
|
|
742
|
+
notifyListeners(getState());
|
|
546
743
|
};
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
return;
|
|
550
|
-
}
|
|
551
|
-
let index = 0;
|
|
552
|
-
const next = () => {
|
|
553
|
-
if (index < middlewares.length) {
|
|
554
|
-
const mw = middlewares[index++];
|
|
555
|
-
mw(getState(), String(action), payload, next);
|
|
556
|
-
} else {
|
|
744
|
+
perform(() => {
|
|
745
|
+
if (middlewares.length === 0) {
|
|
557
746
|
execute();
|
|
747
|
+
return;
|
|
558
748
|
}
|
|
559
|
-
|
|
560
|
-
|
|
749
|
+
const runFrom = (index) => {
|
|
750
|
+
if (index >= middlewares.length) {
|
|
751
|
+
execute();
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
let called = false;
|
|
755
|
+
let failed = false;
|
|
756
|
+
let synchronous = true;
|
|
757
|
+
const next = () => {
|
|
758
|
+
if (failed && !called) {
|
|
759
|
+
if (DEV)
|
|
760
|
+
devWarn(
|
|
761
|
+
`globalStore: middleware ${index} next() called after it failed for "${String(action)}"; ignored.`
|
|
762
|
+
);
|
|
763
|
+
called = true;
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
if (called) {
|
|
767
|
+
if (DEV)
|
|
768
|
+
devWarn(
|
|
769
|
+
`globalStore: middleware ${index} next() called more than once for "${String(action)}"; ignored.`
|
|
770
|
+
);
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
called = true;
|
|
774
|
+
if (synchronous) {
|
|
775
|
+
runFrom(index + 1);
|
|
776
|
+
return;
|
|
777
|
+
}
|
|
778
|
+
const proceed = () => perform(() => runFrom(index + 1), false);
|
|
779
|
+
if (!adoption) {
|
|
780
|
+
proceed();
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
adoption.probe(() => {
|
|
784
|
+
failed = true;
|
|
785
|
+
if (DEV)
|
|
786
|
+
devWarn(
|
|
787
|
+
`globalStore: middleware ${index} next() called after it failed for "${String(action)}"; ignored.`
|
|
788
|
+
);
|
|
789
|
+
}, proceed);
|
|
790
|
+
};
|
|
791
|
+
let adoption = null;
|
|
792
|
+
try {
|
|
793
|
+
adoption = adopt(middlewares[index](getState(), String(action), payload, next));
|
|
794
|
+
} catch (err) {
|
|
795
|
+
failed = true;
|
|
796
|
+
throw err;
|
|
797
|
+
} finally {
|
|
798
|
+
synchronous = false;
|
|
799
|
+
}
|
|
800
|
+
if (adoption) {
|
|
801
|
+
if (adoption.failedEarly) failed = true;
|
|
802
|
+
adoption.promise.then(void 0, (err) => {
|
|
803
|
+
failed = true;
|
|
804
|
+
reportError(err, { phase: "async", name: "globalStore(middleware)" });
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
runFrom(0);
|
|
809
|
+
});
|
|
561
810
|
}
|
|
562
811
|
function select(selector) {
|
|
563
812
|
return () => selector(getState());
|
|
564
813
|
}
|
|
565
814
|
function subscribe(callback) {
|
|
566
|
-
|
|
567
|
-
|
|
815
|
+
let subscription = subscriptions.get(callback);
|
|
816
|
+
if (!subscription) {
|
|
817
|
+
subscription = { callback, active: true };
|
|
818
|
+
subscriptions.set(callback, subscription);
|
|
819
|
+
}
|
|
820
|
+
const own = subscription;
|
|
821
|
+
return () => {
|
|
822
|
+
if (subscriptions.get(callback) !== own) return;
|
|
823
|
+
own.active = false;
|
|
824
|
+
subscriptions.delete(callback);
|
|
825
|
+
};
|
|
568
826
|
}
|
|
569
827
|
function reset() {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
}
|
|
828
|
+
perform(() => {
|
|
829
|
+
setState({ ...initialState });
|
|
830
|
+
notifyListeners(getState());
|
|
831
|
+
});
|
|
574
832
|
}
|
|
575
833
|
return { getState, select, dispatch, subscribe, reset };
|
|
576
834
|
}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createPlugin
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-J6FW5TV6.js";
|
|
4
4
|
import {
|
|
5
5
|
tagFactory
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-VVWPJ543.js";
|
|
7
7
|
import {
|
|
8
8
|
derived
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-QE4TTDU3.js";
|
|
10
|
+
import {
|
|
11
|
+
globalSingleton
|
|
12
|
+
} from "./chunk-7ZHH77QA.js";
|
|
10
13
|
import {
|
|
11
14
|
effect
|
|
12
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-XC4MEKGA.js";
|
|
13
16
|
import {
|
|
14
17
|
batch,
|
|
15
18
|
signal
|
|
16
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-D33YTSX5.js";
|
|
17
20
|
|
|
18
21
|
// src/ecosystem/adapters/mobx.ts
|
|
19
22
|
function mobXAdapter(options) {
|
|
@@ -111,53 +114,119 @@ function zustandAdapter(options) {
|
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
// src/ecosystem/ui/componentAdapter.ts
|
|
117
|
+
var _themeLayers = globalSingleton(
|
|
118
|
+
/* @__PURE__ */ Symbol.for("sibujs.themeLayers.v1"),
|
|
119
|
+
() => /* @__PURE__ */ new WeakMap()
|
|
120
|
+
);
|
|
121
|
+
function commitThemeProperty(root, name, record) {
|
|
122
|
+
const top = record.layers[record.layers.length - 1];
|
|
123
|
+
if (top) {
|
|
124
|
+
root.style.setProperty(name, top.value);
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
_themeLayers.get(root)?.delete(name);
|
|
128
|
+
if (record.original.value === "") root.style.removeProperty(name);
|
|
129
|
+
else root.style.setProperty(name, record.original.value, record.original.priority);
|
|
130
|
+
}
|
|
131
|
+
function setThemeLayer(root, name, handle, value) {
|
|
132
|
+
let properties = _themeLayers.get(root);
|
|
133
|
+
if (!properties) _themeLayers.set(root, properties = /* @__PURE__ */ new Map());
|
|
134
|
+
let record = properties.get(name);
|
|
135
|
+
if (!record) {
|
|
136
|
+
record = {
|
|
137
|
+
original: { value: root.style.getPropertyValue(name), priority: root.style.getPropertyPriority(name) },
|
|
138
|
+
layers: []
|
|
139
|
+
};
|
|
140
|
+
properties.set(name, record);
|
|
141
|
+
}
|
|
142
|
+
const layer = record.layers.find((l) => l.handle === handle);
|
|
143
|
+
if (layer) layer.value = value;
|
|
144
|
+
else record.layers.push({ handle, value });
|
|
145
|
+
commitThemeProperty(root, name, record);
|
|
146
|
+
}
|
|
147
|
+
function removeThemeLayer(root, name, handle) {
|
|
148
|
+
const record = _themeLayers.get(root)?.get(name);
|
|
149
|
+
if (!record) return;
|
|
150
|
+
const index = record.layers.findIndex((l) => l.handle === handle);
|
|
151
|
+
if (index === -1) return;
|
|
152
|
+
record.layers.splice(index, 1);
|
|
153
|
+
commitThemeProperty(root, name, record);
|
|
154
|
+
}
|
|
155
|
+
function ownString(map, key) {
|
|
156
|
+
if (!map || key === void 0 || !Object.hasOwn(map, key)) return void 0;
|
|
157
|
+
const value = map[key];
|
|
158
|
+
return typeof value === "string" ? value : void 0;
|
|
159
|
+
}
|
|
114
160
|
function createTheme(initial) {
|
|
115
161
|
const [getConfig, setConfig] = signal(initial);
|
|
116
162
|
function resolveClass(component, variant) {
|
|
117
163
|
const config = getConfig();
|
|
118
164
|
const overrideKey = variant ? `${component}-${variant}` : component;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
165
|
+
const override = ownString(config.classOverrides, overrideKey);
|
|
166
|
+
if (override) return override;
|
|
122
167
|
const base = `${config.prefix}-${component}`;
|
|
123
168
|
return variant ? `${base} ${config.prefix}-${component}--${variant}` : base;
|
|
124
169
|
}
|
|
125
170
|
function setTheme(partial) {
|
|
126
171
|
setConfig((prev) => ({ ...prev, ...partial }));
|
|
127
172
|
}
|
|
128
|
-
|
|
173
|
+
function applyTo(root) {
|
|
174
|
+
const handle = {};
|
|
175
|
+
let applied = /* @__PURE__ */ new Set();
|
|
176
|
+
const stop = effect(() => {
|
|
177
|
+
const variables = getConfig().variables ?? {};
|
|
178
|
+
const next = new Set(Object.keys(variables));
|
|
179
|
+
for (const name of applied) {
|
|
180
|
+
if (!next.has(name)) removeThemeLayer(root, name, handle);
|
|
181
|
+
}
|
|
182
|
+
for (const [name, value] of Object.entries(variables)) setThemeLayer(root, name, handle, value);
|
|
183
|
+
applied = next;
|
|
184
|
+
});
|
|
185
|
+
let released = false;
|
|
186
|
+
return () => {
|
|
187
|
+
if (released) return;
|
|
188
|
+
released = true;
|
|
189
|
+
stop();
|
|
190
|
+
for (const name of applied) removeThemeLayer(root, name, handle);
|
|
191
|
+
applied.clear();
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
return { config: getConfig, setTheme, resolveClass, applyTo };
|
|
129
195
|
}
|
|
130
196
|
function componentAdapter(config) {
|
|
131
197
|
const theme = createTheme({ prefix: config.prefix });
|
|
198
|
+
const reprefix = (cls, prefix) => prefix !== config.prefix && cls.startsWith(`${config.prefix}-`) ? `${prefix}-${cls.slice(config.prefix.length + 1)}` : cls;
|
|
132
199
|
const components = {};
|
|
133
200
|
for (const [name, mapping] of Object.entries(config.components)) {
|
|
134
201
|
const factory = tagFactory(mapping.tag || "div");
|
|
135
|
-
components[name] = (props = {}) => {
|
|
202
|
+
components[name] = (props = {}, children) => {
|
|
136
203
|
const { variant, size, class: userClass, ...rest } = props;
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
204
|
+
const themeClasses = () => {
|
|
205
|
+
const current = theme.config();
|
|
206
|
+
const overrides = current.classOverrides ?? {};
|
|
207
|
+
const pick = (key, fallback) => Object.hasOwn(overrides, key) ? overrides[key] : reprefix(fallback, current.prefix);
|
|
208
|
+
const classes = [pick(name, mapping.baseClass)];
|
|
209
|
+
const variantClass = ownString(mapping.variants, variant);
|
|
210
|
+
if (variant && variantClass) {
|
|
211
|
+
classes.push(pick(`${name}-${variant}`, variantClass));
|
|
212
|
+
}
|
|
213
|
+
const sizeClass = ownString(mapping.sizes, size);
|
|
214
|
+
if (size && sizeClass) {
|
|
215
|
+
classes.push(pick(`${name}-${size}`, sizeClass));
|
|
216
|
+
}
|
|
217
|
+
return classes.filter(Boolean).join(" ");
|
|
218
|
+
};
|
|
219
|
+
const finalClass = () => {
|
|
220
|
+
const base = themeClasses();
|
|
221
|
+
const extra = typeof userClass === "function" ? userClass() : userClass;
|
|
222
|
+
return typeof extra === "string" && extra ? `${base} ${extra}` : base;
|
|
223
|
+
};
|
|
155
224
|
const mergedProps = {
|
|
156
225
|
...mapping.defaultProps,
|
|
157
226
|
...rest,
|
|
158
227
|
class: finalClass
|
|
159
228
|
};
|
|
160
|
-
return factory(mergedProps);
|
|
229
|
+
return children === void 0 ? factory(mergedProps) : factory(mergedProps, children);
|
|
161
230
|
};
|
|
162
231
|
}
|
|
163
232
|
return { name: config.name, components, theme };
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
notifySubscribers,
|
|
4
4
|
queueSignalNotification,
|
|
5
5
|
recordDependency
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5Q4R7HCL.js";
|
|
7
7
|
import {
|
|
8
8
|
DEV
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-NYNYSPK7.js";
|
|
10
10
|
|
|
11
11
|
// src/reactivity/batch.ts
|
|
12
12
|
var batchDepth = 0;
|