react-server-dom-webpack 18.3.0-next-fa4314841-20230502 → 19.0.0-beta-4508873393-20240430
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/react-server-dom-webpack-client.browser.development.js +1893 -1200
- package/cjs/react-server-dom-webpack-client.browser.production.js +931 -0
- package/cjs/react-server-dom-webpack-client.edge.development.js +1888 -241
- package/cjs/react-server-dom-webpack-client.edge.production.js +1093 -0
- package/cjs/react-server-dom-webpack-client.node.development.js +1876 -259
- package/cjs/react-server-dom-webpack-client.node.production.js +1070 -0
- package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +1833 -212
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +1049 -0
- package/cjs/react-server-dom-webpack-node-register.js +59 -10
- package/cjs/react-server-dom-webpack-plugin.js +389 -11
- package/cjs/react-server-dom-webpack-server.browser.development.js +2187 -937
- package/cjs/react-server-dom-webpack-server.browser.production.js +1935 -0
- package/cjs/react-server-dom-webpack-server.edge.development.js +2183 -941
- package/cjs/react-server-dom-webpack-server.edge.production.js +1956 -0
- package/cjs/react-server-dom-webpack-server.node.development.js +2169 -929
- package/cjs/react-server-dom-webpack-server.node.production.js +2083 -0
- package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +2116 -881
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +2051 -0
- package/client.browser.js +1 -1
- package/client.edge.js +1 -1
- package/client.node.js +1 -1
- package/client.node.unbundled.js +1 -1
- package/esm/{react-server-dom-webpack-node-loader.production.min.js → react-server-dom-webpack-node-loader.production.js} +20 -13
- package/package.json +8 -15
- package/server.browser.js +1 -1
- package/server.edge.js +1 -1
- package/server.node.js +1 -1
- package/server.node.unbundled.js +1 -1
- package/cjs/react-server-dom-webpack-client.browser.production.min.js +0 -34
- package/cjs/react-server-dom-webpack-client.edge.production.min.js +0 -28
- package/cjs/react-server-dom-webpack-client.node.production.min.js +0 -28
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +0 -26
- package/cjs/react-server-dom-webpack-server.browser.production.min.js +0 -62
- package/cjs/react-server-dom-webpack-server.edge.production.min.js +0 -62
- package/cjs/react-server-dom-webpack-server.node.production.min.js +0 -67
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +0 -65
- package/umd/react-server-dom-webpack-client.browser.development.js +0 -1731
- package/umd/react-server-dom-webpack-client.browser.production.min.js +0 -29
- package/umd/react-server-dom-webpack-server.browser.development.js +0 -2904
- package/umd/react-server-dom-webpack-server.browser.production.min.js +0 -51
@@ -17,7 +17,27 @@ if (process.env.NODE_ENV !== "production") {
|
|
17
17
|
var React = require('react');
|
18
18
|
var ReactDOM = require('react-dom');
|
19
19
|
|
20
|
-
|
20
|
+
function _defineProperty(obj, key, value) {
|
21
|
+
if (key in obj) {
|
22
|
+
Object.defineProperty(obj, key, {
|
23
|
+
value: value,
|
24
|
+
enumerable: true,
|
25
|
+
configurable: true,
|
26
|
+
writable: true
|
27
|
+
});
|
28
|
+
} else {
|
29
|
+
obj[key] = value;
|
30
|
+
}
|
31
|
+
|
32
|
+
return obj;
|
33
|
+
}
|
34
|
+
|
35
|
+
var ReactSharedInternalsServer = // $FlowFixMe: It's defined in the one we resolve to.
|
36
|
+
React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
37
|
+
|
38
|
+
if (!ReactSharedInternalsServer) {
|
39
|
+
throw new Error('The "react" package in this environment is not configured correctly. ' + 'The "react-server" condition must be enabled in any environment that ' + 'runs React Server Components.');
|
40
|
+
}
|
21
41
|
|
22
42
|
function error(format) {
|
23
43
|
{
|
@@ -35,8 +55,7 @@ function printWarning(level, format, args) {
|
|
35
55
|
// When changing this logic, you might want to also
|
36
56
|
// update consoleWithStackDev.www.js as well.
|
37
57
|
{
|
38
|
-
var
|
39
|
-
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
58
|
+
var stack = ReactSharedInternalsServer.getStackAddendum();
|
40
59
|
|
41
60
|
if (stack !== '') {
|
42
61
|
format += '%s';
|
@@ -56,10 +75,13 @@ function printWarning(level, format, args) {
|
|
56
75
|
}
|
57
76
|
}
|
58
77
|
|
78
|
+
// -----------------------------------------------------------------------------
|
79
|
+
var enablePostpone = false;
|
80
|
+
|
59
81
|
function scheduleWork(callback) {
|
60
82
|
setTimeout(callback, 0);
|
61
83
|
}
|
62
|
-
var VIEW_SIZE =
|
84
|
+
var VIEW_SIZE = 2048;
|
63
85
|
var currentView = null;
|
64
86
|
var writtenBytes = 0;
|
65
87
|
function beginWriting(destination) {
|
@@ -67,20 +89,14 @@ function beginWriting(destination) {
|
|
67
89
|
writtenBytes = 0;
|
68
90
|
}
|
69
91
|
function writeChunk(destination, chunk) {
|
70
|
-
if (chunk.
|
92
|
+
if (chunk.byteLength === 0) {
|
71
93
|
return;
|
72
94
|
}
|
73
95
|
|
74
|
-
if (chunk.
|
75
|
-
|
76
|
-
if (precomputedChunkSet.has(chunk)) {
|
77
|
-
error('A large precomputed chunk was passed to writeChunk without being copied.' + ' Large chunks get enqueued directly and are not copied. This is incompatible with precomputed chunks because you cannot enqueue the same precomputed chunk twice.' + ' Use "cloneChunk" to make a copy of this large precomputed chunk before writing it. This is a bug in React.');
|
78
|
-
}
|
79
|
-
} // this chunk may overflow a single view which implies it was not
|
96
|
+
if (chunk.byteLength > VIEW_SIZE) {
|
97
|
+
// this chunk may overflow a single view which implies it was not
|
80
98
|
// one that is cached by the streaming renderer. We will enqueu
|
81
99
|
// it directly and expect it is not re-used
|
82
|
-
|
83
|
-
|
84
100
|
if (writtenBytes > 0) {
|
85
101
|
destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes));
|
86
102
|
currentView = new Uint8Array(VIEW_SIZE);
|
@@ -94,7 +110,7 @@ function writeChunk(destination, chunk) {
|
|
94
110
|
var bytesToWrite = chunk;
|
95
111
|
var allowableBytes = currentView.length - writtenBytes;
|
96
112
|
|
97
|
-
if (allowableBytes < bytesToWrite.
|
113
|
+
if (allowableBytes < bytesToWrite.byteLength) {
|
98
114
|
// this chunk would overflow the current view. We enqueue a full view
|
99
115
|
// and start a new view with the remaining chunk
|
100
116
|
if (allowableBytes === 0) {
|
@@ -114,7 +130,7 @@ function writeChunk(destination, chunk) {
|
|
114
130
|
}
|
115
131
|
|
116
132
|
currentView.set(bytesToWrite, writtenBytes);
|
117
|
-
writtenBytes += bytesToWrite.
|
133
|
+
writtenBytes += bytesToWrite.byteLength;
|
118
134
|
}
|
119
135
|
function writeChunkAndReturn(destination, chunk) {
|
120
136
|
writeChunk(destination, chunk); // in web streams there is no backpressure so we can alwas write more
|
@@ -135,7 +151,9 @@ var textEncoder = new TextEncoder();
|
|
135
151
|
function stringToChunk(content) {
|
136
152
|
return textEncoder.encode(content);
|
137
153
|
}
|
138
|
-
|
154
|
+
function byteLengthOfChunk(chunk) {
|
155
|
+
return chunk.byteLength;
|
156
|
+
}
|
139
157
|
function closeWithError(destination, error) {
|
140
158
|
// $FlowFixMe[method-unbinding]
|
141
159
|
if (typeof destination.error === 'function') {
|
@@ -152,65 +170,270 @@ function closeWithError(destination, error) {
|
|
152
170
|
}
|
153
171
|
}
|
154
172
|
|
155
|
-
//
|
156
|
-
var
|
157
|
-
|
158
|
-
function
|
159
|
-
return
|
173
|
+
// eslint-disable-next-line no-unused-vars
|
174
|
+
var CLIENT_REFERENCE_TAG$1 = Symbol.for('react.client.reference');
|
175
|
+
var SERVER_REFERENCE_TAG = Symbol.for('react.server.reference');
|
176
|
+
function isClientReference(reference) {
|
177
|
+
return reference.$$typeof === CLIENT_REFERENCE_TAG$1;
|
178
|
+
}
|
179
|
+
function isServerReference(reference) {
|
180
|
+
return reference.$$typeof === SERVER_REFERENCE_TAG;
|
181
|
+
}
|
182
|
+
function registerClientReference(proxyImplementation, id, exportName) {
|
183
|
+
return registerClientReferenceImpl(proxyImplementation, id + '#' + exportName, false);
|
160
184
|
}
|
161
185
|
|
162
|
-
function
|
163
|
-
{
|
164
|
-
|
165
|
-
|
166
|
-
|
186
|
+
function registerClientReferenceImpl(proxyImplementation, id, async) {
|
187
|
+
return Object.defineProperties(proxyImplementation, {
|
188
|
+
$$typeof: {
|
189
|
+
value: CLIENT_REFERENCE_TAG$1
|
190
|
+
},
|
191
|
+
$$id: {
|
192
|
+
value: id
|
193
|
+
},
|
194
|
+
$$async: {
|
195
|
+
value: async
|
196
|
+
}
|
197
|
+
});
|
198
|
+
} // $FlowFixMe[method-unbinding]
|
199
|
+
|
200
|
+
|
201
|
+
var FunctionBind = Function.prototype.bind; // $FlowFixMe[method-unbinding]
|
202
|
+
|
203
|
+
var ArraySlice = Array.prototype.slice;
|
204
|
+
|
205
|
+
function bind() {
|
206
|
+
// $FlowFixMe[unsupported-syntax]
|
207
|
+
var newFn = FunctionBind.apply(this, arguments);
|
208
|
+
|
209
|
+
if (this.$$typeof === SERVER_REFERENCE_TAG) {
|
210
|
+
{
|
211
|
+
var thisBind = arguments[0];
|
212
|
+
|
213
|
+
if (thisBind != null) {
|
214
|
+
error('Cannot bind "this" of a Server Action. Pass null or undefined as the first argument to .bind().');
|
215
|
+
}
|
216
|
+
}
|
217
|
+
|
218
|
+
var args = ArraySlice.call(arguments, 1);
|
219
|
+
return Object.defineProperties(newFn, {
|
220
|
+
$$typeof: {
|
221
|
+
value: SERVER_REFERENCE_TAG
|
222
|
+
},
|
223
|
+
$$id: {
|
224
|
+
value: this.$$id
|
225
|
+
},
|
226
|
+
$$bound: {
|
227
|
+
value: this.$$bound ? this.$$bound.concat(args) : args
|
228
|
+
},
|
229
|
+
bind: {
|
230
|
+
value: bind
|
231
|
+
}
|
232
|
+
});
|
167
233
|
}
|
168
|
-
}
|
169
|
-
function processErrorChunkDev(request, id, digest, message, stack) {
|
170
234
|
|
171
|
-
|
172
|
-
digest: digest,
|
173
|
-
message: message,
|
174
|
-
stack: stack
|
175
|
-
};
|
176
|
-
var row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n';
|
177
|
-
return stringToChunk(row);
|
178
|
-
}
|
179
|
-
function processModelChunk(request, id, model) {
|
180
|
-
// $FlowFixMe[incompatible-type] stringify can return null
|
181
|
-
var json = stringify(model, request.toJSON);
|
182
|
-
var row = id.toString(16) + ':' + json + '\n';
|
183
|
-
return stringToChunk(row);
|
235
|
+
return newFn;
|
184
236
|
}
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
237
|
+
|
238
|
+
function registerServerReference(reference, id, exportName) {
|
239
|
+
return Object.defineProperties(reference, {
|
240
|
+
$$typeof: {
|
241
|
+
value: SERVER_REFERENCE_TAG
|
242
|
+
},
|
243
|
+
$$id: {
|
244
|
+
value: exportName === null ? id : id + '#' + exportName,
|
245
|
+
configurable: true
|
246
|
+
},
|
247
|
+
$$bound: {
|
248
|
+
value: null,
|
249
|
+
configurable: true
|
250
|
+
},
|
251
|
+
bind: {
|
252
|
+
value: bind,
|
253
|
+
configurable: true
|
254
|
+
}
|
255
|
+
});
|
189
256
|
}
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
257
|
+
var PROMISE_PROTOTYPE = Promise.prototype;
|
258
|
+
var deepProxyHandlers = {
|
259
|
+
get: function (target, name, receiver) {
|
260
|
+
switch (name) {
|
261
|
+
// These names are read by the Flight runtime if you end up using the exports object.
|
262
|
+
case '$$typeof':
|
263
|
+
// These names are a little too common. We should probably have a way to
|
264
|
+
// have the Flight runtime extract the inner target instead.
|
265
|
+
return target.$$typeof;
|
266
|
+
|
267
|
+
case '$$id':
|
268
|
+
return target.$$id;
|
269
|
+
|
270
|
+
case '$$async':
|
271
|
+
return target.$$async;
|
272
|
+
|
273
|
+
case 'name':
|
274
|
+
return target.name;
|
275
|
+
|
276
|
+
case 'displayName':
|
277
|
+
return undefined;
|
278
|
+
// We need to special case this because createElement reads it if we pass this
|
279
|
+
// reference.
|
280
|
+
|
281
|
+
case 'defaultProps':
|
282
|
+
return undefined;
|
283
|
+
// Avoid this attempting to be serialized.
|
284
|
+
|
285
|
+
case 'toJSON':
|
286
|
+
return undefined;
|
287
|
+
|
288
|
+
case Symbol.toPrimitive:
|
289
|
+
// $FlowFixMe[prop-missing]
|
290
|
+
return Object.prototype[Symbol.toPrimitive];
|
291
|
+
|
292
|
+
case Symbol.toStringTag:
|
293
|
+
// $FlowFixMe[prop-missing]
|
294
|
+
return Object.prototype[Symbol.toStringTag];
|
295
|
+
|
296
|
+
case 'Provider':
|
297
|
+
throw new Error("Cannot render a Client Context Provider on the Server. " + "Instead, you can export a Client Component wrapper " + "that itself renders a Client Context Provider.");
|
298
|
+
} // eslint-disable-next-line react-internal/safe-string-coercion
|
299
|
+
|
300
|
+
|
301
|
+
var expression = String(target.name) + '.' + String(name);
|
302
|
+
throw new Error("Cannot access " + expression + " on the server. " + 'You cannot dot into a client module from a server component. ' + 'You can only pass the imported name through.');
|
303
|
+
},
|
304
|
+
set: function () {
|
305
|
+
throw new Error('Cannot assign to a client module from a server module.');
|
306
|
+
}
|
307
|
+
};
|
308
|
+
|
309
|
+
function getReference(target, name) {
|
310
|
+
switch (name) {
|
311
|
+
// These names are read by the Flight runtime if you end up using the exports object.
|
312
|
+
case '$$typeof':
|
313
|
+
return target.$$typeof;
|
314
|
+
|
315
|
+
case '$$id':
|
316
|
+
return target.$$id;
|
317
|
+
|
318
|
+
case '$$async':
|
319
|
+
return target.$$async;
|
320
|
+
|
321
|
+
case 'name':
|
322
|
+
return target.name;
|
323
|
+
// We need to special case this because createElement reads it if we pass this
|
324
|
+
// reference.
|
325
|
+
|
326
|
+
case 'defaultProps':
|
327
|
+
return undefined;
|
328
|
+
// Avoid this attempting to be serialized.
|
329
|
+
|
330
|
+
case 'toJSON':
|
331
|
+
return undefined;
|
332
|
+
|
333
|
+
case Symbol.toPrimitive:
|
334
|
+
// $FlowFixMe[prop-missing]
|
335
|
+
return Object.prototype[Symbol.toPrimitive];
|
336
|
+
|
337
|
+
case Symbol.toStringTag:
|
338
|
+
// $FlowFixMe[prop-missing]
|
339
|
+
return Object.prototype[Symbol.toStringTag];
|
340
|
+
|
341
|
+
case '__esModule':
|
342
|
+
// Something is conditionally checking which export to use. We'll pretend to be
|
343
|
+
// an ESM compat module but then we'll check again on the client.
|
344
|
+
var moduleId = target.$$id;
|
345
|
+
target.default = registerClientReferenceImpl(function () {
|
346
|
+
throw new Error("Attempted to call the default export of " + moduleId + " from the server " + "but it's on the client. It's not possible to invoke a client function from " + "the server, it can only be rendered as a Component or passed to props of a " + "Client Component.");
|
347
|
+
}, target.$$id + '#', target.$$async);
|
348
|
+
return true;
|
349
|
+
|
350
|
+
case 'then':
|
351
|
+
if (target.then) {
|
352
|
+
// Use a cached value
|
353
|
+
return target.then;
|
354
|
+
}
|
355
|
+
|
356
|
+
if (!target.$$async) {
|
357
|
+
// If this module is expected to return a Promise (such as an AsyncModule) then
|
358
|
+
// we should resolve that with a client reference that unwraps the Promise on
|
359
|
+
// the client.
|
360
|
+
var clientReference = registerClientReferenceImpl({}, target.$$id, true);
|
361
|
+
var proxy = new Proxy(clientReference, proxyHandlers$1); // Treat this as a resolved Promise for React's use()
|
362
|
+
|
363
|
+
target.status = 'fulfilled';
|
364
|
+
target.value = proxy;
|
365
|
+
var then = target.then = registerClientReferenceImpl(function then(resolve, reject) {
|
366
|
+
// Expose to React.
|
367
|
+
return Promise.resolve(resolve(proxy));
|
368
|
+
}, // If this is not used as a Promise but is treated as a reference to a `.then`
|
369
|
+
// export then we should treat it as a reference to that name.
|
370
|
+
target.$$id + '#then', false);
|
371
|
+
return then;
|
372
|
+
} else {
|
373
|
+
// Since typeof .then === 'function' is a feature test we'd continue recursing
|
374
|
+
// indefinitely if we return a function. Instead, we return an object reference
|
375
|
+
// if we check further.
|
376
|
+
return undefined;
|
377
|
+
}
|
378
|
+
|
379
|
+
}
|
380
|
+
|
381
|
+
if (typeof name === 'symbol') {
|
382
|
+
throw new Error('Cannot read Symbol exports. Only named exports are supported on a client module ' + 'imported on the server.');
|
383
|
+
}
|
384
|
+
|
385
|
+
var cachedReference = target[name];
|
386
|
+
|
387
|
+
if (!cachedReference) {
|
388
|
+
var reference = registerClientReferenceImpl(function () {
|
389
|
+
throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion
|
390
|
+
"Attempted to call " + String(name) + "() from the server but " + String(name) + " is on the client. " + "It's not possible to invoke a client function from the server, it can " + "only be rendered as a Component or passed to props of a Client Component.");
|
391
|
+
}, target.$$id + '#' + name, target.$$async);
|
392
|
+
Object.defineProperty(reference, 'name', {
|
393
|
+
value: name
|
394
|
+
});
|
395
|
+
cachedReference = target[name] = new Proxy(reference, deepProxyHandlers);
|
396
|
+
}
|
397
|
+
|
398
|
+
return cachedReference;
|
195
399
|
}
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
400
|
+
|
401
|
+
var proxyHandlers$1 = {
|
402
|
+
get: function (target, name, receiver) {
|
403
|
+
return getReference(target, name);
|
404
|
+
},
|
405
|
+
getOwnPropertyDescriptor: function (target, name) {
|
406
|
+
var descriptor = Object.getOwnPropertyDescriptor(target, name);
|
407
|
+
|
408
|
+
if (!descriptor) {
|
409
|
+
descriptor = {
|
410
|
+
value: getReference(target, name),
|
411
|
+
writable: false,
|
412
|
+
configurable: false,
|
413
|
+
enumerable: false
|
414
|
+
};
|
415
|
+
Object.defineProperty(target, name, descriptor);
|
416
|
+
}
|
417
|
+
|
418
|
+
return descriptor;
|
419
|
+
},
|
420
|
+
getPrototypeOf: function (target) {
|
421
|
+
// Pretend to be a Promise in case anyone asks.
|
422
|
+
return PROMISE_PROTOTYPE;
|
423
|
+
},
|
424
|
+
set: function () {
|
425
|
+
throw new Error('Cannot assign to a client module from a server module.');
|
426
|
+
}
|
427
|
+
};
|
428
|
+
function createClientModuleProxy(moduleId) {
|
429
|
+
var clientReference = registerClientReferenceImpl({}, // Represents the whole Module object instead of a particular import.
|
430
|
+
moduleId, false);
|
431
|
+
return new Proxy(clientReference, proxyHandlers$1);
|
200
432
|
}
|
201
433
|
|
202
|
-
// eslint-disable-next-line no-unused-vars
|
203
|
-
var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
|
204
|
-
var SERVER_REFERENCE_TAG = Symbol.for('react.server.reference');
|
205
434
|
function getClientReferenceKey(reference) {
|
206
435
|
return reference.$$async ? reference.$$id + '#async' : reference.$$id;
|
207
436
|
}
|
208
|
-
function isClientReference(reference) {
|
209
|
-
return reference.$$typeof === CLIENT_REFERENCE_TAG;
|
210
|
-
}
|
211
|
-
function isServerReference(reference) {
|
212
|
-
return reference.$$typeof === SERVER_REFERENCE_TAG;
|
213
|
-
}
|
214
437
|
function resolveClientReferenceMetadata(config, clientReference) {
|
215
438
|
var modulePath = clientReference.$$id;
|
216
439
|
var name = '';
|
@@ -236,12 +459,11 @@ function resolveClientReferenceMetadata(config, clientReference) {
|
|
236
459
|
}
|
237
460
|
}
|
238
461
|
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
};
|
462
|
+
if (clientReference.$$async === true) {
|
463
|
+
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1];
|
464
|
+
} else {
|
465
|
+
return [resolvedModuleData.id, resolvedModuleData.chunks, name];
|
466
|
+
}
|
245
467
|
}
|
246
468
|
function getServerReferenceId(config, serverReference) {
|
247
469
|
return serverReference.$$id;
|
@@ -250,342 +472,404 @@ function getServerReferenceBoundArguments(config, serverReference) {
|
|
250
472
|
return serverReference.$$bound;
|
251
473
|
}
|
252
474
|
|
253
|
-
var ReactDOMSharedInternals = ReactDOM.
|
254
|
-
|
255
|
-
var
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
475
|
+
var ReactDOMSharedInternals = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
476
|
+
|
477
|
+
var previousDispatcher = ReactDOMSharedInternals.d;
|
478
|
+
/* ReactDOMCurrentDispatcher */
|
479
|
+
|
480
|
+
ReactDOMSharedInternals.d
|
481
|
+
/* ReactDOMCurrentDispatcher */
|
482
|
+
= {
|
483
|
+
f
|
484
|
+
/* flushSyncWork */
|
485
|
+
: previousDispatcher.f
|
486
|
+
/* flushSyncWork */
|
487
|
+
,
|
488
|
+
r
|
489
|
+
/* requestFormReset */
|
490
|
+
: previousDispatcher.r
|
491
|
+
/* requestFormReset */
|
492
|
+
,
|
493
|
+
D
|
494
|
+
/* prefetchDNS */
|
495
|
+
: prefetchDNS,
|
496
|
+
C
|
497
|
+
/* preconnect */
|
498
|
+
: preconnect,
|
499
|
+
L
|
500
|
+
/* preload */
|
501
|
+
: preload,
|
502
|
+
m
|
503
|
+
/* preloadModule */
|
504
|
+
: preloadModule$1,
|
505
|
+
X
|
506
|
+
/* preinitScript */
|
507
|
+
: preinitScript,
|
508
|
+
S
|
509
|
+
/* preinitStyle */
|
510
|
+
: preinitStyle,
|
511
|
+
M
|
512
|
+
/* preinitModuleScript */
|
513
|
+
: preinitModuleScript
|
260
514
|
};
|
261
515
|
|
262
|
-
function prefetchDNS(href
|
263
|
-
{
|
264
|
-
|
265
|
-
var request = resolveRequest();
|
266
|
-
|
267
|
-
if (request) {
|
268
|
-
var hints = getHints(request);
|
269
|
-
var key = 'D' + href;
|
516
|
+
function prefetchDNS(href) {
|
517
|
+
if (typeof href === 'string' && href) {
|
518
|
+
var request = resolveRequest();
|
270
519
|
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
}
|
275
|
-
|
276
|
-
hints.add(key);
|
520
|
+
if (request) {
|
521
|
+
var hints = getHints(request);
|
522
|
+
var key = 'D|' + href;
|
277
523
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
emitHint(request, 'D', href);
|
282
|
-
}
|
524
|
+
if (hints.has(key)) {
|
525
|
+
// duplicate hint
|
526
|
+
return;
|
283
527
|
}
|
528
|
+
|
529
|
+
hints.add(key);
|
530
|
+
emitHint(request, 'D', href);
|
531
|
+
} else {
|
532
|
+
previousDispatcher.D(
|
533
|
+
/* prefetchDNS */
|
534
|
+
href);
|
284
535
|
}
|
285
536
|
}
|
286
537
|
}
|
287
538
|
|
288
|
-
function preconnect(href,
|
289
|
-
{
|
290
|
-
|
291
|
-
var request = resolveRequest();
|
539
|
+
function preconnect(href, crossOrigin) {
|
540
|
+
if (typeof href === 'string') {
|
541
|
+
var request = resolveRequest();
|
292
542
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
var key = "C" + (crossOrigin === null ? 'null' : crossOrigin) + "|" + href;
|
543
|
+
if (request) {
|
544
|
+
var hints = getHints(request);
|
545
|
+
var key = "C|" + (crossOrigin == null ? 'null' : crossOrigin) + "|" + href;
|
297
546
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
547
|
+
if (hints.has(key)) {
|
548
|
+
// duplicate hint
|
549
|
+
return;
|
550
|
+
}
|
302
551
|
|
303
|
-
|
552
|
+
hints.add(key);
|
304
553
|
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
}
|
554
|
+
if (typeof crossOrigin === 'string') {
|
555
|
+
emitHint(request, 'C', [href, crossOrigin]);
|
556
|
+
} else {
|
557
|
+
emitHint(request, 'C', href);
|
310
558
|
}
|
559
|
+
} else {
|
560
|
+
previousDispatcher.C(
|
561
|
+
/* preconnect */
|
562
|
+
href, crossOrigin);
|
311
563
|
}
|
312
564
|
}
|
313
565
|
}
|
314
566
|
|
315
|
-
function preload(href, options) {
|
316
|
-
{
|
317
|
-
|
318
|
-
var request = resolveRequest();
|
319
|
-
|
320
|
-
if (request) {
|
321
|
-
var hints = getHints(request);
|
322
|
-
var key = 'L' + href;
|
567
|
+
function preload(href, as, options) {
|
568
|
+
if (typeof href === 'string') {
|
569
|
+
var request = resolveRequest();
|
323
570
|
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
}
|
571
|
+
if (request) {
|
572
|
+
var hints = getHints(request);
|
573
|
+
var key = 'L';
|
328
574
|
|
329
|
-
|
330
|
-
|
575
|
+
if (as === 'image' && options) {
|
576
|
+
key += getImagePreloadKey(href, options.imageSrcSet, options.imageSizes);
|
577
|
+
} else {
|
578
|
+
key += "[" + as + "]" + href;
|
331
579
|
}
|
332
|
-
}
|
333
|
-
}
|
334
|
-
}
|
335
|
-
|
336
|
-
function preinit(href, options) {
|
337
|
-
{
|
338
|
-
if (typeof href === 'string') {
|
339
|
-
var request = resolveRequest();
|
340
580
|
|
341
|
-
if (
|
342
|
-
|
343
|
-
|
581
|
+
if (hints.has(key)) {
|
582
|
+
// duplicate hint
|
583
|
+
return;
|
584
|
+
}
|
344
585
|
|
345
|
-
|
346
|
-
|
347
|
-
return;
|
348
|
-
}
|
586
|
+
hints.add(key);
|
587
|
+
var trimmed = trimOptions(options);
|
349
588
|
|
350
|
-
|
351
|
-
emitHint(request, '
|
589
|
+
if (trimmed) {
|
590
|
+
emitHint(request, 'L', [href, as, trimmed]);
|
591
|
+
} else {
|
592
|
+
emitHint(request, 'L', [href, as]);
|
352
593
|
}
|
594
|
+
} else {
|
595
|
+
previousDispatcher.L(
|
596
|
+
/* preload */
|
597
|
+
href, as, options);
|
353
598
|
}
|
354
599
|
}
|
355
600
|
}
|
356
601
|
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
} // Used to distinguish these contexts from ones used in other renderers.
|
361
|
-
function createHints() {
|
362
|
-
return new Set();
|
363
|
-
}
|
602
|
+
function preloadModule$1(href, options) {
|
603
|
+
if (typeof href === 'string') {
|
604
|
+
var request = resolveRequest();
|
364
605
|
|
365
|
-
|
366
|
-
var
|
606
|
+
if (request) {
|
607
|
+
var hints = getHints(request);
|
608
|
+
var key = 'm|' + href;
|
367
609
|
|
368
|
-
|
369
|
-
//
|
370
|
-
|
371
|
-
|
372
|
-
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
373
|
-
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
374
|
-
var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
|
375
|
-
var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
|
376
|
-
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
377
|
-
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
378
|
-
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
379
|
-
var REACT_MEMO_TYPE = Symbol.for('react.memo');
|
380
|
-
var REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
381
|
-
var REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED = Symbol.for('react.default_value');
|
382
|
-
var REACT_MEMO_CACHE_SENTINEL = Symbol.for('react.memo_cache_sentinel');
|
383
|
-
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
384
|
-
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
385
|
-
function getIteratorFn(maybeIterable) {
|
386
|
-
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
387
|
-
return null;
|
388
|
-
}
|
610
|
+
if (hints.has(key)) {
|
611
|
+
// duplicate hint
|
612
|
+
return;
|
613
|
+
}
|
389
614
|
|
390
|
-
|
615
|
+
hints.add(key);
|
616
|
+
var trimmed = trimOptions(options);
|
391
617
|
|
392
|
-
|
393
|
-
|
618
|
+
if (trimmed) {
|
619
|
+
return emitHint(request, 'm', [href, trimmed]);
|
620
|
+
} else {
|
621
|
+
return emitHint(request, 'm', href);
|
622
|
+
}
|
623
|
+
} else {
|
624
|
+
previousDispatcher.m(
|
625
|
+
/* preloadModule */
|
626
|
+
href, options);
|
627
|
+
}
|
394
628
|
}
|
395
|
-
|
396
|
-
return null;
|
397
629
|
}
|
398
630
|
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
// Use this to detect multiple renderers using the same context
|
403
|
-
rendererSigil = {};
|
404
|
-
} // Used to store the parent path of all context overrides in a shared linked list.
|
405
|
-
// Forming a reverse tree.
|
406
|
-
// The structure of a context snapshot is an implementation of this file.
|
407
|
-
// Currently, it's implemented as tracking the current active node.
|
631
|
+
function preinitStyle(href, precedence, options) {
|
632
|
+
if (typeof href === 'string') {
|
633
|
+
var request = resolveRequest();
|
408
634
|
|
635
|
+
if (request) {
|
636
|
+
var hints = getHints(request);
|
637
|
+
var key = 'S|' + href;
|
409
638
|
|
410
|
-
|
411
|
-
//
|
412
|
-
|
639
|
+
if (hints.has(key)) {
|
640
|
+
// duplicate hint
|
641
|
+
return;
|
642
|
+
}
|
413
643
|
|
414
|
-
|
644
|
+
hints.add(key);
|
645
|
+
var trimmed = trimOptions(options);
|
415
646
|
|
416
|
-
|
417
|
-
|
418
|
-
|
647
|
+
if (trimmed) {
|
648
|
+
return emitHint(request, 'S', [href, typeof precedence === 'string' ? precedence : 0, trimmed]);
|
649
|
+
} else if (typeof precedence === 'string') {
|
650
|
+
return emitHint(request, 'S', [href, precedence]);
|
651
|
+
} else {
|
652
|
+
return emitHint(request, 'S', href);
|
653
|
+
}
|
654
|
+
} else {
|
655
|
+
previousDispatcher.S(
|
656
|
+
/* preinitStyle */
|
657
|
+
href, precedence, options);
|
658
|
+
}
|
419
659
|
}
|
420
660
|
}
|
421
661
|
|
422
|
-
function
|
423
|
-
{
|
424
|
-
|
425
|
-
}
|
426
|
-
}
|
662
|
+
function preinitScript(src, options) {
|
663
|
+
if (typeof src === 'string') {
|
664
|
+
var request = resolveRequest();
|
427
665
|
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
var parentPrev = prev.parent;
|
432
|
-
var parentNext = next.parent;
|
666
|
+
if (request) {
|
667
|
+
var hints = getHints(request);
|
668
|
+
var key = 'X|' + src;
|
433
669
|
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
}
|
438
|
-
} else {
|
439
|
-
if (parentNext === null) {
|
440
|
-
throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
|
670
|
+
if (hints.has(key)) {
|
671
|
+
// duplicate hint
|
672
|
+
return;
|
441
673
|
}
|
442
674
|
|
443
|
-
|
675
|
+
hints.add(key);
|
676
|
+
var trimmed = trimOptions(options);
|
444
677
|
|
445
|
-
|
678
|
+
if (trimmed) {
|
679
|
+
return emitHint(request, 'X', [src, trimmed]);
|
680
|
+
} else {
|
681
|
+
return emitHint(request, 'X', src);
|
682
|
+
}
|
683
|
+
} else {
|
684
|
+
previousDispatcher.X(
|
685
|
+
/* preinitScript */
|
686
|
+
src, options);
|
446
687
|
}
|
447
688
|
}
|
448
689
|
}
|
449
690
|
|
450
|
-
function
|
451
|
-
|
452
|
-
|
691
|
+
function preinitModuleScript(src, options) {
|
692
|
+
if (typeof src === 'string') {
|
693
|
+
var request = resolveRequest();
|
453
694
|
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
695
|
+
if (request) {
|
696
|
+
var hints = getHints(request);
|
697
|
+
var key = 'M|' + src;
|
698
|
+
|
699
|
+
if (hints.has(key)) {
|
700
|
+
// duplicate hint
|
701
|
+
return;
|
702
|
+
}
|
458
703
|
|
459
|
-
|
460
|
-
|
704
|
+
hints.add(key);
|
705
|
+
var trimmed = trimOptions(options);
|
461
706
|
|
462
|
-
|
463
|
-
|
707
|
+
if (trimmed) {
|
708
|
+
return emitHint(request, 'M', [src, trimmed]);
|
709
|
+
} else {
|
710
|
+
return emitHint(request, 'M', src);
|
711
|
+
}
|
712
|
+
} else {
|
713
|
+
previousDispatcher.M(
|
714
|
+
/* preinitModuleScript */
|
715
|
+
src, options);
|
716
|
+
}
|
717
|
+
}
|
718
|
+
} // Flight normally encodes undefined as a special character however for directive option
|
719
|
+
// arguments we don't want to send unnecessary keys and bloat the payload so we create a
|
720
|
+
// trimmed object which omits any keys with null or undefined values.
|
721
|
+
// This is only typesafe because these option objects have entirely optional fields where
|
722
|
+
// null and undefined represent the same thing as no property.
|
723
|
+
|
724
|
+
|
725
|
+
function trimOptions(options) {
|
726
|
+
if (options == null) return null;
|
727
|
+
var hasProperties = false;
|
728
|
+
var trimmed = {};
|
729
|
+
|
730
|
+
for (var key in options) {
|
731
|
+
if (options[key] != null) {
|
732
|
+
hasProperties = true;
|
733
|
+
trimmed[key] = options[key];
|
734
|
+
}
|
464
735
|
}
|
465
736
|
|
466
|
-
|
737
|
+
return hasProperties ? trimmed : null;
|
467
738
|
}
|
468
739
|
|
469
|
-
function
|
470
|
-
|
471
|
-
var parentPrev = prev.parent;
|
740
|
+
function getImagePreloadKey(href, imageSrcSet, imageSizes) {
|
741
|
+
var uniquePart = '';
|
472
742
|
|
473
|
-
if (
|
474
|
-
|
475
|
-
}
|
743
|
+
if (typeof imageSrcSet === 'string' && imageSrcSet !== '') {
|
744
|
+
uniquePart += '[' + imageSrcSet + ']';
|
476
745
|
|
477
|
-
|
478
|
-
|
479
|
-
|
746
|
+
if (typeof imageSizes === 'string') {
|
747
|
+
uniquePart += '[' + imageSizes + ']';
|
748
|
+
}
|
480
749
|
} else {
|
481
|
-
|
482
|
-
popPreviousToCommonLevel(parentPrev, next);
|
750
|
+
uniquePart += '[][]' + href;
|
483
751
|
}
|
484
|
-
}
|
485
|
-
|
486
|
-
function popNextToCommonLevel(prev, next) {
|
487
|
-
var parentNext = next.parent;
|
488
752
|
|
489
|
-
|
490
|
-
|
491
|
-
}
|
753
|
+
return "[image]" + uniquePart;
|
754
|
+
}
|
492
755
|
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
popNextToCommonLevel(prev, parentNext);
|
499
|
-
}
|
500
|
-
|
501
|
-
pushNode(next);
|
502
|
-
} // Perform context switching to the new snapshot.
|
503
|
-
// To make it cheap to read many contexts, while not suspending, we make the switch eagerly by
|
504
|
-
// updating all the context's current values. That way reads, always just read the current value.
|
505
|
-
// At the cost of updating contexts even if they're never read by this subtree.
|
506
|
-
|
507
|
-
|
508
|
-
function switchContext(newSnapshot) {
|
509
|
-
// The basic algorithm we need to do is to pop back any contexts that are no longer on the stack.
|
510
|
-
// We also need to update any new contexts that are now on the stack with the deepest value.
|
511
|
-
// The easiest way to update new contexts is to just reapply them in reverse order from the
|
512
|
-
// perspective of the backpointers. To avoid allocating a lot when switching, we use the stack
|
513
|
-
// for that. Therefore this algorithm is recursive.
|
514
|
-
// 1) First we pop which ever snapshot tree was deepest. Popping old contexts as we go.
|
515
|
-
// 2) Then we find the nearest common ancestor from there. Popping old contexts as we go.
|
516
|
-
// 3) Then we reapply new contexts on the way back up the stack.
|
517
|
-
var prev = currentActiveSnapshot;
|
518
|
-
var next = newSnapshot;
|
519
|
-
|
520
|
-
if (prev !== next) {
|
521
|
-
if (prev === null) {
|
522
|
-
// $FlowFixMe[incompatible-call]: This has to be non-null since it's not equal to prev.
|
523
|
-
pushAllNext(next);
|
524
|
-
} else if (next === null) {
|
525
|
-
popAllPrevious(prev);
|
526
|
-
} else if (prev.depth === next.depth) {
|
527
|
-
popToNearestCommonAncestor(prev, next);
|
528
|
-
} else if (prev.depth > next.depth) {
|
529
|
-
popPreviousToCommonLevel(prev, next);
|
530
|
-
} else {
|
531
|
-
popNextToCommonLevel(prev, next);
|
532
|
-
}
|
756
|
+
// This module registers the host dispatcher so it needs to be imported
|
757
|
+
// small, smaller than how we encode undefined, and is unambiguous. We could use
|
758
|
+
// a different tuple structure to encode this instead but this makes the runtime
|
759
|
+
// cost cheaper by eliminating a type checks in more positions.
|
760
|
+
// prettier-ignore
|
533
761
|
|
534
|
-
|
535
|
-
|
762
|
+
function createHints() {
|
763
|
+
return new Set();
|
536
764
|
}
|
537
|
-
function pushProvider(context, nextValue) {
|
538
|
-
var prevValue;
|
539
765
|
|
540
|
-
|
541
|
-
|
542
|
-
context._currentValue = nextValue;
|
766
|
+
var supportsRequestStorage = typeof AsyncLocalStorage === 'function';
|
767
|
+
var requestStorage = supportsRequestStorage ? new AsyncLocalStorage() : null; // We use the Node version but get access to async_hooks from a global.
|
543
768
|
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
769
|
+
typeof async_hooks === 'object' ? async_hooks.createHook : function () {
|
770
|
+
return {
|
771
|
+
enable: function () {},
|
772
|
+
disable: function () {}
|
773
|
+
};
|
774
|
+
};
|
775
|
+
typeof async_hooks === 'object' ? async_hooks.executionAsyncId : null;
|
776
|
+
|
777
|
+
var TEMPORARY_REFERENCE_TAG = Symbol.for('react.temporary.reference'); // eslint-disable-next-line no-unused-vars
|
548
778
|
|
549
|
-
|
779
|
+
function isTemporaryReference(reference) {
|
780
|
+
return reference.$$typeof === TEMPORARY_REFERENCE_TAG;
|
781
|
+
}
|
782
|
+
function resolveTemporaryReferenceID(temporaryReference) {
|
783
|
+
return temporaryReference.$$id;
|
784
|
+
}
|
785
|
+
var proxyHandlers = {
|
786
|
+
get: function (target, name, receiver) {
|
787
|
+
switch (name) {
|
788
|
+
// These names are read by the Flight runtime if you end up using the exports object.
|
789
|
+
case '$$typeof':
|
790
|
+
// These names are a little too common. We should probably have a way to
|
791
|
+
// have the Flight runtime extract the inner target instead.
|
792
|
+
return target.$$typeof;
|
793
|
+
|
794
|
+
case '$$id':
|
795
|
+
return target.$$id;
|
796
|
+
|
797
|
+
case '$$async':
|
798
|
+
return target.$$async;
|
799
|
+
|
800
|
+
case 'name':
|
801
|
+
return undefined;
|
802
|
+
|
803
|
+
case 'displayName':
|
804
|
+
return undefined;
|
805
|
+
// We need to special case this because createElement reads it if we pass this
|
806
|
+
// reference.
|
807
|
+
|
808
|
+
case 'defaultProps':
|
809
|
+
return undefined;
|
810
|
+
// Avoid this attempting to be serialized.
|
811
|
+
|
812
|
+
case 'toJSON':
|
813
|
+
return undefined;
|
814
|
+
|
815
|
+
case Symbol.toPrimitive:
|
816
|
+
// $FlowFixMe[prop-missing]
|
817
|
+
return Object.prototype[Symbol.toPrimitive];
|
818
|
+
|
819
|
+
case Symbol.toStringTag:
|
820
|
+
// $FlowFixMe[prop-missing]
|
821
|
+
return Object.prototype[Symbol.toStringTag];
|
822
|
+
|
823
|
+
case 'Provider':
|
824
|
+
throw new Error("Cannot render a Client Context Provider on the Server. " + "Instead, you can export a Client Component wrapper " + "that itself renders a Client Context Provider.");
|
550
825
|
}
|
551
|
-
}
|
552
826
|
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
827
|
+
throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion
|
828
|
+
"Cannot access " + String(name) + " on the server. " + 'You cannot dot into a temporary client reference from a server component. ' + 'You can only pass the value through to the client.');
|
829
|
+
},
|
830
|
+
set: function () {
|
831
|
+
throw new Error('Cannot assign to a temporary client reference from a server module.');
|
832
|
+
}
|
833
|
+
};
|
834
|
+
function createTemporaryReference(id) {
|
835
|
+
var reference = Object.defineProperties(function () {
|
836
|
+
throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion
|
837
|
+
"Attempted to call a temporary Client Reference from the server but it is on the client. " + "It's not possible to invoke a client function from the server, it can " + "only be rendered as a Component or passed to props of a Client Component.");
|
838
|
+
}, {
|
839
|
+
$$typeof: {
|
840
|
+
value: TEMPORARY_REFERENCE_TAG
|
841
|
+
},
|
842
|
+
$$id: {
|
843
|
+
value: id
|
844
|
+
}
|
845
|
+
});
|
846
|
+
return new Proxy(reference, proxyHandlers);
|
563
847
|
}
|
564
|
-
function popProvider() {
|
565
|
-
var prevSnapshot = currentActiveSnapshot;
|
566
848
|
|
567
|
-
|
568
|
-
|
849
|
+
var REACT_ELEMENT_TYPE = Symbol.for('react.transitional.element') ;
|
850
|
+
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
851
|
+
var REACT_CONTEXT_TYPE = Symbol.for('react.context');
|
852
|
+
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
853
|
+
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
854
|
+
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
855
|
+
var REACT_MEMO_TYPE = Symbol.for('react.memo');
|
856
|
+
var REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
857
|
+
var REACT_MEMO_CACHE_SENTINEL = Symbol.for('react.memo_cache_sentinel');
|
858
|
+
var REACT_POSTPONE_TYPE = Symbol.for('react.postpone');
|
859
|
+
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
860
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
861
|
+
function getIteratorFn(maybeIterable) {
|
862
|
+
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
863
|
+
return null;
|
569
864
|
}
|
570
865
|
|
571
|
-
|
572
|
-
var value = prevSnapshot.parentValue;
|
866
|
+
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
573
867
|
|
574
|
-
|
575
|
-
|
576
|
-
} else {
|
577
|
-
prevSnapshot.context._currentValue = value;
|
578
|
-
}
|
868
|
+
if (typeof maybeIterator === 'function') {
|
869
|
+
return maybeIterator;
|
579
870
|
}
|
580
871
|
|
581
|
-
return
|
582
|
-
}
|
583
|
-
function getActiveContext() {
|
584
|
-
return currentActiveSnapshot;
|
585
|
-
}
|
586
|
-
function readContext$1(context) {
|
587
|
-
var value = context._currentValue ;
|
588
|
-
return value;
|
872
|
+
return null;
|
589
873
|
}
|
590
874
|
|
591
875
|
// Corresponds to ReactFiberWakeable and ReactFizzWakeable modules. Generally,
|
@@ -640,7 +924,14 @@ function trackUsedThenable(thenableState, thenable, index) {
|
|
640
924
|
|
641
925
|
default:
|
642
926
|
{
|
643
|
-
if (typeof thenable.status === 'string')
|
927
|
+
if (typeof thenable.status === 'string') {
|
928
|
+
// Only instrument the thenable if the status if not defined. If
|
929
|
+
// it's defined, but an unknown value, assume it's been instrumented by
|
930
|
+
// some custom userspace implementation. We treat it as "pending".
|
931
|
+
// Attach a dummy listener, to ensure that any lazy initialization can
|
932
|
+
// happen. Flight lazily parses JSON when the value is actually awaited.
|
933
|
+
thenable.then(noop, noop);
|
934
|
+
} else {
|
644
935
|
var pendingThenable = thenable;
|
645
936
|
pendingThenable.status = 'pending';
|
646
937
|
pendingThenable.then(function (fulfilledValue) {
|
@@ -655,21 +946,22 @@ function trackUsedThenable(thenableState, thenable, index) {
|
|
655
946
|
rejectedThenable.status = 'rejected';
|
656
947
|
rejectedThenable.reason = error;
|
657
948
|
}
|
658
|
-
});
|
949
|
+
});
|
950
|
+
} // Check one more time in case the thenable resolved synchronously
|
659
951
|
|
660
|
-
switch (thenable.status) {
|
661
|
-
case 'fulfilled':
|
662
|
-
{
|
663
|
-
var fulfilledThenable = thenable;
|
664
|
-
return fulfilledThenable.value;
|
665
|
-
}
|
666
952
|
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
953
|
+
switch (thenable.status) {
|
954
|
+
case 'fulfilled':
|
955
|
+
{
|
956
|
+
var fulfilledThenable = thenable;
|
957
|
+
return fulfilledThenable.value;
|
958
|
+
}
|
959
|
+
|
960
|
+
case 'rejected':
|
961
|
+
{
|
962
|
+
var rejectedThenable = thenable;
|
963
|
+
throw rejectedThenable.reason;
|
964
|
+
}
|
673
965
|
} // Suspend.
|
674
966
|
//
|
675
967
|
// Throwing here is an implementation detail that allows us to unwind the
|
@@ -705,40 +997,37 @@ function getSuspendedThenable() {
|
|
705
997
|
var currentRequest$1 = null;
|
706
998
|
var thenableIndexCounter = 0;
|
707
999
|
var thenableState = null;
|
1000
|
+
var currentComponentDebugInfo = null;
|
708
1001
|
function prepareToUseHooksForRequest(request) {
|
709
1002
|
currentRequest$1 = request;
|
710
1003
|
}
|
711
1004
|
function resetHooksForRequest() {
|
712
1005
|
currentRequest$1 = null;
|
713
1006
|
}
|
714
|
-
function prepareToUseHooksForComponent(prevThenableState) {
|
1007
|
+
function prepareToUseHooksForComponent(prevThenableState, componentDebugInfo) {
|
715
1008
|
thenableIndexCounter = 0;
|
716
1009
|
thenableState = prevThenableState;
|
1010
|
+
|
1011
|
+
{
|
1012
|
+
currentComponentDebugInfo = componentDebugInfo;
|
1013
|
+
}
|
717
1014
|
}
|
718
1015
|
function getThenableStateAfterSuspending() {
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
1016
|
+
// If you use() to Suspend this should always exist but if you throw a Promise instead,
|
1017
|
+
// which is not really supported anymore, it will be empty. We use the empty set as a
|
1018
|
+
// marker to know if this was a replay of the same component or first attempt.
|
1019
|
+
var state = thenableState || createThenableState();
|
723
1020
|
|
724
|
-
function readContext(context) {
|
725
1021
|
{
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
error('Only createServerContext is supported in Server Components.');
|
731
|
-
}
|
732
|
-
}
|
733
|
-
|
734
|
-
if (currentRequest$1 === null) {
|
735
|
-
error('Context can only be read while React is rendering. ' + 'In classes, you can read it in the render method or getDerivedStateFromProps. ' + 'In function components, you can read it directly in the function body, but not ' + 'inside Hooks like useReducer() or useMemo().');
|
736
|
-
}
|
1022
|
+
// This is a hack but we stash the debug info here so that we don't need a completely
|
1023
|
+
// different data structure just for this in DEV. Not too happy about it.
|
1024
|
+
state._componentDebugInfo = currentComponentDebugInfo;
|
1025
|
+
currentComponentDebugInfo = null;
|
737
1026
|
}
|
738
1027
|
|
739
|
-
|
1028
|
+
thenableState = null;
|
1029
|
+
return state;
|
740
1030
|
}
|
741
|
-
|
742
1031
|
var HooksDispatcher = {
|
743
1032
|
useMemo: function (nextCreate) {
|
744
1033
|
return nextCreate();
|
@@ -749,8 +1038,8 @@ var HooksDispatcher = {
|
|
749
1038
|
useDebugValue: function () {},
|
750
1039
|
useDeferredValue: unsupportedHook,
|
751
1040
|
useTransition: unsupportedHook,
|
752
|
-
readContext:
|
753
|
-
useContext:
|
1041
|
+
readContext: unsupportedContext,
|
1042
|
+
useContext: unsupportedContext,
|
754
1043
|
useReducer: unsupportedHook,
|
755
1044
|
useRef: unsupportedHook,
|
756
1045
|
useState: unsupportedHook,
|
@@ -759,7 +1048,6 @@ var HooksDispatcher = {
|
|
759
1048
|
useImperativeHandle: unsupportedHook,
|
760
1049
|
useEffect: unsupportedHook,
|
761
1050
|
useId: useId,
|
762
|
-
useMutableSource: unsupportedHook,
|
763
1051
|
useSyncExternalStore: unsupportedHook,
|
764
1052
|
useCacheRefresh: function () {
|
765
1053
|
return unsupportedRefresh;
|
@@ -784,6 +1072,10 @@ function unsupportedRefresh() {
|
|
784
1072
|
throw new Error('Refreshing the cache is not supported in Server Components.');
|
785
1073
|
}
|
786
1074
|
|
1075
|
+
function unsupportedContext() {
|
1076
|
+
throw new Error('Cannot read a Client Context from a Server Component.');
|
1077
|
+
}
|
1078
|
+
|
787
1079
|
function useId() {
|
788
1080
|
if (currentRequest$1 === null) {
|
789
1081
|
throw new Error('useId can only be used while React is rendering');
|
@@ -809,24 +1101,22 @@ function use(usable) {
|
|
809
1101
|
}
|
810
1102
|
|
811
1103
|
return trackUsedThenable(thenableState, thenable, index);
|
812
|
-
} else if (usable.$$typeof ===
|
813
|
-
|
814
|
-
return readContext(context);
|
1104
|
+
} else if (usable.$$typeof === REACT_CONTEXT_TYPE) {
|
1105
|
+
unsupportedContext();
|
815
1106
|
}
|
816
1107
|
}
|
817
1108
|
|
818
|
-
{
|
819
|
-
if (
|
820
|
-
|
1109
|
+
if (isClientReference(usable)) {
|
1110
|
+
if (usable.value != null && usable.value.$$typeof === REACT_CONTEXT_TYPE) {
|
1111
|
+
// Show a more specific message since it's a common mistake.
|
1112
|
+
throw new Error('Cannot read a Client Context from a Server Component.');
|
1113
|
+
} else {
|
1114
|
+
throw new Error('Cannot use() an already resolved Client Reference.');
|
821
1115
|
}
|
822
|
-
}
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
}
|
827
|
-
|
828
|
-
function createSignal() {
|
829
|
-
return new AbortController().signal;
|
1116
|
+
} else {
|
1117
|
+
throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion
|
1118
|
+
'An unsupported type was passed to use(): ' + String(usable));
|
1119
|
+
}
|
830
1120
|
}
|
831
1121
|
|
832
1122
|
function resolveCache() {
|
@@ -839,18 +1129,7 @@ function resolveCache() {
|
|
839
1129
|
return new Map();
|
840
1130
|
}
|
841
1131
|
|
842
|
-
var
|
843
|
-
getCacheSignal: function () {
|
844
|
-
var cache = resolveCache();
|
845
|
-
var entry = cache.get(createSignal);
|
846
|
-
|
847
|
-
if (entry === undefined) {
|
848
|
-
entry = createSignal();
|
849
|
-
cache.set(createSignal, entry);
|
850
|
-
}
|
851
|
-
|
852
|
-
return entry;
|
853
|
-
},
|
1132
|
+
var DefaultAsyncDispatcher = {
|
854
1133
|
getCacheForType: function (resourceType) {
|
855
1134
|
var cache = resolveCache();
|
856
1135
|
var entry = cache.get(resourceType);
|
@@ -864,6 +1143,17 @@ var DefaultCacheDispatcher = {
|
|
864
1143
|
return entry;
|
865
1144
|
}
|
866
1145
|
};
|
1146
|
+
var currentOwner = null;
|
1147
|
+
|
1148
|
+
{
|
1149
|
+
DefaultAsyncDispatcher.getOwner = function () {
|
1150
|
+
return currentOwner;
|
1151
|
+
};
|
1152
|
+
}
|
1153
|
+
|
1154
|
+
function setCurrentOwner(componentInfo) {
|
1155
|
+
currentOwner = componentInfo;
|
1156
|
+
}
|
867
1157
|
|
868
1158
|
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
|
869
1159
|
|
@@ -871,6 +1161,8 @@ function isArray(a) {
|
|
871
1161
|
return isArrayImpl(a);
|
872
1162
|
}
|
873
1163
|
|
1164
|
+
var getPrototypeOf = Object.getPrototypeOf;
|
1165
|
+
|
874
1166
|
// in case they error.
|
875
1167
|
|
876
1168
|
var jsxPropsParents = new WeakMap();
|
@@ -889,7 +1181,7 @@ function isObjectPrototype(object) {
|
|
889
1181
|
// still just a plain simple object.
|
890
1182
|
|
891
1183
|
|
892
|
-
if (
|
1184
|
+
if (getPrototypeOf(object)) {
|
893
1185
|
return false;
|
894
1186
|
}
|
895
1187
|
|
@@ -905,7 +1197,7 @@ function isObjectPrototype(object) {
|
|
905
1197
|
}
|
906
1198
|
|
907
1199
|
function isSimpleObject(object) {
|
908
|
-
if (!isObjectPrototype(
|
1200
|
+
if (!isObjectPrototype(getPrototypeOf(object))) {
|
909
1201
|
return false;
|
910
1202
|
}
|
911
1203
|
|
@@ -958,6 +1250,10 @@ function describeValueForErrorMessage(value) {
|
|
958
1250
|
return '[...]';
|
959
1251
|
}
|
960
1252
|
|
1253
|
+
if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) {
|
1254
|
+
return describeClientReference();
|
1255
|
+
}
|
1256
|
+
|
961
1257
|
var name = objectName(value);
|
962
1258
|
|
963
1259
|
if (name === 'Object') {
|
@@ -968,7 +1264,15 @@ function describeValueForErrorMessage(value) {
|
|
968
1264
|
}
|
969
1265
|
|
970
1266
|
case 'function':
|
971
|
-
|
1267
|
+
{
|
1268
|
+
if (value.$$typeof === CLIENT_REFERENCE_TAG) {
|
1269
|
+
return describeClientReference();
|
1270
|
+
}
|
1271
|
+
|
1272
|
+
var _name = value.displayName || value.name;
|
1273
|
+
|
1274
|
+
return _name ? 'function ' + _name : 'function';
|
1275
|
+
}
|
972
1276
|
|
973
1277
|
default:
|
974
1278
|
// eslint-disable-next-line react-internal/safe-string-coercion
|
@@ -1014,6 +1318,12 @@ function describeElementType(type) {
|
|
1014
1318
|
return '';
|
1015
1319
|
}
|
1016
1320
|
|
1321
|
+
var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
|
1322
|
+
|
1323
|
+
function describeClientReference(ref) {
|
1324
|
+
return 'client';
|
1325
|
+
}
|
1326
|
+
|
1017
1327
|
function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
1018
1328
|
var objKind = objectName(objectOrArray);
|
1019
1329
|
|
@@ -1039,7 +1349,6 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1039
1349
|
if (typeof value === 'string') {
|
1040
1350
|
substr = value;
|
1041
1351
|
} else if (typeof value === 'object' && value !== null) {
|
1042
|
-
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1043
1352
|
substr = '{' + describeObjectForErrorMessage(value) + '}';
|
1044
1353
|
} else {
|
1045
1354
|
substr = '{' + describeValueForErrorMessage(value) + '}';
|
@@ -1072,7 +1381,6 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1072
1381
|
var _substr = void 0;
|
1073
1382
|
|
1074
1383
|
if (typeof _value === 'object' && _value !== null) {
|
1075
|
-
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1076
1384
|
_substr = describeObjectForErrorMessage(_value);
|
1077
1385
|
} else {
|
1078
1386
|
_substr = describeValueForErrorMessage(_value);
|
@@ -1094,6 +1402,8 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1094
1402
|
} else {
|
1095
1403
|
if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
|
1096
1404
|
str = '<' + describeElementType(objectOrArray.type) + '/>';
|
1405
|
+
} else if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) {
|
1406
|
+
return describeClientReference();
|
1097
1407
|
} else if (jsxPropsParents.has(objectOrArray)) {
|
1098
1408
|
// Print JSX
|
1099
1409
|
var _type = jsxPropsParents.get(objectOrArray);
|
@@ -1111,7 +1421,6 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1111
1421
|
var _substr2 = void 0;
|
1112
1422
|
|
1113
1423
|
if (name === expandedName && typeof _value2 === 'object' && _value2 !== null) {
|
1114
|
-
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1115
1424
|
_substr2 = describeObjectForErrorMessage(_value2);
|
1116
1425
|
} else {
|
1117
1426
|
_substr2 = describeValueForErrorMessage(_value2);
|
@@ -1145,20 +1454,19 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1145
1454
|
str += ', ';
|
1146
1455
|
}
|
1147
1456
|
|
1148
|
-
var
|
1149
|
-
str += describeKeyForErrorMessage(
|
1150
|
-
var _value3 = _object[
|
1457
|
+
var _name2 = _names[_i3];
|
1458
|
+
str += describeKeyForErrorMessage(_name2) + ': ';
|
1459
|
+
var _value3 = _object[_name2];
|
1151
1460
|
|
1152
1461
|
var _substr3 = void 0;
|
1153
1462
|
|
1154
1463
|
if (typeof _value3 === 'object' && _value3 !== null) {
|
1155
|
-
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1156
1464
|
_substr3 = describeObjectForErrorMessage(_value3);
|
1157
1465
|
} else {
|
1158
1466
|
_substr3 = describeValueForErrorMessage(_value3);
|
1159
1467
|
}
|
1160
1468
|
|
1161
|
-
if (
|
1469
|
+
if (_name2 === expandedName) {
|
1162
1470
|
start = str.length;
|
1163
1471
|
length = _substr3.length;
|
1164
1472
|
str += _substr3;
|
@@ -1185,41 +1493,41 @@ function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
|
1185
1493
|
return '\n ' + str;
|
1186
1494
|
}
|
1187
1495
|
|
1188
|
-
var
|
1189
|
-
function getOrCreateServerContext(globalName) {
|
1190
|
-
if (!ContextRegistry[globalName]) {
|
1191
|
-
ContextRegistry[globalName] = React.createServerContext(globalName, // $FlowFixMe[incompatible-call] function signature doesn't reflect the symbol value
|
1192
|
-
REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED);
|
1193
|
-
}
|
1194
|
-
|
1195
|
-
return ContextRegistry[globalName];
|
1196
|
-
}
|
1496
|
+
var ReactSharedInternals = ReactSharedInternalsServer;
|
1197
1497
|
|
1498
|
+
var ObjectPrototype = Object.prototype;
|
1499
|
+
var stringify = JSON.stringify; // Serializable values
|
1198
1500
|
// Thenable<ReactClientValue>
|
1501
|
+
// task status
|
1199
1502
|
|
1200
1503
|
var PENDING$1 = 0;
|
1201
1504
|
var COMPLETED = 1;
|
1202
1505
|
var ABORTED = 3;
|
1203
|
-
var ERRORED$1 = 4;
|
1204
|
-
|
1205
|
-
var
|
1506
|
+
var ERRORED$1 = 4; // object reference status
|
1507
|
+
|
1508
|
+
var SEEN_BUT_NOT_YET_OUTLINED = -1;
|
1509
|
+
var NEVER_OUTLINED = -2;
|
1206
1510
|
|
1207
1511
|
function defaultErrorHandler(error) {
|
1208
1512
|
console['error'](error); // Don't transform to our wrapper
|
1209
1513
|
}
|
1210
1514
|
|
1515
|
+
function defaultPostponeHandler(reason) {// Noop
|
1516
|
+
}
|
1517
|
+
|
1211
1518
|
var OPEN = 0;
|
1212
1519
|
var CLOSING = 1;
|
1213
1520
|
var CLOSED = 2;
|
1214
|
-
function createRequest(model, bundlerConfig, onError,
|
1215
|
-
if (
|
1521
|
+
function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpone, environmentName) {
|
1522
|
+
if (ReactSharedInternals.A !== null && ReactSharedInternals.A !== DefaultAsyncDispatcher) {
|
1216
1523
|
throw new Error('Currently React only supports one RSC renderer at a time.');
|
1217
1524
|
}
|
1218
1525
|
|
1219
|
-
|
1220
|
-
ReactCurrentCache.current = DefaultCacheDispatcher;
|
1526
|
+
ReactSharedInternals.A = DefaultAsyncDispatcher;
|
1221
1527
|
var abortSet = new Set();
|
1222
1528
|
var pingedTasks = [];
|
1529
|
+
var cleanupQueue = [];
|
1530
|
+
|
1223
1531
|
var hints = createHints();
|
1224
1532
|
var request = {
|
1225
1533
|
status: OPEN,
|
@@ -1231,27 +1539,29 @@ function createRequest(model, bundlerConfig, onError, context, identifierPrefix)
|
|
1231
1539
|
nextChunkId: 0,
|
1232
1540
|
pendingChunks: 0,
|
1233
1541
|
hints: hints,
|
1542
|
+
abortListeners: new Set(),
|
1234
1543
|
abortableTasks: abortSet,
|
1235
1544
|
pingedTasks: pingedTasks,
|
1236
1545
|
completedImportChunks: [],
|
1237
1546
|
completedHintChunks: [],
|
1238
|
-
|
1547
|
+
completedRegularChunks: [],
|
1239
1548
|
completedErrorChunks: [],
|
1240
1549
|
writtenSymbols: new Map(),
|
1241
1550
|
writtenClientReferences: new Map(),
|
1242
1551
|
writtenServerReferences: new Map(),
|
1243
|
-
|
1552
|
+
writtenObjects: new WeakMap(),
|
1244
1553
|
identifierPrefix: identifierPrefix || '',
|
1245
1554
|
identifierCount: 1,
|
1555
|
+
taintCleanupQueue: cleanupQueue,
|
1246
1556
|
onError: onError === undefined ? defaultErrorHandler : onError,
|
1247
|
-
|
1248
|
-
toJSON: function (key, value) {
|
1249
|
-
return resolveModelToJSON(request, this, key, value);
|
1250
|
-
}
|
1557
|
+
onPostpone: onPostpone === undefined ? defaultPostponeHandler : onPostpone
|
1251
1558
|
};
|
1252
|
-
|
1253
|
-
|
1254
|
-
|
1559
|
+
|
1560
|
+
{
|
1561
|
+
request.environmentName = environmentName === undefined ? 'Server' : environmentName;
|
1562
|
+
}
|
1563
|
+
|
1564
|
+
var rootTask = createTask(request, model, null, false, abortSet);
|
1255
1565
|
pingedTasks.push(rootTask);
|
1256
1566
|
return request;
|
1257
1567
|
}
|
@@ -1267,15 +1577,18 @@ function resolveRequest() {
|
|
1267
1577
|
return null;
|
1268
1578
|
}
|
1269
1579
|
|
1270
|
-
function
|
1271
|
-
|
1272
|
-
|
1580
|
+
function serializeThenable(request, task, thenable) {
|
1581
|
+
var newTask = createTask(request, null, task.keyPath, // the server component sequence continues through Promise-as-a-child.
|
1582
|
+
task.implicitSlot, request.abortableTasks);
|
1273
1583
|
|
1274
|
-
|
1584
|
+
{
|
1585
|
+
// If this came from Flight, forward any debug info into this new row.
|
1586
|
+
var debugInfo = thenable._debugInfo;
|
1275
1587
|
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1588
|
+
if (debugInfo) {
|
1589
|
+
forwardDebugInfo(request, newTask.id, debugInfo);
|
1590
|
+
}
|
1591
|
+
}
|
1279
1592
|
|
1280
1593
|
switch (thenable.status) {
|
1281
1594
|
case 'fulfilled':
|
@@ -1289,14 +1602,10 @@ function serializeThenable(request, thenable) {
|
|
1289
1602
|
case 'rejected':
|
1290
1603
|
{
|
1291
1604
|
var x = thenable.reason;
|
1292
|
-
var digest = logRecoverableError(request, x);
|
1293
1605
|
|
1294
1606
|
{
|
1295
|
-
var
|
1296
|
-
|
1297
|
-
stack = _getErrorMessageAndSt.stack;
|
1298
|
-
|
1299
|
-
emitErrorChunkDev(request, newTask.id, digest, message, stack);
|
1607
|
+
var digest = logRecoverableError(request, x);
|
1608
|
+
emitErrorChunk(request, newTask.id, digest, x);
|
1300
1609
|
}
|
1301
1610
|
|
1302
1611
|
return newTask.id;
|
@@ -1334,21 +1643,16 @@ function serializeThenable(request, thenable) {
|
|
1334
1643
|
newTask.model = value;
|
1335
1644
|
pingTask(request, newTask);
|
1336
1645
|
}, function (reason) {
|
1337
|
-
newTask.status = ERRORED$1; // TODO: We should ideally do this inside performWork so it's scheduled
|
1338
|
-
|
1339
|
-
var digest = logRecoverableError(request, reason);
|
1340
|
-
|
1341
1646
|
{
|
1342
|
-
|
1343
|
-
_message = _getErrorMessageAndSt2.message,
|
1344
|
-
_stack = _getErrorMessageAndSt2.stack;
|
1647
|
+
newTask.status = ERRORED$1;
|
1345
1648
|
|
1346
|
-
|
1347
|
-
}
|
1649
|
+
var _digest = logRecoverableError(request, reason);
|
1348
1650
|
|
1349
|
-
|
1350
|
-
flushCompletedChunks(request, request.destination);
|
1651
|
+
emitErrorChunk(request, newTask.id, _digest, reason);
|
1351
1652
|
}
|
1653
|
+
|
1654
|
+
request.abortableTasks.delete(newTask);
|
1655
|
+
enqueueFlush(request);
|
1352
1656
|
});
|
1353
1657
|
return newTask.id;
|
1354
1658
|
}
|
@@ -1417,36 +1721,68 @@ function createLazyWrapperAroundWakeable(wakeable) {
|
|
1417
1721
|
_payload: thenable,
|
1418
1722
|
_init: readThenable
|
1419
1723
|
};
|
1724
|
+
|
1725
|
+
{
|
1726
|
+
// If this came from React, transfer the debug info.
|
1727
|
+
lazyType._debugInfo = thenable._debugInfo || [];
|
1728
|
+
}
|
1729
|
+
|
1420
1730
|
return lazyType;
|
1421
1731
|
}
|
1422
1732
|
|
1423
|
-
function
|
1424
|
-
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1733
|
+
function renderFunctionComponent(request, task, key, Component, props, owner) {
|
1734
|
+
// Reset the task's thenable state before continuing, so that if a later
|
1735
|
+
// component suspends we can reuse the same task object. If the same
|
1736
|
+
// component suspends again, the thenable state will be restored.
|
1737
|
+
var prevThenableState = task.thenableState;
|
1738
|
+
task.thenableState = null;
|
1739
|
+
var componentDebugInfo = null;
|
1430
1740
|
|
1431
1741
|
{
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1742
|
+
if (debugID === null) {
|
1743
|
+
// We don't have a chunk to assign debug info. We need to outline this
|
1744
|
+
// component to assign it an ID.
|
1745
|
+
return outlineTask(request, task);
|
1746
|
+
} else if (prevThenableState !== null) {
|
1747
|
+
// This is a replay and we've already emitted the debug info of this component
|
1748
|
+
// in the first pass. We skip emitting a duplicate line.
|
1749
|
+
// As a hack we stashed the previous component debug info on this object in DEV.
|
1750
|
+
componentDebugInfo = prevThenableState._componentDebugInfo;
|
1751
|
+
} else {
|
1752
|
+
// This is a new component in the same task so we can emit more debug info.
|
1753
|
+
var componentName = Component.displayName || Component.name || '';
|
1754
|
+
request.pendingChunks++;
|
1755
|
+
var componentDebugID = debugID;
|
1756
|
+
componentDebugInfo = {
|
1757
|
+
name: componentName,
|
1758
|
+
env: request.environmentName,
|
1759
|
+
owner: owner
|
1760
|
+
}; // We outline this model eagerly so that we can refer to by reference as an owner.
|
1761
|
+
// If we had a smarter way to dedupe we might not have to do this if there ends up
|
1762
|
+
// being no references to this as an owner.
|
1763
|
+
|
1764
|
+
outlineModel(request, componentDebugInfo);
|
1765
|
+
emitDebugChunk(request, componentDebugID, componentDebugInfo);
|
1436
1766
|
}
|
1437
1767
|
}
|
1438
1768
|
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
} // This is a server-side component.
|
1769
|
+
prepareToUseHooksForComponent(prevThenableState, componentDebugInfo); // The secondArg is always undefined in Server Components since refs error early.
|
1770
|
+
|
1771
|
+
var secondArg = undefined;
|
1772
|
+
var result;
|
1444
1773
|
|
1774
|
+
{
|
1775
|
+
setCurrentOwner(componentDebugInfo);
|
1445
1776
|
|
1446
|
-
|
1447
|
-
|
1777
|
+
try {
|
1778
|
+
result = Component(props, secondArg);
|
1779
|
+
} finally {
|
1780
|
+
setCurrentOwner(null);
|
1781
|
+
}
|
1782
|
+
}
|
1448
1783
|
|
1449
|
-
|
1784
|
+
if (typeof result === 'object' && result !== null) {
|
1785
|
+
if (typeof result.then === 'function') {
|
1450
1786
|
// When the return value is in children position we can resolve it immediately,
|
1451
1787
|
// to its value without a wrapper if it's synchronously available.
|
1452
1788
|
var thenable = result;
|
@@ -1457,29 +1793,228 @@ function attemptResolveElement(request, type, key, ref, props, prevThenableState
|
|
1457
1793
|
// the thenable here.
|
1458
1794
|
|
1459
1795
|
|
1460
|
-
|
1796
|
+
result = createLazyWrapperAroundWakeable(result);
|
1797
|
+
} // Normally we'd serialize an Iterator/AsyncIterator as a single-shot which is not compatible
|
1798
|
+
// to be rendered as a React Child. However, because we have the function to recreate
|
1799
|
+
// an iterable from rendering the element again, we can effectively treat it as multi-
|
1800
|
+
// shot. Therefore we treat this as an Iterable/AsyncIterable, whether it was one or not, by
|
1801
|
+
// adding a wrapper so that this component effectively renders down to an AsyncIterable.
|
1802
|
+
|
1803
|
+
|
1804
|
+
var iteratorFn = getIteratorFn(result);
|
1805
|
+
|
1806
|
+
if (iteratorFn) {
|
1807
|
+
var iterableChild = result;
|
1808
|
+
result = _defineProperty({}, Symbol.iterator, function () {
|
1809
|
+
var iterator = iteratorFn.call(iterableChild);
|
1810
|
+
|
1811
|
+
{
|
1812
|
+
// If this was an Iterator but not a GeneratorFunction we warn because
|
1813
|
+
// it might have been a mistake. Technically you can make this mistake with
|
1814
|
+
// GeneratorFunctions and even single-shot Iterables too but it's extra
|
1815
|
+
// tempting to try to return the value from a generator.
|
1816
|
+
if (iterator === iterableChild) {
|
1817
|
+
var isGeneratorComponent = // $FlowIgnore[method-unbinding]
|
1818
|
+
Object.prototype.toString.call(Component) === '[object GeneratorFunction]' && // $FlowIgnore[method-unbinding]
|
1819
|
+
Object.prototype.toString.call(iterableChild) === '[object Generator]';
|
1820
|
+
|
1821
|
+
if (!isGeneratorComponent) {
|
1822
|
+
error('Returning an Iterator from a Server Component is not supported ' + 'since it cannot be looped over more than once. ');
|
1823
|
+
}
|
1824
|
+
}
|
1825
|
+
}
|
1826
|
+
|
1827
|
+
return iterator;
|
1828
|
+
});
|
1829
|
+
|
1830
|
+
{
|
1831
|
+
result._debugInfo = iterableChild._debugInfo;
|
1832
|
+
}
|
1833
|
+
}
|
1834
|
+
} // Track this element's key on the Server Component on the keyPath context..
|
1835
|
+
|
1836
|
+
|
1837
|
+
var prevKeyPath = task.keyPath;
|
1838
|
+
var prevImplicitSlot = task.implicitSlot;
|
1839
|
+
|
1840
|
+
if (key !== null) {
|
1841
|
+
// Append the key to the path. Technically a null key should really add the child
|
1842
|
+
// index. We don't do that to hold the payload small and implementation simple.
|
1843
|
+
task.keyPath = prevKeyPath === null ? key : prevKeyPath + ',' + key;
|
1844
|
+
} else if (prevKeyPath === null) {
|
1845
|
+
// This sequence of Server Components has no keys. This means that it was rendered
|
1846
|
+
// in a slot that needs to assign an implicit key. Even if children below have
|
1847
|
+
// explicit keys, they should not be used for the outer most key since it might
|
1848
|
+
// collide with other slots in that set.
|
1849
|
+
task.implicitSlot = true;
|
1850
|
+
}
|
1851
|
+
|
1852
|
+
var json = renderModelDestructive(request, task, emptyRoot, '', result);
|
1853
|
+
task.keyPath = prevKeyPath;
|
1854
|
+
task.implicitSlot = prevImplicitSlot;
|
1855
|
+
return json;
|
1856
|
+
}
|
1857
|
+
|
1858
|
+
function renderFragment(request, task, children) {
|
1859
|
+
if (task.keyPath !== null) {
|
1860
|
+
// We have a Server Component that specifies a key but we're now splitting
|
1861
|
+
// the tree using a fragment.
|
1862
|
+
var fragment = [REACT_ELEMENT_TYPE, REACT_FRAGMENT_TYPE, task.keyPath, {
|
1863
|
+
children: children
|
1864
|
+
}];
|
1865
|
+
|
1866
|
+
if (!task.implicitSlot) {
|
1867
|
+
// If this was keyed inside a set. I.e. the outer Server Component was keyed
|
1868
|
+
// then we need to handle reorders of the whole set. To do this we need to wrap
|
1869
|
+
// this array in a keyed Fragment.
|
1870
|
+
return fragment;
|
1871
|
+
} // If the outer Server Component was implicit but then an inner one had a key
|
1872
|
+
// we don't actually need to be able to move the whole set around. It'll always be
|
1873
|
+
// in an implicit slot. The key only exists to be able to reset the state of the
|
1874
|
+
// children. We could achieve the same effect by passing on the keyPath to the next
|
1875
|
+
// set of components inside the fragment. This would also allow a keyless fragment
|
1876
|
+
// reconcile against a single child.
|
1877
|
+
// Unfortunately because of JSON.stringify, we can't call the recursive loop for
|
1878
|
+
// each child within this context because we can't return a set with already resolved
|
1879
|
+
// values. E.g. a string would get double encoded. Returning would pop the context.
|
1880
|
+
// So instead, we wrap it with an unkeyed fragment and inner keyed fragment.
|
1881
|
+
|
1882
|
+
|
1883
|
+
return [fragment];
|
1884
|
+
} // Since we're yielding here, that implicitly resets the keyPath context on the
|
1885
|
+
// way up. Which is what we want since we've consumed it. If this changes to
|
1886
|
+
// be recursive serialization, we need to reset the keyPath and implicitSlot,
|
1887
|
+
// before recursing here.
|
1888
|
+
|
1889
|
+
|
1890
|
+
{
|
1891
|
+
var debugInfo = children._debugInfo;
|
1892
|
+
|
1893
|
+
if (debugInfo) {
|
1894
|
+
// If this came from Flight, forward any debug info into this new row.
|
1895
|
+
if (debugID === null) {
|
1896
|
+
// We don't have a chunk to assign debug info. We need to outline this
|
1897
|
+
// component to assign it an ID.
|
1898
|
+
return outlineTask(request, task);
|
1899
|
+
} else {
|
1900
|
+
// Forward any debug info we have the first time we see it.
|
1901
|
+
// We do this after init so that we have received all the debug info
|
1902
|
+
// from the server by the time we emit it.
|
1903
|
+
forwardDebugInfo(request, debugID, debugInfo);
|
1904
|
+
} // Since we're rendering this array again, create a copy that doesn't
|
1905
|
+
// have the debug info so we avoid outlining or emitting debug info again.
|
1906
|
+
|
1907
|
+
|
1908
|
+
children = Array.from(children);
|
1909
|
+
}
|
1910
|
+
}
|
1911
|
+
|
1912
|
+
return children;
|
1913
|
+
}
|
1914
|
+
|
1915
|
+
function renderClientElement(task, type, key, props, owner) // DEV-only
|
1916
|
+
{
|
1917
|
+
// the keys of any Server Components which are not serialized.
|
1918
|
+
|
1919
|
+
|
1920
|
+
var keyPath = task.keyPath;
|
1921
|
+
|
1922
|
+
if (key === null) {
|
1923
|
+
key = keyPath;
|
1924
|
+
} else if (keyPath !== null) {
|
1925
|
+
key = keyPath + ',' + key;
|
1926
|
+
}
|
1927
|
+
|
1928
|
+
var element = [REACT_ELEMENT_TYPE, type, key, props, owner] ;
|
1929
|
+
|
1930
|
+
if (task.implicitSlot && key !== null) {
|
1931
|
+
// The root Server Component had no key so it was in an implicit slot.
|
1932
|
+
// If we had a key lower, it would end up in that slot with an explicit key.
|
1933
|
+
// We wrap the element in a fragment to give it an implicit key slot with
|
1934
|
+
// an inner explicit key.
|
1935
|
+
return [element];
|
1936
|
+
} // Since we're yielding here, that implicitly resets the keyPath context on the
|
1937
|
+
// way up. Which is what we want since we've consumed it. If this changes to
|
1938
|
+
// be recursive serialization, we need to reset the keyPath and implicitSlot,
|
1939
|
+
// before recursing here. We also need to reset it once we render into an array
|
1940
|
+
// or anything else too which we also get implicitly.
|
1941
|
+
|
1942
|
+
|
1943
|
+
return element;
|
1944
|
+
} // The chunk ID we're currently rendering that we can assign debug data to.
|
1945
|
+
|
1946
|
+
|
1947
|
+
var debugID = null;
|
1948
|
+
|
1949
|
+
function outlineTask(request, task) {
|
1950
|
+
var newTask = createTask(request, task.model, // the currently rendering element
|
1951
|
+
task.keyPath, // unlike outlineModel this one carries along context
|
1952
|
+
task.implicitSlot, request.abortableTasks);
|
1953
|
+
retryTask(request, newTask);
|
1954
|
+
|
1955
|
+
if (newTask.status === COMPLETED) {
|
1956
|
+
// We completed synchronously so we can refer to this by reference. This
|
1957
|
+
// makes it behaves the same as prod during deserialization.
|
1958
|
+
return serializeByValueID(newTask.id);
|
1959
|
+
} // This didn't complete synchronously so it wouldn't have even if we didn't
|
1960
|
+
// outline it, so this would reduce to a lazy reference even in prod.
|
1961
|
+
|
1962
|
+
|
1963
|
+
return serializeLazyID(newTask.id);
|
1964
|
+
}
|
1965
|
+
|
1966
|
+
function renderElement(request, task, type, key, ref, props, owner) // DEV only
|
1967
|
+
{
|
1968
|
+
if (ref !== null && ref !== undefined) {
|
1969
|
+
// When the ref moves to the regular props object this will implicitly
|
1970
|
+
// throw for functions. We could probably relax it to a DEV warning for other
|
1971
|
+
// cases.
|
1972
|
+
// TODO: `ref` is now just a prop when `enableRefAsProp` is on. Should we
|
1973
|
+
// do what the above comment says?
|
1974
|
+
throw new Error('Refs cannot be used in Server Components, nor passed to Client Components.');
|
1975
|
+
}
|
1976
|
+
|
1977
|
+
{
|
1978
|
+
jsxPropsParents.set(props, type);
|
1979
|
+
|
1980
|
+
if (typeof props.children === 'object' && props.children !== null) {
|
1981
|
+
jsxChildrenParents.set(props.children, type);
|
1461
1982
|
}
|
1983
|
+
}
|
1984
|
+
|
1985
|
+
if (typeof type === 'function') {
|
1986
|
+
if (isClientReference(type) || isTemporaryReference(type)) {
|
1987
|
+
// This is a reference to a Client Component.
|
1988
|
+
return renderClientElement(task, type, key, props, owner);
|
1989
|
+
} // This is a Server Component.
|
1990
|
+
|
1462
1991
|
|
1463
|
-
return
|
1992
|
+
return renderFunctionComponent(request, task, key, type, props, owner);
|
1464
1993
|
} else if (typeof type === 'string') {
|
1465
1994
|
// This is a host element. E.g. HTML.
|
1466
|
-
return
|
1995
|
+
return renderClientElement(task, type, key, props, owner);
|
1467
1996
|
} else if (typeof type === 'symbol') {
|
1468
|
-
if (type === REACT_FRAGMENT_TYPE) {
|
1997
|
+
if (type === REACT_FRAGMENT_TYPE && key === null) {
|
1469
1998
|
// For key-less fragments, we add a small optimization to avoid serializing
|
1470
1999
|
// it as a wrapper.
|
1471
|
-
|
1472
|
-
|
1473
|
-
|
2000
|
+
var prevImplicitSlot = task.implicitSlot;
|
2001
|
+
|
2002
|
+
if (task.keyPath === null) {
|
2003
|
+
task.implicitSlot = true;
|
2004
|
+
}
|
2005
|
+
|
2006
|
+
var json = renderModelDestructive(request, task, emptyRoot, '', props.children);
|
2007
|
+
task.implicitSlot = prevImplicitSlot;
|
2008
|
+
return json;
|
1474
2009
|
} // This might be a built-in React component. We'll let the client decide.
|
1475
2010
|
// Any built-in works as long as its props are serializable.
|
1476
2011
|
|
1477
2012
|
|
1478
|
-
return
|
2013
|
+
return renderClientElement(task, type, key, props, owner);
|
1479
2014
|
} else if (type != null && typeof type === 'object') {
|
1480
2015
|
if (isClientReference(type)) {
|
1481
2016
|
// This is a reference to a Client Component.
|
1482
|
-
return
|
2017
|
+
return renderClientElement(task, type, key, props, owner);
|
1483
2018
|
}
|
1484
2019
|
|
1485
2020
|
switch (type.$$typeof) {
|
@@ -1488,45 +2023,17 @@ function attemptResolveElement(request, type, key, ref, props, prevThenableState
|
|
1488
2023
|
var payload = type._payload;
|
1489
2024
|
var init = type._init;
|
1490
2025
|
var wrappedType = init(payload);
|
1491
|
-
return
|
2026
|
+
return renderElement(request, task, wrappedType, key, ref, props, owner);
|
1492
2027
|
}
|
1493
2028
|
|
1494
2029
|
case REACT_FORWARD_REF_TYPE:
|
1495
2030
|
{
|
1496
|
-
|
1497
|
-
prepareToUseHooksForComponent(prevThenableState);
|
1498
|
-
return render(props, undefined);
|
2031
|
+
return renderFunctionComponent(request, task, key, type.render, props, owner);
|
1499
2032
|
}
|
1500
2033
|
|
1501
2034
|
case REACT_MEMO_TYPE:
|
1502
2035
|
{
|
1503
|
-
return
|
1504
|
-
}
|
1505
|
-
|
1506
|
-
case REACT_PROVIDER_TYPE:
|
1507
|
-
{
|
1508
|
-
pushProvider(type._context, props.value);
|
1509
|
-
|
1510
|
-
{
|
1511
|
-
var extraKeys = Object.keys(props).filter(function (value) {
|
1512
|
-
if (value === 'children' || value === 'value') {
|
1513
|
-
return false;
|
1514
|
-
}
|
1515
|
-
|
1516
|
-
return true;
|
1517
|
-
});
|
1518
|
-
|
1519
|
-
if (extraKeys.length !== 0) {
|
1520
|
-
error('ServerContext can only have a value prop and children. Found: %s', JSON.stringify(extraKeys));
|
1521
|
-
}
|
1522
|
-
}
|
1523
|
-
|
1524
|
-
return [REACT_ELEMENT_TYPE, type, key, // Rely on __popProvider being serialized last to pop the provider.
|
1525
|
-
{
|
1526
|
-
value: props.value,
|
1527
|
-
children: props.children,
|
1528
|
-
__pop: POP
|
1529
|
-
}];
|
2036
|
+
return renderElement(request, task, type.type, key, ref, props, owner);
|
1530
2037
|
}
|
1531
2038
|
}
|
1532
2039
|
}
|
@@ -1546,16 +2053,51 @@ function pingTask(request, task) {
|
|
1546
2053
|
}
|
1547
2054
|
}
|
1548
2055
|
|
1549
|
-
function createTask(request, model,
|
2056
|
+
function createTask(request, model, keyPath, implicitSlot, abortSet) {
|
2057
|
+
request.pendingChunks++;
|
1550
2058
|
var id = request.nextChunkId++;
|
2059
|
+
|
2060
|
+
if (typeof model === 'object' && model !== null) {
|
2061
|
+
// If we're about to write this into a new task we can assign it an ID early so that
|
2062
|
+
// any other references can refer to the value we're about to write.
|
2063
|
+
if ((keyPath !== null || implicitSlot)) ; else {
|
2064
|
+
request.writtenObjects.set(model, id);
|
2065
|
+
}
|
2066
|
+
}
|
2067
|
+
|
1551
2068
|
var task = {
|
1552
2069
|
id: id,
|
1553
2070
|
status: PENDING$1,
|
1554
2071
|
model: model,
|
1555
|
-
|
2072
|
+
keyPath: keyPath,
|
2073
|
+
implicitSlot: implicitSlot,
|
1556
2074
|
ping: function () {
|
1557
2075
|
return pingTask(request, task);
|
1558
2076
|
},
|
2077
|
+
toJSON: function (parentPropertyName, value) {
|
2078
|
+
var parent = this; // Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us
|
2079
|
+
|
2080
|
+
{
|
2081
|
+
// $FlowFixMe[incompatible-use]
|
2082
|
+
var originalValue = parent[parentPropertyName];
|
2083
|
+
|
2084
|
+
if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
|
2085
|
+
if (objectName(originalValue) !== 'Object') {
|
2086
|
+
var jsxParentType = jsxChildrenParents.get(parent);
|
2087
|
+
|
2088
|
+
if (typeof jsxParentType === 'string') {
|
2089
|
+
error('%s objects cannot be rendered as text children. Try formatting it using toString().%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
|
2090
|
+
} else {
|
2091
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
|
2092
|
+
}
|
2093
|
+
} else {
|
2094
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + 'Objects with toJSON methods are not supported. Convert it manually ' + 'to a simple value before passing it to props.%s', describeObjectForErrorMessage(parent, parentPropertyName));
|
2095
|
+
}
|
2096
|
+
}
|
2097
|
+
}
|
2098
|
+
|
2099
|
+
return renderModel(request, task, parent, parentPropertyName, value);
|
2100
|
+
},
|
1559
2101
|
thenableState: null
|
1560
2102
|
};
|
1561
2103
|
abortSet.add(task);
|
@@ -1570,6 +2112,10 @@ function serializeLazyID(id) {
|
|
1570
2112
|
return '$L' + id.toString(16);
|
1571
2113
|
}
|
1572
2114
|
|
2115
|
+
function serializeInfinitePromise() {
|
2116
|
+
return '$@';
|
2117
|
+
}
|
2118
|
+
|
1573
2119
|
function serializePromiseID(id) {
|
1574
2120
|
return '$@' + id.toString(16);
|
1575
2121
|
}
|
@@ -1578,12 +2124,12 @@ function serializeServerReferenceID(id) {
|
|
1578
2124
|
return '$F' + id.toString(16);
|
1579
2125
|
}
|
1580
2126
|
|
1581
|
-
function
|
1582
|
-
return '$
|
2127
|
+
function serializeTemporaryReferenceID(id) {
|
2128
|
+
return '$T' + id;
|
1583
2129
|
}
|
1584
2130
|
|
1585
|
-
function
|
1586
|
-
return '$
|
2131
|
+
function serializeSymbolReference(name) {
|
2132
|
+
return '$S' + name;
|
1587
2133
|
}
|
1588
2134
|
|
1589
2135
|
function serializeNumber(number) {
|
@@ -1618,13 +2164,23 @@ function serializeBigInt(n) {
|
|
1618
2164
|
return '$n' + n.toString(10);
|
1619
2165
|
}
|
1620
2166
|
|
1621
|
-
function
|
2167
|
+
function serializeRowHeader(tag, id) {
|
2168
|
+
return id.toString(16) + ':' + tag;
|
2169
|
+
}
|
2170
|
+
|
2171
|
+
function encodeReferenceChunk(request, id, reference) {
|
2172
|
+
var json = stringify(reference);
|
2173
|
+
var row = id.toString(16) + ':' + json + '\n';
|
2174
|
+
return stringToChunk(row);
|
2175
|
+
}
|
2176
|
+
|
2177
|
+
function serializeClientReference(request, parent, parentPropertyName, clientReference) {
|
1622
2178
|
var clientReferenceKey = getClientReferenceKey(clientReference);
|
1623
2179
|
var writtenClientReferences = request.writtenClientReferences;
|
1624
2180
|
var existingId = writtenClientReferences.get(clientReferenceKey);
|
1625
2181
|
|
1626
2182
|
if (existingId !== undefined) {
|
1627
|
-
if (parent[0] === REACT_ELEMENT_TYPE &&
|
2183
|
+
if (parent[0] === REACT_ELEMENT_TYPE && parentPropertyName === '1') {
|
1628
2184
|
// If we're encoding the "type" of an element, we can refer
|
1629
2185
|
// to that by a lazy reference instead of directly since React
|
1630
2186
|
// knows how to deal with lazy values. This lets us suspend
|
@@ -1643,7 +2199,7 @@ function serializeClientReference(request, parent, key, clientReference) {
|
|
1643
2199
|
emitImportChunk(request, importId, clientReferenceMetadata);
|
1644
2200
|
writtenClientReferences.set(clientReferenceKey, importId);
|
1645
2201
|
|
1646
|
-
if (parent[0] === REACT_ELEMENT_TYPE &&
|
2202
|
+
if (parent[0] === REACT_ELEMENT_TYPE && parentPropertyName === '1') {
|
1647
2203
|
// If we're encoding the "type" of an element, we can refer
|
1648
2204
|
// to that by a lazy reference instead of directly since React
|
1649
2205
|
// knows how to deal with lazy values. This lets us suspend
|
@@ -1657,20 +2213,20 @@ function serializeClientReference(request, parent, key, clientReference) {
|
|
1657
2213
|
request.pendingChunks++;
|
1658
2214
|
var errorId = request.nextChunkId++;
|
1659
2215
|
var digest = logRecoverableError(request, x);
|
1660
|
-
|
1661
|
-
{
|
1662
|
-
var _getErrorMessageAndSt3 = getErrorMessageAndStackDev(x),
|
1663
|
-
message = _getErrorMessageAndSt3.message,
|
1664
|
-
stack = _getErrorMessageAndSt3.stack;
|
1665
|
-
|
1666
|
-
emitErrorChunkDev(request, errorId, digest, message, stack);
|
1667
|
-
}
|
1668
|
-
|
2216
|
+
emitErrorChunk(request, errorId, digest, x);
|
1669
2217
|
return serializeByValueID(errorId);
|
1670
2218
|
}
|
1671
2219
|
}
|
1672
2220
|
|
1673
|
-
function
|
2221
|
+
function outlineModel(request, value) {
|
2222
|
+
var newTask = createTask(request, value, null, // The way we use outlining is for reusing an object.
|
2223
|
+
false, // It makes no sense for that use case to be contextual.
|
2224
|
+
request.abortableTasks);
|
2225
|
+
retryTask(request, newTask);
|
2226
|
+
return newTask.id;
|
2227
|
+
}
|
2228
|
+
|
2229
|
+
function serializeServerReference(request, serverReference) {
|
1674
2230
|
var writtenServerReferences = request.writtenServerReferences;
|
1675
2231
|
var existingId = writtenServerReferences.get(serverReference);
|
1676
2232
|
|
@@ -1683,187 +2239,733 @@ function serializeServerReference(request, parent, key, serverReference) {
|
|
1683
2239
|
id: getServerReferenceId(request.bundlerConfig, serverReference),
|
1684
2240
|
bound: bound ? Promise.resolve(bound) : null
|
1685
2241
|
};
|
1686
|
-
request
|
1687
|
-
var metadataId = request.nextChunkId++; // We assume that this object doesn't suspend.
|
1688
|
-
|
1689
|
-
var processedChunk = processModelChunk(request, metadataId, serverReferenceMetadata);
|
1690
|
-
request.completedJSONChunks.push(processedChunk);
|
2242
|
+
var metadataId = outlineModel(request, serverReferenceMetadata);
|
1691
2243
|
writtenServerReferences.set(serverReference, metadataId);
|
1692
2244
|
return serializeServerReferenceID(metadataId);
|
1693
2245
|
}
|
1694
2246
|
|
1695
|
-
function
|
1696
|
-
|
1697
|
-
|
1698
|
-
// references to IDs and as special symbol values.
|
1699
|
-
return '$' + value;
|
1700
|
-
} else {
|
1701
|
-
return value;
|
1702
|
-
}
|
2247
|
+
function serializeTemporaryReference(request, temporaryReference) {
|
2248
|
+
var id = resolveTemporaryReferenceID(temporaryReference);
|
2249
|
+
return serializeTemporaryReferenceID(id);
|
1703
2250
|
}
|
1704
2251
|
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
|
1710
|
-
|
1711
|
-
var originalValue = parent[key];
|
2252
|
+
function serializeLargeTextString(request, text) {
|
2253
|
+
request.pendingChunks++;
|
2254
|
+
var textId = request.nextChunkId++;
|
2255
|
+
emitTextChunk(request, textId, text);
|
2256
|
+
return serializeByValueID(textId);
|
2257
|
+
}
|
1712
2258
|
|
1713
|
-
|
1714
|
-
|
1715
|
-
var jsxParentType = jsxChildrenParents.get(parent);
|
2259
|
+
function serializeMap(request, map) {
|
2260
|
+
var entries = Array.from(map);
|
1716
2261
|
|
1717
|
-
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1722
|
-
|
1723
|
-
|
2262
|
+
for (var i = 0; i < entries.length; i++) {
|
2263
|
+
var key = entries[i][0];
|
2264
|
+
|
2265
|
+
if (typeof key === 'object' && key !== null) {
|
2266
|
+
var writtenObjects = request.writtenObjects;
|
2267
|
+
var existingId = writtenObjects.get(key);
|
2268
|
+
|
2269
|
+
if (existingId === undefined) {
|
2270
|
+
writtenObjects.set(key, SEEN_BUT_NOT_YET_OUTLINED);
|
1724
2271
|
}
|
1725
2272
|
}
|
1726
|
-
}
|
2273
|
+
}
|
1727
2274
|
|
2275
|
+
var id = outlineModel(request, entries);
|
2276
|
+
return '$Q' + id.toString(16);
|
2277
|
+
}
|
1728
2278
|
|
1729
|
-
|
1730
|
-
|
1731
|
-
|
1732
|
-
|
2279
|
+
function serializeFormData(request, formData) {
|
2280
|
+
var entries = Array.from(formData.entries());
|
2281
|
+
var id = outlineModel(request, entries);
|
2282
|
+
return '$K' + id.toString(16);
|
2283
|
+
}
|
1733
2284
|
|
1734
|
-
|
1735
|
-
|
1736
|
-
insideContextProps = value;
|
1737
|
-
} else if (insideContextProps === parent && key === 'value') {
|
1738
|
-
isInsideContextValue = true;
|
1739
|
-
} else if (insideContextProps === parent && key === 'children') {
|
1740
|
-
isInsideContextValue = false;
|
1741
|
-
}
|
1742
|
-
} // Resolve Server Components.
|
2285
|
+
function serializeSet(request, set) {
|
2286
|
+
var entries = Array.from(set);
|
1743
2287
|
|
2288
|
+
for (var i = 0; i < entries.length; i++) {
|
2289
|
+
var key = entries[i];
|
1744
2290
|
|
1745
|
-
|
1746
|
-
|
1747
|
-
|
1748
|
-
|
2291
|
+
if (typeof key === 'object' && key !== null) {
|
2292
|
+
var writtenObjects = request.writtenObjects;
|
2293
|
+
var existingId = writtenObjects.get(key);
|
2294
|
+
|
2295
|
+
if (existingId === undefined) {
|
2296
|
+
writtenObjects.set(key, SEEN_BUT_NOT_YET_OUTLINED);
|
1749
2297
|
}
|
1750
2298
|
}
|
2299
|
+
}
|
1751
2300
|
|
1752
|
-
|
1753
|
-
|
1754
|
-
|
1755
|
-
{
|
1756
|
-
// TODO: Concatenate keys of parents onto children.
|
1757
|
-
var element = value; // Attempt to render the Server Component.
|
2301
|
+
var id = outlineModel(request, entries);
|
2302
|
+
return '$W' + id.toString(16);
|
2303
|
+
}
|
1758
2304
|
|
1759
|
-
|
1760
|
-
|
1761
|
-
|
2305
|
+
function serializeIterator(request, iterator) {
|
2306
|
+
var id = outlineModel(request, Array.from(iterator));
|
2307
|
+
return '$i' + id.toString(16);
|
2308
|
+
}
|
1762
2309
|
|
1763
|
-
|
1764
|
-
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
|
1769
|
-
|
1770
|
-
|
1771
|
-
|
1772
|
-
|
1773
|
-
|
1774
|
-
|
1775
|
-
|
1776
|
-
|
1777
|
-
|
1778
|
-
|
1779
|
-
|
2310
|
+
function escapeStringValue(value) {
|
2311
|
+
if (value[0] === '$') {
|
2312
|
+
// We need to escape $ prefixed strings since we use those to encode
|
2313
|
+
// references to IDs and as special symbol values.
|
2314
|
+
return '$' + value;
|
2315
|
+
} else {
|
2316
|
+
return value;
|
2317
|
+
}
|
2318
|
+
}
|
2319
|
+
|
2320
|
+
var modelRoot = false;
|
2321
|
+
|
2322
|
+
function renderModel(request, task, parent, key, value) {
|
2323
|
+
var prevKeyPath = task.keyPath;
|
2324
|
+
var prevImplicitSlot = task.implicitSlot;
|
2325
|
+
|
2326
|
+
try {
|
2327
|
+
return renderModelDestructive(request, task, parent, key, value);
|
2328
|
+
} catch (thrownValue) {
|
2329
|
+
var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
|
2330
|
+
// reasons, the rest of the Suspense implementation expects the thrown
|
2331
|
+
// value to be a thenable, because before `use` existed that was the
|
2332
|
+
// (unstable) API for suspending. This implementation detail can change
|
2333
|
+
// later, once we deprecate the old API in favor of `use`.
|
2334
|
+
getSuspendedThenable() : thrownValue; // If the suspended/errored value was an element or lazy it can be reduced
|
2335
|
+
// to a lazy reference, so that it doesn't error the parent.
|
2336
|
+
|
2337
|
+
var model = task.model;
|
2338
|
+
var wasReactNode = typeof model === 'object' && model !== null && (model.$$typeof === REACT_ELEMENT_TYPE || model.$$typeof === REACT_LAZY_TYPE);
|
2339
|
+
|
2340
|
+
if (typeof x === 'object' && x !== null) {
|
2341
|
+
// $FlowFixMe[method-unbinding]
|
2342
|
+
if (typeof x.then === 'function') {
|
1780
2343
|
// Something suspended, we'll need to create a new task and resolve it later.
|
1781
|
-
request.
|
1782
|
-
var newTask = createTask(request, value, getActiveContext(), request.abortableTasks);
|
2344
|
+
var newTask = createTask(request, task.model, task.keyPath, task.implicitSlot, request.abortableTasks);
|
1783
2345
|
var ping = newTask.ping;
|
1784
2346
|
x.then(ping, ping);
|
1785
|
-
newTask.thenableState = getThenableStateAfterSuspending();
|
1786
|
-
|
1787
|
-
|
1788
|
-
|
1789
|
-
|
1790
|
-
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
2347
|
+
newTask.thenableState = getThenableStateAfterSuspending(); // Restore the context. We assume that this will be restored by the inner
|
2348
|
+
// functions in case nothing throws so we don't use "finally" here.
|
2349
|
+
|
2350
|
+
task.keyPath = prevKeyPath;
|
2351
|
+
task.implicitSlot = prevImplicitSlot;
|
2352
|
+
|
2353
|
+
if (wasReactNode) {
|
2354
|
+
return serializeLazyID(newTask.id);
|
2355
|
+
}
|
2356
|
+
|
2357
|
+
return serializeByValueID(newTask.id);
|
2358
|
+
}
|
2359
|
+
} // Restore the context. We assume that this will be restored by the inner
|
2360
|
+
// functions in case nothing throws so we don't use "finally" here.
|
2361
|
+
|
2362
|
+
|
2363
|
+
task.keyPath = prevKeyPath;
|
2364
|
+
task.implicitSlot = prevImplicitSlot;
|
1794
2365
|
|
2366
|
+
if (wasReactNode) {
|
2367
|
+
// Something errored. We'll still send everything we have up until this point.
|
2368
|
+
// We'll replace this element with a lazy reference that throws on the client
|
2369
|
+
// once it gets rendered.
|
2370
|
+
request.pendingChunks++;
|
2371
|
+
var errorId = request.nextChunkId++;
|
2372
|
+
var digest = logRecoverableError(request, x);
|
2373
|
+
emitErrorChunk(request, errorId, digest, x);
|
2374
|
+
return serializeLazyID(errorId);
|
2375
|
+
} // Something errored but it was not in a React Node. There's no need to serialize
|
2376
|
+
// it by value because it'll just error the whole parent row anyway so we can
|
2377
|
+
// just stop any siblings and error the whole parent row.
|
2378
|
+
|
2379
|
+
|
2380
|
+
throw x;
|
2381
|
+
}
|
2382
|
+
}
|
2383
|
+
|
2384
|
+
function renderModelDestructive(request, task, parent, parentPropertyName, value) {
|
2385
|
+
// Set the currently rendering model
|
2386
|
+
task.model = value; // Special Symbol, that's very common.
|
2387
|
+
|
2388
|
+
if (value === REACT_ELEMENT_TYPE) {
|
2389
|
+
return '$';
|
2390
|
+
}
|
2391
|
+
|
2392
|
+
if (value === null) {
|
2393
|
+
return null;
|
2394
|
+
}
|
2395
|
+
|
2396
|
+
if (typeof value === 'object') {
|
2397
|
+
switch (value.$$typeof) {
|
2398
|
+
case REACT_ELEMENT_TYPE:
|
1795
2399
|
{
|
1796
|
-
var
|
1797
|
-
|
1798
|
-
|
2400
|
+
var _writtenObjects = request.writtenObjects;
|
2401
|
+
|
2402
|
+
var _existingId = _writtenObjects.get(value);
|
2403
|
+
|
2404
|
+
if (_existingId !== undefined) {
|
2405
|
+
if ((task.keyPath !== null || task.implicitSlot)) ; else if (modelRoot === value) {
|
2406
|
+
// This is the ID we're currently emitting so we need to write it
|
2407
|
+
// once but if we discover it again, we refer to it by id.
|
2408
|
+
modelRoot = null;
|
2409
|
+
} else if (_existingId === SEEN_BUT_NOT_YET_OUTLINED) {
|
2410
|
+
// TODO: If we throw here we can treat this as suspending which causes an outline
|
2411
|
+
// but that is able to reuse the same task if we're already in one but then that
|
2412
|
+
// will be a lazy future value rather than guaranteed to exist but maybe that's good.
|
2413
|
+
var newId = outlineModel(request, value);
|
2414
|
+
return serializeByValueID(newId);
|
2415
|
+
} else {
|
2416
|
+
// We've already emitted this as an outlined object, so we can refer to that by its
|
2417
|
+
// existing ID. TODO: We should use a lazy reference since, unlike plain objects,
|
2418
|
+
// elements might suspend so it might not have emitted yet even if we have the ID for
|
2419
|
+
// it. However, this creates an extra wrapper when it's not needed. We should really
|
2420
|
+
// detect whether this already was emitted and synchronously available. In that
|
2421
|
+
// case we can refer to it synchronously and only make it lazy otherwise.
|
2422
|
+
// We currently don't have a data structure that lets us see that though.
|
2423
|
+
return serializeByValueID(_existingId);
|
2424
|
+
}
|
2425
|
+
} else {
|
2426
|
+
// This is the first time we've seen this object. We may never see it again
|
2427
|
+
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
|
2428
|
+
_writtenObjects.set(value, SEEN_BUT_NOT_YET_OUTLINED); // The element's props are marked as "never outlined" so that they are inlined into
|
2429
|
+
// the same row as the element itself.
|
1799
2430
|
|
1800
|
-
|
2431
|
+
|
2432
|
+
_writtenObjects.set(value.props, NEVER_OUTLINED);
|
2433
|
+
}
|
2434
|
+
|
2435
|
+
var element = value;
|
2436
|
+
|
2437
|
+
{
|
2438
|
+
var debugInfo = value._debugInfo;
|
2439
|
+
|
2440
|
+
if (debugInfo) {
|
2441
|
+
// If this came from Flight, forward any debug info into this new row.
|
2442
|
+
if (debugID === null) {
|
2443
|
+
// We don't have a chunk to assign debug info. We need to outline this
|
2444
|
+
// component to assign it an ID.
|
2445
|
+
return outlineTask(request, task);
|
2446
|
+
} else {
|
2447
|
+
// Forward any debug info we have the first time we see it.
|
2448
|
+
forwardDebugInfo(request, debugID, debugInfo);
|
2449
|
+
}
|
2450
|
+
}
|
2451
|
+
}
|
2452
|
+
|
2453
|
+
var props = element.props;
|
2454
|
+
var ref;
|
2455
|
+
|
2456
|
+
{
|
2457
|
+
// TODO: This is a temporary, intermediate step. Once the feature
|
2458
|
+
// flag is removed, we should get the ref off the props object right
|
2459
|
+
// before using it.
|
2460
|
+
var refProp = props.ref;
|
2461
|
+
ref = refProp !== undefined ? refProp : null;
|
2462
|
+
} // Attempt to render the Server Component.
|
2463
|
+
|
2464
|
+
|
2465
|
+
return renderElement(request, task, element.type, // $FlowFixMe[incompatible-call] the key of an element is null | string
|
2466
|
+
element.key, ref, props, element._owner );
|
2467
|
+
}
|
2468
|
+
|
2469
|
+
case REACT_LAZY_TYPE:
|
2470
|
+
{
|
2471
|
+
// Reset the task's thenable state before continuing. If there was one, it was
|
2472
|
+
// from suspending the lazy before.
|
2473
|
+
task.thenableState = null;
|
2474
|
+
var lazy = value;
|
2475
|
+
var payload = lazy._payload;
|
2476
|
+
var init = lazy._init;
|
2477
|
+
var resolvedModel = init(payload);
|
2478
|
+
|
2479
|
+
{
|
2480
|
+
var _debugInfo = lazy._debugInfo;
|
2481
|
+
|
2482
|
+
if (_debugInfo) {
|
2483
|
+
// If this came from Flight, forward any debug info into this new row.
|
2484
|
+
if (debugID === null) {
|
2485
|
+
// We don't have a chunk to assign debug info. We need to outline this
|
2486
|
+
// component to assign it an ID.
|
2487
|
+
return outlineTask(request, task);
|
2488
|
+
} else {
|
2489
|
+
// Forward any debug info we have the first time we see it.
|
2490
|
+
// We do this after init so that we have received all the debug info
|
2491
|
+
// from the server by the time we emit it.
|
2492
|
+
forwardDebugInfo(request, debugID, _debugInfo);
|
2493
|
+
}
|
2494
|
+
}
|
2495
|
+
}
|
2496
|
+
|
2497
|
+
return renderModelDestructive(request, task, emptyRoot, '', resolvedModel);
|
1801
2498
|
}
|
2499
|
+
}
|
2500
|
+
|
2501
|
+
if (isClientReference(value)) {
|
2502
|
+
return serializeClientReference(request, parent, parentPropertyName, value);
|
2503
|
+
}
|
2504
|
+
|
2505
|
+
var writtenObjects = request.writtenObjects;
|
2506
|
+
var existingId = writtenObjects.get(value); // $FlowFixMe[method-unbinding]
|
2507
|
+
|
2508
|
+
if (typeof value.then === 'function') {
|
2509
|
+
if (existingId !== undefined) {
|
2510
|
+
if ((task.keyPath !== null || task.implicitSlot)) {
|
2511
|
+
// If we're in some kind of context we can't reuse the result of this render or
|
2512
|
+
// previous renders of this element. We only reuse Promises if they're not wrapped
|
2513
|
+
// by another Server Component.
|
2514
|
+
var _promiseId = serializeThenable(request, task, value);
|
2515
|
+
|
2516
|
+
return serializePromiseID(_promiseId);
|
2517
|
+
} else if (modelRoot === value) {
|
2518
|
+
// This is the ID we're currently emitting so we need to write it
|
2519
|
+
// once but if we discover it again, we refer to it by id.
|
2520
|
+
modelRoot = null;
|
2521
|
+
} else {
|
2522
|
+
// We've seen this promise before, so we can just refer to the same result.
|
2523
|
+
return serializePromiseID(existingId);
|
2524
|
+
}
|
2525
|
+
} // We assume that any object with a .then property is a "Thenable" type,
|
2526
|
+
// or a Promise type. Either of which can be represented by a Promise.
|
2527
|
+
|
2528
|
+
|
2529
|
+
var promiseId = serializeThenable(request, task, value);
|
2530
|
+
writtenObjects.set(value, promiseId);
|
2531
|
+
return serializePromiseID(promiseId);
|
2532
|
+
}
|
2533
|
+
|
2534
|
+
if (existingId !== undefined) {
|
2535
|
+
if (modelRoot === value) {
|
2536
|
+
// This is the ID we're currently emitting so we need to write it
|
2537
|
+
// once but if we discover it again, we refer to it by id.
|
2538
|
+
modelRoot = null;
|
2539
|
+
} else if (existingId === SEEN_BUT_NOT_YET_OUTLINED) {
|
2540
|
+
var _newId = outlineModel(request, value);
|
2541
|
+
|
2542
|
+
return serializeByValueID(_newId);
|
2543
|
+
} else if (existingId !== NEVER_OUTLINED) {
|
2544
|
+
// We've already emitted this as an outlined object, so we can
|
2545
|
+
// just refer to that by its existing ID.
|
2546
|
+
return serializeByValueID(existingId);
|
2547
|
+
}
|
2548
|
+
} else {
|
2549
|
+
// This is the first time we've seen this object. We may never see it again
|
2550
|
+
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
|
2551
|
+
writtenObjects.set(value, SEEN_BUT_NOT_YET_OUTLINED);
|
2552
|
+
}
|
2553
|
+
|
2554
|
+
if (isArray(value)) {
|
2555
|
+
return renderFragment(request, task, value);
|
2556
|
+
}
|
2557
|
+
|
2558
|
+
if (value instanceof Map) {
|
2559
|
+
return serializeMap(request, value);
|
2560
|
+
}
|
2561
|
+
|
2562
|
+
if (value instanceof Set) {
|
2563
|
+
return serializeSet(request, value);
|
2564
|
+
} // TODO: FormData is not available in old Node. Remove the typeof later.
|
2565
|
+
|
2566
|
+
|
2567
|
+
if (typeof FormData === 'function' && value instanceof FormData) {
|
2568
|
+
return serializeFormData(request, value);
|
2569
|
+
}
|
2570
|
+
|
2571
|
+
var iteratorFn = getIteratorFn(value);
|
2572
|
+
|
2573
|
+
if (iteratorFn) {
|
2574
|
+
// TODO: Should we serialize the return value as well like we do for AsyncIterables?
|
2575
|
+
var iterator = iteratorFn.call(value);
|
2576
|
+
|
2577
|
+
if (iterator === value) {
|
2578
|
+
// Iterator, not Iterable
|
2579
|
+
return serializeIterator(request, iterator);
|
2580
|
+
}
|
2581
|
+
|
2582
|
+
return renderFragment(request, task, Array.from(iterator));
|
2583
|
+
}
|
2584
|
+
|
2585
|
+
|
2586
|
+
var proto = getPrototypeOf(value);
|
2587
|
+
|
2588
|
+
if (proto !== ObjectPrototype && (proto === null || getPrototypeOf(proto) !== null)) {
|
2589
|
+
throw new Error('Only plain objects, and a few built-ins, can be passed to Client Components ' + 'from Server Components. Classes or null prototypes are not supported.');
|
2590
|
+
}
|
2591
|
+
|
2592
|
+
{
|
2593
|
+
if (objectName(value) !== 'Object') {
|
2594
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent, parentPropertyName));
|
2595
|
+
} else if (!isSimpleObject(value)) {
|
2596
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + 'Classes or other objects with methods are not supported.%s', describeObjectForErrorMessage(parent, parentPropertyName));
|
2597
|
+
} else if (Object.getOwnPropertySymbols) {
|
2598
|
+
var symbols = Object.getOwnPropertySymbols(value);
|
2599
|
+
|
2600
|
+
if (symbols.length > 0) {
|
2601
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + 'Objects with symbol properties like %s are not supported.%s', symbols[0].description, describeObjectForErrorMessage(parent, parentPropertyName));
|
2602
|
+
}
|
2603
|
+
}
|
2604
|
+
} // $FlowFixMe[incompatible-return]
|
2605
|
+
|
2606
|
+
|
2607
|
+
return value;
|
2608
|
+
}
|
2609
|
+
|
2610
|
+
if (typeof value === 'string') {
|
2611
|
+
|
2612
|
+
|
2613
|
+
if (value[value.length - 1] === 'Z') {
|
2614
|
+
// Possibly a Date, whose toJSON automatically calls toISOString
|
2615
|
+
// $FlowFixMe[incompatible-use]
|
2616
|
+
var originalValue = parent[parentPropertyName];
|
2617
|
+
|
2618
|
+
if (originalValue instanceof Date) {
|
2619
|
+
return serializeDateFromDateJSON(value);
|
2620
|
+
}
|
2621
|
+
}
|
2622
|
+
|
2623
|
+
if (value.length >= 1024) {
|
2624
|
+
// For large strings, we encode them outside the JSON payload so that we
|
2625
|
+
// don't have to double encode and double parse the strings. This can also
|
2626
|
+
// be more compact in case the string has a lot of escaped characters.
|
2627
|
+
return serializeLargeTextString(request, value);
|
2628
|
+
}
|
2629
|
+
|
2630
|
+
return escapeStringValue(value);
|
2631
|
+
}
|
2632
|
+
|
2633
|
+
if (typeof value === 'boolean') {
|
2634
|
+
return value;
|
2635
|
+
}
|
2636
|
+
|
2637
|
+
if (typeof value === 'number') {
|
2638
|
+
return serializeNumber(value);
|
2639
|
+
}
|
2640
|
+
|
2641
|
+
if (typeof value === 'undefined') {
|
2642
|
+
return serializeUndefined();
|
2643
|
+
}
|
2644
|
+
|
2645
|
+
if (typeof value === 'function') {
|
2646
|
+
if (isClientReference(value)) {
|
2647
|
+
return serializeClientReference(request, parent, parentPropertyName, value);
|
2648
|
+
}
|
2649
|
+
|
2650
|
+
if (isServerReference(value)) {
|
2651
|
+
return serializeServerReference(request, value);
|
2652
|
+
}
|
2653
|
+
|
2654
|
+
if (isTemporaryReference(value)) {
|
2655
|
+
return serializeTemporaryReference(request, value);
|
2656
|
+
}
|
2657
|
+
|
2658
|
+
if (/^on[A-Z]/.test(parentPropertyName)) {
|
2659
|
+
throw new Error('Event handlers cannot be passed to Client Component props.' + describeObjectForErrorMessage(parent, parentPropertyName) + '\nIf you need interactivity, consider converting part of this to a Client Component.');
|
2660
|
+
} else if ((jsxChildrenParents.has(parent) || jsxPropsParents.has(parent) && parentPropertyName === 'children')) {
|
2661
|
+
var componentName = value.displayName || value.name || 'Component';
|
2662
|
+
throw new Error('Functions are not valid as a child of Client Components. This may happen if ' + 'you return ' + componentName + ' instead of <' + componentName + ' /> from render. ' + 'Or maybe you meant to call this function rather than return it.' + describeObjectForErrorMessage(parent, parentPropertyName));
|
2663
|
+
} else {
|
2664
|
+
throw new Error('Functions cannot be passed directly to Client Components ' + 'unless you explicitly expose it by marking it with "use server". ' + 'Or maybe you meant to call this function rather than return it.' + describeObjectForErrorMessage(parent, parentPropertyName));
|
2665
|
+
}
|
2666
|
+
}
|
2667
|
+
|
2668
|
+
if (typeof value === 'symbol') {
|
2669
|
+
var writtenSymbols = request.writtenSymbols;
|
2670
|
+
|
2671
|
+
var _existingId2 = writtenSymbols.get(value);
|
2672
|
+
|
2673
|
+
if (_existingId2 !== undefined) {
|
2674
|
+
return serializeByValueID(_existingId2);
|
2675
|
+
} // $FlowFixMe[incompatible-type] `description` might be undefined
|
2676
|
+
|
2677
|
+
|
2678
|
+
var name = value.description;
|
2679
|
+
|
2680
|
+
if (Symbol.for(name) !== value) {
|
2681
|
+
throw new Error('Only global symbols received from Symbol.for(...) can be passed to Client Components. ' + ("The symbol Symbol.for(" + // $FlowFixMe[incompatible-type] `description` might be undefined
|
2682
|
+
value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent, parentPropertyName));
|
2683
|
+
}
|
2684
|
+
|
2685
|
+
request.pendingChunks++;
|
2686
|
+
var symbolId = request.nextChunkId++;
|
2687
|
+
emitSymbolChunk(request, symbolId, name);
|
2688
|
+
writtenSymbols.set(value, symbolId);
|
2689
|
+
return serializeByValueID(symbolId);
|
2690
|
+
}
|
2691
|
+
|
2692
|
+
if (typeof value === 'bigint') {
|
2693
|
+
|
2694
|
+
return serializeBigInt(value);
|
2695
|
+
}
|
2696
|
+
|
2697
|
+
throw new Error("Type " + typeof value + " is not supported in Client Component props." + describeObjectForErrorMessage(parent, parentPropertyName));
|
2698
|
+
}
|
2699
|
+
|
2700
|
+
function logPostpone(request, reason) {
|
2701
|
+
var prevRequest = currentRequest;
|
2702
|
+
currentRequest = null;
|
2703
|
+
|
2704
|
+
try {
|
2705
|
+
var onPostpone = request.onPostpone;
|
2706
|
+
|
2707
|
+
if (supportsRequestStorage) {
|
2708
|
+
// Exit the request context while running callbacks.
|
2709
|
+
requestStorage.run(undefined, onPostpone, reason);
|
2710
|
+
} else {
|
2711
|
+
onPostpone(reason);
|
2712
|
+
}
|
2713
|
+
} finally {
|
2714
|
+
currentRequest = prevRequest;
|
2715
|
+
}
|
2716
|
+
}
|
2717
|
+
|
2718
|
+
function logRecoverableError(request, error) {
|
2719
|
+
var prevRequest = currentRequest;
|
2720
|
+
currentRequest = null;
|
2721
|
+
var errorDigest;
|
1802
2722
|
|
1803
|
-
|
2723
|
+
try {
|
2724
|
+
var onError = request.onError;
|
2725
|
+
|
2726
|
+
if (supportsRequestStorage) {
|
2727
|
+
// Exit the request context while running callbacks.
|
2728
|
+
errorDigest = requestStorage.run(undefined, onError, error);
|
2729
|
+
} else {
|
2730
|
+
errorDigest = onError(error);
|
2731
|
+
}
|
2732
|
+
} finally {
|
2733
|
+
currentRequest = prevRequest;
|
2734
|
+
}
|
2735
|
+
|
2736
|
+
if (errorDigest != null && typeof errorDigest !== 'string') {
|
2737
|
+
// eslint-disable-next-line react-internal/prod-error-codes
|
2738
|
+
throw new Error("onError returned something with a type other than \"string\". onError should return a string and may return null or undefined but must not return anything else. It received something of type \"" + typeof errorDigest + "\" instead");
|
2739
|
+
}
|
2740
|
+
|
2741
|
+
return errorDigest || '';
|
2742
|
+
}
|
2743
|
+
|
2744
|
+
function fatalError(request, error) {
|
2745
|
+
|
2746
|
+
|
2747
|
+
if (request.destination !== null) {
|
2748
|
+
request.status = CLOSED;
|
2749
|
+
closeWithError(request.destination, error);
|
2750
|
+
} else {
|
2751
|
+
request.status = CLOSING;
|
2752
|
+
request.fatalError = error;
|
2753
|
+
}
|
2754
|
+
}
|
2755
|
+
|
2756
|
+
function emitPostponeChunk(request, id, postponeInstance) {
|
2757
|
+
var row;
|
2758
|
+
|
2759
|
+
{
|
2760
|
+
var reason = '';
|
2761
|
+
var stack = '';
|
2762
|
+
|
2763
|
+
try {
|
2764
|
+
// eslint-disable-next-line react-internal/safe-string-coercion
|
2765
|
+
reason = String(postponeInstance.message); // eslint-disable-next-line react-internal/safe-string-coercion
|
2766
|
+
|
2767
|
+
stack = String(postponeInstance.stack);
|
2768
|
+
} catch (x) {}
|
2769
|
+
|
2770
|
+
row = serializeRowHeader('P', id) + stringify({
|
2771
|
+
reason: reason,
|
2772
|
+
stack: stack
|
2773
|
+
}) + '\n';
|
2774
|
+
}
|
2775
|
+
|
2776
|
+
var processedChunk = stringToChunk(row);
|
2777
|
+
request.completedErrorChunks.push(processedChunk);
|
2778
|
+
}
|
2779
|
+
|
2780
|
+
function emitErrorChunk(request, id, digest, error) {
|
2781
|
+
var errorInfo;
|
2782
|
+
|
2783
|
+
{
|
2784
|
+
var message;
|
2785
|
+
var stack = '';
|
2786
|
+
|
2787
|
+
try {
|
2788
|
+
if (error instanceof Error) {
|
2789
|
+
// eslint-disable-next-line react-internal/safe-string-coercion
|
2790
|
+
message = String(error.message); // eslint-disable-next-line react-internal/safe-string-coercion
|
2791
|
+
|
2792
|
+
stack = String(error.stack);
|
2793
|
+
} else if (typeof error === 'object' && error !== null) {
|
2794
|
+
message = describeObjectForErrorMessage(error);
|
2795
|
+
} else {
|
2796
|
+
// eslint-disable-next-line react-internal/safe-string-coercion
|
2797
|
+
message = String(error);
|
1804
2798
|
}
|
2799
|
+
} catch (x) {
|
2800
|
+
message = 'An error occurred but serializing the error message failed.';
|
1805
2801
|
}
|
2802
|
+
|
2803
|
+
errorInfo = {
|
2804
|
+
digest: digest,
|
2805
|
+
message: message,
|
2806
|
+
stack: stack
|
2807
|
+
};
|
2808
|
+
}
|
2809
|
+
|
2810
|
+
var row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n';
|
2811
|
+
var processedChunk = stringToChunk(row);
|
2812
|
+
request.completedErrorChunks.push(processedChunk);
|
2813
|
+
}
|
2814
|
+
|
2815
|
+
function emitImportChunk(request, id, clientReferenceMetadata) {
|
2816
|
+
// $FlowFixMe[incompatible-type] stringify can return null
|
2817
|
+
var json = stringify(clientReferenceMetadata);
|
2818
|
+
var row = serializeRowHeader('I', id) + json + '\n';
|
2819
|
+
var processedChunk = stringToChunk(row);
|
2820
|
+
request.completedImportChunks.push(processedChunk);
|
2821
|
+
}
|
2822
|
+
|
2823
|
+
function emitHintChunk(request, code, model) {
|
2824
|
+
var json = stringify(model);
|
2825
|
+
var id = request.nextChunkId++;
|
2826
|
+
var row = serializeRowHeader('H' + code, id) + json + '\n';
|
2827
|
+
var processedChunk = stringToChunk(row);
|
2828
|
+
request.completedHintChunks.push(processedChunk);
|
2829
|
+
}
|
2830
|
+
|
2831
|
+
function emitSymbolChunk(request, id, name) {
|
2832
|
+
var symbolReference = serializeSymbolReference(name);
|
2833
|
+
var processedChunk = encodeReferenceChunk(request, id, symbolReference);
|
2834
|
+
request.completedImportChunks.push(processedChunk);
|
2835
|
+
}
|
2836
|
+
|
2837
|
+
function emitModelChunk(request, id, json) {
|
2838
|
+
var row = id.toString(16) + ':' + json + '\n';
|
2839
|
+
var processedChunk = stringToChunk(row);
|
2840
|
+
request.completedRegularChunks.push(processedChunk);
|
2841
|
+
}
|
2842
|
+
|
2843
|
+
function emitDebugChunk(request, id, debugInfo) {
|
2844
|
+
// use the full serialization that requires a task.
|
2845
|
+
|
2846
|
+
|
2847
|
+
var counter = {
|
2848
|
+
objectCount: 0
|
2849
|
+
};
|
2850
|
+
|
2851
|
+
function replacer(parentPropertyName, value) {
|
2852
|
+
return renderConsoleValue(request, counter, this, parentPropertyName, value);
|
2853
|
+
} // $FlowFixMe[incompatible-type] stringify can return null
|
2854
|
+
|
2855
|
+
|
2856
|
+
var json = stringify(debugInfo, replacer);
|
2857
|
+
var row = serializeRowHeader('D', id) + json + '\n';
|
2858
|
+
var processedChunk = stringToChunk(row);
|
2859
|
+
request.completedRegularChunks.push(processedChunk);
|
2860
|
+
}
|
2861
|
+
|
2862
|
+
function emitTextChunk(request, id, text) {
|
2863
|
+
request.pendingChunks++; // Extra chunk for the header.
|
2864
|
+
|
2865
|
+
var textChunk = stringToChunk(text);
|
2866
|
+
var binaryLength = byteLengthOfChunk(textChunk);
|
2867
|
+
var row = id.toString(16) + ':T' + binaryLength.toString(16) + ',';
|
2868
|
+
var headerChunk = stringToChunk(row);
|
2869
|
+
request.completedRegularChunks.push(headerChunk, textChunk);
|
2870
|
+
}
|
2871
|
+
|
2872
|
+
function serializeEval(source) {
|
2873
|
+
|
2874
|
+
return '$E' + source;
|
2875
|
+
} // This is a forked version of renderModel which should never error, never suspend and is limited
|
2876
|
+
// in the depth it can encode.
|
2877
|
+
|
2878
|
+
|
2879
|
+
function renderConsoleValue(request, counter, parent, parentPropertyName, value) {
|
2880
|
+
// Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us
|
2881
|
+
// $FlowFixMe[incompatible-use]
|
2882
|
+
var originalValue = parent[parentPropertyName];
|
2883
|
+
|
2884
|
+
if (value === null) {
|
2885
|
+
return null;
|
1806
2886
|
}
|
1807
2887
|
|
1808
|
-
if (value ===
|
1809
|
-
|
1810
|
-
|
2888
|
+
if (typeof value === 'object') {
|
2889
|
+
if (isClientReference(value)) {
|
2890
|
+
// We actually have this value on the client so we could import it.
|
2891
|
+
// This might be confusing though because on the Server it won't actually
|
2892
|
+
// be this value, so if you're debugging client references maybe you'd be
|
2893
|
+
// better with a place holder.
|
2894
|
+
return serializeClientReference(request, parent, parentPropertyName, value);
|
2895
|
+
}
|
2896
|
+
|
2897
|
+
if (counter.objectCount > 20) {
|
2898
|
+
// We've reached our max number of objects to serialize across the wire so we serialize this
|
2899
|
+
// object but no properties inside of it, as a place holder.
|
2900
|
+
return Array.isArray(value) ? [] : {};
|
2901
|
+
}
|
2902
|
+
|
2903
|
+
counter.objectCount++;
|
2904
|
+
var writtenObjects = request.writtenObjects;
|
2905
|
+
var existingId = writtenObjects.get(value); // $FlowFixMe[method-unbinding]
|
2906
|
+
|
2907
|
+
if (typeof value.then === 'function') {
|
2908
|
+
if (existingId !== undefined) {
|
2909
|
+
// We've seen this promise before, so we can just refer to the same result.
|
2910
|
+
return serializePromiseID(existingId);
|
2911
|
+
}
|
2912
|
+
|
2913
|
+
var thenable = value;
|
2914
|
+
|
2915
|
+
switch (thenable.status) {
|
2916
|
+
case 'fulfilled':
|
2917
|
+
{
|
2918
|
+
return serializePromiseID(outlineConsoleValue(request, counter, thenable.value));
|
2919
|
+
}
|
2920
|
+
|
2921
|
+
case 'rejected':
|
2922
|
+
{
|
2923
|
+
var x = thenable.reason;
|
2924
|
+
request.pendingChunks++;
|
2925
|
+
var errorId = request.nextChunkId++;
|
2926
|
+
|
2927
|
+
{
|
2928
|
+
// We don't log these errors since they didn't actually throw into Flight.
|
2929
|
+
var digest = '';
|
2930
|
+
emitErrorChunk(request, errorId, digest, x);
|
2931
|
+
}
|
2932
|
+
|
2933
|
+
return serializePromiseID(errorId);
|
2934
|
+
}
|
2935
|
+
} // If it hasn't already resolved (and been instrumented) we just encode an infinite
|
2936
|
+
// promise that will never resolve.
|
2937
|
+
|
1811
2938
|
|
1812
|
-
|
1813
|
-
|
1814
|
-
return serializeClientReference(request, parent, key, value); // $FlowFixMe[method-unbinding]
|
1815
|
-
} else if (typeof value.then === 'function') {
|
1816
|
-
// We assume that any object with a .then property is a "Thenable" type,
|
1817
|
-
// or a Promise type. Either of which can be represented by a Promise.
|
1818
|
-
var promiseId = serializeThenable(request, value);
|
1819
|
-
return serializePromiseID(promiseId);
|
1820
|
-
} else if (value.$$typeof === REACT_PROVIDER_TYPE) {
|
1821
|
-
var providerKey = value._context._globalName;
|
1822
|
-
var writtenProviders = request.writtenProviders;
|
1823
|
-
var providerId = writtenProviders.get(key);
|
1824
|
-
|
1825
|
-
if (providerId === undefined) {
|
1826
|
-
request.pendingChunks++;
|
1827
|
-
providerId = request.nextChunkId++;
|
1828
|
-
writtenProviders.set(providerKey, providerId);
|
1829
|
-
emitProviderChunk(request, providerId, providerKey);
|
1830
|
-
}
|
2939
|
+
return serializeInfinitePromise();
|
2940
|
+
}
|
1831
2941
|
|
1832
|
-
|
1833
|
-
|
1834
|
-
|
2942
|
+
if (existingId !== undefined && existingId >= 0) {
|
2943
|
+
// We've already emitted this as a real object, so we can
|
2944
|
+
// just refer to that by its existing ID.
|
2945
|
+
return serializeByValueID(existingId);
|
2946
|
+
}
|
1835
2947
|
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
}
|
2948
|
+
if (isArray(value)) {
|
2949
|
+
return value;
|
2950
|
+
}
|
1840
2951
|
|
1841
|
-
|
2952
|
+
if (value instanceof Map) {
|
2953
|
+
return serializeMap(request, value);
|
1842
2954
|
}
|
1843
2955
|
|
1844
|
-
if (
|
1845
|
-
|
2956
|
+
if (value instanceof Set) {
|
2957
|
+
return serializeSet(request, value);
|
2958
|
+
} // TODO: FormData is not available in old Node. Remove the typeof later.
|
1846
2959
|
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
2960
|
+
|
2961
|
+
if (typeof FormData === 'function' && value instanceof FormData) {
|
2962
|
+
return serializeFormData(request, value);
|
1850
2963
|
}
|
1851
2964
|
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent, key));
|
1857
|
-
} else if (!isSimpleObject(value)) {
|
1858
|
-
error('Only plain objects can be passed to Client Components from Server Components. ' + 'Classes or other objects with methods are not supported.%s', describeObjectForErrorMessage(parent, key));
|
1859
|
-
} else if (Object.getOwnPropertySymbols) {
|
1860
|
-
var symbols = Object.getOwnPropertySymbols(value);
|
1861
|
-
|
1862
|
-
if (symbols.length > 0) {
|
1863
|
-
error('Only plain objects can be passed to Client Components from Server Components. ' + 'Objects with symbol properties like %s are not supported.%s', symbols[0].description, describeObjectForErrorMessage(parent, key));
|
1864
|
-
}
|
1865
|
-
}
|
1866
|
-
}
|
2965
|
+
var iteratorFn = getIteratorFn(value);
|
2966
|
+
|
2967
|
+
if (iteratorFn) {
|
2968
|
+
return Array.from(value);
|
1867
2969
|
} // $FlowFixMe[incompatible-return]
|
1868
2970
|
|
1869
2971
|
|
@@ -1871,17 +2973,20 @@ function resolveModelToJSON(request, parent, key, value) {
|
|
1871
2973
|
}
|
1872
2974
|
|
1873
2975
|
if (typeof value === 'string') {
|
1874
|
-
// TODO: Maybe too clever. If we support URL there's no similar trick.
|
1875
2976
|
if (value[value.length - 1] === 'Z') {
|
1876
2977
|
// Possibly a Date, whose toJSON automatically calls toISOString
|
1877
|
-
|
1878
|
-
var _originalValue = parent[key]; // $FlowFixMe[method-unbinding]
|
1879
|
-
|
1880
|
-
if (_originalValue instanceof Date) {
|
2978
|
+
if (originalValue instanceof Date) {
|
1881
2979
|
return serializeDateFromDateJSON(value);
|
1882
2980
|
}
|
1883
2981
|
}
|
1884
2982
|
|
2983
|
+
if (value.length >= 1024) {
|
2984
|
+
// For large strings, we encode them outside the JSON payload so that we
|
2985
|
+
// don't have to double encode and double parse the strings. This can also
|
2986
|
+
// be more compact in case the string has a lot of escaped characters.
|
2987
|
+
return serializeLargeTextString(request, value);
|
2988
|
+
}
|
2989
|
+
|
1885
2990
|
return escapeStringValue(value);
|
1886
2991
|
}
|
1887
2992
|
|
@@ -1899,40 +3004,33 @@ function resolveModelToJSON(request, parent, key, value) {
|
|
1899
3004
|
|
1900
3005
|
if (typeof value === 'function') {
|
1901
3006
|
if (isClientReference(value)) {
|
1902
|
-
return serializeClientReference(request, parent,
|
3007
|
+
return serializeClientReference(request, parent, parentPropertyName, value);
|
1903
3008
|
}
|
1904
3009
|
|
1905
|
-
if (
|
1906
|
-
return
|
1907
|
-
}
|
3010
|
+
if (isTemporaryReference(value)) {
|
3011
|
+
return serializeTemporaryReference(request, value);
|
3012
|
+
} // Serialize the body of the function as an eval so it can be printed.
|
3013
|
+
// $FlowFixMe[method-unbinding]
|
1908
3014
|
|
1909
|
-
|
1910
|
-
|
1911
|
-
} else {
|
1912
|
-
throw new Error('Functions cannot be passed directly to Client Components ' + 'unless you explicitly expose it by marking it with "use server".' + describeObjectForErrorMessage(parent, key));
|
1913
|
-
}
|
3015
|
+
|
3016
|
+
return serializeEval('(' + Function.prototype.toString.call(value) + ')');
|
1914
3017
|
}
|
1915
3018
|
|
1916
3019
|
if (typeof value === 'symbol') {
|
1917
3020
|
var writtenSymbols = request.writtenSymbols;
|
1918
|
-
var existingId = writtenSymbols.get(value);
|
1919
3021
|
|
1920
|
-
|
1921
|
-
return serializeByValueID(existingId);
|
1922
|
-
} // $FlowFixMe[incompatible-type] `description` might be undefined
|
3022
|
+
var _existingId3 = writtenSymbols.get(value);
|
1923
3023
|
|
3024
|
+
if (_existingId3 !== undefined) {
|
3025
|
+
return serializeByValueID(_existingId3);
|
3026
|
+
} // $FlowFixMe[incompatible-type] `description` might be undefined
|
1924
3027
|
|
1925
|
-
var name = value.description;
|
1926
3028
|
|
1927
|
-
|
1928
|
-
throw new Error('Only global symbols received from Symbol.for(...) can be passed to Client Components. ' + ("The symbol Symbol.for(" + // $FlowFixMe[incompatible-type] `description` might be undefined
|
1929
|
-
value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent, key));
|
1930
|
-
}
|
3029
|
+
var name = value.description; // We use the Symbol.for version if it's not a global symbol. Close enough.
|
1931
3030
|
|
1932
3031
|
request.pendingChunks++;
|
1933
3032
|
var symbolId = request.nextChunkId++;
|
1934
3033
|
emitSymbolChunk(request, symbolId, name);
|
1935
|
-
writtenSymbols.set(value, symbolId);
|
1936
3034
|
return serializeByValueID(symbolId);
|
1937
3035
|
}
|
1938
3036
|
|
@@ -1940,88 +3038,53 @@ function resolveModelToJSON(request, parent, key, value) {
|
|
1940
3038
|
return serializeBigInt(value);
|
1941
3039
|
}
|
1942
3040
|
|
1943
|
-
|
1944
|
-
}
|
1945
|
-
|
1946
|
-
function logRecoverableError(request, error) {
|
1947
|
-
var onError = request.onError;
|
1948
|
-
var errorDigest = onError(error);
|
1949
|
-
|
1950
|
-
if (errorDigest != null && typeof errorDigest !== 'string') {
|
1951
|
-
// eslint-disable-next-line react-internal/prod-error-codes
|
1952
|
-
throw new Error("onError returned something with a type other than \"string\". onError should return a string and may return null or undefined but must not return anything else. It received something of type \"" + typeof errorDigest + "\" instead");
|
1953
|
-
}
|
1954
|
-
|
1955
|
-
return errorDigest || '';
|
3041
|
+
return 'unknown type ' + typeof value;
|
1956
3042
|
}
|
1957
3043
|
|
1958
|
-
function
|
1959
|
-
{
|
1960
|
-
var message;
|
1961
|
-
var stack = '';
|
3044
|
+
function outlineConsoleValue(request, counter, model) {
|
1962
3045
|
|
3046
|
+
function replacer(parentPropertyName, value) {
|
1963
3047
|
try {
|
1964
|
-
|
1965
|
-
// eslint-disable-next-line react-internal/safe-string-coercion
|
1966
|
-
message = String(error.message); // eslint-disable-next-line react-internal/safe-string-coercion
|
1967
|
-
|
1968
|
-
stack = String(error.stack);
|
1969
|
-
} else {
|
1970
|
-
message = 'Error: ' + error;
|
1971
|
-
}
|
3048
|
+
return renderConsoleValue(request, counter, this, parentPropertyName, value);
|
1972
3049
|
} catch (x) {
|
1973
|
-
|
3050
|
+
return 'unknown value';
|
1974
3051
|
}
|
3052
|
+
} // $FlowFixMe[incompatible-type] stringify can return null
|
1975
3053
|
|
1976
|
-
|
1977
|
-
|
1978
|
-
|
1979
|
-
|
1980
|
-
|
3054
|
+
|
3055
|
+
var json = stringify(model, replacer);
|
3056
|
+
request.pendingChunks++;
|
3057
|
+
var id = request.nextChunkId++;
|
3058
|
+
var row = id.toString(16) + ':' + json + '\n';
|
3059
|
+
var processedChunk = stringToChunk(row);
|
3060
|
+
request.completedRegularChunks.push(processedChunk);
|
3061
|
+
return id;
|
1981
3062
|
}
|
1982
3063
|
|
1983
|
-
function
|
1984
|
-
|
1985
|
-
|
1986
|
-
request
|
1987
|
-
closeWithError(request.destination, error);
|
1988
|
-
} else {
|
1989
|
-
request.status = CLOSING;
|
1990
|
-
request.fatalError = error;
|
3064
|
+
function forwardDebugInfo(request, id, debugInfo) {
|
3065
|
+
for (var i = 0; i < debugInfo.length; i++) {
|
3066
|
+
request.pendingChunks++;
|
3067
|
+
emitDebugChunk(request, id, debugInfo[i]);
|
1991
3068
|
}
|
1992
3069
|
}
|
1993
3070
|
|
1994
|
-
function
|
1995
|
-
var
|
1996
|
-
|
1997
|
-
}
|
3071
|
+
function emitChunk(request, task, value) {
|
3072
|
+
var id = task.id; // For certain types we have special types, we typically outlined them but
|
3073
|
+
// we can emit them directly for this row instead of through an indirection.
|
1998
3074
|
|
1999
|
-
|
2000
|
-
var processedChunk = processErrorChunkDev(request, id, digest, message, stack);
|
2001
|
-
request.completedErrorChunks.push(processedChunk);
|
2002
|
-
}
|
3075
|
+
if (typeof value === 'string') {
|
2003
3076
|
|
2004
|
-
|
2005
|
-
|
2006
|
-
|
2007
|
-
|
3077
|
+
emitTextChunk(request, id, value);
|
3078
|
+
return;
|
3079
|
+
}
|
3080
|
+
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
2008
3081
|
|
2009
|
-
function emitHintChunk(request, code, model) {
|
2010
|
-
var processedChunk = processHintChunk(request, request.nextChunkId++, code, model);
|
2011
|
-
request.completedHintChunks.push(processedChunk);
|
2012
|
-
}
|
2013
3082
|
|
2014
|
-
|
2015
|
-
|
2016
|
-
var processedChunk = processReferenceChunk(request, id, symbolReference);
|
2017
|
-
request.completedImportChunks.push(processedChunk);
|
3083
|
+
var json = stringify(value, task.toJSON);
|
3084
|
+
emitModelChunk(request, task.id, json);
|
2018
3085
|
}
|
2019
3086
|
|
2020
|
-
|
2021
|
-
var contextReference = serializeProviderReference(contextName);
|
2022
|
-
var processedChunk = processReferenceChunk(request, id, contextReference);
|
2023
|
-
request.completedJSONChunks.push(processedChunk);
|
2024
|
-
}
|
3087
|
+
var emptyRoot = {};
|
2025
3088
|
|
2026
3089
|
function retryTask(request, task) {
|
2027
3090
|
if (task.status !== PENDING$1) {
|
@@ -2029,38 +3092,47 @@ function retryTask(request, task) {
|
|
2029
3092
|
return;
|
2030
3093
|
}
|
2031
3094
|
|
2032
|
-
|
3095
|
+
var prevDebugID = debugID;
|
2033
3096
|
|
2034
3097
|
try {
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2051
|
-
//
|
2052
|
-
|
2053
|
-
|
2054
|
-
|
2055
|
-
|
2056
|
-
|
2057
|
-
|
2058
|
-
|
2059
|
-
|
3098
|
+
// Track the root so we know that we have to emit this object even though it
|
3099
|
+
// already has an ID. This is needed because we might see this object twice
|
3100
|
+
// in the same toJSON if it is cyclic.
|
3101
|
+
modelRoot = task.model;
|
3102
|
+
|
3103
|
+
if (true) {
|
3104
|
+
// Track the ID of the current task so we can assign debug info to this id.
|
3105
|
+
debugID = task.id;
|
3106
|
+
} // We call the destructive form that mutates this task. That way if something
|
3107
|
+
// suspends again, we can reuse the same task instead of spawning a new one.
|
3108
|
+
|
3109
|
+
|
3110
|
+
var resolvedModel = renderModelDestructive(request, task, emptyRoot, '', task.model);
|
3111
|
+
|
3112
|
+
if (true) {
|
3113
|
+
// We're now past rendering this task and future renders will spawn new tasks for their
|
3114
|
+
// debug info.
|
3115
|
+
debugID = null;
|
3116
|
+
} // Track the root again for the resolved object.
|
3117
|
+
|
3118
|
+
|
3119
|
+
modelRoot = resolvedModel; // The keyPath resets at any terminal child node.
|
3120
|
+
|
3121
|
+
task.keyPath = null;
|
3122
|
+
task.implicitSlot = false;
|
3123
|
+
|
3124
|
+
if (typeof resolvedModel === 'object' && resolvedModel !== null) {
|
3125
|
+
// Object might contain unresolved values like additional elements.
|
3126
|
+
// This is simulating what the JSON loop would do if this was part of it.
|
3127
|
+
emitChunk(request, task, resolvedModel);
|
3128
|
+
} else {
|
3129
|
+
// If the value is a string, it means it's a terminal value and we already escaped it
|
3130
|
+
// We don't need to escape it again so it's not passed the toJSON replacer.
|
3131
|
+
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
3132
|
+
var json = stringify(resolvedModel);
|
3133
|
+
emitModelChunk(request, task.id, json);
|
2060
3134
|
}
|
2061
3135
|
|
2062
|
-
var processedChunk = processModelChunk(request, task.id, value);
|
2063
|
-
request.completedJSONChunks.push(processedChunk);
|
2064
3136
|
request.abortableTasks.delete(task);
|
2065
3137
|
task.status = COMPLETED;
|
2066
3138
|
} catch (thrownValue) {
|
@@ -2069,33 +3141,33 @@ function retryTask(request, task) {
|
|
2069
3141
|
// value to be a thenable, because before `use` existed that was the
|
2070
3142
|
// (unstable) API for suspending. This implementation detail can change
|
2071
3143
|
// later, once we deprecate the old API in favor of `use`.
|
2072
|
-
getSuspendedThenable() : thrownValue;
|
2073
|
-
|
2074
|
-
if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
|
2075
|
-
// Something suspended again, let's pick it back up later.
|
2076
|
-
var ping = task.ping;
|
2077
|
-
x.then(ping, ping);
|
2078
|
-
task.thenableState = getThenableStateAfterSuspending();
|
2079
|
-
return;
|
2080
|
-
} else {
|
2081
|
-
request.abortableTasks.delete(task);
|
2082
|
-
task.status = ERRORED$1;
|
2083
|
-
var digest = logRecoverableError(request, x);
|
2084
|
-
|
2085
|
-
{
|
2086
|
-
var _getErrorMessageAndSt5 = getErrorMessageAndStackDev(x),
|
2087
|
-
message = _getErrorMessageAndSt5.message,
|
2088
|
-
stack = _getErrorMessageAndSt5.stack;
|
3144
|
+
getSuspendedThenable() : thrownValue;
|
2089
3145
|
|
2090
|
-
|
3146
|
+
if (typeof x === 'object' && x !== null) {
|
3147
|
+
// $FlowFixMe[method-unbinding]
|
3148
|
+
if (typeof x.then === 'function') {
|
3149
|
+
// Something suspended again, let's pick it back up later.
|
3150
|
+
var ping = task.ping;
|
3151
|
+
x.then(ping, ping);
|
3152
|
+
task.thenableState = getThenableStateAfterSuspending();
|
3153
|
+
return;
|
2091
3154
|
}
|
2092
3155
|
}
|
3156
|
+
|
3157
|
+
request.abortableTasks.delete(task);
|
3158
|
+
task.status = ERRORED$1;
|
3159
|
+
var digest = logRecoverableError(request, x);
|
3160
|
+
emitErrorChunk(request, task.id, digest, x);
|
3161
|
+
} finally {
|
3162
|
+
{
|
3163
|
+
debugID = prevDebugID;
|
3164
|
+
}
|
2093
3165
|
}
|
2094
3166
|
}
|
2095
3167
|
|
2096
3168
|
function performWork(request) {
|
2097
|
-
var prevDispatcher =
|
2098
|
-
|
3169
|
+
var prevDispatcher = ReactSharedInternals.H;
|
3170
|
+
ReactSharedInternals.H = HooksDispatcher;
|
2099
3171
|
var prevRequest = currentRequest;
|
2100
3172
|
currentRequest = request;
|
2101
3173
|
prepareToUseHooksForRequest(request);
|
@@ -2116,7 +3188,7 @@ function performWork(request) {
|
|
2116
3188
|
logRecoverableError(request, error);
|
2117
3189
|
fatalError(request, error);
|
2118
3190
|
} finally {
|
2119
|
-
|
3191
|
+
ReactSharedInternals.H = prevDispatcher;
|
2120
3192
|
resetHooksForRequest();
|
2121
3193
|
currentRequest = prevRequest;
|
2122
3194
|
}
|
@@ -2127,7 +3199,7 @@ function abortTask(task, request, errorId) {
|
|
2127
3199
|
// has a single value referencing the error.
|
2128
3200
|
|
2129
3201
|
var ref = serializeByValueID(errorId);
|
2130
|
-
var processedChunk =
|
3202
|
+
var processedChunk = encodeReferenceChunk(request, task.id, ref);
|
2131
3203
|
request.completedErrorChunks.push(processedChunk);
|
2132
3204
|
}
|
2133
3205
|
|
@@ -2171,12 +3243,12 @@ function flushCompletedChunks(request, destination) {
|
|
2171
3243
|
|
2172
3244
|
hintChunks.splice(0, i); // Next comes model data.
|
2173
3245
|
|
2174
|
-
var
|
3246
|
+
var regularChunks = request.completedRegularChunks;
|
2175
3247
|
i = 0;
|
2176
3248
|
|
2177
|
-
for (; i <
|
3249
|
+
for (; i < regularChunks.length; i++) {
|
2178
3250
|
request.pendingChunks--;
|
2179
|
-
var _chunk2 =
|
3251
|
+
var _chunk2 = regularChunks[i];
|
2180
3252
|
|
2181
3253
|
var _keepWriting2 = writeChunkAndReturn(destination, _chunk2);
|
2182
3254
|
|
@@ -2187,7 +3259,7 @@ function flushCompletedChunks(request, destination) {
|
|
2187
3259
|
}
|
2188
3260
|
}
|
2189
3261
|
|
2190
|
-
|
3262
|
+
regularChunks.splice(0, i); // Finally, errors are sent. The idea is that it's ok to delay
|
2191
3263
|
// any error messages and prioritize display of other parts of
|
2192
3264
|
// the page.
|
2193
3265
|
|
@@ -2214,8 +3286,9 @@ function flushCompletedChunks(request, destination) {
|
|
2214
3286
|
}
|
2215
3287
|
|
2216
3288
|
if (request.pendingChunks === 0) {
|
2217
|
-
|
3289
|
+
|
2218
3290
|
close$1(destination);
|
3291
|
+
request.destination = null;
|
2219
3292
|
}
|
2220
3293
|
}
|
2221
3294
|
|
@@ -2270,26 +3343,24 @@ function startFlowing(request, destination) {
|
|
2270
3343
|
logRecoverableError(request, error);
|
2271
3344
|
fatalError(request, error);
|
2272
3345
|
}
|
3346
|
+
}
|
3347
|
+
function stopFlowing(request) {
|
3348
|
+
request.destination = null;
|
2273
3349
|
} // This is called to early terminate a request. It creates an error at all pending tasks.
|
2274
3350
|
|
2275
3351
|
function abort(request, reason) {
|
2276
3352
|
try {
|
2277
|
-
var abortableTasks = request.abortableTasks;
|
3353
|
+
var abortableTasks = request.abortableTasks; // We have tasks to abort. We'll emit one error row and then emit a reference
|
3354
|
+
// to that row from every row that's still remaining.
|
2278
3355
|
|
2279
3356
|
if (abortableTasks.size > 0) {
|
2280
|
-
// We have tasks to abort. We'll emit one error row and then emit a reference
|
2281
|
-
// to that row from every row that's still remaining.
|
2282
|
-
var error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : reason;
|
2283
|
-
var digest = logRecoverableError(request, error);
|
2284
3357
|
request.pendingChunks++;
|
2285
3358
|
var errorId = request.nextChunkId++;
|
2286
3359
|
|
2287
|
-
if (
|
2288
|
-
var
|
2289
|
-
|
2290
|
-
|
2291
|
-
|
2292
|
-
emitErrorChunkDev(request, errorId, digest, message, stack);
|
3360
|
+
var postponeInstance; if (enablePostpone && typeof reason === 'object' && reason !== null && reason.$$typeof === REACT_POSTPONE_TYPE) ; else {
|
3361
|
+
var error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : reason;
|
3362
|
+
var digest = logRecoverableError(request, error);
|
3363
|
+
emitErrorChunk(request, errorId, digest, error);
|
2293
3364
|
}
|
2294
3365
|
|
2295
3366
|
abortableTasks.forEach(function (task) {
|
@@ -2298,6 +3369,21 @@ function abort(request, reason) {
|
|
2298
3369
|
abortableTasks.clear();
|
2299
3370
|
}
|
2300
3371
|
|
3372
|
+
var abortListeners = request.abortListeners;
|
3373
|
+
|
3374
|
+
if (abortListeners.size > 0) {
|
3375
|
+
var _error;
|
3376
|
+
|
3377
|
+
if (enablePostpone && typeof reason === 'object' && reason !== null && reason.$$typeof === REACT_POSTPONE_TYPE) ; else {
|
3378
|
+
_error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : reason;
|
3379
|
+
}
|
3380
|
+
|
3381
|
+
abortListeners.forEach(function (callback) {
|
3382
|
+
return callback(_error);
|
3383
|
+
});
|
3384
|
+
abortListeners.clear();
|
3385
|
+
}
|
3386
|
+
|
2301
3387
|
if (request.destination !== null) {
|
2302
3388
|
flushCompletedChunks(request, request.destination);
|
2303
3389
|
}
|
@@ -2307,28 +3393,20 @@ function abort(request, reason) {
|
|
2307
3393
|
}
|
2308
3394
|
}
|
2309
3395
|
|
2310
|
-
|
2311
|
-
|
2312
|
-
|
2313
|
-
|
2314
|
-
|
2315
|
-
|
2316
|
-
|
2317
|
-
|
2318
|
-
|
2319
|
-
|
2320
|
-
|
2321
|
-
|
2322
|
-
|
2323
|
-
var importedContext = getActiveContext();
|
2324
|
-
switchContext(prevContext);
|
2325
|
-
return importedContext;
|
2326
|
-
}
|
2327
|
-
|
2328
|
-
return rootContextSnapshot;
|
3396
|
+
// This is the parsed shape of the wire format which is why it is
|
3397
|
+
// condensed to only the essentialy information
|
3398
|
+
var ID = 0;
|
3399
|
+
var CHUNKS = 1;
|
3400
|
+
var NAME = 2; // export const ASYNC = 3;
|
3401
|
+
// This logic is correct because currently only include the 4th tuple member
|
3402
|
+
// when the module is async. If that changes we will need to actually assert
|
3403
|
+
// the value is true. We don't index into the 4th slot because flow does not
|
3404
|
+
// like the potential out of bounds access
|
3405
|
+
|
3406
|
+
function isAsyncImport(metadata) {
|
3407
|
+
return metadata.length === 4;
|
2329
3408
|
}
|
2330
3409
|
|
2331
|
-
// eslint-disable-next-line no-unused-vars
|
2332
3410
|
function resolveServerReference(bundlerConfig, id) {
|
2333
3411
|
var name = '';
|
2334
3412
|
var resolvedModuleData = bundlerConfig[id];
|
@@ -2354,19 +3432,38 @@ function resolveServerReference(bundlerConfig, id) {
|
|
2354
3432
|
} // TODO: This needs to return async: true if it's an async module.
|
2355
3433
|
|
2356
3434
|
|
2357
|
-
return
|
2358
|
-
id: resolvedModuleData.id,
|
2359
|
-
chunks: resolvedModuleData.chunks,
|
2360
|
-
name: name,
|
2361
|
-
async: false
|
2362
|
-
};
|
3435
|
+
return [resolvedModuleData.id, resolvedModuleData.chunks, name];
|
2363
3436
|
} // The chunk cache contains all the chunks we've preloaded so far.
|
2364
3437
|
// If they're still pending they're a thenable. This map also exists
|
2365
3438
|
// in Webpack but unfortunately it's not exposed so we have to
|
2366
3439
|
// replicate it in user space. null means that it has already loaded.
|
2367
3440
|
|
2368
3441
|
var chunkCache = new Map();
|
2369
|
-
|
3442
|
+
|
3443
|
+
function requireAsyncModule(id) {
|
3444
|
+
// We've already loaded all the chunks. We can require the module.
|
3445
|
+
var promise = __webpack_require__(id);
|
3446
|
+
|
3447
|
+
if (typeof promise.then !== 'function') {
|
3448
|
+
// This wasn't a promise after all.
|
3449
|
+
return null;
|
3450
|
+
} else if (promise.status === 'fulfilled') {
|
3451
|
+
// This module was already resolved earlier.
|
3452
|
+
return null;
|
3453
|
+
} else {
|
3454
|
+
// Instrument the Promise to stash the result.
|
3455
|
+
promise.then(function (value) {
|
3456
|
+
var fulfilledThenable = promise;
|
3457
|
+
fulfilledThenable.status = 'fulfilled';
|
3458
|
+
fulfilledThenable.value = value;
|
3459
|
+
}, function (reason) {
|
3460
|
+
var rejectedThenable = promise;
|
3461
|
+
rejectedThenable.status = 'rejected';
|
3462
|
+
rejectedThenable.reason = reason;
|
3463
|
+
});
|
3464
|
+
return promise;
|
3465
|
+
}
|
3466
|
+
}
|
2370
3467
|
|
2371
3468
|
function ignoreReject() {// We rely on rejected promises to be handled by another listener.
|
2372
3469
|
} // Start preloading the modules since we might need them soon.
|
@@ -2374,16 +3471,17 @@ function ignoreReject() {// We rely on rejected promises to be handled by anothe
|
|
2374
3471
|
|
2375
3472
|
|
2376
3473
|
function preloadModule(metadata) {
|
2377
|
-
var chunks = metadata
|
3474
|
+
var chunks = metadata[CHUNKS];
|
2378
3475
|
var promises = [];
|
3476
|
+
var i = 0;
|
2379
3477
|
|
2380
|
-
|
2381
|
-
var chunkId = chunks[i];
|
3478
|
+
while (i < chunks.length) {
|
3479
|
+
var chunkId = chunks[i++];
|
3480
|
+
chunks[i++];
|
2382
3481
|
var entry = chunkCache.get(chunkId);
|
2383
3482
|
|
2384
3483
|
if (entry === undefined) {
|
2385
|
-
var thenable =
|
2386
|
-
|
3484
|
+
var thenable = loadChunk(chunkId);
|
2387
3485
|
promises.push(thenable); // $FlowFixMe[method-unbinding]
|
2388
3486
|
|
2389
3487
|
var resolve = chunkCache.set.bind(chunkCache, chunkId, null);
|
@@ -2394,30 +3492,13 @@ function preloadModule(metadata) {
|
|
2394
3492
|
}
|
2395
3493
|
}
|
2396
3494
|
|
2397
|
-
if (metadata
|
2398
|
-
|
2399
|
-
|
2400
|
-
if (existingPromise) {
|
2401
|
-
if (existingPromise.status === 'fulfilled') {
|
2402
|
-
return null;
|
2403
|
-
}
|
2404
|
-
|
2405
|
-
return existingPromise;
|
3495
|
+
if (isAsyncImport(metadata)) {
|
3496
|
+
if (promises.length === 0) {
|
3497
|
+
return requireAsyncModule(metadata[ID]);
|
2406
3498
|
} else {
|
2407
|
-
|
2408
|
-
return
|
3499
|
+
return Promise.all(promises).then(function () {
|
3500
|
+
return requireAsyncModule(metadata[ID]);
|
2409
3501
|
});
|
2410
|
-
modulePromise.then(function (value) {
|
2411
|
-
var fulfilledThenable = modulePromise;
|
2412
|
-
fulfilledThenable.status = 'fulfilled';
|
2413
|
-
fulfilledThenable.value = value;
|
2414
|
-
}, function (reason) {
|
2415
|
-
var rejectedThenable = modulePromise;
|
2416
|
-
rejectedThenable.status = 'rejected';
|
2417
|
-
rejectedThenable.reason = reason;
|
2418
|
-
});
|
2419
|
-
asyncModuleCache.set(metadata.id, modulePromise);
|
2420
|
-
return modulePromise;
|
2421
3502
|
}
|
2422
3503
|
} else if (promises.length > 0) {
|
2423
3504
|
return Promise.all(promises);
|
@@ -2428,35 +3509,34 @@ function preloadModule(metadata) {
|
|
2428
3509
|
// Increase priority if necessary.
|
2429
3510
|
|
2430
3511
|
function requireModule(metadata) {
|
2431
|
-
var moduleExports;
|
2432
|
-
|
2433
|
-
if (metadata.async) {
|
2434
|
-
// We assume that preloadModule has been called before, which
|
2435
|
-
// should have added something to the module cache.
|
2436
|
-
var promise = asyncModuleCache.get(metadata.id);
|
3512
|
+
var moduleExports = __webpack_require__(metadata[ID]);
|
2437
3513
|
|
2438
|
-
|
2439
|
-
|
3514
|
+
if (isAsyncImport(metadata)) {
|
3515
|
+
if (typeof moduleExports.then !== 'function') ; else if (moduleExports.status === 'fulfilled') {
|
3516
|
+
// This Promise should've been instrumented by preloadModule.
|
3517
|
+
moduleExports = moduleExports.value;
|
2440
3518
|
} else {
|
2441
|
-
throw
|
3519
|
+
throw moduleExports.reason;
|
2442
3520
|
}
|
2443
|
-
} else {
|
2444
|
-
moduleExports = __webpack_require__(metadata.id);
|
2445
3521
|
}
|
2446
3522
|
|
2447
|
-
if (metadata
|
3523
|
+
if (metadata[NAME] === '*') {
|
2448
3524
|
// This is a placeholder value that represents that the caller imported this
|
2449
3525
|
// as a CommonJS module as is.
|
2450
3526
|
return moduleExports;
|
2451
3527
|
}
|
2452
3528
|
|
2453
|
-
if (metadata
|
3529
|
+
if (metadata[NAME] === '') {
|
2454
3530
|
// This is a placeholder value that represents that the caller accessed the
|
2455
3531
|
// default property of this if it was an ESM interop module.
|
2456
3532
|
return moduleExports.__esModule ? moduleExports.default : moduleExports;
|
2457
3533
|
}
|
2458
3534
|
|
2459
|
-
return moduleExports[metadata
|
3535
|
+
return moduleExports[metadata[NAME]];
|
3536
|
+
}
|
3537
|
+
|
3538
|
+
function loadChunk(chunkId, filename) {
|
3539
|
+
return __webpack_chunk_load__(chunkId);
|
2460
3540
|
}
|
2461
3541
|
|
2462
3542
|
// The server acts as a Client of itself when resolving Server References.
|
@@ -2556,11 +3636,11 @@ function createResolvedModelChunk(response, value) {
|
|
2556
3636
|
return new Chunk(RESOLVED_MODEL, value, null, response);
|
2557
3637
|
}
|
2558
3638
|
|
2559
|
-
function bindArgs(fn, args) {
|
3639
|
+
function bindArgs$1(fn, args) {
|
2560
3640
|
return fn.bind.apply(fn, [null].concat(args));
|
2561
3641
|
}
|
2562
3642
|
|
2563
|
-
function loadServerReference(response, id, bound, parentChunk, parentObject, key) {
|
3643
|
+
function loadServerReference$1(response, id, bound, parentChunk, parentObject, key) {
|
2564
3644
|
var serverReference = resolveServerReference(response._bundlerConfig, id); // We expect most servers to not really need this because you'd just have all
|
2565
3645
|
// the relevant modules already loaded but it allows for lazy loading of code
|
2566
3646
|
// if needed.
|
@@ -2571,7 +3651,7 @@ function loadServerReference(response, id, bound, parentChunk, parentObject, key
|
|
2571
3651
|
if (bound) {
|
2572
3652
|
promise = Promise.all([bound, preloadPromise]).then(function (_ref) {
|
2573
3653
|
var args = _ref[0];
|
2574
|
-
return bindArgs(requireModule(serverReference), args);
|
3654
|
+
return bindArgs$1(requireModule(serverReference), args);
|
2575
3655
|
});
|
2576
3656
|
} else {
|
2577
3657
|
if (preloadPromise) {
|
@@ -2701,7 +3781,22 @@ function createModelReject(chunk) {
|
|
2701
3781
|
};
|
2702
3782
|
}
|
2703
3783
|
|
2704
|
-
function
|
3784
|
+
function getOutlinedModel(response, id) {
|
3785
|
+
var chunk = getChunk(response, id);
|
3786
|
+
|
3787
|
+
if (chunk.status === RESOLVED_MODEL) {
|
3788
|
+
initializeModelChunk(chunk);
|
3789
|
+
}
|
3790
|
+
|
3791
|
+
if (chunk.status !== INITIALIZED) {
|
3792
|
+
// We know that this is emitted earlier so otherwise it's an error.
|
3793
|
+
throw chunk.reason;
|
3794
|
+
}
|
3795
|
+
|
3796
|
+
return chunk.value;
|
3797
|
+
}
|
3798
|
+
|
3799
|
+
function parseModelString(response, obj, key, value) {
|
2705
3800
|
if (value[0] === '$') {
|
2706
3801
|
switch (value[1]) {
|
2707
3802
|
case '$':
|
@@ -2713,36 +3808,46 @@ function parseModelString(response, parentObject, key, value) {
|
|
2713
3808
|
case '@':
|
2714
3809
|
{
|
2715
3810
|
// Promise
|
2716
|
-
var
|
2717
|
-
var chunk = getChunk(response, id);
|
2718
|
-
return chunk;
|
2719
|
-
}
|
3811
|
+
var _id = parseInt(value.slice(2), 16);
|
2720
3812
|
|
2721
|
-
|
2722
|
-
|
2723
|
-
|
2724
|
-
return Symbol.for(value.slice(2));
|
3813
|
+
var _chunk = getChunk(response, _id);
|
3814
|
+
|
3815
|
+
return _chunk;
|
2725
3816
|
}
|
2726
3817
|
|
2727
3818
|
case 'F':
|
2728
3819
|
{
|
2729
3820
|
// Server Reference
|
2730
|
-
var
|
3821
|
+
var _id2 = parseInt(value.slice(2), 16); // TODO: Just encode this in the reference inline instead of as a model.
|
2731
3822
|
|
2732
|
-
var _chunk = getChunk(response, _id);
|
2733
3823
|
|
2734
|
-
|
2735
|
-
|
2736
|
-
|
3824
|
+
var metaData = getOutlinedModel(response, _id2);
|
3825
|
+
return loadServerReference$1(response, metaData.id, metaData.bound, initializingChunk, obj, key);
|
3826
|
+
}
|
3827
|
+
|
3828
|
+
case 'T':
|
3829
|
+
{
|
3830
|
+
// Temporary Reference
|
3831
|
+
return createTemporaryReference(value.slice(2));
|
3832
|
+
}
|
3833
|
+
|
3834
|
+
case 'Q':
|
3835
|
+
{
|
3836
|
+
// Map
|
3837
|
+
var _id3 = parseInt(value.slice(2), 16);
|
2737
3838
|
|
2738
|
-
|
2739
|
-
|
2740
|
-
|
2741
|
-
|
3839
|
+
var data = getOutlinedModel(response, _id3);
|
3840
|
+
return new Map(data);
|
3841
|
+
}
|
3842
|
+
|
3843
|
+
case 'W':
|
3844
|
+
{
|
3845
|
+
// Set
|
3846
|
+
var _id4 = parseInt(value.slice(2), 16);
|
2742
3847
|
|
3848
|
+
var _data = getOutlinedModel(response, _id4);
|
2743
3849
|
|
2744
|
-
|
2745
|
-
return loadServerReference(response, metaData.id, metaData.bound, initializingChunk, parentObject, key);
|
3850
|
+
return new Set(_data);
|
2746
3851
|
}
|
2747
3852
|
|
2748
3853
|
case 'K':
|
@@ -2750,7 +3855,9 @@ function parseModelString(response, parentObject, key, value) {
|
|
2750
3855
|
// FormData
|
2751
3856
|
var stringId = value.slice(2);
|
2752
3857
|
var formPrefix = response._prefix + stringId + '_';
|
2753
|
-
|
3858
|
+
|
3859
|
+
var _data2 = new FormData();
|
3860
|
+
|
2754
3861
|
var backingFormData = response._formData; // We assume that the reference to FormData always comes after each
|
2755
3862
|
// entry that it references so we can assume they all exist in the
|
2756
3863
|
// backing store already.
|
@@ -2758,10 +3865,20 @@ function parseModelString(response, parentObject, key, value) {
|
|
2758
3865
|
|
2759
3866
|
backingFormData.forEach(function (entry, entryKey) {
|
2760
3867
|
if (entryKey.startsWith(formPrefix)) {
|
2761
|
-
|
3868
|
+
_data2.append(entryKey.slice(formPrefix.length), entry);
|
2762
3869
|
}
|
2763
3870
|
});
|
2764
|
-
return
|
3871
|
+
return _data2;
|
3872
|
+
}
|
3873
|
+
|
3874
|
+
case 'i':
|
3875
|
+
{
|
3876
|
+
// Iterator
|
3877
|
+
var _id5 = parseInt(value.slice(2), 16);
|
3878
|
+
|
3879
|
+
var _data3 = getOutlinedModel(response, _id5);
|
3880
|
+
|
3881
|
+
return _data3[Symbol.iterator]();
|
2765
3882
|
}
|
2766
3883
|
|
2767
3884
|
case 'I':
|
@@ -2804,37 +3921,31 @@ function parseModelString(response, parentObject, key, value) {
|
|
2804
3921
|
// BigInt
|
2805
3922
|
return BigInt(value.slice(2));
|
2806
3923
|
}
|
3924
|
+
}
|
2807
3925
|
|
2808
|
-
default:
|
2809
|
-
{
|
2810
|
-
// We assume that anything else is a reference ID.
|
2811
|
-
var _id2 = parseInt(value.slice(1), 16);
|
2812
|
-
|
2813
|
-
var _chunk2 = getChunk(response, _id2);
|
2814
|
-
|
2815
|
-
switch (_chunk2.status) {
|
2816
|
-
case RESOLVED_MODEL:
|
2817
|
-
initializeModelChunk(_chunk2);
|
2818
|
-
break;
|
2819
|
-
} // The status might have changed after initialization.
|
2820
3926
|
|
3927
|
+
var id = parseInt(value.slice(1), 16);
|
3928
|
+
var chunk = getChunk(response, id);
|
2821
3929
|
|
2822
|
-
|
2823
|
-
|
2824
|
-
|
3930
|
+
switch (chunk.status) {
|
3931
|
+
case RESOLVED_MODEL:
|
3932
|
+
initializeModelChunk(chunk);
|
3933
|
+
break;
|
3934
|
+
} // The status might have changed after initialization.
|
2825
3935
|
|
2826
|
-
case PENDING:
|
2827
|
-
case BLOCKED:
|
2828
|
-
var parentChunk = initializingChunk;
|
2829
3936
|
|
2830
|
-
|
3937
|
+
switch (chunk.status) {
|
3938
|
+
case INITIALIZED:
|
3939
|
+
return chunk.value;
|
2831
3940
|
|
2832
|
-
|
3941
|
+
case PENDING:
|
3942
|
+
case BLOCKED:
|
3943
|
+
var parentChunk = initializingChunk;
|
3944
|
+
chunk.then(createModelResolver(parentChunk, obj, key), createModelReject(parentChunk));
|
3945
|
+
return null;
|
2833
3946
|
|
2834
|
-
|
2835
|
-
|
2836
|
-
}
|
2837
|
-
}
|
3947
|
+
default:
|
3948
|
+
throw chunk.reason;
|
2838
3949
|
}
|
2839
3950
|
}
|
2840
3951
|
|
@@ -2868,8 +3979,130 @@ function close(response) {
|
|
2868
3979
|
reportGlobalError(response, new Error('Connection closed.'));
|
2869
3980
|
}
|
2870
3981
|
|
3982
|
+
function bindArgs(fn, args) {
|
3983
|
+
return fn.bind.apply(fn, [null].concat(args));
|
3984
|
+
}
|
3985
|
+
|
3986
|
+
function loadServerReference(bundlerConfig, id, bound) {
|
3987
|
+
var serverReference = resolveServerReference(bundlerConfig, id); // We expect most servers to not really need this because you'd just have all
|
3988
|
+
// the relevant modules already loaded but it allows for lazy loading of code
|
3989
|
+
// if needed.
|
3990
|
+
|
3991
|
+
var preloadPromise = preloadModule(serverReference);
|
3992
|
+
|
3993
|
+
if (bound) {
|
3994
|
+
return Promise.all([bound, preloadPromise]).then(function (_ref) {
|
3995
|
+
var args = _ref[0];
|
3996
|
+
return bindArgs(requireModule(serverReference), args);
|
3997
|
+
});
|
3998
|
+
} else if (preloadPromise) {
|
3999
|
+
return Promise.resolve(preloadPromise).then(function () {
|
4000
|
+
return requireModule(serverReference);
|
4001
|
+
});
|
4002
|
+
} else {
|
4003
|
+
// Synchronously available
|
4004
|
+
return Promise.resolve(requireModule(serverReference));
|
4005
|
+
}
|
4006
|
+
}
|
4007
|
+
|
4008
|
+
function decodeBoundActionMetaData(body, serverManifest, formFieldPrefix) {
|
4009
|
+
// The data for this reference is encoded in multiple fields under this prefix.
|
4010
|
+
var actionResponse = createResponse(serverManifest, formFieldPrefix, body);
|
4011
|
+
close(actionResponse);
|
4012
|
+
var refPromise = getRoot(actionResponse); // Force it to initialize
|
4013
|
+
// $FlowFixMe
|
4014
|
+
|
4015
|
+
refPromise.then(function () {});
|
4016
|
+
|
4017
|
+
if (refPromise.status !== 'fulfilled') {
|
4018
|
+
// $FlowFixMe
|
4019
|
+
throw refPromise.reason;
|
4020
|
+
}
|
4021
|
+
|
4022
|
+
return refPromise.value;
|
4023
|
+
}
|
4024
|
+
|
4025
|
+
function decodeAction(body, serverManifest) {
|
4026
|
+
// We're going to create a new formData object that holds all the fields except
|
4027
|
+
// the implementation details of the action data.
|
4028
|
+
var formData = new FormData();
|
4029
|
+
var action = null; // $FlowFixMe[prop-missing]
|
4030
|
+
|
4031
|
+
body.forEach(function (value, key) {
|
4032
|
+
if (!key.startsWith('$ACTION_')) {
|
4033
|
+
formData.append(key, value);
|
4034
|
+
return;
|
4035
|
+
} // Later actions may override earlier actions if a button is used to override the default
|
4036
|
+
// form action.
|
4037
|
+
|
4038
|
+
|
4039
|
+
if (key.startsWith('$ACTION_REF_')) {
|
4040
|
+
var formFieldPrefix = '$ACTION_' + key.slice(12) + ':';
|
4041
|
+
var metaData = decodeBoundActionMetaData(body, serverManifest, formFieldPrefix);
|
4042
|
+
action = loadServerReference(serverManifest, metaData.id, metaData.bound);
|
4043
|
+
return;
|
4044
|
+
}
|
4045
|
+
|
4046
|
+
if (key.startsWith('$ACTION_ID_')) {
|
4047
|
+
var id = key.slice(11);
|
4048
|
+
action = loadServerReference(serverManifest, id, null);
|
4049
|
+
return;
|
4050
|
+
}
|
4051
|
+
});
|
4052
|
+
|
4053
|
+
if (action === null) {
|
4054
|
+
return null;
|
4055
|
+
} // Return the action with the remaining FormData bound to the first argument.
|
4056
|
+
|
4057
|
+
|
4058
|
+
return action.then(function (fn) {
|
4059
|
+
return fn.bind(null, formData);
|
4060
|
+
});
|
4061
|
+
}
|
4062
|
+
function decodeFormState(actionResult, body, serverManifest) {
|
4063
|
+
var keyPath = body.get('$ACTION_KEY');
|
4064
|
+
|
4065
|
+
if (typeof keyPath !== 'string') {
|
4066
|
+
// This form submission did not include any form state.
|
4067
|
+
return Promise.resolve(null);
|
4068
|
+
} // Search through the form data object to get the reference id and the number
|
4069
|
+
// of bound arguments. This repeats some of the work done in decodeAction.
|
4070
|
+
|
4071
|
+
|
4072
|
+
var metaData = null; // $FlowFixMe[prop-missing]
|
4073
|
+
|
4074
|
+
body.forEach(function (value, key) {
|
4075
|
+
if (key.startsWith('$ACTION_REF_')) {
|
4076
|
+
var formFieldPrefix = '$ACTION_' + key.slice(12) + ':';
|
4077
|
+
metaData = decodeBoundActionMetaData(body, serverManifest, formFieldPrefix);
|
4078
|
+
} // We don't check for the simple $ACTION_ID_ case because form state actions
|
4079
|
+
// are always bound to the state argument.
|
4080
|
+
|
4081
|
+
});
|
4082
|
+
|
4083
|
+
if (metaData === null) {
|
4084
|
+
// Should be unreachable.
|
4085
|
+
return Promise.resolve(null);
|
4086
|
+
}
|
4087
|
+
|
4088
|
+
var referenceId = metaData.id;
|
4089
|
+
return Promise.resolve(metaData.bound).then(function (bound) {
|
4090
|
+
if (bound === null) {
|
4091
|
+
// Should be unreachable because form state actions are always bound to the
|
4092
|
+
// state argument.
|
4093
|
+
return null;
|
4094
|
+
} // The form action dispatch method is always bound to the initial state.
|
4095
|
+
// But when comparing signatures, we compare to the original unbound action.
|
4096
|
+
// Subtract one from the arity to account for this.
|
4097
|
+
|
4098
|
+
|
4099
|
+
var boundArity = bound.length - 1;
|
4100
|
+
return [actionResult, keyPath, referenceId, boundArity];
|
4101
|
+
});
|
4102
|
+
}
|
4103
|
+
|
2871
4104
|
function renderToReadableStream(model, webpackMap, options) {
|
2872
|
-
var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.
|
4105
|
+
var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.identifierPrefix : undefined, options ? options.onPostpone : undefined, options ? options.environmentName : undefined);
|
2873
4106
|
|
2874
4107
|
if (options && options.signal) {
|
2875
4108
|
var signal = options.signal;
|
@@ -2894,7 +4127,10 @@ function renderToReadableStream(model, webpackMap, options) {
|
|
2894
4127
|
pull: function (controller) {
|
2895
4128
|
startFlowing(request, controller);
|
2896
4129
|
},
|
2897
|
-
cancel: function (reason) {
|
4130
|
+
cancel: function (reason) {
|
4131
|
+
stopFlowing(request);
|
4132
|
+
abort(request, reason);
|
4133
|
+
}
|
2898
4134
|
}, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams.
|
2899
4135
|
{
|
2900
4136
|
highWaterMark: 0
|
@@ -2910,11 +4146,17 @@ function decodeReply(body, webpackMap) {
|
|
2910
4146
|
}
|
2911
4147
|
|
2912
4148
|
var response = createResponse(webpackMap, '', body);
|
4149
|
+
var root = getRoot(response);
|
2913
4150
|
close(response);
|
2914
|
-
return
|
4151
|
+
return root;
|
2915
4152
|
}
|
2916
4153
|
|
4154
|
+
exports.createClientModuleProxy = createClientModuleProxy;
|
4155
|
+
exports.decodeAction = decodeAction;
|
4156
|
+
exports.decodeFormState = decodeFormState;
|
2917
4157
|
exports.decodeReply = decodeReply;
|
4158
|
+
exports.registerClientReference = registerClientReference;
|
4159
|
+
exports.registerServerReference = registerServerReference;
|
2918
4160
|
exports.renderToReadableStream = renderToReadableStream;
|
2919
4161
|
})();
|
2920
4162
|
}
|