react-server-dom-webpack 18.3.0-next-5dd90c562-20230502 → 19.0.0-beta-94eed63c49-20240425
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 +1893 -1200
- package/cjs/react-server-dom-webpack-client.browser.production.js +931 -0
- package/cjs/react-server-dom-webpack-client.edge.development.js +1888 -241
- package/cjs/react-server-dom-webpack-client.edge.production.js +1093 -0
- package/cjs/react-server-dom-webpack-client.node.development.js +1876 -259
- package/cjs/react-server-dom-webpack-client.node.production.js +1070 -0
- package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +1833 -212
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +1049 -0
- package/cjs/react-server-dom-webpack-node-register.js +59 -10
- package/cjs/react-server-dom-webpack-plugin.js +389 -11
- package/cjs/react-server-dom-webpack-server.browser.development.js +2187 -937
- package/cjs/react-server-dom-webpack-server.browser.production.js +1935 -0
- package/cjs/react-server-dom-webpack-server.edge.development.js +2183 -941
- package/cjs/react-server-dom-webpack-server.edge.production.js +1956 -0
- package/cjs/react-server-dom-webpack-server.node.development.js +2169 -929
- package/cjs/react-server-dom-webpack-server.node.production.js +2083 -0
- package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +2116 -881
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +2051 -0
- 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} +20 -13
- package/package.json +8 -15
- 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 -34
- package/cjs/react-server-dom-webpack-client.edge.production.min.js +0 -28
- package/cjs/react-server-dom-webpack-client.node.production.min.js +0 -28
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +0 -26
- package/cjs/react-server-dom-webpack-server.browser.production.min.js +0 -62
- package/cjs/react-server-dom-webpack-server.edge.production.min.js +0 -62
- package/cjs/react-server-dom-webpack-server.node.production.min.js +0 -67
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +0 -65
- package/umd/react-server-dom-webpack-client.browser.development.js +0 -1731
- package/umd/react-server-dom-webpack-client.browser.production.min.js +0 -29
- package/umd/react-server-dom-webpack-server.browser.development.js +0 -2904
- package/umd/react-server-dom-webpack-server.browser.production.min.js +0 -51
@@ -17,6 +17,9 @@ if (process.env.NODE_ENV !== "production") {
|
|
17
17
|
var ReactDOM = require('react-dom');
|
18
18
|
var React = require('react');
|
19
19
|
|
20
|
+
// -----------------------------------------------------------------------------
|
21
|
+
var enableBinaryFlight = false;
|
22
|
+
|
20
23
|
function createStringDecoder() {
|
21
24
|
return new TextDecoder();
|
22
25
|
}
|
@@ -30,15 +33,66 @@ function readFinalStringChunk(decoder, buffer) {
|
|
30
33
|
return decoder.decode(buffer);
|
31
34
|
}
|
32
35
|
|
33
|
-
|
34
|
-
|
36
|
+
var badgeFormat = '%c%s%c '; // Same badge styling as DevTools.
|
37
|
+
|
38
|
+
var badgeStyle = // We use a fixed background if light-dark is not supported, otherwise
|
39
|
+
// we use a transparent background.
|
40
|
+
'background: #e6e6e6;' + 'background: light-dark(rgba(0,0,0,0.1), rgba(255,255,255,0.25));' + 'color: #000000;' + 'color: light-dark(#000000, #ffffff);' + 'border-radius: 2px';
|
41
|
+
var resetStyle = '';
|
42
|
+
var pad = ' ';
|
43
|
+
function printToConsole(methodName, args, badgeName) {
|
44
|
+
var offset = 0;
|
45
|
+
|
46
|
+
switch (methodName) {
|
47
|
+
case 'dir':
|
48
|
+
case 'dirxml':
|
49
|
+
case 'groupEnd':
|
50
|
+
case 'table':
|
51
|
+
{
|
52
|
+
// These methods cannot be colorized because they don't take a formatting string.
|
53
|
+
// eslint-disable-next-line react-internal/no-production-logging
|
54
|
+
console[methodName].apply(console, args);
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
|
58
|
+
case 'assert':
|
59
|
+
{
|
60
|
+
// assert takes formatting options as the second argument.
|
61
|
+
offset = 1;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
var newArgs = args.slice(0);
|
66
|
+
|
67
|
+
if (typeof newArgs[offset] === 'string') {
|
68
|
+
newArgs.splice(offset, 1, badgeFormat + newArgs[offset], badgeStyle, pad + badgeName + pad, resetStyle);
|
69
|
+
} else {
|
70
|
+
newArgs.splice(offset, 0, badgeFormat, badgeStyle, pad + badgeName + pad, resetStyle);
|
71
|
+
} // eslint-disable-next-line react-internal/no-production-logging
|
72
|
+
|
73
|
+
|
74
|
+
console[methodName].apply(console, newArgs);
|
75
|
+
return;
|
76
|
+
}
|
77
|
+
|
78
|
+
// This is the parsed shape of the wire format which is why it is
|
79
|
+
// condensed to only the essentialy information
|
80
|
+
var ID = 0;
|
81
|
+
var CHUNKS = 1;
|
82
|
+
var NAME = 2; // export const ASYNC = 3;
|
83
|
+
// This logic is correct because currently only include the 4th tuple member
|
84
|
+
// when the module is async. If that changes we will need to actually assert
|
85
|
+
// the value is true. We don't index into the 4th slot because flow does not
|
86
|
+
// like the potential out of bounds access
|
87
|
+
|
88
|
+
function isAsyncImport(metadata) {
|
89
|
+
return metadata.length === 4;
|
35
90
|
}
|
36
91
|
|
37
|
-
// eslint-disable-next-line no-unused-vars
|
38
92
|
function resolveClientReference(bundlerConfig, metadata) {
|
39
93
|
if (bundlerConfig) {
|
40
|
-
var moduleExports = bundlerConfig[metadata
|
41
|
-
var resolvedModuleData = moduleExports[metadata
|
94
|
+
var moduleExports = bundlerConfig[metadata[ID]];
|
95
|
+
var resolvedModuleData = moduleExports[metadata[NAME]];
|
42
96
|
var name;
|
43
97
|
|
44
98
|
if (resolvedModuleData) {
|
@@ -49,18 +103,19 @@ function resolveClientReference(bundlerConfig, metadata) {
|
|
49
103
|
resolvedModuleData = moduleExports['*'];
|
50
104
|
|
51
105
|
if (!resolvedModuleData) {
|
52
|
-
throw new Error('Could not find the module "' + metadata
|
106
|
+
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.');
|
53
107
|
}
|
54
108
|
|
55
|
-
name = metadata
|
109
|
+
name = metadata[NAME];
|
56
110
|
}
|
57
111
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
112
|
+
if (isAsyncImport(metadata)) {
|
113
|
+
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1
|
114
|
+
/* async */
|
115
|
+
];
|
116
|
+
} else {
|
117
|
+
return [resolvedModuleData.id, resolvedModuleData.chunks, name];
|
118
|
+
}
|
64
119
|
}
|
65
120
|
|
66
121
|
return metadata;
|
@@ -70,7 +125,31 @@ function resolveClientReference(bundlerConfig, metadata) {
|
|
70
125
|
// replicate it in user space. null means that it has already loaded.
|
71
126
|
|
72
127
|
var chunkCache = new Map();
|
73
|
-
|
128
|
+
|
129
|
+
function requireAsyncModule(id) {
|
130
|
+
// We've already loaded all the chunks. We can require the module.
|
131
|
+
var promise = __webpack_require__(id);
|
132
|
+
|
133
|
+
if (typeof promise.then !== 'function') {
|
134
|
+
// This wasn't a promise after all.
|
135
|
+
return null;
|
136
|
+
} else if (promise.status === 'fulfilled') {
|
137
|
+
// This module was already resolved earlier.
|
138
|
+
return null;
|
139
|
+
} else {
|
140
|
+
// Instrument the Promise to stash the result.
|
141
|
+
promise.then(function (value) {
|
142
|
+
var fulfilledThenable = promise;
|
143
|
+
fulfilledThenable.status = 'fulfilled';
|
144
|
+
fulfilledThenable.value = value;
|
145
|
+
}, function (reason) {
|
146
|
+
var rejectedThenable = promise;
|
147
|
+
rejectedThenable.status = 'rejected';
|
148
|
+
rejectedThenable.reason = reason;
|
149
|
+
});
|
150
|
+
return promise;
|
151
|
+
}
|
152
|
+
}
|
74
153
|
|
75
154
|
function ignoreReject() {// We rely on rejected promises to be handled by another listener.
|
76
155
|
} // Start preloading the modules since we might need them soon.
|
@@ -78,16 +157,17 @@ function ignoreReject() {// We rely on rejected promises to be handled by anothe
|
|
78
157
|
|
79
158
|
|
80
159
|
function preloadModule(metadata) {
|
81
|
-
var chunks = metadata
|
160
|
+
var chunks = metadata[CHUNKS];
|
82
161
|
var promises = [];
|
162
|
+
var i = 0;
|
83
163
|
|
84
|
-
|
85
|
-
var chunkId = chunks[i];
|
164
|
+
while (i < chunks.length) {
|
165
|
+
var chunkId = chunks[i++];
|
166
|
+
var chunkFilename = chunks[i++];
|
86
167
|
var entry = chunkCache.get(chunkId);
|
87
168
|
|
88
169
|
if (entry === undefined) {
|
89
|
-
var thenable =
|
90
|
-
|
170
|
+
var thenable = loadChunk(chunkId, chunkFilename);
|
91
171
|
promises.push(thenable); // $FlowFixMe[method-unbinding]
|
92
172
|
|
93
173
|
var resolve = chunkCache.set.bind(chunkCache, chunkId, null);
|
@@ -98,30 +178,13 @@ function preloadModule(metadata) {
|
|
98
178
|
}
|
99
179
|
}
|
100
180
|
|
101
|
-
if (metadata
|
102
|
-
|
103
|
-
|
104
|
-
if (existingPromise) {
|
105
|
-
if (existingPromise.status === 'fulfilled') {
|
106
|
-
return null;
|
107
|
-
}
|
108
|
-
|
109
|
-
return existingPromise;
|
181
|
+
if (isAsyncImport(metadata)) {
|
182
|
+
if (promises.length === 0) {
|
183
|
+
return requireAsyncModule(metadata[ID]);
|
110
184
|
} else {
|
111
|
-
|
112
|
-
return
|
113
|
-
});
|
114
|
-
modulePromise.then(function (value) {
|
115
|
-
var fulfilledThenable = modulePromise;
|
116
|
-
fulfilledThenable.status = 'fulfilled';
|
117
|
-
fulfilledThenable.value = value;
|
118
|
-
}, function (reason) {
|
119
|
-
var rejectedThenable = modulePromise;
|
120
|
-
rejectedThenable.status = 'rejected';
|
121
|
-
rejectedThenable.reason = reason;
|
185
|
+
return Promise.all(promises).then(function () {
|
186
|
+
return requireAsyncModule(metadata[ID]);
|
122
187
|
});
|
123
|
-
asyncModuleCache.set(metadata.id, modulePromise);
|
124
|
-
return modulePromise;
|
125
188
|
}
|
126
189
|
} else if (promises.length > 0) {
|
127
190
|
return Promise.all(promises);
|
@@ -132,115 +195,249 @@ function preloadModule(metadata) {
|
|
132
195
|
// Increase priority if necessary.
|
133
196
|
|
134
197
|
function requireModule(metadata) {
|
135
|
-
var moduleExports;
|
198
|
+
var moduleExports = __webpack_require__(metadata[ID]);
|
136
199
|
|
137
|
-
if (metadata
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
if (promise.status === 'fulfilled') {
|
143
|
-
moduleExports = promise.value;
|
200
|
+
if (isAsyncImport(metadata)) {
|
201
|
+
if (typeof moduleExports.then !== 'function') ; else if (moduleExports.status === 'fulfilled') {
|
202
|
+
// This Promise should've been instrumented by preloadModule.
|
203
|
+
moduleExports = moduleExports.value;
|
144
204
|
} else {
|
145
|
-
throw
|
205
|
+
throw moduleExports.reason;
|
146
206
|
}
|
147
|
-
} else {
|
148
|
-
moduleExports = __webpack_require__(metadata.id);
|
149
207
|
}
|
150
208
|
|
151
|
-
if (metadata
|
209
|
+
if (metadata[NAME] === '*') {
|
152
210
|
// This is a placeholder value that represents that the caller imported this
|
153
211
|
// as a CommonJS module as is.
|
154
212
|
return moduleExports;
|
155
213
|
}
|
156
214
|
|
157
|
-
if (metadata
|
215
|
+
if (metadata[NAME] === '') {
|
158
216
|
// This is a placeholder value that represents that the caller accessed the
|
159
217
|
// default property of this if it was an ESM interop module.
|
160
218
|
return moduleExports.__esModule ? moduleExports.default : moduleExports;
|
161
219
|
}
|
162
220
|
|
163
|
-
return moduleExports[metadata
|
221
|
+
return moduleExports[metadata[NAME]];
|
222
|
+
}
|
223
|
+
|
224
|
+
var chunkMap = new Map();
|
225
|
+
/**
|
226
|
+
* We patch the chunk filename function in webpack to insert our own resolution
|
227
|
+
* of chunks that come from Flight and may not be known to the webpack runtime
|
228
|
+
*/
|
229
|
+
|
230
|
+
var webpackGetChunkFilename = __webpack_require__.u;
|
231
|
+
|
232
|
+
__webpack_require__.u = function (chunkId) {
|
233
|
+
var flightChunk = chunkMap.get(chunkId);
|
234
|
+
|
235
|
+
if (flightChunk !== undefined) {
|
236
|
+
return flightChunk;
|
237
|
+
}
|
238
|
+
|
239
|
+
return webpackGetChunkFilename(chunkId);
|
240
|
+
};
|
241
|
+
|
242
|
+
function loadChunk(chunkId, filename) {
|
243
|
+
chunkMap.set(chunkId, filename);
|
244
|
+
return __webpack_chunk_load__(chunkId);
|
164
245
|
}
|
165
246
|
|
166
|
-
var ReactDOMSharedInternals = ReactDOM.
|
247
|
+
var ReactDOMSharedInternals = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
167
248
|
|
168
249
|
// This client file is in the shared folder because it applies to both SSR and browser contexts.
|
169
|
-
var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.Dispatcher;
|
170
250
|
function dispatchHint(code, model) {
|
171
|
-
var dispatcher =
|
251
|
+
var dispatcher = ReactDOMSharedInternals.d;
|
252
|
+
/* ReactDOMCurrentDispatcher */
|
172
253
|
|
173
|
-
|
174
|
-
|
254
|
+
switch (code) {
|
255
|
+
case 'D':
|
256
|
+
{
|
257
|
+
var refined = refineModel(code, model);
|
258
|
+
var href = refined;
|
259
|
+
dispatcher.D(
|
260
|
+
/* prefetchDNS */
|
261
|
+
href);
|
262
|
+
return;
|
263
|
+
}
|
175
264
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
href = model[0];
|
180
|
-
options = model[1];
|
181
|
-
}
|
265
|
+
case 'C':
|
266
|
+
{
|
267
|
+
var _refined = refineModel(code, model);
|
182
268
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
269
|
+
if (typeof _refined === 'string') {
|
270
|
+
var _href = _refined;
|
271
|
+
dispatcher.C(
|
272
|
+
/* preconnect */
|
273
|
+
_href);
|
274
|
+
} else {
|
275
|
+
var _href2 = _refined[0];
|
276
|
+
var crossOrigin = _refined[1];
|
277
|
+
dispatcher.C(
|
278
|
+
/* preconnect */
|
279
|
+
_href2, crossOrigin);
|
189
280
|
}
|
190
281
|
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
282
|
+
return;
|
283
|
+
}
|
284
|
+
|
285
|
+
case 'L':
|
286
|
+
{
|
287
|
+
var _refined2 = refineModel(code, model);
|
288
|
+
|
289
|
+
var _href3 = _refined2[0];
|
290
|
+
var as = _refined2[1];
|
291
|
+
|
292
|
+
if (_refined2.length === 3) {
|
293
|
+
var options = _refined2[2];
|
294
|
+
dispatcher.L(
|
295
|
+
/* preload */
|
296
|
+
_href3, as, options);
|
297
|
+
} else {
|
298
|
+
dispatcher.L(
|
299
|
+
/* preload */
|
300
|
+
_href3, as);
|
196
301
|
}
|
197
302
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
303
|
+
return;
|
304
|
+
}
|
305
|
+
|
306
|
+
case 'm':
|
307
|
+
{
|
308
|
+
var _refined3 = refineModel(code, model);
|
309
|
+
|
310
|
+
if (typeof _refined3 === 'string') {
|
311
|
+
var _href4 = _refined3;
|
312
|
+
dispatcher.m(
|
313
|
+
/* preloadModule */
|
314
|
+
_href4);
|
315
|
+
} else {
|
316
|
+
var _href5 = _refined3[0];
|
317
|
+
var _options = _refined3[1];
|
318
|
+
dispatcher.m(
|
319
|
+
/* preloadModule */
|
320
|
+
_href5, _options);
|
204
321
|
}
|
205
322
|
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
323
|
+
return;
|
324
|
+
}
|
325
|
+
|
326
|
+
case 'X':
|
327
|
+
{
|
328
|
+
var _refined4 = refineModel(code, model);
|
329
|
+
|
330
|
+
if (typeof _refined4 === 'string') {
|
331
|
+
var _href6 = _refined4;
|
332
|
+
dispatcher.X(
|
333
|
+
/* preinitScript */
|
334
|
+
_href6);
|
335
|
+
} else {
|
336
|
+
var _href7 = _refined4[0];
|
337
|
+
var _options2 = _refined4[1];
|
338
|
+
dispatcher.X(
|
339
|
+
/* preinitScript */
|
340
|
+
_href7, _options2);
|
341
|
+
}
|
342
|
+
|
343
|
+
return;
|
344
|
+
}
|
345
|
+
|
346
|
+
case 'S':
|
347
|
+
{
|
348
|
+
var _refined5 = refineModel(code, model);
|
349
|
+
|
350
|
+
if (typeof _refined5 === 'string') {
|
351
|
+
var _href8 = _refined5;
|
352
|
+
dispatcher.S(
|
353
|
+
/* preinitStyle */
|
354
|
+
_href8);
|
355
|
+
} else {
|
356
|
+
var _href9 = _refined5[0];
|
357
|
+
var precedence = _refined5[1] === 0 ? undefined : _refined5[1];
|
358
|
+
|
359
|
+
var _options3 = _refined5.length === 3 ? _refined5[2] : undefined;
|
360
|
+
|
361
|
+
dispatcher.S(
|
362
|
+
/* preinitStyle */
|
363
|
+
_href9, precedence, _options3);
|
212
364
|
}
|
365
|
+
|
366
|
+
return;
|
367
|
+
}
|
368
|
+
|
369
|
+
case 'M':
|
370
|
+
{
|
371
|
+
var _refined6 = refineModel(code, model);
|
372
|
+
|
373
|
+
if (typeof _refined6 === 'string') {
|
374
|
+
var _href10 = _refined6;
|
375
|
+
dispatcher.M(
|
376
|
+
/* preinitModuleScript */
|
377
|
+
_href10);
|
378
|
+
} else {
|
379
|
+
var _href11 = _refined6[0];
|
380
|
+
var _options4 = _refined6[1];
|
381
|
+
dispatcher.M(
|
382
|
+
/* preinitModuleScript */
|
383
|
+
_href11, _options4);
|
384
|
+
}
|
385
|
+
|
386
|
+
return;
|
387
|
+
}
|
388
|
+
}
|
389
|
+
} // Flow is having trouble refining the HintModels so we help it a bit.
|
390
|
+
// This should be compiled out in the production build.
|
391
|
+
|
392
|
+
function refineModel(code, model) {
|
393
|
+
return model;
|
394
|
+
}
|
395
|
+
|
396
|
+
var ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
397
|
+
|
398
|
+
function error(format) {
|
399
|
+
{
|
400
|
+
{
|
401
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
402
|
+
args[_key2 - 1] = arguments[_key2];
|
403
|
+
}
|
404
|
+
|
405
|
+
printWarning('error', format, args);
|
213
406
|
}
|
214
407
|
}
|
215
408
|
}
|
216
409
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
var
|
222
|
-
return callServer(id, args);
|
223
|
-
};
|
410
|
+
function printWarning(level, format, args) {
|
411
|
+
// When changing this logic, you might want to also
|
412
|
+
// update consoleWithStackDev.www.js as well.
|
413
|
+
{
|
414
|
+
var stack = ReactSharedInternals.getStackAddendum();
|
224
415
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
416
|
+
if (stack !== '') {
|
417
|
+
format += '%s';
|
418
|
+
args = args.concat([stack]);
|
419
|
+
} // eslint-disable-next-line react-internal/safe-string-coercion
|
420
|
+
|
421
|
+
|
422
|
+
var argsWithFormat = args.map(function (item) {
|
423
|
+
return String(item);
|
424
|
+
}); // Careful: RN currently depends on this prefix
|
425
|
+
|
426
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
427
|
+
// breaks IE9: https://github.com/facebook/react/issues/13610
|
428
|
+
// eslint-disable-next-line react-internal/no-production-logging
|
429
|
+
|
430
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
431
|
+
}
|
230
432
|
}
|
231
433
|
|
232
|
-
|
233
|
-
|
234
|
-
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
235
|
-
// The Symbol used to tag the ReactElement-like types.
|
236
|
-
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
237
|
-
var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
|
434
|
+
var REACT_ELEMENT_TYPE = Symbol.for('react.transitional.element') ;
|
435
|
+
var REACT_CONTEXT_TYPE = Symbol.for('react.context');
|
238
436
|
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
239
437
|
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
240
438
|
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
241
439
|
var REACT_MEMO_TYPE = Symbol.for('react.memo');
|
242
440
|
var REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
243
|
-
var REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED = Symbol.for('react.default_value');
|
244
441
|
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
245
442
|
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
246
443
|
function getIteratorFn(maybeIterable) {
|
@@ -256,1399 +453,1922 @@ function getIteratorFn(maybeIterable) {
|
|
256
453
|
|
257
454
|
return null;
|
258
455
|
}
|
456
|
+
var ASYNC_ITERATOR = Symbol.asyncIterator;
|
259
457
|
|
260
|
-
var
|
261
|
-
|
262
|
-
var ContextRegistry = ReactSharedInternals.ContextRegistry;
|
263
|
-
function getOrCreateServerContext(globalName) {
|
264
|
-
if (!ContextRegistry[globalName]) {
|
265
|
-
ContextRegistry[globalName] = React.createServerContext(globalName, // $FlowFixMe[incompatible-call] function signature doesn't reflect the symbol value
|
266
|
-
REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED);
|
267
|
-
}
|
458
|
+
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
|
268
459
|
|
269
|
-
|
460
|
+
function isArray(a) {
|
461
|
+
return isArrayImpl(a);
|
270
462
|
}
|
271
463
|
|
272
|
-
var
|
273
|
-
var BLOCKED = 'blocked';
|
274
|
-
var RESOLVED_MODEL = 'resolved_model';
|
275
|
-
var RESOLVED_MODULE = 'resolved_module';
|
276
|
-
var INITIALIZED = 'fulfilled';
|
277
|
-
var ERRORED = 'rejected'; // $FlowFixMe[missing-this-annot]
|
278
|
-
|
279
|
-
function Chunk(status, value, reason, response) {
|
280
|
-
this.status = status;
|
281
|
-
this.value = value;
|
282
|
-
this.reason = reason;
|
283
|
-
this._response = response;
|
284
|
-
} // We subclass Promise.prototype so that we get other methods like .catch
|
285
|
-
|
464
|
+
var getPrototypeOf = Object.getPrototypeOf;
|
286
465
|
|
287
|
-
|
288
|
-
|
289
|
-
Chunk.prototype.then = function (resolve, reject) {
|
290
|
-
var chunk = this; // If we have resolved content, we try to initialize it first which
|
291
|
-
// might put us back into one of the other states.
|
466
|
+
// in case they error.
|
292
467
|
|
293
|
-
|
294
|
-
|
295
|
-
initializeModelChunk(chunk);
|
296
|
-
break;
|
468
|
+
var jsxPropsParents = new WeakMap();
|
469
|
+
var jsxChildrenParents = new WeakMap();
|
297
470
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
}
|
471
|
+
function isObjectPrototype(object) {
|
472
|
+
if (!object) {
|
473
|
+
return false;
|
474
|
+
}
|
302
475
|
|
476
|
+
var ObjectPrototype = Object.prototype;
|
303
477
|
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
478
|
+
if (object === ObjectPrototype) {
|
479
|
+
return true;
|
480
|
+
} // It might be an object from a different Realm which is
|
481
|
+
// still just a plain simple object.
|
308
482
|
|
309
|
-
case PENDING:
|
310
|
-
case BLOCKED:
|
311
|
-
if (resolve) {
|
312
|
-
if (chunk.value === null) {
|
313
|
-
chunk.value = [];
|
314
|
-
}
|
315
483
|
|
316
|
-
|
317
|
-
|
484
|
+
if (getPrototypeOf(object)) {
|
485
|
+
return false;
|
486
|
+
}
|
318
487
|
|
319
|
-
|
320
|
-
if (chunk.reason === null) {
|
321
|
-
chunk.reason = [];
|
322
|
-
}
|
488
|
+
var names = Object.getOwnPropertyNames(object);
|
323
489
|
|
324
|
-
|
325
|
-
|
490
|
+
for (var i = 0; i < names.length; i++) {
|
491
|
+
if (!(names[i] in ObjectPrototype)) {
|
492
|
+
return false;
|
493
|
+
}
|
494
|
+
}
|
326
495
|
|
327
|
-
|
496
|
+
return true;
|
497
|
+
}
|
328
498
|
|
329
|
-
|
330
|
-
|
331
|
-
|
499
|
+
function isSimpleObject(object) {
|
500
|
+
if (!isObjectPrototype(getPrototypeOf(object))) {
|
501
|
+
return false;
|
332
502
|
}
|
333
|
-
};
|
334
503
|
|
335
|
-
|
336
|
-
// If we have resolved content, we try to initialize it first which
|
337
|
-
// might put us back into one of the other states.
|
338
|
-
switch (chunk.status) {
|
339
|
-
case RESOLVED_MODEL:
|
340
|
-
initializeModelChunk(chunk);
|
341
|
-
break;
|
504
|
+
var names = Object.getOwnPropertyNames(object);
|
342
505
|
|
343
|
-
|
344
|
-
|
345
|
-
break;
|
346
|
-
} // The status might have changed after initialization.
|
506
|
+
for (var i = 0; i < names.length; i++) {
|
507
|
+
var descriptor = Object.getOwnPropertyDescriptor(object, names[i]);
|
347
508
|
|
509
|
+
if (!descriptor) {
|
510
|
+
return false;
|
511
|
+
}
|
348
512
|
|
349
|
-
|
350
|
-
|
351
|
-
|
513
|
+
if (!descriptor.enumerable) {
|
514
|
+
if ((names[i] === 'key' || names[i] === 'ref') && typeof descriptor.get === 'function') {
|
515
|
+
// React adds key and ref getters to props objects to issue warnings.
|
516
|
+
// Those getters will not be transferred to the client, but that's ok,
|
517
|
+
// so we'll special case them.
|
518
|
+
continue;
|
519
|
+
}
|
352
520
|
|
353
|
-
|
354
|
-
|
355
|
-
// eslint-disable-next-line no-throw-literal
|
356
|
-
throw chunk;
|
357
|
-
|
358
|
-
default:
|
359
|
-
throw chunk.reason;
|
521
|
+
return false;
|
522
|
+
}
|
360
523
|
}
|
361
|
-
}
|
362
524
|
|
363
|
-
|
364
|
-
var chunk = getChunk(response, 0);
|
365
|
-
return chunk;
|
525
|
+
return true;
|
366
526
|
}
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
return
|
527
|
+
function objectName(object) {
|
528
|
+
// $FlowFixMe[method-unbinding]
|
529
|
+
var name = Object.prototype.toString.call(object);
|
530
|
+
return name.replace(/^\[object (.*)\]$/, function (m, p0) {
|
531
|
+
return p0;
|
532
|
+
});
|
371
533
|
}
|
372
534
|
|
373
|
-
function
|
374
|
-
|
375
|
-
return
|
535
|
+
function describeKeyForErrorMessage(key) {
|
536
|
+
var encodedKey = JSON.stringify(key);
|
537
|
+
return '"' + key + '"' === encodedKey ? key : encodedKey;
|
376
538
|
}
|
377
539
|
|
378
|
-
function
|
379
|
-
|
380
|
-
|
381
|
-
|
540
|
+
function describeValueForErrorMessage(value) {
|
541
|
+
switch (typeof value) {
|
542
|
+
case 'string':
|
543
|
+
{
|
544
|
+
return JSON.stringify(value.length <= 10 ? value : value.slice(0, 10) + '...');
|
545
|
+
}
|
382
546
|
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
}
|
547
|
+
case 'object':
|
548
|
+
{
|
549
|
+
if (isArray(value)) {
|
550
|
+
return '[...]';
|
551
|
+
}
|
389
552
|
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
wakeChunk(resolveListeners, chunk.value);
|
394
|
-
break;
|
553
|
+
if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) {
|
554
|
+
return describeClientReference();
|
555
|
+
}
|
395
556
|
|
396
|
-
|
397
|
-
case BLOCKED:
|
398
|
-
chunk.value = resolveListeners;
|
399
|
-
chunk.reason = rejectListeners;
|
400
|
-
break;
|
557
|
+
var name = objectName(value);
|
401
558
|
|
402
|
-
|
403
|
-
|
404
|
-
|
559
|
+
if (name === 'Object') {
|
560
|
+
return '{...}';
|
561
|
+
}
|
562
|
+
|
563
|
+
return name;
|
405
564
|
}
|
406
565
|
|
407
|
-
|
408
|
-
|
409
|
-
|
566
|
+
case 'function':
|
567
|
+
{
|
568
|
+
if (value.$$typeof === CLIENT_REFERENCE_TAG) {
|
569
|
+
return describeClientReference();
|
570
|
+
}
|
410
571
|
|
411
|
-
|
412
|
-
if (chunk.status !== PENDING && chunk.status !== BLOCKED) {
|
413
|
-
// We already resolved. We didn't expect to see this.
|
414
|
-
return;
|
415
|
-
}
|
572
|
+
var _name = value.displayName || value.name;
|
416
573
|
|
417
|
-
|
418
|
-
|
419
|
-
erroredChunk.status = ERRORED;
|
420
|
-
erroredChunk.reason = error;
|
574
|
+
return _name ? 'function ' + _name : 'function';
|
575
|
+
}
|
421
576
|
|
422
|
-
|
423
|
-
|
577
|
+
default:
|
578
|
+
// eslint-disable-next-line react-internal/safe-string-coercion
|
579
|
+
return String(value);
|
424
580
|
}
|
425
581
|
}
|
426
582
|
|
427
|
-
function
|
428
|
-
|
429
|
-
|
430
|
-
}
|
583
|
+
function describeElementType(type) {
|
584
|
+
if (typeof type === 'string') {
|
585
|
+
return type;
|
586
|
+
}
|
431
587
|
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
}
|
588
|
+
switch (type) {
|
589
|
+
case REACT_SUSPENSE_TYPE:
|
590
|
+
return 'Suspense';
|
436
591
|
|
437
|
-
|
438
|
-
|
439
|
-
// We already resolved. We didn't expect to see this.
|
440
|
-
return;
|
592
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
593
|
+
return 'SuspenseList';
|
441
594
|
}
|
442
595
|
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
resolvedChunk.value = value;
|
596
|
+
if (typeof type === 'object') {
|
597
|
+
switch (type.$$typeof) {
|
598
|
+
case REACT_FORWARD_REF_TYPE:
|
599
|
+
return describeElementType(type.render);
|
448
600
|
|
449
|
-
|
450
|
-
|
451
|
-
// we already have listeners attached since they might no
|
452
|
-
// longer be rendered or might not be the highest pri.
|
453
|
-
initializeModelChunk(resolvedChunk); // The status might have changed after initialization.
|
601
|
+
case REACT_MEMO_TYPE:
|
602
|
+
return describeElementType(type.type);
|
454
603
|
|
455
|
-
|
604
|
+
case REACT_LAZY_TYPE:
|
605
|
+
{
|
606
|
+
var lazyComponent = type;
|
607
|
+
var payload = lazyComponent._payload;
|
608
|
+
var init = lazyComponent._init;
|
609
|
+
|
610
|
+
try {
|
611
|
+
// Lazy may contain any component type so we recursively resolve it.
|
612
|
+
return describeElementType(init(payload));
|
613
|
+
} catch (x) {}
|
614
|
+
}
|
615
|
+
}
|
456
616
|
}
|
617
|
+
|
618
|
+
return '';
|
457
619
|
}
|
458
620
|
|
459
|
-
|
460
|
-
if (chunk.status !== PENDING && chunk.status !== BLOCKED) {
|
461
|
-
// We already resolved. We didn't expect to see this.
|
462
|
-
return;
|
463
|
-
}
|
621
|
+
var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
|
464
622
|
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
resolvedChunk.status = RESOLVED_MODULE;
|
469
|
-
resolvedChunk.value = value;
|
623
|
+
function describeClientReference(ref) {
|
624
|
+
return 'client';
|
625
|
+
}
|
470
626
|
|
471
|
-
|
472
|
-
|
473
|
-
|
627
|
+
function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
628
|
+
var objKind = objectName(objectOrArray);
|
629
|
+
|
630
|
+
if (objKind !== 'Object' && objKind !== 'Array') {
|
631
|
+
return objKind;
|
474
632
|
}
|
475
|
-
}
|
476
633
|
|
477
|
-
var
|
478
|
-
var
|
634
|
+
var str = '';
|
635
|
+
var start = -1;
|
636
|
+
var length = 0;
|
479
637
|
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
638
|
+
if (isArray(objectOrArray)) {
|
639
|
+
if (jsxChildrenParents.has(objectOrArray)) {
|
640
|
+
// Print JSX Children
|
641
|
+
var type = jsxChildrenParents.get(objectOrArray);
|
642
|
+
str = '<' + describeElementType(type) + '>';
|
643
|
+
var array = objectOrArray;
|
485
644
|
|
486
|
-
|
487
|
-
|
645
|
+
for (var i = 0; i < array.length; i++) {
|
646
|
+
var value = array[i];
|
647
|
+
var substr = void 0;
|
488
648
|
|
489
|
-
|
490
|
-
|
491
|
-
|
649
|
+
if (typeof value === 'string') {
|
650
|
+
substr = value;
|
651
|
+
} else if (typeof value === 'object' && value !== null) {
|
652
|
+
substr = '{' + describeObjectForErrorMessage(value) + '}';
|
653
|
+
} else {
|
654
|
+
substr = '{' + describeValueForErrorMessage(value) + '}';
|
655
|
+
}
|
492
656
|
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
var erroredChunk = chunk;
|
504
|
-
erroredChunk.status = ERRORED;
|
505
|
-
erroredChunk.reason = error;
|
506
|
-
} finally {
|
507
|
-
initializingChunk = prevChunk;
|
508
|
-
initializingChunkBlockedModel = prevBlocked;
|
509
|
-
}
|
510
|
-
}
|
657
|
+
if ('' + i === expandedName) {
|
658
|
+
start = str.length;
|
659
|
+
length = substr.length;
|
660
|
+
str += substr;
|
661
|
+
} else if (substr.length < 15 && str.length + substr.length < 40) {
|
662
|
+
str += substr;
|
663
|
+
} else {
|
664
|
+
str += '{...}';
|
665
|
+
}
|
666
|
+
}
|
511
667
|
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
initializedChunk.value = value;
|
518
|
-
} catch (error) {
|
519
|
-
var erroredChunk = chunk;
|
520
|
-
erroredChunk.status = ERRORED;
|
521
|
-
erroredChunk.reason = error;
|
522
|
-
}
|
523
|
-
} // Report that any missing chunks in the model is now going to throw this
|
524
|
-
// error upon read. Also notify any pending promises.
|
668
|
+
str += '</' + describeElementType(type) + '>';
|
669
|
+
} else {
|
670
|
+
// Print Array
|
671
|
+
str = '[';
|
672
|
+
var _array = objectOrArray;
|
525
673
|
|
674
|
+
for (var _i = 0; _i < _array.length; _i++) {
|
675
|
+
if (_i > 0) {
|
676
|
+
str += ', ';
|
677
|
+
}
|
526
678
|
|
527
|
-
|
528
|
-
response._chunks.forEach(function (chunk) {
|
529
|
-
// If this chunk was already resolved or errored, it won't
|
530
|
-
// trigger an error but if it wasn't then we need to
|
531
|
-
// because we won't be getting any new data to resolve it.
|
532
|
-
if (chunk.status === PENDING) {
|
533
|
-
triggerErrorOnChunk(chunk, error);
|
534
|
-
}
|
535
|
-
});
|
536
|
-
}
|
679
|
+
var _value = _array[_i];
|
537
680
|
|
538
|
-
|
539
|
-
var element = {
|
540
|
-
// This tag allows us to uniquely identify this as a React Element
|
541
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
542
|
-
// Built-in properties that belong on the element
|
543
|
-
type: type,
|
544
|
-
key: key,
|
545
|
-
ref: null,
|
546
|
-
props: props,
|
547
|
-
// Record the component responsible for creating this element.
|
548
|
-
_owner: null
|
549
|
-
};
|
681
|
+
var _substr = void 0;
|
550
682
|
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
Object.defineProperty(element._store, 'validated', {
|
557
|
-
configurable: false,
|
558
|
-
enumerable: false,
|
559
|
-
writable: true,
|
560
|
-
value: true // This element has already been validated on the server.
|
683
|
+
if (typeof _value === 'object' && _value !== null) {
|
684
|
+
_substr = describeObjectForErrorMessage(_value);
|
685
|
+
} else {
|
686
|
+
_substr = describeValueForErrorMessage(_value);
|
687
|
+
}
|
561
688
|
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
}
|
689
|
+
if ('' + _i === expandedName) {
|
690
|
+
start = str.length;
|
691
|
+
length = _substr.length;
|
692
|
+
str += _substr;
|
693
|
+
} else if (_substr.length < 10 && str.length + _substr.length < 40) {
|
694
|
+
str += _substr;
|
695
|
+
} else {
|
696
|
+
str += '...';
|
697
|
+
}
|
698
|
+
}
|
699
|
+
|
700
|
+
str += ']';
|
701
|
+
}
|
702
|
+
} else {
|
703
|
+
if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
|
704
|
+
str = '<' + describeElementType(objectOrArray.type) + '/>';
|
705
|
+
} else if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) {
|
706
|
+
return describeClientReference();
|
707
|
+
} else if (jsxPropsParents.has(objectOrArray)) {
|
708
|
+
// Print JSX
|
709
|
+
var _type = jsxPropsParents.get(objectOrArray);
|
710
|
+
|
711
|
+
str = '<' + (describeElementType(_type) || '...');
|
712
|
+
var object = objectOrArray;
|
713
|
+
var names = Object.keys(object);
|
714
|
+
|
715
|
+
for (var _i2 = 0; _i2 < names.length; _i2++) {
|
716
|
+
str += ' ';
|
717
|
+
var name = names[_i2];
|
718
|
+
str += describeKeyForErrorMessage(name) + '=';
|
719
|
+
var _value2 = object[name];
|
720
|
+
|
721
|
+
var _substr2 = void 0;
|
722
|
+
|
723
|
+
if (name === expandedName && typeof _value2 === 'object' && _value2 !== null) {
|
724
|
+
_substr2 = describeObjectForErrorMessage(_value2);
|
725
|
+
} else {
|
726
|
+
_substr2 = describeValueForErrorMessage(_value2);
|
727
|
+
}
|
728
|
+
|
729
|
+
if (typeof _value2 !== 'string') {
|
730
|
+
_substr2 = '{' + _substr2 + '}';
|
731
|
+
}
|
732
|
+
|
733
|
+
if (name === expandedName) {
|
734
|
+
start = str.length;
|
735
|
+
length = _substr2.length;
|
736
|
+
str += _substr2;
|
737
|
+
} else if (_substr2.length < 10 && str.length + _substr2.length < 40) {
|
738
|
+
str += _substr2;
|
739
|
+
} else {
|
740
|
+
str += '...';
|
741
|
+
}
|
742
|
+
}
|
743
|
+
|
744
|
+
str += '>';
|
745
|
+
} else {
|
746
|
+
// Print Object
|
747
|
+
str = '{';
|
748
|
+
var _object = objectOrArray;
|
749
|
+
|
750
|
+
var _names = Object.keys(_object);
|
751
|
+
|
752
|
+
for (var _i3 = 0; _i3 < _names.length; _i3++) {
|
753
|
+
if (_i3 > 0) {
|
754
|
+
str += ', ';
|
755
|
+
}
|
756
|
+
|
757
|
+
var _name2 = _names[_i3];
|
758
|
+
str += describeKeyForErrorMessage(_name2) + ': ';
|
759
|
+
var _value3 = _object[_name2];
|
760
|
+
|
761
|
+
var _substr3 = void 0;
|
762
|
+
|
763
|
+
if (typeof _value3 === 'object' && _value3 !== null) {
|
764
|
+
_substr3 = describeObjectForErrorMessage(_value3);
|
765
|
+
} else {
|
766
|
+
_substr3 = describeValueForErrorMessage(_value3);
|
767
|
+
}
|
768
|
+
|
769
|
+
if (_name2 === expandedName) {
|
770
|
+
start = str.length;
|
771
|
+
length = _substr3.length;
|
772
|
+
str += _substr3;
|
773
|
+
} else if (_substr3.length < 10 && str.length + _substr3.length < 40) {
|
774
|
+
str += _substr3;
|
775
|
+
} else {
|
776
|
+
str += '...';
|
777
|
+
}
|
778
|
+
}
|
779
|
+
|
780
|
+
str += '}';
|
781
|
+
}
|
575
782
|
}
|
576
783
|
|
577
|
-
|
784
|
+
if (expandedName === undefined) {
|
785
|
+
return str;
|
786
|
+
}
|
787
|
+
|
788
|
+
if (start > -1 && length > 0) {
|
789
|
+
var highlight = ' '.repeat(start) + '^'.repeat(length);
|
790
|
+
return '\n ' + str + '\n ' + highlight;
|
791
|
+
}
|
792
|
+
|
793
|
+
return '\n ' + str;
|
578
794
|
}
|
579
795
|
|
580
|
-
function
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
796
|
+
function createTemporaryReferenceSet() {
|
797
|
+
return [];
|
798
|
+
}
|
799
|
+
function writeTemporaryReference(set, object) {
|
800
|
+
// We always create a new entry regardless if we've already written the same
|
801
|
+
// object. This ensures that we always generate a deterministic encoding of
|
802
|
+
// each slot in the reply for cacheability.
|
803
|
+
var newId = set.length;
|
804
|
+
set.push(object);
|
805
|
+
return newId;
|
806
|
+
}
|
807
|
+
function readTemporaryReference(set, id) {
|
808
|
+
if (id < 0 || id >= set.length) {
|
809
|
+
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.');
|
810
|
+
}
|
811
|
+
|
812
|
+
return set[id];
|
813
|
+
}
|
814
|
+
|
815
|
+
var ObjectPrototype = Object.prototype;
|
816
|
+
var knownServerReferences = new WeakMap(); // Serializable values
|
817
|
+
// Thenable<ReactServerValue>
|
818
|
+
|
819
|
+
function serializeByValueID(id) {
|
820
|
+
return '$' + id.toString(16);
|
821
|
+
}
|
822
|
+
|
823
|
+
function serializePromiseID(id) {
|
824
|
+
return '$@' + id.toString(16);
|
825
|
+
}
|
826
|
+
|
827
|
+
function serializeServerReferenceID(id) {
|
828
|
+
return '$F' + id.toString(16);
|
587
829
|
}
|
588
830
|
|
589
|
-
function
|
590
|
-
|
591
|
-
|
831
|
+
function serializeTemporaryReferenceID(id) {
|
832
|
+
return '$T' + id.toString(16);
|
833
|
+
}
|
834
|
+
|
835
|
+
function serializeFormDataReference(id) {
|
836
|
+
// Why K? F is "Function". D is "Date". What else?
|
837
|
+
return '$K' + id.toString(16);
|
838
|
+
}
|
839
|
+
|
840
|
+
function serializeNumber(number) {
|
841
|
+
if (Number.isFinite(number)) {
|
842
|
+
if (number === 0 && 1 / number === -Infinity) {
|
843
|
+
return '$-0';
|
844
|
+
} else {
|
845
|
+
return number;
|
846
|
+
}
|
847
|
+
} else {
|
848
|
+
if (number === Infinity) {
|
849
|
+
return '$Infinity';
|
850
|
+
} else if (number === -Infinity) {
|
851
|
+
return '$-Infinity';
|
852
|
+
} else {
|
853
|
+
return '$NaN';
|
854
|
+
}
|
855
|
+
}
|
856
|
+
}
|
857
|
+
|
858
|
+
function serializeUndefined() {
|
859
|
+
return '$undefined';
|
860
|
+
}
|
861
|
+
|
862
|
+
function serializeDateFromDateJSON(dateJSON) {
|
863
|
+
// JSON.stringify automatically calls Date.prototype.toJSON which calls toISOString.
|
864
|
+
// We need only tack on a $D prefix.
|
865
|
+
return '$D' + dateJSON;
|
866
|
+
}
|
867
|
+
|
868
|
+
function serializeBigInt(n) {
|
869
|
+
return '$n' + n.toString(10);
|
870
|
+
}
|
871
|
+
|
872
|
+
function serializeMapID(id) {
|
873
|
+
return '$Q' + id.toString(16);
|
874
|
+
}
|
875
|
+
|
876
|
+
function serializeSetID(id) {
|
877
|
+
return '$W' + id.toString(16);
|
878
|
+
}
|
879
|
+
|
880
|
+
function serializeIteratorID(id) {
|
881
|
+
return '$i' + id.toString(16);
|
882
|
+
}
|
883
|
+
|
884
|
+
function escapeStringValue(value) {
|
885
|
+
if (value[0] === '$') {
|
886
|
+
// We need to escape $ prefixed strings since we use those to encode
|
887
|
+
// references to IDs and as special symbol values.
|
888
|
+
return '$' + value;
|
889
|
+
} else {
|
890
|
+
return value;
|
891
|
+
}
|
892
|
+
}
|
893
|
+
|
894
|
+
function processReply(root, formFieldPrefix, temporaryReferences, resolve, reject) {
|
895
|
+
var nextPartId = 1;
|
896
|
+
var pendingParts = 0;
|
897
|
+
var formData = null;
|
898
|
+
|
899
|
+
function resolveToJSON(key, value) {
|
900
|
+
var parent = this; // Make sure that `parent[key]` wasn't JSONified before `value` was passed to us
|
901
|
+
|
902
|
+
{
|
903
|
+
// $FlowFixMe[incompatible-use]
|
904
|
+
var originalValue = parent[key];
|
905
|
+
|
906
|
+
if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
|
907
|
+
if (objectName(originalValue) !== 'Object') {
|
908
|
+
error('Only plain objects can be passed to Server Functions from the Client. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, key));
|
909
|
+
} else {
|
910
|
+
error('Only plain objects can be passed to Server Functions from the Client. ' + 'Objects with toJSON methods are not supported. Convert it manually ' + 'to a simple value before passing it to props.%s', describeObjectForErrorMessage(parent, key));
|
911
|
+
}
|
912
|
+
}
|
913
|
+
}
|
914
|
+
|
915
|
+
if (value === null) {
|
916
|
+
return null;
|
917
|
+
}
|
918
|
+
|
919
|
+
if (typeof value === 'object') {
|
920
|
+
switch (value.$$typeof) {
|
921
|
+
case REACT_ELEMENT_TYPE:
|
922
|
+
{
|
923
|
+
if (temporaryReferences === undefined) {
|
924
|
+
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.' + (describeObjectForErrorMessage(parent, key) ));
|
925
|
+
}
|
926
|
+
|
927
|
+
return serializeTemporaryReferenceID(writeTemporaryReference(temporaryReferences, value));
|
928
|
+
}
|
929
|
+
|
930
|
+
case REACT_LAZY_TYPE:
|
931
|
+
{
|
932
|
+
// Resolve lazy as if it wasn't here. In the future this will be encoded as a Promise.
|
933
|
+
var lazy = value;
|
934
|
+
var payload = lazy._payload;
|
935
|
+
var init = lazy._init;
|
936
|
+
|
937
|
+
if (formData === null) {
|
938
|
+
// Upgrade to use FormData to allow us to stream this value.
|
939
|
+
formData = new FormData();
|
940
|
+
}
|
941
|
+
|
942
|
+
pendingParts++;
|
943
|
+
|
944
|
+
try {
|
945
|
+
var resolvedModel = init(payload); // We always outline this as a separate part even though we could inline it
|
946
|
+
// because it ensures a more deterministic encoding.
|
947
|
+
|
948
|
+
var lazyId = nextPartId++;
|
949
|
+
var partJSON = JSON.stringify(resolvedModel, resolveToJSON); // $FlowFixMe[incompatible-type] We know it's not null because we assigned it above.
|
950
|
+
|
951
|
+
var data = formData; // eslint-disable-next-line react-internal/safe-string-coercion
|
952
|
+
|
953
|
+
data.append(formFieldPrefix + lazyId, partJSON);
|
954
|
+
return serializeByValueID(lazyId);
|
955
|
+
} catch (x) {
|
956
|
+
if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
|
957
|
+
// Suspended
|
958
|
+
pendingParts++;
|
959
|
+
|
960
|
+
var _lazyId = nextPartId++;
|
961
|
+
|
962
|
+
var thenable = x;
|
963
|
+
|
964
|
+
var retry = function () {
|
965
|
+
// While the first promise resolved, its value isn't necessarily what we'll
|
966
|
+
// resolve into because we might suspend again.
|
967
|
+
try {
|
968
|
+
var _partJSON = JSON.stringify(value, resolveToJSON); // $FlowFixMe[incompatible-type] We know it's not null because we assigned it above.
|
969
|
+
|
970
|
+
|
971
|
+
var _data = formData; // eslint-disable-next-line react-internal/safe-string-coercion
|
972
|
+
|
973
|
+
_data.append(formFieldPrefix + _lazyId, _partJSON);
|
974
|
+
|
975
|
+
pendingParts--;
|
976
|
+
|
977
|
+
if (pendingParts === 0) {
|
978
|
+
resolve(_data);
|
979
|
+
}
|
980
|
+
} catch (reason) {
|
981
|
+
reject(reason);
|
982
|
+
}
|
983
|
+
};
|
984
|
+
|
985
|
+
thenable.then(retry, retry);
|
986
|
+
return serializeByValueID(_lazyId);
|
987
|
+
} else {
|
988
|
+
// In the future we could consider serializing this as an error
|
989
|
+
// that throws on the server instead.
|
990
|
+
reject(x);
|
991
|
+
return null;
|
992
|
+
}
|
993
|
+
} finally {
|
994
|
+
pendingParts--;
|
995
|
+
}
|
996
|
+
}
|
997
|
+
} // $FlowFixMe[method-unbinding]
|
998
|
+
|
999
|
+
|
1000
|
+
if (typeof value.then === 'function') {
|
1001
|
+
// We assume that any object with a .then property is a "Thenable" type,
|
1002
|
+
// or a Promise type. Either of which can be represented by a Promise.
|
1003
|
+
if (formData === null) {
|
1004
|
+
// Upgrade to use FormData to allow us to stream this value.
|
1005
|
+
formData = new FormData();
|
1006
|
+
}
|
1007
|
+
|
1008
|
+
pendingParts++;
|
1009
|
+
var promiseId = nextPartId++;
|
1010
|
+
var _thenable = value;
|
1011
|
+
|
1012
|
+
_thenable.then(function (partValue) {
|
1013
|
+
try {
|
1014
|
+
var _partJSON2 = JSON.stringify(partValue, resolveToJSON); // $FlowFixMe[incompatible-type] We know it's not null because we assigned it above.
|
1015
|
+
|
1016
|
+
|
1017
|
+
var _data2 = formData; // eslint-disable-next-line react-internal/safe-string-coercion
|
1018
|
+
|
1019
|
+
_data2.append(formFieldPrefix + promiseId, _partJSON2);
|
1020
|
+
|
1021
|
+
pendingParts--;
|
1022
|
+
|
1023
|
+
if (pendingParts === 0) {
|
1024
|
+
resolve(_data2);
|
1025
|
+
}
|
1026
|
+
} catch (reason) {
|
1027
|
+
reject(reason);
|
1028
|
+
}
|
1029
|
+
}, function (reason) {
|
1030
|
+
// In the future we could consider serializing this as an error
|
1031
|
+
// that throws on the server instead.
|
1032
|
+
reject(reason);
|
1033
|
+
});
|
1034
|
+
|
1035
|
+
return serializePromiseID(promiseId);
|
1036
|
+
}
|
1037
|
+
|
1038
|
+
if (isArray(value)) {
|
1039
|
+
// $FlowFixMe[incompatible-return]
|
1040
|
+
return value;
|
1041
|
+
} // TODO: Should we the Object.prototype.toString.call() to test for cross-realm objects?
|
1042
|
+
|
1043
|
+
|
1044
|
+
if (value instanceof FormData) {
|
1045
|
+
if (formData === null) {
|
1046
|
+
// Upgrade to use FormData to allow us to use rich objects as its values.
|
1047
|
+
formData = new FormData();
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
var _data3 = formData;
|
1051
|
+
var refId = nextPartId++; // Copy all the form fields with a prefix for this reference.
|
1052
|
+
// These must come first in the form order because we assume that all the
|
1053
|
+
// fields are available before this is referenced.
|
1054
|
+
|
1055
|
+
var prefix = formFieldPrefix + refId + '_'; // $FlowFixMe[prop-missing]: FormData has forEach.
|
1056
|
+
|
1057
|
+
value.forEach(function (originalValue, originalKey) {
|
1058
|
+
_data3.append(prefix + originalKey, originalValue);
|
1059
|
+
});
|
1060
|
+
return serializeFormDataReference(refId);
|
1061
|
+
}
|
1062
|
+
|
1063
|
+
if (value instanceof Map) {
|
1064
|
+
var _partJSON3 = JSON.stringify(Array.from(value), resolveToJSON);
|
1065
|
+
|
1066
|
+
if (formData === null) {
|
1067
|
+
formData = new FormData();
|
1068
|
+
}
|
1069
|
+
|
1070
|
+
var mapId = nextPartId++;
|
1071
|
+
formData.append(formFieldPrefix + mapId, _partJSON3);
|
1072
|
+
return serializeMapID(mapId);
|
1073
|
+
}
|
1074
|
+
|
1075
|
+
if (value instanceof Set) {
|
1076
|
+
var _partJSON4 = JSON.stringify(Array.from(value), resolveToJSON);
|
1077
|
+
|
1078
|
+
if (formData === null) {
|
1079
|
+
formData = new FormData();
|
1080
|
+
}
|
1081
|
+
|
1082
|
+
var setId = nextPartId++;
|
1083
|
+
formData.append(formFieldPrefix + setId, _partJSON4);
|
1084
|
+
return serializeSetID(setId);
|
1085
|
+
}
|
1086
|
+
|
1087
|
+
var iteratorFn = getIteratorFn(value);
|
1088
|
+
|
1089
|
+
if (iteratorFn) {
|
1090
|
+
var iterator = iteratorFn.call(value);
|
1091
|
+
|
1092
|
+
if (iterator === value) {
|
1093
|
+
// Iterator, not Iterable
|
1094
|
+
var _partJSON5 = JSON.stringify(Array.from(iterator), resolveToJSON);
|
1095
|
+
|
1096
|
+
if (formData === null) {
|
1097
|
+
formData = new FormData();
|
1098
|
+
}
|
1099
|
+
|
1100
|
+
var iteratorId = nextPartId++;
|
1101
|
+
formData.append(formFieldPrefix + iteratorId, _partJSON5);
|
1102
|
+
return serializeIteratorID(iteratorId);
|
1103
|
+
}
|
1104
|
+
|
1105
|
+
return Array.from(iterator);
|
1106
|
+
} // Verify that this is a simple plain object.
|
1107
|
+
|
1108
|
+
|
1109
|
+
var proto = getPrototypeOf(value);
|
1110
|
+
|
1111
|
+
if (proto !== ObjectPrototype && (proto === null || getPrototypeOf(proto) !== null)) {
|
1112
|
+
if (temporaryReferences === undefined) {
|
1113
|
+
throw new Error('Only plain objects, and a few built-ins, can be passed to Server Actions. ' + 'Classes or null prototypes are not supported.');
|
1114
|
+
} // We can serialize class instances as temporary references.
|
1115
|
+
|
1116
|
+
|
1117
|
+
return serializeTemporaryReferenceID(writeTemporaryReference(temporaryReferences, value));
|
1118
|
+
}
|
1119
|
+
|
1120
|
+
{
|
1121
|
+
if (value.$$typeof === (REACT_CONTEXT_TYPE )) {
|
1122
|
+
error('React Context Providers cannot be passed to Server Functions from the Client.%s', describeObjectForErrorMessage(parent, key));
|
1123
|
+
} else if (objectName(value) !== 'Object') {
|
1124
|
+
error('Only plain objects can be passed to Server Functions from the Client. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent, key));
|
1125
|
+
} else if (!isSimpleObject(value)) {
|
1126
|
+
error('Only plain objects can be passed to Server Functions from the Client. ' + 'Classes or other objects with methods are not supported.%s', describeObjectForErrorMessage(parent, key));
|
1127
|
+
} else if (Object.getOwnPropertySymbols) {
|
1128
|
+
var symbols = Object.getOwnPropertySymbols(value);
|
1129
|
+
|
1130
|
+
if (symbols.length > 0) {
|
1131
|
+
error('Only plain objects can be passed to Server Functions from the Client. ' + 'Objects with symbol properties like %s are not supported.%s', symbols[0].description, describeObjectForErrorMessage(parent, key));
|
1132
|
+
}
|
1133
|
+
}
|
1134
|
+
} // $FlowFixMe[incompatible-return]
|
1135
|
+
|
1136
|
+
|
1137
|
+
return value;
|
1138
|
+
}
|
1139
|
+
|
1140
|
+
if (typeof value === 'string') {
|
1141
|
+
// TODO: Maybe too clever. If we support URL there's no similar trick.
|
1142
|
+
if (value[value.length - 1] === 'Z') {
|
1143
|
+
// Possibly a Date, whose toJSON automatically calls toISOString
|
1144
|
+
// $FlowFixMe[incompatible-use]
|
1145
|
+
var _originalValue = parent[key];
|
1146
|
+
|
1147
|
+
if (_originalValue instanceof Date) {
|
1148
|
+
return serializeDateFromDateJSON(value);
|
1149
|
+
}
|
1150
|
+
}
|
1151
|
+
|
1152
|
+
return escapeStringValue(value);
|
1153
|
+
}
|
1154
|
+
|
1155
|
+
if (typeof value === 'boolean') {
|
1156
|
+
return value;
|
1157
|
+
}
|
1158
|
+
|
1159
|
+
if (typeof value === 'number') {
|
1160
|
+
return serializeNumber(value);
|
1161
|
+
}
|
1162
|
+
|
1163
|
+
if (typeof value === 'undefined') {
|
1164
|
+
return serializeUndefined();
|
1165
|
+
}
|
1166
|
+
|
1167
|
+
if (typeof value === 'function') {
|
1168
|
+
var metaData = knownServerReferences.get(value);
|
592
1169
|
|
593
|
-
|
594
|
-
|
595
|
-
chunks.set(id, chunk);
|
596
|
-
}
|
1170
|
+
if (metaData !== undefined) {
|
1171
|
+
var metaDataJSON = JSON.stringify(metaData, resolveToJSON);
|
597
1172
|
|
598
|
-
|
599
|
-
|
1173
|
+
if (formData === null) {
|
1174
|
+
// Upgrade to use FormData to allow us to stream this value.
|
1175
|
+
formData = new FormData();
|
1176
|
+
} // The reference to this function came from the same client so we can pass it back.
|
600
1177
|
|
601
|
-
function createModelResolver(chunk, parentObject, key) {
|
602
|
-
var blocked;
|
603
1178
|
|
604
|
-
|
605
|
-
blocked = initializingChunkBlockedModel;
|
606
|
-
blocked.deps++;
|
607
|
-
} else {
|
608
|
-
blocked = initializingChunkBlockedModel = {
|
609
|
-
deps: 1,
|
610
|
-
value: null
|
611
|
-
};
|
612
|
-
}
|
1179
|
+
var _refId = nextPartId++; // eslint-disable-next-line react-internal/safe-string-coercion
|
613
1180
|
|
614
|
-
return function (value) {
|
615
|
-
parentObject[key] = value;
|
616
|
-
blocked.deps--;
|
617
1181
|
|
618
|
-
|
619
|
-
|
620
|
-
return;
|
1182
|
+
formData.set(formFieldPrefix + _refId, metaDataJSON);
|
1183
|
+
return serializeServerReferenceID(_refId);
|
621
1184
|
}
|
622
1185
|
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
initializedChunk.value = blocked.value;
|
1186
|
+
if (temporaryReferences === undefined) {
|
1187
|
+
throw new Error('Client Functions cannot be passed directly to Server Functions. ' + 'Only Functions passed from the Server can be passed back again.');
|
1188
|
+
}
|
627
1189
|
|
628
|
-
|
629
|
-
|
1190
|
+
return serializeTemporaryReferenceID(writeTemporaryReference(temporaryReferences, value));
|
1191
|
+
}
|
1192
|
+
|
1193
|
+
if (typeof value === 'symbol') {
|
1194
|
+
if (temporaryReferences === undefined) {
|
1195
|
+
throw new Error('Symbols cannot be passed to a Server Function without a ' + 'temporary reference set. Pass a TemporaryReferenceSet to the options.' + (describeObjectForErrorMessage(parent, key) ));
|
630
1196
|
}
|
1197
|
+
|
1198
|
+
return serializeTemporaryReferenceID(writeTemporaryReference(temporaryReferences, value));
|
631
1199
|
}
|
632
|
-
};
|
633
|
-
}
|
634
1200
|
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
};
|
639
|
-
}
|
1201
|
+
if (typeof value === 'bigint') {
|
1202
|
+
return serializeBigInt(value);
|
1203
|
+
}
|
640
1204
|
|
641
|
-
|
642
|
-
|
1205
|
+
throw new Error("Type " + typeof value + " is not supported as an argument to a Server Function.");
|
1206
|
+
} // $FlowFixMe[incompatible-type] it's not going to be undefined because we'll encode it.
|
643
1207
|
|
644
|
-
var proxy = function () {
|
645
|
-
// $FlowFixMe[method-unbinding]
|
646
|
-
var args = Array.prototype.slice.call(arguments);
|
647
|
-
var p = metaData.bound;
|
648
1208
|
|
649
|
-
|
650
|
-
|
1209
|
+
var json = JSON.stringify(root, resolveToJSON);
|
1210
|
+
|
1211
|
+
if (formData === null) {
|
1212
|
+
// If it's a simple data structure, we just use plain JSON.
|
1213
|
+
resolve(json);
|
1214
|
+
} else {
|
1215
|
+
// Otherwise, we use FormData to let us stream in the result.
|
1216
|
+
formData.set(formFieldPrefix + '0', json);
|
1217
|
+
|
1218
|
+
if (pendingParts === 0) {
|
1219
|
+
// $FlowFixMe[incompatible-call] this has already been refined.
|
1220
|
+
resolve(formData);
|
651
1221
|
}
|
1222
|
+
}
|
1223
|
+
}
|
652
1224
|
|
653
|
-
|
654
|
-
var bound = p.value;
|
655
|
-
return callServer(metaData.id, bound.concat(args));
|
656
|
-
} // Since this is a fake Promise whose .then doesn't chain, we have to wrap it.
|
657
|
-
// TODO: Remove the wrapper once that's fixed.
|
1225
|
+
function registerServerReference(proxy, reference, encodeFormAction) {
|
658
1226
|
|
1227
|
+
knownServerReferences.set(proxy, reference);
|
1228
|
+
} // $FlowFixMe[method-unbinding]
|
659
1229
|
|
660
|
-
|
661
|
-
|
662
|
-
|
1230
|
+
function createServerReference(id, callServer, encodeFormAction) {
|
1231
|
+
var proxy = function () {
|
1232
|
+
// $FlowFixMe[method-unbinding]
|
1233
|
+
var args = Array.prototype.slice.call(arguments);
|
1234
|
+
return callServer(id, args);
|
663
1235
|
};
|
664
1236
|
|
665
|
-
|
1237
|
+
registerServerReference(proxy, {
|
1238
|
+
id: id,
|
1239
|
+
bound: null
|
1240
|
+
});
|
666
1241
|
return proxy;
|
667
1242
|
}
|
668
1243
|
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
1244
|
+
var ROW_ID = 0;
|
1245
|
+
var ROW_TAG = 1;
|
1246
|
+
var ROW_LENGTH = 2;
|
1247
|
+
var ROW_CHUNK_BY_NEWLINE = 3;
|
1248
|
+
var ROW_CHUNK_BY_LENGTH = 4;
|
1249
|
+
var PENDING = 'pending';
|
1250
|
+
var BLOCKED = 'blocked';
|
1251
|
+
var CYCLIC = 'cyclic';
|
1252
|
+
var RESOLVED_MODEL = 'resolved_model';
|
1253
|
+
var RESOLVED_MODULE = 'resolved_module';
|
1254
|
+
var INITIALIZED = 'fulfilled';
|
1255
|
+
var ERRORED = 'rejected'; // $FlowFixMe[missing-this-annot]
|
675
1256
|
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
}
|
1257
|
+
function Chunk(status, value, reason, response) {
|
1258
|
+
this.status = status;
|
1259
|
+
this.value = value;
|
1260
|
+
this.reason = reason;
|
1261
|
+
this._response = response;
|
682
1262
|
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
var chunk = getChunk(response, id); // We create a React.lazy wrapper around any lazy values.
|
688
|
-
// When passed into React, we'll know how to suspend on this.
|
1263
|
+
{
|
1264
|
+
this._debugInfo = null;
|
1265
|
+
}
|
1266
|
+
} // We subclass Promise.prototype so that we get other methods like .catch
|
689
1267
|
|
690
|
-
return createLazyChunkWrapper(chunk);
|
691
|
-
}
|
692
1268
|
|
693
|
-
|
694
|
-
{
|
695
|
-
// Promise
|
696
|
-
var _id = parseInt(value.slice(2), 16);
|
1269
|
+
Chunk.prototype = Object.create(Promise.prototype); // TODO: This doesn't return a new Promise chain unlike the real .then
|
697
1270
|
|
698
|
-
|
1271
|
+
Chunk.prototype.then = function (resolve, reject) {
|
1272
|
+
var chunk = this; // If we have resolved content, we try to initialize it first which
|
1273
|
+
// might put us back into one of the other states.
|
699
1274
|
|
700
|
-
|
701
|
-
|
1275
|
+
switch (chunk.status) {
|
1276
|
+
case RESOLVED_MODEL:
|
1277
|
+
initializeModelChunk(chunk);
|
1278
|
+
break;
|
702
1279
|
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
}
|
1280
|
+
case RESOLVED_MODULE:
|
1281
|
+
initializeModuleChunk(chunk);
|
1282
|
+
break;
|
1283
|
+
} // The status might have changed after initialization.
|
708
1284
|
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
1285
|
+
|
1286
|
+
switch (chunk.status) {
|
1287
|
+
case INITIALIZED:
|
1288
|
+
resolve(chunk.value);
|
1289
|
+
break;
|
1290
|
+
|
1291
|
+
case PENDING:
|
1292
|
+
case BLOCKED:
|
1293
|
+
case CYCLIC:
|
1294
|
+
if (resolve) {
|
1295
|
+
if (chunk.value === null) {
|
1296
|
+
chunk.value = [];
|
713
1297
|
}
|
714
1298
|
|
715
|
-
|
716
|
-
|
717
|
-
// Server Reference
|
718
|
-
var _id2 = parseInt(value.slice(2), 16);
|
1299
|
+
chunk.value.push(resolve);
|
1300
|
+
}
|
719
1301
|
|
720
|
-
|
1302
|
+
if (reject) {
|
1303
|
+
if (chunk.reason === null) {
|
1304
|
+
chunk.reason = [];
|
1305
|
+
}
|
721
1306
|
|
722
|
-
|
723
|
-
|
724
|
-
initializeModelChunk(_chunk2);
|
725
|
-
break;
|
726
|
-
} // The status might have changed after initialization.
|
1307
|
+
chunk.reason.push(reject);
|
1308
|
+
}
|
727
1309
|
|
1310
|
+
break;
|
728
1311
|
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
return createServerReferenceProxy(response, metadata);
|
734
|
-
}
|
735
|
-
// We always encode it first in the stream so it won't be pending.
|
1312
|
+
default:
|
1313
|
+
if (reject) {
|
1314
|
+
reject(chunk.reason);
|
1315
|
+
}
|
736
1316
|
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
}
|
1317
|
+
break;
|
1318
|
+
}
|
1319
|
+
};
|
741
1320
|
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
1321
|
+
function readChunk(chunk) {
|
1322
|
+
// If we have resolved content, we try to initialize it first which
|
1323
|
+
// might put us back into one of the other states.
|
1324
|
+
switch (chunk.status) {
|
1325
|
+
case RESOLVED_MODEL:
|
1326
|
+
initializeModelChunk(chunk);
|
1327
|
+
break;
|
747
1328
|
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
return -0;
|
753
|
-
} else {
|
754
|
-
return -Infinity;
|
755
|
-
}
|
756
|
-
}
|
1329
|
+
case RESOLVED_MODULE:
|
1330
|
+
initializeModuleChunk(chunk);
|
1331
|
+
break;
|
1332
|
+
} // The status might have changed after initialization.
|
757
1333
|
|
758
|
-
case 'N':
|
759
|
-
{
|
760
|
-
// $NaN
|
761
|
-
return NaN;
|
762
|
-
}
|
763
1334
|
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
// Special encoding for `undefined` which can't be serialized as JSON otherwise.
|
768
|
-
return undefined;
|
769
|
-
}
|
1335
|
+
switch (chunk.status) {
|
1336
|
+
case INITIALIZED:
|
1337
|
+
return chunk.value;
|
770
1338
|
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
1339
|
+
case PENDING:
|
1340
|
+
case BLOCKED:
|
1341
|
+
case CYCLIC:
|
1342
|
+
// eslint-disable-next-line no-throw-literal
|
1343
|
+
throw chunk;
|
776
1344
|
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
}
|
1345
|
+
default:
|
1346
|
+
throw chunk.reason;
|
1347
|
+
}
|
1348
|
+
}
|
782
1349
|
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
1350
|
+
function getRoot(response) {
|
1351
|
+
var chunk = getChunk(response, 0);
|
1352
|
+
return chunk;
|
1353
|
+
}
|
1354
|
+
|
1355
|
+
function createPendingChunk(response) {
|
1356
|
+
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
1357
|
+
return new Chunk(PENDING, null, null, response);
|
1358
|
+
}
|
787
1359
|
|
788
|
-
|
1360
|
+
function createBlockedChunk(response) {
|
1361
|
+
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
1362
|
+
return new Chunk(BLOCKED, null, null, response);
|
1363
|
+
}
|
789
1364
|
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
1365
|
+
function createErrorChunk(response, error) {
|
1366
|
+
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
1367
|
+
return new Chunk(ERRORED, null, error, response);
|
1368
|
+
}
|
794
1369
|
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
1370
|
+
function wakeChunk(listeners, value) {
|
1371
|
+
for (var i = 0; i < listeners.length; i++) {
|
1372
|
+
var listener = listeners[i];
|
1373
|
+
listener(value);
|
1374
|
+
}
|
1375
|
+
}
|
799
1376
|
|
1377
|
+
function wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners) {
|
1378
|
+
switch (chunk.status) {
|
1379
|
+
case INITIALIZED:
|
1380
|
+
wakeChunk(resolveListeners, chunk.value);
|
1381
|
+
break;
|
800
1382
|
|
801
|
-
|
802
|
-
|
803
|
-
|
1383
|
+
case PENDING:
|
1384
|
+
case BLOCKED:
|
1385
|
+
case CYCLIC:
|
1386
|
+
chunk.value = resolveListeners;
|
1387
|
+
chunk.reason = rejectListeners;
|
1388
|
+
break;
|
804
1389
|
|
805
|
-
|
806
|
-
|
807
|
-
|
1390
|
+
case ERRORED:
|
1391
|
+
if (rejectListeners) {
|
1392
|
+
wakeChunk(rejectListeners, chunk.reason);
|
1393
|
+
}
|
808
1394
|
|
809
|
-
|
1395
|
+
break;
|
1396
|
+
}
|
1397
|
+
}
|
810
1398
|
|
811
|
-
|
1399
|
+
function triggerErrorOnChunk(chunk, error) {
|
1400
|
+
if (chunk.status !== PENDING && chunk.status !== BLOCKED) {
|
812
1401
|
|
813
|
-
|
814
|
-
throw _chunk3.reason;
|
815
|
-
}
|
816
|
-
}
|
817
|
-
}
|
1402
|
+
return;
|
818
1403
|
}
|
819
1404
|
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
1405
|
+
var listeners = chunk.reason;
|
1406
|
+
var erroredChunk = chunk;
|
1407
|
+
erroredChunk.status = ERRORED;
|
1408
|
+
erroredChunk.reason = error;
|
824
1409
|
|
825
|
-
if (
|
826
|
-
|
827
|
-
// Or even change the ReactElement type to be an array.
|
828
|
-
return createElement(tuple[1], tuple[2], tuple[3]);
|
1410
|
+
if (listeners !== null) {
|
1411
|
+
wakeChunk(listeners, error);
|
829
1412
|
}
|
830
|
-
|
831
|
-
return value;
|
832
1413
|
}
|
833
1414
|
|
834
|
-
function
|
835
|
-
|
1415
|
+
function createResolvedModelChunk(response, value) {
|
1416
|
+
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
1417
|
+
return new Chunk(RESOLVED_MODEL, value, null, response);
|
836
1418
|
}
|
837
1419
|
|
838
|
-
function
|
839
|
-
|
840
|
-
|
841
|
-
_bundlerConfig: bundlerConfig,
|
842
|
-
_callServer: callServer !== undefined ? callServer : missingCall,
|
843
|
-
_chunks: chunks
|
844
|
-
};
|
845
|
-
return response;
|
1420
|
+
function createResolvedModuleChunk(response, value) {
|
1421
|
+
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
1422
|
+
return new Chunk(RESOLVED_MODULE, value, null, response);
|
846
1423
|
}
|
847
|
-
function resolveModel(response, id, model) {
|
848
|
-
var chunks = response._chunks;
|
849
|
-
var chunk = chunks.get(id);
|
850
1424
|
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
resolveModelChunk(chunk, model);
|
855
|
-
}
|
1425
|
+
function createInitializedTextChunk(response, value) {
|
1426
|
+
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
1427
|
+
return new Chunk(INITIALIZED, value, null, response);
|
856
1428
|
}
|
857
|
-
function resolveModule(response, id, model) {
|
858
|
-
var chunks = response._chunks;
|
859
|
-
var chunk = chunks.get(id);
|
860
|
-
var clientReferenceMetadata = parseModel(response, model);
|
861
|
-
var clientReference = resolveClientReference(response._bundlerConfig, clientReferenceMetadata); // TODO: Add an option to encode modules that are lazy loaded.
|
862
|
-
// For now we preload all modules as early as possible since it's likely
|
863
|
-
// that we'll need them.
|
864
1429
|
|
865
|
-
|
1430
|
+
function resolveModelChunk(chunk, value) {
|
1431
|
+
if (chunk.status !== PENDING) {
|
866
1432
|
|
867
|
-
|
868
|
-
|
1433
|
+
return;
|
1434
|
+
}
|
869
1435
|
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
} else {
|
876
|
-
// This can't actually happen because we don't have any forward
|
877
|
-
// references to modules.
|
878
|
-
blockedChunk = chunk;
|
879
|
-
blockedChunk.status = BLOCKED;
|
880
|
-
}
|
1436
|
+
var resolveListeners = chunk.value;
|
1437
|
+
var rejectListeners = chunk.reason;
|
1438
|
+
var resolvedChunk = chunk;
|
1439
|
+
resolvedChunk.status = RESOLVED_MODEL;
|
1440
|
+
resolvedChunk.value = value;
|
881
1441
|
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
chunks.set(id, createResolvedModuleChunk(response, clientReference));
|
890
|
-
} else {
|
891
|
-
// This can't actually happen because we don't have any forward
|
892
|
-
// references to modules.
|
893
|
-
resolveModuleChunk(chunk, clientReference);
|
894
|
-
}
|
1442
|
+
if (resolveListeners !== null) {
|
1443
|
+
// This is unfortunate that we're reading this eagerly if
|
1444
|
+
// we already have listeners attached since they might no
|
1445
|
+
// longer be rendered or might not be the highest pri.
|
1446
|
+
initializeModelChunk(resolvedChunk); // The status might have changed after initialization.
|
1447
|
+
|
1448
|
+
wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners);
|
895
1449
|
}
|
896
1450
|
}
|
897
|
-
function resolveErrorDev(response, id, digest, message, stack) {
|
898
1451
|
|
1452
|
+
function resolveModuleChunk(chunk, value) {
|
1453
|
+
if (chunk.status !== PENDING && chunk.status !== BLOCKED) {
|
1454
|
+
// We already resolved. We didn't expect to see this.
|
1455
|
+
return;
|
1456
|
+
}
|
899
1457
|
|
900
|
-
var
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
var chunk = chunks.get(id);
|
1458
|
+
var resolveListeners = chunk.value;
|
1459
|
+
var rejectListeners = chunk.reason;
|
1460
|
+
var resolvedChunk = chunk;
|
1461
|
+
resolvedChunk.status = RESOLVED_MODULE;
|
1462
|
+
resolvedChunk.value = value;
|
906
1463
|
|
907
|
-
if (
|
908
|
-
|
909
|
-
|
910
|
-
triggerErrorOnChunk(chunk, errorWithDigest);
|
1464
|
+
if (resolveListeners !== null) {
|
1465
|
+
initializeModuleChunk(resolvedChunk);
|
1466
|
+
wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners);
|
911
1467
|
}
|
912
1468
|
}
|
913
|
-
function resolveHint(response, code, model) {
|
914
|
-
var hintModel = parseModel(response, model);
|
915
|
-
dispatchHint(code, hintModel);
|
916
|
-
}
|
917
|
-
function close(response) {
|
918
|
-
// In case there are any remaining unresolved chunks, they won't
|
919
|
-
// be resolved now. So we need to issue an error to those.
|
920
|
-
// Ideally we should be able to early bail out if we kept a
|
921
|
-
// ref count of pending chunks.
|
922
|
-
reportGlobalError(response, new Error('Connection closed.'));
|
923
|
-
}
|
924
1469
|
|
925
|
-
|
926
|
-
|
927
|
-
return;
|
928
|
-
}
|
1470
|
+
var initializingChunk = null;
|
1471
|
+
var initializingChunkBlockedModel = null;
|
929
1472
|
|
930
|
-
|
931
|
-
var
|
932
|
-
var
|
933
|
-
|
934
|
-
|
935
|
-
//
|
1473
|
+
function initializeModelChunk(chunk) {
|
1474
|
+
var prevChunk = initializingChunk;
|
1475
|
+
var prevBlocked = initializingChunkBlockedModel;
|
1476
|
+
initializingChunk = chunk;
|
1477
|
+
initializingChunkBlockedModel = null;
|
1478
|
+
var resolvedModel = chunk.value; // We go to the CYCLIC state until we've fully resolved this.
|
1479
|
+
// We do this before parsing in case we try to initialize the same chunk
|
1480
|
+
// while parsing the model. Such as in a cyclic reference.
|
936
1481
|
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
return;
|
942
|
-
}
|
1482
|
+
var cyclicChunk = chunk;
|
1483
|
+
cyclicChunk.status = CYCLIC;
|
1484
|
+
cyclicChunk.value = null;
|
1485
|
+
cyclicChunk.reason = null;
|
943
1486
|
|
944
|
-
|
945
|
-
|
946
|
-
var code = row[colon + 2];
|
947
|
-
resolveHint(response, code, row.slice(colon + 3));
|
948
|
-
return;
|
949
|
-
}
|
1487
|
+
try {
|
1488
|
+
var value = parseModel(chunk._response, resolvedModel);
|
950
1489
|
|
951
|
-
|
952
|
-
|
953
|
-
|
1490
|
+
if (initializingChunkBlockedModel !== null && initializingChunkBlockedModel.deps > 0) {
|
1491
|
+
initializingChunkBlockedModel.value = value; // We discovered new dependencies on modules that are not yet resolved.
|
1492
|
+
// We have to go the BLOCKED state until they're resolved.
|
954
1493
|
|
955
|
-
|
956
|
-
|
957
|
-
|
1494
|
+
var blockedChunk = chunk;
|
1495
|
+
blockedChunk.status = BLOCKED;
|
1496
|
+
blockedChunk.value = null;
|
1497
|
+
blockedChunk.reason = null;
|
1498
|
+
} else {
|
1499
|
+
var resolveListeners = cyclicChunk.value;
|
1500
|
+
var initializedChunk = chunk;
|
1501
|
+
initializedChunk.status = INITIALIZED;
|
1502
|
+
initializedChunk.value = value;
|
958
1503
|
|
959
|
-
|
1504
|
+
if (resolveListeners !== null) {
|
1505
|
+
wakeChunk(resolveListeners, value);
|
960
1506
|
}
|
1507
|
+
}
|
1508
|
+
} catch (error) {
|
1509
|
+
var erroredChunk = chunk;
|
1510
|
+
erroredChunk.status = ERRORED;
|
1511
|
+
erroredChunk.reason = error;
|
1512
|
+
} finally {
|
1513
|
+
initializingChunk = prevChunk;
|
1514
|
+
initializingChunkBlockedModel = prevBlocked;
|
1515
|
+
}
|
1516
|
+
}
|
961
1517
|
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
1518
|
+
function initializeModuleChunk(chunk) {
|
1519
|
+
try {
|
1520
|
+
var value = requireModule(chunk.value);
|
1521
|
+
var initializedChunk = chunk;
|
1522
|
+
initializedChunk.status = INITIALIZED;
|
1523
|
+
initializedChunk.value = value;
|
1524
|
+
} catch (error) {
|
1525
|
+
var erroredChunk = chunk;
|
1526
|
+
erroredChunk.status = ERRORED;
|
1527
|
+
erroredChunk.reason = error;
|
1528
|
+
}
|
1529
|
+
} // Report that any missing chunks in the model is now going to throw this
|
1530
|
+
// error upon read. Also notify any pending promises.
|
1531
|
+
|
1532
|
+
|
1533
|
+
function reportGlobalError(response, error) {
|
1534
|
+
response._chunks.forEach(function (chunk) {
|
1535
|
+
// If this chunk was already resolved or errored, it won't
|
1536
|
+
// trigger an error but if it wasn't then we need to
|
1537
|
+
// because we won't be getting any new data to resolve it.
|
1538
|
+
if (chunk.status === PENDING) {
|
1539
|
+
triggerErrorOnChunk(chunk, error);
|
1540
|
+
}
|
1541
|
+
});
|
1542
|
+
}
|
1543
|
+
|
1544
|
+
function nullRefGetter() {
|
1545
|
+
{
|
1546
|
+
return null;
|
1547
|
+
}
|
1548
|
+
}
|
1549
|
+
|
1550
|
+
function createElement(type, key, props, owner) // DEV-only
|
1551
|
+
{
|
1552
|
+
var element;
|
1553
|
+
|
1554
|
+
{
|
1555
|
+
// `ref` is non-enumerable in dev
|
1556
|
+
element = {
|
1557
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
1558
|
+
type: type,
|
1559
|
+
key: key,
|
1560
|
+
props: props,
|
1561
|
+
_owner: owner
|
1562
|
+
};
|
1563
|
+
Object.defineProperty(element, 'ref', {
|
1564
|
+
enumerable: false,
|
1565
|
+
get: nullRefGetter
|
1566
|
+
});
|
1567
|
+
}
|
1568
|
+
|
1569
|
+
{
|
1570
|
+
// We don't really need to add any of these but keeping them for good measure.
|
1571
|
+
// Unfortunately, _store is enumerable in jest matchers so for equality to
|
1572
|
+
// work, I need to keep it or make _store non-enumerable in the other file.
|
1573
|
+
element._store = {};
|
1574
|
+
Object.defineProperty(element._store, 'validated', {
|
1575
|
+
configurable: false,
|
1576
|
+
enumerable: false,
|
1577
|
+
writable: true,
|
1578
|
+
value: true // This element has already been validated on the server.
|
1579
|
+
|
1580
|
+
}); // debugInfo contains Server Component debug information.
|
1581
|
+
|
1582
|
+
Object.defineProperty(element, '_debugInfo', {
|
1583
|
+
configurable: false,
|
1584
|
+
enumerable: false,
|
1585
|
+
writable: true,
|
1586
|
+
value: null
|
1587
|
+
});
|
968
1588
|
}
|
1589
|
+
|
1590
|
+
return element;
|
969
1591
|
}
|
970
1592
|
|
971
|
-
function
|
972
|
-
var
|
1593
|
+
function createLazyChunkWrapper(chunk) {
|
1594
|
+
var lazyType = {
|
1595
|
+
$$typeof: REACT_LAZY_TYPE,
|
1596
|
+
_payload: chunk,
|
1597
|
+
_init: readChunk
|
1598
|
+
};
|
973
1599
|
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
offset = linebreak + 1;
|
979
|
-
linebreak = chunk.indexOf('\n', offset);
|
1600
|
+
{
|
1601
|
+
// Ensure we have a live array to track future debug info.
|
1602
|
+
var chunkDebugInfo = chunk._debugInfo || (chunk._debugInfo = []);
|
1603
|
+
lazyType._debugInfo = chunkDebugInfo;
|
980
1604
|
}
|
981
1605
|
|
982
|
-
|
1606
|
+
return lazyType;
|
983
1607
|
}
|
984
|
-
function processBinaryChunk(response, chunk) {
|
985
1608
|
|
986
|
-
|
987
|
-
var
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
chunk = chunk.subarray(linebreak + 1);
|
994
|
-
linebreak = chunk.indexOf(10); // newline
|
1609
|
+
function getChunk(response, id) {
|
1610
|
+
var chunks = response._chunks;
|
1611
|
+
var chunk = chunks.get(id);
|
1612
|
+
|
1613
|
+
if (!chunk) {
|
1614
|
+
chunk = createPendingChunk(response);
|
1615
|
+
chunks.set(id, chunk);
|
995
1616
|
}
|
996
1617
|
|
997
|
-
|
1618
|
+
return chunk;
|
998
1619
|
}
|
999
1620
|
|
1000
|
-
function
|
1001
|
-
|
1002
|
-
return function (key, value) {
|
1003
|
-
if (typeof value === 'string') {
|
1004
|
-
// We can't use .bind here because we need the "this" value.
|
1005
|
-
return parseModelString(response, this, key, value);
|
1006
|
-
}
|
1621
|
+
function createModelResolver(chunk, parentObject, key, cyclic, response, map) {
|
1622
|
+
var blocked;
|
1007
1623
|
|
1008
|
-
|
1009
|
-
|
1624
|
+
if (initializingChunkBlockedModel) {
|
1625
|
+
blocked = initializingChunkBlockedModel;
|
1626
|
+
|
1627
|
+
if (!cyclic) {
|
1628
|
+
blocked.deps++;
|
1010
1629
|
}
|
1630
|
+
} else {
|
1631
|
+
blocked = initializingChunkBlockedModel = {
|
1632
|
+
deps: cyclic ? 0 : 1,
|
1633
|
+
value: null
|
1634
|
+
};
|
1635
|
+
}
|
1011
1636
|
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1637
|
+
return function (value) {
|
1638
|
+
parentObject[key] = map(response, value); // If this is the root object for a model reference, where `blocked.value`
|
1639
|
+
// is a stale `null`, the resolved value can be used directly.
|
1015
1640
|
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
var stringDecoder = createStringDecoder() ;
|
1020
|
-
var response = createResponse$1(bundlerConfig, callServer);
|
1021
|
-
response._partialRow = '';
|
1641
|
+
if (key === '' && blocked.value === null) {
|
1642
|
+
blocked.value = parentObject[key];
|
1643
|
+
}
|
1022
1644
|
|
1023
|
-
|
1024
|
-
response._stringDecoder = stringDecoder;
|
1025
|
-
} // Don't inline this call because it causes closure to outline the call above.
|
1645
|
+
blocked.deps--;
|
1026
1646
|
|
1647
|
+
if (blocked.deps === 0) {
|
1648
|
+
if (chunk.status !== BLOCKED) {
|
1649
|
+
return;
|
1650
|
+
}
|
1027
1651
|
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
1652
|
+
var resolveListeners = chunk.value;
|
1653
|
+
var initializedChunk = chunk;
|
1654
|
+
initializedChunk.status = INITIALIZED;
|
1655
|
+
initializedChunk.value = blocked.value;
|
1031
1656
|
|
1032
|
-
|
1033
|
-
|
1034
|
-
{
|
1035
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
1036
|
-
args[_key2 - 1] = arguments[_key2];
|
1657
|
+
if (resolveListeners !== null) {
|
1658
|
+
wakeChunk(resolveListeners, blocked.value);
|
1037
1659
|
}
|
1038
|
-
|
1039
|
-
printWarning('error', format, args);
|
1040
1660
|
}
|
1041
|
-
}
|
1661
|
+
};
|
1042
1662
|
}
|
1043
1663
|
|
1044
|
-
function
|
1045
|
-
|
1046
|
-
|
1047
|
-
|
1048
|
-
|
1049
|
-
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
1664
|
+
function createModelReject(chunk) {
|
1665
|
+
return function (error) {
|
1666
|
+
return triggerErrorOnChunk(chunk, error);
|
1667
|
+
};
|
1668
|
+
}
|
1050
1669
|
|
1051
|
-
|
1052
|
-
|
1053
|
-
args = args.concat([stack]);
|
1054
|
-
} // eslint-disable-next-line react-internal/safe-string-coercion
|
1670
|
+
function createServerReferenceProxy(response, metaData) {
|
1671
|
+
var callServer = response._callServer;
|
1055
1672
|
|
1673
|
+
var proxy = function () {
|
1674
|
+
// $FlowFixMe[method-unbinding]
|
1675
|
+
var args = Array.prototype.slice.call(arguments);
|
1676
|
+
var p = metaData.bound;
|
1056
1677
|
|
1057
|
-
|
1058
|
-
return
|
1059
|
-
}
|
1678
|
+
if (!p) {
|
1679
|
+
return callServer(metaData.id, args);
|
1680
|
+
}
|
1060
1681
|
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1682
|
+
if (p.status === INITIALIZED) {
|
1683
|
+
var bound = p.value;
|
1684
|
+
return callServer(metaData.id, bound.concat(args));
|
1685
|
+
} // Since this is a fake Promise whose .then doesn't chain, we have to wrap it.
|
1686
|
+
// TODO: Remove the wrapper once that's fixed.
|
1064
1687
|
|
1065
|
-
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
1066
|
-
}
|
1067
|
-
}
|
1068
1688
|
|
1069
|
-
|
1689
|
+
return Promise.resolve(p).then(function (bound) {
|
1690
|
+
return callServer(metaData.id, bound.concat(args));
|
1691
|
+
});
|
1692
|
+
};
|
1070
1693
|
|
1071
|
-
|
1072
|
-
return
|
1694
|
+
registerServerReference(proxy, metaData);
|
1695
|
+
return proxy;
|
1073
1696
|
}
|
1074
1697
|
|
1075
|
-
|
1076
|
-
|
1077
|
-
var jsxPropsParents = new WeakMap();
|
1078
|
-
var jsxChildrenParents = new WeakMap();
|
1698
|
+
function getOutlinedModel(response, id, parentObject, key, map) {
|
1699
|
+
var chunk = getChunk(response, id);
|
1079
1700
|
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
1083
|
-
|
1701
|
+
switch (chunk.status) {
|
1702
|
+
case RESOLVED_MODEL:
|
1703
|
+
initializeModelChunk(chunk);
|
1704
|
+
break;
|
1084
1705
|
|
1085
|
-
|
1706
|
+
case RESOLVED_MODULE:
|
1707
|
+
initializeModuleChunk(chunk);
|
1708
|
+
break;
|
1709
|
+
} // The status might have changed after initialization.
|
1086
1710
|
|
1087
|
-
if (object === ObjectPrototype) {
|
1088
|
-
return true;
|
1089
|
-
} // It might be an object from a different Realm which is
|
1090
|
-
// still just a plain simple object.
|
1091
1711
|
|
1712
|
+
switch (chunk.status) {
|
1713
|
+
case INITIALIZED:
|
1714
|
+
var chunkValue = map(response, chunk.value);
|
1715
|
+
|
1716
|
+
if (chunk._debugInfo) {
|
1717
|
+
// If we have a direct reference to an object that was rendered by a synchronous
|
1718
|
+
// server component, it might have some debug info about how it was rendered.
|
1719
|
+
// We forward this to the underlying object. This might be a React Element or
|
1720
|
+
// an Array fragment.
|
1721
|
+
// If this was a string / number return value we lose the debug info. We choose
|
1722
|
+
// that tradeoff to allow sync server components to return plain values and not
|
1723
|
+
// use them as React Nodes necessarily. We could otherwise wrap them in a Lazy.
|
1724
|
+
if (typeof chunkValue === 'object' && chunkValue !== null && (Array.isArray(chunkValue) || typeof chunkValue[ASYNC_ITERATOR] === 'function' || chunkValue.$$typeof === REACT_ELEMENT_TYPE) && !chunkValue._debugInfo) {
|
1725
|
+
// We should maybe use a unique symbol for arrays but this is a React owned array.
|
1726
|
+
// $FlowFixMe[prop-missing]: This should be added to elements.
|
1727
|
+
Object.defineProperty(chunkValue, '_debugInfo', {
|
1728
|
+
configurable: false,
|
1729
|
+
enumerable: false,
|
1730
|
+
writable: true,
|
1731
|
+
value: chunk._debugInfo
|
1732
|
+
});
|
1733
|
+
}
|
1734
|
+
}
|
1092
1735
|
|
1093
|
-
|
1094
|
-
return false;
|
1095
|
-
}
|
1736
|
+
return chunkValue;
|
1096
1737
|
|
1097
|
-
|
1738
|
+
case PENDING:
|
1739
|
+
case BLOCKED:
|
1740
|
+
case CYCLIC:
|
1741
|
+
var parentChunk = initializingChunk;
|
1742
|
+
chunk.then(createModelResolver(parentChunk, parentObject, key, chunk.status === CYCLIC, response, map), createModelReject(parentChunk));
|
1743
|
+
return null;
|
1098
1744
|
|
1099
|
-
|
1100
|
-
|
1101
|
-
return false;
|
1102
|
-
}
|
1745
|
+
default:
|
1746
|
+
throw chunk.reason;
|
1103
1747
|
}
|
1104
|
-
|
1105
|
-
return true;
|
1106
1748
|
}
|
1107
1749
|
|
1108
|
-
function
|
1109
|
-
|
1110
|
-
|
1111
|
-
}
|
1112
|
-
|
1113
|
-
var names = Object.getOwnPropertyNames(object);
|
1114
|
-
|
1115
|
-
for (var i = 0; i < names.length; i++) {
|
1116
|
-
var descriptor = Object.getOwnPropertyDescriptor(object, names[i]);
|
1750
|
+
function createMap(response, model) {
|
1751
|
+
return new Map(model);
|
1752
|
+
}
|
1117
1753
|
|
1118
|
-
|
1119
|
-
|
1120
|
-
|
1754
|
+
function createSet(response, model) {
|
1755
|
+
return new Set(model);
|
1756
|
+
}
|
1121
1757
|
|
1122
|
-
|
1123
|
-
|
1124
|
-
// React adds key and ref getters to props objects to issue warnings.
|
1125
|
-
// Those getters will not be transferred to the client, but that's ok,
|
1126
|
-
// so we'll special case them.
|
1127
|
-
continue;
|
1128
|
-
}
|
1758
|
+
function createFormData(response, model) {
|
1759
|
+
var formData = new FormData();
|
1129
1760
|
|
1130
|
-
|
1131
|
-
|
1761
|
+
for (var i = 0; i < model.length; i++) {
|
1762
|
+
formData.append(model[i][0], model[i][1]);
|
1132
1763
|
}
|
1133
1764
|
|
1134
|
-
return
|
1765
|
+
return formData;
|
1135
1766
|
}
|
1136
|
-
|
1137
|
-
|
1138
|
-
|
1139
|
-
return
|
1140
|
-
return p0;
|
1141
|
-
});
|
1767
|
+
|
1768
|
+
function extractIterator(response, model) {
|
1769
|
+
// $FlowFixMe[incompatible-use]: This uses raw Symbols because we're extracting from a native array.
|
1770
|
+
return model[Symbol.iterator]();
|
1142
1771
|
}
|
1143
1772
|
|
1144
|
-
function
|
1145
|
-
|
1146
|
-
return '"' + key + '"' === encodedKey ? key : encodedKey;
|
1773
|
+
function createModel(response, model) {
|
1774
|
+
return model;
|
1147
1775
|
}
|
1148
1776
|
|
1149
|
-
function
|
1150
|
-
|
1151
|
-
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1777
|
+
function parseModelString(response, parentObject, key, value) {
|
1778
|
+
if (value[0] === '$') {
|
1779
|
+
if (value === '$') {
|
1780
|
+
// A very common symbol.
|
1781
|
+
return REACT_ELEMENT_TYPE;
|
1782
|
+
}
|
1155
1783
|
|
1156
|
-
|
1157
|
-
|
1158
|
-
|
1159
|
-
|
1784
|
+
switch (value[1]) {
|
1785
|
+
case '$':
|
1786
|
+
{
|
1787
|
+
// This was an escaped string value.
|
1788
|
+
return value.slice(1);
|
1160
1789
|
}
|
1161
1790
|
|
1162
|
-
|
1791
|
+
case 'L':
|
1792
|
+
{
|
1793
|
+
// Lazy node
|
1794
|
+
var id = parseInt(value.slice(2), 16);
|
1795
|
+
var chunk = getChunk(response, id); // We create a React.lazy wrapper around any lazy values.
|
1796
|
+
// When passed into React, we'll know how to suspend on this.
|
1163
1797
|
|
1164
|
-
|
1165
|
-
return '{...}';
|
1798
|
+
return createLazyChunkWrapper(chunk);
|
1166
1799
|
}
|
1167
1800
|
|
1168
|
-
|
1169
|
-
|
1801
|
+
case '@':
|
1802
|
+
{
|
1803
|
+
// Promise
|
1804
|
+
if (value.length === 2) {
|
1805
|
+
// Infinite promise that never resolves.
|
1806
|
+
return new Promise(function () {});
|
1807
|
+
}
|
1170
1808
|
|
1171
|
-
|
1172
|
-
return 'function';
|
1809
|
+
var _id = parseInt(value.slice(2), 16);
|
1173
1810
|
|
1174
|
-
|
1175
|
-
// eslint-disable-next-line react-internal/safe-string-coercion
|
1176
|
-
return String(value);
|
1177
|
-
}
|
1178
|
-
}
|
1811
|
+
var _chunk = getChunk(response, _id);
|
1179
1812
|
|
1180
|
-
|
1181
|
-
|
1182
|
-
return type;
|
1183
|
-
}
|
1813
|
+
return _chunk;
|
1814
|
+
}
|
1184
1815
|
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1816
|
+
case 'S':
|
1817
|
+
{
|
1818
|
+
// Symbol
|
1819
|
+
return Symbol.for(value.slice(2));
|
1820
|
+
}
|
1821
|
+
|
1822
|
+
case 'F':
|
1823
|
+
{
|
1824
|
+
// Server Reference
|
1825
|
+
var _id2 = parseInt(value.slice(2), 16);
|
1826
|
+
|
1827
|
+
return getOutlinedModel(response, _id2, parentObject, key, createServerReferenceProxy);
|
1828
|
+
}
|
1188
1829
|
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1830
|
+
case 'T':
|
1831
|
+
{
|
1832
|
+
// Temporary Reference
|
1833
|
+
var _id3 = parseInt(value.slice(2), 16);
|
1192
1834
|
|
1193
|
-
|
1194
|
-
switch (type.$$typeof) {
|
1195
|
-
case REACT_FORWARD_REF_TYPE:
|
1196
|
-
return describeElementType(type.render);
|
1835
|
+
var temporaryReferences = response._tempRefs;
|
1197
1836
|
|
1198
|
-
|
1199
|
-
|
1837
|
+
if (temporaryReferences == null) {
|
1838
|
+
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.');
|
1839
|
+
}
|
1200
1840
|
|
1201
|
-
|
1841
|
+
return readTemporaryReference(temporaryReferences, _id3);
|
1842
|
+
}
|
1843
|
+
|
1844
|
+
case 'Q':
|
1202
1845
|
{
|
1203
|
-
|
1204
|
-
var
|
1205
|
-
var init = lazyComponent._init;
|
1846
|
+
// Map
|
1847
|
+
var _id4 = parseInt(value.slice(2), 16);
|
1206
1848
|
|
1207
|
-
|
1208
|
-
// Lazy may contain any component type so we recursively resolve it.
|
1209
|
-
return describeElementType(init(payload));
|
1210
|
-
} catch (x) {}
|
1849
|
+
return getOutlinedModel(response, _id4, parentObject, key, createMap);
|
1211
1850
|
}
|
1212
|
-
}
|
1213
|
-
}
|
1214
1851
|
|
1215
|
-
|
1216
|
-
|
1852
|
+
case 'W':
|
1853
|
+
{
|
1854
|
+
// Set
|
1855
|
+
var _id5 = parseInt(value.slice(2), 16);
|
1217
1856
|
|
1218
|
-
|
1219
|
-
|
1857
|
+
return getOutlinedModel(response, _id5, parentObject, key, createSet);
|
1858
|
+
}
|
1220
1859
|
|
1221
|
-
|
1222
|
-
|
1223
|
-
}
|
1860
|
+
case 'B':
|
1861
|
+
{
|
1224
1862
|
|
1225
|
-
|
1226
|
-
|
1227
|
-
var length = 0;
|
1863
|
+
return undefined;
|
1864
|
+
}
|
1228
1865
|
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
str = '<' + describeElementType(type) + '>';
|
1234
|
-
var array = objectOrArray;
|
1866
|
+
case 'K':
|
1867
|
+
{
|
1868
|
+
// FormData
|
1869
|
+
var _id7 = parseInt(value.slice(2), 16);
|
1235
1870
|
|
1236
|
-
|
1237
|
-
|
1238
|
-
var substr = void 0;
|
1871
|
+
return getOutlinedModel(response, _id7, parentObject, key, createFormData);
|
1872
|
+
}
|
1239
1873
|
|
1240
|
-
|
1241
|
-
|
1242
|
-
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
substr = '{' + describeValueForErrorMessage(value) + '}';
|
1874
|
+
case 'i':
|
1875
|
+
{
|
1876
|
+
// Iterator
|
1877
|
+
var _id8 = parseInt(value.slice(2), 16);
|
1878
|
+
|
1879
|
+
return getOutlinedModel(response, _id8, parentObject, key, extractIterator);
|
1247
1880
|
}
|
1248
1881
|
|
1249
|
-
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
} else if (substr.length < 15 && str.length + substr.length < 40) {
|
1254
|
-
str += substr;
|
1255
|
-
} else {
|
1256
|
-
str += '{...}';
|
1882
|
+
case 'I':
|
1883
|
+
{
|
1884
|
+
// $Infinity
|
1885
|
+
return Infinity;
|
1257
1886
|
}
|
1258
|
-
}
|
1259
1887
|
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1888
|
+
case '-':
|
1889
|
+
{
|
1890
|
+
// $-0 or $-Infinity
|
1891
|
+
if (value === '$-0') {
|
1892
|
+
return -0;
|
1893
|
+
} else {
|
1894
|
+
return -Infinity;
|
1895
|
+
}
|
1896
|
+
}
|
1265
1897
|
|
1266
|
-
|
1267
|
-
|
1268
|
-
|
1898
|
+
case 'N':
|
1899
|
+
{
|
1900
|
+
// $NaN
|
1901
|
+
return NaN;
|
1269
1902
|
}
|
1270
1903
|
|
1271
|
-
|
1904
|
+
case 'u':
|
1905
|
+
{
|
1906
|
+
// matches "$undefined"
|
1907
|
+
// Special encoding for `undefined` which can't be serialized as JSON otherwise.
|
1908
|
+
return undefined;
|
1909
|
+
}
|
1272
1910
|
|
1273
|
-
|
1911
|
+
case 'D':
|
1912
|
+
{
|
1913
|
+
// Date
|
1914
|
+
return new Date(Date.parse(value.slice(2)));
|
1915
|
+
}
|
1274
1916
|
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
_substr = describeValueForErrorMessage(_value);
|
1917
|
+
case 'n':
|
1918
|
+
{
|
1919
|
+
// BigInt
|
1920
|
+
return BigInt(value.slice(2));
|
1280
1921
|
}
|
1281
1922
|
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1923
|
+
case 'E':
|
1924
|
+
{
|
1925
|
+
{
|
1926
|
+
// In DEV mode we allow indirect eval to produce functions for logging.
|
1927
|
+
// This should not compile to eval() because then it has local scope access.
|
1928
|
+
try {
|
1929
|
+
// eslint-disable-next-line no-eval
|
1930
|
+
return (0, eval)(value.slice(2));
|
1931
|
+
} catch (x) {
|
1932
|
+
// We currently use this to express functions so we fail parsing it,
|
1933
|
+
// let's just return a blank function as a place holder.
|
1934
|
+
return function () {};
|
1935
|
+
}
|
1936
|
+
} // Fallthrough
|
1937
|
+
|
1290
1938
|
}
|
1291
|
-
}
|
1292
1939
|
|
1293
|
-
|
1940
|
+
default:
|
1941
|
+
{
|
1942
|
+
// We assume that anything else is a reference ID.
|
1943
|
+
var _id9 = parseInt(value.slice(1), 16);
|
1944
|
+
|
1945
|
+
return getOutlinedModel(response, _id9, parentObject, key, createModel);
|
1946
|
+
}
|
1294
1947
|
}
|
1295
|
-
}
|
1296
|
-
if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
|
1297
|
-
str = '<' + describeElementType(objectOrArray.type) + '/>';
|
1298
|
-
} else if (jsxPropsParents.has(objectOrArray)) {
|
1299
|
-
// Print JSX
|
1300
|
-
var _type = jsxPropsParents.get(objectOrArray);
|
1948
|
+
}
|
1301
1949
|
|
1302
|
-
|
1303
|
-
|
1304
|
-
var names = Object.keys(object);
|
1950
|
+
return value;
|
1951
|
+
}
|
1305
1952
|
|
1306
|
-
|
1307
|
-
|
1308
|
-
var name = names[_i2];
|
1309
|
-
str += describeKeyForErrorMessage(name) + '=';
|
1310
|
-
var _value2 = object[name];
|
1953
|
+
function parseModelTuple(response, value) {
|
1954
|
+
var tuple = value;
|
1311
1955
|
|
1312
|
-
|
1956
|
+
if (tuple[0] === REACT_ELEMENT_TYPE) {
|
1957
|
+
// TODO: Consider having React just directly accept these arrays as elements.
|
1958
|
+
// Or even change the ReactElement type to be an array.
|
1959
|
+
return createElement(tuple[1], tuple[2], tuple[3], tuple[4] );
|
1960
|
+
}
|
1313
1961
|
|
1314
|
-
|
1315
|
-
|
1316
|
-
_substr2 = describeObjectForErrorMessage(_value2);
|
1317
|
-
} else {
|
1318
|
-
_substr2 = describeValueForErrorMessage(_value2);
|
1319
|
-
}
|
1962
|
+
return value;
|
1963
|
+
}
|
1320
1964
|
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1965
|
+
function missingCall() {
|
1966
|
+
throw new Error('Trying to call a function from "use server" but the callServer option ' + 'was not implemented in your router runtime.');
|
1967
|
+
}
|
1324
1968
|
|
1325
|
-
|
1326
|
-
|
1327
|
-
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
1331
|
-
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1969
|
+
function createResponse(bundlerConfig, moduleLoading, callServer, encodeFormAction, nonce, temporaryReferences) {
|
1970
|
+
var chunks = new Map();
|
1971
|
+
var response = {
|
1972
|
+
_bundlerConfig: bundlerConfig,
|
1973
|
+
_moduleLoading: moduleLoading,
|
1974
|
+
_callServer: callServer !== undefined ? callServer : missingCall,
|
1975
|
+
_encodeFormAction: encodeFormAction,
|
1976
|
+
_nonce: nonce,
|
1977
|
+
_chunks: chunks,
|
1978
|
+
_stringDecoder: createStringDecoder(),
|
1979
|
+
_fromJSON: null,
|
1980
|
+
_rowState: 0,
|
1981
|
+
_rowID: 0,
|
1982
|
+
_rowTag: 0,
|
1983
|
+
_rowLength: 0,
|
1984
|
+
_buffer: [],
|
1985
|
+
_tempRefs: temporaryReferences
|
1986
|
+
}; // Don't inline this call because it causes closure to outline the call above.
|
1335
1987
|
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
str = '{';
|
1340
|
-
var _object = objectOrArray;
|
1988
|
+
response._fromJSON = createFromJSONCallback(response);
|
1989
|
+
return response;
|
1990
|
+
}
|
1341
1991
|
|
1342
|
-
|
1992
|
+
function resolveModel(response, id, model) {
|
1993
|
+
var chunks = response._chunks;
|
1994
|
+
var chunk = chunks.get(id);
|
1343
1995
|
|
1344
|
-
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1996
|
+
if (!chunk) {
|
1997
|
+
chunks.set(id, createResolvedModelChunk(response, model));
|
1998
|
+
} else {
|
1999
|
+
resolveModelChunk(chunk, model);
|
2000
|
+
}
|
2001
|
+
}
|
1348
2002
|
|
1349
|
-
|
1350
|
-
|
1351
|
-
var _value3 = _object[_name];
|
2003
|
+
function resolveText(response, id, text) {
|
2004
|
+
var chunks = response._chunks;
|
1352
2005
|
|
1353
|
-
|
2006
|
+
chunks.set(id, createInitializedTextChunk(response, text));
|
2007
|
+
}
|
1354
2008
|
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
2009
|
+
function resolveModule(response, id, model) {
|
2010
|
+
var chunks = response._chunks;
|
2011
|
+
var chunk = chunks.get(id);
|
2012
|
+
var clientReferenceMetadata = parseModel(response, model);
|
2013
|
+
var clientReference = resolveClientReference(response._bundlerConfig, clientReferenceMetadata);
|
2014
|
+
// For now we preload all modules as early as possible since it's likely
|
2015
|
+
// that we'll need them.
|
1361
2016
|
|
1362
|
-
|
1363
|
-
start = str.length;
|
1364
|
-
length = _substr3.length;
|
1365
|
-
str += _substr3;
|
1366
|
-
} else if (_substr3.length < 10 && str.length + _substr3.length < 40) {
|
1367
|
-
str += _substr3;
|
1368
|
-
} else {
|
1369
|
-
str += '...';
|
1370
|
-
}
|
1371
|
-
}
|
2017
|
+
var promise = preloadModule(clientReference);
|
1372
2018
|
|
1373
|
-
|
2019
|
+
if (promise) {
|
2020
|
+
var blockedChunk;
|
2021
|
+
|
2022
|
+
if (!chunk) {
|
2023
|
+
// Technically, we should just treat promise as the chunk in this
|
2024
|
+
// case. Because it'll just behave as any other promise.
|
2025
|
+
blockedChunk = createBlockedChunk(response);
|
2026
|
+
chunks.set(id, blockedChunk);
|
2027
|
+
} else {
|
2028
|
+
// This can't actually happen because we don't have any forward
|
2029
|
+
// references to modules.
|
2030
|
+
blockedChunk = chunk;
|
2031
|
+
blockedChunk.status = BLOCKED;
|
1374
2032
|
}
|
1375
|
-
}
|
1376
2033
|
|
1377
|
-
|
1378
|
-
|
2034
|
+
promise.then(function () {
|
2035
|
+
return resolveModuleChunk(blockedChunk, clientReference);
|
2036
|
+
}, function (error) {
|
2037
|
+
return triggerErrorOnChunk(blockedChunk, error);
|
2038
|
+
});
|
2039
|
+
} else {
|
2040
|
+
if (!chunk) {
|
2041
|
+
chunks.set(id, createResolvedModuleChunk(response, clientReference));
|
2042
|
+
} else {
|
2043
|
+
// This can't actually happen because we don't have any forward
|
2044
|
+
// references to modules.
|
2045
|
+
resolveModuleChunk(chunk, clientReference);
|
2046
|
+
}
|
1379
2047
|
}
|
2048
|
+
}
|
1380
2049
|
|
1381
|
-
|
1382
|
-
var highlight = ' '.repeat(start) + '^'.repeat(length);
|
1383
|
-
return '\n ' + str + '\n ' + highlight;
|
1384
|
-
}
|
2050
|
+
function resolveErrorDev(response, id, digest, message, stack) {
|
1385
2051
|
|
1386
|
-
return '\n ' + str;
|
1387
|
-
}
|
1388
2052
|
|
1389
|
-
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
2053
|
+
var error = new Error(message || 'An error occurred in the Server Components render but no message was provided');
|
2054
|
+
error.stack = stack;
|
2055
|
+
error.digest = digest;
|
2056
|
+
var errorWithDigest = error;
|
2057
|
+
var chunks = response._chunks;
|
2058
|
+
var chunk = chunks.get(id);
|
1393
2059
|
|
1394
|
-
|
1395
|
-
|
2060
|
+
if (!chunk) {
|
2061
|
+
chunks.set(id, createErrorChunk(response, errorWithDigest));
|
2062
|
+
} else {
|
2063
|
+
triggerErrorOnChunk(chunk, errorWithDigest);
|
2064
|
+
}
|
1396
2065
|
}
|
1397
2066
|
|
1398
|
-
function
|
1399
|
-
|
2067
|
+
function resolveHint(response, code, model) {
|
2068
|
+
var hintModel = parseModel(response, model);
|
2069
|
+
dispatchHint(code, hintModel);
|
1400
2070
|
}
|
1401
2071
|
|
1402
|
-
function
|
1403
|
-
return '$S' + name;
|
1404
|
-
}
|
2072
|
+
function resolveDebugInfo(response, id, debugInfo) {
|
1405
2073
|
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
2074
|
+
var chunk = getChunk(response, id);
|
2075
|
+
var chunkDebugInfo = chunk._debugInfo || (chunk._debugInfo = []);
|
2076
|
+
chunkDebugInfo.push(debugInfo);
|
1409
2077
|
}
|
1410
2078
|
|
1411
|
-
function
|
1412
|
-
if (Number.isFinite(number)) {
|
1413
|
-
if (number === 0 && 1 / number === -Infinity) {
|
1414
|
-
return '$-0';
|
1415
|
-
} else {
|
1416
|
-
return number;
|
1417
|
-
}
|
1418
|
-
} else {
|
1419
|
-
if (number === Infinity) {
|
1420
|
-
return '$Infinity';
|
1421
|
-
} else if (number === -Infinity) {
|
1422
|
-
return '$-Infinity';
|
1423
|
-
} else {
|
1424
|
-
return '$NaN';
|
1425
|
-
}
|
1426
|
-
}
|
1427
|
-
}
|
2079
|
+
function resolveConsoleEntry(response, value) {
|
1428
2080
|
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
2081
|
+
var payload = parseModel(response, value);
|
2082
|
+
var methodName = payload[0]; // TODO: Restore the fake stack before logging.
|
2083
|
+
// const stackTrace = payload[1];
|
2084
|
+
// const owner = payload[2];
|
1432
2085
|
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
return '$D' + dateJSON;
|
2086
|
+
var env = payload[3];
|
2087
|
+
var args = payload.slice(4);
|
2088
|
+
printToConsole(methodName, args, env);
|
1437
2089
|
}
|
1438
2090
|
|
1439
|
-
function
|
1440
|
-
return '$n' + n.toString(10);
|
1441
|
-
}
|
2091
|
+
function processFullRow(response, id, tag, buffer, chunk) {
|
1442
2092
|
|
1443
|
-
|
1444
|
-
|
1445
|
-
// We need to escape $ prefixed strings since we use those to encode
|
1446
|
-
// references to IDs and as special symbol values.
|
1447
|
-
return '$' + value;
|
1448
|
-
} else {
|
1449
|
-
return value;
|
1450
|
-
}
|
1451
|
-
}
|
2093
|
+
var stringDecoder = response._stringDecoder;
|
2094
|
+
var row = '';
|
1452
2095
|
|
1453
|
-
|
1454
|
-
|
1455
|
-
|
1456
|
-
var formData = null;
|
2096
|
+
for (var i = 0; i < buffer.length; i++) {
|
2097
|
+
row += readPartialStringChunk(stringDecoder, buffer[i]);
|
2098
|
+
}
|
1457
2099
|
|
1458
|
-
|
1459
|
-
var parent = this; // Make sure that `parent[key]` wasn't JSONified before `value` was passed to us
|
2100
|
+
row += readFinalStringChunk(stringDecoder, chunk);
|
1460
2101
|
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
2102
|
+
switch (tag) {
|
2103
|
+
case 73
|
2104
|
+
/* "I" */
|
2105
|
+
:
|
2106
|
+
{
|
2107
|
+
resolveModule(response, id, row);
|
2108
|
+
return;
|
2109
|
+
}
|
1464
2110
|
|
1465
|
-
|
1466
|
-
|
1467
|
-
|
1468
|
-
|
1469
|
-
|
1470
|
-
|
2111
|
+
case 72
|
2112
|
+
/* "H" */
|
2113
|
+
:
|
2114
|
+
{
|
2115
|
+
var code = row[0];
|
2116
|
+
resolveHint(response, code, row.slice(1));
|
2117
|
+
return;
|
1471
2118
|
}
|
1472
|
-
}
|
1473
2119
|
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
2120
|
+
case 69
|
2121
|
+
/* "E" */
|
2122
|
+
:
|
2123
|
+
{
|
2124
|
+
var errorInfo = JSON.parse(row);
|
1477
2125
|
|
1478
|
-
|
1479
|
-
|
1480
|
-
if (typeof value.then === 'function') {
|
1481
|
-
// We assume that any object with a .then property is a "Thenable" type,
|
1482
|
-
// or a Promise type. Either of which can be represented by a Promise.
|
1483
|
-
if (formData === null) {
|
1484
|
-
// Upgrade to use FormData to allow us to stream this value.
|
1485
|
-
formData = new FormData();
|
2126
|
+
{
|
2127
|
+
resolveErrorDev(response, id, errorInfo.digest, errorInfo.message, errorInfo.stack);
|
1486
2128
|
}
|
1487
2129
|
|
1488
|
-
|
1489
|
-
|
1490
|
-
var thenable = value;
|
1491
|
-
thenable.then(function (partValue) {
|
1492
|
-
var partJSON = JSON.stringify(partValue, resolveToJSON); // $FlowFixMe[incompatible-type] We know it's not null because we assigned it above.
|
1493
|
-
|
1494
|
-
var data = formData; // eslint-disable-next-line react-internal/safe-string-coercion
|
2130
|
+
return;
|
2131
|
+
}
|
1495
2132
|
|
1496
|
-
|
1497
|
-
|
2133
|
+
case 84
|
2134
|
+
/* "T" */
|
2135
|
+
:
|
2136
|
+
{
|
2137
|
+
resolveText(response, id, row);
|
2138
|
+
return;
|
2139
|
+
}
|
1498
2140
|
|
1499
|
-
|
1500
|
-
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
1507
|
-
|
1508
|
-
} // TODO: Should we the Object.prototype.toString.call() to test for cross-realm objects?
|
2141
|
+
case 68
|
2142
|
+
/* "D" */
|
2143
|
+
:
|
2144
|
+
{
|
2145
|
+
{
|
2146
|
+
var debugInfo = parseModel(response, row);
|
2147
|
+
resolveDebugInfo(response, id, debugInfo);
|
2148
|
+
return;
|
2149
|
+
} // Fallthrough to share the error with Console entries.
|
1509
2150
|
|
2151
|
+
}
|
1510
2152
|
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
2153
|
+
case 87
|
2154
|
+
/* "W" */
|
2155
|
+
:
|
2156
|
+
{
|
2157
|
+
{
|
2158
|
+
resolveConsoleEntry(response, row);
|
2159
|
+
return;
|
1515
2160
|
}
|
2161
|
+
}
|
1516
2162
|
|
1517
|
-
|
1518
|
-
|
1519
|
-
|
1520
|
-
|
2163
|
+
case 82
|
2164
|
+
/* "R" */
|
2165
|
+
:
|
2166
|
+
// Fallthrough
|
1521
2167
|
|
1522
|
-
|
2168
|
+
case 114
|
2169
|
+
/* "r" */
|
2170
|
+
:
|
2171
|
+
// Fallthrough
|
1523
2172
|
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1527
|
-
|
1528
|
-
}
|
2173
|
+
case 88
|
2174
|
+
/* "X" */
|
2175
|
+
:
|
2176
|
+
// Fallthrough
|
1529
2177
|
|
1530
|
-
|
1531
|
-
|
2178
|
+
case 120
|
2179
|
+
/* "x" */
|
2180
|
+
:
|
2181
|
+
// Fallthrough
|
1532
2182
|
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
2183
|
+
case 67
|
2184
|
+
/* "C" */
|
2185
|
+
:
|
2186
|
+
// Fallthrough
|
1537
2187
|
|
2188
|
+
case 80
|
2189
|
+
/* "P" */
|
2190
|
+
:
|
2191
|
+
// Fallthrough
|
2192
|
+
|
2193
|
+
default:
|
2194
|
+
/* """ "{" "[" "t" "f" "n" "0" - "9" */
|
1538
2195
|
{
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
|
1555
|
-
|
1556
|
-
|
2196
|
+
// We assume anything else is JSON.
|
2197
|
+
resolveModel(response, id, row);
|
2198
|
+
return;
|
2199
|
+
}
|
2200
|
+
}
|
2201
|
+
}
|
2202
|
+
|
2203
|
+
function processBinaryChunk(response, chunk) {
|
2204
|
+
var i = 0;
|
2205
|
+
var rowState = response._rowState;
|
2206
|
+
var rowID = response._rowID;
|
2207
|
+
var rowTag = response._rowTag;
|
2208
|
+
var rowLength = response._rowLength;
|
2209
|
+
var buffer = response._buffer;
|
2210
|
+
var chunkLength = chunk.length;
|
2211
|
+
|
2212
|
+
while (i < chunkLength) {
|
2213
|
+
var lastIdx = -1;
|
2214
|
+
|
2215
|
+
switch (rowState) {
|
2216
|
+
case ROW_ID:
|
2217
|
+
{
|
2218
|
+
var byte = chunk[i++];
|
2219
|
+
|
2220
|
+
if (byte === 58
|
2221
|
+
/* ":" */
|
2222
|
+
) {
|
2223
|
+
// Finished the rowID, next we'll parse the tag.
|
2224
|
+
rowState = ROW_TAG;
|
2225
|
+
} else {
|
2226
|
+
rowID = rowID << 4 | (byte > 96 ? byte - 87 : byte - 48);
|
1557
2227
|
}
|
2228
|
+
|
2229
|
+
continue;
|
1558
2230
|
}
|
1559
|
-
} // $FlowFixMe[incompatible-return]
|
1560
2231
|
|
2232
|
+
case ROW_TAG:
|
2233
|
+
{
|
2234
|
+
var resolvedRowTag = chunk[i];
|
2235
|
+
|
2236
|
+
if (resolvedRowTag === 84
|
2237
|
+
/* "T" */
|
2238
|
+
|| enableBinaryFlight
|
2239
|
+
/* "V" */
|
2240
|
+
) {
|
2241
|
+
rowTag = resolvedRowTag;
|
2242
|
+
rowState = ROW_LENGTH;
|
2243
|
+
i++;
|
2244
|
+
} else if (resolvedRowTag > 64 && resolvedRowTag < 91 ||
|
2245
|
+
/* "A"-"Z" */
|
2246
|
+
resolvedRowTag === 114
|
2247
|
+
/* "r" */
|
2248
|
+
|| resolvedRowTag === 120
|
2249
|
+
/* "x" */
|
2250
|
+
) {
|
2251
|
+
rowTag = resolvedRowTag;
|
2252
|
+
rowState = ROW_CHUNK_BY_NEWLINE;
|
2253
|
+
i++;
|
2254
|
+
} else {
|
2255
|
+
rowTag = 0;
|
2256
|
+
rowState = ROW_CHUNK_BY_NEWLINE; // This was an unknown tag so it was probably part of the data.
|
2257
|
+
}
|
1561
2258
|
|
1562
|
-
|
1563
|
-
|
2259
|
+
continue;
|
2260
|
+
}
|
1564
2261
|
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
2262
|
+
case ROW_LENGTH:
|
2263
|
+
{
|
2264
|
+
var _byte = chunk[i++];
|
2265
|
+
|
2266
|
+
if (_byte === 44
|
2267
|
+
/* "," */
|
2268
|
+
) {
|
2269
|
+
// Finished the rowLength, next we'll buffer up to that length.
|
2270
|
+
rowState = ROW_CHUNK_BY_LENGTH;
|
2271
|
+
} else {
|
2272
|
+
rowLength = rowLength << 4 | (_byte > 96 ? _byte - 87 : _byte - 48);
|
2273
|
+
}
|
1571
2274
|
|
1572
|
-
|
1573
|
-
return serializeDateFromDateJSON(value);
|
2275
|
+
continue;
|
1574
2276
|
}
|
1575
|
-
}
|
1576
2277
|
|
1577
|
-
|
1578
|
-
|
2278
|
+
case ROW_CHUNK_BY_NEWLINE:
|
2279
|
+
{
|
2280
|
+
// We're looking for a newline
|
2281
|
+
lastIdx = chunk.indexOf(10
|
2282
|
+
/* "\n" */
|
2283
|
+
, i);
|
2284
|
+
break;
|
2285
|
+
}
|
1579
2286
|
|
1580
|
-
|
1581
|
-
|
1582
|
-
|
2287
|
+
case ROW_CHUNK_BY_LENGTH:
|
2288
|
+
{
|
2289
|
+
// We're looking for the remaining byte length
|
2290
|
+
lastIdx = i + rowLength;
|
1583
2291
|
|
1584
|
-
|
1585
|
-
|
1586
|
-
|
2292
|
+
if (lastIdx > chunk.length) {
|
2293
|
+
lastIdx = -1;
|
2294
|
+
}
|
1587
2295
|
|
1588
|
-
|
1589
|
-
|
2296
|
+
break;
|
2297
|
+
}
|
1590
2298
|
}
|
1591
2299
|
|
1592
|
-
|
1593
|
-
var metaData = knownServerReferences.get(value);
|
1594
|
-
|
1595
|
-
if (metaData !== undefined) {
|
1596
|
-
var metaDataJSON = JSON.stringify(metaData, resolveToJSON);
|
2300
|
+
var offset = chunk.byteOffset + i;
|
1597
2301
|
|
1598
|
-
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
2302
|
+
if (lastIdx > -1) {
|
2303
|
+
// We found the last chunk of the row
|
2304
|
+
var length = lastIdx - i;
|
2305
|
+
var lastChunk = new Uint8Array(chunk.buffer, offset, length);
|
2306
|
+
processFullRow(response, rowID, rowTag, buffer, lastChunk); // Reset state machine for a new row
|
1602
2307
|
|
2308
|
+
i = lastIdx;
|
1603
2309
|
|
1604
|
-
|
2310
|
+
if (rowState === ROW_CHUNK_BY_NEWLINE) {
|
2311
|
+
// If we're trailing by a newline we need to skip it.
|
2312
|
+
i++;
|
2313
|
+
}
|
1605
2314
|
|
2315
|
+
rowState = ROW_ID;
|
2316
|
+
rowTag = 0;
|
2317
|
+
rowID = 0;
|
2318
|
+
rowLength = 0;
|
2319
|
+
buffer.length = 0;
|
2320
|
+
} else {
|
2321
|
+
// The rest of this row is in a future chunk. We stash the rest of the
|
2322
|
+
// current chunk until we can process the full row.
|
2323
|
+
var _length = chunk.byteLength - i;
|
1606
2324
|
|
1607
|
-
|
1608
|
-
|
1609
|
-
|
2325
|
+
var remainingSlice = new Uint8Array(chunk.buffer, offset, _length);
|
2326
|
+
buffer.push(remainingSlice); // Update how many bytes we're still waiting for. If we're looking for
|
2327
|
+
// a newline, this doesn't hurt since we'll just ignore it.
|
1610
2328
|
|
1611
|
-
|
2329
|
+
rowLength -= remainingSlice.byteLength;
|
2330
|
+
break;
|
1612
2331
|
}
|
2332
|
+
}
|
1613
2333
|
|
1614
|
-
|
1615
|
-
|
1616
|
-
|
2334
|
+
response._rowState = rowState;
|
2335
|
+
response._rowID = rowID;
|
2336
|
+
response._rowTag = rowTag;
|
2337
|
+
response._rowLength = rowLength;
|
2338
|
+
}
|
1617
2339
|
|
1618
|
-
|
1619
|
-
|
1620
|
-
|
1621
|
-
}
|
2340
|
+
function parseModel(response, json) {
|
2341
|
+
return JSON.parse(json, response._fromJSON);
|
2342
|
+
}
|
1622
2343
|
|
1623
|
-
|
2344
|
+
function createFromJSONCallback(response) {
|
2345
|
+
// $FlowFixMe[missing-this-annot]
|
2346
|
+
return function (key, value) {
|
2347
|
+
if (typeof value === 'string') {
|
2348
|
+
// We can't use .bind here because we need the "this" value.
|
2349
|
+
return parseModelString(response, this, key, value);
|
1624
2350
|
}
|
1625
2351
|
|
1626
|
-
if (typeof value === '
|
1627
|
-
return
|
2352
|
+
if (typeof value === 'object' && value !== null) {
|
2353
|
+
return parseModelTuple(response, value);
|
1628
2354
|
}
|
1629
2355
|
|
1630
|
-
|
1631
|
-
}
|
1632
|
-
|
1633
|
-
|
1634
|
-
var json = JSON.stringify(root, resolveToJSON);
|
1635
|
-
|
1636
|
-
if (formData === null) {
|
1637
|
-
// If it's a simple data structure, we just use plain JSON.
|
1638
|
-
resolve(json);
|
1639
|
-
} else {
|
1640
|
-
// Otherwise, we use FormData to let us stream in the result.
|
1641
|
-
formData.set(formFieldPrefix + '0', json);
|
2356
|
+
return value;
|
2357
|
+
};
|
2358
|
+
}
|
1642
2359
|
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
2360
|
+
function close(response) {
|
2361
|
+
// In case there are any remaining unresolved chunks, they won't
|
2362
|
+
// be resolved now. So we need to issue an error to those.
|
2363
|
+
// Ideally we should be able to early bail out if we kept a
|
2364
|
+
// ref count of pending chunks.
|
2365
|
+
reportGlobalError(response, new Error('Connection closed.'));
|
1648
2366
|
}
|
1649
2367
|
|
1650
2368
|
function createResponseFromOptions(options) {
|
1651
|
-
return createResponse(null, options && options.callServer ? options.callServer : undefined
|
2369
|
+
return createResponse(null, null, options && options.callServer ? options.callServer : undefined, undefined, // encodeFormAction
|
2370
|
+
undefined, // nonce
|
2371
|
+
options && options.temporaryReferences ? options.temporaryReferences : undefined);
|
1652
2372
|
}
|
1653
2373
|
|
1654
2374
|
function startReadingFromStream(response, stream) {
|
@@ -1691,45 +2411,18 @@ function createFromFetch(promiseForResponse, options) {
|
|
1691
2411
|
return getRoot(response);
|
1692
2412
|
}
|
1693
2413
|
|
1694
|
-
function
|
1695
|
-
var response = createResponseFromOptions(options);
|
1696
|
-
var processedLength = 0;
|
1697
|
-
|
1698
|
-
function progress(e) {
|
1699
|
-
var chunk = request.responseText;
|
1700
|
-
processStringChunk(response, chunk, processedLength);
|
1701
|
-
processedLength = chunk.length;
|
1702
|
-
}
|
1703
|
-
|
1704
|
-
function load(e) {
|
1705
|
-
progress();
|
1706
|
-
close(response);
|
1707
|
-
}
|
1708
|
-
|
1709
|
-
function error(e) {
|
1710
|
-
reportGlobalError(response, new TypeError('Network error'));
|
1711
|
-
}
|
1712
|
-
|
1713
|
-
request.addEventListener('progress', progress);
|
1714
|
-
request.addEventListener('load', load);
|
1715
|
-
request.addEventListener('error', error);
|
1716
|
-
request.addEventListener('abort', error);
|
1717
|
-
request.addEventListener('timeout', error);
|
1718
|
-
return getRoot(response);
|
1719
|
-
}
|
1720
|
-
|
1721
|
-
function encodeReply(value)
|
2414
|
+
function encodeReply(value, options)
|
1722
2415
|
/* We don't use URLSearchParams yet but maybe */
|
1723
2416
|
{
|
1724
2417
|
return new Promise(function (resolve, reject) {
|
1725
|
-
processReply(value, '', resolve, reject);
|
2418
|
+
processReply(value, '', options && options.temporaryReferences ? options.temporaryReferences : undefined, resolve, reject);
|
1726
2419
|
});
|
1727
2420
|
}
|
1728
2421
|
|
1729
2422
|
exports.createFromFetch = createFromFetch;
|
1730
2423
|
exports.createFromReadableStream = createFromReadableStream;
|
1731
|
-
exports.createFromXHR = createFromXHR;
|
1732
2424
|
exports.createServerReference = createServerReference;
|
2425
|
+
exports.createTemporaryReferenceSet = createTemporaryReferenceSet;
|
1733
2426
|
exports.encodeReply = encodeReply;
|
1734
2427
|
})();
|
1735
2428
|
}
|