sibujs 3.3.0 → 3.3.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/dist/browser.cjs +210 -26
- package/dist/browser.js +4 -4
- package/dist/build.cjs +193 -89
- package/dist/build.js +10 -10
- package/dist/cdn.global.js +7 -7
- package/dist/{chunk-24DBWDTK.js → chunk-37BUKSLH.js} +1 -1
- package/dist/{chunk-IHBVTURX.js → chunk-4UUMSLSL.js} +4 -4
- package/dist/{chunk-USDR2GFV.js → chunk-6LTFHJQG.js} +3 -3
- package/dist/{chunk-MWZFOIBG.js → chunk-AMIKDMLP.js} +4 -4
- package/dist/{chunk-JBXNCZSC.js → chunk-F7FXQ3QS.js} +1 -1
- package/dist/{chunk-BEIKESVL.js → chunk-IKLYI3RF.js} +9 -9
- package/dist/{chunk-NUWKIEHE.js → chunk-LU2MQXQQ.js} +2 -2
- package/dist/{chunk-WVJJUFPC.js → chunk-M5KBNOSJ.js} +2 -2
- package/dist/{chunk-7JHWAGRQ.js → chunk-MHBCEJQO.js} +1 -1
- package/dist/{chunk-Q2ERM6NT.js → chunk-NHKQKKZU.js} +1 -1
- package/dist/{chunk-6G6UNHZI.js → chunk-RYMOSG5B.js} +5 -5
- package/dist/{chunk-F4UM7QBJ.js → chunk-SLMFA3ZZ.js} +1 -1
- package/dist/{chunk-X3NHE2DK.js → chunk-TEFZT5PJ.js} +83 -17
- package/dist/{chunk-SLCUP2EK.js → chunk-ULLTNDRA.js} +3 -3
- package/dist/{chunk-M6WSIGYW.js → chunk-VOVVTOEA.js} +2 -2
- package/dist/{chunk-XQ7XSGYP.js → chunk-WL7BIR6O.js} +1 -1
- package/dist/{chunk-CVMMULHO.js → chunk-WW6DAGGR.js} +4 -4
- package/dist/{chunk-5K72I3UQ.js → chunk-WZG2SZOT.js} +21 -4
- package/dist/{chunk-S4FHR5ZZ.js → chunk-XH2RTYEQ.js} +3 -3
- package/dist/{chunk-4WXWJ4SW.js → chunk-Z37APKBV.js} +4 -4
- package/dist/data.cjs +161 -23
- package/dist/data.js +6 -6
- package/dist/devtools.cjs +245 -31
- package/dist/devtools.js +4 -4
- package/dist/ecosystem.cjs +183 -45
- package/dist/ecosystem.js +7 -7
- package/dist/extras.cjs +185 -86
- package/dist/extras.js +19 -19
- package/dist/index.cjs +193 -89
- package/dist/index.d.cts +59 -8
- package/dist/index.d.ts +59 -8
- package/dist/index.js +10 -10
- package/dist/motion.cjs +329 -13
- package/dist/motion.js +3 -3
- package/dist/patterns.cjs +161 -23
- package/dist/patterns.js +5 -5
- package/dist/performance.cjs +258 -23
- package/dist/performance.js +4 -4
- package/dist/plugins.cjs +244 -51
- package/dist/plugins.js +6 -6
- package/dist/ssr.cjs +183 -44
- package/dist/ssr.js +7 -7
- package/dist/testing.cjs +396 -5
- package/dist/testing.js +2 -2
- package/dist/ui.cjs +221 -32
- package/dist/ui.js +6 -6
- package/dist/widgets.cjs +146 -26
- package/dist/widgets.js +6 -6
- package/package.json +1 -1
package/dist/patterns.cjs
CHANGED
|
@@ -65,7 +65,7 @@ function devWarn(message) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
// src/reactivity/track.ts
|
|
68
|
+
// src/reactivity/track-core.ts
|
|
69
69
|
var _isDev2 = isDev();
|
|
70
70
|
var POOL_MAX = 4096;
|
|
71
71
|
var nodePool = [];
|
|
@@ -149,6 +149,7 @@ function unlinkSub(node) {
|
|
|
149
149
|
else sub.depsTail = prev;
|
|
150
150
|
}
|
|
151
151
|
var currentSubscriber = null;
|
|
152
|
+
var suspendSavedSub = null;
|
|
152
153
|
var notifyDepth = 0;
|
|
153
154
|
var pendingQueue = [];
|
|
154
155
|
var pendingSet = /* @__PURE__ */ new Set();
|
|
@@ -160,7 +161,35 @@ function safeInvoke(sub) {
|
|
|
160
161
|
if (_isDev2) devWarn(`Subscriber threw during notification: ${err instanceof Error ? err.message : String(err)}`);
|
|
161
162
|
}
|
|
162
163
|
}
|
|
164
|
+
var suspendDepth = 0;
|
|
163
165
|
var trackingSuspended = false;
|
|
166
|
+
function suspendTracking() {
|
|
167
|
+
if (suspendDepth === 0) {
|
|
168
|
+
suspendSavedSub = currentSubscriber;
|
|
169
|
+
currentSubscriber = null;
|
|
170
|
+
trackingSuspended = true;
|
|
171
|
+
}
|
|
172
|
+
suspendDepth++;
|
|
173
|
+
}
|
|
174
|
+
function resumeTracking() {
|
|
175
|
+
suspendDepth--;
|
|
176
|
+
if (suspendDepth === 0) {
|
|
177
|
+
currentSubscriber = suspendSavedSub;
|
|
178
|
+
suspendSavedSub = null;
|
|
179
|
+
trackingSuspended = false;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function isTrackingSuspended() {
|
|
183
|
+
return trackingSuspended;
|
|
184
|
+
}
|
|
185
|
+
function untracked(fn) {
|
|
186
|
+
suspendTracking();
|
|
187
|
+
try {
|
|
188
|
+
return fn();
|
|
189
|
+
} finally {
|
|
190
|
+
resumeTracking();
|
|
191
|
+
}
|
|
192
|
+
}
|
|
164
193
|
var subscriberEpochCounter = 0;
|
|
165
194
|
function retrack(effectFn, subscriber) {
|
|
166
195
|
const prev = currentSubscriber;
|
|
@@ -270,6 +299,16 @@ function cleanup(subscriber) {
|
|
|
270
299
|
var maxSubscriberRepeats = 50;
|
|
271
300
|
var maxDrainIterations = 1e6;
|
|
272
301
|
var drainEpoch = 0;
|
|
302
|
+
function setMaxSubscriberRepeats(n) {
|
|
303
|
+
const prev = maxSubscriberRepeats;
|
|
304
|
+
if (Number.isFinite(n) && n > 0) maxSubscriberRepeats = Math.floor(n);
|
|
305
|
+
return prev;
|
|
306
|
+
}
|
|
307
|
+
function setMaxDrainIterations(n) {
|
|
308
|
+
const prev = maxDrainIterations;
|
|
309
|
+
if (Number.isFinite(n) && n > 0) maxDrainIterations = Math.floor(n);
|
|
310
|
+
return prev;
|
|
311
|
+
}
|
|
273
312
|
function tickRepeat(sub) {
|
|
274
313
|
const s = sub;
|
|
275
314
|
if (s._runEpoch !== drainEpoch) {
|
|
@@ -418,11 +457,90 @@ function notifySubscribers(signal2) {
|
|
|
418
457
|
}
|
|
419
458
|
}
|
|
420
459
|
}
|
|
460
|
+
function getSubscriberCount(signal2) {
|
|
461
|
+
return signal2.__sc ?? 0;
|
|
462
|
+
}
|
|
463
|
+
function getSubscriberDeps(subscriber) {
|
|
464
|
+
const sub = subscriber;
|
|
465
|
+
const out = [];
|
|
466
|
+
let node = sub.depsHead ?? null;
|
|
467
|
+
while (node) {
|
|
468
|
+
if (node.sig) out.push(node.sig);
|
|
469
|
+
node = node.subNext;
|
|
470
|
+
}
|
|
471
|
+
return out;
|
|
472
|
+
}
|
|
473
|
+
function forEachSubscriber(signal2, visit) {
|
|
474
|
+
let node = signal2.subsHead ?? null;
|
|
475
|
+
while (node) {
|
|
476
|
+
const s = node.sub;
|
|
477
|
+
if (s) visit(s);
|
|
478
|
+
node = node.sigNext;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// src/reactivity/track.ts
|
|
483
|
+
var _isDev3 = isDev();
|
|
484
|
+
var _runtimeVersion = typeof __SIBU_VERSION__ !== "undefined" ? __SIBU_VERSION__ : "dev";
|
|
485
|
+
var REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.v1");
|
|
486
|
+
function resolveReactiveApi() {
|
|
487
|
+
const g = globalThis;
|
|
488
|
+
const existing = g[REGISTRY_KEY];
|
|
489
|
+
if (existing) {
|
|
490
|
+
if (_isDev3 && !existing.__dupWarned) {
|
|
491
|
+
existing.__dupWarned = true;
|
|
492
|
+
devWarn(
|
|
493
|
+
`Multiple instances of the reactive runtime detected on this page (active: ${existing.version}, duplicate: ${_runtimeVersion}). Reactivity still works \u2014 all copies share the first one \u2014 but de-duplicate sibujs in your bundler (e.g. Vite optimizeDeps.exclude: ['sibujs'] or resolve.dedupe: ['sibujs']).`
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
return existing;
|
|
497
|
+
}
|
|
498
|
+
const local = {
|
|
499
|
+
suspendTracking,
|
|
500
|
+
resumeTracking,
|
|
501
|
+
isTrackingSuspended,
|
|
502
|
+
untracked,
|
|
503
|
+
retrack,
|
|
504
|
+
track,
|
|
505
|
+
reactiveBinding,
|
|
506
|
+
recordDependency,
|
|
507
|
+
cleanup,
|
|
508
|
+
setMaxSubscriberRepeats,
|
|
509
|
+
setMaxDrainIterations,
|
|
510
|
+
drainNotificationQueue,
|
|
511
|
+
queueSignalNotification,
|
|
512
|
+
notifySubscribers,
|
|
513
|
+
getSubscriberCount,
|
|
514
|
+
getSubscriberDeps,
|
|
515
|
+
forEachSubscriber,
|
|
516
|
+
version: _runtimeVersion
|
|
517
|
+
};
|
|
518
|
+
g[REGISTRY_KEY] = local;
|
|
519
|
+
return local;
|
|
520
|
+
}
|
|
521
|
+
var API = resolveReactiveApi();
|
|
522
|
+
var suspendTracking2 = API.suspendTracking;
|
|
523
|
+
var resumeTracking2 = API.resumeTracking;
|
|
524
|
+
var isTrackingSuspended2 = API.isTrackingSuspended;
|
|
525
|
+
var untracked2 = API.untracked;
|
|
526
|
+
var retrack2 = API.retrack;
|
|
527
|
+
var track2 = API.track;
|
|
528
|
+
var reactiveBinding2 = API.reactiveBinding;
|
|
529
|
+
var recordDependency2 = API.recordDependency;
|
|
530
|
+
var cleanup2 = API.cleanup;
|
|
531
|
+
var setMaxSubscriberRepeats2 = API.setMaxSubscriberRepeats;
|
|
532
|
+
var setMaxDrainIterations2 = API.setMaxDrainIterations;
|
|
533
|
+
var drainNotificationQueue2 = API.drainNotificationQueue;
|
|
534
|
+
var queueSignalNotification2 = API.queueSignalNotification;
|
|
535
|
+
var notifySubscribers2 = API.notifySubscribers;
|
|
536
|
+
var getSubscriberCount2 = API.getSubscriberCount;
|
|
537
|
+
var getSubscriberDeps2 = API.getSubscriberDeps;
|
|
538
|
+
var forEachSubscriber2 = API.forEachSubscriber;
|
|
421
539
|
|
|
422
540
|
// src/reactivity/batch.ts
|
|
423
541
|
var batchDepth = 0;
|
|
424
542
|
var pendingSignals = /* @__PURE__ */ new Set();
|
|
425
|
-
function
|
|
543
|
+
function batchImpl(fn) {
|
|
426
544
|
batchDepth++;
|
|
427
545
|
try {
|
|
428
546
|
return fn();
|
|
@@ -433,25 +551,45 @@ function batch(fn) {
|
|
|
433
551
|
}
|
|
434
552
|
}
|
|
435
553
|
}
|
|
436
|
-
function
|
|
554
|
+
function enqueueBatchedSignalImpl(signal2) {
|
|
437
555
|
if (batchDepth === 0) return false;
|
|
438
556
|
pendingSignals.add(signal2);
|
|
439
557
|
return true;
|
|
440
558
|
}
|
|
559
|
+
function isBatchingImpl() {
|
|
560
|
+
return batchDepth > 0;
|
|
561
|
+
}
|
|
441
562
|
function flushBatch() {
|
|
442
563
|
try {
|
|
443
564
|
for (const signal2 of pendingSignals) {
|
|
444
|
-
|
|
565
|
+
queueSignalNotification2(signal2);
|
|
445
566
|
}
|
|
446
567
|
} finally {
|
|
447
568
|
pendingSignals.clear();
|
|
448
569
|
}
|
|
449
|
-
|
|
570
|
+
drainNotificationQueue2();
|
|
571
|
+
}
|
|
572
|
+
var BATCH_REGISTRY_KEY = /* @__PURE__ */ Symbol.for("sibujs.reactive.batch.v1");
|
|
573
|
+
function resolveBatchApi() {
|
|
574
|
+
const g = globalThis;
|
|
575
|
+
const existing = g[BATCH_REGISTRY_KEY];
|
|
576
|
+
if (existing) return existing;
|
|
577
|
+
const local = {
|
|
578
|
+
batch: batchImpl,
|
|
579
|
+
enqueueBatchedSignal: enqueueBatchedSignalImpl,
|
|
580
|
+
isBatching: isBatchingImpl
|
|
581
|
+
};
|
|
582
|
+
g[BATCH_REGISTRY_KEY] = local;
|
|
583
|
+
return local;
|
|
450
584
|
}
|
|
585
|
+
var API2 = resolveBatchApi();
|
|
586
|
+
var batch = API2.batch;
|
|
587
|
+
var enqueueBatchedSignal = API2.enqueueBatchedSignal;
|
|
588
|
+
var isBatching = API2.isBatching;
|
|
451
589
|
|
|
452
590
|
// src/core/signals/signal.ts
|
|
453
591
|
var _g = globalThis;
|
|
454
|
-
var
|
|
592
|
+
var _isDev4 = isDev();
|
|
455
593
|
function signal(initial, options) {
|
|
456
594
|
const state = {
|
|
457
595
|
value: initial,
|
|
@@ -462,11 +600,11 @@ function signal(initial, options) {
|
|
|
462
600
|
__activeNode: null,
|
|
463
601
|
__name: void 0
|
|
464
602
|
};
|
|
465
|
-
const debugName =
|
|
603
|
+
const debugName = _isDev4 ? options?.name : void 0;
|
|
466
604
|
const equalsFn = options?.equals;
|
|
467
605
|
if (debugName) state.__name = debugName;
|
|
468
606
|
function get() {
|
|
469
|
-
|
|
607
|
+
recordDependency2(state);
|
|
470
608
|
return state.value;
|
|
471
609
|
}
|
|
472
610
|
get.__signal = state;
|
|
@@ -479,15 +617,15 @@ function signal(initial, options) {
|
|
|
479
617
|
if (equalsFn(prev, newValue)) return;
|
|
480
618
|
state.value = newValue;
|
|
481
619
|
state.__v++;
|
|
482
|
-
if (
|
|
620
|
+
if (_isDev4) {
|
|
483
621
|
const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
484
622
|
if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
|
|
485
623
|
}
|
|
486
624
|
if (!enqueueBatchedSignal(state)) {
|
|
487
|
-
|
|
625
|
+
notifySubscribers2(state);
|
|
488
626
|
}
|
|
489
627
|
};
|
|
490
|
-
} else if (
|
|
628
|
+
} else if (_isDev4) {
|
|
491
629
|
set = (next) => {
|
|
492
630
|
const prev = state.value;
|
|
493
631
|
const newValue = typeof next === "function" ? next(prev) : next;
|
|
@@ -497,7 +635,7 @@ function signal(initial, options) {
|
|
|
497
635
|
const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
498
636
|
if (hook) hook.emit("signal:update", { signal: state, name: debugName, oldValue: prev, newValue });
|
|
499
637
|
if (!enqueueBatchedSignal(state)) {
|
|
500
|
-
|
|
638
|
+
notifySubscribers2(state);
|
|
501
639
|
}
|
|
502
640
|
};
|
|
503
641
|
} else {
|
|
@@ -508,11 +646,11 @@ function signal(initial, options) {
|
|
|
508
646
|
state.value = newValue;
|
|
509
647
|
state.__v++;
|
|
510
648
|
if (!enqueueBatchedSignal(state)) {
|
|
511
|
-
|
|
649
|
+
notifySubscribers2(state);
|
|
512
650
|
}
|
|
513
651
|
};
|
|
514
652
|
}
|
|
515
|
-
if (
|
|
653
|
+
if (_isDev4) {
|
|
516
654
|
const hook = _g.__SIBU_DEVTOOLS_GLOBAL_HOOK__;
|
|
517
655
|
if (hook) hook.emit("signal:create", { signal: state, name: debugName, getter: get, initial });
|
|
518
656
|
}
|
|
@@ -639,7 +777,7 @@ function drainReruns(ctx) {
|
|
|
639
777
|
do {
|
|
640
778
|
ctx.rerunPending = false;
|
|
641
779
|
if (ctx.userCleanups.length > 0) flushUserCleanups(ctx);
|
|
642
|
-
|
|
780
|
+
retrack2(ctx.bodyFn, ctx.subscriber);
|
|
643
781
|
} while (ctx.rerunPending && ++reruns <= MAX_RERUNS);
|
|
644
782
|
if (ctx.rerunPending) {
|
|
645
783
|
ctx.rerunPending = false;
|
|
@@ -668,7 +806,7 @@ function disposeEffect(ctx) {
|
|
|
668
806
|
}
|
|
669
807
|
}
|
|
670
808
|
try {
|
|
671
|
-
|
|
809
|
+
cleanup2(ctx.subscriber);
|
|
672
810
|
} catch (err) {
|
|
673
811
|
if (typeof console !== "undefined") {
|
|
674
812
|
console.warn("[SibuJS effect] dispose threw:", err);
|
|
@@ -713,7 +851,7 @@ function effect(effectFn, options) {
|
|
|
713
851
|
try {
|
|
714
852
|
ctx.rerunPending = false;
|
|
715
853
|
if (ctx.userCleanups.length > 0) flushUserCleanups(ctx);
|
|
716
|
-
|
|
854
|
+
retrack2(ctx.bodyFn, sub);
|
|
717
855
|
if (ctx.rerunPending) drainReruns(ctx);
|
|
718
856
|
} finally {
|
|
719
857
|
ctx.running = false;
|
|
@@ -729,7 +867,7 @@ function effect(effectFn, options) {
|
|
|
729
867
|
ctx.subscriber = sub;
|
|
730
868
|
ctx.running = true;
|
|
731
869
|
try {
|
|
732
|
-
|
|
870
|
+
retrack2(ctx.bodyFn, ctx.subscriber);
|
|
733
871
|
if (ctx.rerunPending) drainReruns(ctx);
|
|
734
872
|
} finally {
|
|
735
873
|
ctx.running = false;
|
|
@@ -981,7 +1119,7 @@ function derived(getter, options) {
|
|
|
981
1119
|
cs._d = false;
|
|
982
1120
|
cs._init = true;
|
|
983
1121
|
};
|
|
984
|
-
|
|
1122
|
+
track2(() => {
|
|
985
1123
|
let threw = true;
|
|
986
1124
|
try {
|
|
987
1125
|
cs._v = getter();
|
|
@@ -1000,12 +1138,12 @@ function derived(getter, options) {
|
|
|
1000
1138
|
`[SibuJS] Circular dependency detected in derived${debugName ? ` "${debugName}"` : ""}. A derived signal cannot read itself (directly or through a chain).`
|
|
1001
1139
|
);
|
|
1002
1140
|
}
|
|
1003
|
-
if (
|
|
1141
|
+
if (isTrackingSuspended2()) {
|
|
1004
1142
|
if (cs._d) {
|
|
1005
1143
|
const prev = cs._v;
|
|
1006
1144
|
evaluating = true;
|
|
1007
1145
|
try {
|
|
1008
|
-
|
|
1146
|
+
retrack2(recompute, markDirty);
|
|
1009
1147
|
if (!Object.is(prev, cs._v)) cs.__v++;
|
|
1010
1148
|
} finally {
|
|
1011
1149
|
evaluating = false;
|
|
@@ -1013,12 +1151,12 @@ function derived(getter, options) {
|
|
|
1013
1151
|
}
|
|
1014
1152
|
return cs._v;
|
|
1015
1153
|
}
|
|
1016
|
-
|
|
1154
|
+
recordDependency2(cs);
|
|
1017
1155
|
if (cs._d) {
|
|
1018
1156
|
const oldValue = cs._v;
|
|
1019
1157
|
evaluating = true;
|
|
1020
1158
|
try {
|
|
1021
|
-
|
|
1159
|
+
retrack2(recompute, markDirty);
|
|
1022
1160
|
if (!Object.is(oldValue, cs._v)) cs.__v++;
|
|
1023
1161
|
} finally {
|
|
1024
1162
|
evaluating = false;
|
package/dist/patterns.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
optimisticList,
|
|
6
6
|
persisted,
|
|
7
7
|
timeline
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-XH2RTYEQ.js";
|
|
9
9
|
import {
|
|
10
10
|
RenderProp,
|
|
11
11
|
assertType,
|
|
@@ -23,11 +23,11 @@ import {
|
|
|
23
23
|
withWrapper
|
|
24
24
|
} from "./chunk-VJE6DDYM.js";
|
|
25
25
|
import "./chunk-H3SRKIYX.js";
|
|
26
|
-
import "./chunk-
|
|
27
|
-
import "./chunk-
|
|
26
|
+
import "./chunk-WW6DAGGR.js";
|
|
27
|
+
import "./chunk-MHBCEJQO.js";
|
|
28
28
|
import "./chunk-GOJMFRBL.js";
|
|
29
|
-
import "./chunk-
|
|
30
|
-
import "./chunk-
|
|
29
|
+
import "./chunk-WZG2SZOT.js";
|
|
30
|
+
import "./chunk-TEFZT5PJ.js";
|
|
31
31
|
import "./chunk-COY6PUD2.js";
|
|
32
32
|
export {
|
|
33
33
|
RenderProp,
|