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,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 CURRENT_CONSUMER;
|
|
13
3
|
const setCurrentConsumer = (consumer) => {
|
|
14
4
|
CURRENT_CONSUMER = consumer;
|
|
@@ -97,34 +87,19 @@ function signal(initialValue, opts) {
|
|
|
97
87
|
const notifier = (opts) => {
|
|
98
88
|
return new StateSignal(void 0, FALSE_EQUALS, opts?.desc);
|
|
99
89
|
};
|
|
100
|
-
function watchSignal(signal2
|
|
101
|
-
if (parentIsSuspended) {
|
|
102
|
-
watchSuspendedSignal(signal2);
|
|
103
|
-
} else {
|
|
104
|
-
watchActiveSignal(signal2);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function unwatchSignal(signal2, parentIsSuspended) {
|
|
108
|
-
if (parentIsSuspended) {
|
|
109
|
-
unwatchSuspendedSignal(signal2);
|
|
110
|
-
} else {
|
|
111
|
-
unwatchActiveSignal(signal2);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
function watchActiveSignal(signal2) {
|
|
90
|
+
function watchSignal(signal2) {
|
|
115
91
|
const { watchCount } = signal2;
|
|
116
|
-
|
|
117
|
-
signal2.watchCount = newWatchCount;
|
|
92
|
+
signal2.watchCount = watchCount + 1;
|
|
118
93
|
cancelDeactivate(signal2);
|
|
119
94
|
if (signal2._isActive) {
|
|
120
95
|
return;
|
|
121
96
|
}
|
|
122
97
|
for (const dep of signal2.deps.keys()) {
|
|
123
|
-
|
|
98
|
+
watchSignal(dep);
|
|
124
99
|
}
|
|
125
100
|
activateSignal(signal2);
|
|
126
101
|
}
|
|
127
|
-
function
|
|
102
|
+
function unwatchSignal(signal2) {
|
|
128
103
|
const { watchCount } = signal2;
|
|
129
104
|
const newWatchCount = Math.max(watchCount - 1, 0);
|
|
130
105
|
signal2.watchCount = newWatchCount;
|
|
@@ -132,51 +107,7 @@ function unwatchActiveSignal(signal2) {
|
|
|
132
107
|
scheduleDeactivate(signal2);
|
|
133
108
|
}
|
|
134
109
|
}
|
|
135
|
-
function watchSuspendedSignal(signal2) {
|
|
136
|
-
const { watchCount, suspendCount } = signal2;
|
|
137
|
-
const newWatchCount = watchCount + 1;
|
|
138
|
-
const newSuspendCount = suspendCount + 1;
|
|
139
|
-
signal2.watchCount = newWatchCount;
|
|
140
|
-
signal2.suspendCount = newSuspendCount;
|
|
141
|
-
cancelDeactivate(signal2);
|
|
142
|
-
if (watchCount === 0) {
|
|
143
|
-
for (const dep of signal2.deps.keys()) {
|
|
144
|
-
watchSuspendedSignal(dep);
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
function unwatchSuspendedSignal(signal2) {
|
|
149
|
-
const { watchCount, suspendCount } = signal2;
|
|
150
|
-
const newWatchCount = Math.max(watchCount - 1, 0);
|
|
151
|
-
const newSuspendCount = Math.max(suspendCount - 1, 0);
|
|
152
|
-
signal2.watchCount = newWatchCount;
|
|
153
|
-
signal2.suspendCount = newSuspendCount;
|
|
154
|
-
if (newWatchCount === 0) {
|
|
155
|
-
scheduleDeactivate(signal2);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
function resumeSignal(signal2) {
|
|
159
|
-
const { watchCount, suspendCount } = signal2;
|
|
160
|
-
const newSuspendCount = Math.max(suspendCount - 1, 0);
|
|
161
|
-
signal2.suspendCount = newSuspendCount;
|
|
162
|
-
cancelDeactivate(signal2);
|
|
163
|
-
if (watchCount > 0 && !signal2._isActive) {
|
|
164
|
-
for (const dep of signal2.deps.keys()) {
|
|
165
|
-
resumeSignal(dep);
|
|
166
|
-
}
|
|
167
|
-
activateSignal(signal2);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
function suspendSignal(signal2) {
|
|
171
|
-
const { watchCount, suspendCount } = signal2;
|
|
172
|
-
const newSuspendCount = suspendCount + 1;
|
|
173
|
-
signal2.suspendCount = newSuspendCount;
|
|
174
|
-
if (watchCount > 0 && newSuspendCount === watchCount) {
|
|
175
|
-
scheduleDeactivate(signal2);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
110
|
function activateSignal(signal2) {
|
|
179
|
-
signal2.scope?.removeFromGc(signal2);
|
|
180
111
|
cancelDeactivate(signal2);
|
|
181
112
|
signal2._isActive = true;
|
|
182
113
|
if (isRelay(signal2)) {
|
|
@@ -184,37 +115,22 @@ function activateSignal(signal2) {
|
|
|
184
115
|
}
|
|
185
116
|
}
|
|
186
117
|
function deactivateSignal(signal2) {
|
|
187
|
-
const { watchCount, suspendCount } = signal2;
|
|
188
118
|
signal2._isActive = false;
|
|
189
|
-
const isSuspending = watchCount > 0 && suspendCount === watchCount;
|
|
190
119
|
for (const dep of signal2.deps.keys()) {
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
deactivateSignal(dep);
|
|
196
|
-
}
|
|
197
|
-
} else {
|
|
198
|
-
const newWatchCount = dep.watchCount = depWatchCount - 1;
|
|
199
|
-
if (newWatchCount === 0) {
|
|
200
|
-
deactivateSignal(dep);
|
|
201
|
-
}
|
|
120
|
+
const newWatchCount = Math.max(dep.watchCount - 1, 0);
|
|
121
|
+
dep.watchCount = newWatchCount;
|
|
122
|
+
if (newWatchCount === 0) {
|
|
123
|
+
deactivateSignal(dep);
|
|
202
124
|
}
|
|
203
125
|
}
|
|
204
126
|
if (isRelay(signal2)) {
|
|
205
127
|
signal2._value?.();
|
|
206
128
|
}
|
|
207
|
-
if (watchCount === 0) {
|
|
208
|
-
signal2.scope?.markForGc(signal2);
|
|
209
|
-
signal2.reset();
|
|
210
|
-
}
|
|
211
129
|
}
|
|
212
|
-
const scheduleIdleCallback = typeof requestIdleCallback === "function" ? requestIdleCallback : (cb) => scheduleFlush$1(cb);
|
|
213
130
|
let PENDING_PULLS = /* @__PURE__ */ new Set();
|
|
214
131
|
let PENDING_ASYNC_PULLS = [];
|
|
215
132
|
let PENDING_DEACTIVE = /* @__PURE__ */ new Set();
|
|
216
133
|
let PENDING_LISTENERS = [];
|
|
217
|
-
let PENDING_GC = /* @__PURE__ */ new Set();
|
|
218
134
|
const microtask = () => Promise.resolve();
|
|
219
135
|
let currentFlush = null;
|
|
220
136
|
const scheduleFlush = (fn) => {
|
|
@@ -241,7 +157,6 @@ const scheduleDeactivate = (signal2) => {
|
|
|
241
157
|
scheduleFlush();
|
|
242
158
|
};
|
|
243
159
|
const cancelDeactivate = (signal2) => {
|
|
244
|
-
signal2.scope?.removeFromGc(signal2);
|
|
245
160
|
PENDING_DEACTIVE.delete(signal2);
|
|
246
161
|
};
|
|
247
162
|
const scheduleListeners = (signal2) => {
|
|
@@ -250,17 +165,6 @@ const scheduleListeners = (signal2) => {
|
|
|
250
165
|
};
|
|
251
166
|
const scheduleTracer = (tracer) => {
|
|
252
167
|
};
|
|
253
|
-
const scheduleGcSweep = (scope) => {
|
|
254
|
-
PENDING_GC.add(scope);
|
|
255
|
-
if (PENDING_GC.size > 1)
|
|
256
|
-
return;
|
|
257
|
-
scheduleIdleCallback(() => {
|
|
258
|
-
for (const scope2 of PENDING_GC) {
|
|
259
|
-
scope2.sweepGc();
|
|
260
|
-
}
|
|
261
|
-
PENDING_GC.clear();
|
|
262
|
-
});
|
|
263
|
-
};
|
|
264
168
|
const flushWatchers = async () => {
|
|
265
169
|
const flush = currentFlush;
|
|
266
170
|
if (!flush)
|
|
@@ -319,7 +223,7 @@ function propagateDirty(signal2) {
|
|
|
319
223
|
scheduleAsyncPull(signal2);
|
|
320
224
|
}
|
|
321
225
|
} else {
|
|
322
|
-
if (signal2._isListener &&
|
|
226
|
+
if (signal2._isListener && signal2.watchCount > 0) {
|
|
323
227
|
schedulePull(signal2);
|
|
324
228
|
}
|
|
325
229
|
dirtySignalConsumers(signal2.subs);
|
|
@@ -420,6 +324,9 @@ function isGeneratorResult(value) {
|
|
|
420
324
|
function isPromise(value) {
|
|
421
325
|
return value.constructor === Promise;
|
|
422
326
|
}
|
|
327
|
+
function isThennable(value) {
|
|
328
|
+
return value !== null && typeof value === "object" && typeof value.then === "function";
|
|
329
|
+
}
|
|
423
330
|
function generatorResultToPromiseWithConsumer(generator, savedConsumer) {
|
|
424
331
|
function adopt(value) {
|
|
425
332
|
return typeof value === "object" && value !== null && (isPromise(value) || isReactivePromise(value)) ? value : Promise.resolve(value);
|
|
@@ -538,12 +445,6 @@ function callback(fn, idx, deps) {
|
|
|
538
445
|
}
|
|
539
446
|
return callback2.fn;
|
|
540
447
|
}
|
|
541
|
-
function isAbortError(error) {
|
|
542
|
-
if (typeof DOMException !== "undefined" && error instanceof DOMException) {
|
|
543
|
-
return error.name === "AbortError";
|
|
544
|
-
}
|
|
545
|
-
return error instanceof Error && error.name === "AbortError";
|
|
546
|
-
}
|
|
547
448
|
const arrayFrom = Array.from;
|
|
548
449
|
function isThenable(v) {
|
|
549
450
|
return v !== null && typeof v === "object" && typeof v.then === "function";
|
|
@@ -856,10 +757,6 @@ class ReactivePromiseImpl {
|
|
|
856
757
|
}
|
|
857
758
|
}
|
|
858
759
|
_setError(nextError, awaitSubs = this._awaitSubs) {
|
|
859
|
-
if (nextError !== this._error && !isAbortError(nextError)) {
|
|
860
|
-
const desc = this._signal?.desc ?? void 0;
|
|
861
|
-
console.error(`[signalium] Unhandled async error${desc ? ` in "${desc}"` : ""}:`, nextError);
|
|
862
|
-
}
|
|
863
760
|
let error = this._error;
|
|
864
761
|
let notifyFlags = 0;
|
|
865
762
|
if (error !== nextError) {
|
|
@@ -1015,9 +912,6 @@ function setReactivePromise(value) {
|
|
|
1015
912
|
function isReactivePromise(value) {
|
|
1016
913
|
return REACTIVE_PROMISE_SET.has(value);
|
|
1017
914
|
}
|
|
1018
|
-
function isRelay$1(obj) {
|
|
1019
|
-
return isReactivePromise(obj) && (obj["_flags"] & 128) !== 0;
|
|
1020
|
-
}
|
|
1021
915
|
function createPromise(promise, signal2) {
|
|
1022
916
|
const p = new ReactivePromiseImpl();
|
|
1023
917
|
p["_signal"] = signal2;
|
|
@@ -1118,7 +1012,7 @@ function getSignal(signal2) {
|
|
|
1118
1012
|
if (prevConsumedAt !== computedCount) {
|
|
1119
1013
|
if (prevEdge === void 0) {
|
|
1120
1014
|
if (currentConsumer.watchCount > 0) {
|
|
1121
|
-
watchSignal(signal2
|
|
1015
|
+
watchSignal(signal2);
|
|
1122
1016
|
}
|
|
1123
1017
|
}
|
|
1124
1018
|
const updatedAt = checkSignal(signal2);
|
|
@@ -1225,12 +1119,15 @@ function runSignal(signal2) {
|
|
|
1225
1119
|
}
|
|
1226
1120
|
}
|
|
1227
1121
|
function disconnectSignal(signal2, computedCount = signal2.computedCount) {
|
|
1228
|
-
const { ref, deps
|
|
1122
|
+
const { ref, deps } = signal2;
|
|
1229
1123
|
for (const [dep, edge] of deps) {
|
|
1230
1124
|
if (edge.consumedAt !== computedCount) {
|
|
1231
|
-
unwatchSignal(dep
|
|
1125
|
+
unwatchSignal(dep);
|
|
1232
1126
|
dep.subs.delete(ref);
|
|
1233
1127
|
deps.delete(dep);
|
|
1128
|
+
if (dep._state < 2) {
|
|
1129
|
+
dep._state = 2;
|
|
1130
|
+
}
|
|
1234
1131
|
}
|
|
1235
1132
|
}
|
|
1236
1133
|
}
|
|
@@ -1514,12 +1411,11 @@ class ReactiveSignal {
|
|
|
1514
1411
|
id = ++ID;
|
|
1515
1412
|
subs = /* @__PURE__ */ new Map();
|
|
1516
1413
|
deps = /* @__PURE__ */ new Map();
|
|
1517
|
-
ref = new WeakRef
|
|
1414
|
+
ref = new WeakRef(this);
|
|
1518
1415
|
dirtyHead = void 0;
|
|
1519
1416
|
updatedCount = 0;
|
|
1520
1417
|
computedCount = 0;
|
|
1521
1418
|
watchCount = 0;
|
|
1522
|
-
suspendCount = 0;
|
|
1523
1419
|
key;
|
|
1524
1420
|
args;
|
|
1525
1421
|
callbacks = void 0;
|
|
@@ -1546,31 +1442,24 @@ class ReactiveSignal {
|
|
|
1546
1442
|
get _isListener() {
|
|
1547
1443
|
return (this.flags & 16) !== 0;
|
|
1548
1444
|
}
|
|
1549
|
-
get _isSuspendedListener() {
|
|
1550
|
-
return (this.flags & 32) !== 0;
|
|
1551
|
-
}
|
|
1552
|
-
get _isSuspended() {
|
|
1553
|
-
const { watchCount, suspendCount } = this;
|
|
1554
|
-
return watchCount > 0 && watchCount === suspendCount;
|
|
1555
|
-
}
|
|
1556
1445
|
get _isActive() {
|
|
1557
|
-
return (this.flags &
|
|
1446
|
+
return (this.flags & 32) !== 0;
|
|
1558
1447
|
}
|
|
1559
1448
|
set _isActive(isActive) {
|
|
1560
1449
|
if (isActive) {
|
|
1561
|
-
this.flags |=
|
|
1450
|
+
this.flags |= 32;
|
|
1562
1451
|
} else {
|
|
1563
|
-
this.flags &= -
|
|
1452
|
+
this.flags &= -33;
|
|
1564
1453
|
}
|
|
1565
1454
|
}
|
|
1566
1455
|
get _isLazy() {
|
|
1567
|
-
return (this.flags &
|
|
1456
|
+
return (this.flags & 64) !== 0;
|
|
1568
1457
|
}
|
|
1569
1458
|
set _isLazy(isLazy) {
|
|
1570
1459
|
if (isLazy) {
|
|
1571
|
-
this.flags |=
|
|
1460
|
+
this.flags |= 64;
|
|
1572
1461
|
} else {
|
|
1573
|
-
this.flags &= -
|
|
1462
|
+
this.flags &= -65;
|
|
1574
1463
|
}
|
|
1575
1464
|
}
|
|
1576
1465
|
get listeners() {
|
|
@@ -1598,10 +1487,12 @@ class ReactiveSignal {
|
|
|
1598
1487
|
};
|
|
1599
1488
|
}
|
|
1600
1489
|
if (!this._isListener) {
|
|
1601
|
-
watchSignal(this
|
|
1490
|
+
watchSignal(this);
|
|
1602
1491
|
this.flags |= 16;
|
|
1603
1492
|
}
|
|
1604
|
-
|
|
1493
|
+
if (this.watchCount > 0) {
|
|
1494
|
+
schedulePull(this);
|
|
1495
|
+
}
|
|
1605
1496
|
current.set(listener, effective);
|
|
1606
1497
|
}
|
|
1607
1498
|
return () => {
|
|
@@ -1609,7 +1500,7 @@ class ReactiveSignal {
|
|
|
1609
1500
|
current.delete(listener);
|
|
1610
1501
|
if (current.size === 0) {
|
|
1611
1502
|
cancelPull(this);
|
|
1612
|
-
unwatchSignal(this
|
|
1503
|
+
unwatchSignal(this);
|
|
1613
1504
|
this.flags &= -17;
|
|
1614
1505
|
this.listeners.updatedAt = 0;
|
|
1615
1506
|
}
|
|
@@ -1619,39 +1510,15 @@ class ReactiveSignal {
|
|
|
1619
1510
|
// This method is used in React hooks specifically. It returns a bound add method
|
|
1620
1511
|
// that is cached to avoid creating a new one on each call, and it eagerly sets
|
|
1621
1512
|
// the listener as watched so that relays that are accessed will be activated.
|
|
1622
|
-
addListenerLazy() {
|
|
1513
|
+
addListenerLazy(watch = true) {
|
|
1623
1514
|
if (!this._isListener) {
|
|
1624
|
-
|
|
1515
|
+
if (watch) {
|
|
1516
|
+
watchSignal(this);
|
|
1517
|
+
}
|
|
1625
1518
|
this.flags |= 16;
|
|
1626
1519
|
}
|
|
1627
1520
|
return this.listeners.cachedBoundAdd;
|
|
1628
1521
|
}
|
|
1629
|
-
setSuspended(suspended) {
|
|
1630
|
-
const { flags } = this;
|
|
1631
|
-
const isListener = (flags & 16) !== 0;
|
|
1632
|
-
const isSuspendedListener = (flags & 32) !== 0;
|
|
1633
|
-
if (suspended && !isSuspendedListener) {
|
|
1634
|
-
this.flags = flags | 32;
|
|
1635
|
-
if (isListener) {
|
|
1636
|
-
suspendSignal(this);
|
|
1637
|
-
}
|
|
1638
|
-
} else if (!suspended && isSuspendedListener) {
|
|
1639
|
-
this.flags = flags & -33;
|
|
1640
|
-
if (isListener) {
|
|
1641
|
-
resumeSignal(this);
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
}
|
|
1645
|
-
reset() {
|
|
1646
|
-
this.flags = (this.def.isRelay ? 8 : 0) | 2;
|
|
1647
|
-
this.dirtyHead = void 0;
|
|
1648
|
-
this.updatedCount = 0;
|
|
1649
|
-
this.computedCount = 0;
|
|
1650
|
-
this.deps = /* @__PURE__ */ new Map();
|
|
1651
|
-
this.subs = /* @__PURE__ */ new Map();
|
|
1652
|
-
this.watchCount = 0;
|
|
1653
|
-
this.suspendCount = 0;
|
|
1654
|
-
}
|
|
1655
1522
|
}
|
|
1656
1523
|
const runListeners = (signal2) => {
|
|
1657
1524
|
const { listeners } = signal2;
|
|
@@ -1669,6 +1536,10 @@ const isRelay = (signal2) => {
|
|
|
1669
1536
|
function createReactiveSignal(def, args = [], key, scope) {
|
|
1670
1537
|
return new ReactiveSignal(def, args, key, scope);
|
|
1671
1538
|
}
|
|
1539
|
+
let requestScopeGetter;
|
|
1540
|
+
function setRequestScopeGetter(get) {
|
|
1541
|
+
requestScopeGetter = get;
|
|
1542
|
+
}
|
|
1672
1543
|
let CONTEXT_ID = 0;
|
|
1673
1544
|
class ContextImpl {
|
|
1674
1545
|
defaultValue;
|
|
@@ -1710,7 +1581,6 @@ class SignalScope {
|
|
|
1710
1581
|
contexts;
|
|
1711
1582
|
children = /* @__PURE__ */ new Map();
|
|
1712
1583
|
signals = /* @__PURE__ */ new Map();
|
|
1713
|
-
gcCandidates = /* @__PURE__ */ new Set();
|
|
1714
1584
|
setContexts(contexts) {
|
|
1715
1585
|
for (const [context2, value] of contexts) {
|
|
1716
1586
|
this.contexts[context2._key] = value;
|
|
@@ -1736,38 +1606,13 @@ class SignalScope {
|
|
|
1736
1606
|
get(def, args) {
|
|
1737
1607
|
const paramKey = def.paramKey?.(...args);
|
|
1738
1608
|
const key = hashReactiveFn(def.compute, paramKey ? [paramKey] : args);
|
|
1739
|
-
let signal2 = this.signals.get(key);
|
|
1609
|
+
let signal2 = this.signals.get(key)?.deref();
|
|
1740
1610
|
if (signal2 === void 0) {
|
|
1741
1611
|
signal2 = createReactiveSignal(def, args, key, this);
|
|
1742
|
-
this.signals.set(key, signal2);
|
|
1612
|
+
this.signals.set(key, new WeakRef(signal2));
|
|
1743
1613
|
}
|
|
1744
1614
|
return signal2;
|
|
1745
1615
|
}
|
|
1746
|
-
markForGc(signal2) {
|
|
1747
|
-
if (!this.gcCandidates.has(signal2)) {
|
|
1748
|
-
this.gcCandidates.add(signal2);
|
|
1749
|
-
scheduleGcSweep(this);
|
|
1750
|
-
}
|
|
1751
|
-
}
|
|
1752
|
-
removeFromGc(signal2) {
|
|
1753
|
-
this.gcCandidates.delete(signal2);
|
|
1754
|
-
const { key } = signal2;
|
|
1755
|
-
if (key) {
|
|
1756
|
-
this.signals.set(key, signal2);
|
|
1757
|
-
}
|
|
1758
|
-
}
|
|
1759
|
-
forceGc(signal2) {
|
|
1760
|
-
this.signals.delete(signal2.key);
|
|
1761
|
-
}
|
|
1762
|
-
sweepGc() {
|
|
1763
|
-
const signals = this.signals;
|
|
1764
|
-
for (const signal2 of this.gcCandidates) {
|
|
1765
|
-
if (signal2.watchCount === 0) {
|
|
1766
|
-
signals.delete(signal2.key);
|
|
1767
|
-
}
|
|
1768
|
-
}
|
|
1769
|
-
this.gcCandidates = /* @__PURE__ */ new Set();
|
|
1770
|
-
}
|
|
1771
1616
|
}
|
|
1772
1617
|
let GLOBAL_SCOPE = new SignalScope([]);
|
|
1773
1618
|
const getGlobalScope = () => {
|
|
@@ -1787,7 +1632,7 @@ const getInternalCurrentScope = () => {
|
|
|
1787
1632
|
return CURRENT_SCOPE;
|
|
1788
1633
|
};
|
|
1789
1634
|
const getCurrentScope = (fallback = GLOBAL_SCOPE) => {
|
|
1790
|
-
return CURRENT_SCOPE ?? getCurrentConsumer()?.scope ?? fallback;
|
|
1635
|
+
return CURRENT_SCOPE ?? getCurrentConsumer()?.scope ?? requestScopeGetter?.() ?? fallback;
|
|
1791
1636
|
};
|
|
1792
1637
|
const SCOPE_OWNER_MAP = /* @__PURE__ */ new WeakMap();
|
|
1793
1638
|
const OWNER_CHILD_MAP = /* @__PURE__ */ new WeakMap();
|
|
@@ -1814,37 +1659,41 @@ const getScopeOwner = (obj) => {
|
|
|
1814
1659
|
return scope;
|
|
1815
1660
|
};
|
|
1816
1661
|
export {
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1662
|
+
callback as A,
|
|
1663
|
+
settled as B,
|
|
1664
|
+
context as C,
|
|
1665
|
+
getContext as D,
|
|
1666
|
+
withContexts as E,
|
|
1667
|
+
setGlobalContexts as F,
|
|
1668
|
+
clearGlobalContexts as G,
|
|
1669
|
+
setScopeOwner as H,
|
|
1821
1670
|
ReactivePromise as R,
|
|
1822
1671
|
SignalScope as S,
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1672
|
+
generatorResultToPromiseWithConsumer as a,
|
|
1673
|
+
setCurrentConsumer as b,
|
|
1674
|
+
createReactiveSignal as c,
|
|
1675
|
+
getCurrentConsumer as d,
|
|
1676
|
+
setRequestScopeGetter as e,
|
|
1677
|
+
createReactiveDefinition as f,
|
|
1829
1678
|
getCurrentScope as g,
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1679
|
+
createTask as h,
|
|
1680
|
+
createRelay as i,
|
|
1681
|
+
getScopeOwner as j,
|
|
1682
|
+
isReactivePromise as k,
|
|
1683
|
+
getGlobalScope as l,
|
|
1684
|
+
hashValue as m,
|
|
1685
|
+
schedulePull as n,
|
|
1686
|
+
isPromise as o,
|
|
1687
|
+
isThennable as p,
|
|
1688
|
+
signal as q,
|
|
1840
1689
|
runSignal as r,
|
|
1841
1690
|
scheduleTracer as s,
|
|
1842
|
-
|
|
1691
|
+
getSignal as t,
|
|
1843
1692
|
unwatchSignal as u,
|
|
1844
|
-
|
|
1693
|
+
registerCustomHash as v,
|
|
1845
1694
|
watchSignal as w,
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1695
|
+
setReactivePromise as x,
|
|
1696
|
+
notifier as y,
|
|
1697
|
+
isSignal as z
|
|
1849
1698
|
};
|
|
1850
|
-
//# sourceMappingURL=contexts-
|
|
1699
|
+
//# sourceMappingURL=contexts-FxCndlvf.js.map
|