sibujs 2.1.0 → 3.0.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 +324 -273
- package/dist/browser.js +4 -4
- package/dist/build.cjs +363 -330
- package/dist/build.js +10 -10
- package/dist/cdn.global.js +8 -8
- package/dist/{chunk-ZAQSMOED.js → chunk-2JQUV4Y3.js} +4 -4
- package/dist/{chunk-GWWURC5M.js → chunk-2KM2724A.js} +2 -2
- package/dist/{chunk-NASX6ST2.js → chunk-4YTVESDX.js} +1 -1
- package/dist/chunk-5WD7BYTZ.js +152 -0
- package/dist/{chunk-RDTDJCAB.js → chunk-6QZO7MMG.js} +48 -16
- package/dist/{chunk-DRUZZAK4.js → chunk-DF3GTP4Q.js} +7 -2
- package/dist/{chunk-AMK2TYNW.js → chunk-INBOWHQ3.js} +14 -11
- package/dist/{chunk-O6EFQ3KT.js → chunk-KH4OE6WY.js} +5 -5
- package/dist/{chunk-V6C4FADE.js → chunk-KZA7ANXP.js} +3 -3
- package/dist/chunk-L4DAT4WU.js +400 -0
- package/dist/{chunk-WANSMF2L.js → chunk-L52H775O.js} +4 -4
- package/dist/{chunk-45YP72ZQ.js → chunk-NEWH4O5U.js} +1 -1
- package/dist/{chunk-ON5MMR2J.js → chunk-RJIRT46U.js} +4 -4
- package/dist/{chunk-P2HSJDDN.js → chunk-STFTTMO2.js} +2 -2
- package/dist/{chunk-WIPZPFBQ.js → chunk-UKMXT5T6.js} +1 -1
- package/dist/{chunk-KGYT6UO6.js → chunk-V65KTDZW.js} +3 -3
- package/dist/{chunk-CWBVQML6.js → chunk-VSNLICTS.js} +1 -1
- package/dist/{chunk-3DZP6OIT.js → chunk-XDKP4T7G.js} +2 -2
- package/dist/{chunk-TH2ILCYW.js → chunk-XVYB3J6C.js} +27 -33
- package/dist/{chunk-OJ3P4ECI.js → chunk-YMOIAHWA.js} +1 -1
- package/dist/data.cjs +332 -298
- package/dist/data.js +6 -6
- package/dist/devtools.cjs +353 -296
- package/dist/devtools.d.cts +1 -1
- package/dist/devtools.d.ts +1 -1
- package/dist/devtools.js +4 -4
- package/dist/ecosystem.cjs +332 -298
- package/dist/ecosystem.js +7 -7
- package/dist/extras.cjs +372 -328
- package/dist/extras.d.cts +1 -1
- package/dist/extras.d.ts +1 -1
- package/dist/extras.js +19 -19
- package/dist/index.cjs +363 -330
- package/dist/index.d.cts +26 -36
- package/dist/index.d.ts +26 -36
- package/dist/index.js +10 -10
- package/dist/{introspect-DnIpHQQz.d.ts → introspect-BZWKvQUZ.d.ts} +2 -3
- package/dist/{introspect-2TOlQ7oa.d.cts → introspect-DsJlDD2T.d.cts} +2 -3
- package/dist/motion.cjs +147 -123
- package/dist/motion.js +3 -3
- package/dist/patterns.cjs +332 -298
- package/dist/patterns.js +5 -5
- package/dist/performance.cjs +315 -268
- package/dist/performance.js +4 -4
- package/dist/plugins.cjs +332 -266
- package/dist/plugins.js +6 -6
- package/dist/ssr.cjs +340 -270
- package/dist/ssr.js +7 -7
- package/dist/testing.cjs +167 -146
- package/dist/testing.js +2 -2
- package/dist/ui.cjs +324 -294
- package/dist/ui.js +6 -6
- package/dist/widgets.cjs +332 -298
- package/dist/widgets.js +6 -6
- package/package.json +1 -1
- package/dist/chunk-QO3WC6FS.js +0 -384
- package/dist/chunk-WZA53FXU.js +0 -149
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
notifySubscribers,
|
|
4
4
|
queueSignalNotification,
|
|
5
5
|
recordDependency
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-L4DAT4WU.js";
|
|
7
7
|
import {
|
|
8
8
|
isDev
|
|
9
9
|
} from "./chunk-LMLD24FC.js";
|
|
@@ -45,32 +45,64 @@ function flushBatch() {
|
|
|
45
45
|
var _g = globalThis;
|
|
46
46
|
var _isDev = isDev();
|
|
47
47
|
function signal(initial, options) {
|
|
48
|
-
const state = {
|
|
48
|
+
const state = {
|
|
49
|
+
value: initial,
|
|
50
|
+
__v: 0,
|
|
51
|
+
__sc: 0,
|
|
52
|
+
subsHead: null,
|
|
53
|
+
subsTail: null,
|
|
54
|
+
__activeNode: null,
|
|
55
|
+
__name: void 0
|
|
56
|
+
};
|
|
49
57
|
const debugName = _isDev ? options?.name : void 0;
|
|
50
58
|
const equalsFn = options?.equals;
|
|
51
|
-
if (debugName)
|
|
52
|
-
state.__name = debugName;
|
|
53
|
-
}
|
|
59
|
+
if (debugName) state.__name = debugName;
|
|
54
60
|
function get() {
|
|
55
61
|
recordDependency(state);
|
|
56
62
|
return state.value;
|
|
57
63
|
}
|
|
58
64
|
get.__signal = state;
|
|
59
65
|
if (debugName) get.__name = debugName;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
66
|
+
let set;
|
|
67
|
+
if (equalsFn) {
|
|
68
|
+
set = (next) => {
|
|
69
|
+
const prev = state.value;
|
|
70
|
+
const newValue = typeof next === "function" ? next(prev) : next;
|
|
71
|
+
if (equalsFn(prev, newValue)) return;
|
|
72
|
+
state.value = newValue;
|
|
73
|
+
state.__v++;
|
|
74
|
+
if (_isDev) {
|
|
75
|
+
const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
76
|
+
if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
|
|
77
|
+
}
|
|
78
|
+
if (!enqueueBatchedSignal(state)) {
|
|
79
|
+
notifySubscribers(state);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
} else if (_isDev) {
|
|
83
|
+
set = (next) => {
|
|
84
|
+
const prev = state.value;
|
|
85
|
+
const newValue = typeof next === "function" ? next(prev) : next;
|
|
86
|
+
if (Object.is(newValue, prev)) return;
|
|
65
87
|
state.value = newValue;
|
|
88
|
+
state.__v++;
|
|
66
89
|
const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
67
|
-
if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue, newValue });
|
|
68
|
-
|
|
90
|
+
if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
|
|
91
|
+
if (!enqueueBatchedSignal(state)) {
|
|
92
|
+
notifySubscribers(state);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
} else {
|
|
96
|
+
set = (next) => {
|
|
97
|
+
const prev = state.value;
|
|
98
|
+
const newValue = typeof next === "function" ? next(prev) : next;
|
|
99
|
+
if (Object.is(newValue, prev)) return;
|
|
69
100
|
state.value = newValue;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
101
|
+
state.__v++;
|
|
102
|
+
if (!enqueueBatchedSignal(state)) {
|
|
103
|
+
notifySubscribers(state);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
74
106
|
}
|
|
75
107
|
if (_isDev) {
|
|
76
108
|
const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
retrack,
|
|
4
4
|
track,
|
|
5
5
|
trackingSuspended
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-L4DAT4WU.js";
|
|
7
7
|
import {
|
|
8
8
|
devAssert
|
|
9
9
|
} from "./chunk-LMLD24FC.js";
|
|
@@ -16,6 +16,7 @@ function derived(getter, options) {
|
|
|
16
16
|
const cs = {};
|
|
17
17
|
cs._d = false;
|
|
18
18
|
cs._g = getter;
|
|
19
|
+
cs.__v = 0;
|
|
19
20
|
const markDirty = () => {
|
|
20
21
|
if (cs._d) return;
|
|
21
22
|
cs._d = true;
|
|
@@ -45,11 +46,14 @@ function derived(getter, options) {
|
|
|
45
46
|
evaluating = true;
|
|
46
47
|
let threw = true;
|
|
47
48
|
try {
|
|
49
|
+
const prev = cs._v;
|
|
48
50
|
retrack(() => {
|
|
49
|
-
|
|
51
|
+
const next = getter();
|
|
52
|
+
cs._v = equals && cs._v !== void 0 ? equals(cs._v, next) ? cs._v : next : next;
|
|
50
53
|
cs._d = false;
|
|
51
54
|
threw = false;
|
|
52
55
|
}, markDirty);
|
|
56
|
+
if (!Object.is(prev, cs._v)) cs.__v++;
|
|
53
57
|
} finally {
|
|
54
58
|
evaluating = false;
|
|
55
59
|
if (threw) cs._d = true;
|
|
@@ -69,6 +73,7 @@ function derived(getter, options) {
|
|
|
69
73
|
cs._d = false;
|
|
70
74
|
threw = false;
|
|
71
75
|
}, markDirty);
|
|
76
|
+
if (!Object.is(oldValue, cs._v)) cs.__v++;
|
|
72
77
|
} finally {
|
|
73
78
|
evaluating = false;
|
|
74
79
|
if (threw) cs._d = true;
|
|
@@ -139,28 +139,28 @@ import {
|
|
|
139
139
|
use,
|
|
140
140
|
var_,
|
|
141
141
|
video
|
|
142
|
-
} from "./chunk-
|
|
142
|
+
} from "./chunk-VSNLICTS.js";
|
|
143
143
|
import {
|
|
144
144
|
watch
|
|
145
|
-
} from "./chunk-
|
|
145
|
+
} from "./chunk-NEWH4O5U.js";
|
|
146
146
|
import {
|
|
147
147
|
trustHTML
|
|
148
148
|
} from "./chunk-JYD2PWXH.js";
|
|
149
149
|
import {
|
|
150
150
|
context
|
|
151
|
-
} from "./chunk-
|
|
151
|
+
} from "./chunk-YMOIAHWA.js";
|
|
152
152
|
import {
|
|
153
153
|
SVG_NS,
|
|
154
154
|
bindChildNode,
|
|
155
155
|
tagFactory
|
|
156
|
-
} from "./chunk-
|
|
156
|
+
} from "./chunk-STFTTMO2.js";
|
|
157
157
|
import {
|
|
158
158
|
bindAttribute,
|
|
159
159
|
bindDynamic
|
|
160
|
-
} from "./chunk-
|
|
160
|
+
} from "./chunk-UKMXT5T6.js";
|
|
161
161
|
import {
|
|
162
162
|
derived
|
|
163
|
-
} from "./chunk-
|
|
163
|
+
} from "./chunk-DF3GTP4Q.js";
|
|
164
164
|
import {
|
|
165
165
|
checkLeaks,
|
|
166
166
|
dispose,
|
|
@@ -174,7 +174,7 @@ import {
|
|
|
174
174
|
import {
|
|
175
175
|
effect,
|
|
176
176
|
on
|
|
177
|
-
} from "./chunk-
|
|
177
|
+
} from "./chunk-5WD7BYTZ.js";
|
|
178
178
|
import {
|
|
179
179
|
disableSSR,
|
|
180
180
|
enableSSR,
|
|
@@ -188,7 +188,7 @@ import {
|
|
|
188
188
|
enqueueBatchedSignal,
|
|
189
189
|
isBatching,
|
|
190
190
|
signal
|
|
191
|
-
} from "./chunk-
|
|
191
|
+
} from "./chunk-6QZO7MMG.js";
|
|
192
192
|
import {
|
|
193
193
|
notifySubscribers,
|
|
194
194
|
recordDependency,
|
|
@@ -196,7 +196,7 @@ import {
|
|
|
196
196
|
setMaxDrainIterations,
|
|
197
197
|
track,
|
|
198
198
|
untracked
|
|
199
|
-
} from "./chunk-
|
|
199
|
+
} from "./chunk-L4DAT4WU.js";
|
|
200
200
|
import {
|
|
201
201
|
__export,
|
|
202
202
|
devAssert,
|
|
@@ -2845,7 +2845,10 @@ function getMemoizedFallback(fallbackFn, error, retry) {
|
|
|
2845
2845
|
}
|
|
2846
2846
|
return factory();
|
|
2847
2847
|
}
|
|
2848
|
-
function ErrorBoundary(
|
|
2848
|
+
function ErrorBoundary(optionsOrChildren, maybeChildren) {
|
|
2849
|
+
const children = typeof optionsOrChildren === "function" ? optionsOrChildren : maybeChildren;
|
|
2850
|
+
const options = typeof optionsOrChildren === "function" ? {} : optionsOrChildren;
|
|
2851
|
+
const { fallback, onError, resetKeys } = options;
|
|
2849
2852
|
injectStyles2();
|
|
2850
2853
|
const [error, setError] = signal(null);
|
|
2851
2854
|
const retry = () => {
|
|
@@ -2920,7 +2923,7 @@ function ErrorBoundary({ nodes, fallback, onError, resetKeys }) {
|
|
|
2920
2923
|
return tryRenderFallback(currentError);
|
|
2921
2924
|
}
|
|
2922
2925
|
try {
|
|
2923
|
-
const result =
|
|
2926
|
+
const result = children();
|
|
2924
2927
|
if (result && typeof result.then === "function") {
|
|
2925
2928
|
const asyncContainer = div({ class: "sibu-error-async" });
|
|
2926
2929
|
asyncContainer.appendChild(span({ class: "sibu-lazy-loading", nodes: "Loading..." }));
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
bindAttribute
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UKMXT5T6.js";
|
|
4
4
|
import {
|
|
5
5
|
derived
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DF3GTP4Q.js";
|
|
7
7
|
import {
|
|
8
8
|
dispose,
|
|
9
9
|
registerDisposer
|
|
10
10
|
} from "./chunk-2UPRY23K.js";
|
|
11
11
|
import {
|
|
12
12
|
effect
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-5WD7BYTZ.js";
|
|
14
14
|
import {
|
|
15
15
|
signal
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-6QZO7MMG.js";
|
|
17
17
|
import {
|
|
18
18
|
track
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-L4DAT4WU.js";
|
|
20
20
|
|
|
21
21
|
// src/ui/form.ts
|
|
22
22
|
function required(message = "This field is required") {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
derived
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DF3GTP4Q.js";
|
|
4
4
|
import {
|
|
5
5
|
effect
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-5WD7BYTZ.js";
|
|
7
7
|
import {
|
|
8
8
|
batch,
|
|
9
9
|
signal
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-6QZO7MMG.js";
|
|
11
11
|
|
|
12
12
|
// src/patterns/machine.ts
|
|
13
13
|
function machine(config) {
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import {
|
|
2
|
+
devWarn,
|
|
3
|
+
isDev
|
|
4
|
+
} from "./chunk-LMLD24FC.js";
|
|
5
|
+
|
|
6
|
+
// src/reactivity/track.ts
|
|
7
|
+
var _isDev = isDev();
|
|
8
|
+
var POOL_MAX = 4096;
|
|
9
|
+
var nodePool = [];
|
|
10
|
+
function createNode() {
|
|
11
|
+
return {
|
|
12
|
+
sig: null,
|
|
13
|
+
sub: null,
|
|
14
|
+
epoch: 0,
|
|
15
|
+
sigPrev: null,
|
|
16
|
+
sigNext: null,
|
|
17
|
+
subPrev: null,
|
|
18
|
+
subNext: null,
|
|
19
|
+
prevActive: null
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function allocNode(sig, sub, epoch) {
|
|
23
|
+
const n = nodePool.pop();
|
|
24
|
+
if (n) {
|
|
25
|
+
n.sig = sig;
|
|
26
|
+
n.sub = sub;
|
|
27
|
+
n.epoch = epoch;
|
|
28
|
+
return n;
|
|
29
|
+
}
|
|
30
|
+
const fresh = createNode();
|
|
31
|
+
fresh.sig = sig;
|
|
32
|
+
fresh.sub = sub;
|
|
33
|
+
fresh.epoch = epoch;
|
|
34
|
+
return fresh;
|
|
35
|
+
}
|
|
36
|
+
function freeNode(node) {
|
|
37
|
+
node.sig = null;
|
|
38
|
+
node.sub = null;
|
|
39
|
+
node.sigPrev = null;
|
|
40
|
+
node.sigNext = null;
|
|
41
|
+
node.subPrev = null;
|
|
42
|
+
node.subNext = null;
|
|
43
|
+
node.prevActive = null;
|
|
44
|
+
if (nodePool.length < POOL_MAX) nodePool.push(node);
|
|
45
|
+
}
|
|
46
|
+
function linkSignal(sig, node) {
|
|
47
|
+
const oldHead = sig.subsHead ?? null;
|
|
48
|
+
node.sigPrev = null;
|
|
49
|
+
node.sigNext = oldHead;
|
|
50
|
+
if (oldHead) oldHead.sigPrev = node;
|
|
51
|
+
else sig.subsTail = node;
|
|
52
|
+
sig.subsHead = node;
|
|
53
|
+
sig.__sc = (sig.__sc ?? 0) + 1;
|
|
54
|
+
}
|
|
55
|
+
function unlinkSignal(node) {
|
|
56
|
+
const sig = node.sig;
|
|
57
|
+
if (!sig) return;
|
|
58
|
+
const prev = node.sigPrev;
|
|
59
|
+
const next = node.sigNext;
|
|
60
|
+
if (prev) prev.sigNext = next;
|
|
61
|
+
else sig.subsHead = next;
|
|
62
|
+
if (next) next.sigPrev = prev;
|
|
63
|
+
else sig.subsTail = prev;
|
|
64
|
+
sig.__sc = (sig.__sc ?? 1) - 1;
|
|
65
|
+
if (sig.__activeNode === node) sig.__activeNode = node.prevActive;
|
|
66
|
+
if (sig.__sc === 0) {
|
|
67
|
+
sig.subsHead = null;
|
|
68
|
+
sig.subsTail = null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function linkSub(sub, node) {
|
|
72
|
+
const oldTail = sub.depsTail ?? null;
|
|
73
|
+
node.subPrev = oldTail;
|
|
74
|
+
node.subNext = null;
|
|
75
|
+
if (oldTail) oldTail.subNext = node;
|
|
76
|
+
else sub.depsHead = node;
|
|
77
|
+
sub.depsTail = node;
|
|
78
|
+
}
|
|
79
|
+
function unlinkSub(node) {
|
|
80
|
+
const sub = node.sub;
|
|
81
|
+
if (!sub) return;
|
|
82
|
+
const prev = node.subPrev;
|
|
83
|
+
const next = node.subNext;
|
|
84
|
+
if (prev) prev.subNext = next;
|
|
85
|
+
else sub.depsHead = next;
|
|
86
|
+
if (next) next.subPrev = prev;
|
|
87
|
+
else sub.depsTail = prev;
|
|
88
|
+
}
|
|
89
|
+
var currentSubscriber = null;
|
|
90
|
+
var suspendSavedSub = null;
|
|
91
|
+
var notifyDepth = 0;
|
|
92
|
+
var pendingQueue = [];
|
|
93
|
+
var pendingSet = /* @__PURE__ */ new Set();
|
|
94
|
+
var propagateStack = [];
|
|
95
|
+
function safeInvoke(sub) {
|
|
96
|
+
try {
|
|
97
|
+
sub();
|
|
98
|
+
} catch (err) {
|
|
99
|
+
if (_isDev) devWarn(`Subscriber threw during notification: ${err instanceof Error ? err.message : String(err)}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
var suspendDepth = 0;
|
|
103
|
+
var trackingSuspended = false;
|
|
104
|
+
function suspendTracking() {
|
|
105
|
+
if (suspendDepth === 0) {
|
|
106
|
+
suspendSavedSub = currentSubscriber;
|
|
107
|
+
currentSubscriber = null;
|
|
108
|
+
trackingSuspended = true;
|
|
109
|
+
}
|
|
110
|
+
suspendDepth++;
|
|
111
|
+
}
|
|
112
|
+
function resumeTracking() {
|
|
113
|
+
suspendDepth--;
|
|
114
|
+
if (suspendDepth === 0) {
|
|
115
|
+
currentSubscriber = suspendSavedSub;
|
|
116
|
+
suspendSavedSub = null;
|
|
117
|
+
trackingSuspended = false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function untracked(fn) {
|
|
121
|
+
suspendTracking();
|
|
122
|
+
try {
|
|
123
|
+
return fn();
|
|
124
|
+
} finally {
|
|
125
|
+
resumeTracking();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
var subscriberEpochCounter = 0;
|
|
129
|
+
function retrack(effectFn, subscriber) {
|
|
130
|
+
const prev = currentSubscriber;
|
|
131
|
+
currentSubscriber = subscriber;
|
|
132
|
+
const sub = subscriber;
|
|
133
|
+
const epoch = ++subscriberEpochCounter;
|
|
134
|
+
sub._epoch = epoch;
|
|
135
|
+
sub._structDirty = false;
|
|
136
|
+
for (let n = sub.depsHead ?? null; n !== null; n = n.subNext) {
|
|
137
|
+
const sig = n.sig;
|
|
138
|
+
n.prevActive = sig.__activeNode ?? null;
|
|
139
|
+
sig.__activeNode = n;
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
effectFn();
|
|
143
|
+
} finally {
|
|
144
|
+
currentSubscriber = prev;
|
|
145
|
+
let node = sub.depsHead ?? null;
|
|
146
|
+
while (node !== null) {
|
|
147
|
+
const next = node.subNext;
|
|
148
|
+
const sig = node.sig;
|
|
149
|
+
sig.__activeNode = node.prevActive;
|
|
150
|
+
node.prevActive = null;
|
|
151
|
+
if (node.epoch !== epoch) {
|
|
152
|
+
unlinkSub(node);
|
|
153
|
+
unlinkSignal(node);
|
|
154
|
+
freeNode(node);
|
|
155
|
+
}
|
|
156
|
+
node = next;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function track(effectFn, subscriber) {
|
|
161
|
+
if (!subscriber) subscriber = effectFn;
|
|
162
|
+
cleanup(subscriber);
|
|
163
|
+
const prev = currentSubscriber;
|
|
164
|
+
currentSubscriber = subscriber;
|
|
165
|
+
try {
|
|
166
|
+
effectFn();
|
|
167
|
+
} finally {
|
|
168
|
+
currentSubscriber = prev;
|
|
169
|
+
const sub2 = subscriber;
|
|
170
|
+
for (let n = sub2.depsHead ?? null; n !== null; n = n.subNext) {
|
|
171
|
+
const sig = n.sig;
|
|
172
|
+
sig.__activeNode = n.prevActive;
|
|
173
|
+
n.prevActive = null;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const sub = subscriber;
|
|
177
|
+
return sub._dispose ?? (sub._dispose = () => cleanup(subscriber));
|
|
178
|
+
}
|
|
179
|
+
function recordDependency(signal) {
|
|
180
|
+
if (!currentSubscriber) return;
|
|
181
|
+
const sub = currentSubscriber;
|
|
182
|
+
const sig = signal;
|
|
183
|
+
const epoch = sub._epoch ?? 0;
|
|
184
|
+
const active = sig.__activeNode ?? null;
|
|
185
|
+
if (active !== null && active.sub === sub) {
|
|
186
|
+
active.epoch = epoch;
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const node = allocNode(signal, sub, epoch);
|
|
190
|
+
node.prevActive = active;
|
|
191
|
+
sig.__activeNode = node;
|
|
192
|
+
linkSub(sub, node);
|
|
193
|
+
linkSignal(sig, node);
|
|
194
|
+
sub._structDirty = true;
|
|
195
|
+
}
|
|
196
|
+
function cleanup(subscriber) {
|
|
197
|
+
const sub = subscriber;
|
|
198
|
+
let node = sub.depsHead ?? null;
|
|
199
|
+
sub.depsHead = null;
|
|
200
|
+
sub.depsTail = null;
|
|
201
|
+
while (node) {
|
|
202
|
+
const next = node.subNext;
|
|
203
|
+
unlinkSignal(node);
|
|
204
|
+
freeNode(node);
|
|
205
|
+
node = next;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
var maxSubscriberRepeats = 50;
|
|
209
|
+
var maxDrainIterations = 1e6;
|
|
210
|
+
var drainEpoch = 0;
|
|
211
|
+
function setMaxDrainIterations(n) {
|
|
212
|
+
const prev = maxDrainIterations;
|
|
213
|
+
if (Number.isFinite(n) && n > 0) maxDrainIterations = Math.floor(n);
|
|
214
|
+
return prev;
|
|
215
|
+
}
|
|
216
|
+
function tickRepeat(sub) {
|
|
217
|
+
const s = sub;
|
|
218
|
+
if (s._runEpoch !== drainEpoch) {
|
|
219
|
+
s._runEpoch = drainEpoch;
|
|
220
|
+
s._runs = 1;
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
s._runs = (s._runs ?? 0) + 1;
|
|
224
|
+
return s._runs > maxSubscriberRepeats;
|
|
225
|
+
}
|
|
226
|
+
function cycleError(sub) {
|
|
227
|
+
if (typeof console !== "undefined") {
|
|
228
|
+
const name = sub.__name ?? "<unnamed>";
|
|
229
|
+
console.error(
|
|
230
|
+
`[SibuJS] subscriber "${name}" fired more than ${maxSubscriberRepeats} times \u2014 likely a write-reads-self cycle between effects/signals. Breaking to prevent infinite loop.`
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function absoluteDrainError() {
|
|
235
|
+
if (typeof console !== "undefined") {
|
|
236
|
+
console.error(
|
|
237
|
+
`[SibuJS] Notification drain exceeded ${maxDrainIterations} iterations \u2014 absolute safety net tripped. Breaking to prevent infinite loop.`
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function drainQueue() {
|
|
242
|
+
let i = 0;
|
|
243
|
+
while (i < pendingQueue.length) {
|
|
244
|
+
if (i >= maxDrainIterations) {
|
|
245
|
+
absoluteDrainError();
|
|
246
|
+
break;
|
|
247
|
+
}
|
|
248
|
+
const sub = pendingQueue[i++];
|
|
249
|
+
if (tickRepeat(sub)) {
|
|
250
|
+
cycleError(sub);
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
pendingSet.delete(sub);
|
|
254
|
+
safeInvoke(sub);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function drainNotificationQueue() {
|
|
258
|
+
if (notifyDepth > 0) return;
|
|
259
|
+
notifyDepth++;
|
|
260
|
+
drainEpoch++;
|
|
261
|
+
try {
|
|
262
|
+
drainQueue();
|
|
263
|
+
} finally {
|
|
264
|
+
notifyDepth--;
|
|
265
|
+
if (notifyDepth === 0) {
|
|
266
|
+
pendingQueue.length = 0;
|
|
267
|
+
pendingSet.clear();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
function propagateDirty(sub) {
|
|
272
|
+
sub();
|
|
273
|
+
const rootSig = sub._sig;
|
|
274
|
+
if (!rootSig) return;
|
|
275
|
+
const stack = propagateStack;
|
|
276
|
+
const baseLen = stack.length;
|
|
277
|
+
stack.push(rootSig);
|
|
278
|
+
while (stack.length > baseLen) {
|
|
279
|
+
const sig = stack.pop();
|
|
280
|
+
let node = sig.subsHead ?? null;
|
|
281
|
+
while (node) {
|
|
282
|
+
const s = node.sub;
|
|
283
|
+
if (s) {
|
|
284
|
+
if (s._c) {
|
|
285
|
+
const nSig = s._sig;
|
|
286
|
+
if (nSig) {
|
|
287
|
+
if (!nSig._d) {
|
|
288
|
+
nSig._d = true;
|
|
289
|
+
stack.push(nSig);
|
|
290
|
+
}
|
|
291
|
+
} else {
|
|
292
|
+
s();
|
|
293
|
+
}
|
|
294
|
+
} else if (!pendingSet.has(s)) {
|
|
295
|
+
pendingSet.add(s);
|
|
296
|
+
pendingQueue.push(s);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
node = node.sigNext;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
function queueSignalNotification(signal) {
|
|
304
|
+
const sig = signal;
|
|
305
|
+
let node = sig.subsHead ?? null;
|
|
306
|
+
while (node) {
|
|
307
|
+
const s = node.sub;
|
|
308
|
+
if (s) {
|
|
309
|
+
if (s._c) {
|
|
310
|
+
propagateDirty(s);
|
|
311
|
+
} else if (!pendingSet.has(s)) {
|
|
312
|
+
pendingSet.add(s);
|
|
313
|
+
pendingQueue.push(s);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
node = node.sigNext;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
function notifySubscribers(signal) {
|
|
320
|
+
const sig = signal;
|
|
321
|
+
const head = sig.subsHead;
|
|
322
|
+
if (!head) return;
|
|
323
|
+
if (notifyDepth > 0) {
|
|
324
|
+
let node = head;
|
|
325
|
+
while (node) {
|
|
326
|
+
const s = node.sub;
|
|
327
|
+
if (s) {
|
|
328
|
+
if (s._c) {
|
|
329
|
+
propagateDirty(s);
|
|
330
|
+
} else if (!pendingSet.has(s)) {
|
|
331
|
+
pendingSet.add(s);
|
|
332
|
+
pendingQueue.push(s);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
node = node.sigNext;
|
|
336
|
+
}
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
notifyDepth++;
|
|
340
|
+
drainEpoch++;
|
|
341
|
+
try {
|
|
342
|
+
let node = head;
|
|
343
|
+
while (node) {
|
|
344
|
+
const s = node.sub;
|
|
345
|
+
if (s) {
|
|
346
|
+
if (s._c) {
|
|
347
|
+
propagateDirty(s);
|
|
348
|
+
} else if (!pendingSet.has(s)) {
|
|
349
|
+
pendingSet.add(s);
|
|
350
|
+
pendingQueue.push(s);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
node = node.sigNext;
|
|
354
|
+
}
|
|
355
|
+
drainQueue();
|
|
356
|
+
} finally {
|
|
357
|
+
notifyDepth--;
|
|
358
|
+
if (notifyDepth === 0) {
|
|
359
|
+
pendingQueue.length = 0;
|
|
360
|
+
pendingSet.clear();
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
function getSubscriberCount(signal) {
|
|
365
|
+
return signal.__sc ?? 0;
|
|
366
|
+
}
|
|
367
|
+
function getSubscriberDeps(subscriber) {
|
|
368
|
+
const sub = subscriber;
|
|
369
|
+
const out = [];
|
|
370
|
+
let node = sub.depsHead ?? null;
|
|
371
|
+
while (node) {
|
|
372
|
+
if (node.sig) out.push(node.sig);
|
|
373
|
+
node = node.subNext;
|
|
374
|
+
}
|
|
375
|
+
return out;
|
|
376
|
+
}
|
|
377
|
+
function forEachSubscriber(signal, visit) {
|
|
378
|
+
let node = signal.subsHead ?? null;
|
|
379
|
+
while (node) {
|
|
380
|
+
const s = node.sub;
|
|
381
|
+
if (s) visit(s);
|
|
382
|
+
node = node.sigNext;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export {
|
|
387
|
+
trackingSuspended,
|
|
388
|
+
untracked,
|
|
389
|
+
retrack,
|
|
390
|
+
track,
|
|
391
|
+
recordDependency,
|
|
392
|
+
cleanup,
|
|
393
|
+
setMaxDrainIterations,
|
|
394
|
+
drainNotificationQueue,
|
|
395
|
+
queueSignalNotification,
|
|
396
|
+
notifySubscribers,
|
|
397
|
+
getSubscriberCount,
|
|
398
|
+
getSubscriberDeps,
|
|
399
|
+
forEachSubscriber
|
|
400
|
+
};
|
|
@@ -3,17 +3,17 @@ import {
|
|
|
3
3
|
} from "./chunk-3JHCYHWN.js";
|
|
4
4
|
import {
|
|
5
5
|
tagFactory
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-STFTTMO2.js";
|
|
7
7
|
import {
|
|
8
8
|
derived
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DF3GTP4Q.js";
|
|
10
10
|
import {
|
|
11
11
|
effect
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-5WD7BYTZ.js";
|
|
13
13
|
import {
|
|
14
14
|
batch,
|
|
15
15
|
signal
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-6QZO7MMG.js";
|
|
17
17
|
|
|
18
18
|
// src/ecosystem/adapters/mobx.ts
|
|
19
19
|
function mobXAdapter(options) {
|