@async/framework 0.11.1 → 0.11.3
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 +30 -0
- package/README.md +3 -1
- package/browser.js +264 -39
- package/browser.min.js +1 -1
- package/browser.ts +264 -39
- package/browser.umd.js +264 -39
- package/browser.umd.min.js +1 -1
- package/framework.ts +270 -40
- package/package.json +4 -3
- package/server.js +270 -40
package/server.js
CHANGED
|
@@ -187,6 +187,28 @@ const __asyncSignalModule = (() => {
|
|
|
187
187
|
};
|
|
188
188
|
},
|
|
189
189
|
|
|
190
|
+
_cloneSignalDeclaration() {
|
|
191
|
+
return asyncSignal(id, fn);
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
_restore(snapshot = {}) {
|
|
195
|
+
if (!isAsyncSignalSnapshot(snapshot)) {
|
|
196
|
+
return state.set(snapshot);
|
|
197
|
+
}
|
|
198
|
+
if (activeAbort && !activeAbort.aborted) {
|
|
199
|
+
activeAbort.cancel(new Error(`Async signal "${registeredId}" restored from snapshot.`));
|
|
200
|
+
}
|
|
201
|
+
value = snapshot.value;
|
|
202
|
+
loading = Boolean(snapshot.loading);
|
|
203
|
+
error = snapshot.error ?? null;
|
|
204
|
+
status = typeof snapshot.status === "string" ? snapshot.status : inferStatus({ value, loading, error });
|
|
205
|
+
if (Number.isFinite(snapshot.version)) {
|
|
206
|
+
version = snapshot.version;
|
|
207
|
+
}
|
|
208
|
+
notify();
|
|
209
|
+
return state;
|
|
210
|
+
},
|
|
211
|
+
|
|
190
212
|
_bindRegistry(nextRegistry, nextId) {
|
|
191
213
|
registry = nextRegistry;
|
|
192
214
|
registeredId = nextId;
|
|
@@ -272,6 +294,27 @@ const __asyncSignalModule = (() => {
|
|
|
272
294
|
return Boolean(value?.[asyncSignalKind]);
|
|
273
295
|
}
|
|
274
296
|
|
|
297
|
+
function isAsyncSignalSnapshot(value) {
|
|
298
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
return Object.hasOwn(value, "value")
|
|
302
|
+
&& (Object.hasOwn(value, "loading")
|
|
303
|
+
|| Object.hasOwn(value, "error")
|
|
304
|
+
|| Object.hasOwn(value, "status")
|
|
305
|
+
|| Object.hasOwn(value, "version"));
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function inferStatus({ value, loading, error }) {
|
|
309
|
+
if (loading) {
|
|
310
|
+
return "loading";
|
|
311
|
+
}
|
|
312
|
+
if (error) {
|
|
313
|
+
return "error";
|
|
314
|
+
}
|
|
315
|
+
return value === undefined ? "idle" : "ready";
|
|
316
|
+
}
|
|
317
|
+
|
|
275
318
|
function attachCancel(signal, controller) {
|
|
276
319
|
Object.defineProperty(signal, "cancel", {
|
|
277
320
|
configurable: true,
|
|
@@ -919,7 +962,12 @@ const __cacheModule = (() => {
|
|
|
919
962
|
return registryStore.entries(`${type}.entries`);
|
|
920
963
|
},
|
|
921
964
|
|
|
922
|
-
_adoptMany() {
|
|
965
|
+
_adoptMany(map = {}) {
|
|
966
|
+
for (const [id, definition] of Object.entries(map ?? {})) {
|
|
967
|
+
if (!definitions.has(id)) {
|
|
968
|
+
registryApi.register(id, definition);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
923
971
|
return registryApi;
|
|
924
972
|
}
|
|
925
973
|
}, registryStore, type);
|
|
@@ -1077,6 +1125,10 @@ const __signalsModule = (() => {
|
|
|
1077
1125
|
|
|
1078
1126
|
snapshot() {
|
|
1079
1127
|
return value;
|
|
1128
|
+
},
|
|
1129
|
+
|
|
1130
|
+
_cloneSignalDeclaration() {
|
|
1131
|
+
return createSignal(value);
|
|
1080
1132
|
}
|
|
1081
1133
|
};
|
|
1082
1134
|
|
|
@@ -1119,6 +1171,10 @@ const __signalsModule = (() => {
|
|
|
1119
1171
|
return backing.snapshot();
|
|
1120
1172
|
},
|
|
1121
1173
|
|
|
1174
|
+
_cloneSignalDeclaration() {
|
|
1175
|
+
return computed(fn);
|
|
1176
|
+
},
|
|
1177
|
+
|
|
1122
1178
|
_bindRegistry(registry, id) {
|
|
1123
1179
|
return registry.effect(() => {
|
|
1124
1180
|
backing.set(fn.call({
|
|
@@ -1143,6 +1199,9 @@ const __signalsModule = (() => {
|
|
|
1143
1199
|
[effectKind]: true,
|
|
1144
1200
|
kind: "effect",
|
|
1145
1201
|
fn,
|
|
1202
|
+
_cloneSignalDeclaration() {
|
|
1203
|
+
return effect(fn);
|
|
1204
|
+
},
|
|
1146
1205
|
_bindRegistry(registry) {
|
|
1147
1206
|
return registry.effect(fn);
|
|
1148
1207
|
}
|
|
@@ -1361,10 +1420,14 @@ const __signalsModule = (() => {
|
|
|
1361
1420
|
},
|
|
1362
1421
|
|
|
1363
1422
|
_adoptMany(map = {}) {
|
|
1364
|
-
for (const id of Object.
|
|
1365
|
-
if (entries.has(id)) {
|
|
1366
|
-
|
|
1423
|
+
for (const [id, signalLike] of Object.entries(map ?? {})) {
|
|
1424
|
+
if (!entries.has(id)) {
|
|
1425
|
+
const entry = cloneSignalDeclaration(signalLike);
|
|
1426
|
+
entries.set(id, entry);
|
|
1427
|
+
bindEntry(id, entry);
|
|
1428
|
+
continue;
|
|
1367
1429
|
}
|
|
1430
|
+
bindEntry(id, entries.get(id));
|
|
1368
1431
|
}
|
|
1369
1432
|
return registry;
|
|
1370
1433
|
}
|
|
@@ -1442,6 +1505,16 @@ const __signalsModule = (() => {
|
|
|
1442
1505
|
return createSignal(signalLike);
|
|
1443
1506
|
}
|
|
1444
1507
|
|
|
1508
|
+
function cloneSignalDeclaration(signalLike) {
|
|
1509
|
+
if (typeof signalLike?._cloneSignalDeclaration === "function") {
|
|
1510
|
+
return signalLike._cloneSignalDeclaration();
|
|
1511
|
+
}
|
|
1512
|
+
if (isSignalLike(signalLike)) {
|
|
1513
|
+
return createSignal(typeof signalLike.snapshot === "function" ? signalLike.snapshot() : signalLike.value);
|
|
1514
|
+
}
|
|
1515
|
+
return createSignal(signalLike);
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1445
1518
|
function isSignalLike(value) {
|
|
1446
1519
|
return Boolean(value && typeof value === "object" && typeof value.subscribe === "function");
|
|
1447
1520
|
}
|
|
@@ -1620,7 +1693,7 @@ const __signalsModule = (() => {
|
|
|
1620
1693
|
frame.add(path);
|
|
1621
1694
|
}
|
|
1622
1695
|
}
|
|
1623
|
-
return { createSignal, computed, effect, createSignalRegistry, isSignalRef, signal };
|
|
1696
|
+
return { createSignal, computed, effect, createSignalRegistry, cloneSignalDeclaration, isSignalRef, signal };
|
|
1624
1697
|
})();
|
|
1625
1698
|
|
|
1626
1699
|
const __htmlModule = (() => {
|
|
@@ -1862,7 +1935,12 @@ const __componentModule = (() => {
|
|
|
1862
1935
|
return lazyComponents.get(id);
|
|
1863
1936
|
},
|
|
1864
1937
|
|
|
1865
|
-
_adoptMany() {
|
|
1938
|
+
_adoptMany(map = {}) {
|
|
1939
|
+
for (const [id, Component] of Object.entries(map ?? {})) {
|
|
1940
|
+
if (!entries.has(id)) {
|
|
1941
|
+
registry.register(id, Component);
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1866
1944
|
return registry;
|
|
1867
1945
|
}
|
|
1868
1946
|
}, registryStore, type);
|
|
@@ -1910,12 +1988,16 @@ const __componentModule = (() => {
|
|
|
1910
1988
|
});
|
|
1911
1989
|
|
|
1912
1990
|
const output = Component.call(context, props);
|
|
1991
|
+
if (output && typeof output.then === "function") {
|
|
1992
|
+
throw new TypeError(`Component "${componentName(Component)}" returned a Promise. Async components are not supported by synchronous renderComponent(). Use an async partial or handler instead.`);
|
|
1993
|
+
}
|
|
1913
1994
|
const html = renderScopedTemplate(output);
|
|
1914
1995
|
|
|
1915
1996
|
return {
|
|
1916
1997
|
html,
|
|
1917
1998
|
attach(target) {
|
|
1918
|
-
for (
|
|
1999
|
+
for (let index = 0; index < attachHooks.length; index += 1) {
|
|
2000
|
+
const hook = attachHooks[index];
|
|
1919
2001
|
runtime.scheduler?.enqueue("lifecycle", () => {
|
|
1920
2002
|
const cleanup = hook(target);
|
|
1921
2003
|
if (typeof cleanup === "function") {
|
|
@@ -1923,7 +2005,7 @@ const __componentModule = (() => {
|
|
|
1923
2005
|
}
|
|
1924
2006
|
}, {
|
|
1925
2007
|
scope,
|
|
1926
|
-
key: `attach:${
|
|
2008
|
+
key: `attach:${index}`
|
|
1927
2009
|
}) ?? runAttachHook(hook, target);
|
|
1928
2010
|
}
|
|
1929
2011
|
},
|
|
@@ -1931,8 +2013,12 @@ const __componentModule = (() => {
|
|
|
1931
2013
|
this.attach(target);
|
|
1932
2014
|
},
|
|
1933
2015
|
visible(target, observeVisible) {
|
|
1934
|
-
|
|
1935
|
-
|
|
2016
|
+
if (visibleHooks.length === 0) {
|
|
2017
|
+
return;
|
|
2018
|
+
}
|
|
2019
|
+
const cleanup = observeVisible(target, () => {
|
|
2020
|
+
for (let index = 0; index < visibleHooks.length; index += 1) {
|
|
2021
|
+
const hook = visibleHooks[index];
|
|
1936
2022
|
runtime.scheduler?.enqueue("lifecycle", () => {
|
|
1937
2023
|
const hookCleanup = hook(target);
|
|
1938
2024
|
if (typeof hookCleanup === "function") {
|
|
@@ -1940,12 +2026,12 @@ const __componentModule = (() => {
|
|
|
1940
2026
|
}
|
|
1941
2027
|
}, {
|
|
1942
2028
|
scope,
|
|
1943
|
-
key: `visible:${
|
|
2029
|
+
key: `visible:${index}`
|
|
1944
2030
|
}) ?? runVisibleHook(hook, target);
|
|
1945
|
-
});
|
|
1946
|
-
if (typeof cleanup === "function") {
|
|
1947
|
-
cleanups.push(cleanup);
|
|
1948
2031
|
}
|
|
2032
|
+
});
|
|
2033
|
+
if (typeof cleanup === "function") {
|
|
2034
|
+
cleanups.push(cleanup);
|
|
1949
2035
|
}
|
|
1950
2036
|
},
|
|
1951
2037
|
cleanup() {
|
|
@@ -2201,11 +2287,12 @@ const __serverModule = (() => {
|
|
|
2201
2287
|
signal: context.abort
|
|
2202
2288
|
});
|
|
2203
2289
|
|
|
2290
|
+
assertTransportResponse(id, response);
|
|
2204
2291
|
if (!response.ok) {
|
|
2205
2292
|
throw new Error(`Server function "${id}" failed with ${response.status}.`);
|
|
2206
2293
|
}
|
|
2207
2294
|
|
|
2208
|
-
const result = await readServerResponse(response);
|
|
2295
|
+
const result = await readServerResponse(id, response);
|
|
2209
2296
|
await applyServerResult(result, runContext);
|
|
2210
2297
|
return markAppliedServerValue(unwrapServerResult(result));
|
|
2211
2298
|
}
|
|
@@ -2246,6 +2333,11 @@ const __serverModule = (() => {
|
|
|
2246
2333
|
return result;
|
|
2247
2334
|
}
|
|
2248
2335
|
|
|
2336
|
+
if (result.error) {
|
|
2337
|
+
markAppliedServerResult(result);
|
|
2338
|
+
throw toError(result.error);
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2249
2341
|
if (result.signals && context.signals) {
|
|
2250
2342
|
for (const [path, value] of Object.entries(result.signals)) {
|
|
2251
2343
|
context.signals.set?.(path, value);
|
|
@@ -2264,15 +2356,7 @@ const __serverModule = (() => {
|
|
|
2264
2356
|
await context.router?.navigate?.(result.redirect);
|
|
2265
2357
|
}
|
|
2266
2358
|
|
|
2267
|
-
|
|
2268
|
-
throw toError(result.error);
|
|
2269
|
-
}
|
|
2270
|
-
|
|
2271
|
-
Object.defineProperty(result, appliedServerResult, {
|
|
2272
|
-
configurable: true,
|
|
2273
|
-
enumerable: false,
|
|
2274
|
-
value: true
|
|
2275
|
-
});
|
|
2359
|
+
markAppliedServerResult(result);
|
|
2276
2360
|
|
|
2277
2361
|
return result;
|
|
2278
2362
|
}
|
|
@@ -2291,6 +2375,15 @@ const __serverModule = (() => {
|
|
|
2291
2375
|
return value;
|
|
2292
2376
|
}
|
|
2293
2377
|
|
|
2378
|
+
function markAppliedServerResult(result) {
|
|
2379
|
+
Object.defineProperty(result, appliedServerResult, {
|
|
2380
|
+
configurable: true,
|
|
2381
|
+
enumerable: false,
|
|
2382
|
+
value: true
|
|
2383
|
+
});
|
|
2384
|
+
return result;
|
|
2385
|
+
}
|
|
2386
|
+
|
|
2294
2387
|
function defaultInput(context = {}) {
|
|
2295
2388
|
const form = findForm(context);
|
|
2296
2389
|
if (form) {
|
|
@@ -2368,10 +2461,37 @@ const __serverModule = (() => {
|
|
|
2368
2461
|
return namespace([]);
|
|
2369
2462
|
}
|
|
2370
2463
|
|
|
2371
|
-
|
|
2464
|
+
function assertTransportResponse(id, response) {
|
|
2465
|
+
if (!response || typeof response !== "object") {
|
|
2466
|
+
throw new Error(`Server function "${id}" transport returned an invalid response: expected a fetch Response-like object.`);
|
|
2467
|
+
}
|
|
2468
|
+
if (typeof response.ok !== "boolean") {
|
|
2469
|
+
throw new Error(`Server function "${id}" transport returned an invalid response: missing boolean ok.`);
|
|
2470
|
+
}
|
|
2471
|
+
if (!response.headers || typeof response.headers.get !== "function") {
|
|
2472
|
+
throw new Error(`Server function "${id}" transport returned an invalid response: missing headers.get(name).`);
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
|
|
2476
|
+
async function readServerResponse(id, response) {
|
|
2477
|
+
if (response.status === 204) {
|
|
2478
|
+
return { value: undefined };
|
|
2479
|
+
}
|
|
2372
2480
|
const type = response.headers.get("content-type") ?? "";
|
|
2373
2481
|
if (type.includes("application/json")) {
|
|
2374
|
-
|
|
2482
|
+
if (typeof response.json !== "function") {
|
|
2483
|
+
throw new Error(`Server function "${id}" transport returned an invalid response: missing json().`);
|
|
2484
|
+
}
|
|
2485
|
+
try {
|
|
2486
|
+
return await response.json();
|
|
2487
|
+
} catch (cause) {
|
|
2488
|
+
throw new Error(`Server function "${id}" returned invalid JSON: ${errorMessage(cause)}`, {
|
|
2489
|
+
cause
|
|
2490
|
+
});
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
if (typeof response.text !== "function") {
|
|
2494
|
+
throw new Error(`Server function "${id}" transport returned an invalid response: missing text().`);
|
|
2375
2495
|
}
|
|
2376
2496
|
return { value: await response.text() };
|
|
2377
2497
|
}
|
|
@@ -2484,6 +2604,9 @@ const __serverModule = (() => {
|
|
|
2484
2604
|
if (tag === "[object File]" || tag === "[object Blob]" || tag === "[object FormData]") {
|
|
2485
2605
|
throw new Error("Server proxy JSON transport does not support File, Blob, or FormData values yet.");
|
|
2486
2606
|
}
|
|
2607
|
+
if (isUnsupportedJsonTransportObject(value, tag)) {
|
|
2608
|
+
throw new Error("Server proxy JSON transport does not support URLSearchParams, Headers, Request, Response, ReadableStream, ArrayBuffer, or typed array values yet.");
|
|
2609
|
+
}
|
|
2487
2610
|
if (Array.isArray(value)) {
|
|
2488
2611
|
for (const item of value) {
|
|
2489
2612
|
assertJsonTransportable(item, stack);
|
|
@@ -2497,6 +2620,16 @@ const __serverModule = (() => {
|
|
|
2497
2620
|
stack.delete(value);
|
|
2498
2621
|
}
|
|
2499
2622
|
|
|
2623
|
+
function isUnsupportedJsonTransportObject(value, tag = Object.prototype.toString.call(value)) {
|
|
2624
|
+
return tag === "[object URLSearchParams]"
|
|
2625
|
+
|| tag === "[object Headers]"
|
|
2626
|
+
|| tag === "[object Request]"
|
|
2627
|
+
|| tag === "[object Response]"
|
|
2628
|
+
|| tag === "[object ReadableStream]"
|
|
2629
|
+
|| tag === "[object ArrayBuffer]"
|
|
2630
|
+
|| ArrayBuffer.isView(value);
|
|
2631
|
+
}
|
|
2632
|
+
|
|
2500
2633
|
function joinEndpoint(endpoint, id) {
|
|
2501
2634
|
return `${String(endpoint).replace(/\/$/, "")}/${encodeURIComponent(id)}`;
|
|
2502
2635
|
}
|
|
@@ -2518,6 +2651,10 @@ const __serverModule = (() => {
|
|
|
2518
2651
|
return new Error(String(value));
|
|
2519
2652
|
}
|
|
2520
2653
|
|
|
2654
|
+
function errorMessage(error) {
|
|
2655
|
+
return error instanceof Error ? error.message : String(error);
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2521
2658
|
function assertServerId(id) {
|
|
2522
2659
|
if (typeof id !== "string" || id.length === 0) {
|
|
2523
2660
|
throw new TypeError("Server function id must be a non-empty string.");
|
|
@@ -2643,7 +2780,12 @@ const __handlersModule = (() => {
|
|
|
2643
2780
|
return results;
|
|
2644
2781
|
},
|
|
2645
2782
|
|
|
2646
|
-
_adoptMany() {
|
|
2783
|
+
_adoptMany(map = {}) {
|
|
2784
|
+
for (const [id, fn] of Object.entries(map ?? {})) {
|
|
2785
|
+
if (!handlers.has(id)) {
|
|
2786
|
+
registry.register(id, fn);
|
|
2787
|
+
}
|
|
2788
|
+
}
|
|
2647
2789
|
return registry;
|
|
2648
2790
|
}
|
|
2649
2791
|
}, registryStore, type);
|
|
@@ -2750,7 +2892,8 @@ const __schedulerModule = (() => {
|
|
|
2750
2892
|
const phases = [...(options.phases ?? defaultPhases)];
|
|
2751
2893
|
const queues = new Map(phases.map((phase) => [phase, []]));
|
|
2752
2894
|
const keyedJobs = new Map();
|
|
2753
|
-
const
|
|
2895
|
+
const destroyedObjectScopes = new WeakSet();
|
|
2896
|
+
const destroyedPrimitiveScopes = new Set();
|
|
2754
2897
|
const objectScopeIds = new WeakMap();
|
|
2755
2898
|
const onError = typeof options.onError === "function" ? options.onError : undefined;
|
|
2756
2899
|
const maxDepth = options.maxDepth ?? 100;
|
|
@@ -2798,7 +2941,7 @@ const __schedulerModule = (() => {
|
|
|
2798
2941
|
throw new TypeError("scheduler.enqueue(phase, fn) requires a function.");
|
|
2799
2942
|
}
|
|
2800
2943
|
const scope = options.scope;
|
|
2801
|
-
if (
|
|
2944
|
+
if (isScopeDestroyed(scope)) {
|
|
2802
2945
|
return noop;
|
|
2803
2946
|
}
|
|
2804
2947
|
|
|
@@ -2902,14 +3045,29 @@ const __schedulerModule = (() => {
|
|
|
2902
3045
|
|
|
2903
3046
|
markScopeDestroyed(scope) {
|
|
2904
3047
|
if (scope !== undefined) {
|
|
2905
|
-
|
|
3048
|
+
if (isObjectScope(scope)) {
|
|
3049
|
+
destroyedObjectScopes.add(scope);
|
|
3050
|
+
} else {
|
|
3051
|
+
destroyedPrimitiveScopes.add(scope);
|
|
3052
|
+
}
|
|
2906
3053
|
api.cancelScope(scope);
|
|
2907
3054
|
}
|
|
2908
3055
|
return api;
|
|
2909
3056
|
},
|
|
2910
3057
|
|
|
3058
|
+
reviveScope(scope) {
|
|
3059
|
+
if (scope !== undefined) {
|
|
3060
|
+
if (isObjectScope(scope)) {
|
|
3061
|
+
destroyedObjectScopes.delete(scope);
|
|
3062
|
+
} else {
|
|
3063
|
+
destroyedPrimitiveScopes.delete(scope);
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
return api;
|
|
3067
|
+
},
|
|
3068
|
+
|
|
2911
3069
|
isScopeDestroyed(scope) {
|
|
2912
|
-
return
|
|
3070
|
+
return isScopeDestroyed(scope);
|
|
2913
3071
|
},
|
|
2914
3072
|
|
|
2915
3073
|
inspect() {
|
|
@@ -2921,7 +3079,7 @@ const __schedulerModule = (() => {
|
|
|
2921
3079
|
strategy,
|
|
2922
3080
|
phases: [...phases],
|
|
2923
3081
|
pending: counts,
|
|
2924
|
-
scopesDestroyed:
|
|
3082
|
+
scopesDestroyed: destroyedPrimitiveScopes.size,
|
|
2925
3083
|
flushing,
|
|
2926
3084
|
scheduled
|
|
2927
3085
|
};
|
|
@@ -2936,7 +3094,7 @@ const __schedulerModule = (() => {
|
|
|
2936
3094
|
queue.length = 0;
|
|
2937
3095
|
}
|
|
2938
3096
|
keyedJobs.clear();
|
|
2939
|
-
|
|
3097
|
+
destroyedPrimitiveScopes.clear();
|
|
2940
3098
|
}
|
|
2941
3099
|
};
|
|
2942
3100
|
|
|
@@ -2976,7 +3134,7 @@ const __schedulerModule = (() => {
|
|
|
2976
3134
|
if (job.key) {
|
|
2977
3135
|
keyedJobs.delete(job.key);
|
|
2978
3136
|
}
|
|
2979
|
-
if (job.canceled || (job.scope
|
|
3137
|
+
if (job.canceled || isScopeDestroyed(job.scope)) {
|
|
2980
3138
|
continue;
|
|
2981
3139
|
}
|
|
2982
3140
|
try {
|
|
@@ -3033,6 +3191,20 @@ const __schedulerModule = (() => {
|
|
|
3033
3191
|
}
|
|
3034
3192
|
return String(scope);
|
|
3035
3193
|
}
|
|
3194
|
+
|
|
3195
|
+
function isScopeDestroyed(scope) {
|
|
3196
|
+
if (scope === undefined) {
|
|
3197
|
+
return false;
|
|
3198
|
+
}
|
|
3199
|
+
if (isObjectScope(scope)) {
|
|
3200
|
+
return destroyedObjectScopes.has(scope);
|
|
3201
|
+
}
|
|
3202
|
+
return destroyedPrimitiveScopes.has(scope);
|
|
3203
|
+
}
|
|
3204
|
+
}
|
|
3205
|
+
|
|
3206
|
+
function isObjectScope(scope) {
|
|
3207
|
+
return (typeof scope === "object" && scope !== null) || typeof scope === "function";
|
|
3036
3208
|
}
|
|
3037
3209
|
|
|
3038
3210
|
function scheduleMicrotask(fn) {
|
|
@@ -3093,6 +3265,7 @@ const __loaderModule = (() => {
|
|
|
3093
3265
|
|
|
3094
3266
|
scan(rootOrFragment = rootNode) {
|
|
3095
3267
|
assertActive();
|
|
3268
|
+
reviveScopes(rootOrFragment);
|
|
3096
3269
|
bindSignalAttributes(rootOrFragment);
|
|
3097
3270
|
bindClassAttributes(rootOrFragment);
|
|
3098
3271
|
bindEventAttributes(rootOrFragment);
|
|
@@ -3596,6 +3769,12 @@ const __loaderModule = (() => {
|
|
|
3596
3769
|
}
|
|
3597
3770
|
}
|
|
3598
3771
|
|
|
3772
|
+
function reviveScopes(scope) {
|
|
3773
|
+
for (const element of elementsIn(scope)) {
|
|
3774
|
+
schedulerInstance.reviveScope?.(element);
|
|
3775
|
+
}
|
|
3776
|
+
}
|
|
3777
|
+
|
|
3599
3778
|
return api;
|
|
3600
3779
|
}
|
|
3601
3780
|
|
|
@@ -3895,7 +4074,12 @@ const __partialsModule = (() => {
|
|
|
3895
4074
|
return normalizePartialResult(result, partialContext);
|
|
3896
4075
|
},
|
|
3897
4076
|
|
|
3898
|
-
_adoptMany() {
|
|
4077
|
+
_adoptMany(map = {}) {
|
|
4078
|
+
for (const [id, fn] of Object.entries(map ?? {})) {
|
|
4079
|
+
if (!entries.has(id)) {
|
|
4080
|
+
registry.register(id, fn);
|
|
4081
|
+
}
|
|
4082
|
+
}
|
|
3899
4083
|
return registry;
|
|
3900
4084
|
}
|
|
3901
4085
|
}, registryStore, type);
|
|
@@ -4047,7 +4231,11 @@ const __routerModule = (() => {
|
|
|
4047
4231
|
},
|
|
4048
4232
|
|
|
4049
4233
|
_adoptMany(map = {}) {
|
|
4050
|
-
for (const pattern of Object.
|
|
4234
|
+
for (const [pattern, definition] of Object.entries(map ?? {})) {
|
|
4235
|
+
if (!entries.has(pattern)) {
|
|
4236
|
+
registry.register(pattern, definition);
|
|
4237
|
+
continue;
|
|
4238
|
+
}
|
|
4051
4239
|
adoptRoute(pattern, entries.get(pattern));
|
|
4052
4240
|
}
|
|
4053
4241
|
return registry;
|
|
@@ -4159,7 +4347,10 @@ const __routerModule = (() => {
|
|
|
4159
4347
|
}
|
|
4160
4348
|
const matched = api.match(url);
|
|
4161
4349
|
if (matched?.route?.partial && partials?.resolve?.(matched.route.partial)) {
|
|
4162
|
-
return partials.render(matched.route.partial, matched.params,
|
|
4350
|
+
return partials.render(matched.route.partial, matched.params, {
|
|
4351
|
+
...contextFor(matched),
|
|
4352
|
+
prefetch: true
|
|
4353
|
+
});
|
|
4163
4354
|
}
|
|
4164
4355
|
return Promise.resolve(null);
|
|
4165
4356
|
},
|
|
@@ -4540,7 +4731,7 @@ const __appModule = (() => {
|
|
|
4540
4731
|
const { createRouteRegistry, createRouter } = __routerModule;
|
|
4541
4732
|
const { createScheduler } = __schedulerModule;
|
|
4542
4733
|
const { createServerNamespace } = __serverModule;
|
|
4543
|
-
const { createSignal, createSignalRegistry } = __signalsModule;
|
|
4734
|
+
const { cloneSignalDeclaration, createSignal, createSignalRegistry } = __signalsModule;
|
|
4544
4735
|
const { createRegistryStore } = __registryStoreModule;
|
|
4545
4736
|
const { attributeName, normalizeAttributeConfig } = __attributesModule;
|
|
4546
4737
|
const { createLazyRegistry, defineRegistrySnapshot, sameRegistryValue } = __lazyRegistryModule;
|
|
@@ -4623,7 +4814,7 @@ const __appModule = (() => {
|
|
|
4623
4814
|
registryAssets: options.registryAssets,
|
|
4624
4815
|
importModule: options.importModule
|
|
4625
4816
|
});
|
|
4626
|
-
const registry = options.registry ?? app.registry
|
|
4817
|
+
const registry = options.registry ?? createRuntimeRegistry(app.registry, { target });
|
|
4627
4818
|
const signals = options.signals ?? createSignalRegistry(undefined, { registry, type: "signal", lazyRegistry });
|
|
4628
4819
|
const handlers = options.handlers ?? createHandlerRegistry(undefined, { registry, type: "handler", lazyRegistry });
|
|
4629
4820
|
const serverCache = createCacheRegistry(undefined, { registry, type: "cache.server" });
|
|
@@ -5004,6 +5195,22 @@ const __appModule = (() => {
|
|
|
5004
5195
|
registry?.registerMany?.(entries);
|
|
5005
5196
|
}
|
|
5006
5197
|
|
|
5198
|
+
function createRuntimeRegistry(appRegistry, { target } = {}) {
|
|
5199
|
+
const declarations = appRegistry.rawSnapshot();
|
|
5200
|
+
return createRegistryStore({
|
|
5201
|
+
...declarations,
|
|
5202
|
+
signal: cloneSignalDeclarations(declarations.signal)
|
|
5203
|
+
}, { target });
|
|
5204
|
+
}
|
|
5205
|
+
|
|
5206
|
+
function cloneSignalDeclarations(signals = {}) {
|
|
5207
|
+
const cloned = {};
|
|
5208
|
+
for (const [id, signalLike] of Object.entries(signals ?? {})) {
|
|
5209
|
+
cloned[id] = cloneSignalDeclaration(signalLike);
|
|
5210
|
+
}
|
|
5211
|
+
return cloned;
|
|
5212
|
+
}
|
|
5213
|
+
|
|
5007
5214
|
function emptyDeclarations() {
|
|
5008
5215
|
return {
|
|
5009
5216
|
signal: {},
|
|
@@ -5195,6 +5402,13 @@ const __appModule = (() => {
|
|
|
5195
5402
|
function setOrRegisterSignal(signals, path, value) {
|
|
5196
5403
|
const id = String(path).split(".")[0];
|
|
5197
5404
|
if (signals.has?.(id)) {
|
|
5405
|
+
if (path === id) {
|
|
5406
|
+
const entry = signals._entry?.(id);
|
|
5407
|
+
if (typeof entry?._restore === "function" && isAsyncSignalSnapshot(value)) {
|
|
5408
|
+
entry._restore(value);
|
|
5409
|
+
return;
|
|
5410
|
+
}
|
|
5411
|
+
}
|
|
5198
5412
|
signals.set(path, value);
|
|
5199
5413
|
return;
|
|
5200
5414
|
}
|
|
@@ -5204,6 +5418,17 @@ const __appModule = (() => {
|
|
|
5204
5418
|
}
|
|
5205
5419
|
}
|
|
5206
5420
|
|
|
5421
|
+
function isAsyncSignalSnapshot(value) {
|
|
5422
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
5423
|
+
return false;
|
|
5424
|
+
}
|
|
5425
|
+
return Object.hasOwn(value, "value")
|
|
5426
|
+
&& (Object.hasOwn(value, "loading")
|
|
5427
|
+
|| Object.hasOwn(value, "error")
|
|
5428
|
+
|| Object.hasOwn(value, "status")
|
|
5429
|
+
|| Object.hasOwn(value, "version"));
|
|
5430
|
+
}
|
|
5431
|
+
|
|
5207
5432
|
function attachServerCache(server, cache) {
|
|
5208
5433
|
try {
|
|
5209
5434
|
server.cache = cache;
|
|
@@ -5454,7 +5679,12 @@ const __serverRegistryModule = (() => {
|
|
|
5454
5679
|
return registry;
|
|
5455
5680
|
},
|
|
5456
5681
|
|
|
5457
|
-
_adoptMany() {
|
|
5682
|
+
_adoptMany(map = {}) {
|
|
5683
|
+
for (const [id, fn] of Object.entries(map ?? {})) {
|
|
5684
|
+
if (!entries.has(id)) {
|
|
5685
|
+
registry.register(id, fn);
|
|
5686
|
+
}
|
|
5687
|
+
}
|
|
5458
5688
|
return registry;
|
|
5459
5689
|
}
|
|
5460
5690
|
}, registryStore, type);
|