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