signalium 2.3.2 → 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/CHANGELOG.md +230 -0
- package/dist/cjs/development/component-shared-Cug2Y5YZ.js +33 -0
- package/dist/cjs/development/component-shared-Cug2Y5YZ.js.map +1 -0
- package/dist/cjs/development/{debug-ouT0N0E4.js → debug-C46WDxhL.js} +47 -195
- package/dist/cjs/development/debug-C46WDxhL.js.map +1 -0
- package/dist/cjs/development/debug.js +1 -1
- package/dist/cjs/development/index.js +3 -2
- package/dist/cjs/development/index.js.map +1 -1
- package/dist/cjs/development/react/index.js +256 -87
- package/dist/cjs/development/react/index.js.map +1 -1
- package/dist/cjs/development/react/index.server.js +14 -0
- package/dist/cjs/development/react/index.server.js.map +1 -0
- package/dist/cjs/development/react/server.js +37 -0
- package/dist/cjs/development/react/server.js.map +1 -0
- package/dist/cjs/development/{snapshot-BPJ-qw6l.js → snapshot-48aGePMZ.js} +2 -2
- package/dist/cjs/development/{snapshot-BPJ-qw6l.js.map → snapshot-48aGePMZ.js.map} +1 -1
- package/dist/cjs/development/transform/index.js +196 -13
- package/dist/cjs/development/transform/index.js.map +1 -1
- package/dist/cjs/development/utils.js +6 -6
- package/dist/cjs/development/utils.js.map +1 -1
- package/dist/cjs/production/component-shared-D0J85PUi.js +33 -0
- package/dist/cjs/production/component-shared-D0J85PUi.js.map +1 -0
- package/dist/cjs/production/{contexts-DtQMtXO7.js → contexts-CM3QLfV8.js} +47 -198
- package/dist/cjs/production/contexts-CM3QLfV8.js.map +1 -0
- package/dist/cjs/production/debug.js +1 -1
- package/dist/cjs/production/index.js +3 -2
- package/dist/cjs/production/index.js.map +1 -1
- package/dist/cjs/production/react/index.js +242 -89
- package/dist/cjs/production/react/index.js.map +1 -1
- package/dist/cjs/production/react/index.server.js +14 -0
- package/dist/cjs/production/react/index.server.js.map +1 -0
- package/dist/cjs/production/react/server.js +37 -0
- package/dist/cjs/production/react/server.js.map +1 -0
- package/dist/cjs/production/{snapshot-Dw62eSpw.js → snapshot-BCESZVAP.js} +2 -2
- package/dist/cjs/production/{snapshot-Dw62eSpw.js.map → snapshot-BCESZVAP.js.map} +1 -1
- package/dist/cjs/production/transform/index.js +196 -13
- package/dist/cjs/production/transform/index.js.map +1 -1
- package/dist/cjs/production/utils.js +6 -6
- package/dist/cjs/production/utils.js.map +1 -1
- package/dist/esm/development/component-shared-CLSmdnGU.js +34 -0
- package/dist/esm/development/component-shared-CLSmdnGU.js.map +1 -0
- package/dist/esm/development/{debug-DaK9qsbI.js → debug-BTLbgTPK.js} +79 -227
- package/dist/esm/development/debug-BTLbgTPK.js.map +1 -0
- package/dist/esm/development/debug.js +9 -9
- package/dist/esm/development/index.js +14 -13
- package/dist/esm/development/react/index.js +232 -79
- package/dist/esm/development/react/index.js.map +1 -1
- package/dist/esm/development/react/index.server.js +14 -0
- package/dist/esm/development/react/index.server.js.map +1 -0
- package/dist/esm/development/react/server.js +20 -0
- package/dist/esm/development/react/server.js.map +1 -0
- package/dist/esm/development/{snapshot-D8ZJEbwO.js → snapshot-Ca_rQa4c.js} +2 -2
- package/dist/esm/development/{snapshot-D8ZJEbwO.js.map → snapshot-Ca_rQa4c.js.map} +1 -1
- package/dist/esm/development/transform/index.js +197 -14
- package/dist/esm/development/transform/index.js.map +1 -1
- package/dist/esm/development/utils.js +11 -11
- package/dist/esm/development/utils.js.map +1 -1
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/internals/async.d.ts +3 -3
- package/dist/esm/internals/async.d.ts.map +1 -1
- package/dist/esm/internals/contexts.d.ts +10 -6
- package/dist/esm/internals/contexts.d.ts.map +1 -1
- package/dist/esm/internals/core-api.d.ts +2 -2
- package/dist/esm/internals/core-api.d.ts.map +1 -1
- package/dist/esm/internals/get.d.ts.map +1 -1
- package/dist/esm/internals/reactive.d.ts +3 -9
- package/dist/esm/internals/reactive.d.ts.map +1 -1
- package/dist/esm/internals/scheduling.d.ts +0 -2
- package/dist/esm/internals/scheduling.d.ts.map +1 -1
- package/dist/esm/internals/watch.d.ts +3 -4
- package/dist/esm/internals/watch.d.ts.map +1 -1
- package/dist/esm/production/component-shared-Dva0S5e3.js +34 -0
- package/dist/esm/production/component-shared-Dva0S5e3.js.map +1 -0
- package/dist/esm/production/{contexts-US_h2nBi.js → contexts-FxCndlvf.js} +71 -222
- package/dist/esm/production/contexts-FxCndlvf.js.map +1 -0
- package/dist/esm/production/debug.js +1 -1
- package/dist/esm/production/index.js +14 -13
- package/dist/esm/production/react/index.js +219 -82
- package/dist/esm/production/react/index.js.map +1 -1
- package/dist/esm/production/react/index.server.js +14 -0
- package/dist/esm/production/react/index.server.js.map +1 -0
- package/dist/esm/production/react/server.js +20 -0
- package/dist/esm/production/react/server.js.map +1 -0
- package/dist/esm/production/{snapshot-CfJGJCvW.js → snapshot-TYiTYPGB.js} +2 -2
- package/dist/esm/production/{snapshot-CfJGJCvW.js.map → snapshot-TYiTYPGB.js.map} +1 -1
- package/dist/esm/production/transform/index.js +197 -14
- package/dist/esm/production/transform/index.js.map +1 -1
- package/dist/esm/production/utils.js +11 -11
- package/dist/esm/production/utils.js.map +1 -1
- package/dist/esm/react/async-component.d.ts +42 -0
- package/dist/esm/react/async-component.d.ts.map +1 -0
- package/dist/esm/react/component-server.d.ts +4 -0
- package/dist/esm/react/component-server.d.ts.map +1 -0
- package/dist/esm/react/component-shared.d.ts +21 -0
- package/dist/esm/react/component-shared.d.ts.map +1 -0
- package/dist/esm/react/component.d.ts +5 -1
- package/dist/esm/react/component.d.ts.map +1 -1
- package/dist/esm/react/index.d.ts +3 -4
- package/dist/esm/react/index.d.ts.map +1 -1
- package/dist/esm/react/index.server.d.ts +8 -0
- package/dist/esm/react/index.server.d.ts.map +1 -0
- package/dist/esm/react/pause-signals-context.d.ts +18 -0
- package/dist/esm/react/pause-signals-context.d.ts.map +1 -0
- package/dist/esm/react/server.d.ts +12 -0
- package/dist/esm/react/server.d.ts.map +1 -0
- package/dist/esm/react/use-reactive.d.ts +36 -7
- package/dist/esm/react/use-reactive.d.ts.map +1 -1
- package/dist/esm/transform/async.d.ts.map +1 -1
- package/dist/esm/transform/callback.d.ts.map +1 -1
- package/dist/esm/transform/index.d.ts +1 -0
- package/dist/esm/transform/index.d.ts.map +1 -1
- package/dist/esm/transform/preset.d.ts +1 -0
- package/dist/esm/transform/preset.d.ts.map +1 -1
- package/dist/esm/transform/use-reactive.d.ts +9 -0
- package/dist/esm/transform/use-reactive.d.ts.map +1 -0
- package/dist/esm/types.d.ts +33 -10
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/utils.d.ts +2 -2
- package/dist/esm/utils.d.ts.map +1 -1
- package/package.json +35 -4
- package/react-server.js +15 -0
- package/dist/cjs/development/debug-ouT0N0E4.js.map +0 -1
- package/dist/cjs/production/contexts-DtQMtXO7.js.map +0 -1
- package/dist/esm/development/debug-DaK9qsbI.js.map +0 -1
- package/dist/esm/internals/weakref.d.ts +0 -3
- package/dist/esm/internals/weakref.d.ts.map +0 -1
- package/dist/esm/production/contexts-US_h2nBi.js.map +0 -1
- package/dist/esm/react/suspend-signals-context.d.ts +0 -3
- package/dist/esm/react/suspend-signals-context.d.ts.map +0 -1
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const config = require("./config-B0MtLBgx.js");
|
|
3
|
-
class WeakRefPolyfill {
|
|
4
|
-
value;
|
|
5
|
-
constructor(value) {
|
|
6
|
-
this.value = value;
|
|
7
|
-
}
|
|
8
|
-
deref() {
|
|
9
|
-
return this.value;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
const WeakRef$1 = typeof WeakRef === "function" ? WeakRef : WeakRefPolyfill;
|
|
13
3
|
let UNKNOWN_SIGNAL_ID = 0;
|
|
14
4
|
const UNKNOWN_SIGNAL_NAMES = /* @__PURE__ */ new Map();
|
|
15
5
|
function getUnknownSignalFnName(fn) {
|
|
@@ -426,34 +416,19 @@ function signal(initialValue, opts) {
|
|
|
426
416
|
const notifier = (opts) => {
|
|
427
417
|
return new StateSignal(void 0, FALSE_EQUALS, opts?.desc);
|
|
428
418
|
};
|
|
429
|
-
function watchSignal(signal2
|
|
430
|
-
if (parentIsSuspended) {
|
|
431
|
-
watchSuspendedSignal(signal2);
|
|
432
|
-
} else {
|
|
433
|
-
watchActiveSignal(signal2);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
function unwatchSignal(signal2, parentIsSuspended) {
|
|
437
|
-
if (parentIsSuspended) {
|
|
438
|
-
unwatchSuspendedSignal(signal2);
|
|
439
|
-
} else {
|
|
440
|
-
unwatchActiveSignal(signal2);
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
function watchActiveSignal(signal2) {
|
|
419
|
+
function watchSignal(signal2) {
|
|
444
420
|
const { watchCount } = signal2;
|
|
445
|
-
|
|
446
|
-
signal2.watchCount = newWatchCount;
|
|
421
|
+
signal2.watchCount = watchCount + 1;
|
|
447
422
|
cancelDeactivate(signal2);
|
|
448
423
|
if (signal2._isActive) {
|
|
449
424
|
return;
|
|
450
425
|
}
|
|
451
426
|
for (const dep of signal2.deps.keys()) {
|
|
452
|
-
|
|
427
|
+
watchSignal(dep);
|
|
453
428
|
}
|
|
454
429
|
activateSignal(signal2);
|
|
455
430
|
}
|
|
456
|
-
function
|
|
431
|
+
function unwatchSignal(signal2) {
|
|
457
432
|
const { watchCount } = signal2;
|
|
458
433
|
const newWatchCount = Math.max(watchCount - 1, 0);
|
|
459
434
|
signal2.watchCount = newWatchCount;
|
|
@@ -461,51 +436,7 @@ function unwatchActiveSignal(signal2) {
|
|
|
461
436
|
scheduleDeactivate(signal2);
|
|
462
437
|
}
|
|
463
438
|
}
|
|
464
|
-
function watchSuspendedSignal(signal2) {
|
|
465
|
-
const { watchCount, suspendCount } = signal2;
|
|
466
|
-
const newWatchCount = watchCount + 1;
|
|
467
|
-
const newSuspendCount = suspendCount + 1;
|
|
468
|
-
signal2.watchCount = newWatchCount;
|
|
469
|
-
signal2.suspendCount = newSuspendCount;
|
|
470
|
-
cancelDeactivate(signal2);
|
|
471
|
-
if (watchCount === 0) {
|
|
472
|
-
for (const dep of signal2.deps.keys()) {
|
|
473
|
-
watchSuspendedSignal(dep);
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
function unwatchSuspendedSignal(signal2) {
|
|
478
|
-
const { watchCount, suspendCount } = signal2;
|
|
479
|
-
const newWatchCount = Math.max(watchCount - 1, 0);
|
|
480
|
-
const newSuspendCount = Math.max(suspendCount - 1, 0);
|
|
481
|
-
signal2.watchCount = newWatchCount;
|
|
482
|
-
signal2.suspendCount = newSuspendCount;
|
|
483
|
-
if (newWatchCount === 0) {
|
|
484
|
-
scheduleDeactivate(signal2);
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
function resumeSignal(signal2) {
|
|
488
|
-
const { watchCount, suspendCount } = signal2;
|
|
489
|
-
const newSuspendCount = Math.max(suspendCount - 1, 0);
|
|
490
|
-
signal2.suspendCount = newSuspendCount;
|
|
491
|
-
cancelDeactivate(signal2);
|
|
492
|
-
if (watchCount > 0 && !signal2._isActive) {
|
|
493
|
-
for (const dep of signal2.deps.keys()) {
|
|
494
|
-
resumeSignal(dep);
|
|
495
|
-
}
|
|
496
|
-
activateSignal(signal2);
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
function suspendSignal(signal2) {
|
|
500
|
-
const { watchCount, suspendCount } = signal2;
|
|
501
|
-
const newSuspendCount = suspendCount + 1;
|
|
502
|
-
signal2.suspendCount = newSuspendCount;
|
|
503
|
-
if (watchCount > 0 && newSuspendCount === watchCount) {
|
|
504
|
-
scheduleDeactivate(signal2);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
439
|
function activateSignal(signal2) {
|
|
508
|
-
signal2.scope?.removeFromGc(signal2);
|
|
509
440
|
cancelDeactivate(signal2);
|
|
510
441
|
signal2._isActive = true;
|
|
511
442
|
if (isRelay(signal2)) {
|
|
@@ -513,38 +444,23 @@ function activateSignal(signal2) {
|
|
|
513
444
|
}
|
|
514
445
|
}
|
|
515
446
|
function deactivateSignal(signal2) {
|
|
516
|
-
const { watchCount, suspendCount } = signal2;
|
|
517
447
|
signal2._isActive = false;
|
|
518
|
-
const isSuspending = watchCount > 0 && suspendCount === watchCount;
|
|
519
448
|
for (const dep of signal2.deps.keys()) {
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
deactivateSignal(dep);
|
|
525
|
-
}
|
|
526
|
-
} else {
|
|
527
|
-
const newWatchCount = dep.watchCount = depWatchCount - 1;
|
|
528
|
-
if (newWatchCount === 0) {
|
|
529
|
-
deactivateSignal(dep);
|
|
530
|
-
}
|
|
449
|
+
const newWatchCount = Math.max(dep.watchCount - 1, 0);
|
|
450
|
+
dep.watchCount = newWatchCount;
|
|
451
|
+
if (newWatchCount === 0) {
|
|
452
|
+
deactivateSignal(dep);
|
|
531
453
|
}
|
|
532
454
|
}
|
|
533
455
|
if (isRelay(signal2)) {
|
|
534
456
|
signal2._value?.();
|
|
535
457
|
}
|
|
536
|
-
if (watchCount === 0) {
|
|
537
|
-
signal2.scope?.markForGc(signal2);
|
|
538
|
-
signal2.reset();
|
|
539
|
-
}
|
|
540
458
|
}
|
|
541
|
-
const scheduleIdleCallback = typeof requestIdleCallback === "function" ? requestIdleCallback : (cb) => config.scheduleFlush(cb);
|
|
542
459
|
let PENDING_PULLS = /* @__PURE__ */ new Set();
|
|
543
460
|
let PENDING_ASYNC_PULLS = [];
|
|
544
461
|
let PENDING_DEACTIVE = /* @__PURE__ */ new Set();
|
|
545
462
|
let PENDING_LISTENERS = [];
|
|
546
463
|
let PENDING_TRACERS = [];
|
|
547
|
-
let PENDING_GC = /* @__PURE__ */ new Set();
|
|
548
464
|
const microtask = () => Promise.resolve();
|
|
549
465
|
let currentFlush = null;
|
|
550
466
|
const scheduleFlush = (fn) => {
|
|
@@ -571,7 +487,6 @@ const scheduleDeactivate = (signal2) => {
|
|
|
571
487
|
scheduleFlush();
|
|
572
488
|
};
|
|
573
489
|
const cancelDeactivate = (signal2) => {
|
|
574
|
-
signal2.scope?.removeFromGc(signal2);
|
|
575
490
|
PENDING_DEACTIVE.delete(signal2);
|
|
576
491
|
};
|
|
577
492
|
const scheduleListeners = (signal2) => {
|
|
@@ -584,17 +499,6 @@ const scheduleTracer = (tracer) => {
|
|
|
584
499
|
scheduleFlush();
|
|
585
500
|
}
|
|
586
501
|
};
|
|
587
|
-
const scheduleGcSweep = (scope) => {
|
|
588
|
-
PENDING_GC.add(scope);
|
|
589
|
-
if (PENDING_GC.size > 1)
|
|
590
|
-
return;
|
|
591
|
-
scheduleIdleCallback(() => {
|
|
592
|
-
for (const scope2 of PENDING_GC) {
|
|
593
|
-
scope2.sweepGc();
|
|
594
|
-
}
|
|
595
|
-
PENDING_GC.clear();
|
|
596
|
-
});
|
|
597
|
-
};
|
|
598
502
|
const flushWatchers = async () => {
|
|
599
503
|
const flush = currentFlush;
|
|
600
504
|
if (!flush)
|
|
@@ -659,7 +563,7 @@ function propagateDirty(signal2) {
|
|
|
659
563
|
scheduleAsyncPull(signal2);
|
|
660
564
|
}
|
|
661
565
|
} else {
|
|
662
|
-
if (signal2._isListener &&
|
|
566
|
+
if (signal2._isListener && signal2.watchCount > 0) {
|
|
663
567
|
schedulePull(signal2);
|
|
664
568
|
}
|
|
665
569
|
dirtySignalConsumers(signal2.subs);
|
|
@@ -763,6 +667,9 @@ function isGeneratorResult(value) {
|
|
|
763
667
|
function isPromise(value) {
|
|
764
668
|
return value.constructor === Promise;
|
|
765
669
|
}
|
|
670
|
+
function isThennable(value) {
|
|
671
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
672
|
+
}
|
|
766
673
|
function generatorResultToPromiseWithConsumer(generator, savedConsumer) {
|
|
767
674
|
function adopt(value) {
|
|
768
675
|
return typeof value === "object" && value !== null && (isPromise(value) || isReactivePromise(value)) ? value : Promise.resolve(value);
|
|
@@ -881,12 +788,6 @@ function callback(fn, idx, deps) {
|
|
|
881
788
|
}
|
|
882
789
|
return callback2.fn;
|
|
883
790
|
}
|
|
884
|
-
function isAbortError(error) {
|
|
885
|
-
if (typeof DOMException !== "undefined" && error instanceof DOMException) {
|
|
886
|
-
return error.name === "AbortError";
|
|
887
|
-
}
|
|
888
|
-
return error instanceof Error && error.name === "AbortError";
|
|
889
|
-
}
|
|
890
791
|
const arrayFrom = Array.from;
|
|
891
792
|
function isThenable(v) {
|
|
892
793
|
return v !== null && typeof v === "object" && typeof v.then === "function";
|
|
@@ -1225,10 +1126,6 @@ class ReactivePromiseImpl {
|
|
|
1225
1126
|
}
|
|
1226
1127
|
}
|
|
1227
1128
|
_setError(nextError, awaitSubs = this._awaitSubs) {
|
|
1228
|
-
if (nextError !== this._error && !isAbortError(nextError)) {
|
|
1229
|
-
const desc = this._signal?.desc ?? this._signal?.tracerMeta?.desc;
|
|
1230
|
-
console.error(`[signalium] Unhandled async error${desc ? ` in "${desc}"` : ""}:`, nextError);
|
|
1231
|
-
}
|
|
1232
1129
|
let error = this._error;
|
|
1233
1130
|
let notifyFlags = 0;
|
|
1234
1131
|
if (error !== nextError) {
|
|
@@ -1497,7 +1394,7 @@ function getSignal(signal2) {
|
|
|
1497
1394
|
});
|
|
1498
1395
|
}
|
|
1499
1396
|
if (currentConsumer.watchCount > 0) {
|
|
1500
|
-
watchSignal(signal2
|
|
1397
|
+
watchSignal(signal2);
|
|
1501
1398
|
}
|
|
1502
1399
|
}
|
|
1503
1400
|
const updatedAt = checkSignal(signal2);
|
|
@@ -1622,12 +1519,15 @@ function runSignal(signal2) {
|
|
|
1622
1519
|
}
|
|
1623
1520
|
}
|
|
1624
1521
|
function disconnectSignal(signal2, computedCount = signal2.computedCount) {
|
|
1625
|
-
const { ref, deps
|
|
1522
|
+
const { ref, deps } = signal2;
|
|
1626
1523
|
for (const [dep, edge] of deps) {
|
|
1627
1524
|
if (edge.consumedAt !== computedCount) {
|
|
1628
|
-
unwatchSignal(dep
|
|
1525
|
+
unwatchSignal(dep);
|
|
1629
1526
|
dep.subs.delete(ref);
|
|
1630
1527
|
deps.delete(dep);
|
|
1528
|
+
if (dep._state < 2) {
|
|
1529
|
+
dep._state = 2;
|
|
1530
|
+
}
|
|
1631
1531
|
}
|
|
1632
1532
|
}
|
|
1633
1533
|
}
|
|
@@ -1968,12 +1868,11 @@ class ReactiveSignal {
|
|
|
1968
1868
|
id = ++ID;
|
|
1969
1869
|
subs = /* @__PURE__ */ new Map();
|
|
1970
1870
|
deps = /* @__PURE__ */ new Map();
|
|
1971
|
-
ref = new WeakRef
|
|
1871
|
+
ref = new WeakRef(this);
|
|
1972
1872
|
dirtyHead = void 0;
|
|
1973
1873
|
updatedCount = 0;
|
|
1974
1874
|
computedCount = 0;
|
|
1975
1875
|
watchCount = 0;
|
|
1976
|
-
suspendCount = 0;
|
|
1977
1876
|
key;
|
|
1978
1877
|
args;
|
|
1979
1878
|
callbacks = void 0;
|
|
@@ -2008,31 +1907,24 @@ class ReactiveSignal {
|
|
|
2008
1907
|
get _isListener() {
|
|
2009
1908
|
return (this.flags & 16) !== 0;
|
|
2010
1909
|
}
|
|
2011
|
-
get _isSuspendedListener() {
|
|
2012
|
-
return (this.flags & 32) !== 0;
|
|
2013
|
-
}
|
|
2014
|
-
get _isSuspended() {
|
|
2015
|
-
const { watchCount, suspendCount } = this;
|
|
2016
|
-
return watchCount > 0 && watchCount === suspendCount;
|
|
2017
|
-
}
|
|
2018
1910
|
get _isActive() {
|
|
2019
|
-
return (this.flags &
|
|
1911
|
+
return (this.flags & 32) !== 0;
|
|
2020
1912
|
}
|
|
2021
1913
|
set _isActive(isActive) {
|
|
2022
1914
|
if (isActive) {
|
|
2023
|
-
this.flags |=
|
|
1915
|
+
this.flags |= 32;
|
|
2024
1916
|
} else {
|
|
2025
|
-
this.flags &= -
|
|
1917
|
+
this.flags &= -33;
|
|
2026
1918
|
}
|
|
2027
1919
|
}
|
|
2028
1920
|
get _isLazy() {
|
|
2029
|
-
return (this.flags &
|
|
1921
|
+
return (this.flags & 64) !== 0;
|
|
2030
1922
|
}
|
|
2031
1923
|
set _isLazy(isLazy) {
|
|
2032
1924
|
if (isLazy) {
|
|
2033
|
-
this.flags |=
|
|
1925
|
+
this.flags |= 64;
|
|
2034
1926
|
} else {
|
|
2035
|
-
this.flags &= -
|
|
1927
|
+
this.flags &= -65;
|
|
2036
1928
|
}
|
|
2037
1929
|
}
|
|
2038
1930
|
get listeners() {
|
|
@@ -2060,10 +1952,12 @@ class ReactiveSignal {
|
|
|
2060
1952
|
};
|
|
2061
1953
|
}
|
|
2062
1954
|
if (!this._isListener) {
|
|
2063
|
-
watchSignal(this
|
|
1955
|
+
watchSignal(this);
|
|
2064
1956
|
this.flags |= 16;
|
|
2065
1957
|
}
|
|
2066
|
-
|
|
1958
|
+
if (this.watchCount > 0) {
|
|
1959
|
+
schedulePull(this);
|
|
1960
|
+
}
|
|
2067
1961
|
current.set(listener, effective);
|
|
2068
1962
|
}
|
|
2069
1963
|
return () => {
|
|
@@ -2071,7 +1965,7 @@ class ReactiveSignal {
|
|
|
2071
1965
|
current.delete(listener);
|
|
2072
1966
|
if (current.size === 0) {
|
|
2073
1967
|
cancelPull(this);
|
|
2074
|
-
unwatchSignal(this
|
|
1968
|
+
unwatchSignal(this);
|
|
2075
1969
|
this.flags &= -17;
|
|
2076
1970
|
this.listeners.updatedAt = 0;
|
|
2077
1971
|
}
|
|
@@ -2081,39 +1975,15 @@ class ReactiveSignal {
|
|
|
2081
1975
|
// This method is used in React hooks specifically. It returns a bound add method
|
|
2082
1976
|
// that is cached to avoid creating a new one on each call, and it eagerly sets
|
|
2083
1977
|
// the listener as watched so that relays that are accessed will be activated.
|
|
2084
|
-
addListenerLazy() {
|
|
1978
|
+
addListenerLazy(watch = true) {
|
|
2085
1979
|
if (!this._isListener) {
|
|
2086
|
-
|
|
1980
|
+
if (watch) {
|
|
1981
|
+
watchSignal(this);
|
|
1982
|
+
}
|
|
2087
1983
|
this.flags |= 16;
|
|
2088
1984
|
}
|
|
2089
1985
|
return this.listeners.cachedBoundAdd;
|
|
2090
1986
|
}
|
|
2091
|
-
setSuspended(suspended) {
|
|
2092
|
-
const { flags } = this;
|
|
2093
|
-
const isListener = (flags & 16) !== 0;
|
|
2094
|
-
const isSuspendedListener = (flags & 32) !== 0;
|
|
2095
|
-
if (suspended && !isSuspendedListener) {
|
|
2096
|
-
this.flags = flags | 32;
|
|
2097
|
-
if (isListener) {
|
|
2098
|
-
suspendSignal(this);
|
|
2099
|
-
}
|
|
2100
|
-
} else if (!suspended && isSuspendedListener) {
|
|
2101
|
-
this.flags = flags & -33;
|
|
2102
|
-
if (isListener) {
|
|
2103
|
-
resumeSignal(this);
|
|
2104
|
-
}
|
|
2105
|
-
}
|
|
2106
|
-
}
|
|
2107
|
-
reset() {
|
|
2108
|
-
this.flags = (this.def.isRelay ? 8 : 0) | 2;
|
|
2109
|
-
this.dirtyHead = void 0;
|
|
2110
|
-
this.updatedCount = 0;
|
|
2111
|
-
this.computedCount = 0;
|
|
2112
|
-
this.deps = /* @__PURE__ */ new Map();
|
|
2113
|
-
this.subs = /* @__PURE__ */ new Map();
|
|
2114
|
-
this.watchCount = 0;
|
|
2115
|
-
this.suspendCount = 0;
|
|
2116
|
-
}
|
|
2117
1987
|
}
|
|
2118
1988
|
const runListeners = (signal2) => {
|
|
2119
1989
|
const { listeners } = signal2;
|
|
@@ -2131,6 +2001,10 @@ const isRelay = (signal2) => {
|
|
|
2131
2001
|
function createReactiveSignal(def, args = [], key, scope) {
|
|
2132
2002
|
return new ReactiveSignal(def, args, key, scope);
|
|
2133
2003
|
}
|
|
2004
|
+
let requestScopeGetter;
|
|
2005
|
+
function setRequestScopeGetter(get) {
|
|
2006
|
+
requestScopeGetter = get;
|
|
2007
|
+
}
|
|
2134
2008
|
let CONTEXT_ID = 0;
|
|
2135
2009
|
class ContextImpl {
|
|
2136
2010
|
defaultValue;
|
|
@@ -2172,7 +2046,6 @@ class SignalScope {
|
|
|
2172
2046
|
contexts;
|
|
2173
2047
|
children = /* @__PURE__ */ new Map();
|
|
2174
2048
|
signals = /* @__PURE__ */ new Map();
|
|
2175
|
-
gcCandidates = /* @__PURE__ */ new Set();
|
|
2176
2049
|
setContexts(contexts) {
|
|
2177
2050
|
for (const [context2, value] of contexts) {
|
|
2178
2051
|
this.contexts[context2._key] = value;
|
|
@@ -2198,38 +2071,13 @@ class SignalScope {
|
|
|
2198
2071
|
get(def, args) {
|
|
2199
2072
|
const paramKey = def.paramKey?.(...args);
|
|
2200
2073
|
const key = hashReactiveFn(def.compute, paramKey ? [paramKey] : args);
|
|
2201
|
-
let signal2 = this.signals.get(key);
|
|
2074
|
+
let signal2 = this.signals.get(key)?.deref();
|
|
2202
2075
|
if (signal2 === void 0) {
|
|
2203
2076
|
signal2 = createReactiveSignal(def, args, key, this);
|
|
2204
|
-
this.signals.set(key, signal2);
|
|
2077
|
+
this.signals.set(key, new WeakRef(signal2));
|
|
2205
2078
|
}
|
|
2206
2079
|
return signal2;
|
|
2207
2080
|
}
|
|
2208
|
-
markForGc(signal2) {
|
|
2209
|
-
if (!this.gcCandidates.has(signal2)) {
|
|
2210
|
-
this.gcCandidates.add(signal2);
|
|
2211
|
-
scheduleGcSweep(this);
|
|
2212
|
-
}
|
|
2213
|
-
}
|
|
2214
|
-
removeFromGc(signal2) {
|
|
2215
|
-
this.gcCandidates.delete(signal2);
|
|
2216
|
-
const { key } = signal2;
|
|
2217
|
-
if (key) {
|
|
2218
|
-
this.signals.set(key, signal2);
|
|
2219
|
-
}
|
|
2220
|
-
}
|
|
2221
|
-
forceGc(signal2) {
|
|
2222
|
-
this.signals.delete(signal2.key);
|
|
2223
|
-
}
|
|
2224
|
-
sweepGc() {
|
|
2225
|
-
const signals = this.signals;
|
|
2226
|
-
for (const signal2 of this.gcCandidates) {
|
|
2227
|
-
if (signal2.watchCount === 0) {
|
|
2228
|
-
signals.delete(signal2.key);
|
|
2229
|
-
}
|
|
2230
|
-
}
|
|
2231
|
-
this.gcCandidates = /* @__PURE__ */ new Set();
|
|
2232
|
-
}
|
|
2233
2081
|
}
|
|
2234
2082
|
let GLOBAL_SCOPE = new SignalScope([]);
|
|
2235
2083
|
const getGlobalScope = () => {
|
|
@@ -2249,7 +2097,7 @@ const getInternalCurrentScope = () => {
|
|
|
2249
2097
|
return CURRENT_SCOPE;
|
|
2250
2098
|
};
|
|
2251
2099
|
const getCurrentScope = (fallback = GLOBAL_SCOPE) => {
|
|
2252
|
-
return CURRENT_SCOPE ?? getCurrentConsumer()?.scope ?? fallback;
|
|
2100
|
+
return CURRENT_SCOPE ?? getCurrentConsumer()?.scope ?? requestScopeGetter?.() ?? fallback;
|
|
2253
2101
|
};
|
|
2254
2102
|
const SCOPE_OWNER_MAP = /* @__PURE__ */ new WeakMap();
|
|
2255
2103
|
const OWNER_CHILD_MAP = /* @__PURE__ */ new WeakMap();
|
|
@@ -2288,6 +2136,7 @@ exports.createRelay = createRelay;
|
|
|
2288
2136
|
exports.createTask = createTask;
|
|
2289
2137
|
exports.createTracer = createTracer;
|
|
2290
2138
|
exports.createTracerFromId = createTracerFromId;
|
|
2139
|
+
exports.generatorResultToPromiseWithConsumer = generatorResultToPromiseWithConsumer;
|
|
2291
2140
|
exports.getContext = getContext;
|
|
2292
2141
|
exports.getCurrentConsumer = getCurrentConsumer;
|
|
2293
2142
|
exports.getCurrentScope = getCurrentScope;
|
|
@@ -2298,15 +2147,18 @@ exports.getTracerProxy = getTracerProxy;
|
|
|
2298
2147
|
exports.hashValue = hashValue;
|
|
2299
2148
|
exports.isPromise = isPromise;
|
|
2300
2149
|
exports.isReactivePromise = isReactivePromise;
|
|
2301
|
-
exports.isRelay = isRelay$1;
|
|
2302
2150
|
exports.isSignal = isSignal;
|
|
2151
|
+
exports.isThennable = isThennable;
|
|
2303
2152
|
exports.notifier = notifier;
|
|
2304
2153
|
exports.registerCustomHash = registerCustomHash;
|
|
2305
2154
|
exports.removeTracer = removeTracer;
|
|
2306
2155
|
exports.runSignal = runSignal;
|
|
2156
|
+
exports.schedulePull = schedulePull;
|
|
2307
2157
|
exports.scheduleTracer = scheduleTracer;
|
|
2158
|
+
exports.setCurrentConsumer = setCurrentConsumer;
|
|
2308
2159
|
exports.setGlobalContexts = setGlobalContexts;
|
|
2309
2160
|
exports.setReactivePromise = setReactivePromise;
|
|
2161
|
+
exports.setRequestScopeGetter = setRequestScopeGetter;
|
|
2310
2162
|
exports.setScopeOwner = setScopeOwner;
|
|
2311
2163
|
exports.setTracing = setTracing;
|
|
2312
2164
|
exports.settled = settled;
|
|
@@ -2314,4 +2166,4 @@ exports.signal = signal;
|
|
|
2314
2166
|
exports.unwatchSignal = unwatchSignal;
|
|
2315
2167
|
exports.watchSignal = watchSignal;
|
|
2316
2168
|
exports.withContexts = withContexts;
|
|
2317
|
-
//# sourceMappingURL=debug-
|
|
2169
|
+
//# sourceMappingURL=debug-C46WDxhL.js.map
|