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
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { g as getCurrentScope, c as createReactiveSignal, a as generatorResultToPromiseWithConsumer, s as setCurrentConsumer, b as getCurrentConsumer } from "./debug-BTLbgTPK.js";
|
|
2
|
+
function isGeneratorFunction(fn) {
|
|
3
|
+
return typeof fn === "function" && fn.constructor?.name === "GeneratorFunction";
|
|
4
|
+
}
|
|
5
|
+
function isAsyncFunctionWithoutTransform(fn) {
|
|
6
|
+
return typeof fn === "function" && fn.constructor?.name === "AsyncFunction";
|
|
7
|
+
}
|
|
8
|
+
function createServerAsyncComponentWrapper(fn) {
|
|
9
|
+
return async function(props) {
|
|
10
|
+
const scope = getCurrentScope();
|
|
11
|
+
const owned = createReactiveSignal({ compute: () => null, equals: () => true, isRelay: false, tracer: void 0 }, [], void 0, scope);
|
|
12
|
+
return generatorResultToPromiseWithConsumer(fn(props), owned);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function createServerSyncComponentWrapper(fn) {
|
|
16
|
+
return function(props) {
|
|
17
|
+
const scope = getCurrentScope();
|
|
18
|
+
const owned = createReactiveSignal({ compute: () => null, equals: () => true, isRelay: false, tracer: void 0 }, [], void 0, scope);
|
|
19
|
+
const prevConsumer = getCurrentConsumer();
|
|
20
|
+
try {
|
|
21
|
+
setCurrentConsumer(owned);
|
|
22
|
+
return fn(props);
|
|
23
|
+
} finally {
|
|
24
|
+
setCurrentConsumer(prevConsumer);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
isGeneratorFunction as a,
|
|
30
|
+
createServerSyncComponentWrapper as b,
|
|
31
|
+
createServerAsyncComponentWrapper as c,
|
|
32
|
+
isAsyncFunctionWithoutTransform as i
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=component-shared-CLSmdnGU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component-shared-CLSmdnGU.js","sources":["../../../.tsc-out/react/component-shared.js"],"sourcesContent":["import { getCurrentConsumer, setCurrentConsumer } from '../internals/consumer.js';\nimport { getCurrentScope } from '../internals/contexts.js';\nimport { createReactiveSignal } from '../internals/reactive.js';\nimport { generatorResultToPromiseWithConsumer } from '../internals/generators.js';\nexport function isGeneratorFunction(fn) {\n return (typeof fn === 'function' && fn.constructor?.name === 'GeneratorFunction');\n}\nexport function isAsyncFunctionWithoutTransform(fn) {\n return typeof fn === 'function' && fn.constructor?.name === 'AsyncFunction';\n}\n/**\n * Wrap a Babel-transformed async generator in a real `async function` that drives it\n * with {@link generatorResultToPromiseWithConsumer}. Used on the server (RSC + SSR)\n * where hooks-based Suspense replay is not appropriate.\n */\nexport function createServerAsyncComponentWrapper(fn) {\n return async function (props) {\n const scope = getCurrentScope();\n const owned = createReactiveSignal({ compute: () => null, equals: () => true, isRelay: false, tracer: undefined }, [], undefined, scope);\n return generatorResultToPromiseWithConsumer(fn(props), owned);\n };\n}\n/**\n * Wrap a sync render function with consumer/scope tracking. Used by the server\n * `component()` for non-generator definitions.\n */\nexport function createServerSyncComponentWrapper(fn) {\n return function (props) {\n const scope = getCurrentScope();\n const owned = createReactiveSignal({ compute: () => null, equals: () => true, isRelay: false, tracer: undefined }, [], undefined, scope);\n const prevConsumer = getCurrentConsumer();\n try {\n setCurrentConsumer(owned);\n return fn(props);\n }\n finally {\n setCurrentConsumer(prevConsumer);\n }\n };\n}\n"],"names":[],"mappings":";AAIO,SAAS,oBAAoB,IAAI;AACpC,SAAQ,OAAO,OAAO,cAAc,GAAG,aAAa,SAAS;AACjE;AACO,SAAS,gCAAgC,IAAI;AAChD,SAAO,OAAO,OAAO,cAAc,GAAG,aAAa,SAAS;AAChE;AAMO,SAAS,kCAAkC,IAAI;AAClD,SAAO,eAAgB,OAAO;AAC1B,UAAM,QAAQ,gBAAe;AAC7B,UAAM,QAAQ,qBAAqB,EAAE,SAAS,MAAM,MAAM,QAAQ,MAAM,MAAM,SAAS,OAAO,QAAQ,OAAS,GAAI,CAAA,GAAI,QAAW,KAAK;AACvI,WAAO,qCAAqC,GAAG,KAAK,GAAG,KAAK;AAAA,EAChE;AACJ;AAKO,SAAS,iCAAiC,IAAI;AACjD,SAAO,SAAU,OAAO;AACpB,UAAM,QAAQ,gBAAe;AAC7B,UAAM,QAAQ,qBAAqB,EAAE,SAAS,MAAM,MAAM,QAAQ,MAAM,MAAM,SAAS,OAAO,QAAQ,OAAS,GAAI,CAAA,GAAI,QAAW,KAAK;AACvI,UAAM,eAAe,mBAAkB;AACvC,QAAI;AACA,yBAAmB,KAAK;AACxB,aAAO,GAAG,KAAK;AAAA,IACnB,UACR;AACY,yBAAmB,YAAY;AAAA,IACnC;AAAA,EACJ;AACJ;"}
|
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import { s as scheduleFlush$1, r as runBatch } from "./config-CPQL7hX-.js";
|
|
2
|
-
class WeakRefPolyfill {
|
|
3
|
-
value;
|
|
4
|
-
constructor(value) {
|
|
5
|
-
this.value = value;
|
|
6
|
-
}
|
|
7
|
-
deref() {
|
|
8
|
-
return this.value;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
const WeakRef$1 = typeof WeakRef === "function" ? WeakRef : WeakRefPolyfill;
|
|
12
2
|
let UNKNOWN_SIGNAL_ID = 0;
|
|
13
3
|
const UNKNOWN_SIGNAL_NAMES = /* @__PURE__ */ new Map();
|
|
14
4
|
function getUnknownSignalFnName(fn) {
|
|
@@ -425,34 +415,19 @@ function signal(initialValue, opts) {
|
|
|
425
415
|
const notifier = (opts) => {
|
|
426
416
|
return new StateSignal(void 0, FALSE_EQUALS, opts?.desc);
|
|
427
417
|
};
|
|
428
|
-
function watchSignal(signal2
|
|
429
|
-
if (parentIsSuspended) {
|
|
430
|
-
watchSuspendedSignal(signal2);
|
|
431
|
-
} else {
|
|
432
|
-
watchActiveSignal(signal2);
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
function unwatchSignal(signal2, parentIsSuspended) {
|
|
436
|
-
if (parentIsSuspended) {
|
|
437
|
-
unwatchSuspendedSignal(signal2);
|
|
438
|
-
} else {
|
|
439
|
-
unwatchActiveSignal(signal2);
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
function watchActiveSignal(signal2) {
|
|
418
|
+
function watchSignal(signal2) {
|
|
443
419
|
const { watchCount } = signal2;
|
|
444
|
-
|
|
445
|
-
signal2.watchCount = newWatchCount;
|
|
420
|
+
signal2.watchCount = watchCount + 1;
|
|
446
421
|
cancelDeactivate(signal2);
|
|
447
422
|
if (signal2._isActive) {
|
|
448
423
|
return;
|
|
449
424
|
}
|
|
450
425
|
for (const dep of signal2.deps.keys()) {
|
|
451
|
-
|
|
426
|
+
watchSignal(dep);
|
|
452
427
|
}
|
|
453
428
|
activateSignal(signal2);
|
|
454
429
|
}
|
|
455
|
-
function
|
|
430
|
+
function unwatchSignal(signal2) {
|
|
456
431
|
const { watchCount } = signal2;
|
|
457
432
|
const newWatchCount = Math.max(watchCount - 1, 0);
|
|
458
433
|
signal2.watchCount = newWatchCount;
|
|
@@ -460,51 +435,7 @@ function unwatchActiveSignal(signal2) {
|
|
|
460
435
|
scheduleDeactivate(signal2);
|
|
461
436
|
}
|
|
462
437
|
}
|
|
463
|
-
function watchSuspendedSignal(signal2) {
|
|
464
|
-
const { watchCount, suspendCount } = signal2;
|
|
465
|
-
const newWatchCount = watchCount + 1;
|
|
466
|
-
const newSuspendCount = suspendCount + 1;
|
|
467
|
-
signal2.watchCount = newWatchCount;
|
|
468
|
-
signal2.suspendCount = newSuspendCount;
|
|
469
|
-
cancelDeactivate(signal2);
|
|
470
|
-
if (watchCount === 0) {
|
|
471
|
-
for (const dep of signal2.deps.keys()) {
|
|
472
|
-
watchSuspendedSignal(dep);
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
function unwatchSuspendedSignal(signal2) {
|
|
477
|
-
const { watchCount, suspendCount } = signal2;
|
|
478
|
-
const newWatchCount = Math.max(watchCount - 1, 0);
|
|
479
|
-
const newSuspendCount = Math.max(suspendCount - 1, 0);
|
|
480
|
-
signal2.watchCount = newWatchCount;
|
|
481
|
-
signal2.suspendCount = newSuspendCount;
|
|
482
|
-
if (newWatchCount === 0) {
|
|
483
|
-
scheduleDeactivate(signal2);
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
function resumeSignal(signal2) {
|
|
487
|
-
const { watchCount, suspendCount } = signal2;
|
|
488
|
-
const newSuspendCount = Math.max(suspendCount - 1, 0);
|
|
489
|
-
signal2.suspendCount = newSuspendCount;
|
|
490
|
-
cancelDeactivate(signal2);
|
|
491
|
-
if (watchCount > 0 && !signal2._isActive) {
|
|
492
|
-
for (const dep of signal2.deps.keys()) {
|
|
493
|
-
resumeSignal(dep);
|
|
494
|
-
}
|
|
495
|
-
activateSignal(signal2);
|
|
496
|
-
}
|
|
497
|
-
}
|
|
498
|
-
function suspendSignal(signal2) {
|
|
499
|
-
const { watchCount, suspendCount } = signal2;
|
|
500
|
-
const newSuspendCount = suspendCount + 1;
|
|
501
|
-
signal2.suspendCount = newSuspendCount;
|
|
502
|
-
if (watchCount > 0 && newSuspendCount === watchCount) {
|
|
503
|
-
scheduleDeactivate(signal2);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
438
|
function activateSignal(signal2) {
|
|
507
|
-
signal2.scope?.removeFromGc(signal2);
|
|
508
439
|
cancelDeactivate(signal2);
|
|
509
440
|
signal2._isActive = true;
|
|
510
441
|
if (isRelay(signal2)) {
|
|
@@ -512,38 +443,23 @@ function activateSignal(signal2) {
|
|
|
512
443
|
}
|
|
513
444
|
}
|
|
514
445
|
function deactivateSignal(signal2) {
|
|
515
|
-
const { watchCount, suspendCount } = signal2;
|
|
516
446
|
signal2._isActive = false;
|
|
517
|
-
const isSuspending = watchCount > 0 && suspendCount === watchCount;
|
|
518
447
|
for (const dep of signal2.deps.keys()) {
|
|
519
|
-
const
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
deactivateSignal(dep);
|
|
524
|
-
}
|
|
525
|
-
} else {
|
|
526
|
-
const newWatchCount = dep.watchCount = depWatchCount - 1;
|
|
527
|
-
if (newWatchCount === 0) {
|
|
528
|
-
deactivateSignal(dep);
|
|
529
|
-
}
|
|
448
|
+
const newWatchCount = Math.max(dep.watchCount - 1, 0);
|
|
449
|
+
dep.watchCount = newWatchCount;
|
|
450
|
+
if (newWatchCount === 0) {
|
|
451
|
+
deactivateSignal(dep);
|
|
530
452
|
}
|
|
531
453
|
}
|
|
532
454
|
if (isRelay(signal2)) {
|
|
533
455
|
signal2._value?.();
|
|
534
456
|
}
|
|
535
|
-
if (watchCount === 0) {
|
|
536
|
-
signal2.scope?.markForGc(signal2);
|
|
537
|
-
signal2.reset();
|
|
538
|
-
}
|
|
539
457
|
}
|
|
540
|
-
const scheduleIdleCallback = typeof requestIdleCallback === "function" ? requestIdleCallback : (cb) => scheduleFlush$1(cb);
|
|
541
458
|
let PENDING_PULLS = /* @__PURE__ */ new Set();
|
|
542
459
|
let PENDING_ASYNC_PULLS = [];
|
|
543
460
|
let PENDING_DEACTIVE = /* @__PURE__ */ new Set();
|
|
544
461
|
let PENDING_LISTENERS = [];
|
|
545
462
|
let PENDING_TRACERS = [];
|
|
546
|
-
let PENDING_GC = /* @__PURE__ */ new Set();
|
|
547
463
|
const microtask = () => Promise.resolve();
|
|
548
464
|
let currentFlush = null;
|
|
549
465
|
const scheduleFlush = (fn) => {
|
|
@@ -570,7 +486,6 @@ const scheduleDeactivate = (signal2) => {
|
|
|
570
486
|
scheduleFlush();
|
|
571
487
|
};
|
|
572
488
|
const cancelDeactivate = (signal2) => {
|
|
573
|
-
signal2.scope?.removeFromGc(signal2);
|
|
574
489
|
PENDING_DEACTIVE.delete(signal2);
|
|
575
490
|
};
|
|
576
491
|
const scheduleListeners = (signal2) => {
|
|
@@ -583,17 +498,6 @@ const scheduleTracer = (tracer) => {
|
|
|
583
498
|
scheduleFlush();
|
|
584
499
|
}
|
|
585
500
|
};
|
|
586
|
-
const scheduleGcSweep = (scope) => {
|
|
587
|
-
PENDING_GC.add(scope);
|
|
588
|
-
if (PENDING_GC.size > 1)
|
|
589
|
-
return;
|
|
590
|
-
scheduleIdleCallback(() => {
|
|
591
|
-
for (const scope2 of PENDING_GC) {
|
|
592
|
-
scope2.sweepGc();
|
|
593
|
-
}
|
|
594
|
-
PENDING_GC.clear();
|
|
595
|
-
});
|
|
596
|
-
};
|
|
597
501
|
const flushWatchers = async () => {
|
|
598
502
|
const flush = currentFlush;
|
|
599
503
|
if (!flush)
|
|
@@ -658,7 +562,7 @@ function propagateDirty(signal2) {
|
|
|
658
562
|
scheduleAsyncPull(signal2);
|
|
659
563
|
}
|
|
660
564
|
} else {
|
|
661
|
-
if (signal2._isListener &&
|
|
565
|
+
if (signal2._isListener && signal2.watchCount > 0) {
|
|
662
566
|
schedulePull(signal2);
|
|
663
567
|
}
|
|
664
568
|
dirtySignalConsumers(signal2.subs);
|
|
@@ -762,6 +666,9 @@ function isGeneratorResult(value) {
|
|
|
762
666
|
function isPromise(value) {
|
|
763
667
|
return value.constructor === Promise;
|
|
764
668
|
}
|
|
669
|
+
function isThennable(value) {
|
|
670
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
671
|
+
}
|
|
765
672
|
function generatorResultToPromiseWithConsumer(generator, savedConsumer) {
|
|
766
673
|
function adopt(value) {
|
|
767
674
|
return typeof value === "object" && value !== null && (isPromise(value) || isReactivePromise(value)) ? value : Promise.resolve(value);
|
|
@@ -880,12 +787,6 @@ function callback(fn, idx, deps) {
|
|
|
880
787
|
}
|
|
881
788
|
return callback2.fn;
|
|
882
789
|
}
|
|
883
|
-
function isAbortError(error) {
|
|
884
|
-
if (typeof DOMException !== "undefined" && error instanceof DOMException) {
|
|
885
|
-
return error.name === "AbortError";
|
|
886
|
-
}
|
|
887
|
-
return error instanceof Error && error.name === "AbortError";
|
|
888
|
-
}
|
|
889
790
|
const arrayFrom = Array.from;
|
|
890
791
|
function isThenable(v) {
|
|
891
792
|
return v !== null && typeof v === "object" && typeof v.then === "function";
|
|
@@ -1224,10 +1125,6 @@ class ReactivePromiseImpl {
|
|
|
1224
1125
|
}
|
|
1225
1126
|
}
|
|
1226
1127
|
_setError(nextError, awaitSubs = this._awaitSubs) {
|
|
1227
|
-
if (nextError !== this._error && !isAbortError(nextError)) {
|
|
1228
|
-
const desc = this._signal?.desc ?? this._signal?.tracerMeta?.desc;
|
|
1229
|
-
console.error(`[signalium] Unhandled async error${desc ? ` in "${desc}"` : ""}:`, nextError);
|
|
1230
|
-
}
|
|
1231
1128
|
let error = this._error;
|
|
1232
1129
|
let notifyFlags = 0;
|
|
1233
1130
|
if (error !== nextError) {
|
|
@@ -1496,7 +1393,7 @@ function getSignal(signal2) {
|
|
|
1496
1393
|
});
|
|
1497
1394
|
}
|
|
1498
1395
|
if (currentConsumer.watchCount > 0) {
|
|
1499
|
-
watchSignal(signal2
|
|
1396
|
+
watchSignal(signal2);
|
|
1500
1397
|
}
|
|
1501
1398
|
}
|
|
1502
1399
|
const updatedAt = checkSignal(signal2);
|
|
@@ -1621,12 +1518,15 @@ function runSignal(signal2) {
|
|
|
1621
1518
|
}
|
|
1622
1519
|
}
|
|
1623
1520
|
function disconnectSignal(signal2, computedCount = signal2.computedCount) {
|
|
1624
|
-
const { ref, deps
|
|
1521
|
+
const { ref, deps } = signal2;
|
|
1625
1522
|
for (const [dep, edge] of deps) {
|
|
1626
1523
|
if (edge.consumedAt !== computedCount) {
|
|
1627
|
-
unwatchSignal(dep
|
|
1524
|
+
unwatchSignal(dep);
|
|
1628
1525
|
dep.subs.delete(ref);
|
|
1629
1526
|
deps.delete(dep);
|
|
1527
|
+
if (dep._state < 2) {
|
|
1528
|
+
dep._state = 2;
|
|
1529
|
+
}
|
|
1630
1530
|
}
|
|
1631
1531
|
}
|
|
1632
1532
|
}
|
|
@@ -1967,12 +1867,11 @@ class ReactiveSignal {
|
|
|
1967
1867
|
id = ++ID;
|
|
1968
1868
|
subs = /* @__PURE__ */ new Map();
|
|
1969
1869
|
deps = /* @__PURE__ */ new Map();
|
|
1970
|
-
ref = new WeakRef
|
|
1870
|
+
ref = new WeakRef(this);
|
|
1971
1871
|
dirtyHead = void 0;
|
|
1972
1872
|
updatedCount = 0;
|
|
1973
1873
|
computedCount = 0;
|
|
1974
1874
|
watchCount = 0;
|
|
1975
|
-
suspendCount = 0;
|
|
1976
1875
|
key;
|
|
1977
1876
|
args;
|
|
1978
1877
|
callbacks = void 0;
|
|
@@ -2007,31 +1906,24 @@ class ReactiveSignal {
|
|
|
2007
1906
|
get _isListener() {
|
|
2008
1907
|
return (this.flags & 16) !== 0;
|
|
2009
1908
|
}
|
|
2010
|
-
get _isSuspendedListener() {
|
|
2011
|
-
return (this.flags & 32) !== 0;
|
|
2012
|
-
}
|
|
2013
|
-
get _isSuspended() {
|
|
2014
|
-
const { watchCount, suspendCount } = this;
|
|
2015
|
-
return watchCount > 0 && watchCount === suspendCount;
|
|
2016
|
-
}
|
|
2017
1909
|
get _isActive() {
|
|
2018
|
-
return (this.flags &
|
|
1910
|
+
return (this.flags & 32) !== 0;
|
|
2019
1911
|
}
|
|
2020
1912
|
set _isActive(isActive) {
|
|
2021
1913
|
if (isActive) {
|
|
2022
|
-
this.flags |=
|
|
1914
|
+
this.flags |= 32;
|
|
2023
1915
|
} else {
|
|
2024
|
-
this.flags &= -
|
|
1916
|
+
this.flags &= -33;
|
|
2025
1917
|
}
|
|
2026
1918
|
}
|
|
2027
1919
|
get _isLazy() {
|
|
2028
|
-
return (this.flags &
|
|
1920
|
+
return (this.flags & 64) !== 0;
|
|
2029
1921
|
}
|
|
2030
1922
|
set _isLazy(isLazy) {
|
|
2031
1923
|
if (isLazy) {
|
|
2032
|
-
this.flags |=
|
|
1924
|
+
this.flags |= 64;
|
|
2033
1925
|
} else {
|
|
2034
|
-
this.flags &= -
|
|
1926
|
+
this.flags &= -65;
|
|
2035
1927
|
}
|
|
2036
1928
|
}
|
|
2037
1929
|
get listeners() {
|
|
@@ -2059,10 +1951,12 @@ class ReactiveSignal {
|
|
|
2059
1951
|
};
|
|
2060
1952
|
}
|
|
2061
1953
|
if (!this._isListener) {
|
|
2062
|
-
watchSignal(this
|
|
1954
|
+
watchSignal(this);
|
|
2063
1955
|
this.flags |= 16;
|
|
2064
1956
|
}
|
|
2065
|
-
|
|
1957
|
+
if (this.watchCount > 0) {
|
|
1958
|
+
schedulePull(this);
|
|
1959
|
+
}
|
|
2066
1960
|
current.set(listener, effective);
|
|
2067
1961
|
}
|
|
2068
1962
|
return () => {
|
|
@@ -2070,7 +1964,7 @@ class ReactiveSignal {
|
|
|
2070
1964
|
current.delete(listener);
|
|
2071
1965
|
if (current.size === 0) {
|
|
2072
1966
|
cancelPull(this);
|
|
2073
|
-
unwatchSignal(this
|
|
1967
|
+
unwatchSignal(this);
|
|
2074
1968
|
this.flags &= -17;
|
|
2075
1969
|
this.listeners.updatedAt = 0;
|
|
2076
1970
|
}
|
|
@@ -2080,39 +1974,15 @@ class ReactiveSignal {
|
|
|
2080
1974
|
// This method is used in React hooks specifically. It returns a bound add method
|
|
2081
1975
|
// that is cached to avoid creating a new one on each call, and it eagerly sets
|
|
2082
1976
|
// the listener as watched so that relays that are accessed will be activated.
|
|
2083
|
-
addListenerLazy() {
|
|
1977
|
+
addListenerLazy(watch = true) {
|
|
2084
1978
|
if (!this._isListener) {
|
|
2085
|
-
|
|
1979
|
+
if (watch) {
|
|
1980
|
+
watchSignal(this);
|
|
1981
|
+
}
|
|
2086
1982
|
this.flags |= 16;
|
|
2087
1983
|
}
|
|
2088
1984
|
return this.listeners.cachedBoundAdd;
|
|
2089
1985
|
}
|
|
2090
|
-
setSuspended(suspended) {
|
|
2091
|
-
const { flags } = this;
|
|
2092
|
-
const isListener = (flags & 16) !== 0;
|
|
2093
|
-
const isSuspendedListener = (flags & 32) !== 0;
|
|
2094
|
-
if (suspended && !isSuspendedListener) {
|
|
2095
|
-
this.flags = flags | 32;
|
|
2096
|
-
if (isListener) {
|
|
2097
|
-
suspendSignal(this);
|
|
2098
|
-
}
|
|
2099
|
-
} else if (!suspended && isSuspendedListener) {
|
|
2100
|
-
this.flags = flags & -33;
|
|
2101
|
-
if (isListener) {
|
|
2102
|
-
resumeSignal(this);
|
|
2103
|
-
}
|
|
2104
|
-
}
|
|
2105
|
-
}
|
|
2106
|
-
reset() {
|
|
2107
|
-
this.flags = (this.def.isRelay ? 8 : 0) | 2;
|
|
2108
|
-
this.dirtyHead = void 0;
|
|
2109
|
-
this.updatedCount = 0;
|
|
2110
|
-
this.computedCount = 0;
|
|
2111
|
-
this.deps = /* @__PURE__ */ new Map();
|
|
2112
|
-
this.subs = /* @__PURE__ */ new Map();
|
|
2113
|
-
this.watchCount = 0;
|
|
2114
|
-
this.suspendCount = 0;
|
|
2115
|
-
}
|
|
2116
1986
|
}
|
|
2117
1987
|
const runListeners = (signal2) => {
|
|
2118
1988
|
const { listeners } = signal2;
|
|
@@ -2130,6 +2000,10 @@ const isRelay = (signal2) => {
|
|
|
2130
2000
|
function createReactiveSignal(def, args = [], key, scope) {
|
|
2131
2001
|
return new ReactiveSignal(def, args, key, scope);
|
|
2132
2002
|
}
|
|
2003
|
+
let requestScopeGetter;
|
|
2004
|
+
function setRequestScopeGetter(get) {
|
|
2005
|
+
requestScopeGetter = get;
|
|
2006
|
+
}
|
|
2133
2007
|
let CONTEXT_ID = 0;
|
|
2134
2008
|
class ContextImpl {
|
|
2135
2009
|
defaultValue;
|
|
@@ -2171,7 +2045,6 @@ class SignalScope {
|
|
|
2171
2045
|
contexts;
|
|
2172
2046
|
children = /* @__PURE__ */ new Map();
|
|
2173
2047
|
signals = /* @__PURE__ */ new Map();
|
|
2174
|
-
gcCandidates = /* @__PURE__ */ new Set();
|
|
2175
2048
|
setContexts(contexts) {
|
|
2176
2049
|
for (const [context2, value] of contexts) {
|
|
2177
2050
|
this.contexts[context2._key] = value;
|
|
@@ -2197,38 +2070,13 @@ class SignalScope {
|
|
|
2197
2070
|
get(def, args) {
|
|
2198
2071
|
const paramKey = def.paramKey?.(...args);
|
|
2199
2072
|
const key = hashReactiveFn(def.compute, paramKey ? [paramKey] : args);
|
|
2200
|
-
let signal2 = this.signals.get(key);
|
|
2073
|
+
let signal2 = this.signals.get(key)?.deref();
|
|
2201
2074
|
if (signal2 === void 0) {
|
|
2202
2075
|
signal2 = createReactiveSignal(def, args, key, this);
|
|
2203
|
-
this.signals.set(key, signal2);
|
|
2076
|
+
this.signals.set(key, new WeakRef(signal2));
|
|
2204
2077
|
}
|
|
2205
2078
|
return signal2;
|
|
2206
2079
|
}
|
|
2207
|
-
markForGc(signal2) {
|
|
2208
|
-
if (!this.gcCandidates.has(signal2)) {
|
|
2209
|
-
this.gcCandidates.add(signal2);
|
|
2210
|
-
scheduleGcSweep(this);
|
|
2211
|
-
}
|
|
2212
|
-
}
|
|
2213
|
-
removeFromGc(signal2) {
|
|
2214
|
-
this.gcCandidates.delete(signal2);
|
|
2215
|
-
const { key } = signal2;
|
|
2216
|
-
if (key) {
|
|
2217
|
-
this.signals.set(key, signal2);
|
|
2218
|
-
}
|
|
2219
|
-
}
|
|
2220
|
-
forceGc(signal2) {
|
|
2221
|
-
this.signals.delete(signal2.key);
|
|
2222
|
-
}
|
|
2223
|
-
sweepGc() {
|
|
2224
|
-
const signals = this.signals;
|
|
2225
|
-
for (const signal2 of this.gcCandidates) {
|
|
2226
|
-
if (signal2.watchCount === 0) {
|
|
2227
|
-
signals.delete(signal2.key);
|
|
2228
|
-
}
|
|
2229
|
-
}
|
|
2230
|
-
this.gcCandidates = /* @__PURE__ */ new Set();
|
|
2231
|
-
}
|
|
2232
2080
|
}
|
|
2233
2081
|
let GLOBAL_SCOPE = new SignalScope([]);
|
|
2234
2082
|
const getGlobalScope = () => {
|
|
@@ -2248,7 +2096,7 @@ const getInternalCurrentScope = () => {
|
|
|
2248
2096
|
return CURRENT_SCOPE;
|
|
2249
2097
|
};
|
|
2250
2098
|
const getCurrentScope = (fallback = GLOBAL_SCOPE) => {
|
|
2251
|
-
return CURRENT_SCOPE ?? getCurrentConsumer()?.scope ?? fallback;
|
|
2099
|
+
return CURRENT_SCOPE ?? getCurrentConsumer()?.scope ?? requestScopeGetter?.() ?? fallback;
|
|
2252
2100
|
};
|
|
2253
2101
|
const SCOPE_OWNER_MAP = /* @__PURE__ */ new WeakMap();
|
|
2254
2102
|
const OWNER_CHILD_MAP = /* @__PURE__ */ new WeakMap();
|
|
@@ -2275,46 +2123,50 @@ const getScopeOwner = (obj) => {
|
|
|
2275
2123
|
return scope;
|
|
2276
2124
|
};
|
|
2277
2125
|
export {
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2126
|
+
settled as A,
|
|
2127
|
+
context as B,
|
|
2128
|
+
getContext as C,
|
|
2129
|
+
withContexts as D,
|
|
2130
|
+
setGlobalContexts as E,
|
|
2131
|
+
clearGlobalContexts as F,
|
|
2132
|
+
setScopeOwner as G,
|
|
2133
|
+
setTracing as H,
|
|
2134
|
+
createTracer as I,
|
|
2135
|
+
createTracerFromId as J,
|
|
2136
|
+
removeTracer as K,
|
|
2137
|
+
Tracer as L,
|
|
2138
|
+
SignalType as M,
|
|
2139
|
+
getTracerProxy as N,
|
|
2140
|
+
scheduleTracer as O,
|
|
2289
2141
|
ReactivePromise as R,
|
|
2290
2142
|
SignalScope as S,
|
|
2291
2143
|
TracerEventType as T,
|
|
2292
2144
|
VisualizerNode as V,
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2145
|
+
generatorResultToPromiseWithConsumer as a,
|
|
2146
|
+
getCurrentConsumer as b,
|
|
2147
|
+
createReactiveSignal as c,
|
|
2148
|
+
setRequestScopeGetter as d,
|
|
2149
|
+
createReactiveDefinition as e,
|
|
2150
|
+
createTask as f,
|
|
2299
2151
|
getCurrentScope as g,
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2152
|
+
createRelay as h,
|
|
2153
|
+
getScopeOwner as i,
|
|
2154
|
+
isReactivePromise as j,
|
|
2155
|
+
getGlobalScope as k,
|
|
2156
|
+
hashValue as l,
|
|
2157
|
+
schedulePull as m,
|
|
2158
|
+
isPromise as n,
|
|
2159
|
+
isThennable as o,
|
|
2160
|
+
signal as p,
|
|
2161
|
+
getSignal as q,
|
|
2310
2162
|
runSignal as r,
|
|
2311
|
-
|
|
2312
|
-
|
|
2163
|
+
setCurrentConsumer as s,
|
|
2164
|
+
registerCustomHash as t,
|
|
2313
2165
|
unwatchSignal as u,
|
|
2314
|
-
|
|
2166
|
+
setReactivePromise as v,
|
|
2315
2167
|
watchSignal as w,
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2168
|
+
notifier as x,
|
|
2169
|
+
isSignal as y,
|
|
2170
|
+
callback as z
|
|
2319
2171
|
};
|
|
2320
|
-
//# sourceMappingURL=debug-
|
|
2172
|
+
//# sourceMappingURL=debug-BTLbgTPK.js.map
|