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
@@ -2245,66 +2245,46 @@
2245
2245
  : rootTask
2246
2246
  : null;
2247
2247
  }
2248
- function initializeFakeTask(response, debugInfo, childEnvironmentName) {
2248
+ function initializeFakeTask(response, debugInfo) {
2249
2249
  if (!supportsCreateTask || null == debugInfo.stack) return null;
2250
+ var cachedEntry = debugInfo.debugTask;
2251
+ if (void 0 !== cachedEntry) return cachedEntry;
2250
2252
  var useEnclosingLine = void 0 === debugInfo.key,
2251
2253
  stack = debugInfo.stack,
2252
2254
  env =
2253
2255
  null == debugInfo.env ? response._rootEnvironmentName : debugInfo.env;
2254
- if (env !== childEnvironmentName)
2255
- return (
2256
- (debugInfo =
2257
- null == debugInfo.owner
2258
- ? null
2259
- : initializeFakeTask(response, debugInfo.owner, env)),
2260
- buildFakeTask(
2261
- response,
2262
- debugInfo,
2263
- stack,
2264
- '"use ' + childEnvironmentName.toLowerCase() + '"',
2265
- env,
2266
- useEnclosingLine
2267
- )
2268
- );
2269
- childEnvironmentName = debugInfo.debugTask;
2270
- if (void 0 !== childEnvironmentName) return childEnvironmentName;
2271
- childEnvironmentName =
2256
+ cachedEntry =
2257
+ null == debugInfo.owner || null == debugInfo.owner.env
2258
+ ? response._rootEnvironmentName
2259
+ : debugInfo.owner.env;
2260
+ var ownerTask =
2272
2261
  null == debugInfo.owner
2273
2262
  ? null
2274
- : initializeFakeTask(response, debugInfo.owner, env);
2275
- return (debugInfo.debugTask = buildFakeTask(
2276
- response,
2277
- childEnvironmentName,
2278
- stack,
2279
- void 0 !== debugInfo.key
2280
- ? "<" + (debugInfo.name || "...") + ">"
2281
- : void 0 !== debugInfo.name
2282
- ? debugInfo.name || "unknown"
2283
- : "await " + (debugInfo.awaited.name || "unknown"),
2284
- env,
2285
- useEnclosingLine
2286
- ));
2287
- }
2288
- function buildFakeTask(
2289
- response,
2290
- ownerTask,
2291
- stack,
2292
- taskName,
2293
- env,
2294
- useEnclosingLine
2295
- ) {
2296
- taskName = console.createTask.bind(console, taskName);
2297
- stack = buildFakeCallStack(
2263
+ : initializeFakeTask(response, debugInfo.owner);
2264
+ env =
2265
+ env !== cachedEntry
2266
+ ? '"use ' + env.toLowerCase() + '"'
2267
+ : void 0 !== debugInfo.key
2268
+ ? "<" + (debugInfo.name || "...") + ">"
2269
+ : void 0 !== debugInfo.name
2270
+ ? debugInfo.name || "unknown"
2271
+ : "await " + (debugInfo.awaited.name || "unknown");
2272
+ env = console.createTask.bind(console, env);
2273
+ useEnclosingLine = buildFakeCallStack(
2298
2274
  response,
2299
2275
  stack,
2300
- env,
2276
+ cachedEntry,
2301
2277
  useEnclosingLine,
2302
- taskName
2278
+ env
2303
2279
  );
2304
- return null === ownerTask
2305
- ? ((response = getRootTask(response, env)),
2306
- null != response ? response.run(stack) : stack())
2307
- : ownerTask.run(stack);
2280
+ null === ownerTask
2281
+ ? ((response = getRootTask(response, cachedEntry)),
2282
+ (response =
2283
+ null != response
2284
+ ? response.run(useEnclosingLine)
2285
+ : useEnclosingLine()))
2286
+ : (response = ownerTask.run(useEnclosingLine));
2287
+ return (debugInfo.debugTask = response);
2308
2288
  }
2309
2289
  function fakeJSXCallSite() {
2310
2290
  return Error("react-stack-top-frame");
@@ -2321,15 +2301,12 @@
2321
2301
  initializeFakeStack(response, debugInfo.owner));
2322
2302
  }
2323
2303
  function resolveDebugInfo(response, id, debugInfo) {
2324
- var env =
2325
- void 0 === debugInfo.env
2326
- ? response._rootEnvironmentName
2327
- : debugInfo.env;
2328
- void 0 !== debugInfo.stack &&
2329
- initializeFakeTask(response, debugInfo, env);
2330
- null === debugInfo.owner && null != response._debugRootOwner
2304
+ void 0 !== debugInfo.stack && initializeFakeTask(response, debugInfo);
2305
+ null == debugInfo.owner && null != response._debugRootOwner
2331
2306
  ? ((debugInfo.owner = response._debugRootOwner),
2332
- (debugInfo.debugStack = response._debugRootStack))
2307
+ (debugInfo.stack = null),
2308
+ (debugInfo.debugStack = response._debugRootStack),
2309
+ (debugInfo.debugTask = response._debugRootTask))
2333
2310
  : void 0 !== debugInfo.stack &&
2334
2311
  initializeFakeStack(response, debugInfo);
2335
2312
  response = getChunk(response, id);
@@ -2555,6 +2532,85 @@
2555
2532
  resolveModel(response, id, row);
2556
2533
  }
2557
2534
  }
2535
+ function processBinaryChunk(response, chunk) {
2536
+ for (
2537
+ var i = 0,
2538
+ rowState = response._rowState,
2539
+ rowID = response._rowID,
2540
+ rowTag = response._rowTag,
2541
+ rowLength = response._rowLength,
2542
+ buffer = response._buffer,
2543
+ chunkLength = chunk.length;
2544
+ i < chunkLength;
2545
+
2546
+ ) {
2547
+ var lastIdx = -1;
2548
+ switch (rowState) {
2549
+ case 0:
2550
+ lastIdx = chunk[i++];
2551
+ 58 === lastIdx
2552
+ ? (rowState = 1)
2553
+ : (rowID =
2554
+ (rowID << 4) | (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
2555
+ continue;
2556
+ case 1:
2557
+ rowState = chunk[i];
2558
+ 84 === rowState ||
2559
+ 65 === rowState ||
2560
+ 79 === rowState ||
2561
+ 111 === rowState ||
2562
+ 85 === rowState ||
2563
+ 83 === rowState ||
2564
+ 115 === rowState ||
2565
+ 76 === rowState ||
2566
+ 108 === rowState ||
2567
+ 71 === rowState ||
2568
+ 103 === rowState ||
2569
+ 77 === rowState ||
2570
+ 109 === rowState ||
2571
+ 86 === rowState
2572
+ ? ((rowTag = rowState), (rowState = 2), i++)
2573
+ : (64 < rowState && 91 > rowState) ||
2574
+ 35 === rowState ||
2575
+ 114 === rowState ||
2576
+ 120 === rowState
2577
+ ? ((rowTag = rowState), (rowState = 3), i++)
2578
+ : ((rowTag = 0), (rowState = 3));
2579
+ continue;
2580
+ case 2:
2581
+ lastIdx = chunk[i++];
2582
+ 44 === lastIdx
2583
+ ? (rowState = 4)
2584
+ : (rowLength =
2585
+ (rowLength << 4) |
2586
+ (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
2587
+ continue;
2588
+ case 3:
2589
+ lastIdx = chunk.indexOf(10, i);
2590
+ break;
2591
+ case 4:
2592
+ (lastIdx = i + rowLength), lastIdx > chunk.length && (lastIdx = -1);
2593
+ }
2594
+ var offset = chunk.byteOffset + i;
2595
+ if (-1 < lastIdx)
2596
+ (rowLength = new Uint8Array(chunk.buffer, offset, lastIdx - i)),
2597
+ processFullBinaryRow(response, rowID, rowTag, buffer, rowLength),
2598
+ (i = lastIdx),
2599
+ 3 === rowState && i++,
2600
+ (rowLength = rowID = rowTag = rowState = 0),
2601
+ (buffer.length = 0);
2602
+ else {
2603
+ chunk = new Uint8Array(chunk.buffer, offset, chunk.byteLength - i);
2604
+ buffer.push(chunk);
2605
+ rowLength -= chunk.byteLength;
2606
+ break;
2607
+ }
2608
+ }
2609
+ response._rowState = rowState;
2610
+ response._rowID = rowID;
2611
+ response._rowTag = rowTag;
2612
+ response._rowLength = rowLength;
2613
+ }
2558
2614
  function createFromJSONCallback(response) {
2559
2615
  return function (key, value) {
2560
2616
  if ("string" === typeof value)
@@ -2617,10 +2673,7 @@
2617
2673
  !1,
2618
2674
  type
2619
2675
  )),
2620
- (type =
2621
- null === key
2622
- ? null
2623
- : initializeFakeTask(response, key, validated)),
2676
+ (type = null === key ? null : initializeFakeTask(response, key)),
2624
2677
  null === type
2625
2678
  ? ((type = response._debugRootTask),
2626
2679
  (normalizedStackTrace =
@@ -2665,6 +2718,46 @@
2665
2718
  return value;
2666
2719
  };
2667
2720
  }
2721
+ function close(response) {
2722
+ reportGlobalError(response, Error("Connection closed."));
2723
+ }
2724
+ function noServerCall$1() {
2725
+ throw Error(
2726
+ "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."
2727
+ );
2728
+ }
2729
+ function createResponseFromOptions(options) {
2730
+ return new ResponseInstance(
2731
+ options.serverConsumerManifest.moduleMap,
2732
+ options.serverConsumerManifest.serverModuleMap,
2733
+ options.serverConsumerManifest.moduleLoading,
2734
+ noServerCall$1,
2735
+ options.encodeFormAction,
2736
+ "string" === typeof options.nonce ? options.nonce : void 0,
2737
+ options && options.temporaryReferences
2738
+ ? options.temporaryReferences
2739
+ : void 0,
2740
+ options && options.findSourceMapURL ? options.findSourceMapURL : void 0,
2741
+ options ? !0 === options.replayConsoleLogs : !1,
2742
+ options && options.environmentName ? options.environmentName : void 0
2743
+ );
2744
+ }
2745
+ function startReadingFromStream(response, stream) {
2746
+ function progress(_ref) {
2747
+ var value = _ref.value;
2748
+ if (_ref.done) close(response);
2749
+ else
2750
+ return (
2751
+ processBinaryChunk(response, value),
2752
+ reader.read().then(progress).catch(error)
2753
+ );
2754
+ }
2755
+ function error(e) {
2756
+ reportGlobalError(response, e);
2757
+ }
2758
+ var reader = stream.getReader();
2759
+ reader.read().then(progress).catch(error);
2760
+ }
2668
2761
  function noServerCall() {
2669
2762
  throw Error(
2670
2763
  "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."
@@ -2826,7 +2919,7 @@
2826
2919
  JSCompiler_inline_result
2827
2920
  );
2828
2921
  if (null != owner) {
2829
- var task = initializeFakeTask(response, owner, env);
2922
+ var task = initializeFakeTask(response, owner);
2830
2923
  initializeFakeStack(response, owner);
2831
2924
  if (null !== task) {
2832
2925
  task.run(callStack);
@@ -2844,6 +2937,18 @@
2844
2937
  replayConsoleWithCallStackInDEV = replayConsoleWithCallStack[
2845
2938
  "react-stack-bottom-frame"
2846
2939
  ].bind(replayConsoleWithCallStack);
2940
+ exports.createFromFetch = function (promiseForResponse, options) {
2941
+ var response = createResponseFromOptions(options);
2942
+ promiseForResponse.then(
2943
+ function (r) {
2944
+ startReadingFromStream(response, r.body);
2945
+ },
2946
+ function (e) {
2947
+ reportGlobalError(response, e);
2948
+ }
2949
+ );
2950
+ return getChunk(response, 0);
2951
+ };
2847
2952
  exports.createFromNodeStream = function (
2848
2953
  stream,
2849
2954
  serverConsumerManifest,
@@ -2949,102 +3054,50 @@
2949
3054
  response._rowID = rowID;
2950
3055
  response._rowTag = rowTag;
2951
3056
  response._rowLength = rowLength;
2952
- } else {
2953
- rowLength = 0;
2954
- chunkLength = response._rowState;
2955
- rowID = response._rowID;
2956
- i = response._rowTag;
2957
- rowState = response._rowLength;
2958
- buffer = response._buffer;
2959
- for (rowTag = chunk.length; rowLength < rowTag; ) {
2960
- lastIdx = -1;
2961
- switch (chunkLength) {
2962
- case 0:
2963
- lastIdx = chunk[rowLength++];
2964
- 58 === lastIdx
2965
- ? (chunkLength = 1)
2966
- : (rowID =
2967
- (rowID << 4) |
2968
- (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
2969
- continue;
2970
- case 1:
2971
- chunkLength = chunk[rowLength];
2972
- 84 === chunkLength ||
2973
- 65 === chunkLength ||
2974
- 79 === chunkLength ||
2975
- 111 === chunkLength ||
2976
- 85 === chunkLength ||
2977
- 83 === chunkLength ||
2978
- 115 === chunkLength ||
2979
- 76 === chunkLength ||
2980
- 108 === chunkLength ||
2981
- 71 === chunkLength ||
2982
- 103 === chunkLength ||
2983
- 77 === chunkLength ||
2984
- 109 === chunkLength ||
2985
- 86 === chunkLength
2986
- ? ((i = chunkLength), (chunkLength = 2), rowLength++)
2987
- : (64 < chunkLength && 91 > chunkLength) ||
2988
- 35 === chunkLength ||
2989
- 114 === chunkLength ||
2990
- 120 === chunkLength
2991
- ? ((i = chunkLength), (chunkLength = 3), rowLength++)
2992
- : ((i = 0), (chunkLength = 3));
2993
- continue;
2994
- case 2:
2995
- lastIdx = chunk[rowLength++];
2996
- 44 === lastIdx
2997
- ? (chunkLength = 4)
2998
- : (rowState =
2999
- (rowState << 4) |
3000
- (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
3001
- continue;
3002
- case 3:
3003
- lastIdx = chunk.indexOf(10, rowLength);
3004
- break;
3005
- case 4:
3006
- (lastIdx = rowLength + rowState),
3007
- lastIdx > chunk.length && (lastIdx = -1);
3008
- }
3009
- var offset = chunk.byteOffset + rowLength;
3010
- if (-1 < lastIdx)
3011
- (rowState = new Uint8Array(
3012
- chunk.buffer,
3013
- offset,
3014
- lastIdx - rowLength
3015
- )),
3016
- processFullBinaryRow(response, rowID, i, buffer, rowState),
3017
- (rowLength = lastIdx),
3018
- 3 === chunkLength && rowLength++,
3019
- (rowState = rowID = i = chunkLength = 0),
3020
- (buffer.length = 0);
3021
- else {
3022
- chunk = new Uint8Array(
3023
- chunk.buffer,
3024
- offset,
3025
- chunk.byteLength - rowLength
3026
- );
3027
- buffer.push(chunk);
3028
- rowState -= chunk.byteLength;
3029
- break;
3030
- }
3031
- }
3032
- response._rowState = chunkLength;
3033
- response._rowID = rowID;
3034
- response._rowTag = i;
3035
- response._rowLength = rowState;
3036
- }
3057
+ } else processBinaryChunk(response, chunk);
3037
3058
  });
3038
3059
  stream.on("error", function (error) {
3039
3060
  reportGlobalError(response, error);
3040
3061
  });
3041
3062
  stream.on("end", function () {
3042
- reportGlobalError(response, Error("Connection closed."));
3063
+ return close(response);
3043
3064
  });
3044
3065
  return getChunk(response, 0);
3045
3066
  };
3067
+ exports.createFromReadableStream = function (stream, options) {
3068
+ options = createResponseFromOptions(options);
3069
+ startReadingFromStream(options, stream);
3070
+ return getChunk(options, 0);
3071
+ };
3046
3072
  exports.createServerReference = function (id) {
3047
- return createServerReference$1(id, noServerCall);
3073
+ return createServerReference$1(id, noServerCall$1);
3074
+ };
3075
+ exports.createTemporaryReferenceSet = function () {
3076
+ return new Map();
3077
+ };
3078
+ exports.encodeReply = function (value, options) {
3079
+ return new Promise(function (resolve, reject) {
3080
+ var abort = processReply(
3081
+ value,
3082
+ "",
3083
+ options && options.temporaryReferences
3084
+ ? options.temporaryReferences
3085
+ : void 0,
3086
+ resolve,
3087
+ reject
3088
+ );
3089
+ if (options && options.signal) {
3090
+ var signal = options.signal;
3091
+ if (signal.aborted) abort(signal.reason);
3092
+ else {
3093
+ var listener = function () {
3094
+ abort(signal.reason);
3095
+ signal.removeEventListener("abort", listener);
3096
+ };
3097
+ signal.addEventListener("abort", listener);
3098
+ }
3099
+ }
3100
+ });
3048
3101
  };
3049
3102
  exports.registerServerReference = function (
3050
3103
  reference,
@@ -1612,6 +1612,84 @@ function processFullStringRow(response, id, tag, row) {
1612
1612
  );
1613
1613
  }
1614
1614
  }
1615
+ function processBinaryChunk(response, chunk) {
1616
+ for (
1617
+ var i = 0,
1618
+ rowState = response._rowState,
1619
+ rowID = response._rowID,
1620
+ rowTag = response._rowTag,
1621
+ rowLength = response._rowLength,
1622
+ buffer = response._buffer,
1623
+ chunkLength = chunk.length;
1624
+ i < chunkLength;
1625
+
1626
+ ) {
1627
+ var lastIdx = -1;
1628
+ switch (rowState) {
1629
+ case 0:
1630
+ lastIdx = chunk[i++];
1631
+ 58 === lastIdx
1632
+ ? (rowState = 1)
1633
+ : (rowID =
1634
+ (rowID << 4) | (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1635
+ continue;
1636
+ case 1:
1637
+ rowState = chunk[i];
1638
+ 84 === rowState ||
1639
+ 65 === rowState ||
1640
+ 79 === rowState ||
1641
+ 111 === rowState ||
1642
+ 85 === rowState ||
1643
+ 83 === rowState ||
1644
+ 115 === rowState ||
1645
+ 76 === rowState ||
1646
+ 108 === rowState ||
1647
+ 71 === rowState ||
1648
+ 103 === rowState ||
1649
+ 77 === rowState ||
1650
+ 109 === rowState ||
1651
+ 86 === rowState
1652
+ ? ((rowTag = rowState), (rowState = 2), i++)
1653
+ : (64 < rowState && 91 > rowState) ||
1654
+ 35 === rowState ||
1655
+ 114 === rowState ||
1656
+ 120 === rowState
1657
+ ? ((rowTag = rowState), (rowState = 3), i++)
1658
+ : ((rowTag = 0), (rowState = 3));
1659
+ continue;
1660
+ case 2:
1661
+ lastIdx = chunk[i++];
1662
+ 44 === lastIdx
1663
+ ? (rowState = 4)
1664
+ : (rowLength =
1665
+ (rowLength << 4) | (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1666
+ continue;
1667
+ case 3:
1668
+ lastIdx = chunk.indexOf(10, i);
1669
+ break;
1670
+ case 4:
1671
+ (lastIdx = i + rowLength), lastIdx > chunk.length && (lastIdx = -1);
1672
+ }
1673
+ var offset = chunk.byteOffset + i;
1674
+ if (-1 < lastIdx)
1675
+ (rowLength = new Uint8Array(chunk.buffer, offset, lastIdx - i)),
1676
+ processFullBinaryRow(response, rowID, rowTag, buffer, rowLength),
1677
+ (i = lastIdx),
1678
+ 3 === rowState && i++,
1679
+ (rowLength = rowID = rowTag = rowState = 0),
1680
+ (buffer.length = 0);
1681
+ else {
1682
+ chunk = new Uint8Array(chunk.buffer, offset, chunk.byteLength - i);
1683
+ buffer.push(chunk);
1684
+ rowLength -= chunk.byteLength;
1685
+ break;
1686
+ }
1687
+ }
1688
+ response._rowState = rowState;
1689
+ response._rowID = rowID;
1690
+ response._rowTag = rowTag;
1691
+ response._rowLength = rowLength;
1692
+ }
1615
1693
  function createFromJSONCallback(response) {
1616
1694
  return function (key, value) {
1617
1695
  if ("string" === typeof value)
@@ -1652,11 +1730,60 @@ function createFromJSONCallback(response) {
1652
1730
  return value;
1653
1731
  };
1654
1732
  }
1733
+ function close(response) {
1734
+ reportGlobalError(response, Error("Connection closed."));
1735
+ }
1736
+ function noServerCall$1() {
1737
+ throw Error(
1738
+ "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."
1739
+ );
1740
+ }
1741
+ function createResponseFromOptions(options) {
1742
+ return new ResponseInstance(
1743
+ options.serverConsumerManifest.moduleMap,
1744
+ options.serverConsumerManifest.serverModuleMap,
1745
+ options.serverConsumerManifest.moduleLoading,
1746
+ noServerCall$1,
1747
+ options.encodeFormAction,
1748
+ "string" === typeof options.nonce ? options.nonce : void 0,
1749
+ options && options.temporaryReferences
1750
+ ? options.temporaryReferences
1751
+ : void 0
1752
+ );
1753
+ }
1754
+ function startReadingFromStream(response, stream) {
1755
+ function progress(_ref) {
1756
+ var value = _ref.value;
1757
+ if (_ref.done) close(response);
1758
+ else
1759
+ return (
1760
+ processBinaryChunk(response, value),
1761
+ reader.read().then(progress).catch(error)
1762
+ );
1763
+ }
1764
+ function error(e) {
1765
+ reportGlobalError(response, e);
1766
+ }
1767
+ var reader = stream.getReader();
1768
+ reader.read().then(progress).catch(error);
1769
+ }
1655
1770
  function noServerCall() {
1656
1771
  throw Error(
1657
1772
  "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."
1658
1773
  );
1659
1774
  }
1775
+ exports.createFromFetch = function (promiseForResponse, options) {
1776
+ var response = createResponseFromOptions(options);
1777
+ promiseForResponse.then(
1778
+ function (r) {
1779
+ startReadingFromStream(response, r.body);
1780
+ },
1781
+ function (e) {
1782
+ reportGlobalError(response, e);
1783
+ }
1784
+ );
1785
+ return getChunk(response, 0);
1786
+ };
1660
1787
  exports.createFromNodeStream = function (
1661
1788
  stream,
1662
1789
  serverConsumerManifest,
@@ -1758,101 +1885,50 @@ exports.createFromNodeStream = function (
1758
1885
  response._rowID = rowID;
1759
1886
  response._rowTag = rowTag;
1760
1887
  response._rowLength = rowLength;
1761
- } else {
1762
- rowLength = 0;
1763
- chunkLength = response._rowState;
1764
- rowID = response._rowID;
1765
- i = response._rowTag;
1766
- rowState = response._rowLength;
1767
- buffer = response._buffer;
1768
- for (rowTag = chunk.length; rowLength < rowTag; ) {
1769
- lastIdx = -1;
1770
- switch (chunkLength) {
1771
- case 0:
1772
- lastIdx = chunk[rowLength++];
1773
- 58 === lastIdx
1774
- ? (chunkLength = 1)
1775
- : (rowID =
1776
- (rowID << 4) | (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1777
- continue;
1778
- case 1:
1779
- chunkLength = chunk[rowLength];
1780
- 84 === chunkLength ||
1781
- 65 === chunkLength ||
1782
- 79 === chunkLength ||
1783
- 111 === chunkLength ||
1784
- 85 === chunkLength ||
1785
- 83 === chunkLength ||
1786
- 115 === chunkLength ||
1787
- 76 === chunkLength ||
1788
- 108 === chunkLength ||
1789
- 71 === chunkLength ||
1790
- 103 === chunkLength ||
1791
- 77 === chunkLength ||
1792
- 109 === chunkLength ||
1793
- 86 === chunkLength
1794
- ? ((i = chunkLength), (chunkLength = 2), rowLength++)
1795
- : (64 < chunkLength && 91 > chunkLength) ||
1796
- 35 === chunkLength ||
1797
- 114 === chunkLength ||
1798
- 120 === chunkLength
1799
- ? ((i = chunkLength), (chunkLength = 3), rowLength++)
1800
- : ((i = 0), (chunkLength = 3));
1801
- continue;
1802
- case 2:
1803
- lastIdx = chunk[rowLength++];
1804
- 44 === lastIdx
1805
- ? (chunkLength = 4)
1806
- : (rowState =
1807
- (rowState << 4) |
1808
- (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1809
- continue;
1810
- case 3:
1811
- lastIdx = chunk.indexOf(10, rowLength);
1812
- break;
1813
- case 4:
1814
- (lastIdx = rowLength + rowState),
1815
- lastIdx > chunk.length && (lastIdx = -1);
1816
- }
1817
- var offset = chunk.byteOffset + rowLength;
1818
- if (-1 < lastIdx)
1819
- (rowState = new Uint8Array(
1820
- chunk.buffer,
1821
- offset,
1822
- lastIdx - rowLength
1823
- )),
1824
- processFullBinaryRow(response, rowID, i, buffer, rowState),
1825
- (rowLength = lastIdx),
1826
- 3 === chunkLength && rowLength++,
1827
- (rowState = rowID = i = chunkLength = 0),
1828
- (buffer.length = 0);
1829
- else {
1830
- chunk = new Uint8Array(
1831
- chunk.buffer,
1832
- offset,
1833
- chunk.byteLength - rowLength
1834
- );
1835
- buffer.push(chunk);
1836
- rowState -= chunk.byteLength;
1837
- break;
1838
- }
1839
- }
1840
- response._rowState = chunkLength;
1841
- response._rowID = rowID;
1842
- response._rowTag = i;
1843
- response._rowLength = rowState;
1844
- }
1888
+ } else processBinaryChunk(response, chunk);
1845
1889
  });
1846
1890
  stream.on("error", function (error) {
1847
1891
  reportGlobalError(response, error);
1848
1892
  });
1849
1893
  stream.on("end", function () {
1850
- reportGlobalError(response, Error("Connection closed."));
1894
+ return close(response);
1851
1895
  });
1852
1896
  return getChunk(response, 0);
1853
1897
  };
1898
+ exports.createFromReadableStream = function (stream, options) {
1899
+ options = createResponseFromOptions(options);
1900
+ startReadingFromStream(options, stream);
1901
+ return getChunk(options, 0);
1902
+ };
1854
1903
  exports.createServerReference = function (id) {
1855
- return createServerReference$1(id, noServerCall);
1904
+ return createServerReference$1(id, noServerCall$1);
1905
+ };
1906
+ exports.createTemporaryReferenceSet = function () {
1907
+ return new Map();
1908
+ };
1909
+ exports.encodeReply = function (value, options) {
1910
+ return new Promise(function (resolve, reject) {
1911
+ var abort = processReply(
1912
+ value,
1913
+ "",
1914
+ options && options.temporaryReferences
1915
+ ? options.temporaryReferences
1916
+ : void 0,
1917
+ resolve,
1918
+ reject
1919
+ );
1920
+ if (options && options.signal) {
1921
+ var signal = options.signal;
1922
+ if (signal.aborted) abort(signal.reason);
1923
+ else {
1924
+ var listener = function () {
1925
+ abort(signal.reason);
1926
+ signal.removeEventListener("abort", listener);
1927
+ };
1928
+ signal.addEventListener("abort", listener);
1929
+ }
1930
+ }
1931
+ });
1856
1932
  };
1857
1933
  exports.registerServerReference = function (reference, id, encodeFormAction) {
1858
1934
  registerBoundServerReference(reference, id, null, encodeFormAction);