octane 0.13.0 → 0.13.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/LICENSE +28 -0
- package/dist/cjs/runtime.server.cjs +4 -1
- package/dist/cjs/signals/engine.cjs +152 -165
- package/dist/cjs/signals/facade.cjs +20 -20
- package/dist/cjs/signals/graph.cjs +278 -90
- package/dist/cjs/signals/requests.cjs +89 -99
- package/dist/cjs/signals/scope-streams.cjs +54 -41
- package/dist/cjs/version.cjs +1 -1
- package/dist/node/runtime.server.js +4 -1
- package/dist/node/signals/engine.js +149 -164
- package/dist/node/signals/facade.js +28 -21
- package/dist/node/signals/graph.js +278 -92
- package/dist/node/signals/requests.js +85 -99
- package/dist/node/signals/scope-streams.js +55 -40
- package/dist/node/version.js +1 -1
- package/dist/runtime.server.d.ts +4 -2
- package/dist/runtime.server.js +4 -1
- package/dist/signals/engine.d.ts +4 -15
- package/dist/signals/engine.js +149 -164
- package/dist/signals/facade.d.ts +5 -7
- package/dist/signals/facade.js +28 -21
- package/dist/signals/graph.d.ts +25 -11
- package/dist/signals/graph.js +278 -92
- package/dist/signals/requests.d.ts +4 -7
- package/dist/signals/requests.js +85 -99
- package/dist/signals/scope-streams.d.ts +11 -7
- package/dist/signals/scope-streams.js +55 -40
- package/dist/signals/transition-state.d.ts +2 -3
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -19,3 +19,31 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
The dependency graph algorithms in src/signals/graph.ts are adapted from
|
|
26
|
+
Alien Signals 3.2.1, commit 8734d386d925025d0e99419bd9161c17b112c5ee:
|
|
27
|
+
https://github.com/stackblitz/alien-signals
|
|
28
|
+
|
|
29
|
+
MIT License
|
|
30
|
+
|
|
31
|
+
Copyright (c) 2024-present Johnson Chu
|
|
32
|
+
|
|
33
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
34
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
35
|
+
in the Software without restriction, including without limitation the rights
|
|
36
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
37
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
38
|
+
furnished to do so, subject to the following conditions:
|
|
39
|
+
|
|
40
|
+
The above copyright notice and this permission notice shall be included in all
|
|
41
|
+
copies or substantial portions of the Software.
|
|
42
|
+
|
|
43
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
44
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
45
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
46
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
47
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
48
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
49
|
+
SOFTWARE.
|
|
@@ -4039,7 +4039,10 @@ const ViewTransition = /* @__PURE__ */ (0, import_component_flags.markComponentF
|
|
|
4039
4039
|
attrs.push(["vt-parent-" + kind.toLowerCase() + "-x", value ?? (handler ? "auto" : "none")]);
|
|
4040
4040
|
}
|
|
4041
4041
|
const annotated = vtSsrAnnotate(inner, attrs);
|
|
4042
|
-
|
|
4042
|
+
const body = props.scope === "element" ? vtSsrAnnotateScope(annotated) : annotated;
|
|
4043
|
+
const children = props.children;
|
|
4044
|
+
const unframed = typeof children === "function" || children !== null && typeof children === "object" && SERVER_HTML in children;
|
|
4045
|
+
return ssrHtml(unframed ? ssrBlock(body) : body);
|
|
4043
4046
|
},
|
|
4044
4047
|
import_component_flags.COMPONENT_FLAGS_AUTHOR_BOUNDARY,
|
|
4045
4048
|
"ViewTransition"
|
|
@@ -34,8 +34,10 @@ __export(engine_exports, {
|
|
|
34
34
|
getResourceSelectionAuthority: () => getResourceSelectionAuthority,
|
|
35
35
|
getSignalScope: () => getSignalScope,
|
|
36
36
|
installPublicScope: () => installPublicScope,
|
|
37
|
+
resumeScopeReads: () => resumeScopeReads,
|
|
37
38
|
signalDeclarationSequence: () => signalDeclarationSequence,
|
|
38
|
-
startSignalBatch: () => import_graph.startSignalBatch
|
|
39
|
+
startSignalBatch: () => import_graph.startSignalBatch,
|
|
40
|
+
suspendScopeReads: () => suspendScopeReads
|
|
39
41
|
});
|
|
40
42
|
module.exports = __toCommonJS(engine_exports);
|
|
41
43
|
var import_error_codes_client_generated = require("../error-codes.client.generated.cjs");
|
|
@@ -131,12 +133,6 @@ class ScopeImpl {
|
|
|
131
133
|
frames = void 0;
|
|
132
134
|
/** Holds a writable or asynchronous derived cell that new render inputs cannot re-select. */
|
|
133
135
|
unkeyedState = false;
|
|
134
|
-
/** An attempt that never committed restarts with new inputs and keeps these cells. */
|
|
135
|
-
supersede() {
|
|
136
|
-
if (this.resources) for (const binding of this.resources.values()) binding.supersede();
|
|
137
|
-
if (this.derivedBindings)
|
|
138
|
-
for (const binding of this.derivedBindings.values()) binding.supersede();
|
|
139
|
-
}
|
|
140
136
|
seedEntries;
|
|
141
137
|
traceLimit;
|
|
142
138
|
events = void 0;
|
|
@@ -144,33 +140,6 @@ class ScopeImpl {
|
|
|
144
140
|
lifetime = 0;
|
|
145
141
|
disposed = false;
|
|
146
142
|
readBarrier;
|
|
147
|
-
/** Internal document lifecycle: mark every owner before cancellation runs user code. */
|
|
148
|
-
suspendReads() {
|
|
149
|
-
if (this.disposed || this.readBarrier === void 0) return;
|
|
150
|
-
this.streams?.suspend();
|
|
151
|
-
if (this.requests) for (const entry of this.requests.values()) entry.stopAttempt();
|
|
152
|
-
if (this.derivedBindings)
|
|
153
|
-
for (const binding of this.derivedBindings.values()) binding.suspend();
|
|
154
|
-
}
|
|
155
|
-
resumeReads() {
|
|
156
|
-
if (this.disposed || this.readBarrier !== void 0) return;
|
|
157
|
-
(0, import_graph.signalBatch)(() => {
|
|
158
|
-
if (this.resources)
|
|
159
|
-
for (const [node, binding] of this.resources) {
|
|
160
|
-
(0, import_graph.refreshNode)(node);
|
|
161
|
-
this.streams?.resume(node, binding);
|
|
162
|
-
}
|
|
163
|
-
if (this.requests)
|
|
164
|
-
for (const entry of this.requests.values()) {
|
|
165
|
-
if (this.readBarrier !== void 0) break;
|
|
166
|
-
if (!entry.active && !entry.state.snapshot.complete && entry.state.snapshot.status !== "error" && entry.consumers.size) {
|
|
167
|
-
entry.start(entry.state.snapshot.status !== "ready");
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
if (this.derivedBindings)
|
|
171
|
-
for (const binding of this.derivedBindings.values()) binding.resume();
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
143
|
get scopeKey() {
|
|
175
144
|
return this.key;
|
|
176
145
|
}
|
|
@@ -180,117 +149,14 @@ class ScopeImpl {
|
|
|
180
149
|
get retired() {
|
|
181
150
|
return this.disposed;
|
|
182
151
|
}
|
|
183
|
-
createNode(key, kind, allowDuringRead = false) {
|
|
184
|
-
(0, import_graph.assertAlive)(this);
|
|
185
|
-
if (this.seedable && !allowDuringRead) (0, import_graph.assertWritable)();
|
|
186
|
-
requireKey(key, "Signal key");
|
|
187
|
-
if (this.nodes.has(key)) throw new TypeError((0, import_error_codes_client_generated.formatClientError)(132, key));
|
|
188
|
-
const seeds = this.seedEntries;
|
|
189
|
-
if (seeds)
|
|
190
|
-
for (const read of ["value", "latest", "snapshot"]) {
|
|
191
|
-
const seed = seeds.get(seedKey(key, read));
|
|
192
|
-
if (seed && seed.entry.kind !== kind) {
|
|
193
|
-
throw new import_errors.SignalFrameError((0, import_error_codes_client_generated.formatClientError)(133, key));
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
const node = new import_graph.ScopedNode(this, key, kind);
|
|
197
|
-
this.nodes.set(key, node);
|
|
198
|
-
return node;
|
|
199
|
-
}
|
|
200
|
-
declaredNode(key, kind) {
|
|
201
|
-
(0, import_graph.assertAlive)(this);
|
|
202
|
-
requireKey(key, "Signal key");
|
|
203
|
-
const existing = this.nodes.get(key);
|
|
204
|
-
if (existing) {
|
|
205
|
-
if (existing.kind !== kind) {
|
|
206
|
-
throw new TypeError((0, import_error_codes_client_generated.formatClientError)(134, key, existing.kind));
|
|
207
|
-
}
|
|
208
|
-
return [existing, false];
|
|
209
|
-
}
|
|
210
|
-
return [this.createNode(key, kind, true), true];
|
|
211
|
-
}
|
|
212
|
-
initialSeed(key) {
|
|
213
|
-
const seeds = this.seedEntries;
|
|
214
|
-
return seeds && (seeds.get(seedKey(key)) ?? seeds.get(seedKey(key, "snapshot")));
|
|
215
|
-
}
|
|
216
|
-
retainedSeed(key) {
|
|
217
|
-
const seeds = this.seedEntries;
|
|
218
|
-
if (!seeds) return void 0;
|
|
219
|
-
const seed = seeds.get(seedKey(key, "latest")) ?? this.initialSeed(key);
|
|
220
|
-
return seed?.entry.available === false ? void 0 : seed;
|
|
221
|
-
}
|
|
222
|
-
initializeRetention(node) {
|
|
223
|
-
const seed = this.retainedSeed(node.key);
|
|
224
|
-
if (!seed) return;
|
|
225
|
-
node.lastState = seedState(seed);
|
|
226
|
-
node.last = seed.value;
|
|
227
|
-
node.hasLast = true;
|
|
228
|
-
}
|
|
229
|
-
consumeSeed(key) {
|
|
230
|
-
const seeds = this.seedEntries;
|
|
231
|
-
if (seeds)
|
|
232
|
-
for (const read of ["value", "latest", "snapshot"]) {
|
|
233
|
-
seeds.delete(seedKey(key, read));
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
152
|
signal$(key, initial) {
|
|
237
|
-
const node = this
|
|
238
|
-
const seed = this
|
|
153
|
+
const node = createScopeNode(this, key, "signal");
|
|
154
|
+
const seed = initialScopeSeed(this, key) ?? retainedScopeSeed(this, key);
|
|
239
155
|
node.state = (0, import_graph.readyState)(seed ? seed.value : initial);
|
|
240
156
|
node.lastState = node.state;
|
|
241
157
|
node.last = node.state.snapshot.value;
|
|
242
158
|
node.hasLast = true;
|
|
243
|
-
this
|
|
244
|
-
return node;
|
|
245
|
-
}
|
|
246
|
-
createSignalDeclaration(key, initial, preferInitial = false) {
|
|
247
|
-
const [node, created] = this.declaredNode(key, "signal");
|
|
248
|
-
if (!created) return node;
|
|
249
|
-
const seed = this.initialSeed(key) ?? this.retainedSeed(key);
|
|
250
|
-
node.state = (0, import_graph.readyState)(seed && !preferInitial ? seed.value : initial);
|
|
251
|
-
node.lastState = node.state;
|
|
252
|
-
node.last = node.state.snapshot.value;
|
|
253
|
-
node.hasLast = true;
|
|
254
|
-
this.consumeSeed(key);
|
|
255
|
-
return node;
|
|
256
|
-
}
|
|
257
|
-
createDerivedDeclaration(key, compute, options, Binding, sequence = 0, captures, declaring = 0) {
|
|
258
|
-
if (typeof compute !== "function") throw new TypeError((0, import_error_codes_client_generated.formatClientError)(122));
|
|
259
|
-
const [node, created] = this.declaredNode(key, "derived");
|
|
260
|
-
if (!created) {
|
|
261
|
-
const binding2 = this.derivedBindings?.get(node);
|
|
262
|
-
return binding2?.redeclare(compute, sequence, captures, declaring) ?? node;
|
|
263
|
-
}
|
|
264
|
-
const binding = new Binding(this, node, compute, options);
|
|
265
|
-
binding.declared(sequence, captures, declaring);
|
|
266
|
-
(this.derivedBindings ??= /* @__PURE__ */ new Map()).set(node, binding);
|
|
267
|
-
this.initializeRetention(node);
|
|
268
|
-
this.consumeSeed(key);
|
|
269
|
-
return node;
|
|
270
|
-
}
|
|
271
|
-
createResourceDeclaration(key, describe, initialize, unique = false, sequence = 0, captures, declaring = 0) {
|
|
272
|
-
if (typeof describe !== "function") throw new TypeError((0, import_error_codes_client_generated.formatClientError)(137));
|
|
273
|
-
let node;
|
|
274
|
-
if (unique) node = this.createNode(key, "async");
|
|
275
|
-
else {
|
|
276
|
-
const [declared, created] = this.declaredNode(key, "async");
|
|
277
|
-
if (!created) {
|
|
278
|
-
const binding = this.resources?.get(declared);
|
|
279
|
-
return binding?.redeclare(describe, sequence, captures, declaring) ?? declared;
|
|
280
|
-
}
|
|
281
|
-
node = declared;
|
|
282
|
-
}
|
|
283
|
-
const seed = this.initialSeed(key);
|
|
284
|
-
const retained = this.retainedSeed(key);
|
|
285
|
-
this.initializeRetention(node);
|
|
286
|
-
(0, import_graph.signalBatch)(() => {
|
|
287
|
-
const binding = initialize(this, node, describe, seed, retained);
|
|
288
|
-
binding.declared(sequence, captures, declaring);
|
|
289
|
-
(this.resources ??= /* @__PURE__ */ new Map()).set(node, binding);
|
|
290
|
-
(0, import_graph.refreshNode)(node);
|
|
291
|
-
this.streams?.flush(node, binding);
|
|
292
|
-
});
|
|
293
|
-
this.consumeSeed(key);
|
|
159
|
+
consumeScopeSeed(this, key);
|
|
294
160
|
return node;
|
|
295
161
|
}
|
|
296
162
|
// Server native reads serialize, and hydration adopts, internal owner scopes
|
|
@@ -338,6 +204,85 @@ class ScopeImpl {
|
|
|
338
204
|
});
|
|
339
205
|
}
|
|
340
206
|
}
|
|
207
|
+
function suspendScopeReads(scope) {
|
|
208
|
+
if (scope.disposed || scope.readBarrier === void 0) return;
|
|
209
|
+
scope.streams?.suspend();
|
|
210
|
+
if (scope.requests) for (const entry of scope.requests.values()) entry.stopAttempt();
|
|
211
|
+
if (scope.derivedBindings)
|
|
212
|
+
for (const binding of scope.derivedBindings.values()) binding.suspend();
|
|
213
|
+
}
|
|
214
|
+
function resumeScopeReads(scope) {
|
|
215
|
+
if (scope.disposed || scope.readBarrier !== void 0) return;
|
|
216
|
+
(0, import_graph.signalBatch)(() => {
|
|
217
|
+
if (scope.resources)
|
|
218
|
+
for (const [node, binding] of scope.resources) {
|
|
219
|
+
(0, import_graph.refreshNode)(node);
|
|
220
|
+
scope.streams?.resume(node, binding);
|
|
221
|
+
}
|
|
222
|
+
if (scope.requests)
|
|
223
|
+
for (const entry of scope.requests.values()) {
|
|
224
|
+
if (scope.readBarrier !== void 0) break;
|
|
225
|
+
if (!entry.active && !entry.state.snapshot.complete && entry.state.snapshot.status !== "error" && entry.consumers.size) {
|
|
226
|
+
entry.start(entry.state.snapshot.status !== "ready");
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (scope.derivedBindings)
|
|
230
|
+
for (const binding of scope.derivedBindings.values()) binding.resume();
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
function createScopeNode(owner, key, kind, allowDuringRead = false) {
|
|
234
|
+
(0, import_graph.assertAlive)(owner);
|
|
235
|
+
if (owner.seedable && !allowDuringRead) (0, import_graph.assertWritable)();
|
|
236
|
+
requireKey(key, "Signal key");
|
|
237
|
+
if (owner.nodes.has(key)) throw new TypeError((0, import_error_codes_client_generated.formatClientError)(132, key));
|
|
238
|
+
const seeds = owner.seedEntries;
|
|
239
|
+
if (seeds)
|
|
240
|
+
for (const read of ["value", "latest", "snapshot"]) {
|
|
241
|
+
const seed = seeds.get(seedKey(key, read));
|
|
242
|
+
if (seed && seed.entry.kind !== kind) {
|
|
243
|
+
throw new import_errors.SignalFrameError((0, import_error_codes_client_generated.formatClientError)(133, key));
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
const node = new import_graph.ScopedNode(owner, key, kind);
|
|
247
|
+
owner.nodes.set(key, node);
|
|
248
|
+
return node;
|
|
249
|
+
}
|
|
250
|
+
function declaredScopeNode(owner, key, kind) {
|
|
251
|
+
(0, import_graph.assertAlive)(owner);
|
|
252
|
+
requireKey(key, "Signal key");
|
|
253
|
+
const existing = owner.nodes.get(key);
|
|
254
|
+
if (existing) {
|
|
255
|
+
if (existing.kind !== kind) {
|
|
256
|
+
throw new TypeError((0, import_error_codes_client_generated.formatClientError)(134, key, existing.kind));
|
|
257
|
+
}
|
|
258
|
+
return [existing, false];
|
|
259
|
+
}
|
|
260
|
+
return [createScopeNode(owner, key, kind, true), true];
|
|
261
|
+
}
|
|
262
|
+
function initialScopeSeed(owner, key) {
|
|
263
|
+
const seeds = owner.seedEntries;
|
|
264
|
+
return seeds && (seeds.get(seedKey(key)) ?? seeds.get(seedKey(key, "snapshot")));
|
|
265
|
+
}
|
|
266
|
+
function retainedScopeSeed(owner, key) {
|
|
267
|
+
const seeds = owner.seedEntries;
|
|
268
|
+
if (!seeds) return void 0;
|
|
269
|
+
const seed = seeds.get(seedKey(key, "latest")) ?? initialScopeSeed(owner, key);
|
|
270
|
+
return seed?.entry.available === false ? void 0 : seed;
|
|
271
|
+
}
|
|
272
|
+
function initializeScopeRetention(owner, node) {
|
|
273
|
+
const seed = retainedScopeSeed(owner, node.key);
|
|
274
|
+
if (!seed) return;
|
|
275
|
+
node.lastState = seedState(seed);
|
|
276
|
+
node.last = seed.value;
|
|
277
|
+
node.hasLast = true;
|
|
278
|
+
}
|
|
279
|
+
function consumeScopeSeed(owner, key) {
|
|
280
|
+
const seeds = owner.seedEntries;
|
|
281
|
+
if (seeds)
|
|
282
|
+
for (const read of ["value", "latest", "snapshot"]) {
|
|
283
|
+
seeds.delete(seedKey(key, read));
|
|
284
|
+
}
|
|
285
|
+
}
|
|
341
286
|
function presentedSeed(entries, key, read) {
|
|
342
287
|
return entries.get(seedKey(key, read)) ?? (read === "value" ? void 0 : entries.get(seedKey(key)));
|
|
343
288
|
}
|
|
@@ -612,10 +557,10 @@ function installPublicScope() {
|
|
|
612
557
|
const prototype = ScopeImpl.prototype;
|
|
613
558
|
prototype.derived$ = function(key, compute) {
|
|
614
559
|
if (typeof compute !== "function") throw new TypeError((0, import_error_codes_client_generated.formatClientError)(122));
|
|
615
|
-
const node = this
|
|
560
|
+
const node = createScopeNode(this, key, "derived");
|
|
616
561
|
node.compute = (target) => (0, import_graph.derivedState)(target, compute);
|
|
617
|
-
this
|
|
618
|
-
this
|
|
562
|
+
initializeScopeRetention(this, node);
|
|
563
|
+
consumeScopeSeed(this, key);
|
|
619
564
|
return node;
|
|
620
565
|
};
|
|
621
566
|
prototype.get = function(handle$) {
|
|
@@ -681,19 +626,30 @@ function createLocalScope(scopeKey) {
|
|
|
681
626
|
}
|
|
682
627
|
function createDeclaredSignalCell(owner, key, initial, preferInitial = false) {
|
|
683
628
|
if (!(owner instanceof ScopeImpl)) throw new TypeError((0, import_error_codes_client_generated.formatClientError)(148));
|
|
684
|
-
|
|
629
|
+
const [node, created] = declaredScopeNode(owner, key, "signal");
|
|
630
|
+
if (!created) return node;
|
|
631
|
+
const seed = initialScopeSeed(owner, key) ?? retainedScopeSeed(owner, key);
|
|
632
|
+
node.state = (0, import_graph.readyState)(seed && !preferInitial ? seed.value : initial);
|
|
633
|
+
node.lastState = node.state;
|
|
634
|
+
node.last = node.state.snapshot.value;
|
|
635
|
+
node.hasLast = true;
|
|
636
|
+
consumeScopeSeed(owner, key);
|
|
637
|
+
return node;
|
|
685
638
|
}
|
|
686
639
|
function createDerivedCellWith(owner, key, compute, options, Binding, sequence = 0, captures, declaring = 0) {
|
|
687
640
|
if (!(owner instanceof ScopeImpl)) throw new TypeError((0, import_error_codes_client_generated.formatClientError)(149));
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
);
|
|
641
|
+
if (typeof compute !== "function") throw new TypeError((0, import_error_codes_client_generated.formatClientError)(122));
|
|
642
|
+
const [node, created] = declaredScopeNode(owner, key, "derived");
|
|
643
|
+
if (!created) {
|
|
644
|
+
const binding2 = owner.derivedBindings?.get(node);
|
|
645
|
+
return binding2?.redeclare(compute, sequence, captures, declaring) ?? node;
|
|
646
|
+
}
|
|
647
|
+
const binding = new Binding(owner, node, compute, options);
|
|
648
|
+
binding.declared(sequence, captures, declaring);
|
|
649
|
+
(owner.derivedBindings ??= /* @__PURE__ */ new Map()).set(node, binding);
|
|
650
|
+
initializeScopeRetention(owner, node);
|
|
651
|
+
consumeScopeSeed(owner, key);
|
|
652
|
+
return node;
|
|
697
653
|
}
|
|
698
654
|
let declarationSequence = 0;
|
|
699
655
|
function signalDeclarationSequence(site) {
|
|
@@ -701,27 +657,56 @@ function signalDeclarationSequence(site) {
|
|
|
701
657
|
}
|
|
702
658
|
function createResourceCellWith(owner, key, describe, initialize, unique = false, sequence = 0, captures, declaring = 0) {
|
|
703
659
|
if (!(owner instanceof ScopeImpl)) throw new TypeError((0, import_error_codes_client_generated.formatClientError)(150));
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
660
|
+
if (typeof describe !== "function") throw new TypeError((0, import_error_codes_client_generated.formatClientError)(137));
|
|
661
|
+
let node;
|
|
662
|
+
if (unique) node = createScopeNode(owner, key, "async");
|
|
663
|
+
else {
|
|
664
|
+
const [declared, created] = declaredScopeNode(owner, key, "async");
|
|
665
|
+
if (!created) {
|
|
666
|
+
const binding = owner.resources?.get(declared);
|
|
667
|
+
return binding?.redeclare(describe, sequence, captures, declaring) ?? declared;
|
|
668
|
+
}
|
|
669
|
+
node = declared;
|
|
670
|
+
}
|
|
671
|
+
const seed = initialScopeSeed(owner, key);
|
|
672
|
+
const retained = retainedScopeSeed(owner, key);
|
|
673
|
+
initializeScopeRetention(owner, node);
|
|
674
|
+
(0, import_graph.signalBatch)(() => {
|
|
675
|
+
const binding = initialize(owner, node, describe, seed, retained);
|
|
676
|
+
binding.declared(sequence, captures, declaring);
|
|
677
|
+
(owner.resources ??= /* @__PURE__ */ new Map()).set(node, binding);
|
|
678
|
+
(0, import_graph.refreshNode)(node);
|
|
679
|
+
owner.streams?.flush(node, binding);
|
|
680
|
+
});
|
|
681
|
+
consumeScopeSeed(owner, key);
|
|
682
|
+
return node;
|
|
713
683
|
}
|
|
714
684
|
function adoptResourceValue(handle$, requestKey, value) {
|
|
715
685
|
if (!(handle$ instanceof import_graph.ScopedNode) || !(handle$.owner instanceof ScopeImpl)) return false;
|
|
716
686
|
const binding = handle$.owner.resources?.get(handle$);
|
|
717
|
-
|
|
687
|
+
if (!binding) return false;
|
|
688
|
+
(0, import_graph.assertAlive)(binding.owner);
|
|
689
|
+
(0, import_graph.assertWritable)();
|
|
690
|
+
const entry = binding.selected;
|
|
691
|
+
if (!entry || entry.request.identity !== requestKey) return false;
|
|
692
|
+
const streaming = entry.request.definition.kind === "stream";
|
|
693
|
+
if (!streaming) entry.stopAttempt();
|
|
694
|
+
entry.state = (0, import_graph.readyState)(value, {
|
|
695
|
+
requestKey: entry.request.identity,
|
|
696
|
+
connection: streaming ? entry.state.snapshot.connection : "none",
|
|
697
|
+
complete: streaming ? entry.state.snapshot.complete : true
|
|
698
|
+
});
|
|
699
|
+
entry.deliver();
|
|
700
|
+
return true;
|
|
718
701
|
}
|
|
719
702
|
function getSignalScope(handle$) {
|
|
720
703
|
return handle$ instanceof import_graph.ScopedNode && handle$.owner instanceof ScopeImpl ? handle$.owner : void 0;
|
|
721
704
|
}
|
|
722
705
|
function getResourceSelectionAuthority(handle$) {
|
|
723
706
|
if (!(handle$ instanceof import_graph.ScopedNode) || !(handle$.owner instanceof ScopeImpl)) return;
|
|
724
|
-
|
|
707
|
+
const binding = handle$.owner.resources?.get(handle$);
|
|
708
|
+
if (!binding) return;
|
|
709
|
+
return binding.selected ? binding.selectionAuthority : void 0;
|
|
725
710
|
}
|
|
726
711
|
function bindScopeStreamedSelection(owner, identity) {
|
|
727
712
|
if (!(owner instanceof ScopeImpl)) return false;
|
|
@@ -758,6 +743,8 @@ function failScopeStreamedResult(owner, identity, error) {
|
|
|
758
743
|
getResourceSelectionAuthority,
|
|
759
744
|
getSignalScope,
|
|
760
745
|
installPublicScope,
|
|
746
|
+
resumeScopeReads,
|
|
761
747
|
signalDeclarationSequence,
|
|
762
|
-
startSignalBatch
|
|
748
|
+
startSignalBatch,
|
|
749
|
+
suspendScopeReads
|
|
763
750
|
});
|
|
@@ -183,7 +183,11 @@ function supersedeOwner(owner) {
|
|
|
183
183
|
if (retiredIdentities.has(identity)) return false;
|
|
184
184
|
const scope = identityScopes.get(identity);
|
|
185
185
|
if (scope?.unkeyedState) return false;
|
|
186
|
-
scope
|
|
186
|
+
if (scope) {
|
|
187
|
+
if (scope.resources) for (const binding of scope.resources.values()) binding.supersede();
|
|
188
|
+
if (scope.derivedBindings)
|
|
189
|
+
for (const binding of scope.derivedBindings.values()) binding.supersede();
|
|
190
|
+
}
|
|
187
191
|
return true;
|
|
188
192
|
}
|
|
189
193
|
function createSignalOwnerLifecycle(owner) {
|
|
@@ -213,7 +217,7 @@ function createSignalOwnerLifecycle(owner) {
|
|
|
213
217
|
frozenDocuments.set(owner, barrier);
|
|
214
218
|
const existing = scopes();
|
|
215
219
|
for (const scope of existing) scope.readBarrier = barrier;
|
|
216
|
-
for (const scope of existing)
|
|
220
|
+
for (const scope of existing) (0, import_engine.suspendScopeReads)(scope);
|
|
217
221
|
},
|
|
218
222
|
resume() {
|
|
219
223
|
if (this.retired || barrier === void 0) return;
|
|
@@ -225,7 +229,7 @@ function createSignalOwnerLifecycle(owner) {
|
|
|
225
229
|
release = void 0;
|
|
226
230
|
for (const scope of existing) {
|
|
227
231
|
if (barrier !== void 0 || this.retired) break;
|
|
228
|
-
|
|
232
|
+
(0, import_engine.resumeScopeReads)(scope);
|
|
229
233
|
}
|
|
230
234
|
},
|
|
231
235
|
retire() {
|
|
@@ -323,19 +327,6 @@ class Descriptor {
|
|
|
323
327
|
* the read path's check never changes or misses the descriptor's shape.
|
|
324
328
|
*/
|
|
325
329
|
lexical;
|
|
326
|
-
/** @internal See __declared. */
|
|
327
|
-
static declared(handle$) {
|
|
328
|
-
if (!(handle$ instanceof Descriptor) || handle$.owner === void 0) return handle$;
|
|
329
|
-
const declared = handle$;
|
|
330
|
-
const Class = declared.constructor;
|
|
331
|
-
return declared.lexical ??= new Class(
|
|
332
|
-
declared.key,
|
|
333
|
-
declared.kind,
|
|
334
|
-
declared.create,
|
|
335
|
-
declared.site,
|
|
336
|
-
declared
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
330
|
/** The owner a use resolves for: its reader, or for a lexical handle its declaring owner. */
|
|
340
331
|
reader() {
|
|
341
332
|
return this.lexical === this ? this.owner : requireOwner();
|
|
@@ -437,7 +428,16 @@ class Descriptor {
|
|
|
437
428
|
}
|
|
438
429
|
}
|
|
439
430
|
function __declared(handle$) {
|
|
440
|
-
|
|
431
|
+
if (!(handle$ instanceof Descriptor) || handle$.owner === void 0) return handle$;
|
|
432
|
+
const declared = handle$;
|
|
433
|
+
const Class = declared.constructor;
|
|
434
|
+
return declared.lexical ??= new Class(
|
|
435
|
+
declared.key,
|
|
436
|
+
declared.kind,
|
|
437
|
+
declared.create,
|
|
438
|
+
declared.site,
|
|
439
|
+
declared
|
|
440
|
+
);
|
|
441
441
|
}
|
|
442
442
|
class SignalDescriptor extends Descriptor {
|
|
443
443
|
set(value) {
|
|
@@ -556,18 +556,18 @@ function attachStreamedSignalResult(receiver, owner, identity) {
|
|
|
556
556
|
const consumer = {
|
|
557
557
|
accept(frame) {
|
|
558
558
|
if (acceptStreamedSignalResult(owner, frame)) return;
|
|
559
|
-
if (
|
|
559
|
+
if ((0, import_scope_streams.isScopeStreamPending)(streams, frame.identity)) return false;
|
|
560
560
|
fail(new import_errors.SignalStreamError("identity"));
|
|
561
561
|
throw new import_errors.SignalStreamError("identity");
|
|
562
562
|
},
|
|
563
563
|
retainCompleted(frames) {
|
|
564
|
-
return
|
|
564
|
+
return (0, import_scope_streams.retainCompletedScopeStream)(streams, identity, frames);
|
|
565
565
|
},
|
|
566
566
|
fail
|
|
567
567
|
};
|
|
568
568
|
try {
|
|
569
569
|
let detach = receiver.attachResult(identity, consumer);
|
|
570
|
-
const stopWaiting =
|
|
570
|
+
const stopWaiting = (0, import_scope_streams.whenScopeStreamReady)(streams, identity, () => {
|
|
571
571
|
detach = receiver.attachResult(identity, consumer);
|
|
572
572
|
});
|
|
573
573
|
return () => {
|