react-server-dom-webpack 19.0.0-canary-8afa144bd-20240416 → 19.0.0-canary-36e62c603-20240418
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 +39 -7
- package/cjs/react-server-dom-webpack-client.browser.production.js +37 -6
- package/cjs/react-server-dom-webpack-client.browser.production.min.js +7 -7
- package/cjs/react-server-dom-webpack-client.browser.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-client.edge.development.js +39 -7
- package/cjs/react-server-dom-webpack-client.edge.production.js +37 -6
- package/cjs/react-server-dom-webpack-client.edge.production.min.js +18 -18
- package/cjs/react-server-dom-webpack-client.edge.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-client.node.development.js +39 -7
- package/cjs/react-server-dom-webpack-client.node.production.js +37 -6
- package/cjs/react-server-dom-webpack-client.node.production.min.js +4 -4
- package/cjs/react-server-dom-webpack-client.node.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +39 -7
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +37 -6
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +16 -16
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-server.browser.development.js +96 -51
- package/cjs/react-server-dom-webpack-server.browser.production.js +74 -40
- package/cjs/react-server-dom-webpack-server.browser.production.min.js +59 -58
- package/cjs/react-server-dom-webpack-server.browser.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-server.edge.development.js +96 -51
- package/cjs/react-server-dom-webpack-server.edge.production.js +74 -40
- package/cjs/react-server-dom-webpack-server.edge.production.min.js +60 -60
- package/cjs/react-server-dom-webpack-server.edge.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-server.node.development.js +96 -51
- package/cjs/react-server-dom-webpack-server.node.production.js +74 -40
- package/cjs/react-server-dom-webpack-server.node.production.min.js +60 -61
- package/cjs/react-server-dom-webpack-server.node.production.min.js.map +1 -1
- package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +96 -51
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +74 -40
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +58 -58
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js.map +1 -1
- package/package.json +3 -4
- package/umd/react-server-dom-webpack-client.browser.development.js +0 -2365
- package/umd/react-server-dom-webpack-client.browser.production.min.js +0 -35
- package/umd/react-server-dom-webpack-server.browser.development.js +0 -4027
- package/umd/react-server-dom-webpack-server.browser.production.min.js +0 -65
@@ -1,4027 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @license React
|
3
|
-
* react-server-dom-webpack-server.browser.development.js
|
4
|
-
*
|
5
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
6
|
-
*
|
7
|
-
* This source code is licensed under the MIT license found in the
|
8
|
-
* LICENSE file in the root directory of this source tree.
|
9
|
-
*/
|
10
|
-
|
11
|
-
(function (global, factory) {
|
12
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom')) :
|
13
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom'], factory) :
|
14
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ReactServerDOMServer = {}, global.React, global.ReactDOM));
|
15
|
-
})(this, (function (exports, React, ReactDOM) { 'use strict';
|
16
|
-
|
17
|
-
var ReactSharedInternalsServer = // $FlowFixMe: It's defined in the one we resolve to.
|
18
|
-
React.__SERVER_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
19
|
-
|
20
|
-
if (!ReactSharedInternalsServer) {
|
21
|
-
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.');
|
22
|
-
}
|
23
|
-
|
24
|
-
function error(format) {
|
25
|
-
{
|
26
|
-
{
|
27
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
28
|
-
args[_key2 - 1] = arguments[_key2];
|
29
|
-
}
|
30
|
-
|
31
|
-
printWarning('error', format, args);
|
32
|
-
}
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
function printWarning(level, format, args) {
|
37
|
-
// When changing this logic, you might want to also
|
38
|
-
// update consoleWithStackDev.www.js as well.
|
39
|
-
{
|
40
|
-
var stack = ReactSharedInternalsServer.getStackAddendum();
|
41
|
-
|
42
|
-
if (stack !== '') {
|
43
|
-
format += '%s';
|
44
|
-
args = args.concat([stack]);
|
45
|
-
} // eslint-disable-next-line react-internal/safe-string-coercion
|
46
|
-
|
47
|
-
|
48
|
-
var argsWithFormat = args.map(function (item) {
|
49
|
-
return String(item);
|
50
|
-
}); // Careful: RN currently depends on this prefix
|
51
|
-
|
52
|
-
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
53
|
-
// breaks IE9: https://github.com/facebook/react/issues/13610
|
54
|
-
// eslint-disable-next-line react-internal/no-production-logging
|
55
|
-
|
56
|
-
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
57
|
-
}
|
58
|
-
}
|
59
|
-
|
60
|
-
// -----------------------------------------------------------------------------
|
61
|
-
var enablePostpone = false;
|
62
|
-
|
63
|
-
function scheduleWork(callback) {
|
64
|
-
callback();
|
65
|
-
}
|
66
|
-
var VIEW_SIZE = 2048;
|
67
|
-
var currentView = null;
|
68
|
-
var writtenBytes = 0;
|
69
|
-
function beginWriting(destination) {
|
70
|
-
currentView = new Uint8Array(VIEW_SIZE);
|
71
|
-
writtenBytes = 0;
|
72
|
-
}
|
73
|
-
function writeChunk(destination, chunk) {
|
74
|
-
if (chunk.byteLength === 0) {
|
75
|
-
return;
|
76
|
-
}
|
77
|
-
|
78
|
-
if (chunk.byteLength > VIEW_SIZE) {
|
79
|
-
// this chunk may overflow a single view which implies it was not
|
80
|
-
// one that is cached by the streaming renderer. We will enqueu
|
81
|
-
// it directly and expect it is not re-used
|
82
|
-
if (writtenBytes > 0) {
|
83
|
-
destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes));
|
84
|
-
currentView = new Uint8Array(VIEW_SIZE);
|
85
|
-
writtenBytes = 0;
|
86
|
-
}
|
87
|
-
|
88
|
-
destination.enqueue(chunk);
|
89
|
-
return;
|
90
|
-
}
|
91
|
-
|
92
|
-
var bytesToWrite = chunk;
|
93
|
-
var allowableBytes = currentView.length - writtenBytes;
|
94
|
-
|
95
|
-
if (allowableBytes < bytesToWrite.byteLength) {
|
96
|
-
// this chunk would overflow the current view. We enqueue a full view
|
97
|
-
// and start a new view with the remaining chunk
|
98
|
-
if (allowableBytes === 0) {
|
99
|
-
// the current view is already full, send it
|
100
|
-
destination.enqueue(currentView);
|
101
|
-
} else {
|
102
|
-
// fill up the current view and apply the remaining chunk bytes
|
103
|
-
// to a new view.
|
104
|
-
currentView.set(bytesToWrite.subarray(0, allowableBytes), writtenBytes); // writtenBytes += allowableBytes; // this can be skipped because we are going to immediately reset the view
|
105
|
-
|
106
|
-
destination.enqueue(currentView);
|
107
|
-
bytesToWrite = bytesToWrite.subarray(allowableBytes);
|
108
|
-
}
|
109
|
-
|
110
|
-
currentView = new Uint8Array(VIEW_SIZE);
|
111
|
-
writtenBytes = 0;
|
112
|
-
}
|
113
|
-
|
114
|
-
currentView.set(bytesToWrite, writtenBytes);
|
115
|
-
writtenBytes += bytesToWrite.byteLength;
|
116
|
-
}
|
117
|
-
function writeChunkAndReturn(destination, chunk) {
|
118
|
-
writeChunk(destination, chunk); // in web streams there is no backpressure so we can alwas write more
|
119
|
-
|
120
|
-
return true;
|
121
|
-
}
|
122
|
-
function completeWriting(destination) {
|
123
|
-
if (currentView && writtenBytes > 0) {
|
124
|
-
destination.enqueue(new Uint8Array(currentView.buffer, 0, writtenBytes));
|
125
|
-
currentView = null;
|
126
|
-
writtenBytes = 0;
|
127
|
-
}
|
128
|
-
}
|
129
|
-
function close$1(destination) {
|
130
|
-
destination.close();
|
131
|
-
}
|
132
|
-
var textEncoder = new TextEncoder();
|
133
|
-
function stringToChunk(content) {
|
134
|
-
return textEncoder.encode(content);
|
135
|
-
}
|
136
|
-
function byteLengthOfChunk(chunk) {
|
137
|
-
return chunk.byteLength;
|
138
|
-
}
|
139
|
-
function closeWithError(destination, error) {
|
140
|
-
// $FlowFixMe[method-unbinding]
|
141
|
-
if (typeof destination.error === 'function') {
|
142
|
-
// $FlowFixMe[incompatible-call]: This is an Error object or the destination accepts other types.
|
143
|
-
destination.error(error);
|
144
|
-
} else {
|
145
|
-
// Earlier implementations doesn't support this method. In that environment you're
|
146
|
-
// supposed to throw from a promise returned but we don't return a promise in our
|
147
|
-
// approach. We could fork this implementation but this is environment is an edge
|
148
|
-
// case to begin with. It's even less common to run this in an older environment.
|
149
|
-
// Even then, this is not where errors are supposed to happen and they get reported
|
150
|
-
// to a global callback in addition to this anyway. So it's fine just to close this.
|
151
|
-
destination.close();
|
152
|
-
}
|
153
|
-
}
|
154
|
-
|
155
|
-
// eslint-disable-next-line no-unused-vars
|
156
|
-
var CLIENT_REFERENCE_TAG$1 = Symbol.for('react.client.reference');
|
157
|
-
var SERVER_REFERENCE_TAG = Symbol.for('react.server.reference');
|
158
|
-
function isClientReference(reference) {
|
159
|
-
return reference.$$typeof === CLIENT_REFERENCE_TAG$1;
|
160
|
-
}
|
161
|
-
function isServerReference(reference) {
|
162
|
-
return reference.$$typeof === SERVER_REFERENCE_TAG;
|
163
|
-
}
|
164
|
-
function registerClientReference(proxyImplementation, id, exportName) {
|
165
|
-
return registerClientReferenceImpl(proxyImplementation, id + '#' + exportName, false);
|
166
|
-
}
|
167
|
-
|
168
|
-
function registerClientReferenceImpl(proxyImplementation, id, async) {
|
169
|
-
return Object.defineProperties(proxyImplementation, {
|
170
|
-
$$typeof: {
|
171
|
-
value: CLIENT_REFERENCE_TAG$1
|
172
|
-
},
|
173
|
-
$$id: {
|
174
|
-
value: id
|
175
|
-
},
|
176
|
-
$$async: {
|
177
|
-
value: async
|
178
|
-
}
|
179
|
-
});
|
180
|
-
} // $FlowFixMe[method-unbinding]
|
181
|
-
|
182
|
-
|
183
|
-
var FunctionBind = Function.prototype.bind; // $FlowFixMe[method-unbinding]
|
184
|
-
|
185
|
-
var ArraySlice = Array.prototype.slice;
|
186
|
-
|
187
|
-
function bind() {
|
188
|
-
// $FlowFixMe[unsupported-syntax]
|
189
|
-
var newFn = FunctionBind.apply(this, arguments);
|
190
|
-
|
191
|
-
if (this.$$typeof === SERVER_REFERENCE_TAG) {
|
192
|
-
{
|
193
|
-
var thisBind = arguments[0];
|
194
|
-
|
195
|
-
if (thisBind != null) {
|
196
|
-
error('Cannot bind "this" of a Server Action. Pass null or undefined as the first argument to .bind().');
|
197
|
-
}
|
198
|
-
}
|
199
|
-
|
200
|
-
var args = ArraySlice.call(arguments, 1);
|
201
|
-
return Object.defineProperties(newFn, {
|
202
|
-
$$typeof: {
|
203
|
-
value: SERVER_REFERENCE_TAG
|
204
|
-
},
|
205
|
-
$$id: {
|
206
|
-
value: this.$$id
|
207
|
-
},
|
208
|
-
$$bound: {
|
209
|
-
value: this.$$bound ? this.$$bound.concat(args) : args
|
210
|
-
},
|
211
|
-
bind: {
|
212
|
-
value: bind
|
213
|
-
}
|
214
|
-
});
|
215
|
-
}
|
216
|
-
|
217
|
-
return newFn;
|
218
|
-
}
|
219
|
-
|
220
|
-
function registerServerReference(reference, id, exportName) {
|
221
|
-
return Object.defineProperties(reference, {
|
222
|
-
$$typeof: {
|
223
|
-
value: SERVER_REFERENCE_TAG
|
224
|
-
},
|
225
|
-
$$id: {
|
226
|
-
value: exportName === null ? id : id + '#' + exportName,
|
227
|
-
configurable: true
|
228
|
-
},
|
229
|
-
$$bound: {
|
230
|
-
value: null,
|
231
|
-
configurable: true
|
232
|
-
},
|
233
|
-
bind: {
|
234
|
-
value: bind,
|
235
|
-
configurable: true
|
236
|
-
}
|
237
|
-
});
|
238
|
-
}
|
239
|
-
var PROMISE_PROTOTYPE = Promise.prototype;
|
240
|
-
var deepProxyHandlers = {
|
241
|
-
get: function (target, name, receiver) {
|
242
|
-
switch (name) {
|
243
|
-
// These names are read by the Flight runtime if you end up using the exports object.
|
244
|
-
case '$$typeof':
|
245
|
-
// These names are a little too common. We should probably have a way to
|
246
|
-
// have the Flight runtime extract the inner target instead.
|
247
|
-
return target.$$typeof;
|
248
|
-
|
249
|
-
case '$$id':
|
250
|
-
return target.$$id;
|
251
|
-
|
252
|
-
case '$$async':
|
253
|
-
return target.$$async;
|
254
|
-
|
255
|
-
case 'name':
|
256
|
-
return target.name;
|
257
|
-
|
258
|
-
case 'displayName':
|
259
|
-
return undefined;
|
260
|
-
// We need to special case this because createElement reads it if we pass this
|
261
|
-
// reference.
|
262
|
-
|
263
|
-
case 'defaultProps':
|
264
|
-
return undefined;
|
265
|
-
// Avoid this attempting to be serialized.
|
266
|
-
|
267
|
-
case 'toJSON':
|
268
|
-
return undefined;
|
269
|
-
|
270
|
-
case Symbol.toPrimitive:
|
271
|
-
// $FlowFixMe[prop-missing]
|
272
|
-
return Object.prototype[Symbol.toPrimitive];
|
273
|
-
|
274
|
-
case Symbol.toStringTag:
|
275
|
-
// $FlowFixMe[prop-missing]
|
276
|
-
return Object.prototype[Symbol.toStringTag];
|
277
|
-
|
278
|
-
case 'Provider':
|
279
|
-
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.");
|
280
|
-
} // eslint-disable-next-line react-internal/safe-string-coercion
|
281
|
-
|
282
|
-
|
283
|
-
var expression = String(target.name) + '.' + String(name);
|
284
|
-
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.');
|
285
|
-
},
|
286
|
-
set: function () {
|
287
|
-
throw new Error('Cannot assign to a client module from a server module.');
|
288
|
-
}
|
289
|
-
};
|
290
|
-
|
291
|
-
function getReference(target, name) {
|
292
|
-
switch (name) {
|
293
|
-
// These names are read by the Flight runtime if you end up using the exports object.
|
294
|
-
case '$$typeof':
|
295
|
-
return target.$$typeof;
|
296
|
-
|
297
|
-
case '$$id':
|
298
|
-
return target.$$id;
|
299
|
-
|
300
|
-
case '$$async':
|
301
|
-
return target.$$async;
|
302
|
-
|
303
|
-
case 'name':
|
304
|
-
return target.name;
|
305
|
-
// We need to special case this because createElement reads it if we pass this
|
306
|
-
// reference.
|
307
|
-
|
308
|
-
case 'defaultProps':
|
309
|
-
return undefined;
|
310
|
-
// Avoid this attempting to be serialized.
|
311
|
-
|
312
|
-
case 'toJSON':
|
313
|
-
return undefined;
|
314
|
-
|
315
|
-
case Symbol.toPrimitive:
|
316
|
-
// $FlowFixMe[prop-missing]
|
317
|
-
return Object.prototype[Symbol.toPrimitive];
|
318
|
-
|
319
|
-
case Symbol.toStringTag:
|
320
|
-
// $FlowFixMe[prop-missing]
|
321
|
-
return Object.prototype[Symbol.toStringTag];
|
322
|
-
|
323
|
-
case '__esModule':
|
324
|
-
// Something is conditionally checking which export to use. We'll pretend to be
|
325
|
-
// an ESM compat module but then we'll check again on the client.
|
326
|
-
var moduleId = target.$$id;
|
327
|
-
target.default = registerClientReferenceImpl(function () {
|
328
|
-
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.");
|
329
|
-
}, target.$$id + '#', target.$$async);
|
330
|
-
return true;
|
331
|
-
|
332
|
-
case 'then':
|
333
|
-
if (target.then) {
|
334
|
-
// Use a cached value
|
335
|
-
return target.then;
|
336
|
-
}
|
337
|
-
|
338
|
-
if (!target.$$async) {
|
339
|
-
// If this module is expected to return a Promise (such as an AsyncModule) then
|
340
|
-
// we should resolve that with a client reference that unwraps the Promise on
|
341
|
-
// the client.
|
342
|
-
var clientReference = registerClientReferenceImpl({}, target.$$id, true);
|
343
|
-
var proxy = new Proxy(clientReference, proxyHandlers$1); // Treat this as a resolved Promise for React's use()
|
344
|
-
|
345
|
-
target.status = 'fulfilled';
|
346
|
-
target.value = proxy;
|
347
|
-
var then = target.then = registerClientReferenceImpl(function then(resolve, reject) {
|
348
|
-
// Expose to React.
|
349
|
-
return Promise.resolve(resolve(proxy));
|
350
|
-
}, // If this is not used as a Promise but is treated as a reference to a `.then`
|
351
|
-
// export then we should treat it as a reference to that name.
|
352
|
-
target.$$id + '#then', false);
|
353
|
-
return then;
|
354
|
-
} else {
|
355
|
-
// Since typeof .then === 'function' is a feature test we'd continue recursing
|
356
|
-
// indefinitely if we return a function. Instead, we return an object reference
|
357
|
-
// if we check further.
|
358
|
-
return undefined;
|
359
|
-
}
|
360
|
-
|
361
|
-
}
|
362
|
-
|
363
|
-
if (typeof name === 'symbol') {
|
364
|
-
throw new Error('Cannot read Symbol exports. Only named exports are supported on a client module ' + 'imported on the server.');
|
365
|
-
}
|
366
|
-
|
367
|
-
var cachedReference = target[name];
|
368
|
-
|
369
|
-
if (!cachedReference) {
|
370
|
-
var reference = registerClientReferenceImpl(function () {
|
371
|
-
throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion
|
372
|
-
"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.");
|
373
|
-
}, target.$$id + '#' + name, target.$$async);
|
374
|
-
Object.defineProperty(reference, 'name', {
|
375
|
-
value: name
|
376
|
-
});
|
377
|
-
cachedReference = target[name] = new Proxy(reference, deepProxyHandlers);
|
378
|
-
}
|
379
|
-
|
380
|
-
return cachedReference;
|
381
|
-
}
|
382
|
-
|
383
|
-
var proxyHandlers$1 = {
|
384
|
-
get: function (target, name, receiver) {
|
385
|
-
return getReference(target, name);
|
386
|
-
},
|
387
|
-
getOwnPropertyDescriptor: function (target, name) {
|
388
|
-
var descriptor = Object.getOwnPropertyDescriptor(target, name);
|
389
|
-
|
390
|
-
if (!descriptor) {
|
391
|
-
descriptor = {
|
392
|
-
value: getReference(target, name),
|
393
|
-
writable: false,
|
394
|
-
configurable: false,
|
395
|
-
enumerable: false
|
396
|
-
};
|
397
|
-
Object.defineProperty(target, name, descriptor);
|
398
|
-
}
|
399
|
-
|
400
|
-
return descriptor;
|
401
|
-
},
|
402
|
-
getPrototypeOf: function (target) {
|
403
|
-
// Pretend to be a Promise in case anyone asks.
|
404
|
-
return PROMISE_PROTOTYPE;
|
405
|
-
},
|
406
|
-
set: function () {
|
407
|
-
throw new Error('Cannot assign to a client module from a server module.');
|
408
|
-
}
|
409
|
-
};
|
410
|
-
function createClientModuleProxy(moduleId) {
|
411
|
-
var clientReference = registerClientReferenceImpl({}, // Represents the whole Module object instead of a particular import.
|
412
|
-
moduleId, false);
|
413
|
-
return new Proxy(clientReference, proxyHandlers$1);
|
414
|
-
}
|
415
|
-
|
416
|
-
function getClientReferenceKey(reference) {
|
417
|
-
return reference.$$async ? reference.$$id + '#async' : reference.$$id;
|
418
|
-
}
|
419
|
-
function resolveClientReferenceMetadata(config, clientReference) {
|
420
|
-
var modulePath = clientReference.$$id;
|
421
|
-
var name = '';
|
422
|
-
var resolvedModuleData = config[modulePath];
|
423
|
-
|
424
|
-
if (resolvedModuleData) {
|
425
|
-
// The potentially aliased name.
|
426
|
-
name = resolvedModuleData.name;
|
427
|
-
} else {
|
428
|
-
// We didn't find this specific export name but we might have the * export
|
429
|
-
// which contains this name as well.
|
430
|
-
// TODO: It's unfortunate that we now have to parse this string. We should
|
431
|
-
// probably go back to encoding path and name separately on the client reference.
|
432
|
-
var idx = modulePath.lastIndexOf('#');
|
433
|
-
|
434
|
-
if (idx !== -1) {
|
435
|
-
name = modulePath.slice(idx + 1);
|
436
|
-
resolvedModuleData = config[modulePath.slice(0, idx)];
|
437
|
-
}
|
438
|
-
|
439
|
-
if (!resolvedModuleData) {
|
440
|
-
throw new Error('Could not find the module "' + modulePath + '" in the React Client Manifest. ' + 'This is probably a bug in the React Server Components bundler.');
|
441
|
-
}
|
442
|
-
}
|
443
|
-
|
444
|
-
if (clientReference.$$async === true) {
|
445
|
-
return [resolvedModuleData.id, resolvedModuleData.chunks, name, 1];
|
446
|
-
} else {
|
447
|
-
return [resolvedModuleData.id, resolvedModuleData.chunks, name];
|
448
|
-
}
|
449
|
-
}
|
450
|
-
function getServerReferenceId(config, serverReference) {
|
451
|
-
return serverReference.$$id;
|
452
|
-
}
|
453
|
-
function getServerReferenceBoundArguments(config, serverReference) {
|
454
|
-
return serverReference.$$bound;
|
455
|
-
}
|
456
|
-
|
457
|
-
var ReactDOMSharedInternals = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
|
458
|
-
|
459
|
-
var previousDispatcher = ReactDOMSharedInternals.d;
|
460
|
-
/* ReactDOMCurrentDispatcher */
|
461
|
-
|
462
|
-
ReactDOMSharedInternals.d
|
463
|
-
/* ReactDOMCurrentDispatcher */
|
464
|
-
= {
|
465
|
-
f
|
466
|
-
/* flushSyncWork */
|
467
|
-
: previousDispatcher.f
|
468
|
-
/* flushSyncWork */
|
469
|
-
,
|
470
|
-
r
|
471
|
-
/* requestFormReset */
|
472
|
-
: previousDispatcher.r
|
473
|
-
/* requestFormReset */
|
474
|
-
,
|
475
|
-
D
|
476
|
-
/* prefetchDNS */
|
477
|
-
: prefetchDNS,
|
478
|
-
C
|
479
|
-
/* preconnect */
|
480
|
-
: preconnect,
|
481
|
-
L
|
482
|
-
/* preload */
|
483
|
-
: preload,
|
484
|
-
m
|
485
|
-
/* preloadModule */
|
486
|
-
: preloadModule$1,
|
487
|
-
X
|
488
|
-
/* preinitScript */
|
489
|
-
: preinitScript,
|
490
|
-
S
|
491
|
-
/* preinitStyle */
|
492
|
-
: preinitStyle,
|
493
|
-
M
|
494
|
-
/* preinitModuleScript */
|
495
|
-
: preinitModuleScript
|
496
|
-
};
|
497
|
-
|
498
|
-
function prefetchDNS(href) {
|
499
|
-
if (typeof href === 'string' && href) {
|
500
|
-
var request = resolveRequest();
|
501
|
-
|
502
|
-
if (request) {
|
503
|
-
var hints = getHints(request);
|
504
|
-
var key = 'D|' + href;
|
505
|
-
|
506
|
-
if (hints.has(key)) {
|
507
|
-
// duplicate hint
|
508
|
-
return;
|
509
|
-
}
|
510
|
-
|
511
|
-
hints.add(key);
|
512
|
-
emitHint(request, 'D', href);
|
513
|
-
} else {
|
514
|
-
previousDispatcher.D(
|
515
|
-
/* prefetchDNS */
|
516
|
-
href);
|
517
|
-
}
|
518
|
-
}
|
519
|
-
}
|
520
|
-
|
521
|
-
function preconnect(href, crossOrigin) {
|
522
|
-
if (typeof href === 'string') {
|
523
|
-
var request = resolveRequest();
|
524
|
-
|
525
|
-
if (request) {
|
526
|
-
var hints = getHints(request);
|
527
|
-
var key = "C|" + (crossOrigin == null ? 'null' : crossOrigin) + "|" + href;
|
528
|
-
|
529
|
-
if (hints.has(key)) {
|
530
|
-
// duplicate hint
|
531
|
-
return;
|
532
|
-
}
|
533
|
-
|
534
|
-
hints.add(key);
|
535
|
-
|
536
|
-
if (typeof crossOrigin === 'string') {
|
537
|
-
emitHint(request, 'C', [href, crossOrigin]);
|
538
|
-
} else {
|
539
|
-
emitHint(request, 'C', href);
|
540
|
-
}
|
541
|
-
} else {
|
542
|
-
previousDispatcher.C(
|
543
|
-
/* preconnect */
|
544
|
-
href, crossOrigin);
|
545
|
-
}
|
546
|
-
}
|
547
|
-
}
|
548
|
-
|
549
|
-
function preload(href, as, options) {
|
550
|
-
if (typeof href === 'string') {
|
551
|
-
var request = resolveRequest();
|
552
|
-
|
553
|
-
if (request) {
|
554
|
-
var hints = getHints(request);
|
555
|
-
var key = 'L';
|
556
|
-
|
557
|
-
if (as === 'image' && options) {
|
558
|
-
key += getImagePreloadKey(href, options.imageSrcSet, options.imageSizes);
|
559
|
-
} else {
|
560
|
-
key += "[" + as + "]" + href;
|
561
|
-
}
|
562
|
-
|
563
|
-
if (hints.has(key)) {
|
564
|
-
// duplicate hint
|
565
|
-
return;
|
566
|
-
}
|
567
|
-
|
568
|
-
hints.add(key);
|
569
|
-
var trimmed = trimOptions(options);
|
570
|
-
|
571
|
-
if (trimmed) {
|
572
|
-
emitHint(request, 'L', [href, as, trimmed]);
|
573
|
-
} else {
|
574
|
-
emitHint(request, 'L', [href, as]);
|
575
|
-
}
|
576
|
-
} else {
|
577
|
-
previousDispatcher.L(
|
578
|
-
/* preload */
|
579
|
-
href, as, options);
|
580
|
-
}
|
581
|
-
}
|
582
|
-
}
|
583
|
-
|
584
|
-
function preloadModule$1(href, options) {
|
585
|
-
if (typeof href === 'string') {
|
586
|
-
var request = resolveRequest();
|
587
|
-
|
588
|
-
if (request) {
|
589
|
-
var hints = getHints(request);
|
590
|
-
var key = 'm|' + href;
|
591
|
-
|
592
|
-
if (hints.has(key)) {
|
593
|
-
// duplicate hint
|
594
|
-
return;
|
595
|
-
}
|
596
|
-
|
597
|
-
hints.add(key);
|
598
|
-
var trimmed = trimOptions(options);
|
599
|
-
|
600
|
-
if (trimmed) {
|
601
|
-
return emitHint(request, 'm', [href, trimmed]);
|
602
|
-
} else {
|
603
|
-
return emitHint(request, 'm', href);
|
604
|
-
}
|
605
|
-
} else {
|
606
|
-
previousDispatcher.m(
|
607
|
-
/* preloadModule */
|
608
|
-
href, options);
|
609
|
-
}
|
610
|
-
}
|
611
|
-
}
|
612
|
-
|
613
|
-
function preinitStyle(href, precedence, options) {
|
614
|
-
if (typeof href === 'string') {
|
615
|
-
var request = resolveRequest();
|
616
|
-
|
617
|
-
if (request) {
|
618
|
-
var hints = getHints(request);
|
619
|
-
var key = 'S|' + href;
|
620
|
-
|
621
|
-
if (hints.has(key)) {
|
622
|
-
// duplicate hint
|
623
|
-
return;
|
624
|
-
}
|
625
|
-
|
626
|
-
hints.add(key);
|
627
|
-
var trimmed = trimOptions(options);
|
628
|
-
|
629
|
-
if (trimmed) {
|
630
|
-
return emitHint(request, 'S', [href, typeof precedence === 'string' ? precedence : 0, trimmed]);
|
631
|
-
} else if (typeof precedence === 'string') {
|
632
|
-
return emitHint(request, 'S', [href, precedence]);
|
633
|
-
} else {
|
634
|
-
return emitHint(request, 'S', href);
|
635
|
-
}
|
636
|
-
} else {
|
637
|
-
previousDispatcher.S(
|
638
|
-
/* preinitStyle */
|
639
|
-
href, precedence, options);
|
640
|
-
}
|
641
|
-
}
|
642
|
-
}
|
643
|
-
|
644
|
-
function preinitScript(src, options) {
|
645
|
-
if (typeof src === 'string') {
|
646
|
-
var request = resolveRequest();
|
647
|
-
|
648
|
-
if (request) {
|
649
|
-
var hints = getHints(request);
|
650
|
-
var key = 'X|' + src;
|
651
|
-
|
652
|
-
if (hints.has(key)) {
|
653
|
-
// duplicate hint
|
654
|
-
return;
|
655
|
-
}
|
656
|
-
|
657
|
-
hints.add(key);
|
658
|
-
var trimmed = trimOptions(options);
|
659
|
-
|
660
|
-
if (trimmed) {
|
661
|
-
return emitHint(request, 'X', [src, trimmed]);
|
662
|
-
} else {
|
663
|
-
return emitHint(request, 'X', src);
|
664
|
-
}
|
665
|
-
} else {
|
666
|
-
previousDispatcher.X(
|
667
|
-
/* preinitScript */
|
668
|
-
src, options);
|
669
|
-
}
|
670
|
-
}
|
671
|
-
}
|
672
|
-
|
673
|
-
function preinitModuleScript(src, options) {
|
674
|
-
if (typeof src === 'string') {
|
675
|
-
var request = resolveRequest();
|
676
|
-
|
677
|
-
if (request) {
|
678
|
-
var hints = getHints(request);
|
679
|
-
var key = 'M|' + src;
|
680
|
-
|
681
|
-
if (hints.has(key)) {
|
682
|
-
// duplicate hint
|
683
|
-
return;
|
684
|
-
}
|
685
|
-
|
686
|
-
hints.add(key);
|
687
|
-
var trimmed = trimOptions(options);
|
688
|
-
|
689
|
-
if (trimmed) {
|
690
|
-
return emitHint(request, 'M', [src, trimmed]);
|
691
|
-
} else {
|
692
|
-
return emitHint(request, 'M', src);
|
693
|
-
}
|
694
|
-
} else {
|
695
|
-
previousDispatcher.M(
|
696
|
-
/* preinitModuleScript */
|
697
|
-
src, options);
|
698
|
-
}
|
699
|
-
}
|
700
|
-
} // Flight normally encodes undefined as a special character however for directive option
|
701
|
-
// arguments we don't want to send unnecessary keys and bloat the payload so we create a
|
702
|
-
// trimmed object which omits any keys with null or undefined values.
|
703
|
-
// This is only typesafe because these option objects have entirely optional fields where
|
704
|
-
// null and undefined represent the same thing as no property.
|
705
|
-
|
706
|
-
|
707
|
-
function trimOptions(options) {
|
708
|
-
if (options == null) return null;
|
709
|
-
var hasProperties = false;
|
710
|
-
var trimmed = {};
|
711
|
-
|
712
|
-
for (var key in options) {
|
713
|
-
if (options[key] != null) {
|
714
|
-
hasProperties = true;
|
715
|
-
trimmed[key] = options[key];
|
716
|
-
}
|
717
|
-
}
|
718
|
-
|
719
|
-
return hasProperties ? trimmed : null;
|
720
|
-
}
|
721
|
-
|
722
|
-
function getImagePreloadKey(href, imageSrcSet, imageSizes) {
|
723
|
-
var uniquePart = '';
|
724
|
-
|
725
|
-
if (typeof imageSrcSet === 'string' && imageSrcSet !== '') {
|
726
|
-
uniquePart += '[' + imageSrcSet + ']';
|
727
|
-
|
728
|
-
if (typeof imageSizes === 'string') {
|
729
|
-
uniquePart += '[' + imageSizes + ']';
|
730
|
-
}
|
731
|
-
} else {
|
732
|
-
uniquePart += '[][]' + href;
|
733
|
-
}
|
734
|
-
|
735
|
-
return "[image]" + uniquePart;
|
736
|
-
}
|
737
|
-
|
738
|
-
// This module registers the host dispatcher so it needs to be imported
|
739
|
-
// small, smaller than how we encode undefined, and is unambiguous. We could use
|
740
|
-
// a different tuple structure to encode this instead but this makes the runtime
|
741
|
-
// cost cheaper by eliminating a type checks in more positions.
|
742
|
-
// prettier-ignore
|
743
|
-
|
744
|
-
function createHints() {
|
745
|
-
return new Set();
|
746
|
-
}
|
747
|
-
|
748
|
-
var supportsRequestStorage = false;
|
749
|
-
var requestStorage = null;
|
750
|
-
|
751
|
-
var TEMPORARY_REFERENCE_TAG = Symbol.for('react.temporary.reference'); // eslint-disable-next-line no-unused-vars
|
752
|
-
|
753
|
-
function isTemporaryReference(reference) {
|
754
|
-
return reference.$$typeof === TEMPORARY_REFERENCE_TAG;
|
755
|
-
}
|
756
|
-
function resolveTemporaryReferenceID(temporaryReference) {
|
757
|
-
return temporaryReference.$$id;
|
758
|
-
}
|
759
|
-
var proxyHandlers = {
|
760
|
-
get: function (target, name, receiver) {
|
761
|
-
switch (name) {
|
762
|
-
// These names are read by the Flight runtime if you end up using the exports object.
|
763
|
-
case '$$typeof':
|
764
|
-
// These names are a little too common. We should probably have a way to
|
765
|
-
// have the Flight runtime extract the inner target instead.
|
766
|
-
return target.$$typeof;
|
767
|
-
|
768
|
-
case '$$id':
|
769
|
-
return target.$$id;
|
770
|
-
|
771
|
-
case '$$async':
|
772
|
-
return target.$$async;
|
773
|
-
|
774
|
-
case 'name':
|
775
|
-
return undefined;
|
776
|
-
|
777
|
-
case 'displayName':
|
778
|
-
return undefined;
|
779
|
-
// We need to special case this because createElement reads it if we pass this
|
780
|
-
// reference.
|
781
|
-
|
782
|
-
case 'defaultProps':
|
783
|
-
return undefined;
|
784
|
-
// Avoid this attempting to be serialized.
|
785
|
-
|
786
|
-
case 'toJSON':
|
787
|
-
return undefined;
|
788
|
-
|
789
|
-
case Symbol.toPrimitive:
|
790
|
-
// $FlowFixMe[prop-missing]
|
791
|
-
return Object.prototype[Symbol.toPrimitive];
|
792
|
-
|
793
|
-
case Symbol.toStringTag:
|
794
|
-
// $FlowFixMe[prop-missing]
|
795
|
-
return Object.prototype[Symbol.toStringTag];
|
796
|
-
|
797
|
-
case 'Provider':
|
798
|
-
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.");
|
799
|
-
}
|
800
|
-
|
801
|
-
throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion
|
802
|
-
"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.');
|
803
|
-
},
|
804
|
-
set: function () {
|
805
|
-
throw new Error('Cannot assign to a temporary client reference from a server module.');
|
806
|
-
}
|
807
|
-
};
|
808
|
-
function createTemporaryReference(id) {
|
809
|
-
var reference = Object.defineProperties(function () {
|
810
|
-
throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion
|
811
|
-
"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.");
|
812
|
-
}, {
|
813
|
-
$$typeof: {
|
814
|
-
value: TEMPORARY_REFERENCE_TAG
|
815
|
-
},
|
816
|
-
$$id: {
|
817
|
-
value: id
|
818
|
-
}
|
819
|
-
});
|
820
|
-
return new Proxy(reference, proxyHandlers);
|
821
|
-
}
|
822
|
-
|
823
|
-
// ATTENTION
|
824
|
-
// When adding new symbols to this file,
|
825
|
-
// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
|
826
|
-
// The Symbol used to tag the ReactElement-like types.
|
827
|
-
var REACT_ELEMENT_TYPE = Symbol.for('react.element');
|
828
|
-
var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
|
829
|
-
var REACT_CONTEXT_TYPE = Symbol.for('react.context');
|
830
|
-
var REACT_FORWARD_REF_TYPE = Symbol.for('react.forward_ref');
|
831
|
-
var REACT_SUSPENSE_TYPE = Symbol.for('react.suspense');
|
832
|
-
var REACT_SUSPENSE_LIST_TYPE = Symbol.for('react.suspense_list');
|
833
|
-
var REACT_MEMO_TYPE = Symbol.for('react.memo');
|
834
|
-
var REACT_LAZY_TYPE = Symbol.for('react.lazy');
|
835
|
-
var REACT_MEMO_CACHE_SENTINEL = Symbol.for('react.memo_cache_sentinel');
|
836
|
-
var REACT_POSTPONE_TYPE = Symbol.for('react.postpone');
|
837
|
-
var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
|
838
|
-
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
839
|
-
function getIteratorFn(maybeIterable) {
|
840
|
-
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
841
|
-
return null;
|
842
|
-
}
|
843
|
-
|
844
|
-
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
845
|
-
|
846
|
-
if (typeof maybeIterator === 'function') {
|
847
|
-
return maybeIterator;
|
848
|
-
}
|
849
|
-
|
850
|
-
return null;
|
851
|
-
}
|
852
|
-
|
853
|
-
// Corresponds to ReactFiberWakeable and ReactFizzWakeable modules. Generally,
|
854
|
-
// changes to one module should be reflected in the others.
|
855
|
-
// TODO: Rename this module and the corresponding Fiber one to "Thenable"
|
856
|
-
// instead of "Wakeable". Or some other more appropriate name.
|
857
|
-
// An error that is thrown (e.g. by `use`) to trigger Suspense. If we
|
858
|
-
// detect this is caught by userspace, we'll log a warning in development.
|
859
|
-
var SuspenseException = new Error("Suspense Exception: This is not a real error! It's an implementation " + 'detail of `use` to interrupt the current render. You must either ' + 'rethrow it immediately, or move the `use` call outside of the ' + '`try/catch` block. Capturing without rethrowing will lead to ' + 'unexpected behavior.\n\n' + 'To handle async errors, wrap your component in an error boundary, or ' + "call the promise's `.catch` method and pass the result to `use`");
|
860
|
-
function createThenableState() {
|
861
|
-
// The ThenableState is created the first time a component suspends. If it
|
862
|
-
// suspends again, we'll reuse the same state.
|
863
|
-
return [];
|
864
|
-
}
|
865
|
-
|
866
|
-
function noop() {}
|
867
|
-
|
868
|
-
function trackUsedThenable(thenableState, thenable, index) {
|
869
|
-
var previous = thenableState[index];
|
870
|
-
|
871
|
-
if (previous === undefined) {
|
872
|
-
thenableState.push(thenable);
|
873
|
-
} else {
|
874
|
-
if (previous !== thenable) {
|
875
|
-
// Reuse the previous thenable, and drop the new one. We can assume
|
876
|
-
// they represent the same value, because components are idempotent.
|
877
|
-
// Avoid an unhandled rejection errors for the Promises that we'll
|
878
|
-
// intentionally ignore.
|
879
|
-
thenable.then(noop, noop);
|
880
|
-
thenable = previous;
|
881
|
-
}
|
882
|
-
} // We use an expando to track the status and result of a thenable so that we
|
883
|
-
// can synchronously unwrap the value. Think of this as an extension of the
|
884
|
-
// Promise API, or a custom interface that is a superset of Thenable.
|
885
|
-
//
|
886
|
-
// If the thenable doesn't have a status, set it to "pending" and attach
|
887
|
-
// a listener that will update its status and result when it resolves.
|
888
|
-
|
889
|
-
|
890
|
-
switch (thenable.status) {
|
891
|
-
case 'fulfilled':
|
892
|
-
{
|
893
|
-
var fulfilledValue = thenable.value;
|
894
|
-
return fulfilledValue;
|
895
|
-
}
|
896
|
-
|
897
|
-
case 'rejected':
|
898
|
-
{
|
899
|
-
var rejectedError = thenable.reason;
|
900
|
-
throw rejectedError;
|
901
|
-
}
|
902
|
-
|
903
|
-
default:
|
904
|
-
{
|
905
|
-
if (typeof thenable.status === 'string') ; else {
|
906
|
-
var pendingThenable = thenable;
|
907
|
-
pendingThenable.status = 'pending';
|
908
|
-
pendingThenable.then(function (fulfilledValue) {
|
909
|
-
if (thenable.status === 'pending') {
|
910
|
-
var fulfilledThenable = thenable;
|
911
|
-
fulfilledThenable.status = 'fulfilled';
|
912
|
-
fulfilledThenable.value = fulfilledValue;
|
913
|
-
}
|
914
|
-
}, function (error) {
|
915
|
-
if (thenable.status === 'pending') {
|
916
|
-
var rejectedThenable = thenable;
|
917
|
-
rejectedThenable.status = 'rejected';
|
918
|
-
rejectedThenable.reason = error;
|
919
|
-
}
|
920
|
-
}); // Check one more time in case the thenable resolved synchronously
|
921
|
-
|
922
|
-
switch (thenable.status) {
|
923
|
-
case 'fulfilled':
|
924
|
-
{
|
925
|
-
var fulfilledThenable = thenable;
|
926
|
-
return fulfilledThenable.value;
|
927
|
-
}
|
928
|
-
|
929
|
-
case 'rejected':
|
930
|
-
{
|
931
|
-
var rejectedThenable = thenable;
|
932
|
-
throw rejectedThenable.reason;
|
933
|
-
}
|
934
|
-
}
|
935
|
-
} // Suspend.
|
936
|
-
//
|
937
|
-
// Throwing here is an implementation detail that allows us to unwind the
|
938
|
-
// call stack. But we shouldn't allow it to leak into userspace. Throw an
|
939
|
-
// opaque placeholder value instead of the actual thenable. If it doesn't
|
940
|
-
// get captured by the work loop, log a warning, because that means
|
941
|
-
// something in userspace must have caught it.
|
942
|
-
|
943
|
-
|
944
|
-
suspendedThenable = thenable;
|
945
|
-
throw SuspenseException;
|
946
|
-
}
|
947
|
-
}
|
948
|
-
} // This is used to track the actual thenable that suspended so it can be
|
949
|
-
// passed to the rest of the Suspense implementation — which, for historical
|
950
|
-
// reasons, expects to receive a thenable.
|
951
|
-
|
952
|
-
var suspendedThenable = null;
|
953
|
-
function getSuspendedThenable() {
|
954
|
-
// This is called right after `use` suspends by throwing an exception. `use`
|
955
|
-
// throws an opaque value instead of the thenable itself so that it can't be
|
956
|
-
// caught in userspace. Then the work loop accesses the actual thenable using
|
957
|
-
// this function.
|
958
|
-
if (suspendedThenable === null) {
|
959
|
-
throw new Error('Expected a suspended thenable. This is a bug in React. Please file ' + 'an issue.');
|
960
|
-
}
|
961
|
-
|
962
|
-
var thenable = suspendedThenable;
|
963
|
-
suspendedThenable = null;
|
964
|
-
return thenable;
|
965
|
-
}
|
966
|
-
|
967
|
-
var currentRequest$1 = null;
|
968
|
-
var thenableIndexCounter = 0;
|
969
|
-
var thenableState = null;
|
970
|
-
var currentComponentDebugInfo = null;
|
971
|
-
function prepareToUseHooksForRequest(request) {
|
972
|
-
currentRequest$1 = request;
|
973
|
-
}
|
974
|
-
function resetHooksForRequest() {
|
975
|
-
currentRequest$1 = null;
|
976
|
-
}
|
977
|
-
function prepareToUseHooksForComponent(prevThenableState, componentDebugInfo) {
|
978
|
-
thenableIndexCounter = 0;
|
979
|
-
thenableState = prevThenableState;
|
980
|
-
|
981
|
-
{
|
982
|
-
currentComponentDebugInfo = componentDebugInfo;
|
983
|
-
}
|
984
|
-
}
|
985
|
-
function getThenableStateAfterSuspending() {
|
986
|
-
// If you use() to Suspend this should always exist but if you throw a Promise instead,
|
987
|
-
// which is not really supported anymore, it will be empty. We use the empty set as a
|
988
|
-
// marker to know if this was a replay of the same component or first attempt.
|
989
|
-
var state = thenableState || createThenableState();
|
990
|
-
|
991
|
-
{
|
992
|
-
// This is a hack but we stash the debug info here so that we don't need a completely
|
993
|
-
// different data structure just for this in DEV. Not too happy about it.
|
994
|
-
state._componentDebugInfo = currentComponentDebugInfo;
|
995
|
-
currentComponentDebugInfo = null;
|
996
|
-
}
|
997
|
-
|
998
|
-
thenableState = null;
|
999
|
-
return state;
|
1000
|
-
}
|
1001
|
-
var HooksDispatcher = {
|
1002
|
-
useMemo: function (nextCreate) {
|
1003
|
-
return nextCreate();
|
1004
|
-
},
|
1005
|
-
useCallback: function (callback) {
|
1006
|
-
return callback;
|
1007
|
-
},
|
1008
|
-
useDebugValue: function () {},
|
1009
|
-
useDeferredValue: unsupportedHook,
|
1010
|
-
useTransition: unsupportedHook,
|
1011
|
-
readContext: unsupportedContext,
|
1012
|
-
useContext: unsupportedContext,
|
1013
|
-
useReducer: unsupportedHook,
|
1014
|
-
useRef: unsupportedHook,
|
1015
|
-
useState: unsupportedHook,
|
1016
|
-
useInsertionEffect: unsupportedHook,
|
1017
|
-
useLayoutEffect: unsupportedHook,
|
1018
|
-
useImperativeHandle: unsupportedHook,
|
1019
|
-
useEffect: unsupportedHook,
|
1020
|
-
useId: useId,
|
1021
|
-
useSyncExternalStore: unsupportedHook,
|
1022
|
-
useCacheRefresh: function () {
|
1023
|
-
return unsupportedRefresh;
|
1024
|
-
},
|
1025
|
-
useMemoCache: function (size) {
|
1026
|
-
var data = new Array(size);
|
1027
|
-
|
1028
|
-
for (var i = 0; i < size; i++) {
|
1029
|
-
data[i] = REACT_MEMO_CACHE_SENTINEL;
|
1030
|
-
}
|
1031
|
-
|
1032
|
-
return data;
|
1033
|
-
},
|
1034
|
-
use: use
|
1035
|
-
};
|
1036
|
-
|
1037
|
-
function unsupportedHook() {
|
1038
|
-
throw new Error('This Hook is not supported in Server Components.');
|
1039
|
-
}
|
1040
|
-
|
1041
|
-
function unsupportedRefresh() {
|
1042
|
-
throw new Error('Refreshing the cache is not supported in Server Components.');
|
1043
|
-
}
|
1044
|
-
|
1045
|
-
function unsupportedContext() {
|
1046
|
-
throw new Error('Cannot read a Client Context from a Server Component.');
|
1047
|
-
}
|
1048
|
-
|
1049
|
-
function useId() {
|
1050
|
-
if (currentRequest$1 === null) {
|
1051
|
-
throw new Error('useId can only be used while React is rendering');
|
1052
|
-
}
|
1053
|
-
|
1054
|
-
var id = currentRequest$1.identifierCount++; // use 'S' for Flight components to distinguish from 'R' and 'r' in Fizz/Client
|
1055
|
-
|
1056
|
-
return ':' + currentRequest$1.identifierPrefix + 'S' + id.toString(32) + ':';
|
1057
|
-
}
|
1058
|
-
|
1059
|
-
function use(usable) {
|
1060
|
-
if (usable !== null && typeof usable === 'object' || typeof usable === 'function') {
|
1061
|
-
// $FlowFixMe[method-unbinding]
|
1062
|
-
if (typeof usable.then === 'function') {
|
1063
|
-
// This is a thenable.
|
1064
|
-
var thenable = usable; // Track the position of the thenable within this fiber.
|
1065
|
-
|
1066
|
-
var index = thenableIndexCounter;
|
1067
|
-
thenableIndexCounter += 1;
|
1068
|
-
|
1069
|
-
if (thenableState === null) {
|
1070
|
-
thenableState = createThenableState();
|
1071
|
-
}
|
1072
|
-
|
1073
|
-
return trackUsedThenable(thenableState, thenable, index);
|
1074
|
-
} else if (usable.$$typeof === REACT_CONTEXT_TYPE) {
|
1075
|
-
unsupportedContext();
|
1076
|
-
}
|
1077
|
-
}
|
1078
|
-
|
1079
|
-
if (isClientReference(usable)) {
|
1080
|
-
if (usable.value != null && usable.value.$$typeof === REACT_CONTEXT_TYPE) {
|
1081
|
-
// Show a more specific message since it's a common mistake.
|
1082
|
-
throw new Error('Cannot read a Client Context from a Server Component.');
|
1083
|
-
} else {
|
1084
|
-
throw new Error('Cannot use() an already resolved Client Reference.');
|
1085
|
-
}
|
1086
|
-
} else {
|
1087
|
-
throw new Error( // eslint-disable-next-line react-internal/safe-string-coercion
|
1088
|
-
'An unsupported type was passed to use(): ' + String(usable));
|
1089
|
-
}
|
1090
|
-
}
|
1091
|
-
|
1092
|
-
function resolveCache() {
|
1093
|
-
var request = resolveRequest();
|
1094
|
-
|
1095
|
-
if (request) {
|
1096
|
-
return getCache(request);
|
1097
|
-
}
|
1098
|
-
|
1099
|
-
return new Map();
|
1100
|
-
}
|
1101
|
-
|
1102
|
-
var DefaultCacheDispatcher = {
|
1103
|
-
getCacheForType: function (resourceType) {
|
1104
|
-
var cache = resolveCache();
|
1105
|
-
var entry = cache.get(resourceType);
|
1106
|
-
|
1107
|
-
if (entry === undefined) {
|
1108
|
-
entry = resourceType(); // TODO: Warn if undefined?
|
1109
|
-
|
1110
|
-
cache.set(resourceType, entry);
|
1111
|
-
}
|
1112
|
-
|
1113
|
-
return entry;
|
1114
|
-
}
|
1115
|
-
};
|
1116
|
-
|
1117
|
-
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
|
1118
|
-
|
1119
|
-
function isArray(a) {
|
1120
|
-
return isArrayImpl(a);
|
1121
|
-
}
|
1122
|
-
|
1123
|
-
var getPrototypeOf = Object.getPrototypeOf;
|
1124
|
-
|
1125
|
-
// in case they error.
|
1126
|
-
|
1127
|
-
var jsxPropsParents = new WeakMap();
|
1128
|
-
var jsxChildrenParents = new WeakMap();
|
1129
|
-
|
1130
|
-
function isObjectPrototype(object) {
|
1131
|
-
if (!object) {
|
1132
|
-
return false;
|
1133
|
-
}
|
1134
|
-
|
1135
|
-
var ObjectPrototype = Object.prototype;
|
1136
|
-
|
1137
|
-
if (object === ObjectPrototype) {
|
1138
|
-
return true;
|
1139
|
-
} // It might be an object from a different Realm which is
|
1140
|
-
// still just a plain simple object.
|
1141
|
-
|
1142
|
-
|
1143
|
-
if (getPrototypeOf(object)) {
|
1144
|
-
return false;
|
1145
|
-
}
|
1146
|
-
|
1147
|
-
var names = Object.getOwnPropertyNames(object);
|
1148
|
-
|
1149
|
-
for (var i = 0; i < names.length; i++) {
|
1150
|
-
if (!(names[i] in ObjectPrototype)) {
|
1151
|
-
return false;
|
1152
|
-
}
|
1153
|
-
}
|
1154
|
-
|
1155
|
-
return true;
|
1156
|
-
}
|
1157
|
-
|
1158
|
-
function isSimpleObject(object) {
|
1159
|
-
if (!isObjectPrototype(getPrototypeOf(object))) {
|
1160
|
-
return false;
|
1161
|
-
}
|
1162
|
-
|
1163
|
-
var names = Object.getOwnPropertyNames(object);
|
1164
|
-
|
1165
|
-
for (var i = 0; i < names.length; i++) {
|
1166
|
-
var descriptor = Object.getOwnPropertyDescriptor(object, names[i]);
|
1167
|
-
|
1168
|
-
if (!descriptor) {
|
1169
|
-
return false;
|
1170
|
-
}
|
1171
|
-
|
1172
|
-
if (!descriptor.enumerable) {
|
1173
|
-
if ((names[i] === 'key' || names[i] === 'ref') && typeof descriptor.get === 'function') {
|
1174
|
-
// React adds key and ref getters to props objects to issue warnings.
|
1175
|
-
// Those getters will not be transferred to the client, but that's ok,
|
1176
|
-
// so we'll special case them.
|
1177
|
-
continue;
|
1178
|
-
}
|
1179
|
-
|
1180
|
-
return false;
|
1181
|
-
}
|
1182
|
-
}
|
1183
|
-
|
1184
|
-
return true;
|
1185
|
-
}
|
1186
|
-
function objectName(object) {
|
1187
|
-
// $FlowFixMe[method-unbinding]
|
1188
|
-
var name = Object.prototype.toString.call(object);
|
1189
|
-
return name.replace(/^\[object (.*)\]$/, function (m, p0) {
|
1190
|
-
return p0;
|
1191
|
-
});
|
1192
|
-
}
|
1193
|
-
|
1194
|
-
function describeKeyForErrorMessage(key) {
|
1195
|
-
var encodedKey = JSON.stringify(key);
|
1196
|
-
return '"' + key + '"' === encodedKey ? key : encodedKey;
|
1197
|
-
}
|
1198
|
-
|
1199
|
-
function describeValueForErrorMessage(value) {
|
1200
|
-
switch (typeof value) {
|
1201
|
-
case 'string':
|
1202
|
-
{
|
1203
|
-
return JSON.stringify(value.length <= 10 ? value : value.slice(0, 10) + '...');
|
1204
|
-
}
|
1205
|
-
|
1206
|
-
case 'object':
|
1207
|
-
{
|
1208
|
-
if (isArray(value)) {
|
1209
|
-
return '[...]';
|
1210
|
-
}
|
1211
|
-
|
1212
|
-
if (value !== null && value.$$typeof === CLIENT_REFERENCE_TAG) {
|
1213
|
-
return describeClientReference();
|
1214
|
-
}
|
1215
|
-
|
1216
|
-
var name = objectName(value);
|
1217
|
-
|
1218
|
-
if (name === 'Object') {
|
1219
|
-
return '{...}';
|
1220
|
-
}
|
1221
|
-
|
1222
|
-
return name;
|
1223
|
-
}
|
1224
|
-
|
1225
|
-
case 'function':
|
1226
|
-
{
|
1227
|
-
if (value.$$typeof === CLIENT_REFERENCE_TAG) {
|
1228
|
-
return describeClientReference();
|
1229
|
-
}
|
1230
|
-
|
1231
|
-
var _name = value.displayName || value.name;
|
1232
|
-
|
1233
|
-
return _name ? 'function ' + _name : 'function';
|
1234
|
-
}
|
1235
|
-
|
1236
|
-
default:
|
1237
|
-
// eslint-disable-next-line react-internal/safe-string-coercion
|
1238
|
-
return String(value);
|
1239
|
-
}
|
1240
|
-
}
|
1241
|
-
|
1242
|
-
function describeElementType(type) {
|
1243
|
-
if (typeof type === 'string') {
|
1244
|
-
return type;
|
1245
|
-
}
|
1246
|
-
|
1247
|
-
switch (type) {
|
1248
|
-
case REACT_SUSPENSE_TYPE:
|
1249
|
-
return 'Suspense';
|
1250
|
-
|
1251
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
1252
|
-
return 'SuspenseList';
|
1253
|
-
}
|
1254
|
-
|
1255
|
-
if (typeof type === 'object') {
|
1256
|
-
switch (type.$$typeof) {
|
1257
|
-
case REACT_FORWARD_REF_TYPE:
|
1258
|
-
return describeElementType(type.render);
|
1259
|
-
|
1260
|
-
case REACT_MEMO_TYPE:
|
1261
|
-
return describeElementType(type.type);
|
1262
|
-
|
1263
|
-
case REACT_LAZY_TYPE:
|
1264
|
-
{
|
1265
|
-
var lazyComponent = type;
|
1266
|
-
var payload = lazyComponent._payload;
|
1267
|
-
var init = lazyComponent._init;
|
1268
|
-
|
1269
|
-
try {
|
1270
|
-
// Lazy may contain any component type so we recursively resolve it.
|
1271
|
-
return describeElementType(init(payload));
|
1272
|
-
} catch (x) {}
|
1273
|
-
}
|
1274
|
-
}
|
1275
|
-
}
|
1276
|
-
|
1277
|
-
return '';
|
1278
|
-
}
|
1279
|
-
|
1280
|
-
var CLIENT_REFERENCE_TAG = Symbol.for('react.client.reference');
|
1281
|
-
|
1282
|
-
function describeClientReference(ref) {
|
1283
|
-
return 'client';
|
1284
|
-
}
|
1285
|
-
|
1286
|
-
function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
1287
|
-
var objKind = objectName(objectOrArray);
|
1288
|
-
|
1289
|
-
if (objKind !== 'Object' && objKind !== 'Array') {
|
1290
|
-
return objKind;
|
1291
|
-
}
|
1292
|
-
|
1293
|
-
var str = '';
|
1294
|
-
var start = -1;
|
1295
|
-
var length = 0;
|
1296
|
-
|
1297
|
-
if (isArray(objectOrArray)) {
|
1298
|
-
if (jsxChildrenParents.has(objectOrArray)) {
|
1299
|
-
// Print JSX Children
|
1300
|
-
var type = jsxChildrenParents.get(objectOrArray);
|
1301
|
-
str = '<' + describeElementType(type) + '>';
|
1302
|
-
var array = objectOrArray;
|
1303
|
-
|
1304
|
-
for (var i = 0; i < array.length; i++) {
|
1305
|
-
var value = array[i];
|
1306
|
-
var substr = void 0;
|
1307
|
-
|
1308
|
-
if (typeof value === 'string') {
|
1309
|
-
substr = value;
|
1310
|
-
} else if (typeof value === 'object' && value !== null) {
|
1311
|
-
substr = '{' + describeObjectForErrorMessage(value) + '}';
|
1312
|
-
} else {
|
1313
|
-
substr = '{' + describeValueForErrorMessage(value) + '}';
|
1314
|
-
}
|
1315
|
-
|
1316
|
-
if ('' + i === expandedName) {
|
1317
|
-
start = str.length;
|
1318
|
-
length = substr.length;
|
1319
|
-
str += substr;
|
1320
|
-
} else if (substr.length < 15 && str.length + substr.length < 40) {
|
1321
|
-
str += substr;
|
1322
|
-
} else {
|
1323
|
-
str += '{...}';
|
1324
|
-
}
|
1325
|
-
}
|
1326
|
-
|
1327
|
-
str += '</' + describeElementType(type) + '>';
|
1328
|
-
} else {
|
1329
|
-
// Print Array
|
1330
|
-
str = '[';
|
1331
|
-
var _array = objectOrArray;
|
1332
|
-
|
1333
|
-
for (var _i = 0; _i < _array.length; _i++) {
|
1334
|
-
if (_i > 0) {
|
1335
|
-
str += ', ';
|
1336
|
-
}
|
1337
|
-
|
1338
|
-
var _value = _array[_i];
|
1339
|
-
|
1340
|
-
var _substr = void 0;
|
1341
|
-
|
1342
|
-
if (typeof _value === 'object' && _value !== null) {
|
1343
|
-
_substr = describeObjectForErrorMessage(_value);
|
1344
|
-
} else {
|
1345
|
-
_substr = describeValueForErrorMessage(_value);
|
1346
|
-
}
|
1347
|
-
|
1348
|
-
if ('' + _i === expandedName) {
|
1349
|
-
start = str.length;
|
1350
|
-
length = _substr.length;
|
1351
|
-
str += _substr;
|
1352
|
-
} else if (_substr.length < 10 && str.length + _substr.length < 40) {
|
1353
|
-
str += _substr;
|
1354
|
-
} else {
|
1355
|
-
str += '...';
|
1356
|
-
}
|
1357
|
-
}
|
1358
|
-
|
1359
|
-
str += ']';
|
1360
|
-
}
|
1361
|
-
} else {
|
1362
|
-
if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
|
1363
|
-
str = '<' + describeElementType(objectOrArray.type) + '/>';
|
1364
|
-
} else if (objectOrArray.$$typeof === CLIENT_REFERENCE_TAG) {
|
1365
|
-
return describeClientReference();
|
1366
|
-
} else if (jsxPropsParents.has(objectOrArray)) {
|
1367
|
-
// Print JSX
|
1368
|
-
var _type = jsxPropsParents.get(objectOrArray);
|
1369
|
-
|
1370
|
-
str = '<' + (describeElementType(_type) || '...');
|
1371
|
-
var object = objectOrArray;
|
1372
|
-
var names = Object.keys(object);
|
1373
|
-
|
1374
|
-
for (var _i2 = 0; _i2 < names.length; _i2++) {
|
1375
|
-
str += ' ';
|
1376
|
-
var name = names[_i2];
|
1377
|
-
str += describeKeyForErrorMessage(name) + '=';
|
1378
|
-
var _value2 = object[name];
|
1379
|
-
|
1380
|
-
var _substr2 = void 0;
|
1381
|
-
|
1382
|
-
if (name === expandedName && typeof _value2 === 'object' && _value2 !== null) {
|
1383
|
-
_substr2 = describeObjectForErrorMessage(_value2);
|
1384
|
-
} else {
|
1385
|
-
_substr2 = describeValueForErrorMessage(_value2);
|
1386
|
-
}
|
1387
|
-
|
1388
|
-
if (typeof _value2 !== 'string') {
|
1389
|
-
_substr2 = '{' + _substr2 + '}';
|
1390
|
-
}
|
1391
|
-
|
1392
|
-
if (name === expandedName) {
|
1393
|
-
start = str.length;
|
1394
|
-
length = _substr2.length;
|
1395
|
-
str += _substr2;
|
1396
|
-
} else if (_substr2.length < 10 && str.length + _substr2.length < 40) {
|
1397
|
-
str += _substr2;
|
1398
|
-
} else {
|
1399
|
-
str += '...';
|
1400
|
-
}
|
1401
|
-
}
|
1402
|
-
|
1403
|
-
str += '>';
|
1404
|
-
} else {
|
1405
|
-
// Print Object
|
1406
|
-
str = '{';
|
1407
|
-
var _object = objectOrArray;
|
1408
|
-
|
1409
|
-
var _names = Object.keys(_object);
|
1410
|
-
|
1411
|
-
for (var _i3 = 0; _i3 < _names.length; _i3++) {
|
1412
|
-
if (_i3 > 0) {
|
1413
|
-
str += ', ';
|
1414
|
-
}
|
1415
|
-
|
1416
|
-
var _name2 = _names[_i3];
|
1417
|
-
str += describeKeyForErrorMessage(_name2) + ': ';
|
1418
|
-
var _value3 = _object[_name2];
|
1419
|
-
|
1420
|
-
var _substr3 = void 0;
|
1421
|
-
|
1422
|
-
if (typeof _value3 === 'object' && _value3 !== null) {
|
1423
|
-
_substr3 = describeObjectForErrorMessage(_value3);
|
1424
|
-
} else {
|
1425
|
-
_substr3 = describeValueForErrorMessage(_value3);
|
1426
|
-
}
|
1427
|
-
|
1428
|
-
if (_name2 === expandedName) {
|
1429
|
-
start = str.length;
|
1430
|
-
length = _substr3.length;
|
1431
|
-
str += _substr3;
|
1432
|
-
} else if (_substr3.length < 10 && str.length + _substr3.length < 40) {
|
1433
|
-
str += _substr3;
|
1434
|
-
} else {
|
1435
|
-
str += '...';
|
1436
|
-
}
|
1437
|
-
}
|
1438
|
-
|
1439
|
-
str += '}';
|
1440
|
-
}
|
1441
|
-
}
|
1442
|
-
|
1443
|
-
if (expandedName === undefined) {
|
1444
|
-
return str;
|
1445
|
-
}
|
1446
|
-
|
1447
|
-
if (start > -1 && length > 0) {
|
1448
|
-
var highlight = ' '.repeat(start) + '^'.repeat(length);
|
1449
|
-
return '\n ' + str + '\n ' + highlight;
|
1450
|
-
}
|
1451
|
-
|
1452
|
-
return '\n ' + str;
|
1453
|
-
}
|
1454
|
-
|
1455
|
-
var ReactSharedInternals = ReactSharedInternalsServer;
|
1456
|
-
|
1457
|
-
var ObjectPrototype = Object.prototype;
|
1458
|
-
var stringify = JSON.stringify; // Serializable values
|
1459
|
-
// Thenable<ReactClientValue>
|
1460
|
-
// task status
|
1461
|
-
|
1462
|
-
var PENDING$1 = 0;
|
1463
|
-
var COMPLETED = 1;
|
1464
|
-
var ABORTED = 3;
|
1465
|
-
var ERRORED$1 = 4; // object reference status
|
1466
|
-
|
1467
|
-
var SEEN_BUT_NOT_YET_OUTLINED = -1;
|
1468
|
-
var NEVER_OUTLINED = -2;
|
1469
|
-
|
1470
|
-
function defaultErrorHandler(error) {
|
1471
|
-
console['error'](error); // Don't transform to our wrapper
|
1472
|
-
}
|
1473
|
-
|
1474
|
-
function defaultPostponeHandler(reason) {// Noop
|
1475
|
-
}
|
1476
|
-
|
1477
|
-
var OPEN = 0;
|
1478
|
-
var CLOSING = 1;
|
1479
|
-
var CLOSED = 2;
|
1480
|
-
function createRequest(model, bundlerConfig, onError, identifierPrefix, onPostpone, environmentName) {
|
1481
|
-
if (ReactSharedInternals.C !== null && ReactSharedInternals.C !== DefaultCacheDispatcher) {
|
1482
|
-
throw new Error('Currently React only supports one RSC renderer at a time.');
|
1483
|
-
}
|
1484
|
-
|
1485
|
-
ReactSharedInternals.C = DefaultCacheDispatcher;
|
1486
|
-
var abortSet = new Set();
|
1487
|
-
var pingedTasks = [];
|
1488
|
-
var cleanupQueue = [];
|
1489
|
-
|
1490
|
-
var hints = createHints();
|
1491
|
-
var request = {
|
1492
|
-
status: OPEN,
|
1493
|
-
flushScheduled: false,
|
1494
|
-
fatalError: null,
|
1495
|
-
destination: null,
|
1496
|
-
bundlerConfig: bundlerConfig,
|
1497
|
-
cache: new Map(),
|
1498
|
-
nextChunkId: 0,
|
1499
|
-
pendingChunks: 0,
|
1500
|
-
hints: hints,
|
1501
|
-
abortableTasks: abortSet,
|
1502
|
-
pingedTasks: pingedTasks,
|
1503
|
-
completedImportChunks: [],
|
1504
|
-
completedHintChunks: [],
|
1505
|
-
completedRegularChunks: [],
|
1506
|
-
completedErrorChunks: [],
|
1507
|
-
writtenSymbols: new Map(),
|
1508
|
-
writtenClientReferences: new Map(),
|
1509
|
-
writtenServerReferences: new Map(),
|
1510
|
-
writtenObjects: new WeakMap(),
|
1511
|
-
identifierPrefix: identifierPrefix || '',
|
1512
|
-
identifierCount: 1,
|
1513
|
-
taintCleanupQueue: cleanupQueue,
|
1514
|
-
onError: onError === undefined ? defaultErrorHandler : onError,
|
1515
|
-
onPostpone: onPostpone === undefined ? defaultPostponeHandler : onPostpone
|
1516
|
-
};
|
1517
|
-
|
1518
|
-
{
|
1519
|
-
request.environmentName = environmentName === undefined ? 'Server' : environmentName;
|
1520
|
-
}
|
1521
|
-
|
1522
|
-
var rootTask = createTask(request, model, null, false, abortSet);
|
1523
|
-
pingedTasks.push(rootTask);
|
1524
|
-
return request;
|
1525
|
-
}
|
1526
|
-
var currentRequest = null;
|
1527
|
-
function resolveRequest() {
|
1528
|
-
if (currentRequest) return currentRequest;
|
1529
|
-
|
1530
|
-
return null;
|
1531
|
-
}
|
1532
|
-
|
1533
|
-
function serializeThenable(request, task, thenable) {
|
1534
|
-
var newTask = createTask(request, null, task.keyPath, // the server component sequence continues through Promise-as-a-child.
|
1535
|
-
task.implicitSlot, request.abortableTasks);
|
1536
|
-
|
1537
|
-
{
|
1538
|
-
// If this came from Flight, forward any debug info into this new row.
|
1539
|
-
var debugInfo = thenable._debugInfo;
|
1540
|
-
|
1541
|
-
if (debugInfo) {
|
1542
|
-
forwardDebugInfo(request, newTask.id, debugInfo);
|
1543
|
-
}
|
1544
|
-
}
|
1545
|
-
|
1546
|
-
switch (thenable.status) {
|
1547
|
-
case 'fulfilled':
|
1548
|
-
{
|
1549
|
-
// We have the resolved value, we can go ahead and schedule it for serialization.
|
1550
|
-
newTask.model = thenable.value;
|
1551
|
-
pingTask(request, newTask);
|
1552
|
-
return newTask.id;
|
1553
|
-
}
|
1554
|
-
|
1555
|
-
case 'rejected':
|
1556
|
-
{
|
1557
|
-
var x = thenable.reason;
|
1558
|
-
|
1559
|
-
{
|
1560
|
-
var digest = logRecoverableError(request, x);
|
1561
|
-
emitErrorChunk(request, newTask.id, digest, x);
|
1562
|
-
}
|
1563
|
-
|
1564
|
-
return newTask.id;
|
1565
|
-
}
|
1566
|
-
|
1567
|
-
default:
|
1568
|
-
{
|
1569
|
-
if (typeof thenable.status === 'string') {
|
1570
|
-
// Only instrument the thenable if the status if not defined. If
|
1571
|
-
// it's defined, but an unknown value, assume it's been instrumented by
|
1572
|
-
// some custom userspace implementation. We treat it as "pending".
|
1573
|
-
break;
|
1574
|
-
}
|
1575
|
-
|
1576
|
-
var pendingThenable = thenable;
|
1577
|
-
pendingThenable.status = 'pending';
|
1578
|
-
pendingThenable.then(function (fulfilledValue) {
|
1579
|
-
if (thenable.status === 'pending') {
|
1580
|
-
var fulfilledThenable = thenable;
|
1581
|
-
fulfilledThenable.status = 'fulfilled';
|
1582
|
-
fulfilledThenable.value = fulfilledValue;
|
1583
|
-
}
|
1584
|
-
}, function (error) {
|
1585
|
-
if (thenable.status === 'pending') {
|
1586
|
-
var rejectedThenable = thenable;
|
1587
|
-
rejectedThenable.status = 'rejected';
|
1588
|
-
rejectedThenable.reason = error;
|
1589
|
-
}
|
1590
|
-
});
|
1591
|
-
break;
|
1592
|
-
}
|
1593
|
-
}
|
1594
|
-
|
1595
|
-
thenable.then(function (value) {
|
1596
|
-
newTask.model = value;
|
1597
|
-
pingTask(request, newTask);
|
1598
|
-
}, function (reason) {
|
1599
|
-
{
|
1600
|
-
newTask.status = ERRORED$1;
|
1601
|
-
|
1602
|
-
var _digest = logRecoverableError(request, reason);
|
1603
|
-
|
1604
|
-
emitErrorChunk(request, newTask.id, _digest, reason);
|
1605
|
-
}
|
1606
|
-
|
1607
|
-
request.abortableTasks.delete(newTask);
|
1608
|
-
|
1609
|
-
if (request.destination !== null) {
|
1610
|
-
flushCompletedChunks(request, request.destination);
|
1611
|
-
}
|
1612
|
-
});
|
1613
|
-
return newTask.id;
|
1614
|
-
}
|
1615
|
-
|
1616
|
-
function emitHint(request, code, model) {
|
1617
|
-
emitHintChunk(request, code, model);
|
1618
|
-
enqueueFlush(request);
|
1619
|
-
}
|
1620
|
-
function getHints(request) {
|
1621
|
-
return request.hints;
|
1622
|
-
}
|
1623
|
-
function getCache(request) {
|
1624
|
-
return request.cache;
|
1625
|
-
}
|
1626
|
-
|
1627
|
-
function readThenable(thenable) {
|
1628
|
-
if (thenable.status === 'fulfilled') {
|
1629
|
-
return thenable.value;
|
1630
|
-
} else if (thenable.status === 'rejected') {
|
1631
|
-
throw thenable.reason;
|
1632
|
-
}
|
1633
|
-
|
1634
|
-
throw thenable;
|
1635
|
-
}
|
1636
|
-
|
1637
|
-
function createLazyWrapperAroundWakeable(wakeable) {
|
1638
|
-
// This is a temporary fork of the `use` implementation until we accept
|
1639
|
-
// promises everywhere.
|
1640
|
-
var thenable = wakeable;
|
1641
|
-
|
1642
|
-
switch (thenable.status) {
|
1643
|
-
case 'fulfilled':
|
1644
|
-
case 'rejected':
|
1645
|
-
break;
|
1646
|
-
|
1647
|
-
default:
|
1648
|
-
{
|
1649
|
-
if (typeof thenable.status === 'string') {
|
1650
|
-
// Only instrument the thenable if the status if not defined. If
|
1651
|
-
// it's defined, but an unknown value, assume it's been instrumented by
|
1652
|
-
// some custom userspace implementation. We treat it as "pending".
|
1653
|
-
break;
|
1654
|
-
}
|
1655
|
-
|
1656
|
-
var pendingThenable = thenable;
|
1657
|
-
pendingThenable.status = 'pending';
|
1658
|
-
pendingThenable.then(function (fulfilledValue) {
|
1659
|
-
if (thenable.status === 'pending') {
|
1660
|
-
var fulfilledThenable = thenable;
|
1661
|
-
fulfilledThenable.status = 'fulfilled';
|
1662
|
-
fulfilledThenable.value = fulfilledValue;
|
1663
|
-
}
|
1664
|
-
}, function (error) {
|
1665
|
-
if (thenable.status === 'pending') {
|
1666
|
-
var rejectedThenable = thenable;
|
1667
|
-
rejectedThenable.status = 'rejected';
|
1668
|
-
rejectedThenable.reason = error;
|
1669
|
-
}
|
1670
|
-
});
|
1671
|
-
break;
|
1672
|
-
}
|
1673
|
-
}
|
1674
|
-
|
1675
|
-
var lazyType = {
|
1676
|
-
$$typeof: REACT_LAZY_TYPE,
|
1677
|
-
_payload: thenable,
|
1678
|
-
_init: readThenable
|
1679
|
-
};
|
1680
|
-
|
1681
|
-
{
|
1682
|
-
// If this came from React, transfer the debug info.
|
1683
|
-
lazyType._debugInfo = thenable._debugInfo || [];
|
1684
|
-
}
|
1685
|
-
|
1686
|
-
return lazyType;
|
1687
|
-
}
|
1688
|
-
|
1689
|
-
function renderFunctionComponent(request, task, key, Component, props, owner) {
|
1690
|
-
// Reset the task's thenable state before continuing, so that if a later
|
1691
|
-
// component suspends we can reuse the same task object. If the same
|
1692
|
-
// component suspends again, the thenable state will be restored.
|
1693
|
-
var prevThenableState = task.thenableState;
|
1694
|
-
task.thenableState = null;
|
1695
|
-
var componentDebugInfo = null;
|
1696
|
-
|
1697
|
-
{
|
1698
|
-
if (debugID === null) {
|
1699
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
1700
|
-
// component to assign it an ID.
|
1701
|
-
return outlineTask(request, task);
|
1702
|
-
} else if (prevThenableState !== null) {
|
1703
|
-
// This is a replay and we've already emitted the debug info of this component
|
1704
|
-
// in the first pass. We skip emitting a duplicate line.
|
1705
|
-
// As a hack we stashed the previous component debug info on this object in DEV.
|
1706
|
-
componentDebugInfo = prevThenableState._componentDebugInfo;
|
1707
|
-
} else {
|
1708
|
-
// This is a new component in the same task so we can emit more debug info.
|
1709
|
-
var componentName = Component.displayName || Component.name || '';
|
1710
|
-
request.pendingChunks++;
|
1711
|
-
var componentDebugID = debugID;
|
1712
|
-
componentDebugInfo = {
|
1713
|
-
name: componentName,
|
1714
|
-
env: request.environmentName,
|
1715
|
-
owner: owner
|
1716
|
-
}; // We outline this model eagerly so that we can refer to by reference as an owner.
|
1717
|
-
// If we had a smarter way to dedupe we might not have to do this if there ends up
|
1718
|
-
// being no references to this as an owner.
|
1719
|
-
|
1720
|
-
outlineModel(request, componentDebugInfo);
|
1721
|
-
emitDebugChunk(request, componentDebugID, componentDebugInfo);
|
1722
|
-
}
|
1723
|
-
}
|
1724
|
-
|
1725
|
-
prepareToUseHooksForComponent(prevThenableState, componentDebugInfo); // The secondArg is always undefined in Server Components since refs error early.
|
1726
|
-
|
1727
|
-
var secondArg = undefined;
|
1728
|
-
var result;
|
1729
|
-
|
1730
|
-
{
|
1731
|
-
ReactSharedInternals.owner = componentDebugInfo;
|
1732
|
-
|
1733
|
-
try {
|
1734
|
-
result = Component(props, secondArg);
|
1735
|
-
} finally {
|
1736
|
-
ReactSharedInternals.owner = null;
|
1737
|
-
}
|
1738
|
-
}
|
1739
|
-
|
1740
|
-
if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
|
1741
|
-
// When the return value is in children position we can resolve it immediately,
|
1742
|
-
// to its value without a wrapper if it's synchronously available.
|
1743
|
-
var thenable = result;
|
1744
|
-
|
1745
|
-
if (thenable.status === 'fulfilled') {
|
1746
|
-
return thenable.value;
|
1747
|
-
} // TODO: Once we accept Promises as children on the client, we can just return
|
1748
|
-
// the thenable here.
|
1749
|
-
|
1750
|
-
|
1751
|
-
result = createLazyWrapperAroundWakeable(result);
|
1752
|
-
} // Track this element's key on the Server Component on the keyPath context..
|
1753
|
-
|
1754
|
-
|
1755
|
-
var prevKeyPath = task.keyPath;
|
1756
|
-
var prevImplicitSlot = task.implicitSlot;
|
1757
|
-
|
1758
|
-
if (key !== null) {
|
1759
|
-
// Append the key to the path. Technically a null key should really add the child
|
1760
|
-
// index. We don't do that to hold the payload small and implementation simple.
|
1761
|
-
task.keyPath = prevKeyPath === null ? key : prevKeyPath + ',' + key;
|
1762
|
-
} else if (prevKeyPath === null) {
|
1763
|
-
// This sequence of Server Components has no keys. This means that it was rendered
|
1764
|
-
// in a slot that needs to assign an implicit key. Even if children below have
|
1765
|
-
// explicit keys, they should not be used for the outer most key since it might
|
1766
|
-
// collide with other slots in that set.
|
1767
|
-
task.implicitSlot = true;
|
1768
|
-
}
|
1769
|
-
|
1770
|
-
var json = renderModelDestructive(request, task, emptyRoot, '', result);
|
1771
|
-
task.keyPath = prevKeyPath;
|
1772
|
-
task.implicitSlot = prevImplicitSlot;
|
1773
|
-
return json;
|
1774
|
-
}
|
1775
|
-
|
1776
|
-
function renderFragment(request, task, children) {
|
1777
|
-
{
|
1778
|
-
var debugInfo = children._debugInfo;
|
1779
|
-
|
1780
|
-
if (debugInfo) {
|
1781
|
-
// If this came from Flight, forward any debug info into this new row.
|
1782
|
-
if (debugID === null) {
|
1783
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
1784
|
-
// component to assign it an ID.
|
1785
|
-
return outlineTask(request, task);
|
1786
|
-
} else {
|
1787
|
-
// Forward any debug info we have the first time we see it.
|
1788
|
-
// We do this after init so that we have received all the debug info
|
1789
|
-
// from the server by the time we emit it.
|
1790
|
-
forwardDebugInfo(request, debugID, debugInfo);
|
1791
|
-
}
|
1792
|
-
}
|
1793
|
-
}
|
1794
|
-
|
1795
|
-
if (task.keyPath !== null) {
|
1796
|
-
// We have a Server Component that specifies a key but we're now splitting
|
1797
|
-
// the tree using a fragment.
|
1798
|
-
var fragment = [REACT_ELEMENT_TYPE, REACT_FRAGMENT_TYPE, task.keyPath, {
|
1799
|
-
children: children
|
1800
|
-
}];
|
1801
|
-
|
1802
|
-
if (!task.implicitSlot) {
|
1803
|
-
// If this was keyed inside a set. I.e. the outer Server Component was keyed
|
1804
|
-
// then we need to handle reorders of the whole set. To do this we need to wrap
|
1805
|
-
// this array in a keyed Fragment.
|
1806
|
-
return fragment;
|
1807
|
-
} // If the outer Server Component was implicit but then an inner one had a key
|
1808
|
-
// we don't actually need to be able to move the whole set around. It'll always be
|
1809
|
-
// in an implicit slot. The key only exists to be able to reset the state of the
|
1810
|
-
// children. We could achieve the same effect by passing on the keyPath to the next
|
1811
|
-
// set of components inside the fragment. This would also allow a keyless fragment
|
1812
|
-
// reconcile against a single child.
|
1813
|
-
// Unfortunately because of JSON.stringify, we can't call the recursive loop for
|
1814
|
-
// each child within this context because we can't return a set with already resolved
|
1815
|
-
// values. E.g. a string would get double encoded. Returning would pop the context.
|
1816
|
-
// So instead, we wrap it with an unkeyed fragment and inner keyed fragment.
|
1817
|
-
|
1818
|
-
|
1819
|
-
return [fragment];
|
1820
|
-
} // Since we're yielding here, that implicitly resets the keyPath context on the
|
1821
|
-
// way up. Which is what we want since we've consumed it. If this changes to
|
1822
|
-
// be recursive serialization, we need to reset the keyPath and implicitSlot,
|
1823
|
-
// before recursing here.
|
1824
|
-
|
1825
|
-
|
1826
|
-
return children;
|
1827
|
-
}
|
1828
|
-
|
1829
|
-
function renderClientElement(task, type, key, props, owner) // DEV-only
|
1830
|
-
{
|
1831
|
-
// the keys of any Server Components which are not serialized.
|
1832
|
-
|
1833
|
-
|
1834
|
-
var keyPath = task.keyPath;
|
1835
|
-
|
1836
|
-
if (key === null) {
|
1837
|
-
key = keyPath;
|
1838
|
-
} else if (keyPath !== null) {
|
1839
|
-
key = keyPath + ',' + key;
|
1840
|
-
}
|
1841
|
-
|
1842
|
-
var element = [REACT_ELEMENT_TYPE, type, key, props, owner] ;
|
1843
|
-
|
1844
|
-
if (task.implicitSlot && key !== null) {
|
1845
|
-
// The root Server Component had no key so it was in an implicit slot.
|
1846
|
-
// If we had a key lower, it would end up in that slot with an explicit key.
|
1847
|
-
// We wrap the element in a fragment to give it an implicit key slot with
|
1848
|
-
// an inner explicit key.
|
1849
|
-
return [element];
|
1850
|
-
} // Since we're yielding here, that implicitly resets the keyPath context on the
|
1851
|
-
// way up. Which is what we want since we've consumed it. If this changes to
|
1852
|
-
// be recursive serialization, we need to reset the keyPath and implicitSlot,
|
1853
|
-
// before recursing here. We also need to reset it once we render into an array
|
1854
|
-
// or anything else too which we also get implicitly.
|
1855
|
-
|
1856
|
-
|
1857
|
-
return element;
|
1858
|
-
} // The chunk ID we're currently rendering that we can assign debug data to.
|
1859
|
-
|
1860
|
-
|
1861
|
-
var debugID = null;
|
1862
|
-
|
1863
|
-
function outlineTask(request, task) {
|
1864
|
-
var newTask = createTask(request, task.model, // the currently rendering element
|
1865
|
-
task.keyPath, // unlike outlineModel this one carries along context
|
1866
|
-
task.implicitSlot, request.abortableTasks);
|
1867
|
-
retryTask(request, newTask);
|
1868
|
-
|
1869
|
-
if (newTask.status === COMPLETED) {
|
1870
|
-
// We completed synchronously so we can refer to this by reference. This
|
1871
|
-
// makes it behaves the same as prod during deserialization.
|
1872
|
-
return serializeByValueID(newTask.id);
|
1873
|
-
} // This didn't complete synchronously so it wouldn't have even if we didn't
|
1874
|
-
// outline it, so this would reduce to a lazy reference even in prod.
|
1875
|
-
|
1876
|
-
|
1877
|
-
return serializeLazyID(newTask.id);
|
1878
|
-
}
|
1879
|
-
|
1880
|
-
function renderElement(request, task, type, key, ref, props, owner) // DEV only
|
1881
|
-
{
|
1882
|
-
if (ref !== null && ref !== undefined) {
|
1883
|
-
// When the ref moves to the regular props object this will implicitly
|
1884
|
-
// throw for functions. We could probably relax it to a DEV warning for other
|
1885
|
-
// cases.
|
1886
|
-
// TODO: `ref` is now just a prop when `enableRefAsProp` is on. Should we
|
1887
|
-
// do what the above comment says?
|
1888
|
-
throw new Error('Refs cannot be used in Server Components, nor passed to Client Components.');
|
1889
|
-
}
|
1890
|
-
|
1891
|
-
{
|
1892
|
-
jsxPropsParents.set(props, type);
|
1893
|
-
|
1894
|
-
if (typeof props.children === 'object' && props.children !== null) {
|
1895
|
-
jsxChildrenParents.set(props.children, type);
|
1896
|
-
}
|
1897
|
-
}
|
1898
|
-
|
1899
|
-
if (typeof type === 'function') {
|
1900
|
-
if (isClientReference(type) || isTemporaryReference(type)) {
|
1901
|
-
// This is a reference to a Client Component.
|
1902
|
-
return renderClientElement(task, type, key, props, owner);
|
1903
|
-
} // This is a Server Component.
|
1904
|
-
|
1905
|
-
|
1906
|
-
return renderFunctionComponent(request, task, key, type, props, owner);
|
1907
|
-
} else if (typeof type === 'string') {
|
1908
|
-
// This is a host element. E.g. HTML.
|
1909
|
-
return renderClientElement(task, type, key, props, owner);
|
1910
|
-
} else if (typeof type === 'symbol') {
|
1911
|
-
if (type === REACT_FRAGMENT_TYPE && key === null) {
|
1912
|
-
// For key-less fragments, we add a small optimization to avoid serializing
|
1913
|
-
// it as a wrapper.
|
1914
|
-
var prevImplicitSlot = task.implicitSlot;
|
1915
|
-
|
1916
|
-
if (task.keyPath === null) {
|
1917
|
-
task.implicitSlot = true;
|
1918
|
-
}
|
1919
|
-
|
1920
|
-
var json = renderModelDestructive(request, task, emptyRoot, '', props.children);
|
1921
|
-
task.implicitSlot = prevImplicitSlot;
|
1922
|
-
return json;
|
1923
|
-
} // This might be a built-in React component. We'll let the client decide.
|
1924
|
-
// Any built-in works as long as its props are serializable.
|
1925
|
-
|
1926
|
-
|
1927
|
-
return renderClientElement(task, type, key, props, owner);
|
1928
|
-
} else if (type != null && typeof type === 'object') {
|
1929
|
-
if (isClientReference(type)) {
|
1930
|
-
// This is a reference to a Client Component.
|
1931
|
-
return renderClientElement(task, type, key, props, owner);
|
1932
|
-
}
|
1933
|
-
|
1934
|
-
switch (type.$$typeof) {
|
1935
|
-
case REACT_LAZY_TYPE:
|
1936
|
-
{
|
1937
|
-
var payload = type._payload;
|
1938
|
-
var init = type._init;
|
1939
|
-
var wrappedType = init(payload);
|
1940
|
-
return renderElement(request, task, wrappedType, key, ref, props, owner);
|
1941
|
-
}
|
1942
|
-
|
1943
|
-
case REACT_FORWARD_REF_TYPE:
|
1944
|
-
{
|
1945
|
-
return renderFunctionComponent(request, task, key, type.render, props, owner);
|
1946
|
-
}
|
1947
|
-
|
1948
|
-
case REACT_MEMO_TYPE:
|
1949
|
-
{
|
1950
|
-
return renderElement(request, task, type.type, key, ref, props, owner);
|
1951
|
-
}
|
1952
|
-
}
|
1953
|
-
}
|
1954
|
-
|
1955
|
-
throw new Error("Unsupported Server Component type: " + describeValueForErrorMessage(type));
|
1956
|
-
}
|
1957
|
-
|
1958
|
-
function pingTask(request, task) {
|
1959
|
-
var pingedTasks = request.pingedTasks;
|
1960
|
-
pingedTasks.push(task);
|
1961
|
-
|
1962
|
-
if (pingedTasks.length === 1) {
|
1963
|
-
request.flushScheduled = request.destination !== null;
|
1964
|
-
scheduleWork(function () {
|
1965
|
-
return performWork(request);
|
1966
|
-
});
|
1967
|
-
}
|
1968
|
-
}
|
1969
|
-
|
1970
|
-
function createTask(request, model, keyPath, implicitSlot, abortSet) {
|
1971
|
-
request.pendingChunks++;
|
1972
|
-
var id = request.nextChunkId++;
|
1973
|
-
|
1974
|
-
if (typeof model === 'object' && model !== null) {
|
1975
|
-
// If we're about to write this into a new task we can assign it an ID early so that
|
1976
|
-
// any other references can refer to the value we're about to write.
|
1977
|
-
if ((keyPath !== null || implicitSlot)) ; else {
|
1978
|
-
request.writtenObjects.set(model, id);
|
1979
|
-
}
|
1980
|
-
}
|
1981
|
-
|
1982
|
-
var task = {
|
1983
|
-
id: id,
|
1984
|
-
status: PENDING$1,
|
1985
|
-
model: model,
|
1986
|
-
keyPath: keyPath,
|
1987
|
-
implicitSlot: implicitSlot,
|
1988
|
-
ping: function () {
|
1989
|
-
return pingTask(request, task);
|
1990
|
-
},
|
1991
|
-
toJSON: function (parentPropertyName, value) {
|
1992
|
-
var parent = this; // Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us
|
1993
|
-
|
1994
|
-
{
|
1995
|
-
// $FlowFixMe[incompatible-use]
|
1996
|
-
var originalValue = parent[parentPropertyName];
|
1997
|
-
|
1998
|
-
if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
|
1999
|
-
if (objectName(originalValue) !== 'Object') {
|
2000
|
-
var jsxParentType = jsxChildrenParents.get(parent);
|
2001
|
-
|
2002
|
-
if (typeof jsxParentType === 'string') {
|
2003
|
-
error('%s objects cannot be rendered as text children. Try formatting it using toString().%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
|
2004
|
-
} else {
|
2005
|
-
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, parentPropertyName));
|
2006
|
-
}
|
2007
|
-
} else {
|
2008
|
-
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));
|
2009
|
-
}
|
2010
|
-
}
|
2011
|
-
}
|
2012
|
-
|
2013
|
-
return renderModel(request, task, parent, parentPropertyName, value);
|
2014
|
-
},
|
2015
|
-
thenableState: null
|
2016
|
-
};
|
2017
|
-
abortSet.add(task);
|
2018
|
-
return task;
|
2019
|
-
}
|
2020
|
-
|
2021
|
-
function serializeByValueID(id) {
|
2022
|
-
return '$' + id.toString(16);
|
2023
|
-
}
|
2024
|
-
|
2025
|
-
function serializeLazyID(id) {
|
2026
|
-
return '$L' + id.toString(16);
|
2027
|
-
}
|
2028
|
-
|
2029
|
-
function serializeInfinitePromise() {
|
2030
|
-
return '$@';
|
2031
|
-
}
|
2032
|
-
|
2033
|
-
function serializePromiseID(id) {
|
2034
|
-
return '$@' + id.toString(16);
|
2035
|
-
}
|
2036
|
-
|
2037
|
-
function serializeServerReferenceID(id) {
|
2038
|
-
return '$F' + id.toString(16);
|
2039
|
-
}
|
2040
|
-
|
2041
|
-
function serializeTemporaryReferenceID(id) {
|
2042
|
-
return '$T' + id;
|
2043
|
-
}
|
2044
|
-
|
2045
|
-
function serializeSymbolReference(name) {
|
2046
|
-
return '$S' + name;
|
2047
|
-
}
|
2048
|
-
|
2049
|
-
function serializeNumber(number) {
|
2050
|
-
if (Number.isFinite(number)) {
|
2051
|
-
if (number === 0 && 1 / number === -Infinity) {
|
2052
|
-
return '$-0';
|
2053
|
-
} else {
|
2054
|
-
return number;
|
2055
|
-
}
|
2056
|
-
} else {
|
2057
|
-
if (number === Infinity) {
|
2058
|
-
return '$Infinity';
|
2059
|
-
} else if (number === -Infinity) {
|
2060
|
-
return '$-Infinity';
|
2061
|
-
} else {
|
2062
|
-
return '$NaN';
|
2063
|
-
}
|
2064
|
-
}
|
2065
|
-
}
|
2066
|
-
|
2067
|
-
function serializeUndefined() {
|
2068
|
-
return '$undefined';
|
2069
|
-
}
|
2070
|
-
|
2071
|
-
function serializeDateFromDateJSON(dateJSON) {
|
2072
|
-
// JSON.stringify automatically calls Date.prototype.toJSON which calls toISOString.
|
2073
|
-
// We need only tack on a $D prefix.
|
2074
|
-
return '$D' + dateJSON;
|
2075
|
-
}
|
2076
|
-
|
2077
|
-
function serializeBigInt(n) {
|
2078
|
-
return '$n' + n.toString(10);
|
2079
|
-
}
|
2080
|
-
|
2081
|
-
function serializeRowHeader(tag, id) {
|
2082
|
-
return id.toString(16) + ':' + tag;
|
2083
|
-
}
|
2084
|
-
|
2085
|
-
function encodeReferenceChunk(request, id, reference) {
|
2086
|
-
var json = stringify(reference);
|
2087
|
-
var row = id.toString(16) + ':' + json + '\n';
|
2088
|
-
return stringToChunk(row);
|
2089
|
-
}
|
2090
|
-
|
2091
|
-
function serializeClientReference(request, parent, parentPropertyName, clientReference) {
|
2092
|
-
var clientReferenceKey = getClientReferenceKey(clientReference);
|
2093
|
-
var writtenClientReferences = request.writtenClientReferences;
|
2094
|
-
var existingId = writtenClientReferences.get(clientReferenceKey);
|
2095
|
-
|
2096
|
-
if (existingId !== undefined) {
|
2097
|
-
if (parent[0] === REACT_ELEMENT_TYPE && parentPropertyName === '1') {
|
2098
|
-
// If we're encoding the "type" of an element, we can refer
|
2099
|
-
// to that by a lazy reference instead of directly since React
|
2100
|
-
// knows how to deal with lazy values. This lets us suspend
|
2101
|
-
// on this component rather than its parent until the code has
|
2102
|
-
// loaded.
|
2103
|
-
return serializeLazyID(existingId);
|
2104
|
-
}
|
2105
|
-
|
2106
|
-
return serializeByValueID(existingId);
|
2107
|
-
}
|
2108
|
-
|
2109
|
-
try {
|
2110
|
-
var clientReferenceMetadata = resolveClientReferenceMetadata(request.bundlerConfig, clientReference);
|
2111
|
-
request.pendingChunks++;
|
2112
|
-
var importId = request.nextChunkId++;
|
2113
|
-
emitImportChunk(request, importId, clientReferenceMetadata);
|
2114
|
-
writtenClientReferences.set(clientReferenceKey, importId);
|
2115
|
-
|
2116
|
-
if (parent[0] === REACT_ELEMENT_TYPE && parentPropertyName === '1') {
|
2117
|
-
// If we're encoding the "type" of an element, we can refer
|
2118
|
-
// to that by a lazy reference instead of directly since React
|
2119
|
-
// knows how to deal with lazy values. This lets us suspend
|
2120
|
-
// on this component rather than its parent until the code has
|
2121
|
-
// loaded.
|
2122
|
-
return serializeLazyID(importId);
|
2123
|
-
}
|
2124
|
-
|
2125
|
-
return serializeByValueID(importId);
|
2126
|
-
} catch (x) {
|
2127
|
-
request.pendingChunks++;
|
2128
|
-
var errorId = request.nextChunkId++;
|
2129
|
-
var digest = logRecoverableError(request, x);
|
2130
|
-
emitErrorChunk(request, errorId, digest, x);
|
2131
|
-
return serializeByValueID(errorId);
|
2132
|
-
}
|
2133
|
-
}
|
2134
|
-
|
2135
|
-
function outlineModel(request, value) {
|
2136
|
-
var newTask = createTask(request, value, null, // The way we use outlining is for reusing an object.
|
2137
|
-
false, // It makes no sense for that use case to be contextual.
|
2138
|
-
request.abortableTasks);
|
2139
|
-
retryTask(request, newTask);
|
2140
|
-
return newTask.id;
|
2141
|
-
}
|
2142
|
-
|
2143
|
-
function serializeServerReference(request, serverReference) {
|
2144
|
-
var writtenServerReferences = request.writtenServerReferences;
|
2145
|
-
var existingId = writtenServerReferences.get(serverReference);
|
2146
|
-
|
2147
|
-
if (existingId !== undefined) {
|
2148
|
-
return serializeServerReferenceID(existingId);
|
2149
|
-
}
|
2150
|
-
|
2151
|
-
var bound = getServerReferenceBoundArguments(request.bundlerConfig, serverReference);
|
2152
|
-
var serverReferenceMetadata = {
|
2153
|
-
id: getServerReferenceId(request.bundlerConfig, serverReference),
|
2154
|
-
bound: bound ? Promise.resolve(bound) : null
|
2155
|
-
};
|
2156
|
-
var metadataId = outlineModel(request, serverReferenceMetadata);
|
2157
|
-
writtenServerReferences.set(serverReference, metadataId);
|
2158
|
-
return serializeServerReferenceID(metadataId);
|
2159
|
-
}
|
2160
|
-
|
2161
|
-
function serializeTemporaryReference(request, temporaryReference) {
|
2162
|
-
var id = resolveTemporaryReferenceID(temporaryReference);
|
2163
|
-
return serializeTemporaryReferenceID(id);
|
2164
|
-
}
|
2165
|
-
|
2166
|
-
function serializeLargeTextString(request, text) {
|
2167
|
-
request.pendingChunks += 2;
|
2168
|
-
var textId = request.nextChunkId++;
|
2169
|
-
var textChunk = stringToChunk(text);
|
2170
|
-
var binaryLength = byteLengthOfChunk(textChunk);
|
2171
|
-
var row = textId.toString(16) + ':T' + binaryLength.toString(16) + ',';
|
2172
|
-
var headerChunk = stringToChunk(row);
|
2173
|
-
request.completedRegularChunks.push(headerChunk, textChunk);
|
2174
|
-
return serializeByValueID(textId);
|
2175
|
-
}
|
2176
|
-
|
2177
|
-
function serializeMap(request, map) {
|
2178
|
-
var entries = Array.from(map);
|
2179
|
-
|
2180
|
-
for (var i = 0; i < entries.length; i++) {
|
2181
|
-
var key = entries[i][0];
|
2182
|
-
|
2183
|
-
if (typeof key === 'object' && key !== null) {
|
2184
|
-
var writtenObjects = request.writtenObjects;
|
2185
|
-
var existingId = writtenObjects.get(key);
|
2186
|
-
|
2187
|
-
if (existingId === undefined) {
|
2188
|
-
writtenObjects.set(key, SEEN_BUT_NOT_YET_OUTLINED);
|
2189
|
-
}
|
2190
|
-
}
|
2191
|
-
}
|
2192
|
-
|
2193
|
-
var id = outlineModel(request, entries);
|
2194
|
-
return '$Q' + id.toString(16);
|
2195
|
-
}
|
2196
|
-
|
2197
|
-
function serializeFormData(request, formData) {
|
2198
|
-
var entries = Array.from(formData.entries());
|
2199
|
-
var id = outlineModel(request, entries);
|
2200
|
-
return '$K' + id.toString(16);
|
2201
|
-
}
|
2202
|
-
|
2203
|
-
function serializeSet(request, set) {
|
2204
|
-
var entries = Array.from(set);
|
2205
|
-
|
2206
|
-
for (var i = 0; i < entries.length; i++) {
|
2207
|
-
var key = entries[i];
|
2208
|
-
|
2209
|
-
if (typeof key === 'object' && key !== null) {
|
2210
|
-
var writtenObjects = request.writtenObjects;
|
2211
|
-
var existingId = writtenObjects.get(key);
|
2212
|
-
|
2213
|
-
if (existingId === undefined) {
|
2214
|
-
writtenObjects.set(key, SEEN_BUT_NOT_YET_OUTLINED);
|
2215
|
-
}
|
2216
|
-
}
|
2217
|
-
}
|
2218
|
-
|
2219
|
-
var id = outlineModel(request, entries);
|
2220
|
-
return '$W' + id.toString(16);
|
2221
|
-
}
|
2222
|
-
|
2223
|
-
function escapeStringValue(value) {
|
2224
|
-
if (value[0] === '$') {
|
2225
|
-
// We need to escape $ prefixed strings since we use those to encode
|
2226
|
-
// references to IDs and as special symbol values.
|
2227
|
-
return '$' + value;
|
2228
|
-
} else {
|
2229
|
-
return value;
|
2230
|
-
}
|
2231
|
-
}
|
2232
|
-
|
2233
|
-
var modelRoot = false;
|
2234
|
-
|
2235
|
-
function renderModel(request, task, parent, key, value) {
|
2236
|
-
var prevKeyPath = task.keyPath;
|
2237
|
-
var prevImplicitSlot = task.implicitSlot;
|
2238
|
-
|
2239
|
-
try {
|
2240
|
-
return renderModelDestructive(request, task, parent, key, value);
|
2241
|
-
} catch (thrownValue) {
|
2242
|
-
var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
|
2243
|
-
// reasons, the rest of the Suspense implementation expects the thrown
|
2244
|
-
// value to be a thenable, because before `use` existed that was the
|
2245
|
-
// (unstable) API for suspending. This implementation detail can change
|
2246
|
-
// later, once we deprecate the old API in favor of `use`.
|
2247
|
-
getSuspendedThenable() : thrownValue; // If the suspended/errored value was an element or lazy it can be reduced
|
2248
|
-
// to a lazy reference, so that it doesn't error the parent.
|
2249
|
-
|
2250
|
-
var model = task.model;
|
2251
|
-
var wasReactNode = typeof model === 'object' && model !== null && (model.$$typeof === REACT_ELEMENT_TYPE || model.$$typeof === REACT_LAZY_TYPE);
|
2252
|
-
|
2253
|
-
if (typeof x === 'object' && x !== null) {
|
2254
|
-
// $FlowFixMe[method-unbinding]
|
2255
|
-
if (typeof x.then === 'function') {
|
2256
|
-
// Something suspended, we'll need to create a new task and resolve it later.
|
2257
|
-
var newTask = createTask(request, task.model, task.keyPath, task.implicitSlot, request.abortableTasks);
|
2258
|
-
var ping = newTask.ping;
|
2259
|
-
x.then(ping, ping);
|
2260
|
-
newTask.thenableState = getThenableStateAfterSuspending(); // Restore the context. We assume that this will be restored by the inner
|
2261
|
-
// functions in case nothing throws so we don't use "finally" here.
|
2262
|
-
|
2263
|
-
task.keyPath = prevKeyPath;
|
2264
|
-
task.implicitSlot = prevImplicitSlot;
|
2265
|
-
|
2266
|
-
if (wasReactNode) {
|
2267
|
-
return serializeLazyID(newTask.id);
|
2268
|
-
}
|
2269
|
-
|
2270
|
-
return serializeByValueID(newTask.id);
|
2271
|
-
}
|
2272
|
-
} // Restore the context. We assume that this will be restored by the inner
|
2273
|
-
// functions in case nothing throws so we don't use "finally" here.
|
2274
|
-
|
2275
|
-
|
2276
|
-
task.keyPath = prevKeyPath;
|
2277
|
-
task.implicitSlot = prevImplicitSlot;
|
2278
|
-
|
2279
|
-
if (wasReactNode) {
|
2280
|
-
// Something errored. We'll still send everything we have up until this point.
|
2281
|
-
// We'll replace this element with a lazy reference that throws on the client
|
2282
|
-
// once it gets rendered.
|
2283
|
-
request.pendingChunks++;
|
2284
|
-
var errorId = request.nextChunkId++;
|
2285
|
-
var digest = logRecoverableError(request, x);
|
2286
|
-
emitErrorChunk(request, errorId, digest, x);
|
2287
|
-
return serializeLazyID(errorId);
|
2288
|
-
} // Something errored but it was not in a React Node. There's no need to serialize
|
2289
|
-
// it by value because it'll just error the whole parent row anyway so we can
|
2290
|
-
// just stop any siblings and error the whole parent row.
|
2291
|
-
|
2292
|
-
|
2293
|
-
throw x;
|
2294
|
-
}
|
2295
|
-
}
|
2296
|
-
|
2297
|
-
function renderModelDestructive(request, task, parent, parentPropertyName, value) {
|
2298
|
-
// Set the currently rendering model
|
2299
|
-
task.model = value; // Special Symbol, that's very common.
|
2300
|
-
|
2301
|
-
if (value === REACT_ELEMENT_TYPE) {
|
2302
|
-
return '$';
|
2303
|
-
}
|
2304
|
-
|
2305
|
-
if (value === null) {
|
2306
|
-
return null;
|
2307
|
-
}
|
2308
|
-
|
2309
|
-
if (typeof value === 'object') {
|
2310
|
-
switch (value.$$typeof) {
|
2311
|
-
case REACT_ELEMENT_TYPE:
|
2312
|
-
{
|
2313
|
-
var _writtenObjects = request.writtenObjects;
|
2314
|
-
|
2315
|
-
var _existingId = _writtenObjects.get(value);
|
2316
|
-
|
2317
|
-
if (_existingId !== undefined) {
|
2318
|
-
if ((task.keyPath !== null || task.implicitSlot)) ; else if (modelRoot === value) {
|
2319
|
-
// This is the ID we're currently emitting so we need to write it
|
2320
|
-
// once but if we discover it again, we refer to it by id.
|
2321
|
-
modelRoot = null;
|
2322
|
-
} else if (_existingId === SEEN_BUT_NOT_YET_OUTLINED) {
|
2323
|
-
// TODO: If we throw here we can treat this as suspending which causes an outline
|
2324
|
-
// but that is able to reuse the same task if we're already in one but then that
|
2325
|
-
// will be a lazy future value rather than guaranteed to exist but maybe that's good.
|
2326
|
-
var newId = outlineModel(request, value);
|
2327
|
-
return serializeByValueID(newId);
|
2328
|
-
} else {
|
2329
|
-
// We've already emitted this as an outlined object, so we can refer to that by its
|
2330
|
-
// existing ID. TODO: We should use a lazy reference since, unlike plain objects,
|
2331
|
-
// elements might suspend so it might not have emitted yet even if we have the ID for
|
2332
|
-
// it. However, this creates an extra wrapper when it's not needed. We should really
|
2333
|
-
// detect whether this already was emitted and synchronously available. In that
|
2334
|
-
// case we can refer to it synchronously and only make it lazy otherwise.
|
2335
|
-
// We currently don't have a data structure that lets us see that though.
|
2336
|
-
return serializeByValueID(_existingId);
|
2337
|
-
}
|
2338
|
-
} else {
|
2339
|
-
// This is the first time we've seen this object. We may never see it again
|
2340
|
-
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
|
2341
|
-
_writtenObjects.set(value, SEEN_BUT_NOT_YET_OUTLINED); // The element's props are marked as "never outlined" so that they are inlined into
|
2342
|
-
// the same row as the element itself.
|
2343
|
-
|
2344
|
-
|
2345
|
-
_writtenObjects.set(value.props, NEVER_OUTLINED);
|
2346
|
-
}
|
2347
|
-
|
2348
|
-
var element = value;
|
2349
|
-
|
2350
|
-
{
|
2351
|
-
var debugInfo = value._debugInfo;
|
2352
|
-
|
2353
|
-
if (debugInfo) {
|
2354
|
-
// If this came from Flight, forward any debug info into this new row.
|
2355
|
-
if (debugID === null) {
|
2356
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
2357
|
-
// component to assign it an ID.
|
2358
|
-
return outlineTask(request, task);
|
2359
|
-
} else {
|
2360
|
-
// Forward any debug info we have the first time we see it.
|
2361
|
-
forwardDebugInfo(request, debugID, debugInfo);
|
2362
|
-
}
|
2363
|
-
}
|
2364
|
-
}
|
2365
|
-
|
2366
|
-
var props = element.props;
|
2367
|
-
var ref;
|
2368
|
-
|
2369
|
-
{
|
2370
|
-
// TODO: This is a temporary, intermediate step. Once the feature
|
2371
|
-
// flag is removed, we should get the ref off the props object right
|
2372
|
-
// before using it.
|
2373
|
-
var refProp = props.ref;
|
2374
|
-
ref = refProp !== undefined ? refProp : null;
|
2375
|
-
} // Attempt to render the Server Component.
|
2376
|
-
|
2377
|
-
|
2378
|
-
return renderElement(request, task, element.type, // $FlowFixMe[incompatible-call] the key of an element is null | string
|
2379
|
-
element.key, ref, props, element._owner );
|
2380
|
-
}
|
2381
|
-
|
2382
|
-
case REACT_LAZY_TYPE:
|
2383
|
-
{
|
2384
|
-
// Reset the task's thenable state before continuing. If there was one, it was
|
2385
|
-
// from suspending the lazy before.
|
2386
|
-
task.thenableState = null;
|
2387
|
-
var lazy = value;
|
2388
|
-
var payload = lazy._payload;
|
2389
|
-
var init = lazy._init;
|
2390
|
-
var resolvedModel = init(payload);
|
2391
|
-
|
2392
|
-
{
|
2393
|
-
var _debugInfo = lazy._debugInfo;
|
2394
|
-
|
2395
|
-
if (_debugInfo) {
|
2396
|
-
// If this came from Flight, forward any debug info into this new row.
|
2397
|
-
if (debugID === null) {
|
2398
|
-
// We don't have a chunk to assign debug info. We need to outline this
|
2399
|
-
// component to assign it an ID.
|
2400
|
-
return outlineTask(request, task);
|
2401
|
-
} else {
|
2402
|
-
// Forward any debug info we have the first time we see it.
|
2403
|
-
// We do this after init so that we have received all the debug info
|
2404
|
-
// from the server by the time we emit it.
|
2405
|
-
forwardDebugInfo(request, debugID, _debugInfo);
|
2406
|
-
}
|
2407
|
-
}
|
2408
|
-
}
|
2409
|
-
|
2410
|
-
return renderModelDestructive(request, task, emptyRoot, '', resolvedModel);
|
2411
|
-
}
|
2412
|
-
}
|
2413
|
-
|
2414
|
-
if (isClientReference(value)) {
|
2415
|
-
return serializeClientReference(request, parent, parentPropertyName, value);
|
2416
|
-
}
|
2417
|
-
|
2418
|
-
var writtenObjects = request.writtenObjects;
|
2419
|
-
var existingId = writtenObjects.get(value); // $FlowFixMe[method-unbinding]
|
2420
|
-
|
2421
|
-
if (typeof value.then === 'function') {
|
2422
|
-
if (existingId !== undefined) {
|
2423
|
-
if ((task.keyPath !== null || task.implicitSlot)) {
|
2424
|
-
// If we're in some kind of context we can't reuse the result of this render or
|
2425
|
-
// previous renders of this element. We only reuse Promises if they're not wrapped
|
2426
|
-
// by another Server Component.
|
2427
|
-
var _promiseId = serializeThenable(request, task, value);
|
2428
|
-
|
2429
|
-
return serializePromiseID(_promiseId);
|
2430
|
-
} else if (modelRoot === value) {
|
2431
|
-
// This is the ID we're currently emitting so we need to write it
|
2432
|
-
// once but if we discover it again, we refer to it by id.
|
2433
|
-
modelRoot = null;
|
2434
|
-
} else {
|
2435
|
-
// We've seen this promise before, so we can just refer to the same result.
|
2436
|
-
return serializePromiseID(existingId);
|
2437
|
-
}
|
2438
|
-
} // We assume that any object with a .then property is a "Thenable" type,
|
2439
|
-
// or a Promise type. Either of which can be represented by a Promise.
|
2440
|
-
|
2441
|
-
|
2442
|
-
var promiseId = serializeThenable(request, task, value);
|
2443
|
-
writtenObjects.set(value, promiseId);
|
2444
|
-
return serializePromiseID(promiseId);
|
2445
|
-
}
|
2446
|
-
|
2447
|
-
if (existingId !== undefined) {
|
2448
|
-
if (modelRoot === value) {
|
2449
|
-
// This is the ID we're currently emitting so we need to write it
|
2450
|
-
// once but if we discover it again, we refer to it by id.
|
2451
|
-
modelRoot = null;
|
2452
|
-
} else if (existingId === SEEN_BUT_NOT_YET_OUTLINED) {
|
2453
|
-
var _newId = outlineModel(request, value);
|
2454
|
-
|
2455
|
-
return serializeByValueID(_newId);
|
2456
|
-
} else if (existingId !== NEVER_OUTLINED) {
|
2457
|
-
// We've already emitted this as an outlined object, so we can
|
2458
|
-
// just refer to that by its existing ID.
|
2459
|
-
return serializeByValueID(existingId);
|
2460
|
-
}
|
2461
|
-
} else {
|
2462
|
-
// This is the first time we've seen this object. We may never see it again
|
2463
|
-
// so we'll inline it. Mark it as seen. If we see it again, we'll outline.
|
2464
|
-
writtenObjects.set(value, SEEN_BUT_NOT_YET_OUTLINED);
|
2465
|
-
}
|
2466
|
-
|
2467
|
-
if (isArray(value)) {
|
2468
|
-
return renderFragment(request, task, value);
|
2469
|
-
}
|
2470
|
-
|
2471
|
-
if (value instanceof Map) {
|
2472
|
-
return serializeMap(request, value);
|
2473
|
-
}
|
2474
|
-
|
2475
|
-
if (value instanceof Set) {
|
2476
|
-
return serializeSet(request, value);
|
2477
|
-
} // TODO: FormData is not available in old Node. Remove the typeof later.
|
2478
|
-
|
2479
|
-
|
2480
|
-
if (typeof FormData === 'function' && value instanceof FormData) {
|
2481
|
-
return serializeFormData(request, value);
|
2482
|
-
}
|
2483
|
-
|
2484
|
-
var iteratorFn = getIteratorFn(value);
|
2485
|
-
|
2486
|
-
if (iteratorFn) {
|
2487
|
-
return renderFragment(request, task, Array.from(value));
|
2488
|
-
} // Verify that this is a simple plain object.
|
2489
|
-
|
2490
|
-
|
2491
|
-
var proto = getPrototypeOf(value);
|
2492
|
-
|
2493
|
-
if (proto !== ObjectPrototype && (proto === null || getPrototypeOf(proto) !== null)) {
|
2494
|
-
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.');
|
2495
|
-
}
|
2496
|
-
|
2497
|
-
{
|
2498
|
-
if (objectName(value) !== 'Object') {
|
2499
|
-
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent, parentPropertyName));
|
2500
|
-
} else if (!isSimpleObject(value)) {
|
2501
|
-
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));
|
2502
|
-
} else if (Object.getOwnPropertySymbols) {
|
2503
|
-
var symbols = Object.getOwnPropertySymbols(value);
|
2504
|
-
|
2505
|
-
if (symbols.length > 0) {
|
2506
|
-
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));
|
2507
|
-
}
|
2508
|
-
}
|
2509
|
-
} // $FlowFixMe[incompatible-return]
|
2510
|
-
|
2511
|
-
|
2512
|
-
return value;
|
2513
|
-
}
|
2514
|
-
|
2515
|
-
if (typeof value === 'string') {
|
2516
|
-
|
2517
|
-
|
2518
|
-
if (value[value.length - 1] === 'Z') {
|
2519
|
-
// Possibly a Date, whose toJSON automatically calls toISOString
|
2520
|
-
// $FlowFixMe[incompatible-use]
|
2521
|
-
var originalValue = parent[parentPropertyName];
|
2522
|
-
|
2523
|
-
if (originalValue instanceof Date) {
|
2524
|
-
return serializeDateFromDateJSON(value);
|
2525
|
-
}
|
2526
|
-
}
|
2527
|
-
|
2528
|
-
if (value.length >= 1024) {
|
2529
|
-
// For large strings, we encode them outside the JSON payload so that we
|
2530
|
-
// don't have to double encode and double parse the strings. This can also
|
2531
|
-
// be more compact in case the string has a lot of escaped characters.
|
2532
|
-
return serializeLargeTextString(request, value);
|
2533
|
-
}
|
2534
|
-
|
2535
|
-
return escapeStringValue(value);
|
2536
|
-
}
|
2537
|
-
|
2538
|
-
if (typeof value === 'boolean') {
|
2539
|
-
return value;
|
2540
|
-
}
|
2541
|
-
|
2542
|
-
if (typeof value === 'number') {
|
2543
|
-
return serializeNumber(value);
|
2544
|
-
}
|
2545
|
-
|
2546
|
-
if (typeof value === 'undefined') {
|
2547
|
-
return serializeUndefined();
|
2548
|
-
}
|
2549
|
-
|
2550
|
-
if (typeof value === 'function') {
|
2551
|
-
if (isClientReference(value)) {
|
2552
|
-
return serializeClientReference(request, parent, parentPropertyName, value);
|
2553
|
-
}
|
2554
|
-
|
2555
|
-
if (isServerReference(value)) {
|
2556
|
-
return serializeServerReference(request, value);
|
2557
|
-
}
|
2558
|
-
|
2559
|
-
if (isTemporaryReference(value)) {
|
2560
|
-
return serializeTemporaryReference(request, value);
|
2561
|
-
}
|
2562
|
-
|
2563
|
-
if (/^on[A-Z]/.test(parentPropertyName)) {
|
2564
|
-
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.');
|
2565
|
-
} else if ((jsxChildrenParents.has(parent) || jsxPropsParents.has(parent) && parentPropertyName === 'children')) {
|
2566
|
-
var componentName = value.displayName || value.name || 'Component';
|
2567
|
-
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));
|
2568
|
-
} else {
|
2569
|
-
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));
|
2570
|
-
}
|
2571
|
-
}
|
2572
|
-
|
2573
|
-
if (typeof value === 'symbol') {
|
2574
|
-
var writtenSymbols = request.writtenSymbols;
|
2575
|
-
|
2576
|
-
var _existingId2 = writtenSymbols.get(value);
|
2577
|
-
|
2578
|
-
if (_existingId2 !== undefined) {
|
2579
|
-
return serializeByValueID(_existingId2);
|
2580
|
-
} // $FlowFixMe[incompatible-type] `description` might be undefined
|
2581
|
-
|
2582
|
-
|
2583
|
-
var name = value.description;
|
2584
|
-
|
2585
|
-
if (Symbol.for(name) !== value) {
|
2586
|
-
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
|
2587
|
-
value.description + ") cannot be found among global symbols.") + describeObjectForErrorMessage(parent, parentPropertyName));
|
2588
|
-
}
|
2589
|
-
|
2590
|
-
request.pendingChunks++;
|
2591
|
-
var symbolId = request.nextChunkId++;
|
2592
|
-
emitSymbolChunk(request, symbolId, name);
|
2593
|
-
writtenSymbols.set(value, symbolId);
|
2594
|
-
return serializeByValueID(symbolId);
|
2595
|
-
}
|
2596
|
-
|
2597
|
-
if (typeof value === 'bigint') {
|
2598
|
-
|
2599
|
-
return serializeBigInt(value);
|
2600
|
-
}
|
2601
|
-
|
2602
|
-
throw new Error("Type " + typeof value + " is not supported in Client Component props." + describeObjectForErrorMessage(parent, parentPropertyName));
|
2603
|
-
}
|
2604
|
-
|
2605
|
-
function logPostpone(request, reason) {
|
2606
|
-
var prevRequest = currentRequest;
|
2607
|
-
currentRequest = null;
|
2608
|
-
|
2609
|
-
try {
|
2610
|
-
var onPostpone = request.onPostpone;
|
2611
|
-
|
2612
|
-
if (supportsRequestStorage) ; else {
|
2613
|
-
onPostpone(reason);
|
2614
|
-
}
|
2615
|
-
} finally {
|
2616
|
-
currentRequest = prevRequest;
|
2617
|
-
}
|
2618
|
-
}
|
2619
|
-
|
2620
|
-
function logRecoverableError(request, error) {
|
2621
|
-
var prevRequest = currentRequest;
|
2622
|
-
currentRequest = null;
|
2623
|
-
var errorDigest;
|
2624
|
-
|
2625
|
-
try {
|
2626
|
-
var onError = request.onError;
|
2627
|
-
|
2628
|
-
if (supportsRequestStorage) ; else {
|
2629
|
-
errorDigest = onError(error);
|
2630
|
-
}
|
2631
|
-
} finally {
|
2632
|
-
currentRequest = prevRequest;
|
2633
|
-
}
|
2634
|
-
|
2635
|
-
if (errorDigest != null && typeof errorDigest !== 'string') {
|
2636
|
-
// eslint-disable-next-line react-internal/prod-error-codes
|
2637
|
-
throw new Error("onError returned something with a type other than \"string\". onError should return a string and may return null or undefined but must not return anything else. It received something of type \"" + typeof errorDigest + "\" instead");
|
2638
|
-
}
|
2639
|
-
|
2640
|
-
return errorDigest || '';
|
2641
|
-
}
|
2642
|
-
|
2643
|
-
function fatalError(request, error) {
|
2644
|
-
|
2645
|
-
|
2646
|
-
if (request.destination !== null) {
|
2647
|
-
request.status = CLOSED;
|
2648
|
-
closeWithError(request.destination, error);
|
2649
|
-
} else {
|
2650
|
-
request.status = CLOSING;
|
2651
|
-
request.fatalError = error;
|
2652
|
-
}
|
2653
|
-
}
|
2654
|
-
|
2655
|
-
function emitPostponeChunk(request, id, postponeInstance) {
|
2656
|
-
var row;
|
2657
|
-
|
2658
|
-
{
|
2659
|
-
var reason = '';
|
2660
|
-
var stack = '';
|
2661
|
-
|
2662
|
-
try {
|
2663
|
-
// eslint-disable-next-line react-internal/safe-string-coercion
|
2664
|
-
reason = String(postponeInstance.message); // eslint-disable-next-line react-internal/safe-string-coercion
|
2665
|
-
|
2666
|
-
stack = String(postponeInstance.stack);
|
2667
|
-
} catch (x) {}
|
2668
|
-
|
2669
|
-
row = serializeRowHeader('P', id) + stringify({
|
2670
|
-
reason: reason,
|
2671
|
-
stack: stack
|
2672
|
-
}) + '\n';
|
2673
|
-
}
|
2674
|
-
|
2675
|
-
var processedChunk = stringToChunk(row);
|
2676
|
-
request.completedErrorChunks.push(processedChunk);
|
2677
|
-
}
|
2678
|
-
|
2679
|
-
function emitErrorChunk(request, id, digest, error) {
|
2680
|
-
var errorInfo;
|
2681
|
-
|
2682
|
-
{
|
2683
|
-
var message;
|
2684
|
-
var stack = '';
|
2685
|
-
|
2686
|
-
try {
|
2687
|
-
if (error instanceof Error) {
|
2688
|
-
// eslint-disable-next-line react-internal/safe-string-coercion
|
2689
|
-
message = String(error.message); // eslint-disable-next-line react-internal/safe-string-coercion
|
2690
|
-
|
2691
|
-
stack = String(error.stack);
|
2692
|
-
} else if (typeof error === 'object' && error !== null) {
|
2693
|
-
message = describeObjectForErrorMessage(error);
|
2694
|
-
} else {
|
2695
|
-
// eslint-disable-next-line react-internal/safe-string-coercion
|
2696
|
-
message = String(error);
|
2697
|
-
}
|
2698
|
-
} catch (x) {
|
2699
|
-
message = 'An error occurred but serializing the error message failed.';
|
2700
|
-
}
|
2701
|
-
|
2702
|
-
errorInfo = {
|
2703
|
-
digest: digest,
|
2704
|
-
message: message,
|
2705
|
-
stack: stack
|
2706
|
-
};
|
2707
|
-
}
|
2708
|
-
|
2709
|
-
var row = serializeRowHeader('E', id) + stringify(errorInfo) + '\n';
|
2710
|
-
var processedChunk = stringToChunk(row);
|
2711
|
-
request.completedErrorChunks.push(processedChunk);
|
2712
|
-
}
|
2713
|
-
|
2714
|
-
function emitImportChunk(request, id, clientReferenceMetadata) {
|
2715
|
-
// $FlowFixMe[incompatible-type] stringify can return null
|
2716
|
-
var json = stringify(clientReferenceMetadata);
|
2717
|
-
var row = serializeRowHeader('I', id) + json + '\n';
|
2718
|
-
var processedChunk = stringToChunk(row);
|
2719
|
-
request.completedImportChunks.push(processedChunk);
|
2720
|
-
}
|
2721
|
-
|
2722
|
-
function emitHintChunk(request, code, model) {
|
2723
|
-
var json = stringify(model);
|
2724
|
-
var id = request.nextChunkId++;
|
2725
|
-
var row = serializeRowHeader('H' + code, id) + json + '\n';
|
2726
|
-
var processedChunk = stringToChunk(row);
|
2727
|
-
request.completedHintChunks.push(processedChunk);
|
2728
|
-
}
|
2729
|
-
|
2730
|
-
function emitSymbolChunk(request, id, name) {
|
2731
|
-
var symbolReference = serializeSymbolReference(name);
|
2732
|
-
var processedChunk = encodeReferenceChunk(request, id, symbolReference);
|
2733
|
-
request.completedImportChunks.push(processedChunk);
|
2734
|
-
}
|
2735
|
-
|
2736
|
-
function emitModelChunk(request, id, json) {
|
2737
|
-
var row = id.toString(16) + ':' + json + '\n';
|
2738
|
-
var processedChunk = stringToChunk(row);
|
2739
|
-
request.completedRegularChunks.push(processedChunk);
|
2740
|
-
}
|
2741
|
-
|
2742
|
-
function emitDebugChunk(request, id, debugInfo) {
|
2743
|
-
// use the full serialization that requires a task.
|
2744
|
-
|
2745
|
-
|
2746
|
-
var counter = {
|
2747
|
-
objectCount: 0
|
2748
|
-
};
|
2749
|
-
|
2750
|
-
function replacer(parentPropertyName, value) {
|
2751
|
-
return renderConsoleValue(request, counter, this, parentPropertyName, value);
|
2752
|
-
} // $FlowFixMe[incompatible-type] stringify can return null
|
2753
|
-
|
2754
|
-
|
2755
|
-
var json = stringify(debugInfo, replacer);
|
2756
|
-
var row = serializeRowHeader('D', id) + json + '\n';
|
2757
|
-
var processedChunk = stringToChunk(row);
|
2758
|
-
request.completedRegularChunks.push(processedChunk);
|
2759
|
-
}
|
2760
|
-
|
2761
|
-
function serializeEval(source) {
|
2762
|
-
|
2763
|
-
return '$E' + source;
|
2764
|
-
} // This is a forked version of renderModel which should never error, never suspend and is limited
|
2765
|
-
// in the depth it can encode.
|
2766
|
-
|
2767
|
-
|
2768
|
-
function renderConsoleValue(request, counter, parent, parentPropertyName, value) {
|
2769
|
-
// Make sure that `parent[parentPropertyName]` wasn't JSONified before `value` was passed to us
|
2770
|
-
// $FlowFixMe[incompatible-use]
|
2771
|
-
var originalValue = parent[parentPropertyName];
|
2772
|
-
|
2773
|
-
if (value === null) {
|
2774
|
-
return null;
|
2775
|
-
}
|
2776
|
-
|
2777
|
-
if (typeof value === 'object') {
|
2778
|
-
if (isClientReference(value)) {
|
2779
|
-
// We actually have this value on the client so we could import it.
|
2780
|
-
// This might be confusing though because on the Server it won't actually
|
2781
|
-
// be this value, so if you're debugging client references maybe you'd be
|
2782
|
-
// better with a place holder.
|
2783
|
-
return serializeClientReference(request, parent, parentPropertyName, value);
|
2784
|
-
}
|
2785
|
-
|
2786
|
-
if (counter.objectCount > 20) {
|
2787
|
-
// We've reached our max number of objects to serialize across the wire so we serialize this
|
2788
|
-
// object but no properties inside of it, as a place holder.
|
2789
|
-
return Array.isArray(value) ? [] : {};
|
2790
|
-
}
|
2791
|
-
|
2792
|
-
counter.objectCount++;
|
2793
|
-
var writtenObjects = request.writtenObjects;
|
2794
|
-
var existingId = writtenObjects.get(value); // $FlowFixMe[method-unbinding]
|
2795
|
-
|
2796
|
-
if (typeof value.then === 'function') {
|
2797
|
-
if (existingId !== undefined) {
|
2798
|
-
// We've seen this promise before, so we can just refer to the same result.
|
2799
|
-
return serializePromiseID(existingId);
|
2800
|
-
}
|
2801
|
-
|
2802
|
-
var thenable = value;
|
2803
|
-
|
2804
|
-
switch (thenable.status) {
|
2805
|
-
case 'fulfilled':
|
2806
|
-
{
|
2807
|
-
return serializePromiseID(outlineConsoleValue(request, counter, thenable.value));
|
2808
|
-
}
|
2809
|
-
|
2810
|
-
case 'rejected':
|
2811
|
-
{
|
2812
|
-
var x = thenable.reason;
|
2813
|
-
request.pendingChunks++;
|
2814
|
-
var errorId = request.nextChunkId++;
|
2815
|
-
|
2816
|
-
{
|
2817
|
-
// We don't log these errors since they didn't actually throw into Flight.
|
2818
|
-
var digest = '';
|
2819
|
-
emitErrorChunk(request, errorId, digest, x);
|
2820
|
-
}
|
2821
|
-
|
2822
|
-
return serializePromiseID(errorId);
|
2823
|
-
}
|
2824
|
-
} // If it hasn't already resolved (and been instrumented) we just encode an infinite
|
2825
|
-
// promise that will never resolve.
|
2826
|
-
|
2827
|
-
|
2828
|
-
return serializeInfinitePromise();
|
2829
|
-
}
|
2830
|
-
|
2831
|
-
if (existingId !== undefined && existingId >= 0) {
|
2832
|
-
// We've already emitted this as a real object, so we can
|
2833
|
-
// just refer to that by its existing ID.
|
2834
|
-
return serializeByValueID(existingId);
|
2835
|
-
}
|
2836
|
-
|
2837
|
-
if (isArray(value)) {
|
2838
|
-
return value;
|
2839
|
-
}
|
2840
|
-
|
2841
|
-
if (value instanceof Map) {
|
2842
|
-
return serializeMap(request, value);
|
2843
|
-
}
|
2844
|
-
|
2845
|
-
if (value instanceof Set) {
|
2846
|
-
return serializeSet(request, value);
|
2847
|
-
} // TODO: FormData is not available in old Node. Remove the typeof later.
|
2848
|
-
|
2849
|
-
|
2850
|
-
if (typeof FormData === 'function' && value instanceof FormData) {
|
2851
|
-
return serializeFormData(request, value);
|
2852
|
-
}
|
2853
|
-
|
2854
|
-
var iteratorFn = getIteratorFn(value);
|
2855
|
-
|
2856
|
-
if (iteratorFn) {
|
2857
|
-
return Array.from(value);
|
2858
|
-
} // $FlowFixMe[incompatible-return]
|
2859
|
-
|
2860
|
-
|
2861
|
-
return value;
|
2862
|
-
}
|
2863
|
-
|
2864
|
-
if (typeof value === 'string') {
|
2865
|
-
if (value[value.length - 1] === 'Z') {
|
2866
|
-
// Possibly a Date, whose toJSON automatically calls toISOString
|
2867
|
-
if (originalValue instanceof Date) {
|
2868
|
-
return serializeDateFromDateJSON(value);
|
2869
|
-
}
|
2870
|
-
}
|
2871
|
-
|
2872
|
-
if (value.length >= 1024) {
|
2873
|
-
// For large strings, we encode them outside the JSON payload so that we
|
2874
|
-
// don't have to double encode and double parse the strings. This can also
|
2875
|
-
// be more compact in case the string has a lot of escaped characters.
|
2876
|
-
return serializeLargeTextString(request, value);
|
2877
|
-
}
|
2878
|
-
|
2879
|
-
return escapeStringValue(value);
|
2880
|
-
}
|
2881
|
-
|
2882
|
-
if (typeof value === 'boolean') {
|
2883
|
-
return value;
|
2884
|
-
}
|
2885
|
-
|
2886
|
-
if (typeof value === 'number') {
|
2887
|
-
return serializeNumber(value);
|
2888
|
-
}
|
2889
|
-
|
2890
|
-
if (typeof value === 'undefined') {
|
2891
|
-
return serializeUndefined();
|
2892
|
-
}
|
2893
|
-
|
2894
|
-
if (typeof value === 'function') {
|
2895
|
-
if (isClientReference(value)) {
|
2896
|
-
return serializeClientReference(request, parent, parentPropertyName, value);
|
2897
|
-
}
|
2898
|
-
|
2899
|
-
if (isTemporaryReference(value)) {
|
2900
|
-
return serializeTemporaryReference(request, value);
|
2901
|
-
} // Serialize the body of the function as an eval so it can be printed.
|
2902
|
-
// $FlowFixMe[method-unbinding]
|
2903
|
-
|
2904
|
-
|
2905
|
-
return serializeEval('(' + Function.prototype.toString.call(value) + ')');
|
2906
|
-
}
|
2907
|
-
|
2908
|
-
if (typeof value === 'symbol') {
|
2909
|
-
var writtenSymbols = request.writtenSymbols;
|
2910
|
-
|
2911
|
-
var _existingId3 = writtenSymbols.get(value);
|
2912
|
-
|
2913
|
-
if (_existingId3 !== undefined) {
|
2914
|
-
return serializeByValueID(_existingId3);
|
2915
|
-
} // $FlowFixMe[incompatible-type] `description` might be undefined
|
2916
|
-
|
2917
|
-
|
2918
|
-
var name = value.description; // We use the Symbol.for version if it's not a global symbol. Close enough.
|
2919
|
-
|
2920
|
-
request.pendingChunks++;
|
2921
|
-
var symbolId = request.nextChunkId++;
|
2922
|
-
emitSymbolChunk(request, symbolId, name);
|
2923
|
-
return serializeByValueID(symbolId);
|
2924
|
-
}
|
2925
|
-
|
2926
|
-
if (typeof value === 'bigint') {
|
2927
|
-
return serializeBigInt(value);
|
2928
|
-
}
|
2929
|
-
|
2930
|
-
return 'unknown type ' + typeof value;
|
2931
|
-
}
|
2932
|
-
|
2933
|
-
function outlineConsoleValue(request, counter, model) {
|
2934
|
-
|
2935
|
-
function replacer(parentPropertyName, value) {
|
2936
|
-
try {
|
2937
|
-
return renderConsoleValue(request, counter, this, parentPropertyName, value);
|
2938
|
-
} catch (x) {
|
2939
|
-
return 'unknown value';
|
2940
|
-
}
|
2941
|
-
} // $FlowFixMe[incompatible-type] stringify can return null
|
2942
|
-
|
2943
|
-
|
2944
|
-
var json = stringify(model, replacer);
|
2945
|
-
request.pendingChunks++;
|
2946
|
-
var id = request.nextChunkId++;
|
2947
|
-
var row = id.toString(16) + ':' + json + '\n';
|
2948
|
-
var processedChunk = stringToChunk(row);
|
2949
|
-
request.completedRegularChunks.push(processedChunk);
|
2950
|
-
return id;
|
2951
|
-
}
|
2952
|
-
|
2953
|
-
function forwardDebugInfo(request, id, debugInfo) {
|
2954
|
-
for (var i = 0; i < debugInfo.length; i++) {
|
2955
|
-
request.pendingChunks++;
|
2956
|
-
emitDebugChunk(request, id, debugInfo[i]);
|
2957
|
-
}
|
2958
|
-
}
|
2959
|
-
|
2960
|
-
var emptyRoot = {};
|
2961
|
-
|
2962
|
-
function retryTask(request, task) {
|
2963
|
-
if (task.status !== PENDING$1) {
|
2964
|
-
// We completed this by other means before we had a chance to retry it.
|
2965
|
-
return;
|
2966
|
-
}
|
2967
|
-
|
2968
|
-
var prevDebugID = debugID;
|
2969
|
-
|
2970
|
-
try {
|
2971
|
-
// Track the root so we know that we have to emit this object even though it
|
2972
|
-
// already has an ID. This is needed because we might see this object twice
|
2973
|
-
// in the same toJSON if it is cyclic.
|
2974
|
-
modelRoot = task.model;
|
2975
|
-
|
2976
|
-
if (true) {
|
2977
|
-
// Track the ID of the current task so we can assign debug info to this id.
|
2978
|
-
debugID = task.id;
|
2979
|
-
} // We call the destructive form that mutates this task. That way if something
|
2980
|
-
// suspends again, we can reuse the same task instead of spawning a new one.
|
2981
|
-
|
2982
|
-
|
2983
|
-
var resolvedModel = renderModelDestructive(request, task, emptyRoot, '', task.model);
|
2984
|
-
|
2985
|
-
if (true) {
|
2986
|
-
// We're now past rendering this task and future renders will spawn new tasks for their
|
2987
|
-
// debug info.
|
2988
|
-
debugID = null;
|
2989
|
-
} // Track the root again for the resolved object.
|
2990
|
-
|
2991
|
-
|
2992
|
-
modelRoot = resolvedModel; // The keyPath resets at any terminal child node.
|
2993
|
-
|
2994
|
-
task.keyPath = null;
|
2995
|
-
task.implicitSlot = false;
|
2996
|
-
var json;
|
2997
|
-
|
2998
|
-
if (typeof resolvedModel === 'object' && resolvedModel !== null) {
|
2999
|
-
// Object might contain unresolved values like additional elements.
|
3000
|
-
// This is simulating what the JSON loop would do if this was part of it.
|
3001
|
-
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
3002
|
-
json = stringify(resolvedModel, task.toJSON);
|
3003
|
-
} else {
|
3004
|
-
// If the value is a string, it means it's a terminal value and we already escaped it
|
3005
|
-
// We don't need to escape it again so it's not passed the toJSON replacer.
|
3006
|
-
// $FlowFixMe[incompatible-type] stringify can return null for undefined but we never do
|
3007
|
-
json = stringify(resolvedModel);
|
3008
|
-
}
|
3009
|
-
|
3010
|
-
emitModelChunk(request, task.id, json);
|
3011
|
-
request.abortableTasks.delete(task);
|
3012
|
-
task.status = COMPLETED;
|
3013
|
-
} catch (thrownValue) {
|
3014
|
-
var x = thrownValue === SuspenseException ? // This is a special type of exception used for Suspense. For historical
|
3015
|
-
// reasons, the rest of the Suspense implementation expects the thrown
|
3016
|
-
// value to be a thenable, because before `use` existed that was the
|
3017
|
-
// (unstable) API for suspending. This implementation detail can change
|
3018
|
-
// later, once we deprecate the old API in favor of `use`.
|
3019
|
-
getSuspendedThenable() : thrownValue;
|
3020
|
-
|
3021
|
-
if (typeof x === 'object' && x !== null) {
|
3022
|
-
// $FlowFixMe[method-unbinding]
|
3023
|
-
if (typeof x.then === 'function') {
|
3024
|
-
// Something suspended again, let's pick it back up later.
|
3025
|
-
var ping = task.ping;
|
3026
|
-
x.then(ping, ping);
|
3027
|
-
task.thenableState = getThenableStateAfterSuspending();
|
3028
|
-
return;
|
3029
|
-
}
|
3030
|
-
}
|
3031
|
-
|
3032
|
-
request.abortableTasks.delete(task);
|
3033
|
-
task.status = ERRORED$1;
|
3034
|
-
var digest = logRecoverableError(request, x);
|
3035
|
-
emitErrorChunk(request, task.id, digest, x);
|
3036
|
-
} finally {
|
3037
|
-
{
|
3038
|
-
debugID = prevDebugID;
|
3039
|
-
}
|
3040
|
-
}
|
3041
|
-
}
|
3042
|
-
|
3043
|
-
function performWork(request) {
|
3044
|
-
var prevDispatcher = ReactSharedInternals.H;
|
3045
|
-
ReactSharedInternals.H = HooksDispatcher;
|
3046
|
-
var prevRequest = currentRequest;
|
3047
|
-
currentRequest = request;
|
3048
|
-
prepareToUseHooksForRequest(request);
|
3049
|
-
|
3050
|
-
try {
|
3051
|
-
var pingedTasks = request.pingedTasks;
|
3052
|
-
request.pingedTasks = [];
|
3053
|
-
|
3054
|
-
for (var i = 0; i < pingedTasks.length; i++) {
|
3055
|
-
var task = pingedTasks[i];
|
3056
|
-
retryTask(request, task);
|
3057
|
-
}
|
3058
|
-
|
3059
|
-
if (request.destination !== null) {
|
3060
|
-
flushCompletedChunks(request, request.destination);
|
3061
|
-
}
|
3062
|
-
} catch (error) {
|
3063
|
-
logRecoverableError(request, error);
|
3064
|
-
fatalError(request, error);
|
3065
|
-
} finally {
|
3066
|
-
ReactSharedInternals.H = prevDispatcher;
|
3067
|
-
resetHooksForRequest();
|
3068
|
-
currentRequest = prevRequest;
|
3069
|
-
}
|
3070
|
-
}
|
3071
|
-
|
3072
|
-
function abortTask(task, request, errorId) {
|
3073
|
-
task.status = ABORTED; // Instead of emitting an error per task.id, we emit a model that only
|
3074
|
-
// has a single value referencing the error.
|
3075
|
-
|
3076
|
-
var ref = serializeByValueID(errorId);
|
3077
|
-
var processedChunk = encodeReferenceChunk(request, task.id, ref);
|
3078
|
-
request.completedErrorChunks.push(processedChunk);
|
3079
|
-
}
|
3080
|
-
|
3081
|
-
function flushCompletedChunks(request, destination) {
|
3082
|
-
beginWriting();
|
3083
|
-
|
3084
|
-
try {
|
3085
|
-
// We emit module chunks first in the stream so that
|
3086
|
-
// they can be preloaded as early as possible.
|
3087
|
-
var importsChunks = request.completedImportChunks;
|
3088
|
-
var i = 0;
|
3089
|
-
|
3090
|
-
for (; i < importsChunks.length; i++) {
|
3091
|
-
request.pendingChunks--;
|
3092
|
-
var chunk = importsChunks[i];
|
3093
|
-
var keepWriting = writeChunkAndReturn(destination, chunk);
|
3094
|
-
|
3095
|
-
if (!keepWriting) {
|
3096
|
-
request.destination = null;
|
3097
|
-
i++;
|
3098
|
-
break;
|
3099
|
-
}
|
3100
|
-
}
|
3101
|
-
|
3102
|
-
importsChunks.splice(0, i); // Next comes hints.
|
3103
|
-
|
3104
|
-
var hintChunks = request.completedHintChunks;
|
3105
|
-
i = 0;
|
3106
|
-
|
3107
|
-
for (; i < hintChunks.length; i++) {
|
3108
|
-
var _chunk = hintChunks[i];
|
3109
|
-
|
3110
|
-
var _keepWriting = writeChunkAndReturn(destination, _chunk);
|
3111
|
-
|
3112
|
-
if (!_keepWriting) {
|
3113
|
-
request.destination = null;
|
3114
|
-
i++;
|
3115
|
-
break;
|
3116
|
-
}
|
3117
|
-
}
|
3118
|
-
|
3119
|
-
hintChunks.splice(0, i); // Next comes model data.
|
3120
|
-
|
3121
|
-
var regularChunks = request.completedRegularChunks;
|
3122
|
-
i = 0;
|
3123
|
-
|
3124
|
-
for (; i < regularChunks.length; i++) {
|
3125
|
-
request.pendingChunks--;
|
3126
|
-
var _chunk2 = regularChunks[i];
|
3127
|
-
|
3128
|
-
var _keepWriting2 = writeChunkAndReturn(destination, _chunk2);
|
3129
|
-
|
3130
|
-
if (!_keepWriting2) {
|
3131
|
-
request.destination = null;
|
3132
|
-
i++;
|
3133
|
-
break;
|
3134
|
-
}
|
3135
|
-
}
|
3136
|
-
|
3137
|
-
regularChunks.splice(0, i); // Finally, errors are sent. The idea is that it's ok to delay
|
3138
|
-
// any error messages and prioritize display of other parts of
|
3139
|
-
// the page.
|
3140
|
-
|
3141
|
-
var errorChunks = request.completedErrorChunks;
|
3142
|
-
i = 0;
|
3143
|
-
|
3144
|
-
for (; i < errorChunks.length; i++) {
|
3145
|
-
request.pendingChunks--;
|
3146
|
-
var _chunk3 = errorChunks[i];
|
3147
|
-
|
3148
|
-
var _keepWriting3 = writeChunkAndReturn(destination, _chunk3);
|
3149
|
-
|
3150
|
-
if (!_keepWriting3) {
|
3151
|
-
request.destination = null;
|
3152
|
-
i++;
|
3153
|
-
break;
|
3154
|
-
}
|
3155
|
-
}
|
3156
|
-
|
3157
|
-
errorChunks.splice(0, i);
|
3158
|
-
} finally {
|
3159
|
-
request.flushScheduled = false;
|
3160
|
-
completeWriting(destination);
|
3161
|
-
}
|
3162
|
-
|
3163
|
-
if (request.pendingChunks === 0) {
|
3164
|
-
|
3165
|
-
close$1(destination);
|
3166
|
-
}
|
3167
|
-
}
|
3168
|
-
|
3169
|
-
function startWork(request) {
|
3170
|
-
request.flushScheduled = request.destination !== null;
|
3171
|
-
|
3172
|
-
{
|
3173
|
-
scheduleWork(function () {
|
3174
|
-
return performWork(request);
|
3175
|
-
});
|
3176
|
-
}
|
3177
|
-
}
|
3178
|
-
|
3179
|
-
function enqueueFlush(request) {
|
3180
|
-
if (request.flushScheduled === false && // If there are pinged tasks we are going to flush anyway after work completes
|
3181
|
-
request.pingedTasks.length === 0 && // If there is no destination there is nothing we can flush to. A flush will
|
3182
|
-
// happen when we start flowing again
|
3183
|
-
request.destination !== null) {
|
3184
|
-
var destination = request.destination;
|
3185
|
-
request.flushScheduled = true;
|
3186
|
-
scheduleWork(function () {
|
3187
|
-
return flushCompletedChunks(request, destination);
|
3188
|
-
});
|
3189
|
-
}
|
3190
|
-
}
|
3191
|
-
|
3192
|
-
function startFlowing(request, destination) {
|
3193
|
-
if (request.status === CLOSING) {
|
3194
|
-
request.status = CLOSED;
|
3195
|
-
closeWithError(destination, request.fatalError);
|
3196
|
-
return;
|
3197
|
-
}
|
3198
|
-
|
3199
|
-
if (request.status === CLOSED) {
|
3200
|
-
return;
|
3201
|
-
}
|
3202
|
-
|
3203
|
-
if (request.destination !== null) {
|
3204
|
-
// We're already flowing.
|
3205
|
-
return;
|
3206
|
-
}
|
3207
|
-
|
3208
|
-
request.destination = destination;
|
3209
|
-
|
3210
|
-
try {
|
3211
|
-
flushCompletedChunks(request, destination);
|
3212
|
-
} catch (error) {
|
3213
|
-
logRecoverableError(request, error);
|
3214
|
-
fatalError(request, error);
|
3215
|
-
}
|
3216
|
-
}
|
3217
|
-
function stopFlowing(request) {
|
3218
|
-
request.destination = null;
|
3219
|
-
} // This is called to early terminate a request. It creates an error at all pending tasks.
|
3220
|
-
|
3221
|
-
function abort(request, reason) {
|
3222
|
-
try {
|
3223
|
-
var abortableTasks = request.abortableTasks;
|
3224
|
-
|
3225
|
-
if (abortableTasks.size > 0) {
|
3226
|
-
// We have tasks to abort. We'll emit one error row and then emit a reference
|
3227
|
-
// to that row from every row that's still remaining.
|
3228
|
-
request.pendingChunks++;
|
3229
|
-
var errorId = request.nextChunkId++;
|
3230
|
-
|
3231
|
-
var postponeInstance; if (enablePostpone && typeof reason === 'object' && reason !== null && reason.$$typeof === REACT_POSTPONE_TYPE) ; else {
|
3232
|
-
var error = reason === undefined ? new Error('The render was aborted by the server without a reason.') : reason;
|
3233
|
-
var digest = logRecoverableError(request, error);
|
3234
|
-
emitErrorChunk(request, errorId, digest, error);
|
3235
|
-
}
|
3236
|
-
|
3237
|
-
abortableTasks.forEach(function (task) {
|
3238
|
-
return abortTask(task, request, errorId);
|
3239
|
-
});
|
3240
|
-
abortableTasks.clear();
|
3241
|
-
}
|
3242
|
-
|
3243
|
-
if (request.destination !== null) {
|
3244
|
-
flushCompletedChunks(request, request.destination);
|
3245
|
-
}
|
3246
|
-
} catch (error) {
|
3247
|
-
logRecoverableError(request, error);
|
3248
|
-
fatalError(request, error);
|
3249
|
-
}
|
3250
|
-
}
|
3251
|
-
|
3252
|
-
// This is the parsed shape of the wire format which is why it is
|
3253
|
-
// condensed to only the essentialy information
|
3254
|
-
var ID = 0;
|
3255
|
-
var CHUNKS = 1;
|
3256
|
-
var NAME = 2; // export const ASYNC = 3;
|
3257
|
-
// This logic is correct because currently only include the 4th tuple member
|
3258
|
-
// when the module is async. If that changes we will need to actually assert
|
3259
|
-
// the value is true. We don't index into the 4th slot because flow does not
|
3260
|
-
// like the potential out of bounds access
|
3261
|
-
|
3262
|
-
function isAsyncImport(metadata) {
|
3263
|
-
return metadata.length === 4;
|
3264
|
-
}
|
3265
|
-
|
3266
|
-
function resolveServerReference(bundlerConfig, id) {
|
3267
|
-
var name = '';
|
3268
|
-
var resolvedModuleData = bundlerConfig[id];
|
3269
|
-
|
3270
|
-
if (resolvedModuleData) {
|
3271
|
-
// The potentially aliased name.
|
3272
|
-
name = resolvedModuleData.name;
|
3273
|
-
} else {
|
3274
|
-
// We didn't find this specific export name but we might have the * export
|
3275
|
-
// which contains this name as well.
|
3276
|
-
// TODO: It's unfortunate that we now have to parse this string. We should
|
3277
|
-
// probably go back to encoding path and name separately on the client reference.
|
3278
|
-
var idx = id.lastIndexOf('#');
|
3279
|
-
|
3280
|
-
if (idx !== -1) {
|
3281
|
-
name = id.slice(idx + 1);
|
3282
|
-
resolvedModuleData = bundlerConfig[id.slice(0, idx)];
|
3283
|
-
}
|
3284
|
-
|
3285
|
-
if (!resolvedModuleData) {
|
3286
|
-
throw new Error('Could not find the module "' + id + '" in the React Server Manifest. ' + 'This is probably a bug in the React Server Components bundler.');
|
3287
|
-
}
|
3288
|
-
} // TODO: This needs to return async: true if it's an async module.
|
3289
|
-
|
3290
|
-
|
3291
|
-
return [resolvedModuleData.id, resolvedModuleData.chunks, name];
|
3292
|
-
} // The chunk cache contains all the chunks we've preloaded so far.
|
3293
|
-
// If they're still pending they're a thenable. This map also exists
|
3294
|
-
// in Webpack but unfortunately it's not exposed so we have to
|
3295
|
-
// replicate it in user space. null means that it has already loaded.
|
3296
|
-
|
3297
|
-
var chunkCache = new Map();
|
3298
|
-
|
3299
|
-
function requireAsyncModule(id) {
|
3300
|
-
// We've already loaded all the chunks. We can require the module.
|
3301
|
-
var promise = __webpack_require__(id);
|
3302
|
-
|
3303
|
-
if (typeof promise.then !== 'function') {
|
3304
|
-
// This wasn't a promise after all.
|
3305
|
-
return null;
|
3306
|
-
} else if (promise.status === 'fulfilled') {
|
3307
|
-
// This module was already resolved earlier.
|
3308
|
-
return null;
|
3309
|
-
} else {
|
3310
|
-
// Instrument the Promise to stash the result.
|
3311
|
-
promise.then(function (value) {
|
3312
|
-
var fulfilledThenable = promise;
|
3313
|
-
fulfilledThenable.status = 'fulfilled';
|
3314
|
-
fulfilledThenable.value = value;
|
3315
|
-
}, function (reason) {
|
3316
|
-
var rejectedThenable = promise;
|
3317
|
-
rejectedThenable.status = 'rejected';
|
3318
|
-
rejectedThenable.reason = reason;
|
3319
|
-
});
|
3320
|
-
return promise;
|
3321
|
-
}
|
3322
|
-
}
|
3323
|
-
|
3324
|
-
function ignoreReject() {// We rely on rejected promises to be handled by another listener.
|
3325
|
-
} // Start preloading the modules since we might need them soon.
|
3326
|
-
// This function doesn't suspend.
|
3327
|
-
|
3328
|
-
|
3329
|
-
function preloadModule(metadata) {
|
3330
|
-
var chunks = metadata[CHUNKS];
|
3331
|
-
var promises = [];
|
3332
|
-
var i = 0;
|
3333
|
-
|
3334
|
-
while (i < chunks.length) {
|
3335
|
-
var chunkId = chunks[i++];
|
3336
|
-
var chunkFilename = chunks[i++];
|
3337
|
-
var entry = chunkCache.get(chunkId);
|
3338
|
-
|
3339
|
-
if (entry === undefined) {
|
3340
|
-
var thenable = loadChunk(chunkId, chunkFilename);
|
3341
|
-
promises.push(thenable); // $FlowFixMe[method-unbinding]
|
3342
|
-
|
3343
|
-
var resolve = chunkCache.set.bind(chunkCache, chunkId, null);
|
3344
|
-
thenable.then(resolve, ignoreReject);
|
3345
|
-
chunkCache.set(chunkId, thenable);
|
3346
|
-
} else if (entry !== null) {
|
3347
|
-
promises.push(entry);
|
3348
|
-
}
|
3349
|
-
}
|
3350
|
-
|
3351
|
-
if (isAsyncImport(metadata)) {
|
3352
|
-
if (promises.length === 0) {
|
3353
|
-
return requireAsyncModule(metadata[ID]);
|
3354
|
-
} else {
|
3355
|
-
return Promise.all(promises).then(function () {
|
3356
|
-
return requireAsyncModule(metadata[ID]);
|
3357
|
-
});
|
3358
|
-
}
|
3359
|
-
} else if (promises.length > 0) {
|
3360
|
-
return Promise.all(promises);
|
3361
|
-
} else {
|
3362
|
-
return null;
|
3363
|
-
}
|
3364
|
-
} // Actually require the module or suspend if it's not yet ready.
|
3365
|
-
// Increase priority if necessary.
|
3366
|
-
|
3367
|
-
function requireModule(metadata) {
|
3368
|
-
var moduleExports = __webpack_require__(metadata[ID]);
|
3369
|
-
|
3370
|
-
if (isAsyncImport(metadata)) {
|
3371
|
-
if (typeof moduleExports.then !== 'function') ; else if (moduleExports.status === 'fulfilled') {
|
3372
|
-
// This Promise should've been instrumented by preloadModule.
|
3373
|
-
moduleExports = moduleExports.value;
|
3374
|
-
} else {
|
3375
|
-
throw moduleExports.reason;
|
3376
|
-
}
|
3377
|
-
}
|
3378
|
-
|
3379
|
-
if (metadata[NAME] === '*') {
|
3380
|
-
// This is a placeholder value that represents that the caller imported this
|
3381
|
-
// as a CommonJS module as is.
|
3382
|
-
return moduleExports;
|
3383
|
-
}
|
3384
|
-
|
3385
|
-
if (metadata[NAME] === '') {
|
3386
|
-
// This is a placeholder value that represents that the caller accessed the
|
3387
|
-
// default property of this if it was an ESM interop module.
|
3388
|
-
return moduleExports.__esModule ? moduleExports.default : moduleExports;
|
3389
|
-
}
|
3390
|
-
|
3391
|
-
return moduleExports[metadata[NAME]];
|
3392
|
-
}
|
3393
|
-
|
3394
|
-
var chunkMap = new Map();
|
3395
|
-
/**
|
3396
|
-
* We patch the chunk filename function in webpack to insert our own resolution
|
3397
|
-
* of chunks that come from Flight and may not be known to the webpack runtime
|
3398
|
-
*/
|
3399
|
-
|
3400
|
-
var webpackGetChunkFilename = __webpack_require__.u;
|
3401
|
-
|
3402
|
-
__webpack_require__.u = function (chunkId) {
|
3403
|
-
var flightChunk = chunkMap.get(chunkId);
|
3404
|
-
|
3405
|
-
if (flightChunk !== undefined) {
|
3406
|
-
return flightChunk;
|
3407
|
-
}
|
3408
|
-
|
3409
|
-
return webpackGetChunkFilename(chunkId);
|
3410
|
-
};
|
3411
|
-
|
3412
|
-
function loadChunk(chunkId, filename) {
|
3413
|
-
chunkMap.set(chunkId, filename);
|
3414
|
-
return __webpack_chunk_load__(chunkId);
|
3415
|
-
}
|
3416
|
-
|
3417
|
-
// The server acts as a Client of itself when resolving Server References.
|
3418
|
-
var PENDING = 'pending';
|
3419
|
-
var BLOCKED = 'blocked';
|
3420
|
-
var RESOLVED_MODEL = 'resolved_model';
|
3421
|
-
var INITIALIZED = 'fulfilled';
|
3422
|
-
var ERRORED = 'rejected'; // $FlowFixMe[missing-this-annot]
|
3423
|
-
|
3424
|
-
function Chunk(status, value, reason, response) {
|
3425
|
-
this.status = status;
|
3426
|
-
this.value = value;
|
3427
|
-
this.reason = reason;
|
3428
|
-
this._response = response;
|
3429
|
-
} // We subclass Promise.prototype so that we get other methods like .catch
|
3430
|
-
|
3431
|
-
|
3432
|
-
Chunk.prototype = Object.create(Promise.prototype); // TODO: This doesn't return a new Promise chain unlike the real .then
|
3433
|
-
|
3434
|
-
Chunk.prototype.then = function (resolve, reject) {
|
3435
|
-
var chunk = this; // If we have resolved content, we try to initialize it first which
|
3436
|
-
// might put us back into one of the other states.
|
3437
|
-
|
3438
|
-
switch (chunk.status) {
|
3439
|
-
case RESOLVED_MODEL:
|
3440
|
-
initializeModelChunk(chunk);
|
3441
|
-
break;
|
3442
|
-
} // The status might have changed after initialization.
|
3443
|
-
|
3444
|
-
|
3445
|
-
switch (chunk.status) {
|
3446
|
-
case INITIALIZED:
|
3447
|
-
resolve(chunk.value);
|
3448
|
-
break;
|
3449
|
-
|
3450
|
-
case PENDING:
|
3451
|
-
case BLOCKED:
|
3452
|
-
if (resolve) {
|
3453
|
-
if (chunk.value === null) {
|
3454
|
-
chunk.value = [];
|
3455
|
-
}
|
3456
|
-
|
3457
|
-
chunk.value.push(resolve);
|
3458
|
-
}
|
3459
|
-
|
3460
|
-
if (reject) {
|
3461
|
-
if (chunk.reason === null) {
|
3462
|
-
chunk.reason = [];
|
3463
|
-
}
|
3464
|
-
|
3465
|
-
chunk.reason.push(reject);
|
3466
|
-
}
|
3467
|
-
|
3468
|
-
break;
|
3469
|
-
|
3470
|
-
default:
|
3471
|
-
reject(chunk.reason);
|
3472
|
-
break;
|
3473
|
-
}
|
3474
|
-
};
|
3475
|
-
|
3476
|
-
function getRoot(response) {
|
3477
|
-
var chunk = getChunk(response, 0);
|
3478
|
-
return chunk;
|
3479
|
-
}
|
3480
|
-
|
3481
|
-
function createPendingChunk(response) {
|
3482
|
-
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
3483
|
-
return new Chunk(PENDING, null, null, response);
|
3484
|
-
}
|
3485
|
-
|
3486
|
-
function wakeChunk(listeners, value) {
|
3487
|
-
for (var i = 0; i < listeners.length; i++) {
|
3488
|
-
var listener = listeners[i];
|
3489
|
-
listener(value);
|
3490
|
-
}
|
3491
|
-
}
|
3492
|
-
|
3493
|
-
function triggerErrorOnChunk(chunk, error) {
|
3494
|
-
if (chunk.status !== PENDING && chunk.status !== BLOCKED) {
|
3495
|
-
// We already resolved. We didn't expect to see this.
|
3496
|
-
return;
|
3497
|
-
}
|
3498
|
-
|
3499
|
-
var listeners = chunk.reason;
|
3500
|
-
var erroredChunk = chunk;
|
3501
|
-
erroredChunk.status = ERRORED;
|
3502
|
-
erroredChunk.reason = error;
|
3503
|
-
|
3504
|
-
if (listeners !== null) {
|
3505
|
-
wakeChunk(listeners, error);
|
3506
|
-
}
|
3507
|
-
}
|
3508
|
-
|
3509
|
-
function createResolvedModelChunk(response, value) {
|
3510
|
-
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
3511
|
-
return new Chunk(RESOLVED_MODEL, value, null, response);
|
3512
|
-
}
|
3513
|
-
|
3514
|
-
function bindArgs$1(fn, args) {
|
3515
|
-
return fn.bind.apply(fn, [null].concat(args));
|
3516
|
-
}
|
3517
|
-
|
3518
|
-
function loadServerReference$1(response, id, bound, parentChunk, parentObject, key) {
|
3519
|
-
var serverReference = resolveServerReference(response._bundlerConfig, id); // We expect most servers to not really need this because you'd just have all
|
3520
|
-
// the relevant modules already loaded but it allows for lazy loading of code
|
3521
|
-
// if needed.
|
3522
|
-
|
3523
|
-
var preloadPromise = preloadModule(serverReference);
|
3524
|
-
var promise;
|
3525
|
-
|
3526
|
-
if (bound) {
|
3527
|
-
promise = Promise.all([bound, preloadPromise]).then(function (_ref) {
|
3528
|
-
var args = _ref[0];
|
3529
|
-
return bindArgs$1(requireModule(serverReference), args);
|
3530
|
-
});
|
3531
|
-
} else {
|
3532
|
-
if (preloadPromise) {
|
3533
|
-
promise = Promise.resolve(preloadPromise).then(function () {
|
3534
|
-
return requireModule(serverReference);
|
3535
|
-
});
|
3536
|
-
} else {
|
3537
|
-
// Synchronously available
|
3538
|
-
return requireModule(serverReference);
|
3539
|
-
}
|
3540
|
-
}
|
3541
|
-
|
3542
|
-
promise.then(createModelResolver(parentChunk, parentObject, key), createModelReject(parentChunk)); // We need a placeholder value that will be replaced later.
|
3543
|
-
|
3544
|
-
return null;
|
3545
|
-
}
|
3546
|
-
|
3547
|
-
var initializingChunk = null;
|
3548
|
-
var initializingChunkBlockedModel = null;
|
3549
|
-
|
3550
|
-
function initializeModelChunk(chunk) {
|
3551
|
-
var prevChunk = initializingChunk;
|
3552
|
-
var prevBlocked = initializingChunkBlockedModel;
|
3553
|
-
initializingChunk = chunk;
|
3554
|
-
initializingChunkBlockedModel = null;
|
3555
|
-
|
3556
|
-
try {
|
3557
|
-
var value = JSON.parse(chunk.value, chunk._response._fromJSON);
|
3558
|
-
|
3559
|
-
if (initializingChunkBlockedModel !== null && initializingChunkBlockedModel.deps > 0) {
|
3560
|
-
initializingChunkBlockedModel.value = value; // We discovered new dependencies on modules that are not yet resolved.
|
3561
|
-
// We have to go the BLOCKED state until they're resolved.
|
3562
|
-
|
3563
|
-
var blockedChunk = chunk;
|
3564
|
-
blockedChunk.status = BLOCKED;
|
3565
|
-
blockedChunk.value = null;
|
3566
|
-
blockedChunk.reason = null;
|
3567
|
-
} else {
|
3568
|
-
var initializedChunk = chunk;
|
3569
|
-
initializedChunk.status = INITIALIZED;
|
3570
|
-
initializedChunk.value = value;
|
3571
|
-
}
|
3572
|
-
} catch (error) {
|
3573
|
-
var erroredChunk = chunk;
|
3574
|
-
erroredChunk.status = ERRORED;
|
3575
|
-
erroredChunk.reason = error;
|
3576
|
-
} finally {
|
3577
|
-
initializingChunk = prevChunk;
|
3578
|
-
initializingChunkBlockedModel = prevBlocked;
|
3579
|
-
}
|
3580
|
-
} // Report that any missing chunks in the model is now going to throw this
|
3581
|
-
// error upon read. Also notify any pending promises.
|
3582
|
-
|
3583
|
-
|
3584
|
-
function reportGlobalError(response, error) {
|
3585
|
-
response._chunks.forEach(function (chunk) {
|
3586
|
-
// If this chunk was already resolved or errored, it won't
|
3587
|
-
// trigger an error but if it wasn't then we need to
|
3588
|
-
// because we won't be getting any new data to resolve it.
|
3589
|
-
if (chunk.status === PENDING) {
|
3590
|
-
triggerErrorOnChunk(chunk, error);
|
3591
|
-
}
|
3592
|
-
});
|
3593
|
-
}
|
3594
|
-
|
3595
|
-
function getChunk(response, id) {
|
3596
|
-
var chunks = response._chunks;
|
3597
|
-
var chunk = chunks.get(id);
|
3598
|
-
|
3599
|
-
if (!chunk) {
|
3600
|
-
var prefix = response._prefix;
|
3601
|
-
var key = prefix + id; // Check if we have this field in the backing store already.
|
3602
|
-
|
3603
|
-
var backingEntry = response._formData.get(key);
|
3604
|
-
|
3605
|
-
if (backingEntry != null) {
|
3606
|
-
// We assume that this is a string entry for now.
|
3607
|
-
chunk = createResolvedModelChunk(response, backingEntry);
|
3608
|
-
} else {
|
3609
|
-
// We're still waiting on this entry to stream in.
|
3610
|
-
chunk = createPendingChunk(response);
|
3611
|
-
}
|
3612
|
-
|
3613
|
-
chunks.set(id, chunk);
|
3614
|
-
}
|
3615
|
-
|
3616
|
-
return chunk;
|
3617
|
-
}
|
3618
|
-
|
3619
|
-
function createModelResolver(chunk, parentObject, key) {
|
3620
|
-
var blocked;
|
3621
|
-
|
3622
|
-
if (initializingChunkBlockedModel) {
|
3623
|
-
blocked = initializingChunkBlockedModel;
|
3624
|
-
blocked.deps++;
|
3625
|
-
} else {
|
3626
|
-
blocked = initializingChunkBlockedModel = {
|
3627
|
-
deps: 1,
|
3628
|
-
value: null
|
3629
|
-
};
|
3630
|
-
}
|
3631
|
-
|
3632
|
-
return function (value) {
|
3633
|
-
parentObject[key] = value;
|
3634
|
-
blocked.deps--;
|
3635
|
-
|
3636
|
-
if (blocked.deps === 0) {
|
3637
|
-
if (chunk.status !== BLOCKED) {
|
3638
|
-
return;
|
3639
|
-
}
|
3640
|
-
|
3641
|
-
var resolveListeners = chunk.value;
|
3642
|
-
var initializedChunk = chunk;
|
3643
|
-
initializedChunk.status = INITIALIZED;
|
3644
|
-
initializedChunk.value = blocked.value;
|
3645
|
-
|
3646
|
-
if (resolveListeners !== null) {
|
3647
|
-
wakeChunk(resolveListeners, blocked.value);
|
3648
|
-
}
|
3649
|
-
}
|
3650
|
-
};
|
3651
|
-
}
|
3652
|
-
|
3653
|
-
function createModelReject(chunk) {
|
3654
|
-
return function (error) {
|
3655
|
-
return triggerErrorOnChunk(chunk, error);
|
3656
|
-
};
|
3657
|
-
}
|
3658
|
-
|
3659
|
-
function getOutlinedModel(response, id) {
|
3660
|
-
var chunk = getChunk(response, id);
|
3661
|
-
|
3662
|
-
if (chunk.status === RESOLVED_MODEL) {
|
3663
|
-
initializeModelChunk(chunk);
|
3664
|
-
}
|
3665
|
-
|
3666
|
-
if (chunk.status !== INITIALIZED) {
|
3667
|
-
// We know that this is emitted earlier so otherwise it's an error.
|
3668
|
-
throw chunk.reason;
|
3669
|
-
}
|
3670
|
-
|
3671
|
-
return chunk.value;
|
3672
|
-
}
|
3673
|
-
|
3674
|
-
function parseModelString(response, obj, key, value) {
|
3675
|
-
if (value[0] === '$') {
|
3676
|
-
switch (value[1]) {
|
3677
|
-
case '$':
|
3678
|
-
{
|
3679
|
-
// This was an escaped string value.
|
3680
|
-
return value.slice(1);
|
3681
|
-
}
|
3682
|
-
|
3683
|
-
case '@':
|
3684
|
-
{
|
3685
|
-
// Promise
|
3686
|
-
var _id = parseInt(value.slice(2), 16);
|
3687
|
-
|
3688
|
-
var _chunk = getChunk(response, _id);
|
3689
|
-
|
3690
|
-
return _chunk;
|
3691
|
-
}
|
3692
|
-
|
3693
|
-
case 'F':
|
3694
|
-
{
|
3695
|
-
// Server Reference
|
3696
|
-
var _id2 = parseInt(value.slice(2), 16); // TODO: Just encode this in the reference inline instead of as a model.
|
3697
|
-
|
3698
|
-
|
3699
|
-
var metaData = getOutlinedModel(response, _id2);
|
3700
|
-
return loadServerReference$1(response, metaData.id, metaData.bound, initializingChunk, obj, key);
|
3701
|
-
}
|
3702
|
-
|
3703
|
-
case 'T':
|
3704
|
-
{
|
3705
|
-
// Temporary Reference
|
3706
|
-
return createTemporaryReference(value.slice(2));
|
3707
|
-
}
|
3708
|
-
|
3709
|
-
case 'Q':
|
3710
|
-
{
|
3711
|
-
// Map
|
3712
|
-
var _id3 = parseInt(value.slice(2), 16);
|
3713
|
-
|
3714
|
-
var data = getOutlinedModel(response, _id3);
|
3715
|
-
return new Map(data);
|
3716
|
-
}
|
3717
|
-
|
3718
|
-
case 'W':
|
3719
|
-
{
|
3720
|
-
// Set
|
3721
|
-
var _id4 = parseInt(value.slice(2), 16);
|
3722
|
-
|
3723
|
-
var _data = getOutlinedModel(response, _id4);
|
3724
|
-
|
3725
|
-
return new Set(_data);
|
3726
|
-
}
|
3727
|
-
|
3728
|
-
case 'K':
|
3729
|
-
{
|
3730
|
-
// FormData
|
3731
|
-
var stringId = value.slice(2);
|
3732
|
-
var formPrefix = response._prefix + stringId + '_';
|
3733
|
-
|
3734
|
-
var _data2 = new FormData();
|
3735
|
-
|
3736
|
-
var backingFormData = response._formData; // We assume that the reference to FormData always comes after each
|
3737
|
-
// entry that it references so we can assume they all exist in the
|
3738
|
-
// backing store already.
|
3739
|
-
// $FlowFixMe[prop-missing] FormData has forEach on it.
|
3740
|
-
|
3741
|
-
backingFormData.forEach(function (entry, entryKey) {
|
3742
|
-
if (entryKey.startsWith(formPrefix)) {
|
3743
|
-
_data2.append(entryKey.slice(formPrefix.length), entry);
|
3744
|
-
}
|
3745
|
-
});
|
3746
|
-
return _data2;
|
3747
|
-
}
|
3748
|
-
|
3749
|
-
case 'I':
|
3750
|
-
{
|
3751
|
-
// $Infinity
|
3752
|
-
return Infinity;
|
3753
|
-
}
|
3754
|
-
|
3755
|
-
case '-':
|
3756
|
-
{
|
3757
|
-
// $-0 or $-Infinity
|
3758
|
-
if (value === '$-0') {
|
3759
|
-
return -0;
|
3760
|
-
} else {
|
3761
|
-
return -Infinity;
|
3762
|
-
}
|
3763
|
-
}
|
3764
|
-
|
3765
|
-
case 'N':
|
3766
|
-
{
|
3767
|
-
// $NaN
|
3768
|
-
return NaN;
|
3769
|
-
}
|
3770
|
-
|
3771
|
-
case 'u':
|
3772
|
-
{
|
3773
|
-
// matches "$undefined"
|
3774
|
-
// Special encoding for `undefined` which can't be serialized as JSON otherwise.
|
3775
|
-
return undefined;
|
3776
|
-
}
|
3777
|
-
|
3778
|
-
case 'D':
|
3779
|
-
{
|
3780
|
-
// Date
|
3781
|
-
return new Date(Date.parse(value.slice(2)));
|
3782
|
-
}
|
3783
|
-
|
3784
|
-
case 'n':
|
3785
|
-
{
|
3786
|
-
// BigInt
|
3787
|
-
return BigInt(value.slice(2));
|
3788
|
-
}
|
3789
|
-
}
|
3790
|
-
|
3791
|
-
|
3792
|
-
var id = parseInt(value.slice(1), 16);
|
3793
|
-
var chunk = getChunk(response, id);
|
3794
|
-
|
3795
|
-
switch (chunk.status) {
|
3796
|
-
case RESOLVED_MODEL:
|
3797
|
-
initializeModelChunk(chunk);
|
3798
|
-
break;
|
3799
|
-
} // The status might have changed after initialization.
|
3800
|
-
|
3801
|
-
|
3802
|
-
switch (chunk.status) {
|
3803
|
-
case INITIALIZED:
|
3804
|
-
return chunk.value;
|
3805
|
-
|
3806
|
-
case PENDING:
|
3807
|
-
case BLOCKED:
|
3808
|
-
var parentChunk = initializingChunk;
|
3809
|
-
chunk.then(createModelResolver(parentChunk, obj, key), createModelReject(parentChunk));
|
3810
|
-
return null;
|
3811
|
-
|
3812
|
-
default:
|
3813
|
-
throw chunk.reason;
|
3814
|
-
}
|
3815
|
-
}
|
3816
|
-
|
3817
|
-
return value;
|
3818
|
-
}
|
3819
|
-
|
3820
|
-
function createResponse(bundlerConfig, formFieldPrefix) {
|
3821
|
-
var backingFormData = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new FormData();
|
3822
|
-
var chunks = new Map();
|
3823
|
-
var response = {
|
3824
|
-
_bundlerConfig: bundlerConfig,
|
3825
|
-
_prefix: formFieldPrefix,
|
3826
|
-
_formData: backingFormData,
|
3827
|
-
_chunks: chunks,
|
3828
|
-
_fromJSON: function (key, value) {
|
3829
|
-
if (typeof value === 'string') {
|
3830
|
-
// We can't use .bind here because we need the "this" value.
|
3831
|
-
return parseModelString(response, this, key, value);
|
3832
|
-
}
|
3833
|
-
|
3834
|
-
return value;
|
3835
|
-
}
|
3836
|
-
};
|
3837
|
-
return response;
|
3838
|
-
}
|
3839
|
-
function close(response) {
|
3840
|
-
// In case there are any remaining unresolved chunks, they won't
|
3841
|
-
// be resolved now. So we need to issue an error to those.
|
3842
|
-
// Ideally we should be able to early bail out if we kept a
|
3843
|
-
// ref count of pending chunks.
|
3844
|
-
reportGlobalError(response, new Error('Connection closed.'));
|
3845
|
-
}
|
3846
|
-
|
3847
|
-
function bindArgs(fn, args) {
|
3848
|
-
return fn.bind.apply(fn, [null].concat(args));
|
3849
|
-
}
|
3850
|
-
|
3851
|
-
function loadServerReference(bundlerConfig, id, bound) {
|
3852
|
-
var serverReference = resolveServerReference(bundlerConfig, id); // We expect most servers to not really need this because you'd just have all
|
3853
|
-
// the relevant modules already loaded but it allows for lazy loading of code
|
3854
|
-
// if needed.
|
3855
|
-
|
3856
|
-
var preloadPromise = preloadModule(serverReference);
|
3857
|
-
|
3858
|
-
if (bound) {
|
3859
|
-
return Promise.all([bound, preloadPromise]).then(function (_ref) {
|
3860
|
-
var args = _ref[0];
|
3861
|
-
return bindArgs(requireModule(serverReference), args);
|
3862
|
-
});
|
3863
|
-
} else if (preloadPromise) {
|
3864
|
-
return Promise.resolve(preloadPromise).then(function () {
|
3865
|
-
return requireModule(serverReference);
|
3866
|
-
});
|
3867
|
-
} else {
|
3868
|
-
// Synchronously available
|
3869
|
-
return Promise.resolve(requireModule(serverReference));
|
3870
|
-
}
|
3871
|
-
}
|
3872
|
-
|
3873
|
-
function decodeBoundActionMetaData(body, serverManifest, formFieldPrefix) {
|
3874
|
-
// The data for this reference is encoded in multiple fields under this prefix.
|
3875
|
-
var actionResponse = createResponse(serverManifest, formFieldPrefix, body);
|
3876
|
-
close(actionResponse);
|
3877
|
-
var refPromise = getRoot(actionResponse); // Force it to initialize
|
3878
|
-
// $FlowFixMe
|
3879
|
-
|
3880
|
-
refPromise.then(function () {});
|
3881
|
-
|
3882
|
-
if (refPromise.status !== 'fulfilled') {
|
3883
|
-
// $FlowFixMe
|
3884
|
-
throw refPromise.reason;
|
3885
|
-
}
|
3886
|
-
|
3887
|
-
return refPromise.value;
|
3888
|
-
}
|
3889
|
-
|
3890
|
-
function decodeAction(body, serverManifest) {
|
3891
|
-
// We're going to create a new formData object that holds all the fields except
|
3892
|
-
// the implementation details of the action data.
|
3893
|
-
var formData = new FormData();
|
3894
|
-
var action = null; // $FlowFixMe[prop-missing]
|
3895
|
-
|
3896
|
-
body.forEach(function (value, key) {
|
3897
|
-
if (!key.startsWith('$ACTION_')) {
|
3898
|
-
formData.append(key, value);
|
3899
|
-
return;
|
3900
|
-
} // Later actions may override earlier actions if a button is used to override the default
|
3901
|
-
// form action.
|
3902
|
-
|
3903
|
-
|
3904
|
-
if (key.startsWith('$ACTION_REF_')) {
|
3905
|
-
var formFieldPrefix = '$ACTION_' + key.slice(12) + ':';
|
3906
|
-
var metaData = decodeBoundActionMetaData(body, serverManifest, formFieldPrefix);
|
3907
|
-
action = loadServerReference(serverManifest, metaData.id, metaData.bound);
|
3908
|
-
return;
|
3909
|
-
}
|
3910
|
-
|
3911
|
-
if (key.startsWith('$ACTION_ID_')) {
|
3912
|
-
var id = key.slice(11);
|
3913
|
-
action = loadServerReference(serverManifest, id, null);
|
3914
|
-
return;
|
3915
|
-
}
|
3916
|
-
});
|
3917
|
-
|
3918
|
-
if (action === null) {
|
3919
|
-
return null;
|
3920
|
-
} // Return the action with the remaining FormData bound to the first argument.
|
3921
|
-
|
3922
|
-
|
3923
|
-
return action.then(function (fn) {
|
3924
|
-
return fn.bind(null, formData);
|
3925
|
-
});
|
3926
|
-
}
|
3927
|
-
function decodeFormState(actionResult, body, serverManifest) {
|
3928
|
-
var keyPath = body.get('$ACTION_KEY');
|
3929
|
-
|
3930
|
-
if (typeof keyPath !== 'string') {
|
3931
|
-
// This form submission did not include any form state.
|
3932
|
-
return Promise.resolve(null);
|
3933
|
-
} // Search through the form data object to get the reference id and the number
|
3934
|
-
// of bound arguments. This repeats some of the work done in decodeAction.
|
3935
|
-
|
3936
|
-
|
3937
|
-
var metaData = null; // $FlowFixMe[prop-missing]
|
3938
|
-
|
3939
|
-
body.forEach(function (value, key) {
|
3940
|
-
if (key.startsWith('$ACTION_REF_')) {
|
3941
|
-
var formFieldPrefix = '$ACTION_' + key.slice(12) + ':';
|
3942
|
-
metaData = decodeBoundActionMetaData(body, serverManifest, formFieldPrefix);
|
3943
|
-
} // We don't check for the simple $ACTION_ID_ case because form state actions
|
3944
|
-
// are always bound to the state argument.
|
3945
|
-
|
3946
|
-
});
|
3947
|
-
|
3948
|
-
if (metaData === null) {
|
3949
|
-
// Should be unreachable.
|
3950
|
-
return Promise.resolve(null);
|
3951
|
-
}
|
3952
|
-
|
3953
|
-
var referenceId = metaData.id;
|
3954
|
-
return Promise.resolve(metaData.bound).then(function (bound) {
|
3955
|
-
if (bound === null) {
|
3956
|
-
// Should be unreachable because form state actions are always bound to the
|
3957
|
-
// state argument.
|
3958
|
-
return null;
|
3959
|
-
} // The form action dispatch method is always bound to the initial state.
|
3960
|
-
// But when comparing signatures, we compare to the original unbound action.
|
3961
|
-
// Subtract one from the arity to account for this.
|
3962
|
-
|
3963
|
-
|
3964
|
-
var boundArity = bound.length - 1;
|
3965
|
-
return [actionResult, keyPath, referenceId, boundArity];
|
3966
|
-
});
|
3967
|
-
}
|
3968
|
-
|
3969
|
-
function renderToReadableStream(model, webpackMap, options) {
|
3970
|
-
var request = createRequest(model, webpackMap, options ? options.onError : undefined, options ? options.identifierPrefix : undefined, options ? options.onPostpone : undefined, options ? options.environmentName : undefined);
|
3971
|
-
|
3972
|
-
if (options && options.signal) {
|
3973
|
-
var signal = options.signal;
|
3974
|
-
|
3975
|
-
if (signal.aborted) {
|
3976
|
-
abort(request, signal.reason);
|
3977
|
-
} else {
|
3978
|
-
var listener = function () {
|
3979
|
-
abort(request, signal.reason);
|
3980
|
-
signal.removeEventListener('abort', listener);
|
3981
|
-
};
|
3982
|
-
|
3983
|
-
signal.addEventListener('abort', listener);
|
3984
|
-
}
|
3985
|
-
}
|
3986
|
-
|
3987
|
-
var stream = new ReadableStream({
|
3988
|
-
type: 'bytes',
|
3989
|
-
start: function (controller) {
|
3990
|
-
startWork(request);
|
3991
|
-
},
|
3992
|
-
pull: function (controller) {
|
3993
|
-
startFlowing(request, controller);
|
3994
|
-
},
|
3995
|
-
cancel: function (reason) {
|
3996
|
-
stopFlowing(request);
|
3997
|
-
abort(request, reason);
|
3998
|
-
}
|
3999
|
-
}, // $FlowFixMe[prop-missing] size() methods are not allowed on byte streams.
|
4000
|
-
{
|
4001
|
-
highWaterMark: 0
|
4002
|
-
});
|
4003
|
-
return stream;
|
4004
|
-
}
|
4005
|
-
|
4006
|
-
function decodeReply(body, webpackMap) {
|
4007
|
-
if (typeof body === 'string') {
|
4008
|
-
var form = new FormData();
|
4009
|
-
form.append('0', body);
|
4010
|
-
body = form;
|
4011
|
-
}
|
4012
|
-
|
4013
|
-
var response = createResponse(webpackMap, '', body);
|
4014
|
-
var root = getRoot(response);
|
4015
|
-
close(response);
|
4016
|
-
return root;
|
4017
|
-
}
|
4018
|
-
|
4019
|
-
exports.createClientModuleProxy = createClientModuleProxy;
|
4020
|
-
exports.decodeAction = decodeAction;
|
4021
|
-
exports.decodeFormState = decodeFormState;
|
4022
|
-
exports.decodeReply = decodeReply;
|
4023
|
-
exports.registerClientReference = registerClientReference;
|
4024
|
-
exports.registerServerReference = registerServerReference;
|
4025
|
-
exports.renderToReadableStream = renderToReadableStream;
|
4026
|
-
|
4027
|
-
}));
|