@async/framework 0.11.6 → 0.11.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +1 -0
- package/browser.js +20 -25
- package/browser.min.js +1 -1
- package/browser.ts +20 -25
- package/browser.umd.js +20 -25
- package/browser.umd.min.js +1 -1
- package/framework.ts +22 -27
- package/package.json +1 -1
- package/server.js +22 -27
package/browser.ts
CHANGED
|
@@ -2379,9 +2379,10 @@ const __componentModule = (() => {
|
|
|
2379
2379
|
})();
|
|
2380
2380
|
|
|
2381
2381
|
const __serverModule = (() => {
|
|
2382
|
-
const
|
|
2382
|
+
const serverEnvelopeKind = Symbol.for("@async/framework.serverResult");
|
|
2383
|
+
const serverEnvelopeWireKey = "__async_server_result__";
|
|
2384
|
+
const serverEnvelopeWireVersion = 1;
|
|
2383
2385
|
const appliedServerResult = Symbol.for("@async/framework.appliedServerResult");
|
|
2384
|
-
const appliedServerValues = new WeakSet();
|
|
2385
2386
|
|
|
2386
2387
|
function createServerProxy({
|
|
2387
2388
|
endpoint = "/__async/server",
|
|
@@ -2424,9 +2425,7 @@ const __serverModule = (() => {
|
|
|
2424
2425
|
throw new Error(`Server function "${id}" failed with ${response.status}.`);
|
|
2425
2426
|
}
|
|
2426
2427
|
|
|
2427
|
-
|
|
2428
|
-
await applyServerResult(result, runContext);
|
|
2429
|
-
return markAppliedServerValue(unwrapServerResult(result));
|
|
2428
|
+
return consumeServerResult(await readServerResponse(id, response), runContext);
|
|
2430
2429
|
}
|
|
2431
2430
|
|
|
2432
2431
|
return createServerNamespace(run, {
|
|
@@ -2461,7 +2460,7 @@ const __serverModule = (() => {
|
|
|
2461
2460
|
if (!isServerEnvelope(result)) {
|
|
2462
2461
|
return result;
|
|
2463
2462
|
}
|
|
2464
|
-
if (result[appliedServerResult]
|
|
2463
|
+
if (result[appliedServerResult]) {
|
|
2465
2464
|
return result;
|
|
2466
2465
|
}
|
|
2467
2466
|
|
|
@@ -2493,18 +2492,16 @@ const __serverModule = (() => {
|
|
|
2493
2492
|
return result;
|
|
2494
2493
|
}
|
|
2495
2494
|
|
|
2496
|
-
function
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
}
|
|
2500
|
-
return result;
|
|
2495
|
+
async function consumeServerResult(result, context = {}) {
|
|
2496
|
+
await applyServerResult(result, context);
|
|
2497
|
+
return unwrapServerResult(result);
|
|
2501
2498
|
}
|
|
2502
2499
|
|
|
2503
|
-
function
|
|
2504
|
-
if (
|
|
2505
|
-
|
|
2500
|
+
function unwrapServerResult(result) {
|
|
2501
|
+
if (isServerEnvelope(result)) {
|
|
2502
|
+
return Object.hasOwn(result, "value") ? result.value : undefined;
|
|
2506
2503
|
}
|
|
2507
|
-
return
|
|
2504
|
+
return result;
|
|
2508
2505
|
}
|
|
2509
2506
|
|
|
2510
2507
|
function markAppliedServerResult(result) {
|
|
@@ -2548,9 +2545,7 @@ const __serverModule = (() => {
|
|
|
2548
2545
|
throw new Error("Server namespace is not directly callable.");
|
|
2549
2546
|
}
|
|
2550
2547
|
const context = contextProvider() ?? {};
|
|
2551
|
-
|
|
2552
|
-
await applyServerResult(result, context);
|
|
2553
|
-
return unwrapServerResult(result);
|
|
2548
|
+
return run(parts.join("."), args, context);
|
|
2554
2549
|
};
|
|
2555
2550
|
|
|
2556
2551
|
const proxy = new Proxy(callable, {
|
|
@@ -2607,7 +2602,7 @@ const __serverModule = (() => {
|
|
|
2607
2602
|
|
|
2608
2603
|
async function readServerResponse(id, response) {
|
|
2609
2604
|
if (response.status === 204) {
|
|
2610
|
-
return
|
|
2605
|
+
return undefined;
|
|
2611
2606
|
}
|
|
2612
2607
|
const type = response.headers.get("content-type") ?? "";
|
|
2613
2608
|
if (type.includes("application/json")) {
|
|
@@ -2625,7 +2620,7 @@ const __serverModule = (() => {
|
|
|
2625
2620
|
if (typeof response.text !== "function") {
|
|
2626
2621
|
throw new Error(`Server function "${id}" transport returned an invalid response: missing text().`);
|
|
2627
2622
|
}
|
|
2628
|
-
return
|
|
2623
|
+
return response.text();
|
|
2629
2624
|
}
|
|
2630
2625
|
|
|
2631
2626
|
function snapshotSignalPaths(paths = [], signals) {
|
|
@@ -2770,7 +2765,8 @@ const __serverModule = (() => {
|
|
|
2770
2765
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
2771
2766
|
return false;
|
|
2772
2767
|
}
|
|
2773
|
-
return
|
|
2768
|
+
return value[serverEnvelopeKind] === true
|
|
2769
|
+
|| value[serverEnvelopeWireKey] === serverEnvelopeWireVersion;
|
|
2774
2770
|
}
|
|
2775
2771
|
|
|
2776
2772
|
function toError(value) {
|
|
@@ -2792,11 +2788,11 @@ const __serverModule = (() => {
|
|
|
2792
2788
|
throw new TypeError("Server function id must be a non-empty string.");
|
|
2793
2789
|
}
|
|
2794
2790
|
}
|
|
2795
|
-
return { createServerProxy, resolveServerCommandArguments, applyServerResult, unwrapServerResult, defaultInput, createServerNamespace, createSignalReader, assertServerId };
|
|
2791
|
+
return { createServerProxy, resolveServerCommandArguments, applyServerResult, consumeServerResult, unwrapServerResult, defaultInput, createServerNamespace, createSignalReader, assertServerId };
|
|
2796
2792
|
})();
|
|
2797
2793
|
|
|
2798
2794
|
const __handlersModule = (() => {
|
|
2799
|
-
const {
|
|
2795
|
+
const { defaultInput, resolveServerCommandArguments } = __serverModule;
|
|
2800
2796
|
const { attachRegistryInspection, createRegistryStore } = __registryStoreModule;
|
|
2801
2797
|
const { createLazyRegistry, isLazyDescriptor } = __lazyRegistryModule;
|
|
2802
2798
|
const builtInTokens = new Set(["prevent", "preventDefault", "stopPropagation", "stopImmediatePropagation"]);
|
|
@@ -2894,8 +2890,7 @@ const __handlersModule = (() => {
|
|
|
2894
2890
|
signalPaths: resolved.signalPaths,
|
|
2895
2891
|
signalValues: resolved.signalValues
|
|
2896
2892
|
});
|
|
2897
|
-
|
|
2898
|
-
results.push(unwrapServerResult(result));
|
|
2893
|
+
results.push(result);
|
|
2899
2894
|
continue;
|
|
2900
2895
|
}
|
|
2901
2896
|
|
package/browser.umd.js
CHANGED
|
@@ -2389,9 +2389,10 @@
|
|
|
2389
2389
|
})();
|
|
2390
2390
|
|
|
2391
2391
|
const __serverModule = (() => {
|
|
2392
|
-
const
|
|
2392
|
+
const serverEnvelopeKind = Symbol.for("@async/framework.serverResult");
|
|
2393
|
+
const serverEnvelopeWireKey = "__async_server_result__";
|
|
2394
|
+
const serverEnvelopeWireVersion = 1;
|
|
2393
2395
|
const appliedServerResult = Symbol.for("@async/framework.appliedServerResult");
|
|
2394
|
-
const appliedServerValues = new WeakSet();
|
|
2395
2396
|
|
|
2396
2397
|
function createServerProxy({
|
|
2397
2398
|
endpoint = "/__async/server",
|
|
@@ -2434,9 +2435,7 @@
|
|
|
2434
2435
|
throw new Error(`Server function "${id}" failed with ${response.status}.`);
|
|
2435
2436
|
}
|
|
2436
2437
|
|
|
2437
|
-
|
|
2438
|
-
await applyServerResult(result, runContext);
|
|
2439
|
-
return markAppliedServerValue(unwrapServerResult(result));
|
|
2438
|
+
return consumeServerResult(await readServerResponse(id, response), runContext);
|
|
2440
2439
|
}
|
|
2441
2440
|
|
|
2442
2441
|
return createServerNamespace(run, {
|
|
@@ -2471,7 +2470,7 @@
|
|
|
2471
2470
|
if (!isServerEnvelope(result)) {
|
|
2472
2471
|
return result;
|
|
2473
2472
|
}
|
|
2474
|
-
if (result[appliedServerResult]
|
|
2473
|
+
if (result[appliedServerResult]) {
|
|
2475
2474
|
return result;
|
|
2476
2475
|
}
|
|
2477
2476
|
|
|
@@ -2503,18 +2502,16 @@
|
|
|
2503
2502
|
return result;
|
|
2504
2503
|
}
|
|
2505
2504
|
|
|
2506
|
-
function
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
}
|
|
2510
|
-
return result;
|
|
2505
|
+
async function consumeServerResult(result, context = {}) {
|
|
2506
|
+
await applyServerResult(result, context);
|
|
2507
|
+
return unwrapServerResult(result);
|
|
2511
2508
|
}
|
|
2512
2509
|
|
|
2513
|
-
function
|
|
2514
|
-
if (
|
|
2515
|
-
|
|
2510
|
+
function unwrapServerResult(result) {
|
|
2511
|
+
if (isServerEnvelope(result)) {
|
|
2512
|
+
return Object.hasOwn(result, "value") ? result.value : undefined;
|
|
2516
2513
|
}
|
|
2517
|
-
return
|
|
2514
|
+
return result;
|
|
2518
2515
|
}
|
|
2519
2516
|
|
|
2520
2517
|
function markAppliedServerResult(result) {
|
|
@@ -2558,9 +2555,7 @@
|
|
|
2558
2555
|
throw new Error("Server namespace is not directly callable.");
|
|
2559
2556
|
}
|
|
2560
2557
|
const context = contextProvider() ?? {};
|
|
2561
|
-
|
|
2562
|
-
await applyServerResult(result, context);
|
|
2563
|
-
return unwrapServerResult(result);
|
|
2558
|
+
return run(parts.join("."), args, context);
|
|
2564
2559
|
};
|
|
2565
2560
|
|
|
2566
2561
|
const proxy = new Proxy(callable, {
|
|
@@ -2617,7 +2612,7 @@
|
|
|
2617
2612
|
|
|
2618
2613
|
async function readServerResponse(id, response) {
|
|
2619
2614
|
if (response.status === 204) {
|
|
2620
|
-
return
|
|
2615
|
+
return undefined;
|
|
2621
2616
|
}
|
|
2622
2617
|
const type = response.headers.get("content-type") ?? "";
|
|
2623
2618
|
if (type.includes("application/json")) {
|
|
@@ -2635,7 +2630,7 @@
|
|
|
2635
2630
|
if (typeof response.text !== "function") {
|
|
2636
2631
|
throw new Error(`Server function "${id}" transport returned an invalid response: missing text().`);
|
|
2637
2632
|
}
|
|
2638
|
-
return
|
|
2633
|
+
return response.text();
|
|
2639
2634
|
}
|
|
2640
2635
|
|
|
2641
2636
|
function snapshotSignalPaths(paths = [], signals) {
|
|
@@ -2780,7 +2775,8 @@
|
|
|
2780
2775
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
2781
2776
|
return false;
|
|
2782
2777
|
}
|
|
2783
|
-
return
|
|
2778
|
+
return value[serverEnvelopeKind] === true
|
|
2779
|
+
|| value[serverEnvelopeWireKey] === serverEnvelopeWireVersion;
|
|
2784
2780
|
}
|
|
2785
2781
|
|
|
2786
2782
|
function toError(value) {
|
|
@@ -2802,11 +2798,11 @@
|
|
|
2802
2798
|
throw new TypeError("Server function id must be a non-empty string.");
|
|
2803
2799
|
}
|
|
2804
2800
|
}
|
|
2805
|
-
return { createServerProxy, resolveServerCommandArguments, applyServerResult, unwrapServerResult, defaultInput, createServerNamespace, createSignalReader, assertServerId };
|
|
2801
|
+
return { createServerProxy, resolveServerCommandArguments, applyServerResult, consumeServerResult, unwrapServerResult, defaultInput, createServerNamespace, createSignalReader, assertServerId };
|
|
2806
2802
|
})();
|
|
2807
2803
|
|
|
2808
2804
|
const __handlersModule = (() => {
|
|
2809
|
-
const {
|
|
2805
|
+
const { defaultInput, resolveServerCommandArguments } = __serverModule;
|
|
2810
2806
|
const { attachRegistryInspection, createRegistryStore } = __registryStoreModule;
|
|
2811
2807
|
const { createLazyRegistry, isLazyDescriptor } = __lazyRegistryModule;
|
|
2812
2808
|
const builtInTokens = new Set(["prevent", "preventDefault", "stopPropagation", "stopImmediatePropagation"]);
|
|
@@ -2904,8 +2900,7 @@
|
|
|
2904
2900
|
signalPaths: resolved.signalPaths,
|
|
2905
2901
|
signalValues: resolved.signalValues
|
|
2906
2902
|
});
|
|
2907
|
-
|
|
2908
|
-
results.push(unwrapServerResult(result));
|
|
2903
|
+
results.push(result);
|
|
2909
2904
|
continue;
|
|
2910
2905
|
}
|
|
2911
2906
|
|