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