sibujs 1.4.0 → 1.5.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/README.md +105 -119
- package/dist/browser.cjs +53 -14
- package/dist/browser.d.cts +14 -9
- package/dist/browser.d.ts +14 -9
- package/dist/browser.js +4 -4
- package/dist/build.cjs +124 -42
- package/dist/build.d.cts +1 -1
- package/dist/build.d.ts +1 -1
- package/dist/build.js +10 -10
- package/dist/cdn.global.js +7 -7
- package/dist/chunk-5ZYQ6KDD.js +154 -0
- package/dist/chunk-6BMPXPUW.js +26 -0
- package/dist/chunk-7GRNSCFT.js +1097 -0
- package/dist/chunk-BGTHZHJ5.js +1016 -0
- package/dist/chunk-BMPL52BF.js +654 -0
- package/dist/chunk-GJPXRJ45.js +37 -0
- package/dist/chunk-JCDUJN2F.js +2779 -0
- package/dist/chunk-K4G4ZQNR.js +286 -0
- package/dist/chunk-MB6QFH3I.js +2776 -0
- package/dist/chunk-MYRV7VDM.js +742 -0
- package/dist/chunk-NZIIMDWI.js +84 -0
- package/dist/chunk-P3XWXJZU.js +282 -0
- package/dist/chunk-PDZQY43A.js +616 -0
- package/dist/chunk-RJ46C3CS.js +1293 -0
- package/dist/chunk-SFKNRVCU.js +292 -0
- package/dist/chunk-TDGZL5CU.js +365 -0
- package/dist/chunk-VAPYJN4X.js +368 -0
- package/dist/chunk-VQDZK23A.js +1023 -0
- package/dist/chunk-VQNQZCWJ.js +61 -0
- package/dist/chunk-XHK6BDAJ.js +76 -0
- package/dist/chunk-XUEEGU5O.js +409 -0
- package/dist/contracts-ey_Qh8ef.d.cts +239 -0
- package/dist/contracts-ey_Qh8ef.d.ts +239 -0
- package/dist/customElement-BL3Uo8dL.d.cts +318 -0
- package/dist/customElement-BL3Uo8dL.d.ts +318 -0
- package/dist/data.cjs +52 -11
- package/dist/data.js +6 -6
- package/dist/devtools.cjs +22 -24
- package/dist/devtools.js +26 -28
- package/dist/ecosystem.cjs +31 -6
- package/dist/ecosystem.d.cts +4 -4
- package/dist/ecosystem.d.ts +4 -4
- package/dist/ecosystem.js +7 -7
- package/dist/extras.cjs +304 -108
- package/dist/extras.d.cts +3 -3
- package/dist/extras.d.ts +3 -3
- package/dist/extras.js +19 -19
- package/dist/index.cjs +124 -42
- package/dist/index.d.cts +58 -48
- package/dist/index.d.ts +58 -48
- package/dist/index.js +10 -10
- package/dist/motion.cjs +13 -2
- package/dist/motion.d.cts +1 -1
- package/dist/motion.d.ts +1 -1
- package/dist/motion.js +3 -3
- package/dist/patterns.cjs +91 -24
- package/dist/patterns.d.cts +46 -12
- package/dist/patterns.d.ts +46 -12
- package/dist/patterns.js +5 -5
- package/dist/performance.cjs +97 -12
- package/dist/performance.d.cts +6 -1
- package/dist/performance.d.ts +6 -1
- package/dist/performance.js +5 -3
- package/dist/plugins.cjs +19 -13
- package/dist/plugins.d.cts +3 -3
- package/dist/plugins.d.ts +3 -3
- package/dist/plugins.js +16 -18
- package/dist/ssr.cjs +9 -0
- package/dist/ssr.d.cts +1 -1
- package/dist/ssr.d.ts +1 -1
- package/dist/ssr.js +7 -7
- package/dist/testing.js +2 -2
- package/dist/ui.cjs +130 -48
- package/dist/ui.d.cts +13 -16
- package/dist/ui.d.ts +13 -16
- package/dist/ui.js +6 -6
- package/dist/widgets.cjs +31 -6
- package/dist/widgets.js +5 -5
- package/package.json +1 -1
package/dist/data.cjs
CHANGED
|
@@ -138,12 +138,21 @@ function queueSignalNotification(signal2) {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
+
var MAX_DRAIN_ITERATIONS = 1e3;
|
|
141
142
|
function drainNotificationQueue() {
|
|
142
143
|
if (notifyDepth > 0) return;
|
|
143
144
|
notifyDepth++;
|
|
144
145
|
try {
|
|
145
146
|
let i = 0;
|
|
146
147
|
while (i < pendingQueue.length) {
|
|
148
|
+
if (i >= MAX_DRAIN_ITERATIONS) {
|
|
149
|
+
if (typeof console !== "undefined") {
|
|
150
|
+
console.error(
|
|
151
|
+
`[SibuJS] Notification queue exceeded ${MAX_DRAIN_ITERATIONS} iterations \u2014 likely an effect that writes to a signal it reads. Breaking to prevent infinite loop.`
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
147
156
|
safeInvoke(pendingQueue[i]);
|
|
148
157
|
i++;
|
|
149
158
|
}
|
|
@@ -310,21 +319,37 @@ function derived(getter, options) {
|
|
|
310
319
|
cs._v = getter();
|
|
311
320
|
}, markDirty);
|
|
312
321
|
const hook = globalThis.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
322
|
+
let evaluating = false;
|
|
313
323
|
function computedGetter() {
|
|
324
|
+
if (evaluating) {
|
|
325
|
+
throw new Error(
|
|
326
|
+
`[SibuJS] Circular dependency detected in derived${debugName ? ` "${debugName}"` : ""}. A derived signal cannot read itself (directly or through a chain).`
|
|
327
|
+
);
|
|
328
|
+
}
|
|
314
329
|
if (trackingSuspended) {
|
|
315
330
|
if (cs._d) {
|
|
316
|
-
|
|
317
|
-
|
|
331
|
+
evaluating = true;
|
|
332
|
+
try {
|
|
333
|
+
cs._d = false;
|
|
334
|
+
cs._v = getter();
|
|
335
|
+
} finally {
|
|
336
|
+
evaluating = false;
|
|
337
|
+
}
|
|
318
338
|
}
|
|
319
339
|
return cs._v;
|
|
320
340
|
}
|
|
321
341
|
recordDependency(cs);
|
|
322
342
|
if (cs._d) {
|
|
323
343
|
const oldValue = cs._v;
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
344
|
+
evaluating = true;
|
|
345
|
+
try {
|
|
346
|
+
track(() => {
|
|
347
|
+
cs._d = false;
|
|
348
|
+
cs._v = getter();
|
|
349
|
+
}, markDirty);
|
|
350
|
+
} finally {
|
|
351
|
+
evaluating = false;
|
|
352
|
+
}
|
|
328
353
|
if (hook && oldValue !== cs._v) {
|
|
329
354
|
hook.emit("computed:update", { signal: cs, oldValue, newValue: cs._v });
|
|
330
355
|
}
|
|
@@ -480,9 +505,13 @@ async function withRetry(fn, options, onRetry, signal2) {
|
|
|
480
505
|
const delay = calculateDelay(attempt, strategy, baseDelay, maxDelay, jitter);
|
|
481
506
|
onRetry?.(error, attempt, delay);
|
|
482
507
|
await new Promise((resolve, reject) => {
|
|
483
|
-
|
|
508
|
+
let onAbort = null;
|
|
509
|
+
const timer = setTimeout(() => {
|
|
510
|
+
if (onAbort && signal2) signal2.removeEventListener("abort", onAbort);
|
|
511
|
+
resolve();
|
|
512
|
+
}, delay);
|
|
484
513
|
if (signal2) {
|
|
485
|
-
|
|
514
|
+
onAbort = () => {
|
|
486
515
|
clearTimeout(timer);
|
|
487
516
|
reject(new DOMException("Aborted", "AbortError"));
|
|
488
517
|
};
|
|
@@ -633,9 +662,10 @@ function query(key, fetcher, options = {}) {
|
|
|
633
662
|
}
|
|
634
663
|
}
|
|
635
664
|
}
|
|
665
|
+
const keyChanged = currentKey !== key2;
|
|
636
666
|
currentKey = key2;
|
|
637
667
|
const entry = getOrCreateEntry(key2, initialData);
|
|
638
|
-
entry.subscribers++;
|
|
668
|
+
if (keyChanged || entry.subscribers === 0) entry.subscribers++;
|
|
639
669
|
if (entry.gcTimer !== null) {
|
|
640
670
|
clearTimeout(entry.gcTimer);
|
|
641
671
|
entry.gcTimer = null;
|
|
@@ -749,7 +779,9 @@ function mutation(mutationFn, options = {}) {
|
|
|
749
779
|
const [status, setStatus] = signal("idle");
|
|
750
780
|
const isSuccess = derived(() => status() === "success");
|
|
751
781
|
const isIdle = derived(() => status() === "idle");
|
|
782
|
+
let runId = 0;
|
|
752
783
|
async function execute(variables) {
|
|
784
|
+
const myRun = ++runId;
|
|
753
785
|
let context2;
|
|
754
786
|
batch(() => {
|
|
755
787
|
setLoading(true);
|
|
@@ -761,6 +793,7 @@ function mutation(mutationFn, options = {}) {
|
|
|
761
793
|
context2 = await options.onMutate(variables);
|
|
762
794
|
}
|
|
763
795
|
const result = await withRetry(() => mutationFn(variables), options.retry);
|
|
796
|
+
if (myRun !== runId) return result;
|
|
764
797
|
batch(() => {
|
|
765
798
|
setData(result);
|
|
766
799
|
setLoading(false);
|
|
@@ -771,6 +804,7 @@ function mutation(mutationFn, options = {}) {
|
|
|
771
804
|
return result;
|
|
772
805
|
} catch (err) {
|
|
773
806
|
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
807
|
+
if (myRun !== runId) throw errorObj;
|
|
774
808
|
batch(() => {
|
|
775
809
|
setError(errorObj);
|
|
776
810
|
setLoading(false);
|
|
@@ -782,6 +816,7 @@ function mutation(mutationFn, options = {}) {
|
|
|
782
816
|
}
|
|
783
817
|
}
|
|
784
818
|
function reset() {
|
|
819
|
+
runId++;
|
|
785
820
|
batch(() => {
|
|
786
821
|
setData(void 0);
|
|
787
822
|
setError(void 0);
|
|
@@ -1031,7 +1066,10 @@ function resource(sourceOrFetcher, fetcherOrOptions, maybeOptions) {
|
|
|
1031
1066
|
options.onSuccess?.(result);
|
|
1032
1067
|
} catch (err) {
|
|
1033
1068
|
if (version !== fetchVersion || disposed) return;
|
|
1034
|
-
if (err instanceof DOMException && err.name === "AbortError")
|
|
1069
|
+
if (err instanceof DOMException && err.name === "AbortError") {
|
|
1070
|
+
if (version === fetchVersion) setLoading(false);
|
|
1071
|
+
return;
|
|
1072
|
+
}
|
|
1035
1073
|
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
1036
1074
|
batch(() => {
|
|
1037
1075
|
setError(errorObj);
|
|
@@ -1285,6 +1323,7 @@ function socket(url, options) {
|
|
|
1285
1323
|
let reconnectTimer = null;
|
|
1286
1324
|
let heartbeatTimer = null;
|
|
1287
1325
|
let disposed = false;
|
|
1326
|
+
let manuallyClosed = false;
|
|
1288
1327
|
function getUrl() {
|
|
1289
1328
|
return typeof url === "function" ? url() : url;
|
|
1290
1329
|
}
|
|
@@ -1308,12 +1347,13 @@ function socket(url, options) {
|
|
|
1308
1347
|
ws.onclose = () => {
|
|
1309
1348
|
setStatus("closed");
|
|
1310
1349
|
stopHeartbeat();
|
|
1311
|
-
if (autoReconnect && !disposed && reconnectCount < maxReconnects) {
|
|
1350
|
+
if (autoReconnect && !disposed && !manuallyClosed && reconnectCount < maxReconnects) {
|
|
1312
1351
|
reconnectCount++;
|
|
1313
1352
|
reconnectTimer = setTimeout(() => {
|
|
1314
1353
|
connect();
|
|
1315
1354
|
}, reconnectDelay);
|
|
1316
1355
|
}
|
|
1356
|
+
manuallyClosed = false;
|
|
1317
1357
|
};
|
|
1318
1358
|
ws.onerror = () => {
|
|
1319
1359
|
};
|
|
@@ -1339,6 +1379,7 @@ function socket(url, options) {
|
|
|
1339
1379
|
}
|
|
1340
1380
|
}
|
|
1341
1381
|
function close() {
|
|
1382
|
+
manuallyClosed = true;
|
|
1342
1383
|
if (reconnectTimer !== null) {
|
|
1343
1384
|
clearTimeout(reconnectTimer);
|
|
1344
1385
|
reconnectTimer = null;
|
package/dist/data.js
CHANGED
|
@@ -19,14 +19,14 @@ import {
|
|
|
19
19
|
syncAdapter,
|
|
20
20
|
throttle,
|
|
21
21
|
withRetry
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
24
|
-
import "./chunk-
|
|
22
|
+
} from "./chunk-BGTHZHJ5.js";
|
|
23
|
+
import "./chunk-6BMPXPUW.js";
|
|
24
|
+
import "./chunk-XHK6BDAJ.js";
|
|
25
25
|
import "./chunk-CMBFNA7L.js";
|
|
26
|
-
import "./chunk-
|
|
26
|
+
import "./chunk-VQNQZCWJ.js";
|
|
27
27
|
import "./chunk-EUZND3CB.js";
|
|
28
|
-
import "./chunk-
|
|
29
|
-
import "./chunk-
|
|
28
|
+
import "./chunk-NZIIMDWI.js";
|
|
29
|
+
import "./chunk-K4G4ZQNR.js";
|
|
30
30
|
import "./chunk-5X6PP2UK.js";
|
|
31
31
|
export {
|
|
32
32
|
calculateDelay,
|
package/dist/devtools.cjs
CHANGED
|
@@ -1473,55 +1473,53 @@ function createTraceProfiler() {
|
|
|
1473
1473
|
}
|
|
1474
1474
|
const start = typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
1475
1475
|
let recording = true;
|
|
1476
|
-
|
|
1476
|
+
function now() {
|
|
1477
|
+
return (typeof performance !== "undefined" ? performance.now() : Date.now()) - start;
|
|
1478
|
+
}
|
|
1479
|
+
const onEffectCreate = (payload) => {
|
|
1477
1480
|
if (!recording) return;
|
|
1478
|
-
const now = (typeof performance !== "undefined" ? performance.now() : Date.now()) - start;
|
|
1479
|
-
const label = payload.name ?? "effect";
|
|
1480
1481
|
events.push({
|
|
1481
|
-
name:
|
|
1482
|
+
name: payload.name ?? "effect",
|
|
1482
1483
|
cat: "effect",
|
|
1483
|
-
ph: "
|
|
1484
|
-
ts: Math.floor(now * 1e3),
|
|
1484
|
+
ph: "I",
|
|
1485
|
+
ts: Math.floor(now() * 1e3),
|
|
1485
1486
|
tid: 0,
|
|
1486
1487
|
pid: 0
|
|
1487
1488
|
});
|
|
1488
1489
|
};
|
|
1489
|
-
const
|
|
1490
|
+
const onEffectDestroy = (payload) => {
|
|
1490
1491
|
if (!recording) return;
|
|
1491
|
-
const now = (typeof performance !== "undefined" ? performance.now() : Date.now()) - start;
|
|
1492
|
-
const label = payload.name ?? "effect";
|
|
1493
1492
|
events.push({
|
|
1494
|
-
name:
|
|
1493
|
+
name: payload.name ?? "effect:destroy",
|
|
1495
1494
|
cat: "effect",
|
|
1496
|
-
ph: "
|
|
1497
|
-
ts: Math.floor(now * 1e3),
|
|
1495
|
+
ph: "I",
|
|
1496
|
+
ts: Math.floor(now() * 1e3),
|
|
1498
1497
|
tid: 0,
|
|
1499
1498
|
pid: 0
|
|
1500
1499
|
});
|
|
1501
1500
|
};
|
|
1502
|
-
const
|
|
1501
|
+
const onSignalUpdate = (payload) => {
|
|
1503
1502
|
if (!recording) return;
|
|
1504
|
-
const
|
|
1505
|
-
const label = payload.name ?? "signal";
|
|
1503
|
+
const p = payload;
|
|
1506
1504
|
events.push({
|
|
1507
|
-
name:
|
|
1505
|
+
name: p.name ?? "signal",
|
|
1508
1506
|
cat: "signal",
|
|
1509
1507
|
ph: "I",
|
|
1510
|
-
ts: Math.floor(now * 1e3),
|
|
1508
|
+
ts: Math.floor(now() * 1e3),
|
|
1511
1509
|
tid: 0,
|
|
1512
1510
|
pid: 0,
|
|
1513
|
-
args:
|
|
1511
|
+
args: p.oldValue !== void 0 ? { oldValue: String(p.oldValue), newValue: String(p.newValue) } : void 0
|
|
1514
1512
|
});
|
|
1515
1513
|
};
|
|
1516
|
-
const
|
|
1517
|
-
const
|
|
1518
|
-
const
|
|
1514
|
+
const offCreate = hook.on("effect:create", onEffectCreate);
|
|
1515
|
+
const offDestroy = hook.on("effect:destroy", onEffectDestroy);
|
|
1516
|
+
const offUpdate = hook.on("signal:update", onSignalUpdate);
|
|
1519
1517
|
function stop() {
|
|
1520
1518
|
if (!recording) return events;
|
|
1521
1519
|
recording = false;
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1520
|
+
offCreate();
|
|
1521
|
+
offDestroy();
|
|
1522
|
+
offUpdate();
|
|
1525
1523
|
return events;
|
|
1526
1524
|
}
|
|
1527
1525
|
function stopTrace() {
|
package/dist/devtools.js
CHANGED
|
@@ -33,11 +33,11 @@ import {
|
|
|
33
33
|
trackCleanup,
|
|
34
34
|
walkDependencyGraph,
|
|
35
35
|
withErrorTracking
|
|
36
|
-
} from "./chunk-
|
|
37
|
-
import "./chunk-
|
|
36
|
+
} from "./chunk-7GRNSCFT.js";
|
|
37
|
+
import "./chunk-VQNQZCWJ.js";
|
|
38
38
|
import "./chunk-EUZND3CB.js";
|
|
39
|
-
import "./chunk-
|
|
40
|
-
import "./chunk-
|
|
39
|
+
import "./chunk-NZIIMDWI.js";
|
|
40
|
+
import "./chunk-K4G4ZQNR.js";
|
|
41
41
|
import {
|
|
42
42
|
isDev
|
|
43
43
|
} from "./chunk-5X6PP2UK.js";
|
|
@@ -100,55 +100,53 @@ function createTraceProfiler() {
|
|
|
100
100
|
}
|
|
101
101
|
const start = typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
102
102
|
let recording = true;
|
|
103
|
-
|
|
103
|
+
function now() {
|
|
104
|
+
return (typeof performance !== "undefined" ? performance.now() : Date.now()) - start;
|
|
105
|
+
}
|
|
106
|
+
const onEffectCreate = (payload) => {
|
|
104
107
|
if (!recording) return;
|
|
105
|
-
const now = (typeof performance !== "undefined" ? performance.now() : Date.now()) - start;
|
|
106
|
-
const label = payload.name ?? "effect";
|
|
107
108
|
events.push({
|
|
108
|
-
name:
|
|
109
|
+
name: payload.name ?? "effect",
|
|
109
110
|
cat: "effect",
|
|
110
|
-
ph: "
|
|
111
|
-
ts: Math.floor(now * 1e3),
|
|
111
|
+
ph: "I",
|
|
112
|
+
ts: Math.floor(now() * 1e3),
|
|
112
113
|
tid: 0,
|
|
113
114
|
pid: 0
|
|
114
115
|
});
|
|
115
116
|
};
|
|
116
|
-
const
|
|
117
|
+
const onEffectDestroy = (payload) => {
|
|
117
118
|
if (!recording) return;
|
|
118
|
-
const now = (typeof performance !== "undefined" ? performance.now() : Date.now()) - start;
|
|
119
|
-
const label = payload.name ?? "effect";
|
|
120
119
|
events.push({
|
|
121
|
-
name:
|
|
120
|
+
name: payload.name ?? "effect:destroy",
|
|
122
121
|
cat: "effect",
|
|
123
|
-
ph: "
|
|
124
|
-
ts: Math.floor(now * 1e3),
|
|
122
|
+
ph: "I",
|
|
123
|
+
ts: Math.floor(now() * 1e3),
|
|
125
124
|
tid: 0,
|
|
126
125
|
pid: 0
|
|
127
126
|
});
|
|
128
127
|
};
|
|
129
|
-
const
|
|
128
|
+
const onSignalUpdate = (payload) => {
|
|
130
129
|
if (!recording) return;
|
|
131
|
-
const
|
|
132
|
-
const label = payload.name ?? "signal";
|
|
130
|
+
const p = payload;
|
|
133
131
|
events.push({
|
|
134
|
-
name:
|
|
132
|
+
name: p.name ?? "signal",
|
|
135
133
|
cat: "signal",
|
|
136
134
|
ph: "I",
|
|
137
|
-
ts: Math.floor(now * 1e3),
|
|
135
|
+
ts: Math.floor(now() * 1e3),
|
|
138
136
|
tid: 0,
|
|
139
137
|
pid: 0,
|
|
140
|
-
args:
|
|
138
|
+
args: p.oldValue !== void 0 ? { oldValue: String(p.oldValue), newValue: String(p.newValue) } : void 0
|
|
141
139
|
});
|
|
142
140
|
};
|
|
143
|
-
const
|
|
144
|
-
const
|
|
145
|
-
const
|
|
141
|
+
const offCreate = hook.on("effect:create", onEffectCreate);
|
|
142
|
+
const offDestroy = hook.on("effect:destroy", onEffectDestroy);
|
|
143
|
+
const offUpdate = hook.on("signal:update", onSignalUpdate);
|
|
146
144
|
function stop() {
|
|
147
145
|
if (!recording) return events;
|
|
148
146
|
recording = false;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
147
|
+
offCreate();
|
|
148
|
+
offDestroy();
|
|
149
|
+
offUpdate();
|
|
152
150
|
return events;
|
|
153
151
|
}
|
|
154
152
|
function stopTrace() {
|
package/dist/ecosystem.cjs
CHANGED
|
@@ -126,12 +126,21 @@ function queueSignalNotification(signal2) {
|
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
+
var MAX_DRAIN_ITERATIONS = 1e3;
|
|
129
130
|
function drainNotificationQueue() {
|
|
130
131
|
if (notifyDepth > 0) return;
|
|
131
132
|
notifyDepth++;
|
|
132
133
|
try {
|
|
133
134
|
let i = 0;
|
|
134
135
|
while (i < pendingQueue.length) {
|
|
136
|
+
if (i >= MAX_DRAIN_ITERATIONS) {
|
|
137
|
+
if (typeof console !== "undefined") {
|
|
138
|
+
console.error(
|
|
139
|
+
`[SibuJS] Notification queue exceeded ${MAX_DRAIN_ITERATIONS} iterations \u2014 likely an effect that writes to a signal it reads. Breaking to prevent infinite loop.`
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
135
144
|
safeInvoke(pendingQueue[i]);
|
|
136
145
|
i++;
|
|
137
146
|
}
|
|
@@ -436,21 +445,37 @@ function derived(getter, options) {
|
|
|
436
445
|
cs._v = getter();
|
|
437
446
|
}, markDirty);
|
|
438
447
|
const hook = globalThis.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
448
|
+
let evaluating = false;
|
|
439
449
|
function computedGetter() {
|
|
450
|
+
if (evaluating) {
|
|
451
|
+
throw new Error(
|
|
452
|
+
`[SibuJS] Circular dependency detected in derived${debugName ? ` "${debugName}"` : ""}. A derived signal cannot read itself (directly or through a chain).`
|
|
453
|
+
);
|
|
454
|
+
}
|
|
440
455
|
if (trackingSuspended) {
|
|
441
456
|
if (cs._d) {
|
|
442
|
-
|
|
443
|
-
|
|
457
|
+
evaluating = true;
|
|
458
|
+
try {
|
|
459
|
+
cs._d = false;
|
|
460
|
+
cs._v = getter();
|
|
461
|
+
} finally {
|
|
462
|
+
evaluating = false;
|
|
463
|
+
}
|
|
444
464
|
}
|
|
445
465
|
return cs._v;
|
|
446
466
|
}
|
|
447
467
|
recordDependency(cs);
|
|
448
468
|
if (cs._d) {
|
|
449
469
|
const oldValue = cs._v;
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
470
|
+
evaluating = true;
|
|
471
|
+
try {
|
|
472
|
+
track(() => {
|
|
473
|
+
cs._d = false;
|
|
474
|
+
cs._v = getter();
|
|
475
|
+
}, markDirty);
|
|
476
|
+
} finally {
|
|
477
|
+
evaluating = false;
|
|
478
|
+
}
|
|
454
479
|
if (hook && oldValue !== cs._v) {
|
|
455
480
|
hook.emit("computed:update", { signal: cs, oldValue, newValue: cs._v });
|
|
456
481
|
}
|
package/dist/ecosystem.d.cts
CHANGED
|
@@ -48,7 +48,7 @@ interface MobXAdapterAPI {
|
|
|
48
48
|
*
|
|
49
49
|
* const mobx = inject<MobXAdapterAPI>("mobx");
|
|
50
50
|
* const todoCount = mobx.fromMobX(() => todoStore.todos.length);
|
|
51
|
-
* div(
|
|
51
|
+
* div(() => `Todos: ${todoCount()}`);
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
54
|
declare function mobXAdapter(options: MobXAdapterOptions): SibuPlugin;
|
|
@@ -90,7 +90,7 @@ interface ReduxAdapterAPI<S = unknown> {
|
|
|
90
90
|
*
|
|
91
91
|
* const redux = inject<ReduxAdapterAPI>("redux");
|
|
92
92
|
* const count = redux.useSelector(s => s.counter);
|
|
93
|
-
* div(
|
|
93
|
+
* div(() => `Count: ${count()}`);
|
|
94
94
|
* ```
|
|
95
95
|
*/
|
|
96
96
|
declare function reduxAdapter<S>(options: ReduxAdapterOptions<S>): SibuPlugin;
|
|
@@ -133,7 +133,7 @@ interface ZustandAdapterAPI<S> {
|
|
|
133
133
|
*
|
|
134
134
|
* const zs = inject<ZustandAdapterAPI>("zustand");
|
|
135
135
|
* const bears = zs.useSelector(s => s.bears);
|
|
136
|
-
* div(
|
|
136
|
+
* div(() => `Bears: ${bears()}`);
|
|
137
137
|
* ```
|
|
138
138
|
*/
|
|
139
139
|
declare function zustandAdapter<S>(options: ZustandAdapterOptions<S>): SibuPlugin;
|
|
@@ -204,7 +204,7 @@ type AdaptedComponent = (props?: AdaptedComponentProps) => Element;
|
|
|
204
204
|
* });
|
|
205
205
|
*
|
|
206
206
|
* const { Button } = adapter.components;
|
|
207
|
-
* Button({ variant: "raised",
|
|
207
|
+
* Button({ variant: "raised" }, "Click me");
|
|
208
208
|
* ```
|
|
209
209
|
*/
|
|
210
210
|
declare function componentAdapter(config: AdapterConfig): {
|
package/dist/ecosystem.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ interface MobXAdapterAPI {
|
|
|
48
48
|
*
|
|
49
49
|
* const mobx = inject<MobXAdapterAPI>("mobx");
|
|
50
50
|
* const todoCount = mobx.fromMobX(() => todoStore.todos.length);
|
|
51
|
-
* div(
|
|
51
|
+
* div(() => `Todos: ${todoCount()}`);
|
|
52
52
|
* ```
|
|
53
53
|
*/
|
|
54
54
|
declare function mobXAdapter(options: MobXAdapterOptions): SibuPlugin;
|
|
@@ -90,7 +90,7 @@ interface ReduxAdapterAPI<S = unknown> {
|
|
|
90
90
|
*
|
|
91
91
|
* const redux = inject<ReduxAdapterAPI>("redux");
|
|
92
92
|
* const count = redux.useSelector(s => s.counter);
|
|
93
|
-
* div(
|
|
93
|
+
* div(() => `Count: ${count()}`);
|
|
94
94
|
* ```
|
|
95
95
|
*/
|
|
96
96
|
declare function reduxAdapter<S>(options: ReduxAdapterOptions<S>): SibuPlugin;
|
|
@@ -133,7 +133,7 @@ interface ZustandAdapterAPI<S> {
|
|
|
133
133
|
*
|
|
134
134
|
* const zs = inject<ZustandAdapterAPI>("zustand");
|
|
135
135
|
* const bears = zs.useSelector(s => s.bears);
|
|
136
|
-
* div(
|
|
136
|
+
* div(() => `Bears: ${bears()}`);
|
|
137
137
|
* ```
|
|
138
138
|
*/
|
|
139
139
|
declare function zustandAdapter<S>(options: ZustandAdapterOptions<S>): SibuPlugin;
|
|
@@ -204,7 +204,7 @@ type AdaptedComponent = (props?: AdaptedComponentProps) => Element;
|
|
|
204
204
|
* });
|
|
205
205
|
*
|
|
206
206
|
* const { Button } = adapter.components;
|
|
207
|
-
* Button({ variant: "raised",
|
|
207
|
+
* Button({ variant: "raised" }, "Click me");
|
|
208
208
|
* ```
|
|
209
209
|
*/
|
|
210
210
|
declare function componentAdapter(config: AdapterConfig): {
|
package/dist/ecosystem.js
CHANGED
|
@@ -7,16 +7,16 @@ import {
|
|
|
7
7
|
mobXAdapter,
|
|
8
8
|
reduxAdapter,
|
|
9
9
|
zustandAdapter
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-TDGZL5CU.js";
|
|
11
11
|
import "./chunk-K5ZUMYVS.js";
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
12
|
+
import "./chunk-SFKNRVCU.js";
|
|
13
|
+
import "./chunk-5ZYQ6KDD.js";
|
|
14
|
+
import "./chunk-XHK6BDAJ.js";
|
|
15
15
|
import "./chunk-CMBFNA7L.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-VQNQZCWJ.js";
|
|
17
17
|
import "./chunk-EUZND3CB.js";
|
|
18
|
-
import "./chunk-
|
|
19
|
-
import "./chunk-
|
|
18
|
+
import "./chunk-NZIIMDWI.js";
|
|
19
|
+
import "./chunk-K4G4ZQNR.js";
|
|
20
20
|
import "./chunk-5X6PP2UK.js";
|
|
21
21
|
export {
|
|
22
22
|
antdAdapter,
|