react-server-dom-webpack 19.2.0-canary-ab859e31-20250606 → 19.2.0-canary-b6c0aa88-20250609

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.
Files changed (26) hide show
  1. package/cjs/react-server-dom-webpack-client.browser.development.js +38 -64
  2. package/cjs/react-server-dom-webpack-client.edge.development.js +36 -62
  3. package/cjs/react-server-dom-webpack-client.node.development.js +202 -149
  4. package/cjs/react-server-dom-webpack-client.node.production.js +162 -86
  5. package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +202 -149
  6. package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +162 -86
  7. package/cjs/react-server-dom-webpack-server.browser.development.js +132 -92
  8. package/cjs/react-server-dom-webpack-server.edge.development.js +132 -92
  9. package/cjs/react-server-dom-webpack-server.node.development.js +298 -118
  10. package/cjs/react-server-dom-webpack-server.node.production.js +166 -25
  11. package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +298 -118
  12. package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +166 -25
  13. package/client.node.js +2 -23
  14. package/client.node.unbundled.js +2 -23
  15. package/package.json +3 -3
  16. package/server.node.js +6 -9
  17. package/server.node.unbundled.js +4 -7
  18. package/static.node.js +3 -0
  19. package/cjs/react-server-dom-webpack-client.node-webstreams.development.js +0 -3052
  20. package/cjs/react-server-dom-webpack-client.node-webstreams.production.js +0 -1846
  21. package/cjs/react-server-dom-webpack-client.node-webstreams.unbundled.development.js +0 -3014
  22. package/cjs/react-server-dom-webpack-client.node-webstreams.unbundled.production.js +0 -1811
  23. package/cjs/react-server-dom-webpack-server.node-webstreams.development.js +0 -4318
  24. package/cjs/react-server-dom-webpack-server.node-webstreams.production.js +0 -2842
  25. package/cjs/react-server-dom-webpack-server.node-webstreams.unbundled.development.js +0 -4281
  26. package/cjs/react-server-dom-webpack-server.node-webstreams.unbundled.production.js +0 -2808
@@ -2283,66 +2283,46 @@
2283
2283
  : rootTask
2284
2284
  : null;
2285
2285
  }
2286
- function initializeFakeTask(response, debugInfo, childEnvironmentName) {
2286
+ function initializeFakeTask(response, debugInfo) {
2287
2287
  if (!supportsCreateTask || null == debugInfo.stack) return null;
2288
+ var cachedEntry = debugInfo.debugTask;
2289
+ if (void 0 !== cachedEntry) return cachedEntry;
2288
2290
  var useEnclosingLine = void 0 === debugInfo.key,
2289
2291
  stack = debugInfo.stack,
2290
2292
  env =
2291
2293
  null == debugInfo.env ? response._rootEnvironmentName : debugInfo.env;
2292
- if (env !== childEnvironmentName)
2293
- return (
2294
- (debugInfo =
2295
- null == debugInfo.owner
2296
- ? null
2297
- : initializeFakeTask(response, debugInfo.owner, env)),
2298
- buildFakeTask(
2299
- response,
2300
- debugInfo,
2301
- stack,
2302
- '"use ' + childEnvironmentName.toLowerCase() + '"',
2303
- env,
2304
- useEnclosingLine
2305
- )
2306
- );
2307
- childEnvironmentName = debugInfo.debugTask;
2308
- if (void 0 !== childEnvironmentName) return childEnvironmentName;
2309
- childEnvironmentName =
2294
+ cachedEntry =
2295
+ null == debugInfo.owner || null == debugInfo.owner.env
2296
+ ? response._rootEnvironmentName
2297
+ : debugInfo.owner.env;
2298
+ var ownerTask =
2310
2299
  null == debugInfo.owner
2311
2300
  ? null
2312
- : initializeFakeTask(response, debugInfo.owner, env);
2313
- return (debugInfo.debugTask = buildFakeTask(
2314
- response,
2315
- childEnvironmentName,
2316
- stack,
2317
- void 0 !== debugInfo.key
2318
- ? "<" + (debugInfo.name || "...") + ">"
2319
- : void 0 !== debugInfo.name
2320
- ? debugInfo.name || "unknown"
2321
- : "await " + (debugInfo.awaited.name || "unknown"),
2322
- env,
2323
- useEnclosingLine
2324
- ));
2325
- }
2326
- function buildFakeTask(
2327
- response,
2328
- ownerTask,
2329
- stack,
2330
- taskName,
2331
- env,
2332
- useEnclosingLine
2333
- ) {
2334
- taskName = console.createTask.bind(console, taskName);
2335
- stack = buildFakeCallStack(
2301
+ : initializeFakeTask(response, debugInfo.owner);
2302
+ env =
2303
+ env !== cachedEntry
2304
+ ? '"use ' + env.toLowerCase() + '"'
2305
+ : void 0 !== debugInfo.key
2306
+ ? "<" + (debugInfo.name || "...") + ">"
2307
+ : void 0 !== debugInfo.name
2308
+ ? debugInfo.name || "unknown"
2309
+ : "await " + (debugInfo.awaited.name || "unknown");
2310
+ env = console.createTask.bind(console, env);
2311
+ useEnclosingLine = buildFakeCallStack(
2336
2312
  response,
2337
2313
  stack,
2338
- env,
2314
+ cachedEntry,
2339
2315
  useEnclosingLine,
2340
- taskName
2316
+ env
2341
2317
  );
2342
- return null === ownerTask
2343
- ? ((response = getRootTask(response, env)),
2344
- null != response ? response.run(stack) : stack())
2345
- : ownerTask.run(stack);
2318
+ null === ownerTask
2319
+ ? ((response = getRootTask(response, cachedEntry)),
2320
+ (response =
2321
+ null != response
2322
+ ? response.run(useEnclosingLine)
2323
+ : useEnclosingLine()))
2324
+ : (response = ownerTask.run(useEnclosingLine));
2325
+ return (debugInfo.debugTask = response);
2346
2326
  }
2347
2327
  function fakeJSXCallSite() {
2348
2328
  return Error("react-stack-top-frame");
@@ -2359,15 +2339,12 @@
2359
2339
  initializeFakeStack(response, debugInfo.owner));
2360
2340
  }
2361
2341
  function resolveDebugInfo(response, id, debugInfo) {
2362
- var env =
2363
- void 0 === debugInfo.env
2364
- ? response._rootEnvironmentName
2365
- : debugInfo.env;
2366
- void 0 !== debugInfo.stack &&
2367
- initializeFakeTask(response, debugInfo, env);
2368
- null === debugInfo.owner && null != response._debugRootOwner
2342
+ void 0 !== debugInfo.stack && initializeFakeTask(response, debugInfo);
2343
+ null == debugInfo.owner && null != response._debugRootOwner
2369
2344
  ? ((debugInfo.owner = response._debugRootOwner),
2370
- (debugInfo.debugStack = response._debugRootStack))
2345
+ (debugInfo.stack = null),
2346
+ (debugInfo.debugStack = response._debugRootStack),
2347
+ (debugInfo.debugTask = response._debugRootTask))
2371
2348
  : void 0 !== debugInfo.stack &&
2372
2349
  initializeFakeStack(response, debugInfo);
2373
2350
  response = getChunk(response, id);
@@ -2593,6 +2570,85 @@
2593
2570
  resolveModel(response, id, row);
2594
2571
  }
2595
2572
  }
2573
+ function processBinaryChunk(response, chunk) {
2574
+ for (
2575
+ var i = 0,
2576
+ rowState = response._rowState,
2577
+ rowID = response._rowID,
2578
+ rowTag = response._rowTag,
2579
+ rowLength = response._rowLength,
2580
+ buffer = response._buffer,
2581
+ chunkLength = chunk.length;
2582
+ i < chunkLength;
2583
+
2584
+ ) {
2585
+ var lastIdx = -1;
2586
+ switch (rowState) {
2587
+ case 0:
2588
+ lastIdx = chunk[i++];
2589
+ 58 === lastIdx
2590
+ ? (rowState = 1)
2591
+ : (rowID =
2592
+ (rowID << 4) | (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
2593
+ continue;
2594
+ case 1:
2595
+ rowState = chunk[i];
2596
+ 84 === rowState ||
2597
+ 65 === rowState ||
2598
+ 79 === rowState ||
2599
+ 111 === rowState ||
2600
+ 85 === rowState ||
2601
+ 83 === rowState ||
2602
+ 115 === rowState ||
2603
+ 76 === rowState ||
2604
+ 108 === rowState ||
2605
+ 71 === rowState ||
2606
+ 103 === rowState ||
2607
+ 77 === rowState ||
2608
+ 109 === rowState ||
2609
+ 86 === rowState
2610
+ ? ((rowTag = rowState), (rowState = 2), i++)
2611
+ : (64 < rowState && 91 > rowState) ||
2612
+ 35 === rowState ||
2613
+ 114 === rowState ||
2614
+ 120 === rowState
2615
+ ? ((rowTag = rowState), (rowState = 3), i++)
2616
+ : ((rowTag = 0), (rowState = 3));
2617
+ continue;
2618
+ case 2:
2619
+ lastIdx = chunk[i++];
2620
+ 44 === lastIdx
2621
+ ? (rowState = 4)
2622
+ : (rowLength =
2623
+ (rowLength << 4) |
2624
+ (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
2625
+ continue;
2626
+ case 3:
2627
+ lastIdx = chunk.indexOf(10, i);
2628
+ break;
2629
+ case 4:
2630
+ (lastIdx = i + rowLength), lastIdx > chunk.length && (lastIdx = -1);
2631
+ }
2632
+ var offset = chunk.byteOffset + i;
2633
+ if (-1 < lastIdx)
2634
+ (rowLength = new Uint8Array(chunk.buffer, offset, lastIdx - i)),
2635
+ processFullBinaryRow(response, rowID, rowTag, buffer, rowLength),
2636
+ (i = lastIdx),
2637
+ 3 === rowState && i++,
2638
+ (rowLength = rowID = rowTag = rowState = 0),
2639
+ (buffer.length = 0);
2640
+ else {
2641
+ chunk = new Uint8Array(chunk.buffer, offset, chunk.byteLength - i);
2642
+ buffer.push(chunk);
2643
+ rowLength -= chunk.byteLength;
2644
+ break;
2645
+ }
2646
+ }
2647
+ response._rowState = rowState;
2648
+ response._rowID = rowID;
2649
+ response._rowTag = rowTag;
2650
+ response._rowLength = rowLength;
2651
+ }
2596
2652
  function createFromJSONCallback(response) {
2597
2653
  return function (key, value) {
2598
2654
  if ("string" === typeof value)
@@ -2655,10 +2711,7 @@
2655
2711
  !1,
2656
2712
  type
2657
2713
  )),
2658
- (type =
2659
- null === key
2660
- ? null
2661
- : initializeFakeTask(response, key, validated)),
2714
+ (type = null === key ? null : initializeFakeTask(response, key)),
2662
2715
  null === type
2663
2716
  ? ((type = response._debugRootTask),
2664
2717
  (normalizedStackTrace =
@@ -2703,6 +2756,46 @@
2703
2756
  return value;
2704
2757
  };
2705
2758
  }
2759
+ function close(response) {
2760
+ reportGlobalError(response, Error("Connection closed."));
2761
+ }
2762
+ function noServerCall$1() {
2763
+ throw Error(
2764
+ "Server Functions cannot be called during initial render. This would create a fetch waterfall. Try to use a Server Component to pass data to Client Components instead."
2765
+ );
2766
+ }
2767
+ function createResponseFromOptions(options) {
2768
+ return new ResponseInstance(
2769
+ options.serverConsumerManifest.moduleMap,
2770
+ options.serverConsumerManifest.serverModuleMap,
2771
+ options.serverConsumerManifest.moduleLoading,
2772
+ noServerCall$1,
2773
+ options.encodeFormAction,
2774
+ "string" === typeof options.nonce ? options.nonce : void 0,
2775
+ options && options.temporaryReferences
2776
+ ? options.temporaryReferences
2777
+ : void 0,
2778
+ options && options.findSourceMapURL ? options.findSourceMapURL : void 0,
2779
+ options ? !0 === options.replayConsoleLogs : !1,
2780
+ options && options.environmentName ? options.environmentName : void 0
2781
+ );
2782
+ }
2783
+ function startReadingFromStream(response, stream) {
2784
+ function progress(_ref) {
2785
+ var value = _ref.value;
2786
+ if (_ref.done) close(response);
2787
+ else
2788
+ return (
2789
+ processBinaryChunk(response, value),
2790
+ reader.read().then(progress).catch(error)
2791
+ );
2792
+ }
2793
+ function error(e) {
2794
+ reportGlobalError(response, e);
2795
+ }
2796
+ var reader = stream.getReader();
2797
+ reader.read().then(progress).catch(error);
2798
+ }
2706
2799
  function noServerCall() {
2707
2800
  throw Error(
2708
2801
  "Server Functions cannot be called during initial render. This would create a fetch waterfall. Try to use a Server Component to pass data to Client Components instead."
@@ -2864,7 +2957,7 @@
2864
2957
  JSCompiler_inline_result
2865
2958
  );
2866
2959
  if (null != owner) {
2867
- var task = initializeFakeTask(response, owner, env);
2960
+ var task = initializeFakeTask(response, owner);
2868
2961
  initializeFakeStack(response, owner);
2869
2962
  if (null !== task) {
2870
2963
  task.run(callStack);
@@ -2882,6 +2975,18 @@
2882
2975
  replayConsoleWithCallStackInDEV = replayConsoleWithCallStack[
2883
2976
  "react-stack-bottom-frame"
2884
2977
  ].bind(replayConsoleWithCallStack);
2978
+ exports.createFromFetch = function (promiseForResponse, options) {
2979
+ var response = createResponseFromOptions(options);
2980
+ promiseForResponse.then(
2981
+ function (r) {
2982
+ startReadingFromStream(response, r.body);
2983
+ },
2984
+ function (e) {
2985
+ reportGlobalError(response, e);
2986
+ }
2987
+ );
2988
+ return getChunk(response, 0);
2989
+ };
2885
2990
  exports.createFromNodeStream = function (
2886
2991
  stream,
2887
2992
  serverConsumerManifest,
@@ -2987,102 +3092,50 @@
2987
3092
  response._rowID = rowID;
2988
3093
  response._rowTag = rowTag;
2989
3094
  response._rowLength = rowLength;
2990
- } else {
2991
- rowLength = 0;
2992
- chunkLength = response._rowState;
2993
- rowID = response._rowID;
2994
- i = response._rowTag;
2995
- rowState = response._rowLength;
2996
- buffer = response._buffer;
2997
- for (rowTag = chunk.length; rowLength < rowTag; ) {
2998
- lastIdx = -1;
2999
- switch (chunkLength) {
3000
- case 0:
3001
- lastIdx = chunk[rowLength++];
3002
- 58 === lastIdx
3003
- ? (chunkLength = 1)
3004
- : (rowID =
3005
- (rowID << 4) |
3006
- (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
3007
- continue;
3008
- case 1:
3009
- chunkLength = chunk[rowLength];
3010
- 84 === chunkLength ||
3011
- 65 === chunkLength ||
3012
- 79 === chunkLength ||
3013
- 111 === chunkLength ||
3014
- 85 === chunkLength ||
3015
- 83 === chunkLength ||
3016
- 115 === chunkLength ||
3017
- 76 === chunkLength ||
3018
- 108 === chunkLength ||
3019
- 71 === chunkLength ||
3020
- 103 === chunkLength ||
3021
- 77 === chunkLength ||
3022
- 109 === chunkLength ||
3023
- 86 === chunkLength
3024
- ? ((i = chunkLength), (chunkLength = 2), rowLength++)
3025
- : (64 < chunkLength && 91 > chunkLength) ||
3026
- 35 === chunkLength ||
3027
- 114 === chunkLength ||
3028
- 120 === chunkLength
3029
- ? ((i = chunkLength), (chunkLength = 3), rowLength++)
3030
- : ((i = 0), (chunkLength = 3));
3031
- continue;
3032
- case 2:
3033
- lastIdx = chunk[rowLength++];
3034
- 44 === lastIdx
3035
- ? (chunkLength = 4)
3036
- : (rowState =
3037
- (rowState << 4) |
3038
- (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
3039
- continue;
3040
- case 3:
3041
- lastIdx = chunk.indexOf(10, rowLength);
3042
- break;
3043
- case 4:
3044
- (lastIdx = rowLength + rowState),
3045
- lastIdx > chunk.length && (lastIdx = -1);
3046
- }
3047
- var offset = chunk.byteOffset + rowLength;
3048
- if (-1 < lastIdx)
3049
- (rowState = new Uint8Array(
3050
- chunk.buffer,
3051
- offset,
3052
- lastIdx - rowLength
3053
- )),
3054
- processFullBinaryRow(response, rowID, i, buffer, rowState),
3055
- (rowLength = lastIdx),
3056
- 3 === chunkLength && rowLength++,
3057
- (rowState = rowID = i = chunkLength = 0),
3058
- (buffer.length = 0);
3059
- else {
3060
- chunk = new Uint8Array(
3061
- chunk.buffer,
3062
- offset,
3063
- chunk.byteLength - rowLength
3064
- );
3065
- buffer.push(chunk);
3066
- rowState -= chunk.byteLength;
3067
- break;
3068
- }
3069
- }
3070
- response._rowState = chunkLength;
3071
- response._rowID = rowID;
3072
- response._rowTag = i;
3073
- response._rowLength = rowState;
3074
- }
3095
+ } else processBinaryChunk(response, chunk);
3075
3096
  });
3076
3097
  stream.on("error", function (error) {
3077
3098
  reportGlobalError(response, error);
3078
3099
  });
3079
3100
  stream.on("end", function () {
3080
- reportGlobalError(response, Error("Connection closed."));
3101
+ return close(response);
3081
3102
  });
3082
3103
  return getChunk(response, 0);
3083
3104
  };
3105
+ exports.createFromReadableStream = function (stream, options) {
3106
+ options = createResponseFromOptions(options);
3107
+ startReadingFromStream(options, stream);
3108
+ return getChunk(options, 0);
3109
+ };
3084
3110
  exports.createServerReference = function (id) {
3085
- return createServerReference$1(id, noServerCall);
3111
+ return createServerReference$1(id, noServerCall$1);
3112
+ };
3113
+ exports.createTemporaryReferenceSet = function () {
3114
+ return new Map();
3115
+ };
3116
+ exports.encodeReply = function (value, options) {
3117
+ return new Promise(function (resolve, reject) {
3118
+ var abort = processReply(
3119
+ value,
3120
+ "",
3121
+ options && options.temporaryReferences
3122
+ ? options.temporaryReferences
3123
+ : void 0,
3124
+ resolve,
3125
+ reject
3126
+ );
3127
+ if (options && options.signal) {
3128
+ var signal = options.signal;
3129
+ if (signal.aborted) abort(signal.reason);
3130
+ else {
3131
+ var listener = function () {
3132
+ abort(signal.reason);
3133
+ signal.removeEventListener("abort", listener);
3134
+ };
3135
+ signal.addEventListener("abort", listener);
3136
+ }
3137
+ }
3138
+ });
3086
3139
  };
3087
3140
  exports.registerServerReference = function (
3088
3141
  reference,
@@ -1647,6 +1647,84 @@ function processFullStringRow(response, id, tag, row) {
1647
1647
  );
1648
1648
  }
1649
1649
  }
1650
+ function processBinaryChunk(response, chunk) {
1651
+ for (
1652
+ var i = 0,
1653
+ rowState = response._rowState,
1654
+ rowID = response._rowID,
1655
+ rowTag = response._rowTag,
1656
+ rowLength = response._rowLength,
1657
+ buffer = response._buffer,
1658
+ chunkLength = chunk.length;
1659
+ i < chunkLength;
1660
+
1661
+ ) {
1662
+ var lastIdx = -1;
1663
+ switch (rowState) {
1664
+ case 0:
1665
+ lastIdx = chunk[i++];
1666
+ 58 === lastIdx
1667
+ ? (rowState = 1)
1668
+ : (rowID =
1669
+ (rowID << 4) | (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1670
+ continue;
1671
+ case 1:
1672
+ rowState = chunk[i];
1673
+ 84 === rowState ||
1674
+ 65 === rowState ||
1675
+ 79 === rowState ||
1676
+ 111 === rowState ||
1677
+ 85 === rowState ||
1678
+ 83 === rowState ||
1679
+ 115 === rowState ||
1680
+ 76 === rowState ||
1681
+ 108 === rowState ||
1682
+ 71 === rowState ||
1683
+ 103 === rowState ||
1684
+ 77 === rowState ||
1685
+ 109 === rowState ||
1686
+ 86 === rowState
1687
+ ? ((rowTag = rowState), (rowState = 2), i++)
1688
+ : (64 < rowState && 91 > rowState) ||
1689
+ 35 === rowState ||
1690
+ 114 === rowState ||
1691
+ 120 === rowState
1692
+ ? ((rowTag = rowState), (rowState = 3), i++)
1693
+ : ((rowTag = 0), (rowState = 3));
1694
+ continue;
1695
+ case 2:
1696
+ lastIdx = chunk[i++];
1697
+ 44 === lastIdx
1698
+ ? (rowState = 4)
1699
+ : (rowLength =
1700
+ (rowLength << 4) | (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1701
+ continue;
1702
+ case 3:
1703
+ lastIdx = chunk.indexOf(10, i);
1704
+ break;
1705
+ case 4:
1706
+ (lastIdx = i + rowLength), lastIdx > chunk.length && (lastIdx = -1);
1707
+ }
1708
+ var offset = chunk.byteOffset + i;
1709
+ if (-1 < lastIdx)
1710
+ (rowLength = new Uint8Array(chunk.buffer, offset, lastIdx - i)),
1711
+ processFullBinaryRow(response, rowID, rowTag, buffer, rowLength),
1712
+ (i = lastIdx),
1713
+ 3 === rowState && i++,
1714
+ (rowLength = rowID = rowTag = rowState = 0),
1715
+ (buffer.length = 0);
1716
+ else {
1717
+ chunk = new Uint8Array(chunk.buffer, offset, chunk.byteLength - i);
1718
+ buffer.push(chunk);
1719
+ rowLength -= chunk.byteLength;
1720
+ break;
1721
+ }
1722
+ }
1723
+ response._rowState = rowState;
1724
+ response._rowID = rowID;
1725
+ response._rowTag = rowTag;
1726
+ response._rowLength = rowLength;
1727
+ }
1650
1728
  function createFromJSONCallback(response) {
1651
1729
  return function (key, value) {
1652
1730
  if ("string" === typeof value)
@@ -1687,11 +1765,60 @@ function createFromJSONCallback(response) {
1687
1765
  return value;
1688
1766
  };
1689
1767
  }
1768
+ function close(response) {
1769
+ reportGlobalError(response, Error("Connection closed."));
1770
+ }
1771
+ function noServerCall$1() {
1772
+ throw Error(
1773
+ "Server Functions cannot be called during initial render. This would create a fetch waterfall. Try to use a Server Component to pass data to Client Components instead."
1774
+ );
1775
+ }
1776
+ function createResponseFromOptions(options) {
1777
+ return new ResponseInstance(
1778
+ options.serverConsumerManifest.moduleMap,
1779
+ options.serverConsumerManifest.serverModuleMap,
1780
+ options.serverConsumerManifest.moduleLoading,
1781
+ noServerCall$1,
1782
+ options.encodeFormAction,
1783
+ "string" === typeof options.nonce ? options.nonce : void 0,
1784
+ options && options.temporaryReferences
1785
+ ? options.temporaryReferences
1786
+ : void 0
1787
+ );
1788
+ }
1789
+ function startReadingFromStream(response, stream) {
1790
+ function progress(_ref) {
1791
+ var value = _ref.value;
1792
+ if (_ref.done) close(response);
1793
+ else
1794
+ return (
1795
+ processBinaryChunk(response, value),
1796
+ reader.read().then(progress).catch(error)
1797
+ );
1798
+ }
1799
+ function error(e) {
1800
+ reportGlobalError(response, e);
1801
+ }
1802
+ var reader = stream.getReader();
1803
+ reader.read().then(progress).catch(error);
1804
+ }
1690
1805
  function noServerCall() {
1691
1806
  throw Error(
1692
1807
  "Server Functions cannot be called during initial render. This would create a fetch waterfall. Try to use a Server Component to pass data to Client Components instead."
1693
1808
  );
1694
1809
  }
1810
+ exports.createFromFetch = function (promiseForResponse, options) {
1811
+ var response = createResponseFromOptions(options);
1812
+ promiseForResponse.then(
1813
+ function (r) {
1814
+ startReadingFromStream(response, r.body);
1815
+ },
1816
+ function (e) {
1817
+ reportGlobalError(response, e);
1818
+ }
1819
+ );
1820
+ return getChunk(response, 0);
1821
+ };
1695
1822
  exports.createFromNodeStream = function (
1696
1823
  stream,
1697
1824
  serverConsumerManifest,
@@ -1793,101 +1920,50 @@ exports.createFromNodeStream = function (
1793
1920
  response._rowID = rowID;
1794
1921
  response._rowTag = rowTag;
1795
1922
  response._rowLength = rowLength;
1796
- } else {
1797
- rowLength = 0;
1798
- chunkLength = response._rowState;
1799
- rowID = response._rowID;
1800
- i = response._rowTag;
1801
- rowState = response._rowLength;
1802
- buffer = response._buffer;
1803
- for (rowTag = chunk.length; rowLength < rowTag; ) {
1804
- lastIdx = -1;
1805
- switch (chunkLength) {
1806
- case 0:
1807
- lastIdx = chunk[rowLength++];
1808
- 58 === lastIdx
1809
- ? (chunkLength = 1)
1810
- : (rowID =
1811
- (rowID << 4) | (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1812
- continue;
1813
- case 1:
1814
- chunkLength = chunk[rowLength];
1815
- 84 === chunkLength ||
1816
- 65 === chunkLength ||
1817
- 79 === chunkLength ||
1818
- 111 === chunkLength ||
1819
- 85 === chunkLength ||
1820
- 83 === chunkLength ||
1821
- 115 === chunkLength ||
1822
- 76 === chunkLength ||
1823
- 108 === chunkLength ||
1824
- 71 === chunkLength ||
1825
- 103 === chunkLength ||
1826
- 77 === chunkLength ||
1827
- 109 === chunkLength ||
1828
- 86 === chunkLength
1829
- ? ((i = chunkLength), (chunkLength = 2), rowLength++)
1830
- : (64 < chunkLength && 91 > chunkLength) ||
1831
- 35 === chunkLength ||
1832
- 114 === chunkLength ||
1833
- 120 === chunkLength
1834
- ? ((i = chunkLength), (chunkLength = 3), rowLength++)
1835
- : ((i = 0), (chunkLength = 3));
1836
- continue;
1837
- case 2:
1838
- lastIdx = chunk[rowLength++];
1839
- 44 === lastIdx
1840
- ? (chunkLength = 4)
1841
- : (rowState =
1842
- (rowState << 4) |
1843
- (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1844
- continue;
1845
- case 3:
1846
- lastIdx = chunk.indexOf(10, rowLength);
1847
- break;
1848
- case 4:
1849
- (lastIdx = rowLength + rowState),
1850
- lastIdx > chunk.length && (lastIdx = -1);
1851
- }
1852
- var offset = chunk.byteOffset + rowLength;
1853
- if (-1 < lastIdx)
1854
- (rowState = new Uint8Array(
1855
- chunk.buffer,
1856
- offset,
1857
- lastIdx - rowLength
1858
- )),
1859
- processFullBinaryRow(response, rowID, i, buffer, rowState),
1860
- (rowLength = lastIdx),
1861
- 3 === chunkLength && rowLength++,
1862
- (rowState = rowID = i = chunkLength = 0),
1863
- (buffer.length = 0);
1864
- else {
1865
- chunk = new Uint8Array(
1866
- chunk.buffer,
1867
- offset,
1868
- chunk.byteLength - rowLength
1869
- );
1870
- buffer.push(chunk);
1871
- rowState -= chunk.byteLength;
1872
- break;
1873
- }
1874
- }
1875
- response._rowState = chunkLength;
1876
- response._rowID = rowID;
1877
- response._rowTag = i;
1878
- response._rowLength = rowState;
1879
- }
1923
+ } else processBinaryChunk(response, chunk);
1880
1924
  });
1881
1925
  stream.on("error", function (error) {
1882
1926
  reportGlobalError(response, error);
1883
1927
  });
1884
1928
  stream.on("end", function () {
1885
- reportGlobalError(response, Error("Connection closed."));
1929
+ return close(response);
1886
1930
  });
1887
1931
  return getChunk(response, 0);
1888
1932
  };
1933
+ exports.createFromReadableStream = function (stream, options) {
1934
+ options = createResponseFromOptions(options);
1935
+ startReadingFromStream(options, stream);
1936
+ return getChunk(options, 0);
1937
+ };
1889
1938
  exports.createServerReference = function (id) {
1890
- return createServerReference$1(id, noServerCall);
1939
+ return createServerReference$1(id, noServerCall$1);
1940
+ };
1941
+ exports.createTemporaryReferenceSet = function () {
1942
+ return new Map();
1943
+ };
1944
+ exports.encodeReply = function (value, options) {
1945
+ return new Promise(function (resolve, reject) {
1946
+ var abort = processReply(
1947
+ value,
1948
+ "",
1949
+ options && options.temporaryReferences
1950
+ ? options.temporaryReferences
1951
+ : void 0,
1952
+ resolve,
1953
+ reject
1954
+ );
1955
+ if (options && options.signal) {
1956
+ var signal = options.signal;
1957
+ if (signal.aborted) abort(signal.reason);
1958
+ else {
1959
+ var listener = function () {
1960
+ abort(signal.reason);
1961
+ signal.removeEventListener("abort", listener);
1962
+ };
1963
+ signal.addEventListener("abort", listener);
1964
+ }
1965
+ }
1966
+ });
1891
1967
  };
1892
1968
  exports.registerServerReference = function (reference, id, encodeFormAction) {
1893
1969
  registerBoundServerReference(reference, id, null, encodeFormAction);