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