signalium 2.2.3 → 2.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/CHANGELOG.md +16 -0
- package/dist/cjs/development/config-B0MtLBgx.js.map +1 -1
- package/dist/cjs/development/{debug-3nd-6Gnf.js → debug-CmcrpeEO.js} +228 -207
- package/dist/cjs/development/debug-CmcrpeEO.js.map +1 -0
- package/dist/cjs/development/debug.js +9 -3
- package/dist/cjs/development/debug.js.map +1 -1
- package/dist/cjs/development/index.js +9 -8
- package/dist/cjs/development/index.js.map +1 -1
- package/dist/cjs/development/react/index.js +43 -38
- package/dist/cjs/development/react/index.js.map +1 -1
- package/dist/cjs/development/snapshot-BJN--_kH.js +147 -0
- package/dist/cjs/development/snapshot-BJN--_kH.js.map +1 -0
- package/dist/cjs/development/transform/index.js +137 -118
- package/dist/cjs/development/transform/index.js.map +1 -1
- package/dist/cjs/development/utils.js +5 -3
- package/dist/cjs/development/utils.js.map +1 -1
- package/dist/cjs/production/config-B0MtLBgx.js.map +1 -1
- package/dist/cjs/production/{contexts-DoZWv_3I.js → contexts-DCujds9v.js} +147 -133
- package/dist/cjs/production/contexts-DCujds9v.js.map +1 -0
- package/dist/cjs/production/debug.js +61 -66
- package/dist/cjs/production/debug.js.map +1 -1
- package/dist/cjs/production/index.js +9 -8
- package/dist/cjs/production/index.js.map +1 -1
- package/dist/cjs/production/react/index.js +43 -38
- package/dist/cjs/production/react/index.js.map +1 -1
- package/dist/cjs/production/snapshot-CRhlFRNu.js +147 -0
- package/dist/cjs/production/snapshot-CRhlFRNu.js.map +1 -0
- package/dist/cjs/production/transform/index.js +137 -118
- package/dist/cjs/production/transform/index.js.map +1 -1
- package/dist/cjs/production/utils.js +5 -3
- package/dist/cjs/production/utils.js.map +1 -1
- package/dist/esm/development/config-CPQL7hX-.js.map +1 -1
- package/dist/esm/development/{debug-BfudYKc4.js → debug-B6Cqxyzi.js} +228 -205
- package/dist/esm/development/debug-B6Cqxyzi.js.map +1 -0
- package/dist/esm/development/debug.js +9 -9
- package/dist/esm/development/index.js +15 -14
- package/dist/esm/development/react/index.js +43 -38
- package/dist/esm/development/react/index.js.map +1 -1
- package/dist/esm/development/snapshot-BeaCnwxd.js +148 -0
- package/dist/esm/development/snapshot-BeaCnwxd.js.map +1 -0
- package/dist/esm/development/transform/index.js +137 -118
- package/dist/esm/development/transform/index.js.map +1 -1
- package/dist/esm/development/utils.js +7 -4
- package/dist/esm/development/utils.js.map +1 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/internals/async.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/edge.d.ts +4 -4
- package/dist/esm/internals/edge.d.ts.map +1 -1
- package/dist/esm/internals/reactive.d.ts +1 -0
- package/dist/esm/internals/reactive.d.ts.map +1 -1
- package/dist/esm/internals/scheduling.d.ts.map +1 -1
- package/dist/esm/internals/signal.d.ts +4 -0
- package/dist/esm/internals/signal.d.ts.map +1 -1
- package/dist/esm/internals/utils/snapshot.d.ts +29 -0
- package/dist/esm/internals/utils/snapshot.d.ts.map +1 -0
- package/dist/esm/production/config-CPQL7hX-.js.map +1 -1
- package/dist/esm/production/{contexts-CilfS6eG.js → contexts-DL91-2Y8.js} +158 -144
- package/dist/esm/production/contexts-DL91-2Y8.js.map +1 -0
- package/dist/esm/production/debug.js +51 -54
- package/dist/esm/production/debug.js.map +1 -1
- package/dist/esm/production/index.js +16 -15
- package/dist/esm/production/react/index.js +43 -38
- package/dist/esm/production/react/index.js.map +1 -1
- package/dist/esm/production/snapshot-Cj4ycaEt.js +148 -0
- package/dist/esm/production/snapshot-Cj4ycaEt.js.map +1 -0
- package/dist/esm/production/transform/index.js +137 -118
- package/dist/esm/production/transform/index.js.map +1 -1
- package/dist/esm/production/utils.js +7 -4
- package/dist/esm/production/utils.js.map +1 -1
- package/dist/esm/react/index.d.ts +1 -1
- package/dist/esm/react/index.d.ts.map +1 -1
- package/dist/esm/react/provider.d.ts.map +1 -1
- package/dist/esm/react/use-reactive.d.ts +1 -0
- package/dist/esm/react/use-reactive.d.ts.map +1 -1
- package/dist/esm/transform/callback.d.ts.map +1 -1
- package/dist/esm/transform/promise.d.ts.map +1 -1
- package/dist/esm/utils.d.ts +1 -0
- package/dist/esm/utils.d.ts.map +1 -1
- package/package.json +7 -5
- package/dist/cjs/development/core-api-C6HCIyL3.js +0 -55
- package/dist/cjs/development/core-api-C6HCIyL3.js.map +0 -1
- package/dist/cjs/development/debug-3nd-6Gnf.js.map +0 -1
- package/dist/cjs/production/contexts-DoZWv_3I.js.map +0 -1
- package/dist/cjs/production/core-api-CUviCxtM.js +0 -55
- package/dist/cjs/production/core-api-CUviCxtM.js.map +0 -1
- package/dist/esm/development/core-api-CjsScNn1.js +0 -56
- package/dist/esm/development/core-api-CjsScNn1.js.map +0 -1
- package/dist/esm/development/debug-BfudYKc4.js.map +0 -1
- package/dist/esm/production/contexts-CilfS6eG.js.map +0 -1
- package/dist/esm/production/core-api-tTQttL8R.js +0 -56
- package/dist/esm/production/core-api-tTQttL8R.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { s as scheduleFlush$1, r as runBatch } from "./config-CPQL7hX-.js";
|
|
2
2
|
class WeakRefPolyfill {
|
|
3
|
+
value;
|
|
3
4
|
constructor(value) {
|
|
4
5
|
this.value = value;
|
|
5
6
|
}
|
|
@@ -22,7 +23,8 @@ let TRACER;
|
|
|
22
23
|
const getTracerProxy = () => {
|
|
23
24
|
return TRACER;
|
|
24
25
|
};
|
|
25
|
-
var TracerEventType
|
|
26
|
+
var TracerEventType;
|
|
27
|
+
(function(TracerEventType2) {
|
|
26
28
|
TracerEventType2["StartUpdate"] = "StartUpdate";
|
|
27
29
|
TracerEventType2["EndUpdate"] = "EndUpdate";
|
|
28
30
|
TracerEventType2["StartLoading"] = "StartLoading";
|
|
@@ -30,15 +32,31 @@ var TracerEventType = /* @__PURE__ */ ((TracerEventType2) => {
|
|
|
30
32
|
TracerEventType2["Connected"] = "Connected";
|
|
31
33
|
TracerEventType2["Disconnected"] = "Disconnected";
|
|
32
34
|
TracerEventType2["ConsumeState"] = "ConsumeState";
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
})(TracerEventType || (TracerEventType = {}));
|
|
36
|
+
var SignalType;
|
|
37
|
+
(function(SignalType2) {
|
|
36
38
|
SignalType2["State"] = "state";
|
|
37
39
|
SignalType2["Reactive"] = "reactive";
|
|
38
40
|
SignalType2["Watcher"] = "watcher";
|
|
39
|
-
|
|
40
|
-
})(SignalType || {});
|
|
41
|
+
})(SignalType || (SignalType = {}));
|
|
41
42
|
class VisualizerNode {
|
|
43
|
+
tracer;
|
|
44
|
+
depth;
|
|
45
|
+
type;
|
|
46
|
+
id;
|
|
47
|
+
value;
|
|
48
|
+
name;
|
|
49
|
+
params;
|
|
50
|
+
_setValue;
|
|
51
|
+
subscribers = [];
|
|
52
|
+
nextStateChildren = [];
|
|
53
|
+
stateChildren = [];
|
|
54
|
+
children = [];
|
|
55
|
+
updating = true;
|
|
56
|
+
loading = false;
|
|
57
|
+
version = 0;
|
|
58
|
+
updatingVersion = 0;
|
|
59
|
+
didConnect = false;
|
|
42
60
|
constructor(tracer, depth, type, id, value, name, params, _setValue) {
|
|
43
61
|
this.tracer = tracer;
|
|
44
62
|
this.depth = depth;
|
|
@@ -50,15 +68,6 @@ class VisualizerNode {
|
|
|
50
68
|
this._setValue = _setValue;
|
|
51
69
|
this.tracer.maxDepth = Math.max(this.tracer.maxDepth, this.depth);
|
|
52
70
|
}
|
|
53
|
-
subscribers = [];
|
|
54
|
-
nextStateChildren = [];
|
|
55
|
-
stateChildren = [];
|
|
56
|
-
children = [];
|
|
57
|
-
updating = true;
|
|
58
|
-
loading = false;
|
|
59
|
-
version = 0;
|
|
60
|
-
updatingVersion = 0;
|
|
61
|
-
didConnect = false;
|
|
62
71
|
get showParams() {
|
|
63
72
|
return this.tracer.showParams;
|
|
64
73
|
}
|
|
@@ -69,16 +78,14 @@ class VisualizerNode {
|
|
|
69
78
|
return this.tracer.interactive;
|
|
70
79
|
}
|
|
71
80
|
setValue(value) {
|
|
72
|
-
if (this.type !==
|
|
81
|
+
if (this.type !== SignalType.State) {
|
|
73
82
|
throw new Error("setValue is only allowed on state nodes");
|
|
74
83
|
}
|
|
75
84
|
this._setValue?.(value);
|
|
76
85
|
this.notify();
|
|
77
86
|
}
|
|
78
87
|
connectChild(child) {
|
|
79
|
-
let childLink = this.children.find(
|
|
80
|
-
(link) => link.node.id === child.id || link.node.name === child.name && link.version !== this.updatingVersion
|
|
81
|
-
);
|
|
88
|
+
let childLink = this.children.find((link) => link.node.id === child.id || link.node.name === child.name && link.version !== this.updatingVersion);
|
|
82
89
|
let shouldSkip = false;
|
|
83
90
|
if (childLink) {
|
|
84
91
|
if (!child.didConnect) {
|
|
@@ -141,16 +148,7 @@ class VisualizerNode {
|
|
|
141
148
|
this.nextStateChildren.push(existing);
|
|
142
149
|
existing.notify();
|
|
143
150
|
} else {
|
|
144
|
-
const node = new VisualizerNode(
|
|
145
|
-
this.tracer,
|
|
146
|
-
this.depth + 1,
|
|
147
|
-
"state",
|
|
148
|
-
id,
|
|
149
|
-
value,
|
|
150
|
-
name,
|
|
151
|
-
void 0,
|
|
152
|
-
setValue
|
|
153
|
-
);
|
|
151
|
+
const node = new VisualizerNode(this.tracer, this.depth + 1, SignalType.State, id, value, name, void 0, setValue);
|
|
154
152
|
node.updating = false;
|
|
155
153
|
this.nextStateChildren.push(node);
|
|
156
154
|
}
|
|
@@ -195,39 +193,39 @@ class TraceFlush {
|
|
|
195
193
|
}
|
|
196
194
|
}
|
|
197
195
|
class Tracer {
|
|
196
|
+
showParams;
|
|
197
|
+
showValue;
|
|
198
|
+
interactive;
|
|
199
|
+
nodeMap = /* @__PURE__ */ new Map();
|
|
200
|
+
delay = 200;
|
|
201
|
+
maxDepth = 0;
|
|
202
|
+
initialized = false;
|
|
198
203
|
constructor(id, immediate = false, showParams = true, showValue = true, interactive = true) {
|
|
199
204
|
this.showParams = showParams;
|
|
200
205
|
this.showValue = showValue;
|
|
201
206
|
this.interactive = interactive;
|
|
202
207
|
this.initialized = !immediate;
|
|
203
|
-
const node = new VisualizerNode(this, 0,
|
|
208
|
+
const node = new VisualizerNode(this, 0, SignalType.Watcher, id, "");
|
|
204
209
|
this.rootNode = node;
|
|
205
210
|
this.nodeMap.set(id, node);
|
|
206
211
|
}
|
|
207
|
-
nodeMap = /* @__PURE__ */ new Map();
|
|
208
|
-
delay = 200;
|
|
209
|
-
maxDepth = 0;
|
|
210
|
-
initialized = false;
|
|
211
212
|
rootNode;
|
|
212
213
|
eventQueue = [];
|
|
213
214
|
currentFlush;
|
|
214
215
|
emit(event) {
|
|
215
|
-
if (event.type ===
|
|
216
|
+
if (event.type === TracerEventType.Connected || event.type === TracerEventType.ConsumeState) {
|
|
216
217
|
const node = this.nodeMap.get(event.id);
|
|
217
|
-
if (!node || event.type ===
|
|
218
|
+
if (!node || event.type === TracerEventType.Connected && !event.name) {
|
|
218
219
|
return;
|
|
219
220
|
}
|
|
220
221
|
if (!this.nodeMap.has(event.childId)) {
|
|
221
|
-
const name = event.type ===
|
|
222
|
-
const params = event.type ===
|
|
223
|
-
const nodeType = event.type ===
|
|
224
|
-
this.nodeMap.set(
|
|
225
|
-
event.childId,
|
|
226
|
-
new VisualizerNode(this, node.depth + 1, nodeType, event.childId, "", name, params)
|
|
227
|
-
);
|
|
222
|
+
const name = event.type === TracerEventType.Connected ? event.name : void 0;
|
|
223
|
+
const params = event.type === TracerEventType.Connected ? event.params : void 0;
|
|
224
|
+
const nodeType = event.type === TracerEventType.Connected ? event.nodeType : SignalType.State;
|
|
225
|
+
this.nodeMap.set(event.childId, new VisualizerNode(this, node.depth + 1, nodeType, event.childId, "", name, params));
|
|
228
226
|
}
|
|
229
227
|
}
|
|
230
|
-
if (event.type ===
|
|
228
|
+
if (event.type === TracerEventType.StartLoading || event.type === TracerEventType.EndLoading) {
|
|
231
229
|
scheduleTracer(this);
|
|
232
230
|
}
|
|
233
231
|
if (this.initialized) {
|
|
@@ -241,28 +239,28 @@ class Tracer {
|
|
|
241
239
|
if (!node) {
|
|
242
240
|
return true;
|
|
243
241
|
}
|
|
244
|
-
let skipDelay = nextEvent?.type ===
|
|
245
|
-
if (event.type ===
|
|
242
|
+
let skipDelay = nextEvent?.type === TracerEventType.StartLoading;
|
|
243
|
+
if (event.type === TracerEventType.Connected) {
|
|
246
244
|
let child = this.nodeMap.get(event.childId);
|
|
247
245
|
if (!child) {
|
|
248
246
|
throw new Error(`Child node ${event.childId} not found`);
|
|
249
247
|
}
|
|
250
248
|
skipDelay = node.connectChild(child);
|
|
251
|
-
} else if (event.type ===
|
|
249
|
+
} else if (event.type === TracerEventType.Disconnected) {
|
|
252
250
|
node.disconnectChild(event.childId);
|
|
253
|
-
} else if (event.type ===
|
|
251
|
+
} else if (event.type === TracerEventType.StartUpdate) {
|
|
254
252
|
node.startUpdate();
|
|
255
|
-
if (nextEvent && nextEvent.id === event.id && (nextEvent.type ===
|
|
253
|
+
if (nextEvent && nextEvent.id === event.id && (nextEvent.type === TracerEventType.EndUpdate || nextEvent.type === TracerEventType.StartLoading)) {
|
|
256
254
|
skipDelay = true;
|
|
257
255
|
}
|
|
258
|
-
} else if (event.type ===
|
|
256
|
+
} else if (event.type === TracerEventType.EndUpdate) {
|
|
259
257
|
node.endUpdate(event.value, event.preserveChildren);
|
|
260
|
-
} else if (event.type ===
|
|
258
|
+
} else if (event.type === TracerEventType.StartLoading) {
|
|
261
259
|
node.startLoading();
|
|
262
260
|
skipDelay = true;
|
|
263
|
-
} else if (event.type ===
|
|
261
|
+
} else if (event.type === TracerEventType.EndLoading) {
|
|
264
262
|
node.endLoading(event.value);
|
|
265
|
-
} else if (event.type ===
|
|
263
|
+
} else if (event.type === TracerEventType.ConsumeState) {
|
|
266
264
|
node.consumeState(event.childId, event.name, event.value, event.setValue);
|
|
267
265
|
}
|
|
268
266
|
return skipDelay;
|
|
@@ -328,8 +326,21 @@ const setCurrentConsumer = (consumer) => {
|
|
|
328
326
|
const getCurrentConsumer = () => {
|
|
329
327
|
return CURRENT_CONSUMER;
|
|
330
328
|
};
|
|
329
|
+
const DEFAULT_EQUALS = (a, b) => a === b;
|
|
330
|
+
const FALSE_EQUALS = () => false;
|
|
331
|
+
const equalsFrom = (equals) => {
|
|
332
|
+
if (equals === false) {
|
|
333
|
+
return FALSE_EQUALS;
|
|
334
|
+
}
|
|
335
|
+
return equals ?? DEFAULT_EQUALS;
|
|
336
|
+
};
|
|
331
337
|
let STATE_ID = 0;
|
|
338
|
+
const SIGNAL_BRAND = /* @__PURE__ */ Symbol.for("signalium.signal");
|
|
339
|
+
function isSignal(value) {
|
|
340
|
+
return typeof value === "object" && value !== null && value[SIGNAL_BRAND] === true;
|
|
341
|
+
}
|
|
332
342
|
class StateSignal {
|
|
343
|
+
[SIGNAL_BRAND] = true;
|
|
333
344
|
_value;
|
|
334
345
|
_equals;
|
|
335
346
|
_subs = /* @__PURE__ */ new Map();
|
|
@@ -339,8 +350,10 @@ class StateSignal {
|
|
|
339
350
|
constructor(value, equals = (a, b) => a === b, desc = "signal") {
|
|
340
351
|
this._value = value;
|
|
341
352
|
this._equals = equals;
|
|
342
|
-
|
|
343
|
-
|
|
353
|
+
{
|
|
354
|
+
this._id = STATE_ID++;
|
|
355
|
+
this._desc = desc;
|
|
356
|
+
}
|
|
344
357
|
}
|
|
345
358
|
get value() {
|
|
346
359
|
this.consume();
|
|
@@ -384,7 +397,7 @@ class StateSignal {
|
|
|
384
397
|
}
|
|
385
398
|
dirtySignal(sub);
|
|
386
399
|
}
|
|
387
|
-
this._subs
|
|
400
|
+
this._subs.clear();
|
|
388
401
|
scheduleListeners(this);
|
|
389
402
|
}
|
|
390
403
|
addListener(listener) {
|
|
@@ -405,13 +418,12 @@ function runListeners$1(signal2) {
|
|
|
405
418
|
listener();
|
|
406
419
|
}
|
|
407
420
|
}
|
|
408
|
-
const FALSE_EQUALS$1 = () => false;
|
|
409
421
|
function signal(initialValue, opts) {
|
|
410
|
-
const equals = opts?.equals === false ? FALSE_EQUALS
|
|
422
|
+
const equals = opts?.equals === false ? FALSE_EQUALS : opts?.equals ?? ((a, b) => a === b);
|
|
411
423
|
return new StateSignal(initialValue, equals, opts?.desc);
|
|
412
424
|
}
|
|
413
425
|
const notifier = (opts) => {
|
|
414
|
-
return new StateSignal(void 0, FALSE_EQUALS
|
|
426
|
+
return new StateSignal(void 0, FALSE_EQUALS, opts?.desc);
|
|
415
427
|
};
|
|
416
428
|
function watchSignal(signal2, parentIsSuspended) {
|
|
417
429
|
if (parentIsSuspended) {
|
|
@@ -535,7 +547,8 @@ let PENDING_GC = /* @__PURE__ */ new Set();
|
|
|
535
547
|
const microtask = () => Promise.resolve();
|
|
536
548
|
let currentFlush = null;
|
|
537
549
|
const scheduleFlush = (fn) => {
|
|
538
|
-
if (currentFlush)
|
|
550
|
+
if (currentFlush)
|
|
551
|
+
return;
|
|
539
552
|
let resolve;
|
|
540
553
|
const promise = new Promise((r) => resolve = r);
|
|
541
554
|
currentFlush = { promise, resolve };
|
|
@@ -572,7 +585,8 @@ const scheduleTracer = (tracer) => {
|
|
|
572
585
|
};
|
|
573
586
|
const scheduleGcSweep = (scope) => {
|
|
574
587
|
PENDING_GC.add(scope);
|
|
575
|
-
if (PENDING_GC.size > 1)
|
|
588
|
+
if (PENDING_GC.size > 1)
|
|
589
|
+
return;
|
|
576
590
|
scheduleIdleCallback(() => {
|
|
577
591
|
for (const scope2 of PENDING_GC) {
|
|
578
592
|
scope2.sweepGc();
|
|
@@ -582,6 +596,8 @@ const scheduleGcSweep = (scope) => {
|
|
|
582
596
|
};
|
|
583
597
|
const flushWatchers = async () => {
|
|
584
598
|
const flush = currentFlush;
|
|
599
|
+
if (!flush)
|
|
600
|
+
return;
|
|
585
601
|
while (PENDING_ASYNC_PULLS.length > 0 || PENDING_PULLS.size > 0) {
|
|
586
602
|
const asyncPulls = PENDING_ASYNC_PULLS;
|
|
587
603
|
PENDING_ASYNC_PULLS = [];
|
|
@@ -625,19 +641,17 @@ const settled = async () => {
|
|
|
625
641
|
};
|
|
626
642
|
function dirtySignal(signal2) {
|
|
627
643
|
const prevState = signal2._state;
|
|
628
|
-
if (prevState ===
|
|
644
|
+
if (prevState === 2) {
|
|
629
645
|
return;
|
|
630
646
|
}
|
|
631
|
-
signal2._state =
|
|
632
|
-
if (prevState <
|
|
647
|
+
signal2._state = 2;
|
|
648
|
+
if (prevState < 3) {
|
|
633
649
|
propagateDirty(signal2);
|
|
634
650
|
}
|
|
635
651
|
}
|
|
636
652
|
function propagateDirty(signal2) {
|
|
637
653
|
if (getCurrentConsumer() === signal2) {
|
|
638
|
-
throw new Error(
|
|
639
|
-
"A signal was dirtied after it was consumed by the current function. This can cause race conditions and infinite rerenders and is not allowed."
|
|
640
|
-
);
|
|
654
|
+
throw new Error("A signal was dirtied after it was consumed by the current function. This can cause race conditions and infinite rerenders and is not allowed.");
|
|
641
655
|
}
|
|
642
656
|
if (isRelay(signal2)) {
|
|
643
657
|
if (signal2.watchCount > 0) {
|
|
@@ -648,31 +662,32 @@ function propagateDirty(signal2) {
|
|
|
648
662
|
schedulePull(signal2);
|
|
649
663
|
}
|
|
650
664
|
dirtySignalConsumers(signal2.subs);
|
|
651
|
-
signal2.subs
|
|
665
|
+
signal2.subs.clear();
|
|
652
666
|
}
|
|
653
667
|
}
|
|
654
668
|
function dirtySignalConsumers(map) {
|
|
655
669
|
for (const [subRef, edge] of map) {
|
|
656
670
|
const sub = subRef.deref();
|
|
657
|
-
if (sub === void 0 || sub.computedCount !== edge.consumedAt)
|
|
671
|
+
if (sub === void 0 || sub.computedCount !== edge.consumedAt)
|
|
672
|
+
continue;
|
|
658
673
|
const dirtyState = sub._state;
|
|
659
674
|
switch (dirtyState) {
|
|
660
|
-
case
|
|
661
|
-
sub._state =
|
|
675
|
+
case 0:
|
|
676
|
+
sub._state = 3;
|
|
662
677
|
sub.dirtyHead = edge;
|
|
663
678
|
edge.nextDirty = void 0;
|
|
664
679
|
propagateDirty(sub);
|
|
665
680
|
break;
|
|
666
|
-
case
|
|
667
|
-
case
|
|
668
|
-
case
|
|
681
|
+
case 1:
|
|
682
|
+
case 3:
|
|
683
|
+
case 4: {
|
|
669
684
|
let subEdge = sub.dirtyHead;
|
|
670
685
|
const ord = edge.ord;
|
|
671
686
|
if (subEdge.ord > ord) {
|
|
672
687
|
sub.dirtyHead = edge;
|
|
673
688
|
edge.nextDirty = subEdge;
|
|
674
|
-
if (dirtyState ===
|
|
675
|
-
sub._state =
|
|
689
|
+
if (dirtyState === 1 || dirtyState === 4) {
|
|
690
|
+
sub._state = 3;
|
|
676
691
|
propagateDirty(sub);
|
|
677
692
|
}
|
|
678
693
|
} else {
|
|
@@ -693,21 +708,25 @@ function dirtySignalConsumers(map) {
|
|
|
693
708
|
}
|
|
694
709
|
}
|
|
695
710
|
let CURRENT_ORD = 0;
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
711
|
+
class EdgeBase {
|
|
712
|
+
type;
|
|
713
|
+
dep;
|
|
714
|
+
ord;
|
|
715
|
+
updatedAt;
|
|
716
|
+
consumedAt;
|
|
717
|
+
nextDirty;
|
|
718
|
+
constructor(type, dep, updatedAt, consumedAt) {
|
|
719
|
+
this.type = type;
|
|
720
|
+
this.dep = dep;
|
|
721
|
+
this.ord = CURRENT_ORD++;
|
|
722
|
+
this.updatedAt = updatedAt;
|
|
723
|
+
this.consumedAt = consumedAt;
|
|
724
|
+
this.nextDirty = void 0;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
701
727
|
function createEdge(prevEdge, type, dep, updatedAt, consumedAt) {
|
|
702
728
|
if (prevEdge === void 0) {
|
|
703
|
-
return
|
|
704
|
-
type,
|
|
705
|
-
dep,
|
|
706
|
-
ord: CURRENT_ORD++,
|
|
707
|
-
updatedAt,
|
|
708
|
-
consumedAt,
|
|
709
|
-
nextDirty: void 0
|
|
710
|
-
};
|
|
729
|
+
return new EdgeBase(type, dep, updatedAt, consumedAt);
|
|
711
730
|
}
|
|
712
731
|
prevEdge.ord = CURRENT_ORD++;
|
|
713
732
|
prevEdge.updatedAt = updatedAt;
|
|
@@ -735,14 +754,6 @@ function findAndRemoveDirty(sub, dep) {
|
|
|
735
754
|
}
|
|
736
755
|
return void 0;
|
|
737
756
|
}
|
|
738
|
-
const DEFAULT_EQUALS = (a, b) => a === b;
|
|
739
|
-
const FALSE_EQUALS = () => false;
|
|
740
|
-
const equalsFrom = (equals) => {
|
|
741
|
-
if (equals === false) {
|
|
742
|
-
return FALSE_EQUALS;
|
|
743
|
-
}
|
|
744
|
-
return equals ?? DEFAULT_EQUALS;
|
|
745
|
-
};
|
|
746
757
|
const GeneratorResultConstructor = (function* () {
|
|
747
758
|
})().constructor;
|
|
748
759
|
function isGeneratorResult(value) {
|
|
@@ -869,6 +880,9 @@ function callback(fn, idx, deps) {
|
|
|
869
880
|
}
|
|
870
881
|
return callback2.fn;
|
|
871
882
|
}
|
|
883
|
+
function isAbortError(error) {
|
|
884
|
+
return error instanceof DOMException && error.name === "AbortError";
|
|
885
|
+
}
|
|
872
886
|
const arrayFrom = Array.from;
|
|
873
887
|
function isThenable(v) {
|
|
874
888
|
return v !== null && typeof v === "object" && typeof v.then === "function";
|
|
@@ -931,12 +945,15 @@ class ReactivePromiseImpl {
|
|
|
931
945
|
let remaining = len;
|
|
932
946
|
let rejected = false;
|
|
933
947
|
const onFulfillAt = (i) => (v) => {
|
|
934
|
-
if (rejected)
|
|
948
|
+
if (rejected)
|
|
949
|
+
return;
|
|
935
950
|
results[i] = v;
|
|
936
|
-
if (--remaining === 0)
|
|
951
|
+
if (--remaining === 0)
|
|
952
|
+
p._setValue(results);
|
|
937
953
|
};
|
|
938
954
|
const onReject = (r) => {
|
|
939
|
-
if (rejected)
|
|
955
|
+
if (rejected)
|
|
956
|
+
return;
|
|
940
957
|
rejected = true;
|
|
941
958
|
p._setError(r);
|
|
942
959
|
};
|
|
@@ -949,15 +966,18 @@ class ReactivePromiseImpl {
|
|
|
949
966
|
const p = new ReactivePromiseImpl();
|
|
950
967
|
const arr = arrayFrom(values);
|
|
951
968
|
const len = arr.length;
|
|
952
|
-
if (len === 0)
|
|
969
|
+
if (len === 0)
|
|
970
|
+
return p;
|
|
953
971
|
let settled2 = false;
|
|
954
972
|
const onFulfill = (v) => {
|
|
955
|
-
if (settled2)
|
|
973
|
+
if (settled2)
|
|
974
|
+
return;
|
|
956
975
|
settled2 = true;
|
|
957
976
|
p._setValue(v);
|
|
958
977
|
};
|
|
959
978
|
const onReject = (r) => {
|
|
960
|
-
if (settled2)
|
|
979
|
+
if (settled2)
|
|
980
|
+
return;
|
|
961
981
|
settled2 = true;
|
|
962
982
|
p._setError(r);
|
|
963
983
|
};
|
|
@@ -978,12 +998,14 @@ class ReactivePromiseImpl {
|
|
|
978
998
|
const errors = new Array(len);
|
|
979
999
|
let fulfilled = false;
|
|
980
1000
|
const onFulfill = (value) => {
|
|
981
|
-
if (fulfilled)
|
|
1001
|
+
if (fulfilled)
|
|
1002
|
+
return;
|
|
982
1003
|
fulfilled = true;
|
|
983
1004
|
p._setValue(value);
|
|
984
1005
|
};
|
|
985
1006
|
const onRejectAt = (index) => (reason) => {
|
|
986
|
-
if (fulfilled)
|
|
1007
|
+
if (fulfilled)
|
|
1008
|
+
return;
|
|
987
1009
|
errors[index] = reason;
|
|
988
1010
|
if (--pending === 0) {
|
|
989
1011
|
p._setError(new AggregateError(errors, "All promises were rejected in ReactivePromise.any"));
|
|
@@ -1006,11 +1028,13 @@ class ReactivePromiseImpl {
|
|
|
1006
1028
|
let remaining = len;
|
|
1007
1029
|
const onFulfillAt = (index) => (value) => {
|
|
1008
1030
|
results[index] = { status: "fulfilled", value };
|
|
1009
|
-
if (--remaining === 0)
|
|
1031
|
+
if (--remaining === 0)
|
|
1032
|
+
p._setValue(results);
|
|
1010
1033
|
};
|
|
1011
1034
|
const onRejectAt = (index) => (reason) => {
|
|
1012
1035
|
results[index] = { status: "rejected", reason };
|
|
1013
|
-
if (--remaining === 0)
|
|
1036
|
+
if (--remaining === 0)
|
|
1037
|
+
p._setValue(results);
|
|
1014
1038
|
};
|
|
1015
1039
|
for (let i = 0; i < len; i++) {
|
|
1016
1040
|
thenLoop(arr[i], onFulfillAt(i), onRejectAt(i));
|
|
@@ -1018,7 +1042,8 @@ class ReactivePromiseImpl {
|
|
|
1018
1042
|
return p;
|
|
1019
1043
|
}
|
|
1020
1044
|
static resolve(value) {
|
|
1021
|
-
if (value instanceof ReactivePromiseImpl)
|
|
1045
|
+
if (value instanceof ReactivePromiseImpl)
|
|
1046
|
+
return value;
|
|
1022
1047
|
return new ReactivePromiseImpl((resolve) => resolve(value));
|
|
1023
1048
|
}
|
|
1024
1049
|
static reject(reason) {
|
|
@@ -1029,7 +1054,7 @@ class ReactivePromiseImpl {
|
|
|
1029
1054
|
p._equals = DEFAULT_EQUALS;
|
|
1030
1055
|
p._initFlags(
|
|
1031
1056
|
1
|
|
1032
|
-
/* Pending */
|
|
1057
|
+
/* AsyncFlags.Pending */
|
|
1033
1058
|
);
|
|
1034
1059
|
const resolve = (value) => {
|
|
1035
1060
|
if (value && typeof value.then === "function") {
|
|
@@ -1057,7 +1082,8 @@ class ReactivePromiseImpl {
|
|
|
1057
1082
|
}
|
|
1058
1083
|
_consumeFlags(flags) {
|
|
1059
1084
|
const currentConsumer = getCurrentConsumer();
|
|
1060
|
-
if (currentConsumer === void 0)
|
|
1085
|
+
if (currentConsumer === void 0)
|
|
1086
|
+
return;
|
|
1061
1087
|
if ((this._flags & 128) !== 0) {
|
|
1062
1088
|
this._connect();
|
|
1063
1089
|
}
|
|
@@ -1069,11 +1095,13 @@ class ReactivePromiseImpl {
|
|
|
1069
1095
|
_connect() {
|
|
1070
1096
|
const signal2 = this._signal;
|
|
1071
1097
|
const currentConsumer = getCurrentConsumer();
|
|
1098
|
+
if (currentConsumer === signal2)
|
|
1099
|
+
return;
|
|
1072
1100
|
if (currentConsumer?.watchCount === 0) {
|
|
1073
1101
|
const { ref, computedCount, deps } = currentConsumer;
|
|
1074
1102
|
const prevEdge = deps.get(signal2);
|
|
1075
1103
|
if (prevEdge?.consumedAt !== computedCount) {
|
|
1076
|
-
const newEdge = createEdge(prevEdge,
|
|
1104
|
+
const newEdge = createEdge(prevEdge, 0, signal2, signal2.updatedCount, computedCount);
|
|
1077
1105
|
signal2.subs.set(ref, newEdge);
|
|
1078
1106
|
deps.set(signal2, newEdge);
|
|
1079
1107
|
}
|
|
@@ -1130,7 +1158,7 @@ class ReactivePromiseImpl {
|
|
|
1130
1158
|
}
|
|
1131
1159
|
this._setFlags(
|
|
1132
1160
|
1
|
|
1133
|
-
/* Pending */
|
|
1161
|
+
/* AsyncFlags.Pending */
|
|
1134
1162
|
);
|
|
1135
1163
|
dirtySignalConsumers(this._awaitSubs);
|
|
1136
1164
|
return this._awaitSubs = /* @__PURE__ */ new Map();
|
|
@@ -1193,6 +1221,10 @@ class ReactivePromiseImpl {
|
|
|
1193
1221
|
}
|
|
1194
1222
|
}
|
|
1195
1223
|
_setError(nextError, awaitSubs = this._awaitSubs) {
|
|
1224
|
+
if (nextError !== this._error && !isAbortError(nextError)) {
|
|
1225
|
+
const desc = this._signal?.desc ?? this._signal?.tracerMeta?.desc;
|
|
1226
|
+
console.error(`[signalium] Unhandled async error${desc ? ` in "${desc}"` : ""}:`, nextError);
|
|
1227
|
+
}
|
|
1196
1228
|
let error = this._error;
|
|
1197
1229
|
let notifyFlags = 0;
|
|
1198
1230
|
if (error !== nextError) {
|
|
@@ -1222,7 +1254,7 @@ class ReactivePromiseImpl {
|
|
|
1222
1254
|
}
|
|
1223
1255
|
}
|
|
1224
1256
|
_scheduleSubs(awaitSubs, dirty) {
|
|
1225
|
-
const newState = dirty ?
|
|
1257
|
+
const newState = dirty ? 2 : 4;
|
|
1226
1258
|
for (const ref of awaitSubs.keys()) {
|
|
1227
1259
|
const signal2 = ref.deref();
|
|
1228
1260
|
if (signal2 === void 0) {
|
|
@@ -1235,49 +1267,49 @@ class ReactivePromiseImpl {
|
|
|
1235
1267
|
get value() {
|
|
1236
1268
|
this._consumeFlags(
|
|
1237
1269
|
16
|
|
1238
|
-
/* Value */
|
|
1270
|
+
/* AsyncFlags.Value */
|
|
1239
1271
|
);
|
|
1240
1272
|
return this._value;
|
|
1241
1273
|
}
|
|
1242
1274
|
get error() {
|
|
1243
1275
|
this._consumeFlags(
|
|
1244
1276
|
32
|
|
1245
|
-
/* Error */
|
|
1277
|
+
/* AsyncFlags.Error */
|
|
1246
1278
|
);
|
|
1247
1279
|
return this._error;
|
|
1248
1280
|
}
|
|
1249
1281
|
get isPending() {
|
|
1250
1282
|
this._consumeFlags(
|
|
1251
1283
|
1
|
|
1252
|
-
/* Pending */
|
|
1284
|
+
/* AsyncFlags.Pending */
|
|
1253
1285
|
);
|
|
1254
1286
|
return (this._flags & 1) !== 0;
|
|
1255
1287
|
}
|
|
1256
1288
|
get isRejected() {
|
|
1257
1289
|
this._consumeFlags(
|
|
1258
1290
|
2
|
|
1259
|
-
/* Rejected */
|
|
1291
|
+
/* AsyncFlags.Rejected */
|
|
1260
1292
|
);
|
|
1261
1293
|
return (this._flags & 2) !== 0;
|
|
1262
1294
|
}
|
|
1263
1295
|
get isResolved() {
|
|
1264
1296
|
this._consumeFlags(
|
|
1265
1297
|
4
|
|
1266
|
-
/* Resolved */
|
|
1298
|
+
/* AsyncFlags.Resolved */
|
|
1267
1299
|
);
|
|
1268
1300
|
return (this._flags & 4) !== 0;
|
|
1269
1301
|
}
|
|
1270
1302
|
get isReady() {
|
|
1271
1303
|
this._consumeFlags(
|
|
1272
1304
|
8
|
|
1273
|
-
/* Ready */
|
|
1305
|
+
/* AsyncFlags.Ready */
|
|
1274
1306
|
);
|
|
1275
1307
|
return (this._flags & 8) !== 0;
|
|
1276
1308
|
}
|
|
1277
1309
|
get isSettled() {
|
|
1278
1310
|
this._consumeFlags(
|
|
1279
1311
|
6
|
|
1280
|
-
/* Settled */
|
|
1312
|
+
/* AsyncFlags.Settled */
|
|
1281
1313
|
);
|
|
1282
1314
|
return (this._flags & 6) !== 0;
|
|
1283
1315
|
}
|
|
@@ -1293,13 +1325,7 @@ class ReactivePromiseImpl {
|
|
|
1293
1325
|
}
|
|
1294
1326
|
ref = currentConsumer.ref;
|
|
1295
1327
|
const prevEdge = this._awaitSubs.get(ref) ?? findAndRemoveDirty(currentConsumer, this);
|
|
1296
|
-
edge = createEdge(
|
|
1297
|
-
prevEdge,
|
|
1298
|
-
EdgeType.Promise,
|
|
1299
|
-
this,
|
|
1300
|
-
this._updatedCount,
|
|
1301
|
-
currentConsumer.computedCount
|
|
1302
|
-
);
|
|
1328
|
+
edge = createEdge(prevEdge, 1, this, this._updatedCount, currentConsumer.computedCount);
|
|
1303
1329
|
}
|
|
1304
1330
|
const wrappedFulfilled = onfulfilled ? (value) => {
|
|
1305
1331
|
try {
|
|
@@ -1335,16 +1361,13 @@ class ReactivePromiseImpl {
|
|
|
1335
1361
|
return this.then(null, onrejected);
|
|
1336
1362
|
}
|
|
1337
1363
|
finally(onfinally) {
|
|
1338
|
-
return this.then(
|
|
1339
|
-
(
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
throw reason;
|
|
1346
|
-
}
|
|
1347
|
-
);
|
|
1364
|
+
return this.then((value) => {
|
|
1365
|
+
onfinally?.();
|
|
1366
|
+
return value;
|
|
1367
|
+
}, (reason) => {
|
|
1368
|
+
onfinally?.();
|
|
1369
|
+
throw reason;
|
|
1370
|
+
});
|
|
1348
1371
|
}
|
|
1349
1372
|
get [Symbol.toStringTag]() {
|
|
1350
1373
|
return `ReactivePromise`;
|
|
@@ -1366,7 +1389,7 @@ function createPromise(promise, signal2) {
|
|
|
1366
1389
|
p["_equals"] = signal2.def.equals;
|
|
1367
1390
|
p["_initFlags"](
|
|
1368
1391
|
1
|
|
1369
|
-
/* Pending */
|
|
1392
|
+
/* AsyncFlags.Pending */
|
|
1370
1393
|
);
|
|
1371
1394
|
p["_setPromise"](promise);
|
|
1372
1395
|
return p;
|
|
@@ -1383,7 +1406,7 @@ function createRelay(activate, scope, opts) {
|
|
|
1383
1406
|
}
|
|
1384
1407
|
const signal2 = p["_signal"];
|
|
1385
1408
|
signal2.subs = /* @__PURE__ */ new Map();
|
|
1386
|
-
signal2._state =
|
|
1409
|
+
signal2._state = 2;
|
|
1387
1410
|
active = false;
|
|
1388
1411
|
currentSub = void 0;
|
|
1389
1412
|
};
|
|
@@ -1428,7 +1451,7 @@ function createRelay(activate, scope, opts) {
|
|
|
1428
1451
|
p["_equals"] = equalsFrom(opts?.equals);
|
|
1429
1452
|
p["_initFlags"](
|
|
1430
1453
|
128 | 1
|
|
1431
|
-
/* Pending */
|
|
1454
|
+
/* AsyncFlags.Pending */
|
|
1432
1455
|
);
|
|
1433
1456
|
return p;
|
|
1434
1457
|
}
|
|
@@ -1438,7 +1461,7 @@ function createTask(task, scope, opts) {
|
|
|
1438
1461
|
p["_equals"] = equalsFrom(opts?.equals);
|
|
1439
1462
|
p["_initFlags"](
|
|
1440
1463
|
64
|
|
1441
|
-
/* isRunnable */
|
|
1464
|
+
/* AsyncFlags.isRunnable */
|
|
1442
1465
|
);
|
|
1443
1466
|
const throwIfRunning = opts?.throwIfRunning === true;
|
|
1444
1467
|
p["run"] = ((...args) => {
|
|
@@ -1474,7 +1497,7 @@ function getSignal(signal2) {
|
|
|
1474
1497
|
}
|
|
1475
1498
|
}
|
|
1476
1499
|
const updatedAt = checkSignal(signal2);
|
|
1477
|
-
const newEdge = createEdge(prevEdge,
|
|
1500
|
+
const newEdge = createEdge(prevEdge, 0, signal2, updatedAt, computedCount);
|
|
1478
1501
|
signal2.subs.set(ref, newEdge);
|
|
1479
1502
|
deps.set(signal2, newEdge);
|
|
1480
1503
|
} else {
|
|
@@ -1490,26 +1513,26 @@ function getSignal(signal2) {
|
|
|
1490
1513
|
}
|
|
1491
1514
|
function checkSignal(signal2) {
|
|
1492
1515
|
const { ref, _state: state } = signal2;
|
|
1493
|
-
if (state <
|
|
1516
|
+
if (state < 2) {
|
|
1494
1517
|
return signal2.updatedCount;
|
|
1495
1518
|
}
|
|
1496
|
-
if (state >=
|
|
1519
|
+
if (state >= 3) {
|
|
1497
1520
|
let edge = signal2.dirtyHead;
|
|
1498
1521
|
while (edge !== void 0) {
|
|
1499
|
-
if (edge.type ===
|
|
1522
|
+
if (edge.type === 1) {
|
|
1500
1523
|
const dep2 = edge.dep;
|
|
1501
1524
|
if (dep2._getPending()) {
|
|
1502
1525
|
const value = signal2._value;
|
|
1503
1526
|
dep2["_awaitSubs"].set(ref, edge);
|
|
1504
1527
|
value._setPending();
|
|
1505
|
-
signal2._state =
|
|
1528
|
+
signal2._state = 1;
|
|
1506
1529
|
signal2.dirtyHead = edge;
|
|
1507
1530
|
return signal2.updatedCount;
|
|
1508
1531
|
} else if (edge.updatedAt === edge.dep._updatedCount) {
|
|
1509
1532
|
dep2["_awaitSubs"].set(ref, edge);
|
|
1510
1533
|
} else {
|
|
1511
1534
|
signal2.dirtyHead = edge.nextDirty;
|
|
1512
|
-
signal2._state =
|
|
1535
|
+
signal2._state = 2;
|
|
1513
1536
|
break;
|
|
1514
1537
|
}
|
|
1515
1538
|
edge = edge.nextDirty;
|
|
@@ -1520,23 +1543,23 @@ function checkSignal(signal2) {
|
|
|
1520
1543
|
dep.subs.set(ref, edge);
|
|
1521
1544
|
if (edge.updatedAt !== updatedAt) {
|
|
1522
1545
|
signal2.dirtyHead = edge.nextDirty;
|
|
1523
|
-
signal2._state =
|
|
1546
|
+
signal2._state = 2;
|
|
1524
1547
|
break;
|
|
1525
1548
|
}
|
|
1526
1549
|
edge = edge.nextDirty;
|
|
1527
1550
|
}
|
|
1528
1551
|
}
|
|
1529
1552
|
const newState = signal2._state;
|
|
1530
|
-
if (newState ===
|
|
1553
|
+
if (newState === 2) {
|
|
1531
1554
|
if (signal2._isLazy) {
|
|
1532
1555
|
signal2.updatedCount++;
|
|
1533
1556
|
} else {
|
|
1534
1557
|
runSignal(signal2);
|
|
1535
1558
|
}
|
|
1536
|
-
} else if (newState ===
|
|
1559
|
+
} else if (newState === 4) {
|
|
1537
1560
|
signal2._value._clearPending();
|
|
1538
1561
|
}
|
|
1539
|
-
signal2._state =
|
|
1562
|
+
signal2._state = 0;
|
|
1540
1563
|
signal2.dirtyHead = void 0;
|
|
1541
1564
|
if (getTracerProxy() !== void 0 && signal2.tracerMeta?.tracer) {
|
|
1542
1565
|
scheduleTracer(signal2.tracerMeta.tracer);
|
|
@@ -1723,56 +1746,56 @@ function hashDate(date, _seen) {
|
|
|
1723
1746
|
return hashNumber(
|
|
1724
1747
|
date.getTime(),
|
|
1725
1748
|
14
|
|
1726
|
-
/* DATE */
|
|
1749
|
+
/* HashType.DATE */
|
|
1727
1750
|
);
|
|
1728
1751
|
}
|
|
1729
1752
|
function hashRegExp(regexp, _seen) {
|
|
1730
1753
|
const h = hashStr(
|
|
1731
1754
|
regexp.source + regexp.flags,
|
|
1732
1755
|
15
|
|
1733
|
-
/* REGEXP */
|
|
1756
|
+
/* HashType.REGEXP */
|
|
1734
1757
|
);
|
|
1735
1758
|
return (h ^ regexp.lastIndex) >>> 0;
|
|
1736
1759
|
}
|
|
1737
1760
|
const UNDEFINED = hashStr(
|
|
1738
1761
|
"undefined",
|
|
1739
1762
|
0
|
|
1740
|
-
/* UNDEFINED */
|
|
1763
|
+
/* HashType.UNDEFINED */
|
|
1741
1764
|
);
|
|
1742
1765
|
const NULL = hashStr(
|
|
1743
1766
|
"null",
|
|
1744
1767
|
1
|
|
1745
|
-
/* NULL */
|
|
1768
|
+
/* HashType.NULL */
|
|
1746
1769
|
);
|
|
1747
1770
|
const TRUE = hashStr(
|
|
1748
1771
|
"true",
|
|
1749
1772
|
2
|
|
1750
|
-
/* TRUE */
|
|
1773
|
+
/* HashType.TRUE */
|
|
1751
1774
|
);
|
|
1752
1775
|
const FALSE = hashStr(
|
|
1753
1776
|
"false",
|
|
1754
1777
|
3
|
|
1755
|
-
/* FALSE */
|
|
1778
|
+
/* HashType.FALSE */
|
|
1756
1779
|
);
|
|
1757
1780
|
const ARRAY = hashStr(
|
|
1758
1781
|
"array",
|
|
1759
1782
|
7
|
|
1760
|
-
/* ARRAY */
|
|
1783
|
+
/* HashType.ARRAY */
|
|
1761
1784
|
);
|
|
1762
1785
|
const OBJECT = hashStr(
|
|
1763
1786
|
"object",
|
|
1764
1787
|
8
|
|
1765
|
-
/* OBJECT */
|
|
1788
|
+
/* HashType.OBJECT */
|
|
1766
1789
|
);
|
|
1767
1790
|
const SET = hashStr(
|
|
1768
1791
|
"set",
|
|
1769
1792
|
13
|
|
1770
|
-
/* SET */
|
|
1793
|
+
/* HashType.SET */
|
|
1771
1794
|
);
|
|
1772
1795
|
const MAP = hashStr(
|
|
1773
1796
|
"map",
|
|
1774
1797
|
12
|
|
1775
|
-
/* MAP */
|
|
1798
|
+
/* HashType.MAP */
|
|
1776
1799
|
);
|
|
1777
1800
|
const getObjectProto = Object.getPrototypeOf;
|
|
1778
1801
|
const PROTO_TO_HASH = /* @__PURE__ */ new Map([
|
|
@@ -1796,19 +1819,19 @@ function hashValue(node, seen = []) {
|
|
|
1796
1819
|
return hashStr(
|
|
1797
1820
|
String(node),
|
|
1798
1821
|
4
|
|
1799
|
-
/* NUMBER */
|
|
1822
|
+
/* HashType.NUMBER */
|
|
1800
1823
|
);
|
|
1801
1824
|
case "string":
|
|
1802
1825
|
return hashStr(
|
|
1803
1826
|
node,
|
|
1804
1827
|
5
|
|
1805
|
-
/* STRING */
|
|
1828
|
+
/* HashType.STRING */
|
|
1806
1829
|
);
|
|
1807
1830
|
case "bigint":
|
|
1808
1831
|
return hashStr(
|
|
1809
1832
|
node.toString(),
|
|
1810
1833
|
6
|
|
1811
|
-
/* BIGINT */
|
|
1834
|
+
/* HashType.BIGINT */
|
|
1812
1835
|
);
|
|
1813
1836
|
case "object": {
|
|
1814
1837
|
if (node === null) {
|
|
@@ -1819,7 +1842,7 @@ function hashValue(node, seen = []) {
|
|
|
1819
1842
|
return hashStr(
|
|
1820
1843
|
String(index),
|
|
1821
1844
|
11
|
|
1822
|
-
/* CYCLE */
|
|
1845
|
+
/* HashType.CYCLE */
|
|
1823
1846
|
);
|
|
1824
1847
|
}
|
|
1825
1848
|
const hashFn = PROTO_TO_HASH.get(getObjectProto(node));
|
|
@@ -1837,7 +1860,7 @@ function hashValue(node, seen = []) {
|
|
|
1837
1860
|
return hashStr(
|
|
1838
1861
|
node.toString(),
|
|
1839
1862
|
10
|
|
1840
|
-
/* SYMBOL */
|
|
1863
|
+
/* HashType.SYMBOL */
|
|
1841
1864
|
);
|
|
1842
1865
|
}
|
|
1843
1866
|
}
|
|
@@ -1849,7 +1872,7 @@ function getObjectHash(obj) {
|
|
|
1849
1872
|
id = hashNumber(
|
|
1850
1873
|
nextHashMapId++,
|
|
1851
1874
|
9
|
|
1852
|
-
/* REFERENCE */
|
|
1875
|
+
/* HashType.REFERENCE */
|
|
1853
1876
|
);
|
|
1854
1877
|
objectToHashMap.set(obj, id);
|
|
1855
1878
|
}
|
|
@@ -1883,8 +1906,10 @@ function isPlainArray(arr) {
|
|
|
1883
1906
|
return Array.isArray(arr);
|
|
1884
1907
|
}
|
|
1885
1908
|
function stringifyValue(value) {
|
|
1886
|
-
if (value === null)
|
|
1887
|
-
|
|
1909
|
+
if (value === null)
|
|
1910
|
+
return "null";
|
|
1911
|
+
if (value === void 0)
|
|
1912
|
+
return "undefined";
|
|
1888
1913
|
switch (typeof value) {
|
|
1889
1914
|
case "number":
|
|
1890
1915
|
case "boolean":
|
|
@@ -1916,25 +1941,21 @@ function stringifyValue(value) {
|
|
|
1916
1941
|
return getObjectId(value);
|
|
1917
1942
|
}
|
|
1918
1943
|
}
|
|
1919
|
-
var ReactiveFnState = /* @__PURE__ */ ((ReactiveFnState2) => {
|
|
1920
|
-
ReactiveFnState2[ReactiveFnState2["Clean"] = 0] = "Clean";
|
|
1921
|
-
ReactiveFnState2[ReactiveFnState2["Pending"] = 1] = "Pending";
|
|
1922
|
-
ReactiveFnState2[ReactiveFnState2["Dirty"] = 2] = "Dirty";
|
|
1923
|
-
ReactiveFnState2[ReactiveFnState2["MaybeDirty"] = 3] = "MaybeDirty";
|
|
1924
|
-
ReactiveFnState2[ReactiveFnState2["PendingDirty"] = 4] = "PendingDirty";
|
|
1925
|
-
return ReactiveFnState2;
|
|
1926
|
-
})(ReactiveFnState || {});
|
|
1927
1944
|
let ID = 0;
|
|
1928
1945
|
function createReactiveDefinition(id, desc, compute, equals, isRelay2, paramKey, tracer) {
|
|
1929
|
-
|
|
1930
|
-
id,
|
|
1931
|
-
desc,
|
|
1946
|
+
const def = {
|
|
1932
1947
|
compute,
|
|
1933
1948
|
equals: equalsFrom(equals),
|
|
1934
1949
|
isRelay: isRelay2,
|
|
1935
1950
|
paramKey,
|
|
1936
|
-
tracer
|
|
1951
|
+
tracer: void 0
|
|
1937
1952
|
};
|
|
1953
|
+
{
|
|
1954
|
+
def.id = id;
|
|
1955
|
+
def.desc = desc;
|
|
1956
|
+
def.tracer = tracer;
|
|
1957
|
+
}
|
|
1958
|
+
return def;
|
|
1938
1959
|
}
|
|
1939
1960
|
class ReactiveSignal {
|
|
1940
1961
|
// Bitmask containing state in the first 2 bits and boolean properties in the remaining bits
|
|
@@ -1955,6 +1976,7 @@ class ReactiveSignal {
|
|
|
1955
1976
|
_listeners = null;
|
|
1956
1977
|
_value = void 0;
|
|
1957
1978
|
tracerMeta;
|
|
1979
|
+
desc;
|
|
1958
1980
|
// Reference to the shared definition
|
|
1959
1981
|
def;
|
|
1960
1982
|
constructor(def, args, key, scope) {
|
|
@@ -1963,6 +1985,7 @@ class ReactiveSignal {
|
|
|
1963
1985
|
this.key = key;
|
|
1964
1986
|
this.args = args;
|
|
1965
1987
|
this.def = def;
|
|
1988
|
+
this.desc = def.desc;
|
|
1966
1989
|
{
|
|
1967
1990
|
this.tracerMeta = {
|
|
1968
1991
|
id: def.id ?? key ?? hashValue([def.compute, ID++]),
|
|
@@ -2106,13 +2129,14 @@ function createReactiveSignal(def, args = [], key, scope) {
|
|
|
2106
2129
|
}
|
|
2107
2130
|
let CONTEXT_ID = 0;
|
|
2108
2131
|
class ContextImpl {
|
|
2132
|
+
defaultValue;
|
|
2133
|
+
_key;
|
|
2134
|
+
_description;
|
|
2109
2135
|
constructor(defaultValue, desc) {
|
|
2110
2136
|
this.defaultValue = defaultValue;
|
|
2111
2137
|
this._description = desc ?? `context:${CONTEXT_ID++}`;
|
|
2112
2138
|
this._key = Symbol(this._description);
|
|
2113
2139
|
}
|
|
2114
|
-
_key;
|
|
2115
|
-
_description;
|
|
2116
2140
|
}
|
|
2117
2141
|
const context = (initialValue, description) => {
|
|
2118
2142
|
return new ContextImpl(initialValue, description);
|
|
@@ -2130,9 +2154,7 @@ function withContexts(contexts, fn) {
|
|
|
2130
2154
|
const getContext = (context2) => {
|
|
2131
2155
|
const scope = CURRENT_SCOPE ?? getCurrentConsumer()?.scope;
|
|
2132
2156
|
if (scope === void 0) {
|
|
2133
|
-
throw new Error(
|
|
2134
|
-
"getContext must be used within a reactive function, a withContext, or within a framework-specific context provider."
|
|
2135
|
-
);
|
|
2157
|
+
throw new Error("getContext must be used within a reactive function, a withContext, or within a framework-specific context provider.");
|
|
2136
2158
|
}
|
|
2137
2159
|
return scope.getContext(context2) ?? context2.defaultValue;
|
|
2138
2160
|
};
|
|
@@ -2250,16 +2272,17 @@ const getScopeOwner = (obj) => {
|
|
|
2250
2272
|
return scope;
|
|
2251
2273
|
};
|
|
2252
2274
|
export {
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2275
|
+
setGlobalContexts as A,
|
|
2276
|
+
clearGlobalContexts as B,
|
|
2277
|
+
setScopeOwner as C,
|
|
2278
|
+
setTracing as D,
|
|
2279
|
+
createTracer as E,
|
|
2280
|
+
createTracerFromId as F,
|
|
2281
|
+
removeTracer as G,
|
|
2282
|
+
Tracer as H,
|
|
2283
|
+
SignalType as I,
|
|
2284
|
+
getTracerProxy as J,
|
|
2285
|
+
scheduleTracer as K,
|
|
2263
2286
|
ReactivePromise as R,
|
|
2264
2287
|
SignalScope as S,
|
|
2265
2288
|
TracerEventType as T,
|
|
@@ -2272,23 +2295,23 @@ export {
|
|
|
2272
2295
|
getCurrentConsumer as f,
|
|
2273
2296
|
getCurrentScope as g,
|
|
2274
2297
|
getGlobalScope as h,
|
|
2275
|
-
|
|
2276
|
-
|
|
2298
|
+
isReactivePromise as i,
|
|
2299
|
+
hashValue as j,
|
|
2277
2300
|
isRelay$1 as k,
|
|
2278
2301
|
getSignal as l,
|
|
2279
2302
|
isPromise as m,
|
|
2280
2303
|
registerCustomHash as n,
|
|
2281
2304
|
setReactivePromise as o,
|
|
2282
2305
|
notifier as p,
|
|
2283
|
-
|
|
2306
|
+
isSignal as q,
|
|
2284
2307
|
runSignal as r,
|
|
2285
2308
|
signal as s,
|
|
2286
|
-
|
|
2309
|
+
callback as t,
|
|
2287
2310
|
unwatchSignal as u,
|
|
2288
|
-
|
|
2311
|
+
settled as v,
|
|
2289
2312
|
watchSignal as w,
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2313
|
+
context as x,
|
|
2314
|
+
getContext as y,
|
|
2315
|
+
withContexts as z
|
|
2293
2316
|
};
|
|
2294
|
-
//# sourceMappingURL=debug-
|
|
2317
|
+
//# sourceMappingURL=debug-B6Cqxyzi.js.map
|