react-server-dom-webpack 18.3.0-next-fa4314841-20230502 → 19.0.0-canary-05797cceb-20240328
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/react-server-dom-webpack-client.browser.development.js +1768 -1188
- package/cjs/react-server-dom-webpack-client.browser.production.js +1739 -0
- package/cjs/react-server-dom-webpack-client.browser.production.min.js +40 -34
- package/cjs/react-server-dom-webpack-client.browser.production.min.js.map +1 -0
- package/cjs/react-server-dom-webpack-client.edge.development.js +1755 -221
- package/cjs/react-server-dom-webpack-client.edge.production.js +1986 -0
- package/cjs/react-server-dom-webpack-client.edge.production.min.js +45 -28
- package/cjs/react-server-dom-webpack-client.edge.production.min.js.map +1 -0
- package/cjs/react-server-dom-webpack-client.node.development.js +1743 -239
- package/cjs/react-server-dom-webpack-client.node.production.js +1942 -0
- package/cjs/react-server-dom-webpack-client.node.production.min.js +44 -28
- package/cjs/react-server-dom-webpack-client.node.production.min.js.map +1 -0
- package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +1702 -194
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +1895 -0
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +43 -26
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js.map +1 -0
- package/cjs/react-server-dom-webpack-node-register.js +12 -18
- package/cjs/react-server-dom-webpack-node-register.js.map +1 -0
- package/cjs/react-server-dom-webpack-plugin.js +22 -19
- package/cjs/react-server-dom-webpack-plugin.js.map +1 -0
- package/cjs/react-server-dom-webpack-server.browser.development.js +1588 -808
- package/cjs/react-server-dom-webpack-server.browser.production.js +3257 -0
- package/cjs/react-server-dom-webpack-server.browser.production.min.js +80 -62
- package/cjs/react-server-dom-webpack-server.browser.production.min.js.map +1 -0
- package/cjs/react-server-dom-webpack-server.edge.development.js +1583 -811
- package/cjs/react-server-dom-webpack-server.edge.production.js +3261 -0
- package/cjs/react-server-dom-webpack-server.edge.production.min.js +82 -62
- package/cjs/react-server-dom-webpack-server.edge.production.min.js.map +1 -0
- package/cjs/react-server-dom-webpack-server.node.development.js +1575 -805
- package/cjs/react-server-dom-webpack-server.node.production.js +3464 -0
- package/cjs/react-server-dom-webpack-server.node.production.min.js +85 -67
- package/cjs/react-server-dom-webpack-server.node.production.min.js.map +1 -0
- package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +1526 -761
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +3391 -0
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +82 -65
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js.map +1 -0
- package/esm/react-server-dom-webpack-node-loader.production.min.js +19 -12
- package/package.json +7 -13
- package/umd/react-server-dom-webpack-client.browser.development.js +1770 -1189
- package/umd/react-server-dom-webpack-client.browser.production.min.js +26 -20
- package/umd/react-server-dom-webpack-server.browser.development.js +1589 -808
- package/umd/react-server-dom-webpack-server.browser.production.min.js +55 -42
@@ -7,6 +7,7 @@
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
9
9
|
*/
|
10
|
+
|
10
11
|
(function (global, factory) {
|
11
12
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom')) :
|
12
13
|
typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom'], factory) :
|
@@ -52,10 +53,13 @@
|
|
52
53
|
}
|
53
54
|
}
|
54
55
|
|
56
|
+
// -----------------------------------------------------------------------------
|
57
|
+
var enablePostpone = false;
|
58
|
+
|
55
59
|
function scheduleWork(callback) {
|
56
60
|
callback();
|
57
61
|
}
|
58
|
-
var VIEW_SIZE =
|
62
|
+
var VIEW_SIZE = 2048;
|
59
63
|
var currentView = null;
|
60
64
|
var writtenBytes = 0;
|
61
65
|
function beginWriting(destination) {
|
@@ -63,20 +67,14 @@
|
|
63
67
|
writtenBytes = 0;
|
64
68
|
}
|
65
69
|
function writeChunk(destination, chunk) {
|
66
|
-
if (chunk.
|
70
|
+
if (chunk.byteLength === 0) {
|
67
71
|
return;
|
68
72
|
}
|
69
73
|
|
70
|
-
if (chunk.
|
71
|
-
|
72
|
-
if (precomputedChunkSet.has(chunk)) {
|
73
|
-
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.');
|
74
|
-
}
|
75
|
-
} // this chunk may overflow a single view which implies it was not
|
74
|
+
if (chunk.byteLength > VIEW_SIZE) {
|
75
|
+
// this chunk may overflow a single view which implies it was not
|
76
76
|
// one that is cached by the streaming renderer. We will enqueu
|
77
77
|
// it directly and expect it is not re-used
|
78
|
-
|
79
|
-
|
80
78
|
if (writtenBytes > 0) {
|
81
79
|
destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes));
|
82
80
|
currentView = new Uint8Array(VIEW_SIZE);
|
@@ -90,7 +88,7 @@
|
|
90
88
|
var bytesToWrite = chunk;
|
91
89
|
var allowableBytes = currentView.length - writtenBytes;
|
92
90
|
|
93
|
-
if (allowableBytes < bytesToWrite.
|
91
|
+
if (allowableBytes < bytesToWrite.byteLength) {
|
94
92
|
// this chunk would overflow the current view. We enqueue a full view
|
95
93
|
// and start a new view with the remaining chunk
|
96
94
|
if (allowableBytes === 0) {
|
@@ -110,7 +108,7 @@
|
|
110
108
|
}
|
111
109
|
|
112
110
|
currentView.set(bytesToWrite, writtenBytes);
|
113
|
-
writtenBytes += bytesToWrite.
|
111
|
+
writtenBytes += bytesToWrite.byteLength;
|
114
112
|
}
|
115
113
|
function writeChunkAndReturn(destination, chunk) {
|
116
114
|
writeChunk(destination, chunk); // in web streams there is no backpressure so we can alwas write more
|
@@ -131,7 +129,9 @@
|
|
131
129
|
function stringToChunk(content) {
|
132
130
|
return textEncoder.encode(content);
|
133
131
|
}
|
134
|
-
|
132
|
+
function byteLengthOfChunk(chunk) {
|
133
|
+
return chunk.byteLength;
|
134
|
+
}
|
135
135
|
function closeWithError(destination, error) {
|
136
136
|
// $FlowFixMe[method-unbinding]
|
137
137
|
if (typeof destination.error === 'function') {
|
@@ -148,65 +148,270 @@
|
|
148
148
|
}
|
149
149
|
}
|
150
150
|
|
151
|
-
//
|
152
|
-
var
|
153
|
-
|
154
|
-
function
|
155
|
-
return
|
151
|
+
// eslint-disable-next-line no-unused-vars
|
152
|
+
var CLIENT_REFERENCE_TAG$1 = Symbol.for('react.client.reference');
|
153
|
+
var SERVER_REFERENCE_TAG = Symbol.for('react.server.reference');
|
154
|
+
function isClientReference(reference) {
|
155
|
+
return reference.$$typeof === CLIENT_REFERENCE_TAG$1;
|
156
|
+
}
|
157
|
+
function isServerReference(reference) {
|
158
|
+
return reference.$$typeof === SERVER_REFERENCE_TAG;
|
159
|
+
}
|
160
|
+
function registerClientReference(proxyImplementation, id, exportName) {
|
161
|
+
return registerClientReferenceImpl(proxyImplementation, id + '#' + exportName, false);
|
156
162
|
}
|
157
163
|
|
158
|
-
function
|
159
|
-
{
|
160
|
-
|
161
|
-
|
162
|
-
|
164
|
+
function registerClientReferenceImpl(proxyImplementation, id, async) {
|
165
|
+
return Object.defineProperties(proxyImplementation, {
|
166
|
+
$$typeof: {
|
167
|
+
value: CLIENT_REFERENCE_TAG$1
|
168
|
+
},
|
169
|
+
$$id: {
|
170
|
+
value: id
|
171
|
+
},
|
172
|
+
$$async: {
|
173
|
+
value: async
|
174
|
+
}
|
175
|
+
});
|
176
|
+
} // $FlowFixMe[method-unbinding]
|
177
|
+
|
178
|
+
|
179
|
+
var FunctionBind = Function.prototype.bind; // $FlowFixMe[method-unbinding]
|
180
|
+
|
181
|
+
var ArraySlice = Array.prototype.slice;
|
182
|
+
|
183
|
+
function bind() {
|
184
|
+
// $FlowFixMe[unsupported-syntax]
|
185
|
+
var newFn = FunctionBind.apply(this, arguments);
|
186
|
+
|
187
|
+
if (this.$$typeof === SERVER_REFERENCE_TAG) {
|
188
|
+
{
|
189
|
+
var thisBind = arguments[0];
|
190
|
+
|
191
|
+
if (thisBind != null) {
|
192
|
+
error('Cannot bind "this" of a Server Action. Pass null or undefined as the first argument to .bind().');
|
193
|
+
}
|
194
|
+
}
|
195
|
+
|
196
|
+
var args = ArraySlice.call(arguments, 1);
|
197
|
+
return Object.defineProperties(newFn, {
|
198
|
+
$$typeof: {
|
199
|
+
value: SERVER_REFERENCE_TAG
|
200
|
+
},
|
201
|
+
$$id: {
|
202
|
+
value: this.$$id
|
203
|
+
},
|
204
|
+
$$bound: {
|
205
|
+
value: this.$$bound ? this.$$bound.concat(args) : args
|
206
|
+
},
|
207
|
+
bind: {
|
208
|
+
value: bind
|
209
|
+
}
|
210
|
+
});
|
163
211
|
}
|
164
|
-
}
|
165
|
-
function processErrorChunkDev(request, id, digest, message, stack) {
|
166
212
|
|
167
|
-
|
168
|
-
digest: digest,
|
169
|
-
message: message,
|
170
|
-
stack: stack
|
171
|
-
};
|
172
|
-
var row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n';
|
173
|
-
return stringToChunk(row);
|
174
|
-
}
|
175
|
-
function processModelChunk(request, id, model) {
|
176
|
-
// $FlowFixMe[incompatible-type] stringify can return null
|
177
|
-
var json = stringify(model, request.toJSON);
|
178
|
-
var row = id.toString(16) + ':' + json + '\n';
|
179
|
-
return stringToChunk(row);
|
213
|
+
return newFn;
|
180
214
|
}
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
215
|
+
|
216
|
+
function registerServerReference(reference, id, exportName) {
|
217
|
+
return Object.defineProperties(reference, {
|
218
|
+
$$typeof: {
|
219
|
+
value: SERVER_REFERENCE_TAG
|
220
|
+
},
|
221
|
+
$$id: {
|
222
|
+
value: exportName === null ? id : id + '#' + exportName,
|
223
|
+
configurable: true
|
224
|
+
},
|
225
|
+
$$bound: {
|
226
|
+
value: null,
|
227
|
+
configurable: true
|
228
|
+
},
|
229
|
+
bind: {
|
230
|
+
value: bind,
|
231
|
+
configurable: true
|
232
|
+
}
|
233
|
+
});
|
185
234
|
}
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
235
|
+
var PROMISE_PROTOTYPE = Promise.prototype;
|
236
|
+
var deepProxyHandlers = {
|
237
|
+
get: function (target, name, receiver) {
|
238
|
+
switch (name) {
|
239
|
+
// These names are read by the Flight runtime if you end up using the exports object.
|
240
|
+
case '$$typeof':
|
241
|
+
// These names are a little too common. We should probably have a way to
|
242
|
+
// have the Flight runtime extract the inner target instead.
|
243
|
+
return target.$$typeof;
|
244
|
+
|
245
|
+
case '$$id':
|
246
|
+
return target.$$id;
|
247
|
+
|
248
|
+
case '$$async':
|
249
|
+
return target.$$async;
|
250
|
+
|
251
|
+
case 'name':
|
252
|
+
return target.name;
|
253
|
+
|
254
|
+
case 'displayName':
|
255
|
+
return undefined;
|
256
|
+
// We need to special case this because createElement reads it if we pass this
|
257
|
+
// reference.
|
258
|
+
|
259
|
+
case 'defaultProps':
|
260
|
+
return undefined;
|
261
|
+
// Avoid this attempting to be serialized.
|
262
|
+
|
263
|
+
case 'toJSON':
|
264
|
+
return undefined;
|
265
|
+
|
266
|
+
case Symbol.toPrimitive:
|
267
|
+
// $FlowFixMe[prop-missing]
|
268
|
+
return Object.prototype[Symbol.toPrimitive];
|
269
|
+
|
270
|
+
case Symbol.toStringTag:
|
271
|
+
// $FlowFixMe[prop-missing]
|
272
|
+
return Object.prototype[Symbol.toStringTag];
|
273
|
+
|
274
|
+
case 'Provider':
|
275
|
+
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.");
|
276
|
+
} // eslint-disable-next-line react-internal/safe-string-coercion
|
277
|
+
|
278
|
+
|
279
|
+
var expression = String(target.name) + '.' + String(name);
|
280
|
+
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.');
|
281
|
+
},
|
282
|
+
set: function () {
|
283
|
+
throw new Error('Cannot assign to a client module from a server module.');
|
284
|
+
}
|
285
|
+
};
|
286
|
+
|
287
|
+
function getReference(target, name) {
|
288
|
+
switch (name) {
|
289
|
+
// These names are read by the Flight runtime if you end up using the exports object.
|
290
|
+
case '$$typeof':
|
291
|
+
return target.$$typeof;
|
292
|
+
|
293
|
+
case '$$id':
|
294
|
+
return target.$$id;
|
295
|
+
|
296
|
+
case '$$async':
|
297
|
+
return target.$$async;
|
298
|
+
|
299
|
+
case 'name':
|
300
|
+
return target.name;
|
301
|
+
// We need to special case this because createElement reads it if we pass this
|
302
|
+
// reference.
|
303
|
+
|
304
|
+
case 'defaultProps':
|
305
|
+
return undefined;
|
306
|
+
// Avoid this attempting to be serialized.
|
307
|
+
|
308
|
+
case 'toJSON':
|
309
|
+
return undefined;
|
310
|
+
|
311
|
+
case Symbol.toPrimitive:
|
312
|
+
// $FlowFixMe[prop-missing]
|
313
|
+
return Object.prototype[Symbol.toPrimitive];
|
314
|
+
|
315
|
+
case Symbol.toStringTag:
|
316
|
+
// $FlowFixMe[prop-missing]
|
317
|
+
return Object.prototype[Symbol.toStringTag];
|
318
|
+
|
319
|
+
case '__esModule':
|
320
|
+
// Something is conditionally checking which export to use. We'll pretend to be
|
321
|
+
// an ESM compat module but then we'll check again on the client.
|
322
|
+
var moduleId = target.$$id;
|
323
|
+
target.default = registerClientReferenceImpl(function () {
|
324
|
+
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.");
|
325
|
+
}, target.$$id + '#', target.$$async);
|
326
|
+
return true;
|
327
|
+
|
328
|
+
case 'then':
|
329
|
+
if (target.then) {
|
330
|
+
// Use a cached value
|
331
|
+
return target.then;
|
332
|
+
}
|
333
|
+
|
334
|
+
if (!target.$$async) {
|
335
|
+
// If this module is expected to return a Promise (such as an AsyncModule) then
|
336
|
+
// we should resolve that with a client reference that unwraps the Promise on
|
337
|
+
// the client.
|
338
|
+
var clientReference = registerClientReferenceImpl({}, target.$$id, true);
|
339
|
+
var proxy = new Proxy(clientReference, proxyHandlers$1); // Treat this as a resolved Promise for React's use()
|
340
|
+
|
341
|
+
target.status = 'fulfilled';
|
342
|
+
target.value = proxy;
|
343
|
+
var then = target.then = registerClientReferenceImpl(function then(resolve, reject) {
|
344
|
+
// Expose to React.
|
345
|
+
return Promise.resolve(resolve(proxy));
|
346
|
+
}, // If this is not used as a Promise but is treated as a reference to a `.then`
|
347
|
+
// export then we should treat it as a reference to that name.
|
348
|
+
target.$$id + '#then', false);
|
349
|
+
return then;
|
350
|
+
} else {
|
351
|
+
// Since typeof .then === 'function' is a feature test we'd continue recursing
|
352
|
+
// indefinitely if we return a function. Instead, we return an object reference
|
353
|
+
// if we check further.
|
354
|
+
return undefined;
|
355
|
+
}
|
356
|
+
|
357
|
+
}
|
358
|
+
|
359
|
+
if (typeof name === 'symbol') {
|
360
|
+
throw new Error('Cannot read Symbol exports. Only named exports are supported on a client module ' + 'imported on the server.');
|
361
|
+
}
|
362
|
+
|
363
|
+
var cachedReference = target[name];
|
364
|
+
|
365
|
+
if (!cachedReference) {
|
366
|
+
var reference = registerClientReferenceImpl(function () {
|
367
|
+
throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion
|
368
|
+
"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.");
|
369
|
+
}, target.$$id + '#' + name, target.$$async);
|
370
|
+
Object.defineProperty(reference, 'name', {
|
371
|
+
value: name
|
372
|
+
});
|
373
|
+
cachedReference = target[name] = new Proxy(reference, deepProxyHandlers);
|
374
|
+
}
|
375
|
+
|
376
|
+
return cachedReference;
|
191
377
|
}
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
378
|
+
|
379
|
+
var proxyHandlers$1 = {
|
380
|
+
get: function (target, name, receiver) {
|
381
|
+
return getReference(target, name);
|
382
|
+
},
|
383
|
+
getOwnPropertyDescriptor: function (target, name) {
|
384
|
+
var descriptor = Object.getOwnPropertyDescriptor(target, name);
|
385
|
+
|
386
|
+
if (!descriptor) {
|
387
|
+
descriptor = {
|
388
|
+
value: getReference(target, name),
|
389
|
+
writable: false,
|
390
|
+
configurable: false,
|
391
|
+
enumerable: false
|
392
|
+
};
|
393
|
+
Object.defineProperty(target, name, descriptor);
|
394
|
+
}
|
395
|
+
|
396
|
+
return descriptor;
|
397
|
+
},
|
398
|
+
getPrototypeOf: function (target) {
|
399
|
+
// Pretend to be a Promise in case anyone asks.
|
400
|
+
return PROMISE_PROTOTYPE;
|
401
|
+
},
|
402
|
+
set: function () {
|
403
|
+
throw new Error('Cannot assign to a client module from a server module.');
|
404
|
+
}
|
405
|
+
};
|
406
|
+
function createClientModuleProxy(moduleId) {
|
407
|
+
var clientReference = registerClientReferenceImpl({}, // Represents the whole Module object instead of a particular import.
|
408
|
+
moduleId, false);
|
409
|
+
return new Proxy(clientReference, proxyHandlers$1);
|
196
410
|
}
|
197
411
|
|
198
|
-
// eslint-disable-next-line no-unused-vars
|
199
|
-
var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
|
200
|
-
var SERVER_REFERENCE_TAG = Symbol.for('react.server.reference');
|
201
412
|
function getClientReferenceKey(reference) {
|
202
413
|
return reference.$$async ? reference.$$id + '#async' : reference.$$id;
|
203
414
|
}
|
204
|
-
function isClientReference(reference) {
|
205
|
-
return reference.$$typeof === CLIENT_REFERENCE_TAG;
|
206
|
-
}
|
207
|
-
function isServerReference(reference) {
|
208
|
-
return reference.$$typeof === SERVER_REFERENCE_TAG;
|
209
|
-
}
|
210
415
|
function resolveClientReferenceMetadata(config, clientReference) {
|
211
416
|
var modulePath = clientReference.$$id;
|
212
417
|
var name = '';
|
@@ -232,12 +437,11 @@
|
|
232
437
|
}
|
233
438
|
}
|
234
439
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
};
|
440
|
+
if (clientReference.$$async === true) {
|
441
|
+
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1];
|
442
|
+
} else {
|
443
|
+
return [resolvedModuleData.id, resolvedModuleData.chunks, name];
|
444
|
+
}
|
241
445
|
}
|
242
446
|
function getServerReferenceId(config, serverReference) {
|
243
447
|
return serverReference.$$id;
|
@@ -248,337 +452,357 @@
|
|
248
452
|
|
249
453
|
var ReactDOMSharedInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
250
454
|
|
251
|
-
var
|
455
|
+
var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.ReactDOMCurrentDispatcher;
|
456
|
+
var previousDispatcher = ReactDOMCurrentDispatcher.current;
|
457
|
+
ReactDOMCurrentDispatcher.current = {
|
252
458
|
prefetchDNS: prefetchDNS,
|
253
459
|
preconnect: preconnect,
|
254
460
|
preload: preload,
|
255
|
-
|
461
|
+
preloadModule: preloadModule$1,
|
462
|
+
preinitStyle: preinitStyle,
|
463
|
+
preinitScript: preinitScript,
|
464
|
+
preinitModuleScript: preinitModuleScript
|
256
465
|
};
|
257
466
|
|
258
|
-
function prefetchDNS(href
|
259
|
-
{
|
260
|
-
|
261
|
-
var request = resolveRequest();
|
262
|
-
|
263
|
-
if (request) {
|
264
|
-
var hints = getHints(request);
|
265
|
-
var key = 'D' + href;
|
266
|
-
|
267
|
-
if (hints.has(key)) {
|
268
|
-
// duplicate hint
|
269
|
-
return;
|
270
|
-
}
|
467
|
+
function prefetchDNS(href) {
|
468
|
+
if (typeof href === 'string' && href) {
|
469
|
+
var request = resolveRequest();
|
271
470
|
|
272
|
-
|
471
|
+
if (request) {
|
472
|
+
var hints = getHints(request);
|
473
|
+
var key = 'D|' + href;
|
273
474
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
emitHint(request, 'D', href);
|
278
|
-
}
|
475
|
+
if (hints.has(key)) {
|
476
|
+
// duplicate hint
|
477
|
+
return;
|
279
478
|
}
|
479
|
+
|
480
|
+
hints.add(key);
|
481
|
+
emitHint(request, 'D', href);
|
482
|
+
} else {
|
483
|
+
previousDispatcher.prefetchDNS(href);
|
280
484
|
}
|
281
485
|
}
|
282
486
|
}
|
283
487
|
|
284
|
-
function preconnect(href,
|
285
|
-
{
|
286
|
-
|
287
|
-
var request = resolveRequest();
|
488
|
+
function preconnect(href, crossOrigin) {
|
489
|
+
if (typeof href === 'string') {
|
490
|
+
var request = resolveRequest();
|
288
491
|
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
var key = "C" + (crossOrigin === null ? 'null' : crossOrigin) + "|" + href;
|
492
|
+
if (request) {
|
493
|
+
var hints = getHints(request);
|
494
|
+
var key = "C|" + (crossOrigin == null ? 'null' : crossOrigin) + "|" + href;
|
293
495
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
496
|
+
if (hints.has(key)) {
|
497
|
+
// duplicate hint
|
498
|
+
return;
|
499
|
+
}
|
298
500
|
|
299
|
-
|
501
|
+
hints.add(key);
|
300
502
|
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
}
|
503
|
+
if (typeof crossOrigin === 'string') {
|
504
|
+
emitHint(request, 'C', [href, crossOrigin]);
|
505
|
+
} else {
|
506
|
+
emitHint(request, 'C', href);
|
306
507
|
}
|
508
|
+
} else {
|
509
|
+
previousDispatcher.preconnect(href, crossOrigin);
|
307
510
|
}
|
308
511
|
}
|
309
512
|
}
|
310
513
|
|
311
|
-
function preload(href, options) {
|
312
|
-
{
|
313
|
-
|
314
|
-
var request = resolveRequest();
|
514
|
+
function preload(href, as, options) {
|
515
|
+
if (typeof href === 'string') {
|
516
|
+
var request = resolveRequest();
|
315
517
|
|
316
|
-
|
317
|
-
|
318
|
-
|
518
|
+
if (request) {
|
519
|
+
var hints = getHints(request);
|
520
|
+
var key = 'L';
|
319
521
|
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
522
|
+
if (as === 'image' && options) {
|
523
|
+
key += getImagePreloadKey(href, options.imageSrcSet, options.imageSizes);
|
524
|
+
} else {
|
525
|
+
key += "[" + as + "]" + href;
|
526
|
+
}
|
527
|
+
|
528
|
+
if (hints.has(key)) {
|
529
|
+
// duplicate hint
|
530
|
+
return;
|
531
|
+
}
|
532
|
+
|
533
|
+
hints.add(key);
|
534
|
+
var trimmed = trimOptions(options);
|
324
535
|
|
325
|
-
|
326
|
-
emitHint(request, 'L', [href,
|
536
|
+
if (trimmed) {
|
537
|
+
emitHint(request, 'L', [href, as, trimmed]);
|
538
|
+
} else {
|
539
|
+
emitHint(request, 'L', [href, as]);
|
327
540
|
}
|
541
|
+
} else {
|
542
|
+
previousDispatcher.preload(href, as, options);
|
328
543
|
}
|
329
544
|
}
|
330
545
|
}
|
331
546
|
|
332
|
-
function
|
333
|
-
{
|
334
|
-
|
335
|
-
var request = resolveRequest();
|
547
|
+
function preloadModule$1(href, options) {
|
548
|
+
if (typeof href === 'string') {
|
549
|
+
var request = resolveRequest();
|
336
550
|
|
337
|
-
|
338
|
-
|
339
|
-
|
551
|
+
if (request) {
|
552
|
+
var hints = getHints(request);
|
553
|
+
var key = 'm|' + href;
|
340
554
|
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
555
|
+
if (hints.has(key)) {
|
556
|
+
// duplicate hint
|
557
|
+
return;
|
558
|
+
}
|
345
559
|
|
346
|
-
|
347
|
-
|
560
|
+
hints.add(key);
|
561
|
+
var trimmed = trimOptions(options);
|
562
|
+
|
563
|
+
if (trimmed) {
|
564
|
+
return emitHint(request, 'm', [href, trimmed]);
|
565
|
+
} else {
|
566
|
+
return emitHint(request, 'm', href);
|
348
567
|
}
|
568
|
+
} else {
|
569
|
+
previousDispatcher.preloadModule(href, options);
|
349
570
|
}
|
350
571
|
}
|
351
572
|
}
|
352
573
|
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
} // Used to distinguish these contexts from ones used in other renderers.
|
357
|
-
function createHints() {
|
358
|
-
return new Set();
|
359
|
-
}
|
574
|
+
function preinitStyle(href, precedence, options) {
|
575
|
+
if (typeof href === 'string') {
|
576
|
+
var request = resolveRequest();
|
360
577
|
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
// The Symbol used to tag the ReactElement-like types.
|
365
|
-
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
366
|
-
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
367
|
-
var REACT_PROVIDER_TYPE = Symbol.for('react.provider');
|
368
|
-
var REACT_SERVER_CONTEXT_TYPE = Symbol.for('react.server_context');
|
369
|
-
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
370
|
-
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
371
|
-
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
372
|
-
var REACT_MEMO_TYPE = Symbol.for('react.memo');
|
373
|
-
var REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
374
|
-
var REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED = Symbol.for('react.default_value');
|
375
|
-
var REACT_MEMO_CACHE_SENTINEL = Symbol.for('react.memo_cache_sentinel');
|
376
|
-
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
377
|
-
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
378
|
-
function getIteratorFn(maybeIterable) {
|
379
|
-
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
380
|
-
return null;
|
381
|
-
}
|
578
|
+
if (request) {
|
579
|
+
var hints = getHints(request);
|
580
|
+
var key = 'S|' + href;
|
382
581
|
|
383
|
-
|
582
|
+
if (hints.has(key)) {
|
583
|
+
// duplicate hint
|
584
|
+
return;
|
585
|
+
}
|
384
586
|
|
385
|
-
|
386
|
-
|
387
|
-
}
|
587
|
+
hints.add(key);
|
588
|
+
var trimmed = trimOptions(options);
|
388
589
|
|
389
|
-
|
590
|
+
if (trimmed) {
|
591
|
+
return emitHint(request, 'S', [href, typeof precedence === 'string' ? precedence : 0, trimmed]);
|
592
|
+
} else if (typeof precedence === 'string') {
|
593
|
+
return emitHint(request, 'S', [href, precedence]);
|
594
|
+
} else {
|
595
|
+
return emitHint(request, 'S', href);
|
596
|
+
}
|
597
|
+
} else {
|
598
|
+
previousDispatcher.preinitStyle(href, precedence, options);
|
599
|
+
}
|
600
|
+
}
|
390
601
|
}
|
391
602
|
|
392
|
-
|
603
|
+
function preinitScript(src, options) {
|
604
|
+
if (typeof src === 'string') {
|
605
|
+
var request = resolveRequest();
|
393
606
|
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
} // Used to store the parent path of all context overrides in a shared linked list.
|
398
|
-
// Forming a reverse tree.
|
399
|
-
// The structure of a context snapshot is an implementation of this file.
|
400
|
-
// Currently, it's implemented as tracking the current active node.
|
607
|
+
if (request) {
|
608
|
+
var hints = getHints(request);
|
609
|
+
var key = 'X|' + src;
|
401
610
|
|
611
|
+
if (hints.has(key)) {
|
612
|
+
// duplicate hint
|
613
|
+
return;
|
614
|
+
}
|
402
615
|
|
403
|
-
|
404
|
-
|
405
|
-
// fields are currently in.
|
406
|
-
|
407
|
-
var currentActiveSnapshot = null;
|
616
|
+
hints.add(key);
|
617
|
+
var trimmed = trimOptions(options);
|
408
618
|
|
409
|
-
|
410
|
-
|
411
|
-
|
619
|
+
if (trimmed) {
|
620
|
+
return emitHint(request, 'X', [src, trimmed]);
|
621
|
+
} else {
|
622
|
+
return emitHint(request, 'X', src);
|
623
|
+
}
|
624
|
+
} else {
|
625
|
+
previousDispatcher.preinitScript(src, options);
|
626
|
+
}
|
412
627
|
}
|
413
628
|
}
|
414
629
|
|
415
|
-
function
|
416
|
-
{
|
417
|
-
|
418
|
-
}
|
419
|
-
}
|
630
|
+
function preinitModuleScript(src, options) {
|
631
|
+
if (typeof src === 'string') {
|
632
|
+
var request = resolveRequest();
|
420
633
|
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
var parentPrev = prev.parent;
|
425
|
-
var parentNext = next.parent;
|
634
|
+
if (request) {
|
635
|
+
var hints = getHints(request);
|
636
|
+
var key = 'M|' + src;
|
426
637
|
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
}
|
431
|
-
} else {
|
432
|
-
if (parentNext === null) {
|
433
|
-
throw new Error('The stacks must reach the root at the same time. This is a bug in React.');
|
638
|
+
if (hints.has(key)) {
|
639
|
+
// duplicate hint
|
640
|
+
return;
|
434
641
|
}
|
435
642
|
|
436
|
-
|
643
|
+
hints.add(key);
|
644
|
+
var trimmed = trimOptions(options);
|
437
645
|
|
438
|
-
|
646
|
+
if (trimmed) {
|
647
|
+
return emitHint(request, 'M', [src, trimmed]);
|
648
|
+
} else {
|
649
|
+
return emitHint(request, 'M', src);
|
650
|
+
}
|
651
|
+
} else {
|
652
|
+
previousDispatcher.preinitModuleScript(src, options);
|
439
653
|
}
|
440
654
|
}
|
441
|
-
}
|
655
|
+
} // Flight normally encodes undefined as a special character however for directive option
|
656
|
+
// arguments we don't want to send unnecessary keys and bloat the payload so we create a
|
657
|
+
// trimmed object which omits any keys with null or undefined values.
|
658
|
+
// This is only typesafe because these option objects have entirely optional fields where
|
659
|
+
// null and undefined represent the same thing as no property.
|
442
660
|
|
443
|
-
function popAllPrevious(prev) {
|
444
|
-
popNode(prev);
|
445
|
-
var parentPrev = prev.parent;
|
446
661
|
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
function pushAllNext(next) {
|
453
|
-
var parentNext = next.parent;
|
662
|
+
function trimOptions(options) {
|
663
|
+
if (options == null) return null;
|
664
|
+
var hasProperties = false;
|
665
|
+
var trimmed = {};
|
454
666
|
|
455
|
-
|
456
|
-
|
667
|
+
for (var key in options) {
|
668
|
+
if (options[key] != null) {
|
669
|
+
hasProperties = true;
|
670
|
+
trimmed[key] = options[key];
|
671
|
+
}
|
457
672
|
}
|
458
673
|
|
459
|
-
|
674
|
+
return hasProperties ? trimmed : null;
|
460
675
|
}
|
461
676
|
|
462
|
-
function
|
463
|
-
|
464
|
-
var parentPrev = prev.parent;
|
677
|
+
function getImagePreloadKey(href, imageSrcSet, imageSizes) {
|
678
|
+
var uniquePart = '';
|
465
679
|
|
466
|
-
if (
|
467
|
-
|
468
|
-
}
|
680
|
+
if (typeof imageSrcSet === 'string' && imageSrcSet !== '') {
|
681
|
+
uniquePart += '[' + imageSrcSet + ']';
|
469
682
|
|
470
|
-
|
471
|
-
|
472
|
-
|
683
|
+
if (typeof imageSizes === 'string') {
|
684
|
+
uniquePart += '[' + imageSizes + ']';
|
685
|
+
}
|
473
686
|
} else {
|
474
|
-
|
475
|
-
popPreviousToCommonLevel(parentPrev, next);
|
687
|
+
uniquePart += '[][]' + href;
|
476
688
|
}
|
689
|
+
|
690
|
+
return "[image]" + uniquePart;
|
477
691
|
}
|
478
692
|
|
479
|
-
|
480
|
-
|
693
|
+
// This module registers the host dispatcher so it needs to be imported
|
694
|
+
// small, smaller than how we encode undefined, and is unambiguous. We could use
|
695
|
+
// a different tuple structure to encode this instead but this makes the runtime
|
696
|
+
// cost cheaper by eliminating a type checks in more positions.
|
697
|
+
// prettier-ignore
|
481
698
|
|
482
|
-
|
483
|
-
|
484
|
-
|
699
|
+
function createHints() {
|
700
|
+
return new Set();
|
701
|
+
}
|
485
702
|
|
486
|
-
|
487
|
-
|
488
|
-
popToNearestCommonAncestor(prev, parentNext);
|
489
|
-
} else {
|
490
|
-
// We must still be deeper.
|
491
|
-
popNextToCommonLevel(prev, parentNext);
|
492
|
-
}
|
493
|
-
|
494
|
-
pushNode(next);
|
495
|
-
} // Perform context switching to the new snapshot.
|
496
|
-
// To make it cheap to read many contexts, while not suspending, we make the switch eagerly by
|
497
|
-
// updating all the context's current values. That way reads, always just read the current value.
|
498
|
-
// At the cost of updating contexts even if they're never read by this subtree.
|
499
|
-
|
500
|
-
|
501
|
-
function switchContext(newSnapshot) {
|
502
|
-
// The basic algorithm we need to do is to pop back any contexts that are no longer on the stack.
|
503
|
-
// We also need to update any new contexts that are now on the stack with the deepest value.
|
504
|
-
// The easiest way to update new contexts is to just reapply them in reverse order from the
|
505
|
-
// perspective of the backpointers. To avoid allocating a lot when switching, we use the stack
|
506
|
-
// for that. Therefore this algorithm is recursive.
|
507
|
-
// 1) First we pop which ever snapshot tree was deepest. Popping old contexts as we go.
|
508
|
-
// 2) Then we find the nearest common ancestor from there. Popping old contexts as we go.
|
509
|
-
// 3) Then we reapply new contexts on the way back up the stack.
|
510
|
-
var prev = currentActiveSnapshot;
|
511
|
-
var next = newSnapshot;
|
512
|
-
|
513
|
-
if (prev !== next) {
|
514
|
-
if (prev === null) {
|
515
|
-
// $FlowFixMe[incompatible-call]: This has to be non-null since it's not equal to prev.
|
516
|
-
pushAllNext(next);
|
517
|
-
} else if (next === null) {
|
518
|
-
popAllPrevious(prev);
|
519
|
-
} else if (prev.depth === next.depth) {
|
520
|
-
popToNearestCommonAncestor(prev, next);
|
521
|
-
} else if (prev.depth > next.depth) {
|
522
|
-
popPreviousToCommonLevel(prev, next);
|
523
|
-
} else {
|
524
|
-
popNextToCommonLevel(prev, next);
|
525
|
-
}
|
703
|
+
var supportsRequestStorage = false;
|
704
|
+
var requestStorage = null;
|
526
705
|
|
527
|
-
|
528
|
-
|
706
|
+
var TEMPORARY_REFERENCE_TAG = Symbol.for('react.temporary.reference'); // eslint-disable-next-line no-unused-vars
|
707
|
+
|
708
|
+
function isTemporaryReference(reference) {
|
709
|
+
return reference.$$typeof === TEMPORARY_REFERENCE_TAG;
|
529
710
|
}
|
530
|
-
function
|
531
|
-
|
711
|
+
function resolveTemporaryReferenceID(temporaryReference) {
|
712
|
+
return temporaryReference.$$id;
|
713
|
+
}
|
714
|
+
var proxyHandlers = {
|
715
|
+
get: function (target, name, receiver) {
|
716
|
+
switch (name) {
|
717
|
+
// These names are read by the Flight runtime if you end up using the exports object.
|
718
|
+
case '$$typeof':
|
719
|
+
// These names are a little too common. We should probably have a way to
|
720
|
+
// have the Flight runtime extract the inner target instead.
|
721
|
+
return target.$$typeof;
|
532
722
|
|
533
|
-
|
534
|
-
|
535
|
-
context._currentValue = nextValue;
|
723
|
+
case '$$id':
|
724
|
+
return target.$$id;
|
536
725
|
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
726
|
+
case '$$async':
|
727
|
+
return target.$$async;
|
728
|
+
|
729
|
+
case 'name':
|
730
|
+
return undefined;
|
731
|
+
|
732
|
+
case 'displayName':
|
733
|
+
return undefined;
|
734
|
+
// We need to special case this because createElement reads it if we pass this
|
735
|
+
// reference.
|
736
|
+
|
737
|
+
case 'defaultProps':
|
738
|
+
return undefined;
|
739
|
+
// Avoid this attempting to be serialized.
|
740
|
+
|
741
|
+
case 'toJSON':
|
742
|
+
return undefined;
|
541
743
|
|
542
|
-
|
744
|
+
case Symbol.toPrimitive:
|
745
|
+
// $FlowFixMe[prop-missing]
|
746
|
+
return Object.prototype[Symbol.toPrimitive];
|
747
|
+
|
748
|
+
case Symbol.toStringTag:
|
749
|
+
// $FlowFixMe[prop-missing]
|
750
|
+
return Object.prototype[Symbol.toStringTag];
|
751
|
+
|
752
|
+
case 'Provider':
|
753
|
+
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.");
|
543
754
|
}
|
544
|
-
}
|
545
755
|
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
756
|
+
throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion
|
757
|
+
"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.');
|
758
|
+
},
|
759
|
+
set: function () {
|
760
|
+
throw new Error('Cannot assign to a temporary client reference from a server module.');
|
761
|
+
}
|
762
|
+
};
|
763
|
+
function createTemporaryReference(id) {
|
764
|
+
var reference = Object.defineProperties(function () {
|
765
|
+
throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion
|
766
|
+
"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.");
|
767
|
+
}, {
|
768
|
+
$$typeof: {
|
769
|
+
value: TEMPORARY_REFERENCE_TAG
|
770
|
+
},
|
771
|
+
$$id: {
|
772
|
+
value: id
|
773
|
+
}
|
774
|
+
});
|
775
|
+
return new Proxy(reference, proxyHandlers);
|
556
776
|
}
|
557
|
-
function popProvider() {
|
558
|
-
var prevSnapshot = currentActiveSnapshot;
|
559
777
|
|
560
|
-
|
561
|
-
|
778
|
+
// ATTENTION
|
779
|
+
// When adding new symbols to this file,
|
780
|
+
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
781
|
+
// The Symbol used to tag the ReactElement-like types.
|
782
|
+
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
783
|
+
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
784
|
+
var REACT_CONTEXT_TYPE = Symbol.for('react.context');
|
785
|
+
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
786
|
+
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
787
|
+
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
788
|
+
var REACT_MEMO_TYPE = Symbol.for('react.memo');
|
789
|
+
var REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
790
|
+
var REACT_MEMO_CACHE_SENTINEL = Symbol.for('react.memo_cache_sentinel');
|
791
|
+
var REACT_POSTPONE_TYPE = Symbol.for('react.postpone');
|
792
|
+
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
793
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
794
|
+
function getIteratorFn(maybeIterable) {
|
795
|
+
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
796
|
+
return null;
|
562
797
|
}
|
563
798
|
|
564
|
-
|
565
|
-
var value = prevSnapshot.parentValue;
|
799
|
+
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
566
800
|
|
567
|
-
|
568
|
-
|
569
|
-
} else {
|
570
|
-
prevSnapshot.context._currentValue = value;
|
571
|
-
}
|
801
|
+
if (typeof maybeIterator === 'function') {
|
802
|
+
return maybeIterator;
|
572
803
|
}
|
573
804
|
|
574
|
-
return
|
575
|
-
}
|
576
|
-
function getActiveContext() {
|
577
|
-
return currentActiveSnapshot;
|
578
|
-
}
|
579
|
-
function readContext$1(context) {
|
580
|
-
var value = context._currentValue ;
|
581
|
-
return value;
|
805
|
+
return null;
|
582
806
|
}
|
583
807
|
|
584
808
|
// Corresponds to ReactFiberWakeable and ReactFizzWakeable modules. Generally,
|
@@ -709,29 +933,13 @@
|
|
709
933
|
thenableState = prevThenableState;
|
710
934
|
}
|
711
935
|
function getThenableStateAfterSuspending() {
|
712
|
-
|
936
|
+
// If you use() to Suspend this should always exist but if you throw a Promise instead,
|
937
|
+
// which is not really supported anymore, it will be empty. We use the empty set as a
|
938
|
+
// marker to know if this was a replay of the same component or first attempt.
|
939
|
+
var state = thenableState || createThenableState();
|
713
940
|
thenableState = null;
|
714
941
|
return state;
|
715
942
|
}
|
716
|
-
|
717
|
-
function readContext(context) {
|
718
|
-
{
|
719
|
-
if (context.$$typeof !== REACT_SERVER_CONTEXT_TYPE) {
|
720
|
-
if (isClientReference(context)) {
|
721
|
-
error('Cannot read a Client Context from a Server Component.');
|
722
|
-
} else {
|
723
|
-
error('Only createServerContext is supported in Server Components.');
|
724
|
-
}
|
725
|
-
}
|
726
|
-
|
727
|
-
if (currentRequest$1 === null) {
|
728
|
-
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().');
|
729
|
-
}
|
730
|
-
}
|
731
|
-
|
732
|
-
return readContext$1(context);
|
733
|
-
}
|
734
|
-
|
735
943
|
var HooksDispatcher = {
|
736
944
|
useMemo: function (nextCreate) {
|
737
945
|
return nextCreate();
|
@@ -742,8 +950,8 @@
|
|
742
950
|
useDebugValue: function () {},
|
743
951
|
useDeferredValue: unsupportedHook,
|
744
952
|
useTransition: unsupportedHook,
|
745
|
-
readContext:
|
746
|
-
useContext:
|
953
|
+
readContext: unsupportedContext,
|
954
|
+
useContext: unsupportedContext,
|
747
955
|
useReducer: unsupportedHook,
|
748
956
|
useRef: unsupportedHook,
|
749
957
|
useState: unsupportedHook,
|
@@ -752,7 +960,6 @@
|
|
752
960
|
useImperativeHandle: unsupportedHook,
|
753
961
|
useEffect: unsupportedHook,
|
754
962
|
useId: useId,
|
755
|
-
useMutableSource: unsupportedHook,
|
756
963
|
useSyncExternalStore: unsupportedHook,
|
757
964
|
useCacheRefresh: function () {
|
758
965
|
return unsupportedRefresh;
|
@@ -777,6 +984,10 @@
|
|
777
984
|
throw new Error('Refreshing the cache is not supported in Server Components.');
|
778
985
|
}
|
779
986
|
|
987
|
+
function unsupportedContext() {
|
988
|
+
throw new Error('Cannot read a Client Context from a Server Component.');
|
989
|
+
}
|
990
|
+
|
780
991
|
function useId() {
|
781
992
|
if (currentRequest$1 === null) {
|
782
993
|
throw new Error('useId can only be used while React is rendering');
|
@@ -802,20 +1013,22 @@
|
|
802
1013
|
}
|
803
1014
|
|
804
1015
|
return trackUsedThenable(thenableState, thenable, index);
|
805
|
-
} else if (usable.$$typeof ===
|
806
|
-
|
807
|
-
return readContext(context);
|
1016
|
+
} else if (usable.$$typeof === REACT_CONTEXT_TYPE) {
|
1017
|
+
unsupportedContext();
|
808
1018
|
}
|
809
1019
|
}
|
810
1020
|
|
811
|
-
{
|
812
|
-
if (
|
813
|
-
|
1021
|
+
if (isClientReference(usable)) {
|
1022
|
+
if (usable.value != null && usable.value.$$typeof === REACT_CONTEXT_TYPE) {
|
1023
|
+
// Show a more specific message since it's a common mistake.
|
1024
|
+
throw new Error('Cannot read a Client Context from a Server Component.');
|
1025
|
+
} else {
|
1026
|
+
throw new Error('Cannot use() an already resolved Client Reference.');
|
814
1027
|
}
|
815
|
-
}
|
816
|
-
|
817
|
-
|
818
|
-
|
1028
|
+
} else {
|
1029
|
+
throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion
|
1030
|
+
'An unsupported type was passed to use(): ' + String(usable));
|
1031
|
+
}
|
819
1032
|
}
|
820
1033
|
|
821
1034
|
function createSignal() {
|
@@ -864,6 +1077,8 @@
|
|
864
1077
|
return isArrayImpl(a);
|
865
1078
|
}
|
866
1079
|
|
1080
|
+
var getPrototypeOf = Object.getPrototypeOf;
|
1081
|
+
|
867
1082
|
// in case they error.
|
868
1083
|
|
869
1084
|
var jsxPropsParents = new WeakMap();
|
@@ -882,7 +1097,7 @@
|
|
882
1097
|
// still just a plain simple object.
|
883
1098
|
|
884
1099
|
|
885
|
-
if (
|
1100
|
+
if (getPrototypeOf(object)) {
|
886
1101
|
return false;
|
887
1102
|
}
|
888
1103
|
|
@@ -898,7 +1113,7 @@
|
|
898
1113
|
}
|
899
1114
|
|
900
1115
|
function isSimpleObject(object) {
|
901
|
-
if (!isObjectPrototype(
|
1116
|
+
if (!isObjectPrototype(getPrototypeOf(object))) {
|
902
1117
|
return false;
|
903
1118
|
}
|
904
1119
|
|
@@ -951,6 +1166,10 @@
|
|
951
1166
|
return '[...]';
|
952
1167
|
}
|
953
1168
|
|
1169
|
+
if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) {
|
1170
|
+
return describeClientReference();
|
1171
|
+
}
|
1172
|
+
|
954
1173
|
var name = objectName(value);
|
955
1174
|
|
956
1175
|
if (name === 'Object') {
|
@@ -961,7 +1180,15 @@
|
|
961
1180
|
}
|
962
1181
|
|
963
1182
|
case 'function':
|
964
|
-
|
1183
|
+
{
|
1184
|
+
if (value.$$typeof === CLIENT_REFERENCE_TAG) {
|
1185
|
+
return describeClientReference();
|
1186
|
+
}
|
1187
|
+
|
1188
|
+
var _name = value.displayName || value.name;
|
1189
|
+
|
1190
|
+
return _name ? 'function ' + _name : 'function';
|
1191
|
+
}
|
965
1192
|
|
966
1193
|
default:
|
967
1194
|
// eslint-disable-next-line react-internal/safe-string-coercion
|
@@ -1007,6 +1234,12 @@
|
|
1007
1234
|
return '';
|
1008
1235
|
}
|
1009
1236
|
|
1237
|
+
var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
|
1238
|
+
|
1239
|
+
function describeClientReference(ref) {
|
1240
|
+
return 'client';
|
1241
|
+
}
|
1242
|
+
|
1010
1243
|
function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
1011
1244
|
var objKind = objectName(objectOrArray);
|
1012
1245
|
|
@@ -1032,7 +1265,6 @@
|
|
1032
1265
|
if (typeof value === 'string') {
|
1033
1266
|
substr = value;
|
1034
1267
|
} else if (typeof value === 'object' && value !== null) {
|
1035
|
-
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1036
1268
|
substr = '{' + describeObjectForErrorMessage(value) + '}';
|
1037
1269
|
} else {
|
1038
1270
|
substr = '{' + describeValueForErrorMessage(value) + '}';
|
@@ -1065,7 +1297,6 @@
|
|
1065
1297
|
var _substr = void 0;
|
1066
1298
|
|
1067
1299
|
if (typeof _value === 'object' && _value !== null) {
|
1068
|
-
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1069
1300
|
_substr = describeObjectForErrorMessage(_value);
|
1070
1301
|
} else {
|
1071
1302
|
_substr = describeValueForErrorMessage(_value);
|
@@ -1087,6 +1318,8 @@
|
|
1087
1318
|
} else {
|
1088
1319
|
if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
|
1089
1320
|
str = '<' + describeElementType(objectOrArray.type) + '/>';
|
1321
|
+
} else if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) {
|
1322
|
+
return describeClientReference();
|
1090
1323
|
} else if (jsxPropsParents.has(objectOrArray)) {
|
1091
1324
|
// Print JSX
|
1092
1325
|
var _type = jsxPropsParents.get(objectOrArray);
|
@@ -1104,7 +1337,6 @@
|
|
1104
1337
|
var _substr2 = void 0;
|
1105
1338
|
|
1106
1339
|
if (name === expandedName && typeof _value2 === 'object' && _value2 !== null) {
|
1107
|
-
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1108
1340
|
_substr2 = describeObjectForErrorMessage(_value2);
|
1109
1341
|
} else {
|
1110
1342
|
_substr2 = describeValueForErrorMessage(_value2);
|
@@ -1138,20 +1370,19 @@
|
|
1138
1370
|
str += ', ';
|
1139
1371
|
}
|
1140
1372
|
|
1141
|
-
var
|
1142
|
-
str += describeKeyForErrorMessage(
|
1143
|
-
var _value3 = _object[
|
1373
|
+
var _name2 = _names[_i3];
|
1374
|
+
str += describeKeyForErrorMessage(_name2) + ': ';
|
1375
|
+
var _value3 = _object[_name2];
|
1144
1376
|
|
1145
1377
|
var _substr3 = void 0;
|
1146
1378
|
|
1147
1379
|
if (typeof _value3 === 'object' && _value3 !== null) {
|
1148
|
-
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1149
1380
|
_substr3 = describeObjectForErrorMessage(_value3);
|
1150
1381
|
} else {
|
1151
1382
|
_substr3 = describeValueForErrorMessage(_value3);
|
1152
1383
|
}
|
1153
1384
|
|
1154
|
-
if (
|
1385
|
+
if (_name2 === expandedName) {
|
1155
1386
|
start = str.length;
|
1156
1387
|
length = _substr3.length;
|
1157
1388
|
str += _substr3;
|
@@ -1178,41 +1409,44 @@
|
|
1178
1409
|
return '\n ' + str;
|
1179
1410
|
}
|
1180
1411
|
|
1181
|
-
var
|
1182
|
-
|
1183
|
-
if (!ContextRegistry[globalName]) {
|
1184
|
-
ContextRegistry[globalName] = React.createServerContext(globalName, // $FlowFixMe[incompatible-call] function signature doesn't reflect the symbol value
|
1185
|
-
REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED);
|
1186
|
-
}
|
1412
|
+
var ReactSharedServerInternals = // $FlowFixMe: It's defined in the one we resolve to.
|
1413
|
+
React.__SECRET_SERVER_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
1187
1414
|
|
1188
|
-
|
1415
|
+
if (!ReactSharedServerInternals) {
|
1416
|
+
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.');
|
1189
1417
|
}
|
1190
1418
|
|
1419
|
+
var ObjectPrototype = Object.prototype;
|
1420
|
+
var stringify = JSON.stringify; // Serializable values
|
1191
1421
|
// Thenable<ReactClientValue>
|
1192
1422
|
|
1193
1423
|
var PENDING$1 = 0;
|
1194
1424
|
var COMPLETED = 1;
|
1195
1425
|
var ABORTED = 3;
|
1196
1426
|
var ERRORED$1 = 4;
|
1427
|
+
var ReactCurrentCache = ReactSharedServerInternals.ReactCurrentCache;
|
1197
1428
|
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
1198
|
-
var ReactCurrentCache = ReactSharedInternals.ReactCurrentCache;
|
1199
1429
|
|
1200
1430
|
function defaultErrorHandler(error) {
|
1201
1431
|
console['error'](error); // Don't transform to our wrapper
|
1202
1432
|
}
|
1203
1433
|
|
1434
|
+
function defaultPostponeHandler(reason) {// Noop
|
1435
|
+
}
|
1436
|
+
|
1204
1437
|
var OPEN = 0;
|
1205
1438
|
var CLOSING = 1;
|
1206
1439
|
var CLOSED = 2;
|
1207
|
-
function createRequest(model, bundlerConfig, onError,
|
1440
|
+
function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpone, environmentName) {
|
1208
1441
|
if (ReactCurrentCache.current !== null && ReactCurrentCache.current !== DefaultCacheDispatcher) {
|
1209
1442
|
throw new Error('Currently React only supports one RSC renderer at a time.');
|
1210
1443
|
}
|
1211
1444
|
|
1212
|
-
prepareHostDispatcher();
|
1213
1445
|
ReactCurrentCache.current = DefaultCacheDispatcher;
|
1214
1446
|
var abortSet = new Set();
|
1215
1447
|
var pingedTasks = [];
|
1448
|
+
var cleanupQueue = [];
|
1449
|
+
|
1216
1450
|
var hints = createHints();
|
1217
1451
|
var request = {
|
1218
1452
|
status: OPEN,
|
@@ -1228,23 +1462,24 @@
|
|
1228
1462
|
pingedTasks: pingedTasks,
|
1229
1463
|
completedImportChunks: [],
|
1230
1464
|
completedHintChunks: [],
|
1231
|
-
|
1465
|
+
completedRegularChunks: [],
|
1232
1466
|
completedErrorChunks: [],
|
1233
1467
|
writtenSymbols: new Map(),
|
1234
1468
|
writtenClientReferences: new Map(),
|
1235
1469
|
writtenServerReferences: new Map(),
|
1236
|
-
|
1470
|
+
writtenObjects: new WeakMap(),
|
1237
1471
|
identifierPrefix: identifierPrefix || '',
|
1238
1472
|
identifierCount: 1,
|
1473
|
+
taintCleanupQueue: cleanupQueue,
|
1239
1474
|
onError: onError === undefined ? defaultErrorHandler : onError,
|
1240
|
-
|
1241
|
-
toJSON: function (key, value) {
|
1242
|
-
return resolveModelToJSON(request, this, key, value);
|
1243
|
-
}
|
1475
|
+
onPostpone: onPostpone === undefined ? defaultPostponeHandler : onPostpone
|
1244
1476
|
};
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1477
|
+
|
1478
|
+
{
|
1479
|
+
request.environmentName = environmentName === undefined ? 'Server' : environmentName;
|
1480
|
+
}
|
1481
|
+
|
1482
|
+
var rootTask = createTask(request, model, null, false, abortSet);
|
1248
1483
|
pingedTasks.push(rootTask);
|
1249
1484
|
return request;
|
1250
1485
|
}
|
@@ -1255,15 +1490,18 @@
|
|
1255
1490
|
return null;
|
1256
1491
|
}
|
1257
1492
|
|
1258
|
-
function
|
1259
|
-
|
1260
|
-
|
1493
|
+
function serializeThenable(request, task, thenable) {
|
1494
|
+
var newTask = createTask(request, null, task.keyPath, // the server component sequence continues through Promise-as-a-child.
|
1495
|
+
task.implicitSlot, request.abortableTasks);
|
1261
1496
|
|
1262
|
-
|
1497
|
+
{
|
1498
|
+
// If this came from Flight, forward any debug info into this new row.
|
1499
|
+
var debugInfo = thenable._debugInfo;
|
1263
1500
|
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1501
|
+
if (debugInfo) {
|
1502
|
+
forwardDebugInfo(request, newTask.id, debugInfo);
|
1503
|
+
}
|
1504
|
+
}
|
1267
1505
|
|
1268
1506
|
switch (thenable.status) {
|
1269
1507
|
case 'fulfilled':
|
@@ -1277,14 +1515,10 @@
|
|
1277
1515
|
case 'rejected':
|
1278
1516
|
{
|
1279
1517
|
var x = thenable.reason;
|
1280
|
-
var digest = logRecoverableError(request, x);
|
1281
1518
|
|
1282
1519
|
{
|
1283
|
-
var
|
1284
|
-
|
1285
|
-
stack = _getErrorMessageAndSt.stack;
|
1286
|
-
|
1287
|
-
emitErrorChunkDev(request, newTask.id, digest, message, stack);
|
1520
|
+
var digest = logRecoverableError(request, x);
|
1521
|
+
emitErrorChunk(request, newTask.id, digest, x);
|
1288
1522
|
}
|
1289
1523
|
|
1290
1524
|
return newTask.id;
|
@@ -1322,18 +1556,16 @@
|
|
1322
1556
|
newTask.model = value;
|
1323
1557
|
pingTask(request, newTask);
|
1324
1558
|
}, function (reason) {
|
1325
|
-
newTask.status = ERRORED$1; // TODO: We should ideally do this inside performWork so it's scheduled
|
1326
|
-
|
1327
|
-
var digest = logRecoverableError(request, reason);
|
1328
|
-
|
1329
1559
|
{
|
1330
|
-
|
1331
|
-
_message = _getErrorMessageAndSt2.message,
|
1332
|
-
_stack = _getErrorMessageAndSt2.stack;
|
1560
|
+
newTask.status = ERRORED$1;
|
1333
1561
|
|
1334
|
-
|
1562
|
+
var _digest = logRecoverableError(request, reason);
|
1563
|
+
|
1564
|
+
emitErrorChunk(request, newTask.id, _digest, reason);
|
1335
1565
|
}
|
1336
1566
|
|
1567
|
+
request.abortableTasks.delete(newTask);
|
1568
|
+
|
1337
1569
|
if (request.destination !== null) {
|
1338
1570
|
flushCompletedChunks(request, request.destination);
|
1339
1571
|
}
|
@@ -1405,14 +1637,136 @@
|
|
1405
1637
|
_payload: thenable,
|
1406
1638
|
_init: readThenable
|
1407
1639
|
};
|
1640
|
+
|
1641
|
+
{
|
1642
|
+
// If this came from React, transfer the debug info.
|
1643
|
+
lazyType._debugInfo = thenable._debugInfo || [];
|
1644
|
+
}
|
1645
|
+
|
1408
1646
|
return lazyType;
|
1409
1647
|
}
|
1410
1648
|
|
1411
|
-
function
|
1649
|
+
function renderFunctionComponent(request, task, key, Component, props) {
|
1650
|
+
// Reset the task's thenable state before continuing, so that if a later
|
1651
|
+
// component suspends we can reuse the same task object. If the same
|
1652
|
+
// component suspends again, the thenable state will be restored.
|
1653
|
+
var prevThenableState = task.thenableState;
|
1654
|
+
task.thenableState = null;
|
1655
|
+
|
1656
|
+
{
|
1657
|
+
if (debugID === null) {
|
1658
|
+
// We don't have a chunk to assign debug info. We need to outline this
|
1659
|
+
// component to assign it an ID.
|
1660
|
+
return outlineTask(request, task);
|
1661
|
+
} else if (prevThenableState !== null) ; else {
|
1662
|
+
// This is a new component in the same task so we can emit more debug info.
|
1663
|
+
var componentName = Component.displayName || Component.name || '';
|
1664
|
+
request.pendingChunks++;
|
1665
|
+
emitDebugChunk(request, debugID, {
|
1666
|
+
name: componentName,
|
1667
|
+
env: request.environmentName
|
1668
|
+
});
|
1669
|
+
}
|
1670
|
+
}
|
1671
|
+
|
1672
|
+
prepareToUseHooksForComponent(prevThenableState); // The secondArg is always undefined in Server Components since refs error early.
|
1673
|
+
|
1674
|
+
var secondArg = undefined;
|
1675
|
+
var result = Component(props, secondArg);
|
1676
|
+
|
1677
|
+
if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
|
1678
|
+
// When the return value is in children position we can resolve it immediately,
|
1679
|
+
// to its value without a wrapper if it's synchronously available.
|
1680
|
+
var thenable = result;
|
1681
|
+
|
1682
|
+
if (thenable.status === 'fulfilled') {
|
1683
|
+
return thenable.value;
|
1684
|
+
} // TODO: Once we accept Promises as children on the client, we can just return
|
1685
|
+
// the thenable here.
|
1686
|
+
|
1687
|
+
|
1688
|
+
result = createLazyWrapperAroundWakeable(result);
|
1689
|
+
} // Track this element's key on the Server Component on the keyPath context..
|
1690
|
+
|
1691
|
+
|
1692
|
+
var prevKeyPath = task.keyPath;
|
1693
|
+
var prevImplicitSlot = task.implicitSlot;
|
1694
|
+
|
1695
|
+
if (key !== null) {
|
1696
|
+
// Append the key to the path. Technically a null key should really add the child
|
1697
|
+
// index. We don't do that to hold the payload small and implementation simple.
|
1698
|
+
task.keyPath = prevKeyPath === null ? key : prevKeyPath + ',' + key;
|
1699
|
+
} else if (prevKeyPath === null) {
|
1700
|
+
// This sequence of Server Components has no keys. This means that it was rendered
|
1701
|
+
// in a slot that needs to assign an implicit key. Even if children below have
|
1702
|
+
// explicit keys, they should not be used for the outer most key since it might
|
1703
|
+
// collide with other slots in that set.
|
1704
|
+
task.implicitSlot = true;
|
1705
|
+
}
|
1706
|
+
|
1707
|
+
var json = renderModelDestructive(request, task, emptyRoot, '', result);
|
1708
|
+
task.keyPath = prevKeyPath;
|
1709
|
+
task.implicitSlot = prevImplicitSlot;
|
1710
|
+
return json;
|
1711
|
+
}
|
1712
|
+
|
1713
|
+
function renderFragment(request, task, children) {
|
1714
|
+
{
|
1715
|
+
var debugInfo = children._debugInfo;
|
1716
|
+
|
1717
|
+
if (debugInfo) {
|
1718
|
+
// If this came from Flight, forward any debug info into this new row.
|
1719
|
+
if (debugID === null) {
|
1720
|
+
// We don't have a chunk to assign debug info. We need to outline this
|
1721
|
+
// component to assign it an ID.
|
1722
|
+
return outlineTask(request, task);
|
1723
|
+
} else {
|
1724
|
+
// Forward any debug info we have the first time we see it.
|
1725
|
+
// We do this after init so that we have received all the debug info
|
1726
|
+
// from the server by the time we emit it.
|
1727
|
+
forwardDebugInfo(request, debugID, debugInfo);
|
1728
|
+
}
|
1729
|
+
}
|
1730
|
+
}
|
1731
|
+
|
1732
|
+
{
|
1733
|
+
return children;
|
1734
|
+
}
|
1735
|
+
}
|
1736
|
+
|
1737
|
+
function renderClientElement(task, type, key, props) {
|
1738
|
+
{
|
1739
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1740
|
+
} // We prepend the terminal client element that actually gets serialized with
|
1741
|
+
} // The chunk ID we're currently rendering that we can assign debug data to.
|
1742
|
+
|
1743
|
+
|
1744
|
+
var debugID = null;
|
1745
|
+
|
1746
|
+
function outlineTask(request, task) {
|
1747
|
+
var newTask = createTask(request, task.model, // the currently rendering element
|
1748
|
+
task.keyPath, // unlike outlineModel this one carries along context
|
1749
|
+
task.implicitSlot, request.abortableTasks);
|
1750
|
+
retryTask(request, newTask);
|
1751
|
+
|
1752
|
+
if (newTask.status === COMPLETED) {
|
1753
|
+
// We completed synchronously so we can refer to this by reference. This
|
1754
|
+
// makes it behaves the same as prod during deserialization.
|
1755
|
+
return serializeByValueID(newTask.id);
|
1756
|
+
} // This didn't complete synchronously so it wouldn't have even if we didn't
|
1757
|
+
// outline it, so this would reduce to a lazy reference even in prod.
|
1758
|
+
|
1759
|
+
|
1760
|
+
return serializeLazyID(newTask.id);
|
1761
|
+
}
|
1762
|
+
|
1763
|
+
function renderElement(request, task, type, key, ref, props) {
|
1412
1764
|
if (ref !== null && ref !== undefined) {
|
1413
1765
|
// When the ref moves to the regular props object this will implicitly
|
1414
1766
|
// throw for functions. We could probably relax it to a DEV warning for other
|
1415
1767
|
// cases.
|
1768
|
+
// TODO: `ref` is now just a prop when `enableRefAsProp` is on. Should we
|
1769
|
+
// do what the above comment says?
|
1416
1770
|
throw new Error('Refs cannot be used in Server Components, nor passed to Client Components.');
|
1417
1771
|
}
|
1418
1772
|
|
@@ -1425,49 +1779,38 @@
|
|
1425
1779
|
}
|
1426
1780
|
|
1427
1781
|
if (typeof type === 'function') {
|
1428
|
-
if (isClientReference(type)) {
|
1782
|
+
if (isClientReference(type) || isTemporaryReference(type)) {
|
1429
1783
|
// This is a reference to a Client Component.
|
1430
|
-
return
|
1431
|
-
} // This is a
|
1432
|
-
|
1784
|
+
return renderClientElement(task, type, key, props);
|
1785
|
+
} // This is a Server Component.
|
1433
1786
|
|
1434
|
-
prepareToUseHooksForComponent(prevThenableState);
|
1435
|
-
var result = type(props);
|
1436
1787
|
|
1437
|
-
|
1438
|
-
// When the return value is in children position we can resolve it immediately,
|
1439
|
-
// to its value without a wrapper if it's synchronously available.
|
1440
|
-
var thenable = result;
|
1441
|
-
|
1442
|
-
if (thenable.status === 'fulfilled') {
|
1443
|
-
return thenable.value;
|
1444
|
-
} // TODO: Once we accept Promises as children on the client, we can just return
|
1445
|
-
// the thenable here.
|
1446
|
-
|
1447
|
-
|
1448
|
-
return createLazyWrapperAroundWakeable(result);
|
1449
|
-
}
|
1450
|
-
|
1451
|
-
return result;
|
1788
|
+
return renderFunctionComponent(request, task, key, type, props);
|
1452
1789
|
} else if (typeof type === 'string') {
|
1453
1790
|
// This is a host element. E.g. HTML.
|
1454
|
-
return
|
1791
|
+
return renderClientElement(task, type, key, props);
|
1455
1792
|
} else if (typeof type === 'symbol') {
|
1456
|
-
if (type === REACT_FRAGMENT_TYPE) {
|
1793
|
+
if (type === REACT_FRAGMENT_TYPE && key === null) {
|
1457
1794
|
// For key-less fragments, we add a small optimization to avoid serializing
|
1458
1795
|
// it as a wrapper.
|
1459
|
-
|
1460
|
-
|
1461
|
-
|
1796
|
+
var prevImplicitSlot = task.implicitSlot;
|
1797
|
+
|
1798
|
+
if (task.keyPath === null) {
|
1799
|
+
task.implicitSlot = true;
|
1800
|
+
}
|
1801
|
+
|
1802
|
+
var json = renderModelDestructive(request, task, emptyRoot, '', props.children);
|
1803
|
+
task.implicitSlot = prevImplicitSlot;
|
1804
|
+
return json;
|
1462
1805
|
} // This might be a built-in React component. We'll let the client decide.
|
1463
1806
|
// Any built-in works as long as its props are serializable.
|
1464
1807
|
|
1465
1808
|
|
1466
|
-
return
|
1809
|
+
return renderClientElement(task, type, key, props);
|
1467
1810
|
} else if (type != null && typeof type === 'object') {
|
1468
1811
|
if (isClientReference(type)) {
|
1469
1812
|
// This is a reference to a Client Component.
|
1470
|
-
return
|
1813
|
+
return renderClientElement(task, type, key, props);
|
1471
1814
|
}
|
1472
1815
|
|
1473
1816
|
switch (type.$$typeof) {
|
@@ -1476,45 +1819,17 @@
|
|
1476
1819
|
var payload = type._payload;
|
1477
1820
|
var init = type._init;
|
1478
1821
|
var wrappedType = init(payload);
|
1479
|
-
return
|
1822
|
+
return renderElement(request, task, wrappedType, key, ref, props);
|
1480
1823
|
}
|
1481
1824
|
|
1482
1825
|
case REACT_FORWARD_REF_TYPE:
|
1483
1826
|
{
|
1484
|
-
|
1485
|
-
prepareToUseHooksForComponent(prevThenableState);
|
1486
|
-
return render(props, undefined);
|
1827
|
+
return renderFunctionComponent(request, task, key, type.render, props);
|
1487
1828
|
}
|
1488
1829
|
|
1489
1830
|
case REACT_MEMO_TYPE:
|
1490
1831
|
{
|
1491
|
-
return
|
1492
|
-
}
|
1493
|
-
|
1494
|
-
case REACT_PROVIDER_TYPE:
|
1495
|
-
{
|
1496
|
-
pushProvider(type._context, props.value);
|
1497
|
-
|
1498
|
-
{
|
1499
|
-
var extraKeys = Object.keys(props).filter(function (value) {
|
1500
|
-
if (value === 'children' || value === 'value') {
|
1501
|
-
return false;
|
1502
|
-
}
|
1503
|
-
|
1504
|
-
return true;
|
1505
|
-
});
|
1506
|
-
|
1507
|
-
if (extraKeys.length !== 0) {
|
1508
|
-
error('ServerContext can only have a value prop and children. Found: %s', JSON.stringify(extraKeys));
|
1509
|
-
}
|
1510
|
-
}
|
1511
|
-
|
1512
|
-
return [REACT_ELEMENT_TYPE, type, key, // Rely on __popProvider being serialized last to pop the provider.
|
1513
|
-
{
|
1514
|
-
value: props.value,
|
1515
|
-
children: props.children,
|
1516
|
-
__pop: POP
|
1517
|
-
}];
|
1832
|
+
return renderElement(request, task, type.type, key, ref, props);
|
1518
1833
|
}
|
1519
1834
|
}
|
1520
1835
|
}
|
@@ -1534,16 +1849,51 @@
|
|
1534
1849
|
}
|
1535
1850
|
}
|
1536
1851
|
|
1537
|
-
function createTask(request, model,
|
1852
|
+
function createTask(request, model, keyPath, implicitSlot, abortSet) {
|
1853
|
+
request.pendingChunks++;
|
1538
1854
|
var id = request.nextChunkId++;
|
1855
|
+
|
1856
|
+
if (typeof model === 'object' && model !== null) {
|
1857
|
+
// If we're about to write this into a new task we can assign it an ID early so that
|
1858
|
+
// any other references can refer to the value we're about to write.
|
1859
|
+
{
|
1860
|
+
request.writtenObjects.set(model, id);
|
1861
|
+
}
|
1862
|
+
}
|
1863
|
+
|
1539
1864
|
var task = {
|
1540
1865
|
id: id,
|
1541
1866
|
status: PENDING$1,
|
1542
1867
|
model: model,
|
1543
|
-
|
1868
|
+
keyPath: keyPath,
|
1869
|
+
implicitSlot: implicitSlot,
|
1544
1870
|
ping: function () {
|
1545
1871
|
return pingTask(request, task);
|
1546
1872
|
},
|
1873
|
+
toJSON: function (parentPropertyName, value) {
|
1874
|
+
var parent = this; // Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us
|
1875
|
+
|
1876
|
+
{
|
1877
|
+
// $FlowFixMe[incompatible-use]
|
1878
|
+
var originalValue = parent[parentPropertyName];
|
1879
|
+
|
1880
|
+
if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
|
1881
|
+
if (objectName(originalValue) !== 'Object') {
|
1882
|
+
var jsxParentType = jsxChildrenParents.get(parent);
|
1883
|
+
|
1884
|
+
if (typeof jsxParentType === 'string') {
|
1885
|
+
error('%s objects cannot be rendered as text children. Try formatting it using toString().%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
|
1886
|
+
} else {
|
1887
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
|
1888
|
+
}
|
1889
|
+
} else {
|
1890
|
+
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));
|
1891
|
+
}
|
1892
|
+
}
|
1893
|
+
}
|
1894
|
+
|
1895
|
+
return renderModel(request, task, parent, parentPropertyName, value);
|
1896
|
+
},
|
1547
1897
|
thenableState: null
|
1548
1898
|
};
|
1549
1899
|
abortSet.add(task);
|
@@ -1566,12 +1916,12 @@
|
|
1566
1916
|
return '$F' + id.toString(16);
|
1567
1917
|
}
|
1568
1918
|
|
1569
|
-
function
|
1570
|
-
return '$
|
1919
|
+
function serializeTemporaryReferenceID(id) {
|
1920
|
+
return '$T' + id;
|
1571
1921
|
}
|
1572
1922
|
|
1573
|
-
function
|
1574
|
-
return '$
|
1923
|
+
function serializeSymbolReference(name) {
|
1924
|
+
return '$S' + name;
|
1575
1925
|
}
|
1576
1926
|
|
1577
1927
|
function serializeNumber(number) {
|
@@ -1606,13 +1956,23 @@
|
|
1606
1956
|
return '$n' + n.toString(10);
|
1607
1957
|
}
|
1608
1958
|
|
1609
|
-
function
|
1959
|
+
function serializeRowHeader(tag, id) {
|
1960
|
+
return id.toString(16) + ':' + tag;
|
1961
|
+
}
|
1962
|
+
|
1963
|
+
function encodeReferenceChunk(request, id, reference) {
|
1964
|
+
var json = stringify(reference);
|
1965
|
+
var row = id.toString(16) + ':' + json + '\n';
|
1966
|
+
return stringToChunk(row);
|
1967
|
+
}
|
1968
|
+
|
1969
|
+
function serializeClientReference(request, parent, parentPropertyName, clientReference) {
|
1610
1970
|
var clientReferenceKey = getClientReferenceKey(clientReference);
|
1611
1971
|
var writtenClientReferences = request.writtenClientReferences;
|
1612
1972
|
var existingId = writtenClientReferences.get(clientReferenceKey);
|
1613
1973
|
|
1614
1974
|
if (existingId !== undefined) {
|
1615
|
-
if (parent[0] === REACT_ELEMENT_TYPE &&
|
1975
|
+
if (parent[0] === REACT_ELEMENT_TYPE && parentPropertyName === '1') {
|
1616
1976
|
// If we're encoding the "type" of an element, we can refer
|
1617
1977
|
// to that by a lazy reference instead of directly since React
|
1618
1978
|
// knows how to deal with lazy values. This lets us suspend
|
@@ -1631,7 +1991,7 @@
|
|
1631
1991
|
emitImportChunk(request, importId, clientReferenceMetadata);
|
1632
1992
|
writtenClientReferences.set(clientReferenceKey, importId);
|
1633
1993
|
|
1634
|
-
if (parent[0] === REACT_ELEMENT_TYPE &&
|
1994
|
+
if (parent[0] === REACT_ELEMENT_TYPE && parentPropertyName === '1') {
|
1635
1995
|
// If we're encoding the "type" of an element, we can refer
|
1636
1996
|
// to that by a lazy reference instead of directly since React
|
1637
1997
|
// knows how to deal with lazy values. This lets us suspend
|
@@ -1645,20 +2005,20 @@
|
|
1645
2005
|
request.pendingChunks++;
|
1646
2006
|
var errorId = request.nextChunkId++;
|
1647
2007
|
var digest = logRecoverableError(request, x);
|
1648
|
-
|
1649
|
-
{
|
1650
|
-
var _getErrorMessageAndSt3 = getErrorMessageAndStackDev(x),
|
1651
|
-
message = _getErrorMessageAndSt3.message,
|
1652
|
-
stack = _getErrorMessageAndSt3.stack;
|
1653
|
-
|
1654
|
-
emitErrorChunkDev(request, errorId, digest, message, stack);
|
1655
|
-
}
|
1656
|
-
|
2008
|
+
emitErrorChunk(request, errorId, digest, x);
|
1657
2009
|
return serializeByValueID(errorId);
|
1658
2010
|
}
|
1659
2011
|
}
|
1660
2012
|
|
1661
|
-
function
|
2013
|
+
function outlineModel(request, value) {
|
2014
|
+
var newTask = createTask(request, value, null, // The way we use outlining is for reusing an object.
|
2015
|
+
false, // It makes no sense for that use case to be contextual.
|
2016
|
+
request.abortableTasks);
|
2017
|
+
retryTask(request, newTask);
|
2018
|
+
return newTask.id;
|
2019
|
+
}
|
2020
|
+
|
2021
|
+
function serializeServerReference(request, serverReference) {
|
1662
2022
|
var writtenServerReferences = request.writtenServerReferences;
|
1663
2023
|
var existingId = writtenServerReferences.get(serverReference);
|
1664
2024
|
|
@@ -1671,15 +2031,69 @@
|
|
1671
2031
|
id: getServerReferenceId(request.bundlerConfig, serverReference),
|
1672
2032
|
bound: bound ? Promise.resolve(bound) : null
|
1673
2033
|
};
|
1674
|
-
request
|
1675
|
-
var metadataId = request.nextChunkId++; // We assume that this object doesn't suspend.
|
1676
|
-
|
1677
|
-
var processedChunk = processModelChunk(request, metadataId, serverReferenceMetadata);
|
1678
|
-
request.completedJSONChunks.push(processedChunk);
|
2034
|
+
var metadataId = outlineModel(request, serverReferenceMetadata);
|
1679
2035
|
writtenServerReferences.set(serverReference, metadataId);
|
1680
2036
|
return serializeServerReferenceID(metadataId);
|
1681
2037
|
}
|
1682
2038
|
|
2039
|
+
function serializeTemporaryReference(request, temporaryReference) {
|
2040
|
+
var id = resolveTemporaryReferenceID(temporaryReference);
|
2041
|
+
return serializeTemporaryReferenceID(id);
|
2042
|
+
}
|
2043
|
+
|
2044
|
+
function serializeLargeTextString(request, text) {
|
2045
|
+
request.pendingChunks += 2;
|
2046
|
+
var textId = request.nextChunkId++;
|
2047
|
+
var textChunk = stringToChunk(text);
|
2048
|
+
var binaryLength = byteLengthOfChunk(textChunk);
|
2049
|
+
var row = textId.toString(16) + ':T' + binaryLength.toString(16) + ',';
|
2050
|
+
var headerChunk = stringToChunk(row);
|
2051
|
+
request.completedRegularChunks.push(headerChunk, textChunk);
|
2052
|
+
return serializeByValueID(textId);
|
2053
|
+
}
|
2054
|
+
|
2055
|
+
function serializeMap(request, map) {
|
2056
|
+
var entries = Array.from(map);
|
2057
|
+
|
2058
|
+
for (var i = 0; i < entries.length; i++) {
|
2059
|
+
var key = entries[i][0];
|
2060
|
+
|
2061
|
+
if (typeof key === 'object' && key !== null) {
|
2062
|
+
var writtenObjects = request.writtenObjects;
|
2063
|
+
var existingId = writtenObjects.get(key);
|
2064
|
+
|
2065
|
+
if (existingId === undefined) {
|
2066
|
+
// Mark all object keys as seen so that they're always outlined.
|
2067
|
+
writtenObjects.set(key, -1);
|
2068
|
+
}
|
2069
|
+
}
|
2070
|
+
}
|
2071
|
+
|
2072
|
+
var id = outlineModel(request, entries);
|
2073
|
+
return '$Q' + id.toString(16);
|
2074
|
+
}
|
2075
|
+
|
2076
|
+
function serializeSet(request, set) {
|
2077
|
+
var entries = Array.from(set);
|
2078
|
+
|
2079
|
+
for (var i = 0; i < entries.length; i++) {
|
2080
|
+
var key = entries[i];
|
2081
|
+
|
2082
|
+
if (typeof key === 'object' && key !== null) {
|
2083
|
+
var writtenObjects = request.writtenObjects;
|
2084
|
+
var existingId = writtenObjects.get(key);
|
2085
|
+
|
2086
|
+
if (existingId === undefined) {
|
2087
|
+
// Mark all object keys as seen so that they're always outlined.
|
2088
|
+
writtenObjects.set(key, -1);
|
2089
|
+
}
|
2090
|
+
}
|
2091
|
+
}
|
2092
|
+
|
2093
|
+
var id = outlineModel(request, entries);
|
2094
|
+
return '$W' + id.toString(16);
|
2095
|
+
}
|
2096
|
+
|
1683
2097
|
function escapeStringValue(value) {
|
1684
2098
|
if (value[0] === '$') {
|
1685
2099
|
// We need to escape $ prefixed strings since we use those to encode
|
@@ -1690,166 +2104,262 @@
|
|
1690
2104
|
}
|
1691
2105
|
}
|
1692
2106
|
|
1693
|
-
var
|
1694
|
-
var isInsideContextValue = false;
|
1695
|
-
function resolveModelToJSON(request, parent, key, value) {
|
1696
|
-
// Make sure that `parent[key]` wasn't JSONified before `value` was passed to us
|
1697
|
-
{
|
1698
|
-
// $FlowFixMe[incompatible-use]
|
1699
|
-
var originalValue = parent[key];
|
2107
|
+
var modelRoot = false;
|
1700
2108
|
|
1701
|
-
|
1702
|
-
|
1703
|
-
|
2109
|
+
function renderModel(request, task, parent, key, value) {
|
2110
|
+
var prevKeyPath = task.keyPath;
|
2111
|
+
var prevImplicitSlot = task.implicitSlot;
|
1704
2112
|
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
2113
|
+
try {
|
2114
|
+
return renderModelDestructive(request, task, parent, key, value);
|
2115
|
+
} catch (thrownValue) {
|
2116
|
+
var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
|
2117
|
+
// reasons, the rest of the Suspense implementation expects the thrown
|
2118
|
+
// value to be a thenable, because before `use` existed that was the
|
2119
|
+
// (unstable) API for suspending. This implementation detail can change
|
2120
|
+
// later, once we deprecate the old API in favor of `use`.
|
2121
|
+
getSuspendedThenable() : thrownValue; // If the suspended/errored value was an element or lazy it can be reduced
|
2122
|
+
// to a lazy reference, so that it doesn't error the parent.
|
2123
|
+
|
2124
|
+
var model = task.model;
|
2125
|
+
var wasReactNode = typeof model === 'object' && model !== null && (model.$$typeof === REACT_ELEMENT_TYPE || model.$$typeof === REACT_LAZY_TYPE);
|
2126
|
+
|
2127
|
+
if (typeof x === 'object' && x !== null) {
|
2128
|
+
// $FlowFixMe[method-unbinding]
|
2129
|
+
if (typeof x.then === 'function') {
|
2130
|
+
// Something suspended, we'll need to create a new task and resolve it later.
|
2131
|
+
var newTask = createTask(request, task.model, task.keyPath, task.implicitSlot, request.abortableTasks);
|
2132
|
+
var ping = newTask.ping;
|
2133
|
+
x.then(ping, ping);
|
2134
|
+
newTask.thenableState = getThenableStateAfterSuspending(); // Restore the context. We assume that this will be restored by the inner
|
2135
|
+
// functions in case nothing throws so we don't use "finally" here.
|
2136
|
+
|
2137
|
+
task.keyPath = prevKeyPath;
|
2138
|
+
task.implicitSlot = prevImplicitSlot;
|
2139
|
+
|
2140
|
+
if (wasReactNode) {
|
2141
|
+
return serializeLazyID(newTask.id);
|
1709
2142
|
}
|
1710
|
-
|
1711
|
-
|
2143
|
+
|
2144
|
+
return serializeByValueID(newTask.id);
|
1712
2145
|
}
|
1713
|
-
}
|
1714
|
-
|
2146
|
+
} // Restore the context. We assume that this will be restored by the inner
|
2147
|
+
// functions in case nothing throws so we don't use "finally" here.
|
1715
2148
|
|
1716
2149
|
|
1717
|
-
|
1718
|
-
|
1719
|
-
return '$';
|
1720
|
-
}
|
2150
|
+
task.keyPath = prevKeyPath;
|
2151
|
+
task.implicitSlot = prevImplicitSlot;
|
1721
2152
|
|
1722
|
-
|
1723
|
-
|
1724
|
-
|
1725
|
-
|
1726
|
-
|
1727
|
-
|
1728
|
-
|
1729
|
-
|
1730
|
-
|
2153
|
+
if (wasReactNode) {
|
2154
|
+
// Something errored. We'll still send everything we have up until this point.
|
2155
|
+
// We'll replace this element with a lazy reference that throws on the client
|
2156
|
+
// once it gets rendered.
|
2157
|
+
request.pendingChunks++;
|
2158
|
+
var errorId = request.nextChunkId++;
|
2159
|
+
var digest = logRecoverableError(request, x);
|
2160
|
+
emitErrorChunk(request, errorId, digest, x);
|
2161
|
+
return serializeLazyID(errorId);
|
2162
|
+
} // Something errored but it was not in a React Node. There's no need to serialize
|
2163
|
+
// it by value because it'll just error the whole parent row anyway so we can
|
2164
|
+
// just stop any siblings and error the whole parent row.
|
1731
2165
|
|
1732
2166
|
|
1733
|
-
|
1734
|
-
|
1735
|
-
|
1736
|
-
error('React elements are not allowed in ServerContext');
|
1737
|
-
}
|
1738
|
-
}
|
2167
|
+
throw x;
|
2168
|
+
}
|
2169
|
+
}
|
1739
2170
|
|
1740
|
-
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
|
2171
|
+
function renderModelDestructive(request, task, parent, parentPropertyName, value) {
|
2172
|
+
// Set the currently rendering model
|
2173
|
+
task.model = value; // Special Symbol, that's very common.
|
2174
|
+
|
2175
|
+
if (value === REACT_ELEMENT_TYPE) {
|
2176
|
+
return '$';
|
2177
|
+
}
|
2178
|
+
|
2179
|
+
if (value === null) {
|
2180
|
+
return null;
|
2181
|
+
}
|
1746
2182
|
|
1747
|
-
|
1748
|
-
|
2183
|
+
if (typeof value === 'object') {
|
2184
|
+
switch (value.$$typeof) {
|
2185
|
+
case REACT_ELEMENT_TYPE:
|
2186
|
+
{
|
2187
|
+
var _writtenObjects = request.writtenObjects;
|
2188
|
+
|
2189
|
+
var _existingId = _writtenObjects.get(value);
|
2190
|
+
|
2191
|
+
if (_existingId !== undefined) {
|
2192
|
+
if (modelRoot === value) {
|
2193
|
+
// This is the ID we're currently emitting so we need to write it
|
2194
|
+
// once but if we discover it again, we refer to it by id.
|
2195
|
+
modelRoot = null;
|
2196
|
+
} else if (_existingId === -1) {
|
2197
|
+
// Seen but not yet outlined.
|
2198
|
+
// TODO: If we throw here we can treat this as suspending which causes an outline
|
2199
|
+
// but that is able to reuse the same task if we're already in one but then that
|
2200
|
+
// will be a lazy future value rather than guaranteed to exist but maybe that's good.
|
2201
|
+
var newId = outlineModel(request, value);
|
2202
|
+
return serializeByValueID(newId);
|
2203
|
+
} else {
|
2204
|
+
// We've already emitted this as an outlined object, so we can refer to that by its
|
2205
|
+
// existing ID. TODO: We should use a lazy reference since, unlike plain objects,
|
2206
|
+
// elements might suspend so it might not have emitted yet even if we have the ID for
|
2207
|
+
// it. However, this creates an extra wrapper when it's not needed. We should really
|
2208
|
+
// detect whether this already was emitted and synchronously available. In that
|
2209
|
+
// case we can refer to it synchronously and only make it lazy otherwise.
|
2210
|
+
// We currently don't have a data structure that lets us see that though.
|
2211
|
+
return serializeByValueID(_existingId);
|
2212
|
+
}
|
2213
|
+
} else {
|
2214
|
+
// This is the first time we've seen this object. We may never see it again
|
2215
|
+
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
|
2216
|
+
_writtenObjects.set(value, -1);
|
1749
2217
|
}
|
1750
2218
|
|
1751
|
-
|
2219
|
+
var element = value;
|
2220
|
+
|
1752
2221
|
{
|
1753
|
-
var
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
2222
|
+
var debugInfo = value._debugInfo;
|
2223
|
+
|
2224
|
+
if (debugInfo) {
|
2225
|
+
// If this came from Flight, forward any debug info into this new row.
|
2226
|
+
if (debugID === null) {
|
2227
|
+
// We don't have a chunk to assign debug info. We need to outline this
|
2228
|
+
// component to assign it an ID.
|
2229
|
+
return outlineTask(request, task);
|
2230
|
+
} else {
|
2231
|
+
// Forward any debug info we have the first time we see it.
|
2232
|
+
forwardDebugInfo(request, debugID, debugInfo);
|
2233
|
+
}
|
2234
|
+
}
|
1757
2235
|
}
|
1758
|
-
}
|
1759
|
-
} catch (thrownValue) {
|
1760
|
-
var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
|
1761
|
-
// reasons, the rest of the Suspense implementation expects the thrown
|
1762
|
-
// value to be a thenable, because before `use` existed that was the
|
1763
|
-
// (unstable) API for suspending. This implementation detail can change
|
1764
|
-
// later, once we deprecate the old API in favor of `use`.
|
1765
|
-
getSuspendedThenable() : thrownValue; // $FlowFixMe[method-unbinding]
|
1766
|
-
|
1767
|
-
if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
|
1768
|
-
// Something suspended, we'll need to create a new task and resolve it later.
|
1769
|
-
request.pendingChunks++;
|
1770
|
-
var newTask = createTask(request, value, getActiveContext(), request.abortableTasks);
|
1771
|
-
var ping = newTask.ping;
|
1772
|
-
x.then(ping, ping);
|
1773
|
-
newTask.thenableState = getThenableStateAfterSuspending();
|
1774
|
-
return serializeLazyID(newTask.id);
|
1775
|
-
} else {
|
1776
|
-
// Something errored. We'll still send everything we have up until this point.
|
1777
|
-
// We'll replace this element with a lazy reference that throws on the client
|
1778
|
-
// once it gets rendered.
|
1779
|
-
request.pendingChunks++;
|
1780
|
-
var errorId = request.nextChunkId++;
|
1781
|
-
var digest = logRecoverableError(request, x);
|
1782
2236
|
|
2237
|
+
var props = element.props;
|
2238
|
+
var ref;
|
2239
|
+
|
2240
|
+
{
|
2241
|
+
ref = element.ref;
|
2242
|
+
} // Attempt to render the Server Component.
|
2243
|
+
|
2244
|
+
|
2245
|
+
return renderElement(request, task, element.type, // $FlowFixMe[incompatible-call] the key of an element is null | string
|
2246
|
+
element.key, ref, props);
|
2247
|
+
}
|
2248
|
+
|
2249
|
+
case REACT_LAZY_TYPE:
|
1783
2250
|
{
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
2251
|
+
// Reset the task's thenable state before continuing. If there was one, it was
|
2252
|
+
// from suspending the lazy before.
|
2253
|
+
task.thenableState = null;
|
2254
|
+
var lazy = value;
|
2255
|
+
var payload = lazy._payload;
|
2256
|
+
var init = lazy._init;
|
2257
|
+
var resolvedModel = init(payload);
|
2258
|
+
|
2259
|
+
{
|
2260
|
+
var _debugInfo = lazy._debugInfo;
|
2261
|
+
|
2262
|
+
if (_debugInfo) {
|
2263
|
+
// If this came from Flight, forward any debug info into this new row.
|
2264
|
+
if (debugID === null) {
|
2265
|
+
// We don't have a chunk to assign debug info. We need to outline this
|
2266
|
+
// component to assign it an ID.
|
2267
|
+
return outlineTask(request, task);
|
2268
|
+
} else {
|
2269
|
+
// Forward any debug info we have the first time we see it.
|
2270
|
+
// We do this after init so that we have received all the debug info
|
2271
|
+
// from the server by the time we emit it.
|
2272
|
+
forwardDebugInfo(request, debugID, _debugInfo);
|
2273
|
+
}
|
2274
|
+
}
|
2275
|
+
}
|
1787
2276
|
|
1788
|
-
|
2277
|
+
return renderModelDestructive(request, task, emptyRoot, '', resolvedModel);
|
1789
2278
|
}
|
2279
|
+
}
|
1790
2280
|
|
1791
|
-
|
1792
|
-
|
2281
|
+
if (isClientReference(value)) {
|
2282
|
+
return serializeClientReference(request, parent, parentPropertyName, value);
|
1793
2283
|
}
|
1794
|
-
}
|
1795
2284
|
|
1796
|
-
|
1797
|
-
|
1798
|
-
}
|
2285
|
+
var writtenObjects = request.writtenObjects;
|
2286
|
+
var existingId = writtenObjects.get(value); // $FlowFixMe[method-unbinding]
|
1799
2287
|
|
1800
|
-
|
1801
|
-
|
1802
|
-
|
1803
|
-
|
1804
|
-
|
2288
|
+
if (typeof value.then === 'function') {
|
2289
|
+
if (existingId !== undefined) {
|
2290
|
+
if (modelRoot === value) {
|
2291
|
+
// This is the ID we're currently emitting so we need to write it
|
2292
|
+
// once but if we discover it again, we refer to it by id.
|
2293
|
+
modelRoot = null;
|
2294
|
+
} else {
|
2295
|
+
// We've seen this promise before, so we can just refer to the same result.
|
2296
|
+
return serializePromiseID(existingId);
|
2297
|
+
}
|
2298
|
+
} // We assume that any object with a .then property is a "Thenable" type,
|
1805
2299
|
// or a Promise type. Either of which can be represented by a Promise.
|
1806
|
-
|
2300
|
+
|
2301
|
+
|
2302
|
+
var promiseId = serializeThenable(request, task, value);
|
2303
|
+
writtenObjects.set(value, promiseId);
|
1807
2304
|
return serializePromiseID(promiseId);
|
1808
|
-
}
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
|
1816
|
-
|
1817
|
-
|
2305
|
+
}
|
2306
|
+
|
2307
|
+
if (existingId !== undefined) {
|
2308
|
+
if (modelRoot === value) {
|
2309
|
+
// This is the ID we're currently emitting so we need to write it
|
2310
|
+
// once but if we discover it again, we refer to it by id.
|
2311
|
+
modelRoot = null;
|
2312
|
+
} else if (existingId === -1) {
|
2313
|
+
// Seen but not yet outlined.
|
2314
|
+
var _newId = outlineModel(request, value);
|
2315
|
+
|
2316
|
+
return serializeByValueID(_newId);
|
2317
|
+
} else {
|
2318
|
+
// We've already emitted this as an outlined object, so we can
|
2319
|
+
// just refer to that by its existing ID.
|
2320
|
+
return serializeByValueID(existingId);
|
1818
2321
|
}
|
2322
|
+
} else {
|
2323
|
+
// This is the first time we've seen this object. We may never see it again
|
2324
|
+
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
|
2325
|
+
writtenObjects.set(value, -1);
|
2326
|
+
}
|
1819
2327
|
|
1820
|
-
|
1821
|
-
|
1822
|
-
|
2328
|
+
if (isArray(value)) {
|
2329
|
+
return renderFragment(request, task, value);
|
2330
|
+
}
|
1823
2331
|
|
1824
|
-
|
1825
|
-
|
1826
|
-
|
1827
|
-
}
|
2332
|
+
if (value instanceof Map) {
|
2333
|
+
return serializeMap(request, value);
|
2334
|
+
}
|
1828
2335
|
|
1829
|
-
|
2336
|
+
if (value instanceof Set) {
|
2337
|
+
return serializeSet(request, value);
|
1830
2338
|
}
|
1831
2339
|
|
1832
|
-
|
1833
|
-
var iteratorFn = getIteratorFn(value);
|
2340
|
+
var iteratorFn = getIteratorFn(value);
|
1834
2341
|
|
1835
|
-
|
1836
|
-
|
1837
|
-
|
2342
|
+
if (iteratorFn) {
|
2343
|
+
return renderFragment(request, task, Array.from(value));
|
2344
|
+
} // Verify that this is a simple plain object.
|
2345
|
+
|
2346
|
+
|
2347
|
+
var proto = getPrototypeOf(value);
|
2348
|
+
|
2349
|
+
if (proto !== ObjectPrototype && (proto === null || getPrototypeOf(proto) !== null)) {
|
2350
|
+
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.');
|
1838
2351
|
}
|
1839
2352
|
|
1840
2353
|
{
|
1841
|
-
if (value !==
|
1842
|
-
|
1843
|
-
|
1844
|
-
|
1845
|
-
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
if (symbols.length > 0) {
|
1851
|
-
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));
|
1852
|
-
}
|
2354
|
+
if (objectName(value) !== 'Object') {
|
2355
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent, parentPropertyName));
|
2356
|
+
} else if (!isSimpleObject(value)) {
|
2357
|
+
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));
|
2358
|
+
} else if (Object.getOwnPropertySymbols) {
|
2359
|
+
var symbols = Object.getOwnPropertySymbols(value);
|
2360
|
+
|
2361
|
+
if (symbols.length > 0) {
|
2362
|
+
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));
|
1853
2363
|
}
|
1854
2364
|
}
|
1855
2365
|
} // $FlowFixMe[incompatible-return]
|
@@ -1859,17 +2369,25 @@
|
|
1859
2369
|
}
|
1860
2370
|
|
1861
2371
|
if (typeof value === 'string') {
|
1862
|
-
|
2372
|
+
|
2373
|
+
|
1863
2374
|
if (value[value.length - 1] === 'Z') {
|
1864
2375
|
// Possibly a Date, whose toJSON automatically calls toISOString
|
1865
2376
|
// $FlowFixMe[incompatible-use]
|
1866
|
-
var
|
2377
|
+
var originalValue = parent[parentPropertyName];
|
1867
2378
|
|
1868
|
-
if (
|
2379
|
+
if (originalValue instanceof Date) {
|
1869
2380
|
return serializeDateFromDateJSON(value);
|
1870
2381
|
}
|
1871
2382
|
}
|
1872
2383
|
|
2384
|
+
if (value.length >= 1024) {
|
2385
|
+
// For large strings, we encode them outside the JSON payload so that we
|
2386
|
+
// don't have to double encode and double parse the strings. This can also
|
2387
|
+
// be more compact in case the string has a lot of escaped characters.
|
2388
|
+
return serializeLargeTextString(request, value);
|
2389
|
+
}
|
2390
|
+
|
1873
2391
|
return escapeStringValue(value);
|
1874
2392
|
}
|
1875
2393
|
|
@@ -1887,26 +2405,34 @@
|
|
1887
2405
|
|
1888
2406
|
if (typeof value === 'function') {
|
1889
2407
|
if (isClientReference(value)) {
|
1890
|
-
return serializeClientReference(request, parent,
|
2408
|
+
return serializeClientReference(request, parent, parentPropertyName, value);
|
1891
2409
|
}
|
1892
2410
|
|
1893
2411
|
if (isServerReference(value)) {
|
1894
|
-
return serializeServerReference(request,
|
2412
|
+
return serializeServerReference(request, value);
|
2413
|
+
}
|
2414
|
+
|
2415
|
+
if (isTemporaryReference(value)) {
|
2416
|
+
return serializeTemporaryReference(request, value);
|
1895
2417
|
}
|
1896
2418
|
|
1897
|
-
if (/^on[A-Z]/.test(
|
1898
|
-
throw new Error('Event handlers cannot be passed to Client Component props.' + describeObjectForErrorMessage(parent,
|
2419
|
+
if (/^on[A-Z]/.test(parentPropertyName)) {
|
2420
|
+
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.');
|
2421
|
+
} else if ((jsxChildrenParents.has(parent) || jsxPropsParents.has(parent) && parentPropertyName === 'children')) {
|
2422
|
+
var componentName = value.displayName || value.name || 'Component';
|
2423
|
+
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));
|
1899
2424
|
} else {
|
1900
|
-
throw new Error('Functions cannot be passed directly to Client Components ' + 'unless you explicitly expose it by marking it with "use server".' + describeObjectForErrorMessage(parent,
|
2425
|
+
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));
|
1901
2426
|
}
|
1902
2427
|
}
|
1903
2428
|
|
1904
2429
|
if (typeof value === 'symbol') {
|
1905
2430
|
var writtenSymbols = request.writtenSymbols;
|
1906
|
-
var existingId = writtenSymbols.get(value);
|
1907
2431
|
|
1908
|
-
|
1909
|
-
|
2432
|
+
var _existingId2 = writtenSymbols.get(value);
|
2433
|
+
|
2434
|
+
if (_existingId2 !== undefined) {
|
2435
|
+
return serializeByValueID(_existingId2);
|
1910
2436
|
} // $FlowFixMe[incompatible-type] `description` might be undefined
|
1911
2437
|
|
1912
2438
|
|
@@ -1914,7 +2440,7 @@
|
|
1914
2440
|
|
1915
2441
|
if (Symbol.for(name) !== value) {
|
1916
2442
|
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
|
1917
|
-
value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent,
|
2443
|
+
value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent, parentPropertyName));
|
1918
2444
|
}
|
1919
2445
|
|
1920
2446
|
request.pendingChunks++;
|
@@ -1925,15 +2451,42 @@
|
|
1925
2451
|
}
|
1926
2452
|
|
1927
2453
|
if (typeof value === 'bigint') {
|
2454
|
+
|
1928
2455
|
return serializeBigInt(value);
|
1929
2456
|
}
|
1930
2457
|
|
1931
|
-
throw new Error("Type " + typeof value + " is not supported in Client Component props." + describeObjectForErrorMessage(parent,
|
2458
|
+
throw new Error("Type " + typeof value + " is not supported in Client Component props." + describeObjectForErrorMessage(parent, parentPropertyName));
|
2459
|
+
}
|
2460
|
+
|
2461
|
+
function logPostpone(request, reason) {
|
2462
|
+
var prevRequest = currentRequest;
|
2463
|
+
currentRequest = null;
|
2464
|
+
|
2465
|
+
try {
|
2466
|
+
var onPostpone = request.onPostpone;
|
2467
|
+
|
2468
|
+
if (supportsRequestStorage) ; else {
|
2469
|
+
onPostpone(reason);
|
2470
|
+
}
|
2471
|
+
} finally {
|
2472
|
+
currentRequest = prevRequest;
|
2473
|
+
}
|
1932
2474
|
}
|
1933
2475
|
|
1934
2476
|
function logRecoverableError(request, error) {
|
1935
|
-
var
|
1936
|
-
|
2477
|
+
var prevRequest = currentRequest;
|
2478
|
+
currentRequest = null;
|
2479
|
+
var errorDigest;
|
2480
|
+
|
2481
|
+
try {
|
2482
|
+
var onError = request.onError;
|
2483
|
+
|
2484
|
+
if (supportsRequestStorage) ; else {
|
2485
|
+
errorDigest = onError(error);
|
2486
|
+
}
|
2487
|
+
} finally {
|
2488
|
+
currentRequest = prevRequest;
|
2489
|
+
}
|
1937
2490
|
|
1938
2491
|
if (errorDigest != null && typeof errorDigest !== 'string') {
|
1939
2492
|
// eslint-disable-next-line react-internal/prod-error-codes
|
@@ -1943,7 +2496,45 @@
|
|
1943
2496
|
return errorDigest || '';
|
1944
2497
|
}
|
1945
2498
|
|
1946
|
-
function
|
2499
|
+
function fatalError(request, error) {
|
2500
|
+
|
2501
|
+
|
2502
|
+
if (request.destination !== null) {
|
2503
|
+
request.status = CLOSED;
|
2504
|
+
closeWithError(request.destination, error);
|
2505
|
+
} else {
|
2506
|
+
request.status = CLOSING;
|
2507
|
+
request.fatalError = error;
|
2508
|
+
}
|
2509
|
+
}
|
2510
|
+
|
2511
|
+
function emitPostponeChunk(request, id, postponeInstance) {
|
2512
|
+
var row;
|
2513
|
+
|
2514
|
+
{
|
2515
|
+
var reason = '';
|
2516
|
+
var stack = '';
|
2517
|
+
|
2518
|
+
try {
|
2519
|
+
// eslint-disable-next-line react-internal/safe-string-coercion
|
2520
|
+
reason = String(postponeInstance.message); // eslint-disable-next-line react-internal/safe-string-coercion
|
2521
|
+
|
2522
|
+
stack = String(postponeInstance.stack);
|
2523
|
+
} catch (x) {}
|
2524
|
+
|
2525
|
+
row = serializeRowHeader('P', id) + stringify({
|
2526
|
+
reason: reason,
|
2527
|
+
stack: stack
|
2528
|
+
}) + '\n';
|
2529
|
+
}
|
2530
|
+
|
2531
|
+
var processedChunk = stringToChunk(row);
|
2532
|
+
request.completedErrorChunks.push(processedChunk);
|
2533
|
+
}
|
2534
|
+
|
2535
|
+
function emitErrorChunk(request, id, digest, error) {
|
2536
|
+
var errorInfo;
|
2537
|
+
|
1947
2538
|
{
|
1948
2539
|
var message;
|
1949
2540
|
var stack = '';
|
@@ -1954,101 +2545,123 @@
|
|
1954
2545
|
message = String(error.message); // eslint-disable-next-line react-internal/safe-string-coercion
|
1955
2546
|
|
1956
2547
|
stack = String(error.stack);
|
2548
|
+
} else if (typeof error === 'object' && error !== null) {
|
2549
|
+
message = describeObjectForErrorMessage(error);
|
1957
2550
|
} else {
|
1958
|
-
|
2551
|
+
// eslint-disable-next-line react-internal/safe-string-coercion
|
2552
|
+
message = String(error);
|
1959
2553
|
}
|
1960
2554
|
} catch (x) {
|
1961
2555
|
message = 'An error occurred but serializing the error message failed.';
|
1962
2556
|
}
|
1963
2557
|
|
1964
|
-
|
2558
|
+
errorInfo = {
|
2559
|
+
digest: digest,
|
1965
2560
|
message: message,
|
1966
2561
|
stack: stack
|
1967
2562
|
};
|
1968
2563
|
}
|
1969
|
-
}
|
1970
|
-
|
1971
|
-
function fatalError(request, error) {
|
1972
|
-
// This is called outside error handling code such as if an error happens in React internals.
|
1973
|
-
if (request.destination !== null) {
|
1974
|
-
request.status = CLOSED;
|
1975
|
-
closeWithError(request.destination, error);
|
1976
|
-
} else {
|
1977
|
-
request.status = CLOSING;
|
1978
|
-
request.fatalError = error;
|
1979
|
-
}
|
1980
|
-
}
|
1981
|
-
|
1982
|
-
function emitErrorChunkProd(request, id, digest) {
|
1983
|
-
var processedChunk = processErrorChunkProd();
|
1984
|
-
request.completedErrorChunks.push(processedChunk);
|
1985
|
-
}
|
1986
2564
|
|
1987
|
-
|
1988
|
-
var processedChunk =
|
2565
|
+
var row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n';
|
2566
|
+
var processedChunk = stringToChunk(row);
|
1989
2567
|
request.completedErrorChunks.push(processedChunk);
|
1990
2568
|
}
|
1991
2569
|
|
1992
2570
|
function emitImportChunk(request, id, clientReferenceMetadata) {
|
1993
|
-
|
2571
|
+
// $FlowFixMe[incompatible-type] stringify can return null
|
2572
|
+
var json = stringify(clientReferenceMetadata);
|
2573
|
+
var row = serializeRowHeader('I', id) + json + '\n';
|
2574
|
+
var processedChunk = stringToChunk(row);
|
1994
2575
|
request.completedImportChunks.push(processedChunk);
|
1995
2576
|
}
|
1996
2577
|
|
1997
2578
|
function emitHintChunk(request, code, model) {
|
1998
|
-
var
|
2579
|
+
var json = stringify(model);
|
2580
|
+
var id = request.nextChunkId++;
|
2581
|
+
var row = serializeRowHeader('H' + code, id) + json + '\n';
|
2582
|
+
var processedChunk = stringToChunk(row);
|
1999
2583
|
request.completedHintChunks.push(processedChunk);
|
2000
2584
|
}
|
2001
2585
|
|
2002
2586
|
function emitSymbolChunk(request, id, name) {
|
2003
2587
|
var symbolReference = serializeSymbolReference(name);
|
2004
|
-
var processedChunk =
|
2588
|
+
var processedChunk = encodeReferenceChunk(request, id, symbolReference);
|
2005
2589
|
request.completedImportChunks.push(processedChunk);
|
2006
2590
|
}
|
2007
2591
|
|
2008
|
-
function
|
2009
|
-
var
|
2010
|
-
var processedChunk =
|
2011
|
-
request.
|
2592
|
+
function emitModelChunk(request, id, json) {
|
2593
|
+
var row = id.toString(16) + ':' + json + '\n';
|
2594
|
+
var processedChunk = stringToChunk(row);
|
2595
|
+
request.completedRegularChunks.push(processedChunk);
|
2596
|
+
}
|
2597
|
+
|
2598
|
+
function emitDebugChunk(request, id, debugInfo) {
|
2599
|
+
|
2600
|
+
|
2601
|
+
var json = stringify(debugInfo);
|
2602
|
+
var row = serializeRowHeader('D', id) + json + '\n';
|
2603
|
+
var processedChunk = stringToChunk(row);
|
2604
|
+
request.completedRegularChunks.push(processedChunk);
|
2605
|
+
}
|
2606
|
+
|
2607
|
+
function forwardDebugInfo(request, id, debugInfo) {
|
2608
|
+
for (var i = 0; i < debugInfo.length; i++) {
|
2609
|
+
request.pendingChunks++;
|
2610
|
+
emitDebugChunk(request, id, debugInfo[i]);
|
2611
|
+
}
|
2012
2612
|
}
|
2013
2613
|
|
2614
|
+
var emptyRoot = {};
|
2615
|
+
|
2014
2616
|
function retryTask(request, task) {
|
2015
2617
|
if (task.status !== PENDING$1) {
|
2016
2618
|
// We completed this by other means before we had a chance to retry it.
|
2017
2619
|
return;
|
2018
2620
|
}
|
2019
2621
|
|
2020
|
-
|
2622
|
+
var prevDebugID = debugID;
|
2021
2623
|
|
2022
2624
|
try {
|
2023
|
-
|
2024
|
-
|
2025
|
-
|
2026
|
-
|
2027
|
-
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
|
2032
|
-
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2038
|
-
|
2039
|
-
//
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2043
|
-
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
|
2625
|
+
// Track the root so we know that we have to emit this object even though it
|
2626
|
+
// already has an ID. This is needed because we might see this object twice
|
2627
|
+
// in the same toJSON if it is cyclic.
|
2628
|
+
modelRoot = task.model;
|
2629
|
+
|
2630
|
+
if (true) {
|
2631
|
+
// Track the ID of the current task so we can assign debug info to this id.
|
2632
|
+
debugID = task.id;
|
2633
|
+
} // We call the destructive form that mutates this task. That way if something
|
2634
|
+
// suspends again, we can reuse the same task instead of spawning a new one.
|
2635
|
+
|
2636
|
+
|
2637
|
+
var resolvedModel = renderModelDestructive(request, task, emptyRoot, '', task.model);
|
2638
|
+
|
2639
|
+
if (true) {
|
2640
|
+
// We're now past rendering this task and future renders will spawn new tasks for their
|
2641
|
+
// debug info.
|
2642
|
+
debugID = null;
|
2643
|
+
} // Track the root again for the resolved object.
|
2644
|
+
|
2645
|
+
|
2646
|
+
modelRoot = resolvedModel; // The keyPath resets at any terminal child node.
|
2647
|
+
|
2648
|
+
task.keyPath = null;
|
2649
|
+
task.implicitSlot = false;
|
2650
|
+
var json;
|
2651
|
+
|
2652
|
+
if (typeof resolvedModel === 'object' && resolvedModel !== null) {
|
2653
|
+
// Object might contain unresolved values like additional elements.
|
2654
|
+
// This is simulating what the JSON loop would do if this was part of it.
|
2655
|
+
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
2656
|
+
json = stringify(resolvedModel, task.toJSON);
|
2657
|
+
} else {
|
2658
|
+
// If the value is a string, it means it's a terminal value and we already escaped it
|
2659
|
+
// We don't need to escape it again so it's not passed the toJSON replacer.
|
2660
|
+
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
2661
|
+
json = stringify(resolvedModel);
|
2048
2662
|
}
|
2049
2663
|
|
2050
|
-
|
2051
|
-
request.completedJSONChunks.push(processedChunk);
|
2664
|
+
emitModelChunk(request, task.id, json);
|
2052
2665
|
request.abortableTasks.delete(task);
|
2053
2666
|
task.status = COMPLETED;
|
2054
2667
|
} catch (thrownValue) {
|
@@ -2057,27 +2670,27 @@
|
|
2057
2670
|
// value to be a thenable, because before `use` existed that was the
|
2058
2671
|
// (unstable) API for suspending. This implementation detail can change
|
2059
2672
|
// later, once we deprecate the old API in favor of `use`.
|
2060
|
-
getSuspendedThenable() : thrownValue;
|
2061
|
-
|
2062
|
-
if (typeof x === 'object' && x !== null && typeof x.then === 'function') {
|
2063
|
-
// Something suspended again, let's pick it back up later.
|
2064
|
-
var ping = task.ping;
|
2065
|
-
x.then(ping, ping);
|
2066
|
-
task.thenableState = getThenableStateAfterSuspending();
|
2067
|
-
return;
|
2068
|
-
} else {
|
2069
|
-
request.abortableTasks.delete(task);
|
2070
|
-
task.status = ERRORED$1;
|
2071
|
-
var digest = logRecoverableError(request, x);
|
2072
|
-
|
2073
|
-
{
|
2074
|
-
var _getErrorMessageAndSt5 = getErrorMessageAndStackDev(x),
|
2075
|
-
message = _getErrorMessageAndSt5.message,
|
2076
|
-
stack = _getErrorMessageAndSt5.stack;
|
2673
|
+
getSuspendedThenable() : thrownValue;
|
2077
2674
|
|
2078
|
-
|
2675
|
+
if (typeof x === 'object' && x !== null) {
|
2676
|
+
// $FlowFixMe[method-unbinding]
|
2677
|
+
if (typeof x.then === 'function') {
|
2678
|
+
// Something suspended again, let's pick it back up later.
|
2679
|
+
var ping = task.ping;
|
2680
|
+
x.then(ping, ping);
|
2681
|
+
task.thenableState = getThenableStateAfterSuspending();
|
2682
|
+
return;
|
2079
2683
|
}
|
2080
2684
|
}
|
2685
|
+
|
2686
|
+
request.abortableTasks.delete(task);
|
2687
|
+
task.status = ERRORED$1;
|
2688
|
+
var digest = logRecoverableError(request, x);
|
2689
|
+
emitErrorChunk(request, task.id, digest, x);
|
2690
|
+
} finally {
|
2691
|
+
{
|
2692
|
+
debugID = prevDebugID;
|
2693
|
+
}
|
2081
2694
|
}
|
2082
2695
|
}
|
2083
2696
|
|
@@ -2115,7 +2728,7 @@
|
|
2115
2728
|
// has a single value referencing the error.
|
2116
2729
|
|
2117
2730
|
var ref = serializeByValueID(errorId);
|
2118
|
-
var processedChunk =
|
2731
|
+
var processedChunk = encodeReferenceChunk(request, task.id, ref);
|
2119
2732
|
request.completedErrorChunks.push(processedChunk);
|
2120
2733
|
}
|
2121
2734
|
|
@@ -2159,12 +2772,12 @@
|
|
2159
2772
|
|
2160
2773
|
hintChunks.splice(0, i); // Next comes model data.
|
2161
2774
|
|
2162
|
-
var
|
2775
|
+
var regularChunks = request.completedRegularChunks;
|
2163
2776
|
i = 0;
|
2164
2777
|
|
2165
|
-
for (; i <
|
2778
|
+
for (; i < regularChunks.length; i++) {
|
2166
2779
|
request.pendingChunks--;
|
2167
|
-
var _chunk2 =
|
2780
|
+
var _chunk2 = regularChunks[i];
|
2168
2781
|
|
2169
2782
|
var _keepWriting2 = writeChunkAndReturn(destination, _chunk2);
|
2170
2783
|
|
@@ -2175,7 +2788,7 @@
|
|
2175
2788
|
}
|
2176
2789
|
}
|
2177
2790
|
|
2178
|
-
|
2791
|
+
regularChunks.splice(0, i); // Finally, errors are sent. The idea is that it's ok to delay
|
2179
2792
|
// any error messages and prioritize display of other parts of
|
2180
2793
|
// the page.
|
2181
2794
|
|
@@ -2202,7 +2815,7 @@
|
|
2202
2815
|
}
|
2203
2816
|
|
2204
2817
|
if (request.pendingChunks === 0) {
|
2205
|
-
|
2818
|
+
|
2206
2819
|
close$1(destination);
|
2207
2820
|
}
|
2208
2821
|
}
|
@@ -2254,6 +2867,9 @@
|
|
2254
2867
|
logRecoverableError(request, error);
|
2255
2868
|
fatalError(request, error);
|
2256
2869
|
}
|
2870
|
+
}
|
2871
|
+
function stopFlowing(request) {
|
2872
|
+
request.destination = null;
|
2257
2873
|
} // This is called to early terminate a request. It creates an error at all pending tasks.
|
2258
2874
|
|
2259
2875
|
function abort(request, reason) {
|
@@ -2263,17 +2879,13 @@
|
|
2263
2879
|
if (abortableTasks.size > 0) {
|
2264
2880
|
// We have tasks to abort. We'll emit one error row and then emit a reference
|
2265
2881
|
// to that row from every row that's still remaining.
|
2266
|
-
var error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : reason;
|
2267
|
-
var digest = logRecoverableError(request, error);
|
2268
2882
|
request.pendingChunks++;
|
2269
2883
|
var errorId = request.nextChunkId++;
|
2270
2884
|
|
2271
|
-
if (
|
2272
|
-
var
|
2273
|
-
|
2274
|
-
|
2275
|
-
|
2276
|
-
emitErrorChunkDev(request, errorId, digest, message, stack);
|
2885
|
+
var postponeInstance; if (enablePostpone && typeof reason === 'object' && reason !== null && reason.$$typeof === REACT_POSTPONE_TYPE) ; else {
|
2886
|
+
var error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : reason;
|
2887
|
+
var digest = logRecoverableError(request, error);
|
2888
|
+
emitErrorChunk(request, errorId, digest, error);
|
2277
2889
|
}
|
2278
2890
|
|
2279
2891
|
abortableTasks.forEach(function (task) {
|
@@ -2291,28 +2903,20 @@
|
|
2291
2903
|
}
|
2292
2904
|
}
|
2293
2905
|
|
2294
|
-
|
2295
|
-
|
2296
|
-
|
2297
|
-
|
2298
|
-
|
2299
|
-
|
2300
|
-
|
2301
|
-
|
2302
|
-
|
2303
|
-
var context = getOrCreateServerContext(name);
|
2304
|
-
pushProvider(context, value);
|
2305
|
-
}
|
2306
|
-
|
2307
|
-
var importedContext = getActiveContext();
|
2308
|
-
switchContext(prevContext);
|
2309
|
-
return importedContext;
|
2310
|
-
}
|
2906
|
+
// This is the parsed shape of the wire format which is why it is
|
2907
|
+
// condensed to only the essentialy information
|
2908
|
+
var ID = 0;
|
2909
|
+
var CHUNKS = 1;
|
2910
|
+
var NAME = 2; // export const ASYNC = 3;
|
2911
|
+
// This logic is correct because currently only include the 4th tuple member
|
2912
|
+
// when the module is async. If that changes we will need to actually assert
|
2913
|
+
// the value is true. We don't index into the 4th slot because flow does not
|
2914
|
+
// like the potential out of bounds access
|
2311
2915
|
|
2312
|
-
|
2916
|
+
function isAsyncImport(metadata) {
|
2917
|
+
return metadata.length === 4;
|
2313
2918
|
}
|
2314
2919
|
|
2315
|
-
// eslint-disable-next-line no-unused-vars
|
2316
2920
|
function resolveServerReference(bundlerConfig, id) {
|
2317
2921
|
var name = '';
|
2318
2922
|
var resolvedModuleData = bundlerConfig[id];
|
@@ -2338,19 +2942,38 @@
|
|
2338
2942
|
} // TODO: This needs to return async: true if it's an async module.
|
2339
2943
|
|
2340
2944
|
|
2341
|
-
return
|
2342
|
-
id: resolvedModuleData.id,
|
2343
|
-
chunks: resolvedModuleData.chunks,
|
2344
|
-
name: name,
|
2345
|
-
async: false
|
2346
|
-
};
|
2945
|
+
return [resolvedModuleData.id, resolvedModuleData.chunks, name];
|
2347
2946
|
} // The chunk cache contains all the chunks we've preloaded so far.
|
2348
2947
|
// If they're still pending they're a thenable. This map also exists
|
2349
2948
|
// in Webpack but unfortunately it's not exposed so we have to
|
2350
2949
|
// replicate it in user space. null means that it has already loaded.
|
2351
2950
|
|
2352
2951
|
var chunkCache = new Map();
|
2353
|
-
|
2952
|
+
|
2953
|
+
function requireAsyncModule(id) {
|
2954
|
+
// We've already loaded all the chunks. We can require the module.
|
2955
|
+
var promise = __webpack_require__(id);
|
2956
|
+
|
2957
|
+
if (typeof promise.then !== 'function') {
|
2958
|
+
// This wasn't a promise after all.
|
2959
|
+
return null;
|
2960
|
+
} else if (promise.status === 'fulfilled') {
|
2961
|
+
// This module was already resolved earlier.
|
2962
|
+
return null;
|
2963
|
+
} else {
|
2964
|
+
// Instrument the Promise to stash the result.
|
2965
|
+
promise.then(function (value) {
|
2966
|
+
var fulfilledThenable = promise;
|
2967
|
+
fulfilledThenable.status = 'fulfilled';
|
2968
|
+
fulfilledThenable.value = value;
|
2969
|
+
}, function (reason) {
|
2970
|
+
var rejectedThenable = promise;
|
2971
|
+
rejectedThenable.status = 'rejected';
|
2972
|
+
rejectedThenable.reason = reason;
|
2973
|
+
});
|
2974
|
+
return promise;
|
2975
|
+
}
|
2976
|
+
}
|
2354
2977
|
|
2355
2978
|
function ignoreReject() {// We rely on rejected promises to be handled by another listener.
|
2356
2979
|
} // Start preloading the modules since we might need them soon.
|
@@ -2358,16 +2981,17 @@
|
|
2358
2981
|
|
2359
2982
|
|
2360
2983
|
function preloadModule(metadata) {
|
2361
|
-
var chunks = metadata
|
2984
|
+
var chunks = metadata[CHUNKS];
|
2362
2985
|
var promises = [];
|
2986
|
+
var i = 0;
|
2363
2987
|
|
2364
|
-
|
2365
|
-
var chunkId = chunks[i];
|
2988
|
+
while (i < chunks.length) {
|
2989
|
+
var chunkId = chunks[i++];
|
2990
|
+
var chunkFilename = chunks[i++];
|
2366
2991
|
var entry = chunkCache.get(chunkId);
|
2367
2992
|
|
2368
2993
|
if (entry === undefined) {
|
2369
|
-
var thenable =
|
2370
|
-
|
2994
|
+
var thenable = loadChunk(chunkId, chunkFilename);
|
2371
2995
|
promises.push(thenable); // $FlowFixMe[method-unbinding]
|
2372
2996
|
|
2373
2997
|
var resolve = chunkCache.set.bind(chunkCache, chunkId, null);
|
@@ -2378,30 +3002,13 @@
|
|
2378
3002
|
}
|
2379
3003
|
}
|
2380
3004
|
|
2381
|
-
if (metadata
|
2382
|
-
|
2383
|
-
|
2384
|
-
if (existingPromise) {
|
2385
|
-
if (existingPromise.status === 'fulfilled') {
|
2386
|
-
return null;
|
2387
|
-
}
|
2388
|
-
|
2389
|
-
return existingPromise;
|
3005
|
+
if (isAsyncImport(metadata)) {
|
3006
|
+
if (promises.length === 0) {
|
3007
|
+
return requireAsyncModule(metadata[ID]);
|
2390
3008
|
} else {
|
2391
|
-
|
2392
|
-
return
|
3009
|
+
return Promise.all(promises).then(function () {
|
3010
|
+
return requireAsyncModule(metadata[ID]);
|
2393
3011
|
});
|
2394
|
-
modulePromise.then(function (value) {
|
2395
|
-
var fulfilledThenable = modulePromise;
|
2396
|
-
fulfilledThenable.status = 'fulfilled';
|
2397
|
-
fulfilledThenable.value = value;
|
2398
|
-
}, function (reason) {
|
2399
|
-
var rejectedThenable = modulePromise;
|
2400
|
-
rejectedThenable.status = 'rejected';
|
2401
|
-
rejectedThenable.reason = reason;
|
2402
|
-
});
|
2403
|
-
asyncModuleCache.set(metadata.id, modulePromise);
|
2404
|
-
return modulePromise;
|
2405
3012
|
}
|
2406
3013
|
} else if (promises.length > 0) {
|
2407
3014
|
return Promise.all(promises);
|
@@ -2412,35 +3019,53 @@
|
|
2412
3019
|
// Increase priority if necessary.
|
2413
3020
|
|
2414
3021
|
function requireModule(metadata) {
|
2415
|
-
var moduleExports;
|
2416
|
-
|
2417
|
-
if (metadata.async) {
|
2418
|
-
// We assume that preloadModule has been called before, which
|
2419
|
-
// should have added something to the module cache.
|
2420
|
-
var promise = asyncModuleCache.get(metadata.id);
|
3022
|
+
var moduleExports = __webpack_require__(metadata[ID]);
|
2421
3023
|
|
2422
|
-
|
2423
|
-
|
3024
|
+
if (isAsyncImport(metadata)) {
|
3025
|
+
if (typeof moduleExports.then !== 'function') ; else if (moduleExports.status === 'fulfilled') {
|
3026
|
+
// This Promise should've been instrumented by preloadModule.
|
3027
|
+
moduleExports = moduleExports.value;
|
2424
3028
|
} else {
|
2425
|
-
throw
|
3029
|
+
throw moduleExports.reason;
|
2426
3030
|
}
|
2427
|
-
} else {
|
2428
|
-
moduleExports = __webpack_require__(metadata.id);
|
2429
3031
|
}
|
2430
3032
|
|
2431
|
-
if (metadata
|
3033
|
+
if (metadata[NAME] === '*') {
|
2432
3034
|
// This is a placeholder value that represents that the caller imported this
|
2433
3035
|
// as a CommonJS module as is.
|
2434
3036
|
return moduleExports;
|
2435
3037
|
}
|
2436
3038
|
|
2437
|
-
if (metadata
|
3039
|
+
if (metadata[NAME] === '') {
|
2438
3040
|
// This is a placeholder value that represents that the caller accessed the
|
2439
3041
|
// default property of this if it was an ESM interop module.
|
2440
3042
|
return moduleExports.__esModule ? moduleExports.default : moduleExports;
|
2441
3043
|
}
|
2442
3044
|
|
2443
|
-
return moduleExports[metadata
|
3045
|
+
return moduleExports[metadata[NAME]];
|
3046
|
+
}
|
3047
|
+
|
3048
|
+
var chunkMap = new Map();
|
3049
|
+
/**
|
3050
|
+
* We patch the chunk filename function in webpack to insert our own resolution
|
3051
|
+
* of chunks that come from Flight and may not be known to the webpack runtime
|
3052
|
+
*/
|
3053
|
+
|
3054
|
+
var webpackGetChunkFilename = __webpack_require__.u;
|
3055
|
+
|
3056
|
+
__webpack_require__.u = function (chunkId) {
|
3057
|
+
var flightChunk = chunkMap.get(chunkId);
|
3058
|
+
|
3059
|
+
if (flightChunk !== undefined) {
|
3060
|
+
return flightChunk;
|
3061
|
+
}
|
3062
|
+
|
3063
|
+
return webpackGetChunkFilename(chunkId);
|
3064
|
+
};
|
3065
|
+
|
3066
|
+
function loadChunk(chunkId, filename) {
|
3067
|
+
chunkMap.set(chunkId, filename);
|
3068
|
+
return __webpack_chunk_load__(chunkId);
|
2444
3069
|
}
|
2445
3070
|
|
2446
3071
|
// The server acts as a Client of itself when resolving Server References.
|
@@ -2540,11 +3165,11 @@
|
|
2540
3165
|
return new Chunk(RESOLVED_MODEL, value, null, response);
|
2541
3166
|
}
|
2542
3167
|
|
2543
|
-
function bindArgs(fn, args) {
|
3168
|
+
function bindArgs$1(fn, args) {
|
2544
3169
|
return fn.bind.apply(fn, [null].concat(args));
|
2545
3170
|
}
|
2546
3171
|
|
2547
|
-
function loadServerReference(response, id, bound, parentChunk, parentObject, key) {
|
3172
|
+
function loadServerReference$1(response, id, bound, parentChunk, parentObject, key) {
|
2548
3173
|
var serverReference = resolveServerReference(response._bundlerConfig, id); // We expect most servers to not really need this because you'd just have all
|
2549
3174
|
// the relevant modules already loaded but it allows for lazy loading of code
|
2550
3175
|
// if needed.
|
@@ -2555,7 +3180,7 @@
|
|
2555
3180
|
if (bound) {
|
2556
3181
|
promise = Promise.all([bound, preloadPromise]).then(function (_ref) {
|
2557
3182
|
var args = _ref[0];
|
2558
|
-
return bindArgs(requireModule(serverReference), args);
|
3183
|
+
return bindArgs$1(requireModule(serverReference), args);
|
2559
3184
|
});
|
2560
3185
|
} else {
|
2561
3186
|
if (preloadPromise) {
|
@@ -2685,6 +3310,21 @@
|
|
2685
3310
|
};
|
2686
3311
|
}
|
2687
3312
|
|
3313
|
+
function getOutlinedModel(response, id) {
|
3314
|
+
var chunk = getChunk(response, id);
|
3315
|
+
|
3316
|
+
if (chunk.status === RESOLVED_MODEL) {
|
3317
|
+
initializeModelChunk(chunk);
|
3318
|
+
}
|
3319
|
+
|
3320
|
+
if (chunk.status !== INITIALIZED) {
|
3321
|
+
// We know that this is emitted earlier so otherwise it's an error.
|
3322
|
+
throw chunk.reason;
|
3323
|
+
}
|
3324
|
+
|
3325
|
+
return chunk.value;
|
3326
|
+
}
|
3327
|
+
|
2688
3328
|
function parseModelString(response, parentObject, key, value) {
|
2689
3329
|
if (value[0] === '$') {
|
2690
3330
|
switch (value[1]) {
|
@@ -2702,31 +3342,39 @@
|
|
2702
3342
|
return chunk;
|
2703
3343
|
}
|
2704
3344
|
|
2705
|
-
case '
|
3345
|
+
case 'F':
|
2706
3346
|
{
|
2707
|
-
//
|
2708
|
-
|
3347
|
+
// Server Reference
|
3348
|
+
var _id = parseInt(value.slice(2), 16); // TODO: Just encode this in the reference inline instead of as a model.
|
3349
|
+
|
3350
|
+
|
3351
|
+
var metaData = getOutlinedModel(response, _id);
|
3352
|
+
return loadServerReference$1(response, metaData.id, metaData.bound, initializingChunk, parentObject, key);
|
2709
3353
|
}
|
2710
3354
|
|
2711
|
-
case '
|
3355
|
+
case 'T':
|
2712
3356
|
{
|
2713
|
-
//
|
2714
|
-
|
3357
|
+
// Temporary Reference
|
3358
|
+
return createTemporaryReference(value.slice(2));
|
3359
|
+
}
|
2715
3360
|
|
2716
|
-
|
3361
|
+
case 'Q':
|
3362
|
+
{
|
3363
|
+
// Map
|
3364
|
+
var _id2 = parseInt(value.slice(2), 16);
|
2717
3365
|
|
2718
|
-
|
2719
|
-
|
2720
|
-
|
3366
|
+
var data = getOutlinedModel(response, _id2);
|
3367
|
+
return new Map(data);
|
3368
|
+
}
|
2721
3369
|
|
2722
|
-
|
2723
|
-
|
2724
|
-
|
2725
|
-
|
3370
|
+
case 'W':
|
3371
|
+
{
|
3372
|
+
// Set
|
3373
|
+
var _id3 = parseInt(value.slice(2), 16);
|
2726
3374
|
|
3375
|
+
var _data = getOutlinedModel(response, _id3);
|
2727
3376
|
|
2728
|
-
|
2729
|
-
return loadServerReference(response, metaData.id, metaData.bound, initializingChunk, parentObject, key);
|
3377
|
+
return new Set(_data);
|
2730
3378
|
}
|
2731
3379
|
|
2732
3380
|
case 'K':
|
@@ -2734,7 +3382,9 @@
|
|
2734
3382
|
// FormData
|
2735
3383
|
var stringId = value.slice(2);
|
2736
3384
|
var formPrefix = response._prefix + stringId + '_';
|
2737
|
-
|
3385
|
+
|
3386
|
+
var _data2 = new FormData();
|
3387
|
+
|
2738
3388
|
var backingFormData = response._formData; // We assume that the reference to FormData always comes after each
|
2739
3389
|
// entry that it references so we can assume they all exist in the
|
2740
3390
|
// backing store already.
|
@@ -2742,10 +3392,10 @@
|
|
2742
3392
|
|
2743
3393
|
backingFormData.forEach(function (entry, entryKey) {
|
2744
3394
|
if (entryKey.startsWith(formPrefix)) {
|
2745
|
-
|
3395
|
+
_data2.append(entryKey.slice(formPrefix.length), entry);
|
2746
3396
|
}
|
2747
3397
|
});
|
2748
|
-
return
|
3398
|
+
return _data2;
|
2749
3399
|
}
|
2750
3400
|
|
2751
3401
|
case 'I':
|
@@ -2792,31 +3442,31 @@
|
|
2792
3442
|
default:
|
2793
3443
|
{
|
2794
3444
|
// We assume that anything else is a reference ID.
|
2795
|
-
var
|
3445
|
+
var _id4 = parseInt(value.slice(1), 16);
|
2796
3446
|
|
2797
|
-
var
|
3447
|
+
var _chunk = getChunk(response, _id4);
|
2798
3448
|
|
2799
|
-
switch (
|
3449
|
+
switch (_chunk.status) {
|
2800
3450
|
case RESOLVED_MODEL:
|
2801
|
-
initializeModelChunk(
|
3451
|
+
initializeModelChunk(_chunk);
|
2802
3452
|
break;
|
2803
3453
|
} // The status might have changed after initialization.
|
2804
3454
|
|
2805
3455
|
|
2806
|
-
switch (
|
3456
|
+
switch (_chunk.status) {
|
2807
3457
|
case INITIALIZED:
|
2808
|
-
return
|
3458
|
+
return _chunk.value;
|
2809
3459
|
|
2810
3460
|
case PENDING:
|
2811
3461
|
case BLOCKED:
|
2812
3462
|
var parentChunk = initializingChunk;
|
2813
3463
|
|
2814
|
-
|
3464
|
+
_chunk.then(createModelResolver(parentChunk, parentObject, key), createModelReject(parentChunk));
|
2815
3465
|
|
2816
3466
|
return null;
|
2817
3467
|
|
2818
3468
|
default:
|
2819
|
-
throw
|
3469
|
+
throw _chunk.reason;
|
2820
3470
|
}
|
2821
3471
|
}
|
2822
3472
|
}
|
@@ -2852,8 +3502,130 @@
|
|
2852
3502
|
reportGlobalError(response, new Error('Connection closed.'));
|
2853
3503
|
}
|
2854
3504
|
|
3505
|
+
function bindArgs(fn, args) {
|
3506
|
+
return fn.bind.apply(fn, [null].concat(args));
|
3507
|
+
}
|
3508
|
+
|
3509
|
+
function loadServerReference(bundlerConfig, id, bound) {
|
3510
|
+
var serverReference = resolveServerReference(bundlerConfig, id); // We expect most servers to not really need this because you'd just have all
|
3511
|
+
// the relevant modules already loaded but it allows for lazy loading of code
|
3512
|
+
// if needed.
|
3513
|
+
|
3514
|
+
var preloadPromise = preloadModule(serverReference);
|
3515
|
+
|
3516
|
+
if (bound) {
|
3517
|
+
return Promise.all([bound, preloadPromise]).then(function (_ref) {
|
3518
|
+
var args = _ref[0];
|
3519
|
+
return bindArgs(requireModule(serverReference), args);
|
3520
|
+
});
|
3521
|
+
} else if (preloadPromise) {
|
3522
|
+
return Promise.resolve(preloadPromise).then(function () {
|
3523
|
+
return requireModule(serverReference);
|
3524
|
+
});
|
3525
|
+
} else {
|
3526
|
+
// Synchronously available
|
3527
|
+
return Promise.resolve(requireModule(serverReference));
|
3528
|
+
}
|
3529
|
+
}
|
3530
|
+
|
3531
|
+
function decodeBoundActionMetaData(body, serverManifest, formFieldPrefix) {
|
3532
|
+
// The data for this reference is encoded in multiple fields under this prefix.
|
3533
|
+
var actionResponse = createResponse(serverManifest, formFieldPrefix, body);
|
3534
|
+
close(actionResponse);
|
3535
|
+
var refPromise = getRoot(actionResponse); // Force it to initialize
|
3536
|
+
// $FlowFixMe
|
3537
|
+
|
3538
|
+
refPromise.then(function () {});
|
3539
|
+
|
3540
|
+
if (refPromise.status !== 'fulfilled') {
|
3541
|
+
// $FlowFixMe
|
3542
|
+
throw refPromise.reason;
|
3543
|
+
}
|
3544
|
+
|
3545
|
+
return refPromise.value;
|
3546
|
+
}
|
3547
|
+
|
3548
|
+
function decodeAction(body, serverManifest) {
|
3549
|
+
// We're going to create a new formData object that holds all the fields except
|
3550
|
+
// the implementation details of the action data.
|
3551
|
+
var formData = new FormData();
|
3552
|
+
var action = null; // $FlowFixMe[prop-missing]
|
3553
|
+
|
3554
|
+
body.forEach(function (value, key) {
|
3555
|
+
if (!key.startsWith('$ACTION_')) {
|
3556
|
+
formData.append(key, value);
|
3557
|
+
return;
|
3558
|
+
} // Later actions may override earlier actions if a button is used to override the default
|
3559
|
+
// form action.
|
3560
|
+
|
3561
|
+
|
3562
|
+
if (key.startsWith('$ACTION_REF_')) {
|
3563
|
+
var formFieldPrefix = '$ACTION_' + key.slice(12) + ':';
|
3564
|
+
var metaData = decodeBoundActionMetaData(body, serverManifest, formFieldPrefix);
|
3565
|
+
action = loadServerReference(serverManifest, metaData.id, metaData.bound);
|
3566
|
+
return;
|
3567
|
+
}
|
3568
|
+
|
3569
|
+
if (key.startsWith('$ACTION_ID_')) {
|
3570
|
+
var id = key.slice(11);
|
3571
|
+
action = loadServerReference(serverManifest, id, null);
|
3572
|
+
return;
|
3573
|
+
}
|
3574
|
+
});
|
3575
|
+
|
3576
|
+
if (action === null) {
|
3577
|
+
return null;
|
3578
|
+
} // Return the action with the remaining FormData bound to the first argument.
|
3579
|
+
|
3580
|
+
|
3581
|
+
return action.then(function (fn) {
|
3582
|
+
return fn.bind(null, formData);
|
3583
|
+
});
|
3584
|
+
}
|
3585
|
+
function decodeFormState(actionResult, body, serverManifest) {
|
3586
|
+
var keyPath = body.get('$ACTION_KEY');
|
3587
|
+
|
3588
|
+
if (typeof keyPath !== 'string') {
|
3589
|
+
// This form submission did not include any form state.
|
3590
|
+
return Promise.resolve(null);
|
3591
|
+
} // Search through the form data object to get the reference id and the number
|
3592
|
+
// of bound arguments. This repeats some of the work done in decodeAction.
|
3593
|
+
|
3594
|
+
|
3595
|
+
var metaData = null; // $FlowFixMe[prop-missing]
|
3596
|
+
|
3597
|
+
body.forEach(function (value, key) {
|
3598
|
+
if (key.startsWith('$ACTION_REF_')) {
|
3599
|
+
var formFieldPrefix = '$ACTION_' + key.slice(12) + ':';
|
3600
|
+
metaData = decodeBoundActionMetaData(body, serverManifest, formFieldPrefix);
|
3601
|
+
} // We don't check for the simple $ACTION_ID_ case because form state actions
|
3602
|
+
// are always bound to the state argument.
|
3603
|
+
|
3604
|
+
});
|
3605
|
+
|
3606
|
+
if (metaData === null) {
|
3607
|
+
// Should be unreachable.
|
3608
|
+
return Promise.resolve(null);
|
3609
|
+
}
|
3610
|
+
|
3611
|
+
var referenceId = metaData.id;
|
3612
|
+
return Promise.resolve(metaData.bound).then(function (bound) {
|
3613
|
+
if (bound === null) {
|
3614
|
+
// Should be unreachable because form state actions are always bound to the
|
3615
|
+
// state argument.
|
3616
|
+
return null;
|
3617
|
+
} // The form action dispatch method is always bound to the initial state.
|
3618
|
+
// But when comparing signatures, we compare to the original unbound action.
|
3619
|
+
// Subtract one from the arity to account for this.
|
3620
|
+
|
3621
|
+
|
3622
|
+
var boundArity = bound.length - 1;
|
3623
|
+
return [actionResult, keyPath, referenceId, boundArity];
|
3624
|
+
});
|
3625
|
+
}
|
3626
|
+
|
2855
3627
|
function renderToReadableStream(model, webpackMap, options) {
|
2856
|
-
var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.
|
3628
|
+
var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.identifierPrefix : undefined, options ? options.onPostpone : undefined, options ? options.environmentName : undefined);
|
2857
3629
|
|
2858
3630
|
if (options && options.signal) {
|
2859
3631
|
var signal = options.signal;
|
@@ -2878,7 +3650,10 @@
|
|
2878
3650
|
pull: function (controller) {
|
2879
3651
|
startFlowing(request, controller);
|
2880
3652
|
},
|
2881
|
-
cancel: function (reason) {
|
3653
|
+
cancel: function (reason) {
|
3654
|
+
stopFlowing(request);
|
3655
|
+
abort(request, reason);
|
3656
|
+
}
|
2882
3657
|
}, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams.
|
2883
3658
|
{
|
2884
3659
|
highWaterMark: 0
|
@@ -2894,11 +3669,17 @@
|
|
2894
3669
|
}
|
2895
3670
|
|
2896
3671
|
var response = createResponse(webpackMap, '', body);
|
3672
|
+
var root = getRoot(response);
|
2897
3673
|
close(response);
|
2898
|
-
return
|
3674
|
+
return root;
|
2899
3675
|
}
|
2900
3676
|
|
3677
|
+
exports.createClientModuleProxy = createClientModuleProxy;
|
3678
|
+
exports.decodeAction = decodeAction;
|
3679
|
+
exports.decodeFormState = decodeFormState;
|
2901
3680
|
exports.decodeReply = decodeReply;
|
3681
|
+
exports.registerClientReference = registerClientReference;
|
3682
|
+
exports.registerServerReference = registerServerReference;
|
2902
3683
|
exports.renderToReadableStream = renderToReadableStream;
|
2903
3684
|
|
2904
3685
|
}));
|