react-server-dom-webpack 19.0.0-canary-33a32441e9-20240418 → 19.0.0-canary-cb151849e1-20240424

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 (46) hide show
  1. package/cjs/react-server-dom-webpack-client.browser.development.js +36 -8
  2. package/cjs/react-server-dom-webpack-client.browser.production.js +768 -1652
  3. package/cjs/react-server-dom-webpack-client.edge.development.js +36 -8
  4. package/cjs/react-server-dom-webpack-client.edge.production.js +894 -1863
  5. package/cjs/react-server-dom-webpack-client.node.development.js +36 -8
  6. package/cjs/react-server-dom-webpack-client.node.production.js +870 -1818
  7. package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +36 -8
  8. package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +854 -1776
  9. package/cjs/react-server-dom-webpack-node-register.js +68 -13
  10. package/cjs/react-server-dom-webpack-plugin.js +398 -23
  11. package/cjs/react-server-dom-webpack-server.browser.development.js +87 -15
  12. package/cjs/react-server-dom-webpack-server.browser.production.js +1590 -3050
  13. package/cjs/react-server-dom-webpack-server.edge.development.js +87 -15
  14. package/cjs/react-server-dom-webpack-server.edge.production.js +1586 -3029
  15. package/cjs/react-server-dom-webpack-server.node.development.js +87 -15
  16. package/cjs/react-server-dom-webpack-server.node.production.js +1720 -3239
  17. package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +87 -15
  18. package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +1702 -3180
  19. package/client.browser.js +1 -1
  20. package/client.edge.js +1 -1
  21. package/client.node.js +1 -1
  22. package/client.node.unbundled.js +1 -1
  23. package/esm/{react-server-dom-webpack-node-loader.production.min.js → react-server-dom-webpack-node-loader.production.js} +1 -1
  24. package/package.json +4 -4
  25. package/server.browser.js +1 -1
  26. package/server.edge.js +1 -1
  27. package/server.node.js +1 -1
  28. package/server.node.unbundled.js +1 -1
  29. package/cjs/react-server-dom-webpack-client.browser.production.min.js +0 -40
  30. package/cjs/react-server-dom-webpack-client.browser.production.min.js.map +0 -1
  31. package/cjs/react-server-dom-webpack-client.edge.production.min.js +0 -46
  32. package/cjs/react-server-dom-webpack-client.edge.production.min.js.map +0 -1
  33. package/cjs/react-server-dom-webpack-client.node.production.min.js +0 -45
  34. package/cjs/react-server-dom-webpack-client.node.production.min.js.map +0 -1
  35. package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +0 -44
  36. package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js.map +0 -1
  37. package/cjs/react-server-dom-webpack-node-register.js.map +0 -1
  38. package/cjs/react-server-dom-webpack-plugin.js.map +0 -1
  39. package/cjs/react-server-dom-webpack-server.browser.production.min.js +0 -82
  40. package/cjs/react-server-dom-webpack-server.browser.production.min.js.map +0 -1
  41. package/cjs/react-server-dom-webpack-server.edge.production.min.js +0 -83
  42. package/cjs/react-server-dom-webpack-server.edge.production.min.js.map +0 -1
  43. package/cjs/react-server-dom-webpack-server.node.production.min.js +0 -86
  44. package/cjs/react-server-dom-webpack-server.node.production.min.js.map +0 -1
  45. package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +0 -84
  46. package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @license React
3
- * react-server-dom-webpack-client.node.production.min.js
3
+ * react-server-dom-webpack-client.node.production.js
4
4
  *
5
5
  * Copyright (c) Meta Platforms, Inc. and affiliates.
6
6
  *
@@ -8,1636 +8,814 @@
8
8
  * LICENSE file in the root directory of this source tree.
9
9
  */
10
10
 
11
- 'use strict';
12
-
13
- var util = require('util');
14
- var ReactDOM = require('react-dom');
15
-
16
- // -----------------------------------------------------------------------------
17
- const enableBinaryFlight = false;
18
-
19
- function createStringDecoder() {
20
- return new util.TextDecoder();
21
- }
22
- const decoderOptions = {
23
- stream: true
24
- };
25
- function readPartialStringChunk(decoder, buffer) {
26
- return decoder.decode(buffer, decoderOptions);
27
- }
28
- function readFinalStringChunk(decoder, buffer) {
29
- return decoder.decode(buffer);
30
- }
31
-
32
- // This is the parsed shape of the wire format which is why it is
33
- // condensed to only the essentialy information
34
- const ID = 0;
35
- const CHUNKS = 1;
36
- const NAME = 2; // export const ASYNC = 3;
37
- // This logic is correct because currently only include the 4th tuple member
38
- // when the module is async. If that changes we will need to actually assert
39
- // the value is true. We don't index into the 4th slot because flow does not
40
- // like the potential out of bounds access
41
-
42
- function isAsyncImport(metadata) {
43
- return metadata.length === 4;
44
- }
45
-
46
- // The reason this function needs to defined here in this file instead of just
47
- // being exported directly from the WebpackDestination... file is because the
48
- // ClientReferenceMetadata is opaque and we can't unwrap it there.
49
- // This should get inlined and we could also just implement an unwrapping function
50
- // though that risks it getting used in places it shouldn't be. This is unfortunate
51
- // but currently it seems to be the best option we have.
52
-
53
- function prepareDestinationForModule(moduleLoading, nonce, metadata) {
54
- prepareDestinationWithChunks(moduleLoading, metadata[CHUNKS], nonce);
55
- }
11
+ "use strict";
12
+ var util = require("util"),
13
+ ReactDOM = require("react-dom"),
14
+ decoderOptions = { stream: !0 };
56
15
  function resolveClientReference(bundlerConfig, metadata) {
57
16
  if (bundlerConfig) {
58
- const moduleExports = bundlerConfig[metadata[ID]];
59
- let resolvedModuleData = moduleExports[metadata[NAME]];
60
- let name;
61
-
62
- if (resolvedModuleData) {
63
- // The potentially aliased name.
64
- name = resolvedModuleData.name;
65
- } else {
66
- // If we don't have this specific name, we might have the full module.
67
- resolvedModuleData = moduleExports['*'];
68
-
69
- if (!resolvedModuleData) {
70
- throw new Error('Could not find the module "' + metadata[ID] + '" in the React SSR Manifest. ' + 'This is probably a bug in the React Server Components bundler.');
71
- }
72
-
73
- name = metadata[NAME];
74
- }
75
-
76
- if (isAsyncImport(metadata)) {
77
- return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
78
- /* async */
79
- ];
80
- } else {
81
- return [resolvedModuleData.id, resolvedModuleData.chunks, name];
17
+ var moduleExports = bundlerConfig[metadata[0]];
18
+ if ((bundlerConfig = moduleExports[metadata[2]]))
19
+ moduleExports = bundlerConfig.name;
20
+ else {
21
+ bundlerConfig = moduleExports["*"];
22
+ if (!bundlerConfig)
23
+ throw Error(
24
+ 'Could not find the module "' +
25
+ metadata[0] +
26
+ '" in the React SSR Manifest. This is probably a bug in the React Server Components bundler.'
27
+ );
28
+ moduleExports = metadata[2];
82
29
  }
30
+ return 4 === metadata.length
31
+ ? [bundlerConfig.id, bundlerConfig.chunks, moduleExports, 1]
32
+ : [bundlerConfig.id, bundlerConfig.chunks, moduleExports];
83
33
  }
84
-
85
34
  return metadata;
86
35
  }
87
- // If they're still pending they're a thenable. This map also exists
88
- // in Webpack but unfortunately it's not exposed so we have to
89
- // replicate it in user space. null means that it has already loaded.
90
-
91
- const chunkCache = new Map();
92
-
36
+ var chunkCache = new Map();
93
37
  function requireAsyncModule(id) {
94
- // We've already loaded all the chunks. We can require the module.
95
- const promise = __webpack_require__(id);
96
-
97
- if (typeof promise.then !== 'function') {
98
- // This wasn't a promise after all.
99
- return null;
100
- } else if (promise.status === 'fulfilled') {
101
- // This module was already resolved earlier.
38
+ var promise = __webpack_require__(id);
39
+ if ("function" !== typeof promise.then || "fulfilled" === promise.status)
102
40
  return null;
103
- } else {
104
- // Instrument the Promise to stash the result.
105
- promise.then(value => {
106
- const fulfilledThenable = promise;
107
- fulfilledThenable.status = 'fulfilled';
108
- fulfilledThenable.value = value;
109
- }, reason => {
110
- const rejectedThenable = promise;
111
- rejectedThenable.status = 'rejected';
112
- rejectedThenable.reason = reason;
113
- });
114
- return promise;
115
- }
41
+ promise.then(
42
+ function (value) {
43
+ promise.status = "fulfilled";
44
+ promise.value = value;
45
+ },
46
+ function (reason) {
47
+ promise.status = "rejected";
48
+ promise.reason = reason;
49
+ }
50
+ );
51
+ return promise;
116
52
  }
117
-
118
- function ignoreReject() {// We rely on rejected promises to be handled by another listener.
119
- } // Start preloading the modules since we might need them soon.
120
- // This function doesn't suspend.
121
-
122
-
53
+ function ignoreReject() {}
123
54
  function preloadModule(metadata) {
124
- const chunks = metadata[CHUNKS];
125
- const promises = [];
126
- let i = 0;
127
-
128
- while (i < chunks.length) {
129
- const chunkId = chunks[i++];
55
+ for (var chunks = metadata[1], promises = [], i = 0; i < chunks.length; ) {
56
+ var chunkId = chunks[i++];
130
57
  chunks[i++];
131
- const entry = chunkCache.get(chunkId);
132
-
133
- if (entry === undefined) {
134
- const thenable = loadChunk(chunkId);
135
- promises.push(thenable); // $FlowFixMe[method-unbinding]
136
-
137
- const resolve = chunkCache.set.bind(chunkCache, chunkId, null);
138
- thenable.then(resolve, ignoreReject);
139
- chunkCache.set(chunkId, thenable);
140
- } else if (entry !== null) {
58
+ var entry = chunkCache.get(chunkId);
59
+ if (void 0 === entry) {
60
+ entry = __webpack_chunk_load__(chunkId);
141
61
  promises.push(entry);
142
- }
62
+ var resolve = chunkCache.set.bind(chunkCache, chunkId, null);
63
+ entry.then(resolve, ignoreReject);
64
+ chunkCache.set(chunkId, entry);
65
+ } else null !== entry && promises.push(entry);
143
66
  }
144
-
145
- if (isAsyncImport(metadata)) {
146
- if (promises.length === 0) {
147
- return requireAsyncModule(metadata[ID]);
148
- } else {
149
- return Promise.all(promises).then(() => {
150
- return requireAsyncModule(metadata[ID]);
151
- });
152
- }
153
- } else if (promises.length > 0) {
154
- return Promise.all(promises);
155
- } else {
156
- return null;
157
- }
158
- } // Actually require the module or suspend if it's not yet ready.
159
- // Increase priority if necessary.
160
-
161
- function requireModule(metadata) {
162
- let moduleExports = __webpack_require__(metadata[ID]);
163
-
164
- if (isAsyncImport(metadata)) {
165
- if (typeof moduleExports.then !== 'function') ; else if (moduleExports.status === 'fulfilled') {
166
- // This Promise should've been instrumented by preloadModule.
167
- moduleExports = moduleExports.value;
168
- } else {
169
- throw moduleExports.reason;
67
+ return 4 === metadata.length
68
+ ? 0 === promises.length
69
+ ? requireAsyncModule(metadata[0])
70
+ : Promise.all(promises).then(function () {
71
+ return requireAsyncModule(metadata[0]);
72
+ })
73
+ : 0 < promises.length
74
+ ? Promise.all(promises)
75
+ : null;
76
+ }
77
+ function prepareDestinationWithChunks(moduleLoading, chunks, nonce$jscomp$0) {
78
+ if (null !== moduleLoading)
79
+ for (var i = 1; i < chunks.length; i += 2) {
80
+ var nonce = nonce$jscomp$0,
81
+ JSCompiler_temp_const = ReactDOMSharedInternals.d,
82
+ JSCompiler_temp_const$jscomp$0 = JSCompiler_temp_const.X,
83
+ JSCompiler_temp_const$jscomp$1 = moduleLoading.prefix + chunks[i];
84
+ var JSCompiler_inline_result = moduleLoading.crossOrigin;
85
+ JSCompiler_inline_result =
86
+ "string" === typeof JSCompiler_inline_result
87
+ ? "use-credentials" === JSCompiler_inline_result
88
+ ? JSCompiler_inline_result
89
+ : ""
90
+ : void 0;
91
+ JSCompiler_temp_const$jscomp$0.call(
92
+ JSCompiler_temp_const,
93
+ JSCompiler_temp_const$jscomp$1,
94
+ { crossOrigin: JSCompiler_inline_result, nonce: nonce }
95
+ );
170
96
  }
171
- }
172
-
173
- if (metadata[NAME] === '*') {
174
- // This is a placeholder value that represents that the caller imported this
175
- // as a CommonJS module as is.
176
- return moduleExports;
177
- }
178
-
179
- if (metadata[NAME] === '') {
180
- // This is a placeholder value that represents that the caller accessed the
181
- // default property of this if it was an ESM interop module.
182
- return moduleExports.__esModule ? moduleExports.default : moduleExports;
183
- }
184
-
185
- return moduleExports[metadata[NAME]];
186
97
  }
187
-
188
- function loadChunk(chunkId, filename) {
189
- return __webpack_chunk_load__(chunkId);
190
- }
191
-
192
- function prepareDestinationWithChunks(moduleLoading, // Chunks are double-indexed [..., idx, filenamex, idy, filenamey, ...]
193
- chunks, nonce) {
194
- if (moduleLoading !== null) {
195
- for (let i = 1; i < chunks.length; i += 2) {
196
- preinitScriptForSSR(moduleLoading.prefix + chunks[i], nonce, moduleLoading.crossOrigin);
197
- }
198
- }
199
- }
200
-
201
- const ReactDOMSharedInternals = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
202
-
203
- function getCrossOriginString(input) {
204
- if (typeof input === 'string') {
205
- return input === 'use-credentials' ? input : '';
206
- }
207
-
208
- return undefined;
209
- }
210
-
211
- // This client file is in the shared folder because it applies to both SSR and browser contexts.
212
- function dispatchHint(code, model) {
213
- const dispatcher = ReactDOMSharedInternals.d;
214
- /* ReactDOMCurrentDispatcher */
215
-
216
- switch (code) {
217
- case 'D':
218
- {
219
- const refined = refineModel(code, model);
220
- const href = refined;
221
- dispatcher.D(
222
- /* prefetchDNS */
223
- href);
224
- return;
225
- }
226
-
227
- case 'C':
228
- {
229
- const refined = refineModel(code, model);
230
-
231
- if (typeof refined === 'string') {
232
- const href = refined;
233
- dispatcher.C(
234
- /* preconnect */
235
- href);
236
- } else {
237
- const href = refined[0];
238
- const crossOrigin = refined[1];
239
- dispatcher.C(
240
- /* preconnect */
241
- href, crossOrigin);
242
- }
243
-
244
- return;
245
- }
246
-
247
- case 'L':
248
- {
249
- const refined = refineModel(code, model);
250
- const href = refined[0];
251
- const as = refined[1];
252
-
253
- if (refined.length === 3) {
254
- const options = refined[2];
255
- dispatcher.L(
256
- /* preload */
257
- href, as, options);
258
- } else {
259
- dispatcher.L(
260
- /* preload */
261
- href, as);
262
- }
263
-
264
- return;
265
- }
266
-
267
- case 'm':
268
- {
269
- const refined = refineModel(code, model);
270
-
271
- if (typeof refined === 'string') {
272
- const href = refined;
273
- dispatcher.m(
274
- /* preloadModule */
275
- href);
276
- } else {
277
- const href = refined[0];
278
- const options = refined[1];
279
- dispatcher.m(
280
- /* preloadModule */
281
- href, options);
282
- }
283
-
284
- return;
285
- }
286
-
287
- case 'X':
288
- {
289
- const refined = refineModel(code, model);
290
-
291
- if (typeof refined === 'string') {
292
- const href = refined;
293
- dispatcher.X(
294
- /* preinitScript */
295
- href);
296
- } else {
297
- const href = refined[0];
298
- const options = refined[1];
299
- dispatcher.X(
300
- /* preinitScript */
301
- href, options);
302
- }
303
-
304
- return;
305
- }
306
-
307
- case 'S':
308
- {
309
- const refined = refineModel(code, model);
310
-
311
- if (typeof refined === 'string') {
312
- const href = refined;
313
- dispatcher.S(
314
- /* preinitStyle */
315
- href);
316
- } else {
317
- const href = refined[0];
318
- const precedence = refined[1] === 0 ? undefined : refined[1];
319
- const options = refined.length === 3 ? refined[2] : undefined;
320
- dispatcher.S(
321
- /* preinitStyle */
322
- href, precedence, options);
323
- }
324
-
325
- return;
326
- }
327
-
328
- case 'M':
329
- {
330
- const refined = refineModel(code, model);
331
-
332
- if (typeof refined === 'string') {
333
- const href = refined;
334
- dispatcher.M(
335
- /* preinitModuleScript */
336
- href);
337
- } else {
338
- const href = refined[0];
339
- const options = refined[1];
340
- dispatcher.M(
341
- /* preinitModuleScript */
342
- href, options);
343
- }
344
-
345
- return;
346
- }
347
- }
348
- } // Flow is having trouble refining the HintModels so we help it a bit.
349
- // This should be compiled out in the production build.
350
-
351
- function refineModel(code, model) {
352
- return model;
353
- }
354
- function preinitScriptForSSR(href, nonce, crossOrigin) {
355
- ReactDOMSharedInternals.d
356
- /* ReactDOMCurrentDispatcher */
357
- .X(
358
- /* preinitScript */
359
- href, {
360
- crossOrigin: getCrossOriginString(crossOrigin),
361
- nonce
362
- });
363
- }
364
-
365
- // ATTENTION
366
- // When adding new symbols to this file,
367
- // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
368
- // The Symbol used to tag the ReactElement-like types.
369
- const REACT_ELEMENT_TYPE = Symbol.for('react.element');
370
- const REACT_LAZY_TYPE = Symbol.for('react.lazy');
371
- const MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
372
- const FAUX_ITERATOR_SYMBOL = '@@iterator';
98
+ var ReactDOMSharedInternals =
99
+ ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
100
+ REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
101
+ REACT_LAZY_TYPE = Symbol.for("react.lazy"),
102
+ MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
373
103
  function getIteratorFn(maybeIterable) {
374
- if (maybeIterable === null || typeof maybeIterable !== 'object') {
375
- return null;
376
- }
377
-
378
- const maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
379
-
380
- if (typeof maybeIterator === 'function') {
381
- return maybeIterator;
382
- }
383
-
384
- return null;
385
- }
386
-
387
- const isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
388
-
389
- function isArray(a) {
390
- return isArrayImpl(a);
391
- }
392
-
393
- const getPrototypeOf = Object.getPrototypeOf;
394
-
104
+ if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
105
+ maybeIterable =
106
+ (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) ||
107
+ maybeIterable["@@iterator"];
108
+ return "function" === typeof maybeIterable ? maybeIterable : null;
109
+ }
110
+ var isArrayImpl = Array.isArray,
111
+ getPrototypeOf = Object.getPrototypeOf;
395
112
  function writeTemporaryReference(set, object) {
396
- // We always create a new entry regardless if we've already written the same
397
- // object. This ensures that we always generate a deterministic encoding of
398
- // each slot in the reply for cacheability.
399
- const newId = set.length;
113
+ var newId = set.length;
400
114
  set.push(object);
401
115
  return newId;
402
116
  }
403
- function readTemporaryReference(set, id) {
404
- if (id < 0 || id >= set.length) {
405
- throw new Error("The RSC response contained a reference that doesn't exist in the temporary reference set. " + 'Always pass the matching set that was used to create the reply when parsing its response.');
406
- }
407
-
408
- return set[id];
409
- }
410
-
411
- const ObjectPrototype = Object.prototype;
412
- const knownServerReferences = new WeakMap(); // Serializable values
413
- // Thenable<ReactServerValue>
414
-
415
- function serializeByValueID(id) {
416
- return '$' + id.toString(16);
417
- }
418
-
419
- function serializePromiseID(id) {
420
- return '$@' + id.toString(16);
421
- }
422
-
423
- function serializeServerReferenceID(id) {
424
- return '$F' + id.toString(16);
425
- }
426
-
427
- function serializeTemporaryReferenceID(id) {
428
- return '$T' + id.toString(16);
429
- }
430
-
431
- function serializeFormDataReference(id) {
432
- // Why K? F is "Function". D is "Date". What else?
433
- return '$K' + id.toString(16);
434
- }
435
-
117
+ var ObjectPrototype = Object.prototype,
118
+ knownServerReferences = new WeakMap();
436
119
  function serializeNumber(number) {
437
- if (Number.isFinite(number)) {
438
- if (number === 0 && 1 / number === -Infinity) {
439
- return '$-0';
440
- } else {
441
- return number;
442
- }
443
- } else {
444
- if (number === Infinity) {
445
- return '$Infinity';
446
- } else if (number === -Infinity) {
447
- return '$-Infinity';
448
- } else {
449
- return '$NaN';
450
- }
451
- }
452
- }
453
-
454
- function serializeUndefined() {
455
- return '$undefined';
456
- }
457
-
458
- function serializeDateFromDateJSON(dateJSON) {
459
- // JSON.stringify automatically calls Date.prototype.toJSON which calls toISOString.
460
- // We need only tack on a $D prefix.
461
- return '$D' + dateJSON;
462
- }
463
-
464
- function serializeBigInt(n) {
465
- return '$n' + n.toString(10);
466
- }
467
-
468
- function serializeMapID(id) {
469
- return '$Q' + id.toString(16);
470
- }
471
-
472
- function serializeSetID(id) {
473
- return '$W' + id.toString(16);
474
- }
475
-
476
- function escapeStringValue(value) {
477
- if (value[0] === '$') {
478
- // We need to escape $ prefixed strings since we use those to encode
479
- // references to IDs and as special symbol values.
480
- return '$' + value;
481
- } else {
482
- return value;
483
- }
484
- }
485
-
486
- function processReply(root, formFieldPrefix, temporaryReferences, resolve, reject) {
487
- let nextPartId = 1;
488
- let pendingParts = 0;
489
- let formData = null;
490
-
120
+ return Number.isFinite(number)
121
+ ? 0 === number && -Infinity === 1 / number
122
+ ? "$-0"
123
+ : number
124
+ : Infinity === number
125
+ ? "$Infinity"
126
+ : -Infinity === number
127
+ ? "$-Infinity"
128
+ : "$NaN";
129
+ }
130
+ function processReply(
131
+ root,
132
+ formFieldPrefix,
133
+ temporaryReferences,
134
+ resolve,
135
+ reject
136
+ ) {
491
137
  function resolveToJSON(key, value) {
492
- const parent = this; // Make sure that `parent[key]` wasn't JSONified before `value` was passed to us
493
-
494
- if (value === null) {
495
- return null;
496
- }
497
-
498
- if (typeof value === 'object') {
138
+ if (null === value) return null;
139
+ if ("object" === typeof value) {
499
140
  switch (value.$$typeof) {
500
141
  case REACT_ELEMENT_TYPE:
501
- {
502
- if (temporaryReferences === undefined) {
503
- throw new Error('React Element cannot be passed to Server Functions from the Client without a ' + 'temporary reference set. Pass a TemporaryReferenceSet to the options.' + (''));
504
- }
505
-
506
- return serializeTemporaryReferenceID(writeTemporaryReference(temporaryReferences, value));
507
- }
508
-
142
+ if (void 0 === temporaryReferences)
143
+ throw Error(
144
+ "React Element cannot be passed to Server Functions from the Client without a temporary reference set. Pass a TemporaryReferenceSet to the options."
145
+ );
146
+ return (
147
+ "$T" +
148
+ writeTemporaryReference(temporaryReferences, value).toString(16)
149
+ );
509
150
  case REACT_LAZY_TYPE:
510
- {
511
- // Resolve lazy as if it wasn't here. In the future this will be encoded as a Promise.
512
- const lazy = value;
513
- const payload = lazy._payload;
514
- const init = lazy._init;
515
-
516
- if (formData === null) {
517
- // Upgrade to use FormData to allow us to stream this value.
518
- formData = new FormData();
519
- }
520
-
521
- pendingParts++;
522
-
523
- try {
524
- const resolvedModel = init(payload); // We always outline this as a separate part even though we could inline it
525
- // because it ensures a more deterministic encoding.
526
-
527
- const lazyId = nextPartId++;
528
- const partJSON = JSON.stringify(resolvedModel, resolveToJSON); // $FlowFixMe[incompatible-type] We know it's not null because we assigned it above.
529
-
530
- const data = formData; // eslint-disable-next-line react-internal/safe-string-coercion
531
-
532
- data.append(formFieldPrefix + lazyId, partJSON);
533
- return serializeByValueID(lazyId);
534
- } catch (x) {
535
- if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
536
- // Suspended
537
- pendingParts++;
538
- const lazyId = nextPartId++;
539
- const thenable = x;
540
-
541
- const retry = function () {
542
- // While the first promise resolved, its value isn't necessarily what we'll
543
- // resolve into because we might suspend again.
544
- try {
545
- const partJSON = JSON.stringify(value, resolveToJSON); // $FlowFixMe[incompatible-type] We know it's not null because we assigned it above.
546
-
547
- const data = formData; // eslint-disable-next-line react-internal/safe-string-coercion
548
-
549
- data.append(formFieldPrefix + lazyId, partJSON);
550
- pendingParts--;
551
-
552
- if (pendingParts === 0) {
553
- resolve(data);
554
- }
555
- } catch (reason) {
556
- reject(reason);
557
- }
558
- };
559
-
560
- thenable.then(retry, retry);
561
- return serializeByValueID(lazyId);
562
- } else {
563
- // In the future we could consider serializing this as an error
564
- // that throws on the server instead.
565
- reject(x);
566
- return null;
567
- }
568
- } finally {
569
- pendingParts--;
151
+ key = value._payload;
152
+ var init = value._init;
153
+ null === formData && (formData = new FormData());
154
+ pendingParts++;
155
+ try {
156
+ var resolvedModel = init(key),
157
+ lazyId = nextPartId++,
158
+ partJSON = JSON.stringify(resolvedModel, resolveToJSON);
159
+ formData.append(formFieldPrefix + lazyId, partJSON);
160
+ return "$" + lazyId.toString(16);
161
+ } catch (x) {
162
+ if (
163
+ "object" === typeof x &&
164
+ null !== x &&
165
+ "function" === typeof x.then
166
+ ) {
167
+ pendingParts++;
168
+ var lazyId$21 = nextPartId++;
169
+ resolvedModel = function () {
170
+ try {
171
+ var partJSON$22 = JSON.stringify(value, resolveToJSON),
172
+ data$23 = formData;
173
+ data$23.append(formFieldPrefix + lazyId$21, partJSON$22);
174
+ pendingParts--;
175
+ 0 === pendingParts && resolve(data$23);
176
+ } catch (reason) {
177
+ reject(reason);
178
+ }
179
+ };
180
+ x.then(resolvedModel, resolvedModel);
181
+ return "$" + lazyId$21.toString(16);
570
182
  }
183
+ reject(x);
184
+ return null;
185
+ } finally {
186
+ pendingParts--;
571
187
  }
572
- } // $FlowFixMe[method-unbinding]
573
-
574
-
575
- if (typeof value.then === 'function') {
576
- // We assume that any object with a .then property is a "Thenable" type,
577
- // or a Promise type. Either of which can be represented by a Promise.
578
- if (formData === null) {
579
- // Upgrade to use FormData to allow us to stream this value.
580
- formData = new FormData();
581
- }
582
-
188
+ }
189
+ if ("function" === typeof value.then) {
190
+ null === formData && (formData = new FormData());
583
191
  pendingParts++;
584
- const promiseId = nextPartId++;
585
- const thenable = value;
586
- thenable.then(partValue => {
587
- try {
588
- const partJSON = JSON.stringify(partValue, resolveToJSON); // $FlowFixMe[incompatible-type] We know it's not null because we assigned it above.
589
-
590
- const data = formData; // eslint-disable-next-line react-internal/safe-string-coercion
591
-
592
- data.append(formFieldPrefix + promiseId, partJSON);
593
- pendingParts--;
594
-
595
- if (pendingParts === 0) {
596
- resolve(data);
192
+ var promiseId = nextPartId++;
193
+ value.then(
194
+ function (partValue) {
195
+ try {
196
+ var partJSON$25 = JSON.stringify(partValue, resolveToJSON);
197
+ partValue = formData;
198
+ partValue.append(formFieldPrefix + promiseId, partJSON$25);
199
+ pendingParts--;
200
+ 0 === pendingParts && resolve(partValue);
201
+ } catch (reason) {
202
+ reject(reason);
597
203
  }
598
- } catch (reason) {
204
+ },
205
+ function (reason) {
599
206
  reject(reason);
600
207
  }
601
- }, reason => {
602
- // In the future we could consider serializing this as an error
603
- // that throws on the server instead.
604
- reject(reason);
605
- });
606
- return serializePromiseID(promiseId);
208
+ );
209
+ return "$@" + promiseId.toString(16);
607
210
  }
608
-
609
- if (isArray(value)) {
610
- // $FlowFixMe[incompatible-return]
611
- return value;
612
- } // TODO: Should we the Object.prototype.toString.call() to test for cross-realm objects?
613
-
614
-
211
+ if (isArrayImpl(value)) return value;
615
212
  if (value instanceof FormData) {
616
- if (formData === null) {
617
- // Upgrade to use FormData to allow us to use rich objects as its values.
618
- formData = new FormData();
619
- }
620
-
621
- const data = formData;
622
- const refId = nextPartId++; // Copy all the form fields with a prefix for this reference.
623
- // These must come first in the form order because we assume that all the
624
- // fields are available before this is referenced.
625
-
626
- const prefix = formFieldPrefix + refId + '_'; // $FlowFixMe[prop-missing]: FormData has forEach.
627
-
628
- value.forEach((originalValue, originalKey) => {
629
- data.append(prefix + originalKey, originalValue);
213
+ null === formData && (formData = new FormData());
214
+ var data$27 = formData;
215
+ resolvedModel = nextPartId++;
216
+ var prefix = formFieldPrefix + resolvedModel + "_";
217
+ value.forEach(function (originalValue, originalKey) {
218
+ data$27.append(prefix + originalKey, originalValue);
630
219
  });
631
- return serializeFormDataReference(refId);
632
- }
633
-
634
- if (value instanceof Map) {
635
- const partJSON = JSON.stringify(Array.from(value), resolveToJSON);
636
-
637
- if (formData === null) {
638
- formData = new FormData();
639
- }
640
-
641
- const mapId = nextPartId++;
642
- formData.append(formFieldPrefix + mapId, partJSON);
643
- return serializeMapID(mapId);
644
- }
645
-
646
- if (value instanceof Set) {
647
- const partJSON = JSON.stringify(Array.from(value), resolveToJSON);
648
-
649
- if (formData === null) {
650
- formData = new FormData();
651
- }
652
-
653
- const setId = nextPartId++;
654
- formData.append(formFieldPrefix + setId, partJSON);
655
- return serializeSetID(setId);
656
- }
657
-
658
- const iteratorFn = getIteratorFn(value);
659
-
660
- if (iteratorFn) {
661
- return Array.from(value);
662
- } // Verify that this is a simple plain object.
663
-
664
-
665
- const proto = getPrototypeOf(value);
666
-
667
- if (proto !== ObjectPrototype && (proto === null || getPrototypeOf(proto) !== null)) {
668
- if (temporaryReferences === undefined) {
669
- throw new Error('Only plain objects, and a few built-ins, can be passed to Server Actions. ' + 'Classes or null prototypes are not supported.');
670
- } // We can serialize class instances as temporary references.
671
-
672
-
673
- return serializeTemporaryReferenceID(writeTemporaryReference(temporaryReferences, value));
220
+ return "$K" + resolvedModel.toString(16);
674
221
  }
675
-
676
-
677
- return value;
678
- }
679
-
680
- if (typeof value === 'string') {
681
- // TODO: Maybe too clever. If we support URL there's no similar trick.
682
- if (value[value.length - 1] === 'Z') {
683
- // Possibly a Date, whose toJSON automatically calls toISOString
684
- // $FlowFixMe[incompatible-use]
685
- const originalValue = parent[key];
686
-
687
- if (originalValue instanceof Date) {
688
- return serializeDateFromDateJSON(value);
689
- }
222
+ if (value instanceof Map)
223
+ return (
224
+ (resolvedModel = JSON.stringify(Array.from(value), resolveToJSON)),
225
+ null === formData && (formData = new FormData()),
226
+ (lazyId = nextPartId++),
227
+ formData.append(formFieldPrefix + lazyId, resolvedModel),
228
+ "$Q" + lazyId.toString(16)
229
+ );
230
+ if (value instanceof Set)
231
+ return (
232
+ (resolvedModel = JSON.stringify(Array.from(value), resolveToJSON)),
233
+ null === formData && (formData = new FormData()),
234
+ (lazyId = nextPartId++),
235
+ formData.append(formFieldPrefix + lazyId, resolvedModel),
236
+ "$W" + lazyId.toString(16)
237
+ );
238
+ if ((resolvedModel = getIteratorFn(value)))
239
+ return (
240
+ (resolvedModel = resolvedModel.call(value)),
241
+ resolvedModel === value
242
+ ? ((resolvedModel = JSON.stringify(
243
+ Array.from(resolvedModel),
244
+ resolveToJSON
245
+ )),
246
+ null === formData && (formData = new FormData()),
247
+ (lazyId = nextPartId++),
248
+ formData.append(formFieldPrefix + lazyId, resolvedModel),
249
+ "$i" + lazyId.toString(16))
250
+ : Array.from(resolvedModel)
251
+ );
252
+ resolvedModel = getPrototypeOf(value);
253
+ if (
254
+ resolvedModel !== ObjectPrototype &&
255
+ (null === resolvedModel || null !== getPrototypeOf(resolvedModel))
256
+ ) {
257
+ if (void 0 === temporaryReferences)
258
+ throw Error(
259
+ "Only plain objects, and a few built-ins, can be passed to Server Actions. Classes or null prototypes are not supported."
260
+ );
261
+ return (
262
+ "$T" +
263
+ writeTemporaryReference(temporaryReferences, value).toString(16)
264
+ );
690
265
  }
691
-
692
- return escapeStringValue(value);
693
- }
694
-
695
- if (typeof value === 'boolean') {
696
266
  return value;
697
267
  }
698
-
699
- if (typeof value === 'number') {
700
- return serializeNumber(value);
701
- }
702
-
703
- if (typeof value === 'undefined') {
704
- return serializeUndefined();
705
- }
706
-
707
- if (typeof value === 'function') {
708
- const metaData = knownServerReferences.get(value);
709
-
710
- if (metaData !== undefined) {
711
- const metaDataJSON = JSON.stringify(metaData, resolveToJSON);
712
-
713
- if (formData === null) {
714
- // Upgrade to use FormData to allow us to stream this value.
715
- formData = new FormData();
716
- } // The reference to this function came from the same client so we can pass it back.
717
-
718
-
719
- const refId = nextPartId++; // eslint-disable-next-line react-internal/safe-string-coercion
720
-
721
- formData.set(formFieldPrefix + refId, metaDataJSON);
722
- return serializeServerReferenceID(refId);
723
- }
724
-
725
- if (temporaryReferences === undefined) {
726
- throw new Error('Client Functions cannot be passed directly to Server Functions. ' + 'Only Functions passed from the Server can be passed back again.');
727
- }
728
-
729
- return serializeTemporaryReferenceID(writeTemporaryReference(temporaryReferences, value));
730
- }
731
-
732
- if (typeof value === 'symbol') {
733
- if (temporaryReferences === undefined) {
734
- throw new Error('Symbols cannot be passed to a Server Function without a ' + 'temporary reference set. Pass a TemporaryReferenceSet to the options.' + (''));
735
- }
736
-
737
- return serializeTemporaryReferenceID(writeTemporaryReference(temporaryReferences, value));
268
+ if ("string" === typeof value) {
269
+ if ("Z" === value[value.length - 1] && this[key] instanceof Date)
270
+ return "$D" + value;
271
+ resolvedModel = "$" === value[0] ? "$" + value : value;
272
+ return resolvedModel;
738
273
  }
739
-
740
- if (typeof value === 'bigint') {
741
- return serializeBigInt(value);
274
+ if ("boolean" === typeof value) return value;
275
+ if ("number" === typeof value) return serializeNumber(value);
276
+ if ("undefined" === typeof value) return "$undefined";
277
+ if ("function" === typeof value) {
278
+ resolvedModel = knownServerReferences.get(value);
279
+ if (void 0 !== resolvedModel)
280
+ return (
281
+ (resolvedModel = JSON.stringify(resolvedModel, resolveToJSON)),
282
+ null === formData && (formData = new FormData()),
283
+ (lazyId = nextPartId++),
284
+ formData.set(formFieldPrefix + lazyId, resolvedModel),
285
+ "$F" + lazyId.toString(16)
286
+ );
287
+ if (void 0 === temporaryReferences)
288
+ throw Error(
289
+ "Client Functions cannot be passed directly to Server Functions. Only Functions passed from the Server can be passed back again."
290
+ );
291
+ return (
292
+ "$T" + writeTemporaryReference(temporaryReferences, value).toString(16)
293
+ );
742
294
  }
743
-
744
- throw new Error("Type " + typeof value + " is not supported as an argument to a Server Function.");
745
- } // $FlowFixMe[incompatible-type] it's not going to be undefined because we'll encode it.
746
-
747
-
748
- const json = JSON.stringify(root, resolveToJSON);
749
-
750
- if (formData === null) {
751
- // If it's a simple data structure, we just use plain JSON.
752
- resolve(json);
753
- } else {
754
- // Otherwise, we use FormData to let us stream in the result.
755
- formData.set(formFieldPrefix + '0', json);
756
-
757
- if (pendingParts === 0) {
758
- // $FlowFixMe[incompatible-call] this has already been refined.
759
- resolve(formData);
295
+ if ("symbol" === typeof value) {
296
+ if (void 0 === temporaryReferences)
297
+ throw Error(
298
+ "Symbols cannot be passed to a Server Function without a temporary reference set. Pass a TemporaryReferenceSet to the options."
299
+ );
300
+ return (
301
+ "$T" + writeTemporaryReference(temporaryReferences, value).toString(16)
302
+ );
760
303
  }
304
+ if ("bigint" === typeof value) return "$n" + value.toString(10);
305
+ throw Error(
306
+ "Type " +
307
+ typeof value +
308
+ " is not supported as an argument to a Server Function."
309
+ );
761
310
  }
762
- }
763
- const boundCache = new WeakMap();
764
-
311
+ var nextPartId = 1,
312
+ pendingParts = 0,
313
+ formData = null;
314
+ root = JSON.stringify(root, resolveToJSON);
315
+ null === formData
316
+ ? resolve(root)
317
+ : (formData.set(formFieldPrefix + "0", root),
318
+ 0 === pendingParts && resolve(formData));
319
+ }
320
+ var boundCache = new WeakMap();
765
321
  function encodeFormData(reference) {
766
- let resolve, reject; // We need to have a handle on the thenable so that we can synchronously set
767
- // its status from processReply, when it can complete synchronously.
768
-
769
- const thenable = new Promise((res, rej) => {
770
- resolve = res;
771
- reject = rej;
772
- });
773
- processReply(reference, '', undefined, // TODO: This means React Elements can't be used as state in progressive enhancement.
774
- body => {
775
- if (typeof body === 'string') {
776
- const data = new FormData();
777
- data.append('0', body);
778
- body = data;
322
+ var resolve,
323
+ reject,
324
+ thenable = new Promise(function (res, rej) {
325
+ resolve = res;
326
+ reject = rej;
327
+ });
328
+ processReply(
329
+ reference,
330
+ "",
331
+ void 0,
332
+ function (body) {
333
+ if ("string" === typeof body) {
334
+ var data = new FormData();
335
+ data.append("0", body);
336
+ body = data;
337
+ }
338
+ thenable.status = "fulfilled";
339
+ thenable.value = body;
340
+ resolve(body);
341
+ },
342
+ function (e) {
343
+ thenable.status = "rejected";
344
+ thenable.reason = e;
345
+ reject(e);
779
346
  }
780
-
781
- const fulfilled = thenable;
782
- fulfilled.status = 'fulfilled';
783
- fulfilled.value = body;
784
- resolve(body);
785
- }, e => {
786
- const rejected = thenable;
787
- rejected.status = 'rejected';
788
- rejected.reason = e;
789
- reject(e);
790
- });
347
+ );
791
348
  return thenable;
792
349
  }
793
-
794
350
  function defaultEncodeFormAction(identifierPrefix) {
795
- const reference = knownServerReferences.get(this);
796
-
797
- if (!reference) {
798
- throw new Error('Tried to encode a Server Action from a different instance than the encoder is from. ' + 'This is a bug in React.');
799
- }
800
-
801
- let data = null;
802
- let name;
803
- const boundPromise = reference.bound;
804
-
805
- if (boundPromise !== null) {
806
- let thenable = boundCache.get(reference);
807
-
808
- if (!thenable) {
809
- thenable = encodeFormData(reference);
810
- boundCache.set(reference, thenable);
811
- }
812
-
813
- if (thenable.status === 'rejected') {
814
- throw thenable.reason;
815
- } else if (thenable.status !== 'fulfilled') {
816
- throw thenable;
817
- }
818
-
819
- const encodedFormData = thenable.value; // This is hacky but we need the identifier prefix to be added to
820
- // all fields but the suspense cache would break since we might get
821
- // a new identifier each time. So we just append it at the end instead.
822
-
823
- const prefixedData = new FormData(); // $FlowFixMe[prop-missing]
824
-
825
- encodedFormData.forEach((value, key) => {
826
- prefixedData.append('$ACTION_' + identifierPrefix + ':' + key, value);
351
+ var reference = knownServerReferences.get(this);
352
+ if (!reference)
353
+ throw Error(
354
+ "Tried to encode a Server Action from a different instance than the encoder is from. This is a bug in React."
355
+ );
356
+ var data = null;
357
+ if (null !== reference.bound) {
358
+ data = boundCache.get(reference);
359
+ data ||
360
+ ((data = encodeFormData(reference)), boundCache.set(reference, data));
361
+ if ("rejected" === data.status) throw data.reason;
362
+ if ("fulfilled" !== data.status) throw data;
363
+ reference = data.value;
364
+ var prefixedData = new FormData();
365
+ reference.forEach(function (value, key) {
366
+ prefixedData.append("$ACTION_" + identifierPrefix + ":" + key, value);
827
367
  });
828
- data = prefixedData; // We encode the name of the prefix containing the data.
829
-
830
- name = '$ACTION_REF_' + identifierPrefix;
831
- } else {
832
- // This is the simple case so we can just encode the ID.
833
- name = '$ACTION_ID_' + reference.id;
834
- }
835
-
368
+ data = prefixedData;
369
+ reference = "$ACTION_REF_" + identifierPrefix;
370
+ } else reference = "$ACTION_ID_" + reference.id;
836
371
  return {
837
- name: name,
838
- method: 'POST',
839
- encType: 'multipart/form-data',
372
+ name: reference,
373
+ method: "POST",
374
+ encType: "multipart/form-data",
840
375
  data: data
841
376
  };
842
377
  }
843
-
844
- function customEncodeFormAction(proxy, identifierPrefix, encodeFormAction) {
845
- const reference = knownServerReferences.get(proxy);
846
-
847
- if (!reference) {
848
- throw new Error('Tried to encode a Server Action from a different instance than the encoder is from. ' + 'This is a bug in React.');
849
- }
850
-
851
- let boundPromise = reference.bound;
852
-
853
- if (boundPromise === null) {
854
- boundPromise = Promise.resolve([]);
855
- }
856
-
857
- return encodeFormAction(reference.id, boundPromise);
858
- }
859
-
860
378
  function isSignatureEqual(referenceId, numberOfBoundArgs) {
861
- const reference = knownServerReferences.get(this);
862
-
863
- if (!reference) {
864
- throw new Error('Tried to encode a Server Action from a different instance than the encoder is from. ' + 'This is a bug in React.');
865
- }
866
-
867
- if (reference.id !== referenceId) {
868
- // These are different functions.
869
- return false;
870
- } // Now check if the number of bound arguments is the same.
871
-
872
-
873
- const boundPromise = reference.bound;
874
-
875
- if (boundPromise === null) {
876
- // No bound arguments.
877
- return numberOfBoundArgs === 0;
878
- } // Unwrap the bound arguments array by suspending, if necessary. As with
879
- // encodeFormData, this means isSignatureEqual can only be called while React
880
- // is rendering.
881
-
882
-
379
+ var reference = knownServerReferences.get(this);
380
+ if (!reference)
381
+ throw Error(
382
+ "Tried to encode a Server Action from a different instance than the encoder is from. This is a bug in React."
383
+ );
384
+ if (reference.id !== referenceId) return !1;
385
+ var boundPromise = reference.bound;
386
+ if (null === boundPromise) return 0 === numberOfBoundArgs;
883
387
  switch (boundPromise.status) {
884
- case 'fulfilled':
885
- {
886
- const boundArgs = boundPromise.value;
887
- return boundArgs.length === numberOfBoundArgs;
888
- }
889
-
890
- case 'pending':
891
- {
892
- throw boundPromise;
893
- }
894
-
895
- case 'rejected':
896
- {
897
- throw boundPromise.reason;
898
- }
899
-
388
+ case "fulfilled":
389
+ return boundPromise.value.length === numberOfBoundArgs;
390
+ case "pending":
391
+ throw boundPromise;
392
+ case "rejected":
393
+ throw boundPromise.reason;
900
394
  default:
901
- {
902
- if (typeof boundPromise.status === 'string') ; else {
903
- const pendingThenable = boundPromise;
904
- pendingThenable.status = 'pending';
905
- pendingThenable.then(boundArgs => {
906
- const fulfilledThenable = boundPromise;
907
- fulfilledThenable.status = 'fulfilled';
908
- fulfilledThenable.value = boundArgs;
909
- }, error => {
910
- const rejectedThenable = boundPromise;
911
- rejectedThenable.status = 'rejected';
912
- rejectedThenable.reason = error;
913
- });
914
- }
915
-
916
- throw boundPromise;
917
- }
395
+ throw (
396
+ ("string" !== typeof boundPromise.status &&
397
+ ((boundPromise.status = "pending"),
398
+ boundPromise.then(
399
+ function (boundArgs) {
400
+ boundPromise.status = "fulfilled";
401
+ boundPromise.value = boundArgs;
402
+ },
403
+ function (error) {
404
+ boundPromise.status = "rejected";
405
+ boundPromise.reason = error;
406
+ }
407
+ )),
408
+ boundPromise)
409
+ );
918
410
  }
919
411
  }
920
-
921
- function registerServerReference(proxy, reference, encodeFormAction) {
922
- // Expose encoder for use by SSR, as well as a special bind that can be used to
923
- // keep server capabilities.
924
- {
925
- // Only expose this in builds that would actually use it. Not needed on the client.
926
- const $$FORM_ACTION = encodeFormAction === undefined ? defaultEncodeFormAction : function (identifierPrefix) {
927
- return customEncodeFormAction(this, identifierPrefix, encodeFormAction);
928
- };
929
- Object.defineProperties(proxy, {
930
- $$FORM_ACTION: {
931
- value: $$FORM_ACTION
932
- },
933
- $$IS_SIGNATURE_EQUAL: {
934
- value: isSignatureEqual
935
- },
936
- bind: {
937
- value: bind
938
- }
939
- });
940
- }
941
-
942
- knownServerReferences.set(proxy, reference);
943
- } // $FlowFixMe[method-unbinding]
944
-
945
- const FunctionBind = Function.prototype.bind; // $FlowFixMe[method-unbinding]
946
-
947
- const ArraySlice = Array.prototype.slice;
948
-
412
+ function registerServerReference(proxy, reference$jscomp$0, encodeFormAction) {
413
+ Object.defineProperties(proxy, {
414
+ $$FORM_ACTION: {
415
+ value:
416
+ void 0 === encodeFormAction
417
+ ? defaultEncodeFormAction
418
+ : function () {
419
+ var reference = knownServerReferences.get(this);
420
+ if (!reference)
421
+ throw Error(
422
+ "Tried to encode a Server Action from a different instance than the encoder is from. This is a bug in React."
423
+ );
424
+ var boundPromise = reference.bound;
425
+ null === boundPromise && (boundPromise = Promise.resolve([]));
426
+ return encodeFormAction(reference.id, boundPromise);
427
+ }
428
+ },
429
+ $$IS_SIGNATURE_EQUAL: { value: isSignatureEqual },
430
+ bind: { value: bind }
431
+ });
432
+ knownServerReferences.set(proxy, reference$jscomp$0);
433
+ }
434
+ var FunctionBind = Function.prototype.bind,
435
+ ArraySlice = Array.prototype.slice;
949
436
  function bind() {
950
- // $FlowFixMe[unsupported-syntax]
951
- const newFn = FunctionBind.apply(this, arguments);
952
- const reference = knownServerReferences.get(this);
953
-
437
+ var newFn = FunctionBind.apply(this, arguments),
438
+ reference = knownServerReferences.get(this);
954
439
  if (reference) {
955
-
956
- const args = ArraySlice.call(arguments, 1);
957
- let boundPromise = null;
958
-
959
- if (reference.bound !== null) {
960
- boundPromise = Promise.resolve(reference.bound).then(boundArgs => boundArgs.concat(args));
961
- } else {
962
- boundPromise = Promise.resolve(args);
963
- } // Expose encoder for use by SSR, as well as a special bind that can be used to
964
- // keep server capabilities.
965
-
966
-
967
- {
968
- // Only expose this in builds that would actually use it. Not needed on the client.
969
- Object.defineProperties(newFn, {
970
- $$FORM_ACTION: {
971
- value: this.$$FORM_ACTION
972
- },
973
- $$IS_SIGNATURE_EQUAL: {
974
- value: isSignatureEqual
975
- },
976
- bind: {
977
- value: bind
978
- }
979
- });
980
- }
981
-
982
- knownServerReferences.set(newFn, {
983
- id: reference.id,
984
- bound: boundPromise
440
+ var args = ArraySlice.call(arguments, 1),
441
+ boundPromise = null;
442
+ boundPromise =
443
+ null !== reference.bound
444
+ ? Promise.resolve(reference.bound).then(function (boundArgs) {
445
+ return boundArgs.concat(args);
446
+ })
447
+ : Promise.resolve(args);
448
+ Object.defineProperties(newFn, {
449
+ $$FORM_ACTION: { value: this.$$FORM_ACTION },
450
+ $$IS_SIGNATURE_EQUAL: { value: isSignatureEqual },
451
+ bind: { value: bind }
985
452
  });
453
+ knownServerReferences.set(newFn, { id: reference.id, bound: boundPromise });
986
454
  }
987
-
988
455
  return newFn;
989
456
  }
990
-
991
457
  function createServerReference$1(id, callServer, encodeFormAction) {
992
- const proxy = function () {
993
- // $FlowFixMe[method-unbinding]
994
- const args = Array.prototype.slice.call(arguments);
458
+ function proxy() {
459
+ var args = Array.prototype.slice.call(arguments);
995
460
  return callServer(id, args);
996
- };
997
-
998
- registerServerReference(proxy, {
999
- id,
1000
- bound: null
1001
- }, encodeFormAction);
461
+ }
462
+ registerServerReference(proxy, { id: id, bound: null }, encodeFormAction);
1002
463
  return proxy;
1003
464
  }
1004
-
1005
- const ROW_ID = 0;
1006
- const ROW_TAG = 1;
1007
- const ROW_LENGTH = 2;
1008
- const ROW_CHUNK_BY_NEWLINE = 3;
1009
- const ROW_CHUNK_BY_LENGTH = 4;
1010
- const PENDING = 'pending';
1011
- const BLOCKED = 'blocked';
1012
- const CYCLIC = 'cyclic';
1013
- const RESOLVED_MODEL = 'resolved_model';
1014
- const RESOLVED_MODULE = 'resolved_module';
1015
- const INITIALIZED = 'fulfilled';
1016
- const ERRORED = 'rejected'; // $FlowFixMe[missing-this-annot]
1017
-
1018
465
  function Chunk(status, value, reason, response) {
1019
466
  this.status = status;
1020
467
  this.value = value;
1021
468
  this.reason = reason;
1022
469
  this._response = response;
1023
- } // We subclass Promise.prototype so that we get other methods like .catch
1024
-
1025
-
1026
- Chunk.prototype = Object.create(Promise.prototype); // TODO: This doesn't return a new Promise chain unlike the real .then
1027
-
470
+ }
471
+ Chunk.prototype = Object.create(Promise.prototype);
1028
472
  Chunk.prototype.then = function (resolve, reject) {
1029
- const chunk = this; // If we have resolved content, we try to initialize it first which
1030
- // might put us back into one of the other states.
1031
-
1032
- switch (chunk.status) {
1033
- case RESOLVED_MODEL:
1034
- initializeModelChunk(chunk);
473
+ switch (this.status) {
474
+ case "resolved_model":
475
+ initializeModelChunk(this);
1035
476
  break;
1036
-
1037
- case RESOLVED_MODULE:
1038
- initializeModuleChunk(chunk);
477
+ case "resolved_module":
478
+ initializeModuleChunk(this);
479
+ }
480
+ switch (this.status) {
481
+ case "fulfilled":
482
+ resolve(this.value);
1039
483
  break;
1040
- } // The status might have changed after initialization.
1041
-
1042
-
1043
- switch (chunk.status) {
1044
- case INITIALIZED:
1045
- resolve(chunk.value);
484
+ case "pending":
485
+ case "blocked":
486
+ case "cyclic":
487
+ resolve &&
488
+ (null === this.value && (this.value = []), this.value.push(resolve));
489
+ reject &&
490
+ (null === this.reason && (this.reason = []), this.reason.push(reject));
1046
491
  break;
1047
-
1048
- case PENDING:
1049
- case BLOCKED:
1050
- case CYCLIC:
1051
- if (resolve) {
1052
- if (chunk.value === null) {
1053
- chunk.value = [];
1054
- }
1055
-
1056
- chunk.value.push(resolve);
1057
- }
1058
-
1059
- if (reject) {
1060
- if (chunk.reason === null) {
1061
- chunk.reason = [];
1062
- }
1063
-
1064
- chunk.reason.push(reject);
1065
- }
1066
-
1067
- break;
1068
-
1069
492
  default:
1070
- if (reject) {
1071
- reject(chunk.reason);
1072
- }
1073
-
1074
- break;
493
+ reject && reject(this.reason);
1075
494
  }
1076
495
  };
1077
-
1078
496
  function readChunk(chunk) {
1079
- // If we have resolved content, we try to initialize it first which
1080
- // might put us back into one of the other states.
1081
497
  switch (chunk.status) {
1082
- case RESOLVED_MODEL:
498
+ case "resolved_model":
1083
499
  initializeModelChunk(chunk);
1084
500
  break;
1085
-
1086
- case RESOLVED_MODULE:
501
+ case "resolved_module":
1087
502
  initializeModuleChunk(chunk);
1088
- break;
1089
- } // The status might have changed after initialization.
1090
-
1091
-
503
+ }
1092
504
  switch (chunk.status) {
1093
- case INITIALIZED:
505
+ case "fulfilled":
1094
506
  return chunk.value;
1095
-
1096
- case PENDING:
1097
- case BLOCKED:
1098
- case CYCLIC:
1099
- // eslint-disable-next-line no-throw-literal
507
+ case "pending":
508
+ case "blocked":
509
+ case "cyclic":
1100
510
  throw chunk;
1101
-
1102
511
  default:
1103
512
  throw chunk.reason;
1104
513
  }
1105
514
  }
1106
-
1107
- function getRoot(response) {
1108
- const chunk = getChunk(response, 0);
1109
- return chunk;
1110
- }
1111
-
1112
- function createPendingChunk(response) {
1113
- // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
1114
- return new Chunk(PENDING, null, null, response);
1115
- }
1116
-
1117
- function createBlockedChunk(response) {
1118
- // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
1119
- return new Chunk(BLOCKED, null, null, response);
1120
- }
1121
-
1122
- function createErrorChunk(response, error) {
1123
- // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
1124
- return new Chunk(ERRORED, null, error, response);
1125
- }
1126
-
1127
515
  function wakeChunk(listeners, value) {
1128
- for (let i = 0; i < listeners.length; i++) {
1129
- const listener = listeners[i];
1130
- listener(value);
1131
- }
516
+ for (var i = 0; i < listeners.length; i++) (0, listeners[i])(value);
1132
517
  }
1133
-
1134
518
  function wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners) {
1135
519
  switch (chunk.status) {
1136
- case INITIALIZED:
520
+ case "fulfilled":
1137
521
  wakeChunk(resolveListeners, chunk.value);
1138
522
  break;
1139
-
1140
- case PENDING:
1141
- case BLOCKED:
1142
- case CYCLIC:
523
+ case "pending":
524
+ case "blocked":
525
+ case "cyclic":
1143
526
  chunk.value = resolveListeners;
1144
527
  chunk.reason = rejectListeners;
1145
528
  break;
1146
-
1147
- case ERRORED:
1148
- if (rejectListeners) {
1149
- wakeChunk(rejectListeners, chunk.reason);
1150
- }
1151
-
1152
- break;
529
+ case "rejected":
530
+ rejectListeners && wakeChunk(rejectListeners, chunk.reason);
1153
531
  }
1154
532
  }
1155
-
1156
533
  function triggerErrorOnChunk(chunk, error) {
1157
- if (chunk.status !== PENDING && chunk.status !== BLOCKED) {
1158
-
1159
- return;
534
+ if ("pending" === chunk.status || "blocked" === chunk.status) {
535
+ var listeners = chunk.reason;
536
+ chunk.status = "rejected";
537
+ chunk.reason = error;
538
+ null !== listeners && wakeChunk(listeners, error);
1160
539
  }
1161
-
1162
- const listeners = chunk.reason;
1163
- const erroredChunk = chunk;
1164
- erroredChunk.status = ERRORED;
1165
- erroredChunk.reason = error;
1166
-
1167
- if (listeners !== null) {
1168
- wakeChunk(listeners, error);
1169
- }
1170
- }
1171
-
1172
- function createResolvedModelChunk(response, value) {
1173
- // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
1174
- return new Chunk(RESOLVED_MODEL, value, null, response);
1175
540
  }
1176
-
1177
- function createResolvedModuleChunk(response, value) {
1178
- // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
1179
- return new Chunk(RESOLVED_MODULE, value, null, response);
1180
- }
1181
-
1182
- function createInitializedTextChunk(response, value) {
1183
- // $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
1184
- return new Chunk(INITIALIZED, value, null, response);
1185
- }
1186
-
1187
- function resolveModelChunk(chunk, value) {
1188
- if (chunk.status !== PENDING) {
1189
-
1190
- return;
1191
- }
1192
-
1193
- const resolveListeners = chunk.value;
1194
- const rejectListeners = chunk.reason;
1195
- const resolvedChunk = chunk;
1196
- resolvedChunk.status = RESOLVED_MODEL;
1197
- resolvedChunk.value = value;
1198
-
1199
- if (resolveListeners !== null) {
1200
- // This is unfortunate that we're reading this eagerly if
1201
- // we already have listeners attached since they might no
1202
- // longer be rendered or might not be the highest pri.
1203
- initializeModelChunk(resolvedChunk); // The status might have changed after initialization.
1204
-
1205
- wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners);
1206
- }
1207
- }
1208
-
1209
541
  function resolveModuleChunk(chunk, value) {
1210
- if (chunk.status !== PENDING && chunk.status !== BLOCKED) {
1211
- // We already resolved. We didn't expect to see this.
1212
- return;
1213
- }
1214
-
1215
- const resolveListeners = chunk.value;
1216
- const rejectListeners = chunk.reason;
1217
- const resolvedChunk = chunk;
1218
- resolvedChunk.status = RESOLVED_MODULE;
1219
- resolvedChunk.value = value;
1220
-
1221
- if (resolveListeners !== null) {
1222
- initializeModuleChunk(resolvedChunk);
1223
- wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners);
542
+ if ("pending" === chunk.status || "blocked" === chunk.status) {
543
+ var resolveListeners = chunk.value,
544
+ rejectListeners = chunk.reason;
545
+ chunk.status = "resolved_module";
546
+ chunk.value = value;
547
+ null !== resolveListeners &&
548
+ (initializeModuleChunk(chunk),
549
+ wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners));
1224
550
  }
1225
551
  }
1226
-
1227
- let initializingChunk = null;
1228
- let initializingChunkBlockedModel = null;
1229
-
552
+ var initializingChunk = null,
553
+ initializingChunkBlockedModel = null;
1230
554
  function initializeModelChunk(chunk) {
1231
- const prevChunk = initializingChunk;
1232
- const prevBlocked = initializingChunkBlockedModel;
555
+ var prevChunk = initializingChunk,
556
+ prevBlocked = initializingChunkBlockedModel;
1233
557
  initializingChunk = chunk;
1234
558
  initializingChunkBlockedModel = null;
1235
- const resolvedModel = chunk.value; // We go to the CYCLIC state until we've fully resolved this.
1236
- // We do this before parsing in case we try to initialize the same chunk
1237
- // while parsing the model. Such as in a cyclic reference.
1238
-
1239
- const cyclicChunk = chunk;
1240
- cyclicChunk.status = CYCLIC;
1241
- cyclicChunk.value = null;
1242
- cyclicChunk.reason = null;
1243
-
559
+ var resolvedModel = chunk.value;
560
+ chunk.status = "cyclic";
561
+ chunk.value = null;
562
+ chunk.reason = null;
1244
563
  try {
1245
- const value = parseModel(chunk._response, resolvedModel);
1246
-
1247
- if (initializingChunkBlockedModel !== null && initializingChunkBlockedModel.deps > 0) {
1248
- initializingChunkBlockedModel.value = value; // We discovered new dependencies on modules that are not yet resolved.
1249
- // We have to go the BLOCKED state until they're resolved.
1250
-
1251
- const blockedChunk = chunk;
1252
- blockedChunk.status = BLOCKED;
1253
- blockedChunk.value = null;
1254
- blockedChunk.reason = null;
1255
- } else {
1256
- const resolveListeners = cyclicChunk.value;
1257
- const initializedChunk = chunk;
1258
- initializedChunk.status = INITIALIZED;
1259
- initializedChunk.value = value;
1260
-
1261
- if (resolveListeners !== null) {
1262
- wakeChunk(resolveListeners, value);
1263
- }
564
+ var value = JSON.parse(resolvedModel, chunk._response._fromJSON);
565
+ if (
566
+ null !== initializingChunkBlockedModel &&
567
+ 0 < initializingChunkBlockedModel.deps
568
+ )
569
+ (initializingChunkBlockedModel.value = value),
570
+ (chunk.status = "blocked"),
571
+ (chunk.value = null),
572
+ (chunk.reason = null);
573
+ else {
574
+ var resolveListeners = chunk.value;
575
+ chunk.status = "fulfilled";
576
+ chunk.value = value;
577
+ null !== resolveListeners && wakeChunk(resolveListeners, value);
1264
578
  }
1265
579
  } catch (error) {
1266
- const erroredChunk = chunk;
1267
- erroredChunk.status = ERRORED;
1268
- erroredChunk.reason = error;
580
+ (chunk.status = "rejected"), (chunk.reason = error);
1269
581
  } finally {
1270
- initializingChunk = prevChunk;
1271
- initializingChunkBlockedModel = prevBlocked;
1272
- }
1273
- }
1274
-
1275
- function initializeModuleChunk(chunk) {
1276
- try {
1277
- const value = requireModule(chunk.value);
1278
- const initializedChunk = chunk;
1279
- initializedChunk.status = INITIALIZED;
1280
- initializedChunk.value = value;
1281
- } catch (error) {
1282
- const erroredChunk = chunk;
1283
- erroredChunk.status = ERRORED;
1284
- erroredChunk.reason = error;
582
+ (initializingChunk = prevChunk),
583
+ (initializingChunkBlockedModel = prevBlocked);
1285
584
  }
1286
- } // Report that any missing chunks in the model is now going to throw this
1287
- // error upon read. Also notify any pending promises.
1288
-
1289
-
1290
- function reportGlobalError(response, error) {
1291
- response._chunks.forEach(chunk => {
1292
- // If this chunk was already resolved or errored, it won't
1293
- // trigger an error but if it wasn't then we need to
1294
- // because we won't be getting any new data to resolve it.
1295
- if (chunk.status === PENDING) {
1296
- triggerErrorOnChunk(chunk, error);
1297
- }
1298
- });
1299
585
  }
1300
-
1301
- function createElement(type, key, props, owner) // DEV-only
1302
- {
1303
- let element;
1304
-
1305
- {
1306
- element = {
1307
- // This tag allows us to uniquely identify this as a React Element
1308
- $$typeof: REACT_ELEMENT_TYPE,
1309
- type,
1310
- key,
1311
- ref: null,
1312
- props
1313
- };
586
+ function initializeModuleChunk(chunk) {
587
+ try {
588
+ var metadata = chunk.value,
589
+ moduleExports = __webpack_require__(metadata[0]);
590
+ if (4 === metadata.length && "function" === typeof moduleExports.then)
591
+ if ("fulfilled" === moduleExports.status)
592
+ moduleExports = moduleExports.value;
593
+ else throw moduleExports.reason;
594
+ var JSCompiler_inline_result =
595
+ "*" === metadata[2]
596
+ ? moduleExports
597
+ : "" === metadata[2]
598
+ ? moduleExports.__esModule
599
+ ? moduleExports.default
600
+ : moduleExports
601
+ : moduleExports[metadata[2]];
602
+ chunk.status = "fulfilled";
603
+ chunk.value = JSCompiler_inline_result;
604
+ } catch (error) {
605
+ (chunk.status = "rejected"), (chunk.reason = error);
1314
606
  }
1315
-
1316
- return element;
1317
607
  }
1318
-
1319
- function createLazyChunkWrapper(chunk) {
1320
- const lazyType = {
1321
- $$typeof: REACT_LAZY_TYPE,
1322
- _payload: chunk,
1323
- _init: readChunk
1324
- };
1325
-
1326
- return lazyType;
608
+ function reportGlobalError(response, error) {
609
+ response._chunks.forEach(function (chunk) {
610
+ "pending" === chunk.status && triggerErrorOnChunk(chunk, error);
611
+ });
1327
612
  }
1328
-
1329
613
  function getChunk(response, id) {
1330
- const chunks = response._chunks;
1331
- let chunk = chunks.get(id);
1332
-
1333
- if (!chunk) {
1334
- chunk = createPendingChunk(response);
1335
- chunks.set(id, chunk);
1336
- }
1337
-
614
+ var chunks = response._chunks,
615
+ chunk = chunks.get(id);
616
+ chunk ||
617
+ ((chunk = new Chunk("pending", null, null, response)),
618
+ chunks.set(id, chunk));
1338
619
  return chunk;
1339
620
  }
1340
-
1341
621
  function createModelResolver(chunk, parentObject, key, cyclic, response, map) {
1342
- let blocked;
1343
-
1344
622
  if (initializingChunkBlockedModel) {
1345
- blocked = initializingChunkBlockedModel;
1346
-
1347
- if (!cyclic) {
1348
- blocked.deps++;
1349
- }
1350
- } else {
623
+ var blocked = initializingChunkBlockedModel;
624
+ cyclic || blocked.deps++;
625
+ } else
1351
626
  blocked = initializingChunkBlockedModel = {
1352
627
  deps: cyclic ? 0 : 1,
1353
628
  value: null
1354
629
  };
1355
- }
1356
-
1357
- return value => {
1358
- parentObject[key] = map(response, value); // If this is the root object for a model reference, where `blocked.value`
1359
- // is a stale `null`, the resolved value can be used directly.
1360
-
1361
- if (key === '' && blocked.value === null) {
1362
- blocked.value = parentObject[key];
1363
- }
1364
-
630
+ return function (value) {
631
+ parentObject[key] = map(response, value);
632
+ "" === key && null === blocked.value && (blocked.value = parentObject[key]);
1365
633
  blocked.deps--;
1366
-
1367
- if (blocked.deps === 0) {
1368
- if (chunk.status !== BLOCKED) {
1369
- return;
1370
- }
1371
-
1372
- const resolveListeners = chunk.value;
1373
- const initializedChunk = chunk;
1374
- initializedChunk.status = INITIALIZED;
1375
- initializedChunk.value = blocked.value;
1376
-
1377
- if (resolveListeners !== null) {
1378
- wakeChunk(resolveListeners, blocked.value);
1379
- }
1380
- }
634
+ 0 === blocked.deps &&
635
+ "blocked" === chunk.status &&
636
+ ((value = chunk.value),
637
+ (chunk.status = "fulfilled"),
638
+ (chunk.value = blocked.value),
639
+ null !== value && wakeChunk(value, blocked.value));
1381
640
  };
1382
641
  }
1383
-
1384
642
  function createModelReject(chunk) {
1385
- return error => triggerErrorOnChunk(chunk, error);
643
+ return function (error) {
644
+ return triggerErrorOnChunk(chunk, error);
645
+ };
1386
646
  }
1387
-
1388
647
  function createServerReferenceProxy(response, metaData) {
1389
- const callServer = response._callServer;
1390
-
1391
- const proxy = function () {
1392
- // $FlowFixMe[method-unbinding]
1393
- const args = Array.prototype.slice.call(arguments);
1394
- const p = metaData.bound;
1395
-
1396
- if (!p) {
1397
- return callServer(metaData.id, args);
1398
- }
1399
-
1400
- if (p.status === INITIALIZED) {
1401
- const bound = p.value;
1402
- return callServer(metaData.id, bound.concat(args));
1403
- } // Since this is a fake Promise whose .then doesn't chain, we have to wrap it.
1404
- // TODO: Remove the wrapper once that's fixed.
1405
-
1406
-
1407
- return Promise.resolve(p).then(function (bound) {
1408
- return callServer(metaData.id, bound.concat(args));
1409
- });
1410
- };
1411
-
648
+ function proxy() {
649
+ var args = Array.prototype.slice.call(arguments),
650
+ p = metaData.bound;
651
+ return p
652
+ ? "fulfilled" === p.status
653
+ ? callServer(metaData.id, p.value.concat(args))
654
+ : Promise.resolve(p).then(function (bound) {
655
+ return callServer(metaData.id, bound.concat(args));
656
+ })
657
+ : callServer(metaData.id, args);
658
+ }
659
+ var callServer = response._callServer;
1412
660
  registerServerReference(proxy, metaData, response._encodeFormAction);
1413
661
  return proxy;
1414
662
  }
1415
-
1416
663
  function getOutlinedModel(response, id, parentObject, key, map) {
1417
- const chunk = getChunk(response, id);
1418
-
1419
- switch (chunk.status) {
1420
- case RESOLVED_MODEL:
1421
- initializeModelChunk(chunk);
1422
- break;
1423
-
1424
- case RESOLVED_MODULE:
1425
- initializeModuleChunk(chunk);
664
+ id = getChunk(response, id);
665
+ switch (id.status) {
666
+ case "resolved_model":
667
+ initializeModelChunk(id);
1426
668
  break;
1427
- } // The status might have changed after initialization.
1428
-
1429
-
1430
- switch (chunk.status) {
1431
- case INITIALIZED:
1432
- const chunkValue = map(response, chunk.value);
1433
-
1434
- return chunkValue;
1435
-
1436
- case PENDING:
1437
- case BLOCKED:
1438
- case CYCLIC:
1439
- const parentChunk = initializingChunk;
1440
- chunk.then(createModelResolver(parentChunk, parentObject, key, chunk.status === CYCLIC, response, map), createModelReject(parentChunk));
669
+ case "resolved_module":
670
+ initializeModuleChunk(id);
671
+ }
672
+ switch (id.status) {
673
+ case "fulfilled":
674
+ return map(response, id.value);
675
+ case "pending":
676
+ case "blocked":
677
+ case "cyclic":
678
+ var parentChunk = initializingChunk;
679
+ id.then(
680
+ createModelResolver(
681
+ parentChunk,
682
+ parentObject,
683
+ key,
684
+ "cyclic" === id.status,
685
+ response,
686
+ map
687
+ ),
688
+ createModelReject(parentChunk)
689
+ );
1441
690
  return null;
1442
-
1443
691
  default:
1444
- throw chunk.reason;
692
+ throw id.reason;
1445
693
  }
1446
694
  }
1447
-
1448
695
  function createMap(response, model) {
1449
696
  return new Map(model);
1450
697
  }
1451
-
1452
698
  function createSet(response, model) {
1453
699
  return new Set(model);
1454
700
  }
1455
-
1456
701
  function createFormData(response, model) {
1457
- const formData = new FormData();
1458
-
1459
- for (let i = 0; i < model.length; i++) {
1460
- formData.append(model[i][0], model[i][1]);
1461
- }
1462
-
1463
- return formData;
702
+ response = new FormData();
703
+ for (var i = 0; i < model.length; i++)
704
+ response.append(model[i][0], model[i][1]);
705
+ return response;
706
+ }
707
+ function extractIterator(response, model) {
708
+ return model[Symbol.iterator]();
1464
709
  }
1465
-
1466
710
  function createModel(response, model) {
1467
711
  return model;
1468
712
  }
1469
-
1470
713
  function parseModelString(response, parentObject, key, value) {
1471
- if (value[0] === '$') {
1472
- if (value === '$') {
1473
- // A very common symbol.
1474
- return REACT_ELEMENT_TYPE;
1475
- }
1476
-
714
+ if ("$" === value[0]) {
715
+ if ("$" === value) return REACT_ELEMENT_TYPE;
1477
716
  switch (value[1]) {
1478
- case '$':
1479
- {
1480
- // This was an escaped string value.
1481
- return value.slice(1);
1482
- }
1483
-
1484
- case 'L':
1485
- {
1486
- // Lazy node
1487
- const id = parseInt(value.slice(2), 16);
1488
- const chunk = getChunk(response, id); // We create a React.lazy wrapper around any lazy values.
1489
- // When passed into React, we'll know how to suspend on this.
1490
-
1491
- return createLazyChunkWrapper(chunk);
1492
- }
1493
-
1494
- case '@':
1495
- {
1496
- // Promise
1497
- if (value.length === 2) {
1498
- // Infinite promise that never resolves.
1499
- return new Promise(() => {});
1500
- }
1501
-
1502
- const id = parseInt(value.slice(2), 16);
1503
- const chunk = getChunk(response, id);
1504
- return chunk;
1505
- }
1506
-
1507
- case 'S':
1508
- {
1509
- // Symbol
1510
- return Symbol.for(value.slice(2));
1511
- }
1512
-
1513
- case 'F':
1514
- {
1515
- // Server Reference
1516
- const id = parseInt(value.slice(2), 16);
1517
- return getOutlinedModel(response, id, parentObject, key, createServerReferenceProxy);
1518
- }
1519
-
1520
- case 'T':
1521
- {
1522
- // Temporary Reference
1523
- const id = parseInt(value.slice(2), 16);
1524
- const temporaryReferences = response._tempRefs;
1525
-
1526
- if (temporaryReferences == null) {
1527
- throw new Error('Missing a temporary reference set but the RSC response returned a temporary reference. ' + 'Pass a temporaryReference option with the set that was used with the reply.');
1528
- }
1529
-
1530
- return readTemporaryReference(temporaryReferences, id);
1531
- }
1532
-
1533
- case 'Q':
1534
- {
1535
- // Map
1536
- const id = parseInt(value.slice(2), 16);
1537
- return getOutlinedModel(response, id, parentObject, key, createMap);
1538
- }
1539
-
1540
- case 'W':
1541
- {
1542
- // Set
1543
- const id = parseInt(value.slice(2), 16);
1544
- return getOutlinedModel(response, id, parentObject, key, createSet);
1545
- }
1546
-
1547
- case 'B':
1548
- {
1549
-
1550
- return undefined;
1551
- }
1552
-
1553
- case 'K':
1554
- {
1555
- // FormData
1556
- const id = parseInt(value.slice(2), 16);
1557
- return getOutlinedModel(response, id, parentObject, key, createFormData);
1558
- }
1559
-
1560
- case 'I':
1561
- {
1562
- // $Infinity
1563
- return Infinity;
1564
- }
1565
-
1566
- case '-':
1567
- {
1568
- // $-0 or $-Infinity
1569
- if (value === '$-0') {
1570
- return -0;
1571
- } else {
1572
- return -Infinity;
1573
- }
1574
- }
1575
-
1576
- case 'N':
1577
- {
1578
- // $NaN
1579
- return NaN;
1580
- }
1581
-
1582
- case 'u':
1583
- {
1584
- // matches "$undefined"
1585
- // Special encoding for `undefined` which can't be serialized as JSON otherwise.
1586
- return undefined;
1587
- }
1588
-
1589
- case 'D':
1590
- {
1591
- // Date
1592
- return new Date(Date.parse(value.slice(2)));
1593
- }
1594
-
1595
- case 'n':
1596
- {
1597
- // BigInt
1598
- return BigInt(value.slice(2));
1599
- }
1600
-
1601
- case 'E':
1602
-
717
+ case "$":
718
+ return value.slice(1);
719
+ case "L":
720
+ return (
721
+ (parentObject = parseInt(value.slice(2), 16)),
722
+ (response = getChunk(response, parentObject)),
723
+ { $$typeof: REACT_LAZY_TYPE, _payload: response, _init: readChunk }
724
+ );
725
+ case "@":
726
+ if (2 === value.length) return new Promise(function () {});
727
+ parentObject = parseInt(value.slice(2), 16);
728
+ return getChunk(response, parentObject);
729
+ case "S":
730
+ return Symbol.for(value.slice(2));
731
+ case "F":
732
+ return (
733
+ (value = parseInt(value.slice(2), 16)),
734
+ getOutlinedModel(
735
+ response,
736
+ value,
737
+ parentObject,
738
+ key,
739
+ createServerReferenceProxy
740
+ )
741
+ );
742
+ case "T":
743
+ parentObject = parseInt(value.slice(2), 16);
744
+ response = response._tempRefs;
745
+ if (null == response)
746
+ throw Error(
747
+ "Missing a temporary reference set but the RSC response returned a temporary reference. Pass a temporaryReference option with the set that was used with the reply."
748
+ );
749
+ if (0 > parentObject || parentObject >= response.length)
750
+ throw Error(
751
+ "The RSC response contained a reference that doesn't exist in the temporary reference set. Always pass the matching set that was used to create the reply when parsing its response."
752
+ );
753
+ return response[parentObject];
754
+ case "Q":
755
+ return (
756
+ (value = parseInt(value.slice(2), 16)),
757
+ getOutlinedModel(response, value, parentObject, key, createMap)
758
+ );
759
+ case "W":
760
+ return (
761
+ (value = parseInt(value.slice(2), 16)),
762
+ getOutlinedModel(response, value, parentObject, key, createSet)
763
+ );
764
+ case "B":
765
+ return;
766
+ case "K":
767
+ return (
768
+ (value = parseInt(value.slice(2), 16)),
769
+ getOutlinedModel(response, value, parentObject, key, createFormData)
770
+ );
771
+ case "i":
772
+ return (
773
+ (value = parseInt(value.slice(2), 16)),
774
+ getOutlinedModel(response, value, parentObject, key, extractIterator)
775
+ );
776
+ case "I":
777
+ return Infinity;
778
+ case "-":
779
+ return "$-0" === value ? -0 : -Infinity;
780
+ case "N":
781
+ return NaN;
782
+ case "u":
783
+ return;
784
+ case "D":
785
+ return new Date(Date.parse(value.slice(2)));
786
+ case "n":
787
+ return BigInt(value.slice(2));
1603
788
  default:
1604
- {
1605
- // We assume that anything else is a reference ID.
1606
- const id = parseInt(value.slice(1), 16);
1607
- return getOutlinedModel(response, id, parentObject, key, createModel);
1608
- }
789
+ return (
790
+ (value = parseInt(value.slice(1), 16)),
791
+ getOutlinedModel(response, value, parentObject, key, createModel)
792
+ );
1609
793
  }
1610
794
  }
1611
-
1612
- return value;
1613
- }
1614
-
1615
- function parseModelTuple(response, value) {
1616
- const tuple = value;
1617
-
1618
- if (tuple[0] === REACT_ELEMENT_TYPE) {
1619
- // TODO: Consider having React just directly accept these arrays as elements.
1620
- // Or even change the ReactElement type to be an array.
1621
- return createElement(tuple[1], tuple[2], tuple[3]);
1622
- }
1623
-
1624
795
  return value;
1625
796
  }
1626
-
1627
797
  function missingCall() {
1628
- throw new Error('Trying to call a function from "use server" but the callServer option ' + 'was not implemented in your router runtime.');
798
+ throw Error(
799
+ 'Trying to call a function from "use server" but the callServer option was not implemented in your router runtime.'
800
+ );
1629
801
  }
1630
-
1631
- function createResponse(bundlerConfig, moduleLoading, callServer, encodeFormAction, nonce, temporaryReferences) {
1632
- const chunks = new Map();
1633
- const response = {
802
+ function createResponse(
803
+ bundlerConfig,
804
+ moduleLoading,
805
+ callServer,
806
+ encodeFormAction,
807
+ nonce,
808
+ temporaryReferences
809
+ ) {
810
+ var chunks = new Map();
811
+ bundlerConfig = {
1634
812
  _bundlerConfig: bundlerConfig,
1635
813
  _moduleLoading: moduleLoading,
1636
- _callServer: callServer !== undefined ? callServer : missingCall,
814
+ _callServer: void 0 !== callServer ? callServer : missingCall,
1637
815
  _encodeFormAction: encodeFormAction,
1638
816
  _nonce: nonce,
1639
817
  _chunks: chunks,
1640
- _stringDecoder: createStringDecoder(),
818
+ _stringDecoder: new util.TextDecoder(),
1641
819
  _fromJSON: null,
1642
820
  _rowState: 0,
1643
821
  _rowID: 0,
@@ -1645,374 +823,248 @@ function createResponse(bundlerConfig, moduleLoading, callServer, encodeFormActi
1645
823
  _rowLength: 0,
1646
824
  _buffer: [],
1647
825
  _tempRefs: temporaryReferences
1648
- }; // Don't inline this call because it causes closure to outline the call above.
1649
-
1650
- response._fromJSON = createFromJSONCallback(response);
1651
- return response;
1652
- }
1653
-
1654
- function resolveModel(response, id, model) {
1655
- const chunks = response._chunks;
1656
- const chunk = chunks.get(id);
1657
-
1658
- if (!chunk) {
1659
- chunks.set(id, createResolvedModelChunk(response, model));
1660
- } else {
1661
- resolveModelChunk(chunk, model);
1662
- }
1663
- }
1664
-
1665
- function resolveText(response, id, text) {
1666
- const chunks = response._chunks;
1667
-
1668
- chunks.set(id, createInitializedTextChunk(response, text));
826
+ };
827
+ bundlerConfig._fromJSON = createFromJSONCallback(bundlerConfig);
828
+ return bundlerConfig;
1669
829
  }
1670
-
1671
830
  function resolveModule(response, id, model) {
1672
- const chunks = response._chunks;
1673
- const chunk = chunks.get(id);
1674
- const clientReferenceMetadata = parseModel(response, model);
1675
- const clientReference = resolveClientReference(response._bundlerConfig, clientReferenceMetadata);
1676
- prepareDestinationForModule(response._moduleLoading, response._nonce, clientReferenceMetadata); // TODO: Add an option to encode modules that are lazy loaded.
1677
- // For now we preload all modules as early as possible since it's likely
1678
- // that we'll need them.
1679
-
1680
- const promise = preloadModule(clientReference);
1681
-
1682
- if (promise) {
1683
- let blockedChunk;
1684
-
1685
- if (!chunk) {
1686
- // Technically, we should just treat promise as the chunk in this
1687
- // case. Because it'll just behave as any other promise.
1688
- blockedChunk = createBlockedChunk(response);
1689
- chunks.set(id, blockedChunk);
1690
- } else {
1691
- // This can't actually happen because we don't have any forward
1692
- // references to modules.
1693
- blockedChunk = chunk;
1694
- blockedChunk.status = BLOCKED;
1695
- }
1696
-
1697
- promise.then(() => resolveModuleChunk(blockedChunk, clientReference), error => triggerErrorOnChunk(blockedChunk, error));
1698
- } else {
1699
- if (!chunk) {
1700
- chunks.set(id, createResolvedModuleChunk(response, clientReference));
1701
- } else {
1702
- // This can't actually happen because we don't have any forward
1703
- // references to modules.
1704
- resolveModuleChunk(chunk, clientReference);
1705
- }
1706
- }
1707
- }
1708
-
1709
- function resolveErrorProd(response, id, digest) {
1710
-
1711
- const error = new Error('An error occurred in the Server Components render. The specific message is omitted in production' + ' builds to avoid leaking sensitive details. A digest property is included on this error instance which' + ' may provide additional details about the nature of the error.');
1712
- error.stack = 'Error: ' + error.message;
1713
- error.digest = digest;
1714
- const errorWithDigest = error;
1715
- const chunks = response._chunks;
1716
- const chunk = chunks.get(id);
1717
-
1718
- if (!chunk) {
1719
- chunks.set(id, createErrorChunk(response, errorWithDigest));
1720
- } else {
1721
- triggerErrorOnChunk(chunk, errorWithDigest);
1722
- }
831
+ var chunks = response._chunks,
832
+ chunk = chunks.get(id);
833
+ model = JSON.parse(model, response._fromJSON);
834
+ var clientReference = resolveClientReference(response._bundlerConfig, model);
835
+ prepareDestinationWithChunks(
836
+ response._moduleLoading,
837
+ model[1],
838
+ response._nonce
839
+ );
840
+ if ((model = preloadModule(clientReference))) {
841
+ if (chunk) {
842
+ var blockedChunk = chunk;
843
+ blockedChunk.status = "blocked";
844
+ } else
845
+ (blockedChunk = new Chunk("blocked", null, null, response)),
846
+ chunks.set(id, blockedChunk);
847
+ model.then(
848
+ function () {
849
+ return resolveModuleChunk(blockedChunk, clientReference);
850
+ },
851
+ function (error) {
852
+ return triggerErrorOnChunk(blockedChunk, error);
853
+ }
854
+ );
855
+ } else
856
+ chunk
857
+ ? resolveModuleChunk(chunk, clientReference)
858
+ : chunks.set(
859
+ id,
860
+ new Chunk("resolved_module", clientReference, null, response)
861
+ );
1723
862
  }
1724
-
1725
- function resolveHint(response, code, model) {
1726
- const hintModel = parseModel(response, model);
1727
- dispatchHint(code, hintModel);
863
+ function createFromJSONCallback(response) {
864
+ return function (key, value) {
865
+ return "string" === typeof value
866
+ ? parseModelString(response, this, key, value)
867
+ : "object" === typeof value && null !== value
868
+ ? ((key =
869
+ value[0] === REACT_ELEMENT_TYPE
870
+ ? {
871
+ $$typeof: REACT_ELEMENT_TYPE,
872
+ type: value[1],
873
+ key: value[2],
874
+ ref: null,
875
+ props: value[3]
876
+ }
877
+ : value),
878
+ key)
879
+ : value;
880
+ };
1728
881
  }
1729
-
1730
- function processFullRow(response, id, tag, buffer, chunk) {
1731
-
1732
- const stringDecoder = response._stringDecoder;
1733
- let row = '';
1734
-
1735
- for (let i = 0; i < buffer.length; i++) {
1736
- row += readPartialStringChunk(stringDecoder, buffer[i]);
1737
- }
1738
-
1739
- row += readFinalStringChunk(stringDecoder, chunk);
1740
-
1741
- switch (tag) {
1742
- case 73
1743
- /* "I" */
1744
- :
1745
- {
1746
- resolveModule(response, id, row);
1747
- return;
1748
- }
1749
-
1750
- case 72
1751
- /* "H" */
1752
- :
1753
- {
1754
- const code = row[0];
1755
- resolveHint(response, code, row.slice(1));
1756
- return;
1757
- }
1758
-
1759
- case 69
1760
- /* "E" */
1761
- :
1762
- {
1763
- const errorInfo = JSON.parse(row);
1764
-
1765
- {
1766
- resolveErrorProd(response, id, errorInfo.digest);
1767
- }
1768
-
1769
- return;
1770
- }
1771
-
1772
- case 84
1773
- /* "T" */
1774
- :
1775
- {
1776
- resolveText(response, id, row);
1777
- return;
1778
- }
1779
-
1780
- case 68
1781
- /* "D" */
1782
- :
1783
-
1784
- case 87
1785
- /* "W" */
1786
- :
1787
- {
1788
-
1789
- throw new Error('Failed to read a RSC payload created by a development version of React ' + 'on the server while using a production version on the client. Always use ' + 'matching versions on the server and the client.');
1790
- }
1791
-
1792
- case 82
1793
- /* "R" */
1794
- :
1795
- // Fallthrough
1796
-
1797
- case 114
1798
- /* "r" */
1799
- :
1800
- // Fallthrough
1801
-
1802
- case 88
1803
- /* "X" */
1804
- :
1805
- // Fallthrough
1806
-
1807
- case 120
1808
- /* "x" */
1809
- :
1810
- // Fallthrough
1811
-
1812
- case 67
1813
- /* "C" */
1814
- :
1815
- // Fallthrough
1816
-
1817
- case 80
1818
- /* "P" */
1819
- :
1820
- // Fallthrough
1821
-
1822
- default:
1823
- /* """ "{" "[" "t" "f" "n" "0" - "9" */
1824
- {
1825
- // We assume anything else is JSON.
1826
- resolveModel(response, id, row);
1827
- return;
1828
- }
1829
- }
882
+ function noServerCall() {
883
+ throw Error(
884
+ "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."
885
+ );
1830
886
  }
1831
-
1832
- function processBinaryChunk(response, chunk) {
1833
- let i = 0;
1834
- let rowState = response._rowState;
1835
- let rowID = response._rowID;
1836
- let rowTag = response._rowTag;
1837
- let rowLength = response._rowLength;
1838
- const buffer = response._buffer;
1839
- const chunkLength = chunk.length;
1840
-
1841
- while (i < chunkLength) {
1842
- let lastIdx = -1;
1843
-
1844
- switch (rowState) {
1845
- case ROW_ID:
1846
- {
1847
- const byte = chunk[i++];
1848
-
1849
- if (byte === 58
1850
- /* ":" */
1851
- ) {
1852
- // Finished the rowID, next we'll parse the tag.
1853
- rowState = ROW_TAG;
1854
- } else {
1855
- rowID = rowID << 4 | (byte > 96 ? byte - 87 : byte - 48);
1856
- }
1857
-
887
+ exports.createFromNodeStream = function (stream, ssrManifest, options) {
888
+ var response = createResponse(
889
+ ssrManifest.moduleMap,
890
+ ssrManifest.moduleLoading,
891
+ noServerCall,
892
+ options ? options.encodeFormAction : void 0,
893
+ options && "string" === typeof options.nonce ? options.nonce : void 0,
894
+ void 0
895
+ );
896
+ stream.on("data", function (chunk) {
897
+ for (
898
+ var i = 0,
899
+ rowState = response._rowState,
900
+ rowID = response._rowID,
901
+ rowTag = response._rowTag,
902
+ rowLength = response._rowLength,
903
+ buffer = response._buffer,
904
+ chunkLength = chunk.length;
905
+ i < chunkLength;
906
+
907
+ ) {
908
+ var lastIdx = -1;
909
+ switch (rowState) {
910
+ case 0:
911
+ lastIdx = chunk[i++];
912
+ 58 === lastIdx
913
+ ? (rowState = 1)
914
+ : (rowID =
915
+ (rowID << 4) | (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1858
916
  continue;
1859
- }
1860
-
1861
- case ROW_TAG:
1862
- {
1863
- const resolvedRowTag = chunk[i];
1864
-
1865
- if (resolvedRowTag === 84
1866
- /* "T" */
1867
- || enableBinaryFlight
1868
- /* "V" */
1869
- ) {
1870
- rowTag = resolvedRowTag;
1871
- rowState = ROW_LENGTH;
1872
- i++;
1873
- } else if (resolvedRowTag > 64 && resolvedRowTag < 91 ||
1874
- /* "A"-"Z" */
1875
- resolvedRowTag === 114
1876
- /* "r" */
1877
- || resolvedRowTag === 120
1878
- /* "x" */
1879
- ) {
1880
- rowTag = resolvedRowTag;
1881
- rowState = ROW_CHUNK_BY_NEWLINE;
1882
- i++;
1883
- } else {
1884
- rowTag = 0;
1885
- rowState = ROW_CHUNK_BY_NEWLINE; // This was an unknown tag so it was probably part of the data.
1886
- }
1887
-
917
+ case 1:
918
+ rowState = chunk[i];
919
+ 84 === rowState
920
+ ? ((rowTag = rowState), (rowState = 2), i++)
921
+ : (64 < rowState && 91 > rowState) ||
922
+ 114 === rowState ||
923
+ 120 === rowState
924
+ ? ((rowTag = rowState), (rowState = 3), i++)
925
+ : ((rowTag = 0), (rowState = 3));
1888
926
  continue;
1889
- }
1890
-
1891
- case ROW_LENGTH:
1892
- {
1893
- const byte = chunk[i++];
1894
-
1895
- if (byte === 44
1896
- /* "," */
1897
- ) {
1898
- // Finished the rowLength, next we'll buffer up to that length.
1899
- rowState = ROW_CHUNK_BY_LENGTH;
1900
- } else {
1901
- rowLength = rowLength << 4 | (byte > 96 ? byte - 87 : byte - 48);
1902
- }
1903
-
927
+ case 2:
928
+ lastIdx = chunk[i++];
929
+ 44 === lastIdx
930
+ ? (rowState = 4)
931
+ : (rowLength =
932
+ (rowLength << 4) |
933
+ (96 < lastIdx ? lastIdx - 87 : lastIdx - 48));
1904
934
  continue;
1905
- }
1906
-
1907
- case ROW_CHUNK_BY_NEWLINE:
1908
- {
1909
- // We're looking for a newline
1910
- lastIdx = chunk.indexOf(10
1911
- /* "\n" */
1912
- , i);
1913
- break;
1914
- }
1915
-
1916
- case ROW_CHUNK_BY_LENGTH:
1917
- {
1918
- // We're looking for the remaining byte length
1919
- lastIdx = i + rowLength;
1920
-
1921
- if (lastIdx > chunk.length) {
1922
- lastIdx = -1;
1923
- }
1924
-
935
+ case 3:
936
+ lastIdx = chunk.indexOf(10, i);
1925
937
  break;
938
+ case 4:
939
+ (lastIdx = i + rowLength), lastIdx > chunk.length && (lastIdx = -1);
940
+ }
941
+ var offset = chunk.byteOffset + i;
942
+ if (-1 < lastIdx) {
943
+ rowLength = new Uint8Array(chunk.buffer, offset, lastIdx - i);
944
+ i = rowTag;
945
+ offset = response._stringDecoder;
946
+ rowTag = "";
947
+ for (var i$jscomp$0 = 0; i$jscomp$0 < buffer.length; i$jscomp$0++)
948
+ rowTag += offset.decode(buffer[i$jscomp$0], decoderOptions);
949
+ rowTag += offset.decode(rowLength);
950
+ switch (i) {
951
+ case 73:
952
+ resolveModule(response, rowID, rowTag);
953
+ break;
954
+ case 72:
955
+ rowID = rowTag[0];
956
+ rowTag = rowTag.slice(1);
957
+ rowTag = JSON.parse(rowTag, response._fromJSON);
958
+ rowLength = ReactDOMSharedInternals.d;
959
+ switch (rowID) {
960
+ case "D":
961
+ rowLength.D(rowTag);
962
+ break;
963
+ case "C":
964
+ "string" === typeof rowTag
965
+ ? rowLength.C(rowTag)
966
+ : rowLength.C(rowTag[0], rowTag[1]);
967
+ break;
968
+ case "L":
969
+ rowID = rowTag[0];
970
+ i = rowTag[1];
971
+ 3 === rowTag.length
972
+ ? rowLength.L(rowID, i, rowTag[2])
973
+ : rowLength.L(rowID, i);
974
+ break;
975
+ case "m":
976
+ "string" === typeof rowTag
977
+ ? rowLength.m(rowTag)
978
+ : rowLength.m(rowTag[0], rowTag[1]);
979
+ break;
980
+ case "X":
981
+ "string" === typeof rowTag
982
+ ? rowLength.X(rowTag)
983
+ : rowLength.X(rowTag[0], rowTag[1]);
984
+ break;
985
+ case "S":
986
+ "string" === typeof rowTag
987
+ ? rowLength.S(rowTag)
988
+ : rowLength.S(
989
+ rowTag[0],
990
+ 0 === rowTag[1] ? void 0 : rowTag[1],
991
+ 3 === rowTag.length ? rowTag[2] : void 0
992
+ );
993
+ break;
994
+ case "M":
995
+ "string" === typeof rowTag
996
+ ? rowLength.M(rowTag)
997
+ : rowLength.M(rowTag[0], rowTag[1]);
998
+ }
999
+ break;
1000
+ case 69:
1001
+ rowTag = JSON.parse(rowTag);
1002
+ rowLength = rowTag.digest;
1003
+ rowTag = Error(
1004
+ "An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error."
1005
+ );
1006
+ rowTag.stack = "Error: " + rowTag.message;
1007
+ rowTag.digest = rowLength;
1008
+ rowLength = response._chunks;
1009
+ (i = rowLength.get(rowID))
1010
+ ? triggerErrorOnChunk(i, rowTag)
1011
+ : rowLength.set(
1012
+ rowID,
1013
+ new Chunk("rejected", null, rowTag, response)
1014
+ );
1015
+ break;
1016
+ case 84:
1017
+ response._chunks.set(
1018
+ rowID,
1019
+ new Chunk("fulfilled", rowTag, null, response)
1020
+ );
1021
+ break;
1022
+ case 68:
1023
+ case 87:
1024
+ throw Error(
1025
+ "Failed to read a RSC payload created by a development version of React on the server while using a production version on the client. Always use matching versions on the server and the client."
1026
+ );
1027
+ default:
1028
+ (rowLength = response._chunks),
1029
+ (i = rowLength.get(rowID))
1030
+ ? ((rowID = i),
1031
+ "pending" === rowID.status &&
1032
+ ((rowLength = rowID.value),
1033
+ (i = rowID.reason),
1034
+ (rowID.status = "resolved_model"),
1035
+ (rowID.value = rowTag),
1036
+ null !== rowLength &&
1037
+ (initializeModelChunk(rowID),
1038
+ wakeChunkIfInitialized(rowID, rowLength, i))))
1039
+ : rowLength.set(
1040
+ rowID,
1041
+ new Chunk("resolved_model", rowTag, null, response)
1042
+ );
1926
1043
  }
1927
- }
1928
-
1929
- const offset = chunk.byteOffset + i;
1930
-
1931
- if (lastIdx > -1) {
1932
- // We found the last chunk of the row
1933
- const length = lastIdx - i;
1934
- const lastChunk = new Uint8Array(chunk.buffer, offset, length);
1935
- processFullRow(response, rowID, rowTag, buffer, lastChunk); // Reset state machine for a new row
1936
-
1937
- i = lastIdx;
1938
-
1939
- if (rowState === ROW_CHUNK_BY_NEWLINE) {
1940
- // If we're trailing by a newline we need to skip it.
1941
- i++;
1044
+ i = lastIdx;
1045
+ 3 === rowState && i++;
1046
+ rowLength = rowID = rowTag = rowState = 0;
1047
+ buffer.length = 0;
1048
+ } else {
1049
+ chunk = new Uint8Array(chunk.buffer, offset, chunk.byteLength - i);
1050
+ buffer.push(chunk);
1051
+ rowLength -= chunk.byteLength;
1052
+ break;
1942
1053
  }
1943
-
1944
- rowState = ROW_ID;
1945
- rowTag = 0;
1946
- rowID = 0;
1947
- rowLength = 0;
1948
- buffer.length = 0;
1949
- } else {
1950
- // The rest of this row is in a future chunk. We stash the rest of the
1951
- // current chunk until we can process the full row.
1952
- const length = chunk.byteLength - i;
1953
- const remainingSlice = new Uint8Array(chunk.buffer, offset, length);
1954
- buffer.push(remainingSlice); // Update how many bytes we're still waiting for. If we're looking for
1955
- // a newline, this doesn't hurt since we'll just ignore it.
1956
-
1957
- rowLength -= remainingSlice.byteLength;
1958
- break;
1959
- }
1960
- }
1961
-
1962
- response._rowState = rowState;
1963
- response._rowID = rowID;
1964
- response._rowTag = rowTag;
1965
- response._rowLength = rowLength;
1966
- }
1967
-
1968
- function parseModel(response, json) {
1969
- return JSON.parse(json, response._fromJSON);
1970
- }
1971
-
1972
- function createFromJSONCallback(response) {
1973
- // $FlowFixMe[missing-this-annot]
1974
- return function (key, value) {
1975
- if (typeof value === 'string') {
1976
- // We can't use .bind here because we need the "this" value.
1977
- return parseModelString(response, this, key, value);
1978
- }
1979
-
1980
- if (typeof value === 'object' && value !== null) {
1981
- return parseModelTuple(response, value);
1982
1054
  }
1983
-
1984
- return value;
1985
- };
1986
- }
1987
-
1988
- function close(response) {
1989
- // In case there are any remaining unresolved chunks, they won't
1990
- // be resolved now. So we need to issue an error to those.
1991
- // Ideally we should be able to early bail out if we kept a
1992
- // ref count of pending chunks.
1993
- reportGlobalError(response, new Error('Connection closed.'));
1994
- }
1995
-
1996
- function noServerCall() {
1997
- throw new Error('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.');
1998
- }
1999
-
2000
- function createServerReference(id, callServer) {
2001
- return createServerReference$1(id, noServerCall);
2002
- }
2003
-
2004
- function createFromNodeStream(stream, ssrManifest, options) {
2005
- const response = createResponse(ssrManifest.moduleMap, ssrManifest.moduleLoading, noServerCall, options ? options.encodeFormAction : undefined, options && typeof options.nonce === 'string' ? options.nonce : undefined, undefined // TODO: If encodeReply is supported, this should support temporaryReferences
2006
- );
2007
- stream.on('data', chunk => {
2008
- processBinaryChunk(response, chunk);
1055
+ response._rowState = rowState;
1056
+ response._rowID = rowID;
1057
+ response._rowTag = rowTag;
1058
+ response._rowLength = rowLength;
2009
1059
  });
2010
- stream.on('error', error => {
1060
+ stream.on("error", function (error) {
2011
1061
  reportGlobalError(response, error);
2012
1062
  });
2013
- stream.on('end', () => close(response));
2014
- return getRoot(response);
2015
- }
2016
-
2017
- exports.createFromNodeStream = createFromNodeStream;
2018
- exports.createServerReference = createServerReference;
1063
+ stream.on("end", function () {
1064
+ reportGlobalError(response, Error("Connection closed."));
1065
+ });
1066
+ return getChunk(response, 0);
1067
+ };
1068
+ exports.createServerReference = function (id) {
1069
+ return createServerReference$1(id, noServerCall);
1070
+ };