react-server-dom-webpack 18.3.0-canary-b7972822b-20230503 → 18.3.0-canary-b00e27342-20230505
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 +1180 -1096
- package/cjs/react-server-dom-webpack-client.browser.production.min.js +27 -25
- package/cjs/react-server-dom-webpack-client.edge.development.js +722 -3
- package/cjs/react-server-dom-webpack-client.edge.production.min.js +24 -18
- package/cjs/react-server-dom-webpack-client.node.development.js +722 -3
- package/cjs/react-server-dom-webpack-client.node.production.min.js +25 -19
- package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +722 -3
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +24 -17
- package/cjs/react-server-dom-webpack-server.browser.development.js +82 -4
- package/cjs/react-server-dom-webpack-server.browser.production.min.js +43 -41
- package/cjs/react-server-dom-webpack-server.edge.development.js +82 -4
- package/cjs/react-server-dom-webpack-server.edge.production.min.js +49 -47
- package/cjs/react-server-dom-webpack-server.node.development.js +82 -4
- package/cjs/react-server-dom-webpack-server.node.production.min.js +54 -52
- package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +82 -4
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +53 -51
- package/package.json +3 -3
- package/umd/react-server-dom-webpack-client.browser.development.js +1180 -1096
- package/umd/react-server-dom-webpack-client.browser.production.min.js +21 -19
- package/umd/react-server-dom-webpack-server.browser.development.js +82 -4
- package/umd/react-server-dom-webpack-server.browser.production.min.js +41 -40
@@ -210,19 +210,43 @@
|
|
210
210
|
}
|
211
211
|
}
|
212
212
|
|
213
|
-
var
|
214
|
-
function createServerReference(id, callServer) {
|
215
|
-
var proxy = function () {
|
216
|
-
// $FlowFixMe[method-unbinding]
|
217
|
-
var args = Array.prototype.slice.call(arguments);
|
218
|
-
return callServer(id, args);
|
219
|
-
};
|
213
|
+
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
220
214
|
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
215
|
+
function error(format) {
|
216
|
+
{
|
217
|
+
{
|
218
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
219
|
+
args[_key2 - 1] = arguments[_key2];
|
220
|
+
}
|
221
|
+
|
222
|
+
printWarning('error', format, args);
|
223
|
+
}
|
224
|
+
}
|
225
|
+
}
|
226
|
+
|
227
|
+
function printWarning(level, format, args) {
|
228
|
+
// When changing this logic, you might want to also
|
229
|
+
// update consoleWithStackDev.www.js as well.
|
230
|
+
{
|
231
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
232
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
233
|
+
|
234
|
+
if (stack !== '') {
|
235
|
+
format += '%s';
|
236
|
+
args = args.concat([stack]);
|
237
|
+
} // eslint-disable-next-line react-internal/safe-string-coercion
|
238
|
+
|
239
|
+
|
240
|
+
var argsWithFormat = args.map(function (item) {
|
241
|
+
return String(item);
|
242
|
+
}); // Careful: RN currently depends on this prefix
|
243
|
+
|
244
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
245
|
+
// breaks IE9: https://github.com/facebook/react/issues/13610
|
246
|
+
// eslint-disable-next-line react-internal/no-production-logging
|
247
|
+
|
248
|
+
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
249
|
+
}
|
226
250
|
}
|
227
251
|
|
228
252
|
// ATTENTION
|
@@ -253,1394 +277,1454 @@
|
|
253
277
|
return null;
|
254
278
|
}
|
255
279
|
|
256
|
-
var
|
257
|
-
|
258
|
-
var ContextRegistry = ReactSharedInternals.ContextRegistry;
|
259
|
-
function getOrCreateServerContext(globalName) {
|
260
|
-
if (!ContextRegistry[globalName]) {
|
261
|
-
ContextRegistry[globalName] = React.createServerContext(globalName, // $FlowFixMe[incompatible-call] function signature doesn't reflect the symbol value
|
262
|
-
REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED);
|
263
|
-
}
|
280
|
+
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
|
264
281
|
|
265
|
-
|
282
|
+
function isArray(a) {
|
283
|
+
return isArrayImpl(a);
|
266
284
|
}
|
267
285
|
|
268
|
-
|
269
|
-
var BLOCKED = 'blocked';
|
270
|
-
var RESOLVED_MODEL = 'resolved_model';
|
271
|
-
var RESOLVED_MODULE = 'resolved_module';
|
272
|
-
var INITIALIZED = 'fulfilled';
|
273
|
-
var ERRORED = 'rejected'; // $FlowFixMe[missing-this-annot]
|
274
|
-
|
275
|
-
function Chunk(status, value, reason, response) {
|
276
|
-
this.status = status;
|
277
|
-
this.value = value;
|
278
|
-
this.reason = reason;
|
279
|
-
this._response = response;
|
280
|
-
} // We subclass Promise.prototype so that we get other methods like .catch
|
281
|
-
|
282
|
-
|
283
|
-
Chunk.prototype = Object.create(Promise.prototype); // TODO: This doesn't return a new Promise chain unlike the real .then
|
284
|
-
|
285
|
-
Chunk.prototype.then = function (resolve, reject) {
|
286
|
-
var chunk = this; // If we have resolved content, we try to initialize it first which
|
287
|
-
// might put us back into one of the other states.
|
286
|
+
// in case they error.
|
288
287
|
|
289
|
-
|
290
|
-
|
291
|
-
initializeModelChunk(chunk);
|
292
|
-
break;
|
288
|
+
var jsxPropsParents = new WeakMap();
|
289
|
+
var jsxChildrenParents = new WeakMap();
|
293
290
|
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
}
|
291
|
+
function isObjectPrototype(object) {
|
292
|
+
if (!object) {
|
293
|
+
return false;
|
294
|
+
}
|
298
295
|
|
296
|
+
var ObjectPrototype = Object.prototype;
|
299
297
|
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
298
|
+
if (object === ObjectPrototype) {
|
299
|
+
return true;
|
300
|
+
} // It might be an object from a different Realm which is
|
301
|
+
// still just a plain simple object.
|
304
302
|
|
305
|
-
case PENDING:
|
306
|
-
case BLOCKED:
|
307
|
-
if (resolve) {
|
308
|
-
if (chunk.value === null) {
|
309
|
-
chunk.value = [];
|
310
|
-
}
|
311
303
|
|
312
|
-
|
313
|
-
|
304
|
+
if (Object.getPrototypeOf(object)) {
|
305
|
+
return false;
|
306
|
+
}
|
314
307
|
|
315
|
-
|
316
|
-
if (chunk.reason === null) {
|
317
|
-
chunk.reason = [];
|
318
|
-
}
|
308
|
+
var names = Object.getOwnPropertyNames(object);
|
319
309
|
|
320
|
-
|
321
|
-
|
310
|
+
for (var i = 0; i < names.length; i++) {
|
311
|
+
if (!(names[i] in ObjectPrototype)) {
|
312
|
+
return false;
|
313
|
+
}
|
314
|
+
}
|
322
315
|
|
323
|
-
|
316
|
+
return true;
|
317
|
+
}
|
324
318
|
|
325
|
-
|
326
|
-
|
327
|
-
|
319
|
+
function isSimpleObject(object) {
|
320
|
+
if (!isObjectPrototype(Object.getPrototypeOf(object))) {
|
321
|
+
return false;
|
328
322
|
}
|
329
|
-
};
|
330
|
-
|
331
|
-
function readChunk(chunk) {
|
332
|
-
// If we have resolved content, we try to initialize it first which
|
333
|
-
// might put us back into one of the other states.
|
334
|
-
switch (chunk.status) {
|
335
|
-
case RESOLVED_MODEL:
|
336
|
-
initializeModelChunk(chunk);
|
337
|
-
break;
|
338
323
|
|
339
|
-
|
340
|
-
initializeModuleChunk(chunk);
|
341
|
-
break;
|
342
|
-
} // The status might have changed after initialization.
|
324
|
+
var names = Object.getOwnPropertyNames(object);
|
343
325
|
|
326
|
+
for (var i = 0; i < names.length; i++) {
|
327
|
+
var descriptor = Object.getOwnPropertyDescriptor(object, names[i]);
|
344
328
|
|
345
|
-
|
346
|
-
|
347
|
-
|
329
|
+
if (!descriptor) {
|
330
|
+
return false;
|
331
|
+
}
|
348
332
|
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
333
|
+
if (!descriptor.enumerable) {
|
334
|
+
if ((names[i] === 'key' || names[i] === 'ref') && typeof descriptor.get === 'function') {
|
335
|
+
// React adds key and ref getters to props objects to issue warnings.
|
336
|
+
// Those getters will not be transferred to the client, but that's ok,
|
337
|
+
// so we'll special case them.
|
338
|
+
continue;
|
339
|
+
}
|
353
340
|
|
354
|
-
|
355
|
-
|
341
|
+
return false;
|
342
|
+
}
|
356
343
|
}
|
357
|
-
}
|
358
344
|
|
359
|
-
|
360
|
-
var chunk = getChunk(response, 0);
|
361
|
-
return chunk;
|
345
|
+
return true;
|
362
346
|
}
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
return
|
347
|
+
function objectName(object) {
|
348
|
+
// $FlowFixMe[method-unbinding]
|
349
|
+
var name = Object.prototype.toString.call(object);
|
350
|
+
return name.replace(/^\[object (.*)\]$/, function (m, p0) {
|
351
|
+
return p0;
|
352
|
+
});
|
367
353
|
}
|
368
354
|
|
369
|
-
function
|
370
|
-
|
371
|
-
return
|
355
|
+
function describeKeyForErrorMessage(key) {
|
356
|
+
var encodedKey = JSON.stringify(key);
|
357
|
+
return '"' + key + '"' === encodedKey ? key : encodedKey;
|
372
358
|
}
|
373
359
|
|
374
|
-
function
|
375
|
-
|
376
|
-
|
377
|
-
|
360
|
+
function describeValueForErrorMessage(value) {
|
361
|
+
switch (typeof value) {
|
362
|
+
case 'string':
|
363
|
+
{
|
364
|
+
return JSON.stringify(value.length <= 10 ? value : value.slice(0, 10) + '...');
|
365
|
+
}
|
378
366
|
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
}
|
367
|
+
case 'object':
|
368
|
+
{
|
369
|
+
if (isArray(value)) {
|
370
|
+
return '[...]';
|
371
|
+
}
|
385
372
|
|
386
|
-
|
387
|
-
switch (chunk.status) {
|
388
|
-
case INITIALIZED:
|
389
|
-
wakeChunk(resolveListeners, chunk.value);
|
390
|
-
break;
|
373
|
+
var name = objectName(value);
|
391
374
|
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
chunk.reason = rejectListeners;
|
396
|
-
break;
|
375
|
+
if (name === 'Object') {
|
376
|
+
return '{...}';
|
377
|
+
}
|
397
378
|
|
398
|
-
|
399
|
-
if (rejectListeners) {
|
400
|
-
wakeChunk(rejectListeners, chunk.reason);
|
379
|
+
return name;
|
401
380
|
}
|
402
381
|
|
403
|
-
|
382
|
+
case 'function':
|
383
|
+
return 'function';
|
384
|
+
|
385
|
+
default:
|
386
|
+
// eslint-disable-next-line react-internal/safe-string-coercion
|
387
|
+
return String(value);
|
404
388
|
}
|
405
389
|
}
|
406
390
|
|
407
|
-
function
|
408
|
-
if (
|
409
|
-
|
410
|
-
return;
|
391
|
+
function describeElementType(type) {
|
392
|
+
if (typeof type === 'string') {
|
393
|
+
return type;
|
411
394
|
}
|
412
395
|
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
erroredChunk.reason = error;
|
396
|
+
switch (type) {
|
397
|
+
case REACT_SUSPENSE_TYPE:
|
398
|
+
return 'Suspense';
|
417
399
|
|
418
|
-
|
419
|
-
|
420
|
-
}
|
421
|
-
}
|
422
|
-
|
423
|
-
function createResolvedModelChunk(response, value) {
|
424
|
-
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
425
|
-
return new Chunk(RESOLVED_MODEL, value, null, response);
|
426
|
-
}
|
427
|
-
|
428
|
-
function createResolvedModuleChunk(response, value) {
|
429
|
-
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
430
|
-
return new Chunk(RESOLVED_MODULE, value, null, response);
|
431
|
-
}
|
432
|
-
|
433
|
-
function resolveModelChunk(chunk, value) {
|
434
|
-
if (chunk.status !== PENDING) {
|
435
|
-
// We already resolved. We didn't expect to see this.
|
436
|
-
return;
|
400
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
401
|
+
return 'SuspenseList';
|
437
402
|
}
|
438
403
|
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
resolvedChunk.value = value;
|
404
|
+
if (typeof type === 'object') {
|
405
|
+
switch (type.$$typeof) {
|
406
|
+
case REACT_FORWARD_REF_TYPE:
|
407
|
+
return describeElementType(type.render);
|
444
408
|
|
445
|
-
|
446
|
-
|
447
|
-
// we already have listeners attached since they might no
|
448
|
-
// longer be rendered or might not be the highest pri.
|
449
|
-
initializeModelChunk(resolvedChunk); // The status might have changed after initialization.
|
409
|
+
case REACT_MEMO_TYPE:
|
410
|
+
return describeElementType(type.type);
|
450
411
|
|
451
|
-
|
452
|
-
|
453
|
-
|
412
|
+
case REACT_LAZY_TYPE:
|
413
|
+
{
|
414
|
+
var lazyComponent = type;
|
415
|
+
var payload = lazyComponent._payload;
|
416
|
+
var init = lazyComponent._init;
|
454
417
|
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
418
|
+
try {
|
419
|
+
// Lazy may contain any component type so we recursively resolve it.
|
420
|
+
return describeElementType(init(payload));
|
421
|
+
} catch (x) {}
|
422
|
+
}
|
423
|
+
}
|
459
424
|
}
|
460
425
|
|
461
|
-
|
462
|
-
var rejectListeners = chunk.reason;
|
463
|
-
var resolvedChunk = chunk;
|
464
|
-
resolvedChunk.status = RESOLVED_MODULE;
|
465
|
-
resolvedChunk.value = value;
|
466
|
-
|
467
|
-
if (resolveListeners !== null) {
|
468
|
-
initializeModuleChunk(resolvedChunk);
|
469
|
-
wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners);
|
470
|
-
}
|
426
|
+
return '';
|
471
427
|
}
|
472
428
|
|
473
|
-
|
474
|
-
|
429
|
+
function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
430
|
+
var objKind = objectName(objectOrArray);
|
475
431
|
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
initializingChunk = chunk;
|
480
|
-
initializingChunkBlockedModel = null;
|
432
|
+
if (objKind !== 'Object' && objKind !== 'Array') {
|
433
|
+
return objKind;
|
434
|
+
}
|
481
435
|
|
482
|
-
|
483
|
-
|
436
|
+
var str = '';
|
437
|
+
var start = -1;
|
438
|
+
var length = 0;
|
484
439
|
|
485
|
-
|
486
|
-
|
487
|
-
//
|
440
|
+
if (isArray(objectOrArray)) {
|
441
|
+
if (jsxChildrenParents.has(objectOrArray)) {
|
442
|
+
// Print JSX Children
|
443
|
+
var type = jsxChildrenParents.get(objectOrArray);
|
444
|
+
str = '<' + describeElementType(type) + '>';
|
445
|
+
var array = objectOrArray;
|
488
446
|
|
489
|
-
var
|
490
|
-
|
491
|
-
|
492
|
-
blockedChunk.reason = null;
|
493
|
-
} else {
|
494
|
-
var initializedChunk = chunk;
|
495
|
-
initializedChunk.status = INITIALIZED;
|
496
|
-
initializedChunk.value = value;
|
497
|
-
}
|
498
|
-
} catch (error) {
|
499
|
-
var erroredChunk = chunk;
|
500
|
-
erroredChunk.status = ERRORED;
|
501
|
-
erroredChunk.reason = error;
|
502
|
-
} finally {
|
503
|
-
initializingChunk = prevChunk;
|
504
|
-
initializingChunkBlockedModel = prevBlocked;
|
505
|
-
}
|
506
|
-
}
|
447
|
+
for (var i = 0; i < array.length; i++) {
|
448
|
+
var value = array[i];
|
449
|
+
var substr = void 0;
|
507
450
|
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
erroredChunk.status = ERRORED;
|
517
|
-
erroredChunk.reason = error;
|
518
|
-
}
|
519
|
-
} // Report that any missing chunks in the model is now going to throw this
|
520
|
-
// error upon read. Also notify any pending promises.
|
451
|
+
if (typeof value === 'string') {
|
452
|
+
substr = value;
|
453
|
+
} else if (typeof value === 'object' && value !== null) {
|
454
|
+
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
455
|
+
substr = '{' + describeObjectForErrorMessage(value) + '}';
|
456
|
+
} else {
|
457
|
+
substr = '{' + describeValueForErrorMessage(value) + '}';
|
458
|
+
}
|
521
459
|
|
460
|
+
if ('' + i === expandedName) {
|
461
|
+
start = str.length;
|
462
|
+
length = substr.length;
|
463
|
+
str += substr;
|
464
|
+
} else if (substr.length < 15 && str.length + substr.length < 40) {
|
465
|
+
str += substr;
|
466
|
+
} else {
|
467
|
+
str += '{...}';
|
468
|
+
}
|
469
|
+
}
|
522
470
|
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
if (chunk.status === PENDING) {
|
529
|
-
triggerErrorOnChunk(chunk, error);
|
530
|
-
}
|
531
|
-
});
|
532
|
-
}
|
471
|
+
str += '</' + describeElementType(type) + '>';
|
472
|
+
} else {
|
473
|
+
// Print Array
|
474
|
+
str = '[';
|
475
|
+
var _array = objectOrArray;
|
533
476
|
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
// Built-in properties that belong on the element
|
539
|
-
type: type,
|
540
|
-
key: key,
|
541
|
-
ref: null,
|
542
|
-
props: props,
|
543
|
-
// Record the component responsible for creating this element.
|
544
|
-
_owner: null
|
545
|
-
};
|
477
|
+
for (var _i = 0; _i < _array.length; _i++) {
|
478
|
+
if (_i > 0) {
|
479
|
+
str += ', ';
|
480
|
+
}
|
546
481
|
|
547
|
-
|
548
|
-
// We don't really need to add any of these but keeping them for good measure.
|
549
|
-
// Unfortunately, _store is enumerable in jest matchers so for equality to
|
550
|
-
// work, I need to keep it or make _store non-enumerable in the other file.
|
551
|
-
element._store = {};
|
552
|
-
Object.defineProperty(element._store, 'validated', {
|
553
|
-
configurable: false,
|
554
|
-
enumerable: false,
|
555
|
-
writable: true,
|
556
|
-
value: true // This element has already been validated on the server.
|
482
|
+
var _value = _array[_i];
|
557
483
|
|
558
|
-
|
559
|
-
Object.defineProperty(element, '_self', {
|
560
|
-
configurable: false,
|
561
|
-
enumerable: false,
|
562
|
-
writable: false,
|
563
|
-
value: null
|
564
|
-
});
|
565
|
-
Object.defineProperty(element, '_source', {
|
566
|
-
configurable: false,
|
567
|
-
enumerable: false,
|
568
|
-
writable: false,
|
569
|
-
value: null
|
570
|
-
});
|
571
|
-
}
|
484
|
+
var _substr = void 0;
|
572
485
|
|
573
|
-
|
574
|
-
|
486
|
+
if (typeof _value === 'object' && _value !== null) {
|
487
|
+
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
488
|
+
_substr = describeObjectForErrorMessage(_value);
|
489
|
+
} else {
|
490
|
+
_substr = describeValueForErrorMessage(_value);
|
491
|
+
}
|
575
492
|
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
493
|
+
if ('' + _i === expandedName) {
|
494
|
+
start = str.length;
|
495
|
+
length = _substr.length;
|
496
|
+
str += _substr;
|
497
|
+
} else if (_substr.length < 10 && str.length + _substr.length < 40) {
|
498
|
+
str += _substr;
|
499
|
+
} else {
|
500
|
+
str += '...';
|
501
|
+
}
|
502
|
+
}
|
584
503
|
|
585
|
-
|
586
|
-
|
587
|
-
|
504
|
+
str += ']';
|
505
|
+
}
|
506
|
+
} else {
|
507
|
+
if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
|
508
|
+
str = '<' + describeElementType(objectOrArray.type) + '/>';
|
509
|
+
} else if (jsxPropsParents.has(objectOrArray)) {
|
510
|
+
// Print JSX
|
511
|
+
var _type = jsxPropsParents.get(objectOrArray);
|
588
512
|
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
}
|
513
|
+
str = '<' + (describeElementType(_type) || '...');
|
514
|
+
var object = objectOrArray;
|
515
|
+
var names = Object.keys(object);
|
593
516
|
|
594
|
-
|
595
|
-
|
517
|
+
for (var _i2 = 0; _i2 < names.length; _i2++) {
|
518
|
+
str += ' ';
|
519
|
+
var name = names[_i2];
|
520
|
+
str += describeKeyForErrorMessage(name) + '=';
|
521
|
+
var _value2 = object[name];
|
596
522
|
|
597
|
-
|
598
|
-
var blocked;
|
523
|
+
var _substr2 = void 0;
|
599
524
|
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
value: null
|
607
|
-
};
|
608
|
-
}
|
525
|
+
if (name === expandedName && typeof _value2 === 'object' && _value2 !== null) {
|
526
|
+
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
527
|
+
_substr2 = describeObjectForErrorMessage(_value2);
|
528
|
+
} else {
|
529
|
+
_substr2 = describeValueForErrorMessage(_value2);
|
530
|
+
}
|
609
531
|
|
610
|
-
|
611
|
-
|
612
|
-
|
532
|
+
if (typeof _value2 !== 'string') {
|
533
|
+
_substr2 = '{' + _substr2 + '}';
|
534
|
+
}
|
613
535
|
|
614
|
-
|
615
|
-
|
616
|
-
|
536
|
+
if (name === expandedName) {
|
537
|
+
start = str.length;
|
538
|
+
length = _substr2.length;
|
539
|
+
str += _substr2;
|
540
|
+
} else if (_substr2.length < 10 && str.length + _substr2.length < 40) {
|
541
|
+
str += _substr2;
|
542
|
+
} else {
|
543
|
+
str += '...';
|
544
|
+
}
|
617
545
|
}
|
618
546
|
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
if (resolveListeners !== null) {
|
625
|
-
wakeChunk(resolveListeners, blocked.value);
|
626
|
-
}
|
627
|
-
}
|
628
|
-
};
|
629
|
-
}
|
547
|
+
str += '>';
|
548
|
+
} else {
|
549
|
+
// Print Object
|
550
|
+
str = '{';
|
551
|
+
var _object = objectOrArray;
|
630
552
|
|
631
|
-
|
632
|
-
return function (error) {
|
633
|
-
return triggerErrorOnChunk(chunk, error);
|
634
|
-
};
|
635
|
-
}
|
553
|
+
var _names = Object.keys(_object);
|
636
554
|
|
637
|
-
|
638
|
-
|
555
|
+
for (var _i3 = 0; _i3 < _names.length; _i3++) {
|
556
|
+
if (_i3 > 0) {
|
557
|
+
str += ', ';
|
558
|
+
}
|
639
559
|
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
var p = metaData.bound;
|
560
|
+
var _name = _names[_i3];
|
561
|
+
str += describeKeyForErrorMessage(_name) + ': ';
|
562
|
+
var _value3 = _object[_name];
|
644
563
|
|
645
|
-
|
646
|
-
return callServer(metaData.id, args);
|
647
|
-
}
|
564
|
+
var _substr3 = void 0;
|
648
565
|
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
566
|
+
if (typeof _value3 === 'object' && _value3 !== null) {
|
567
|
+
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
568
|
+
_substr3 = describeObjectForErrorMessage(_value3);
|
569
|
+
} else {
|
570
|
+
_substr3 = describeValueForErrorMessage(_value3);
|
571
|
+
}
|
654
572
|
|
573
|
+
if (_name === expandedName) {
|
574
|
+
start = str.length;
|
575
|
+
length = _substr3.length;
|
576
|
+
str += _substr3;
|
577
|
+
} else if (_substr3.length < 10 && str.length + _substr3.length < 40) {
|
578
|
+
str += _substr3;
|
579
|
+
} else {
|
580
|
+
str += '...';
|
581
|
+
}
|
582
|
+
}
|
655
583
|
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
};
|
584
|
+
str += '}';
|
585
|
+
}
|
586
|
+
}
|
660
587
|
|
661
|
-
|
662
|
-
|
663
|
-
|
588
|
+
if (expandedName === undefined) {
|
589
|
+
return str;
|
590
|
+
}
|
664
591
|
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
return REACT_ELEMENT_TYPE;
|
670
|
-
}
|
592
|
+
if (start > -1 && length > 0) {
|
593
|
+
var highlight = ' '.repeat(start) + '^'.repeat(length);
|
594
|
+
return '\n ' + str + '\n ' + highlight;
|
595
|
+
}
|
671
596
|
|
672
|
-
|
673
|
-
|
674
|
-
{
|
675
|
-
// This was an escaped string value.
|
676
|
-
return value.slice(1);
|
677
|
-
}
|
597
|
+
return '\n ' + str;
|
598
|
+
}
|
678
599
|
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
// When passed into React, we'll know how to suspend on this.
|
600
|
+
var knownServerReferences = new WeakMap(); // Serializable values
|
601
|
+
// Thenable<ReactServerValue>
|
602
|
+
// function serializeByValueID(id: number): string {
|
603
|
+
// return '$' + id.toString(16);
|
604
|
+
// }
|
685
605
|
|
686
|
-
|
687
|
-
|
606
|
+
function serializePromiseID(id) {
|
607
|
+
return '$@' + id.toString(16);
|
608
|
+
}
|
688
609
|
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
var _id = parseInt(value.slice(2), 16);
|
610
|
+
function serializeServerReferenceID(id) {
|
611
|
+
return '$F' + id.toString(16);
|
612
|
+
}
|
693
613
|
|
694
|
-
|
614
|
+
function serializeSymbolReference(name) {
|
615
|
+
return '$S' + name;
|
616
|
+
}
|
695
617
|
|
696
|
-
|
697
|
-
|
618
|
+
function serializeFormDataReference(id) {
|
619
|
+
// Why K? F is "Function". D is "Date". What else?
|
620
|
+
return '$K' + id.toString(16);
|
621
|
+
}
|
698
622
|
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
623
|
+
function serializeNumber(number) {
|
624
|
+
if (Number.isFinite(number)) {
|
625
|
+
if (number === 0 && 1 / number === -Infinity) {
|
626
|
+
return '$-0';
|
627
|
+
} else {
|
628
|
+
return number;
|
629
|
+
}
|
630
|
+
} else {
|
631
|
+
if (number === Infinity) {
|
632
|
+
return '$Infinity';
|
633
|
+
} else if (number === -Infinity) {
|
634
|
+
return '$-Infinity';
|
635
|
+
} else {
|
636
|
+
return '$NaN';
|
637
|
+
}
|
638
|
+
}
|
639
|
+
}
|
704
640
|
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
return getOrCreateServerContext(value.slice(2)).Provider;
|
709
|
-
}
|
641
|
+
function serializeUndefined() {
|
642
|
+
return '$undefined';
|
643
|
+
}
|
710
644
|
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
645
|
+
function serializeDateFromDateJSON(dateJSON) {
|
646
|
+
// JSON.stringify automatically calls Date.prototype.toJSON which calls toISOString.
|
647
|
+
// We need only tack on a $D prefix.
|
648
|
+
return '$D' + dateJSON;
|
649
|
+
}
|
715
650
|
|
716
|
-
|
651
|
+
function serializeBigInt(n) {
|
652
|
+
return '$n' + n.toString(10);
|
653
|
+
}
|
717
654
|
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
655
|
+
function escapeStringValue(value) {
|
656
|
+
if (value[0] === '$') {
|
657
|
+
// We need to escape $ prefixed strings since we use those to encode
|
658
|
+
// references to IDs and as special symbol values.
|
659
|
+
return '$' + value;
|
660
|
+
} else {
|
661
|
+
return value;
|
662
|
+
}
|
663
|
+
}
|
723
664
|
|
665
|
+
function processReply(root, formFieldPrefix, resolve, reject) {
|
666
|
+
var nextPartId = 1;
|
667
|
+
var pendingParts = 0;
|
668
|
+
var formData = null;
|
724
669
|
|
725
|
-
|
726
|
-
|
727
|
-
{
|
728
|
-
var metadata = _chunk2.value;
|
729
|
-
return createServerReferenceProxy(response, metadata);
|
730
|
-
}
|
731
|
-
// We always encode it first in the stream so it won't be pending.
|
670
|
+
function resolveToJSON(key, value) {
|
671
|
+
var parent = this; // Make sure that `parent[key]` wasn't JSONified before `value` was passed to us
|
732
672
|
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
}
|
673
|
+
{
|
674
|
+
// $FlowFixMe[incompatible-use]
|
675
|
+
var originalValue = parent[key];
|
737
676
|
|
738
|
-
|
739
|
-
{
|
740
|
-
|
741
|
-
|
677
|
+
if (typeof originalValue === 'object' && originalValue !== value && !(originalValue instanceof Date)) {
|
678
|
+
if (objectName(originalValue) !== 'Object') {
|
679
|
+
error('Only plain objects can be passed to Server Functions from the Client. ' + '%s objects are not supported.%s', objectName(originalValue), describeObjectForErrorMessage(parent, key));
|
680
|
+
} else {
|
681
|
+
error('Only plain objects can be passed to Server Functions from the Client. ' + 'Objects with toJSON methods are not supported. Convert it manually ' + 'to a simple value before passing it to props.%s', describeObjectForErrorMessage(parent, key));
|
742
682
|
}
|
683
|
+
}
|
684
|
+
}
|
743
685
|
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
if (value === '$-0') {
|
748
|
-
return -0;
|
749
|
-
} else {
|
750
|
-
return -Infinity;
|
751
|
-
}
|
752
|
-
}
|
686
|
+
if (value === null) {
|
687
|
+
return null;
|
688
|
+
}
|
753
689
|
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
690
|
+
if (typeof value === 'object') {
|
691
|
+
// $FlowFixMe[method-unbinding]
|
692
|
+
if (typeof value.then === 'function') {
|
693
|
+
// We assume that any object with a .then property is a "Thenable" type,
|
694
|
+
// or a Promise type. Either of which can be represented by a Promise.
|
695
|
+
if (formData === null) {
|
696
|
+
// Upgrade to use FormData to allow us to stream this value.
|
697
|
+
formData = new FormData();
|
758
698
|
}
|
759
699
|
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
}
|
700
|
+
pendingParts++;
|
701
|
+
var promiseId = nextPartId++;
|
702
|
+
var thenable = value;
|
703
|
+
thenable.then(function (partValue) {
|
704
|
+
var partJSON = JSON.stringify(partValue, resolveToJSON); // $FlowFixMe[incompatible-type] We know it's not null because we assigned it above.
|
766
705
|
|
767
|
-
|
768
|
-
{
|
769
|
-
// Date
|
770
|
-
return new Date(Date.parse(value.slice(2)));
|
771
|
-
}
|
706
|
+
var data = formData; // eslint-disable-next-line react-internal/safe-string-coercion
|
772
707
|
|
773
|
-
|
774
|
-
|
775
|
-
// BigInt
|
776
|
-
return BigInt(value.slice(2));
|
777
|
-
}
|
708
|
+
data.append(formFieldPrefix + promiseId, partJSON);
|
709
|
+
pendingParts--;
|
778
710
|
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
711
|
+
if (pendingParts === 0) {
|
712
|
+
resolve(data);
|
713
|
+
}
|
714
|
+
}, function (reason) {
|
715
|
+
// In the future we could consider serializing this as an error
|
716
|
+
// that throws on the server instead.
|
717
|
+
reject(reason);
|
718
|
+
});
|
719
|
+
return serializePromiseID(promiseId);
|
720
|
+
} // TODO: Should we the Object.prototype.toString.call() to test for cross-realm objects?
|
783
721
|
|
784
|
-
var _chunk3 = getChunk(response, _id3);
|
785
722
|
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
723
|
+
if (value instanceof FormData) {
|
724
|
+
if (formData === null) {
|
725
|
+
// Upgrade to use FormData to allow us to use rich objects as its values.
|
726
|
+
formData = new FormData();
|
727
|
+
}
|
790
728
|
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
729
|
+
var data = formData;
|
730
|
+
var refId = nextPartId++; // Copy all the form fields with a prefix for this reference.
|
731
|
+
// These must come first in the form order because we assume that all the
|
732
|
+
// fields are available before this is referenced.
|
795
733
|
|
734
|
+
var prefix = formFieldPrefix + refId + '_'; // $FlowFixMe[prop-missing]: FormData has forEach.
|
796
735
|
|
797
|
-
|
798
|
-
|
799
|
-
|
736
|
+
value.forEach(function (originalValue, originalKey) {
|
737
|
+
data.append(prefix + originalKey, originalValue);
|
738
|
+
});
|
739
|
+
return serializeFormDataReference(refId);
|
740
|
+
}
|
800
741
|
|
801
|
-
|
802
|
-
|
803
|
-
var parentChunk = initializingChunk;
|
742
|
+
if (!isArray(value)) {
|
743
|
+
var iteratorFn = getIteratorFn(value);
|
804
744
|
|
805
|
-
|
745
|
+
if (iteratorFn) {
|
746
|
+
return Array.from(value);
|
747
|
+
}
|
748
|
+
}
|
806
749
|
|
807
|
-
|
750
|
+
{
|
751
|
+
if (value !== null && !isArray(value)) {
|
752
|
+
// Verify that this is a simple plain object.
|
753
|
+
if (value.$$typeof === REACT_ELEMENT_TYPE) {
|
754
|
+
error('React Element cannot be passed to Server Functions from the Client.%s', describeObjectForErrorMessage(parent, key));
|
755
|
+
} else if (value.$$typeof === REACT_LAZY_TYPE) {
|
756
|
+
error('React Lazy cannot be passed to Server Functions from the Client.%s', describeObjectForErrorMessage(parent, key));
|
757
|
+
} else if (value.$$typeof === REACT_PROVIDER_TYPE) {
|
758
|
+
error('React Context Providers cannot be passed to Server Functions from the Client.%s', describeObjectForErrorMessage(parent, key));
|
759
|
+
} else if (objectName(value) !== 'Object') {
|
760
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + '%s objects are not supported.%s', objectName(value), describeObjectForErrorMessage(parent, key));
|
761
|
+
} else if (!isSimpleObject(value)) {
|
762
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + 'Classes or other objects with methods are not supported.%s', describeObjectForErrorMessage(parent, key));
|
763
|
+
} else if (Object.getOwnPropertySymbols) {
|
764
|
+
var symbols = Object.getOwnPropertySymbols(value);
|
808
765
|
|
809
|
-
|
810
|
-
|
766
|
+
if (symbols.length > 0) {
|
767
|
+
error('Only plain objects can be passed to Client Components from Server Components. ' + 'Objects with symbol properties like %s are not supported.%s', symbols[0].description, describeObjectForErrorMessage(parent, key));
|
768
|
+
}
|
811
769
|
}
|
812
770
|
}
|
813
|
-
|
814
|
-
}
|
815
|
-
|
816
|
-
return value;
|
817
|
-
}
|
818
|
-
function parseModelTuple(response, value) {
|
819
|
-
var tuple = value;
|
820
|
-
|
821
|
-
if (tuple[0] === REACT_ELEMENT_TYPE) {
|
822
|
-
// TODO: Consider having React just directly accept these arrays as elements.
|
823
|
-
// Or even change the ReactElement type to be an array.
|
824
|
-
return createElement(tuple[1], tuple[2], tuple[3]);
|
825
|
-
}
|
771
|
+
} // $FlowFixMe[incompatible-return]
|
826
772
|
|
827
|
-
return value;
|
828
|
-
}
|
829
773
|
|
830
|
-
|
831
|
-
|
832
|
-
}
|
774
|
+
return value;
|
775
|
+
}
|
833
776
|
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
};
|
841
|
-
return response;
|
842
|
-
}
|
843
|
-
function resolveModel(response, id, model) {
|
844
|
-
var chunks = response._chunks;
|
845
|
-
var chunk = chunks.get(id);
|
777
|
+
if (typeof value === 'string') {
|
778
|
+
// TODO: Maybe too clever. If we support URL there's no similar trick.
|
779
|
+
if (value[value.length - 1] === 'Z') {
|
780
|
+
// Possibly a Date, whose toJSON automatically calls toISOString
|
781
|
+
// $FlowFixMe[incompatible-use]
|
782
|
+
var _originalValue = parent[key]; // $FlowFixMe[method-unbinding]
|
846
783
|
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
}
|
852
|
-
}
|
853
|
-
function resolveModule(response, id, model) {
|
854
|
-
var chunks = response._chunks;
|
855
|
-
var chunk = chunks.get(id);
|
856
|
-
var clientReferenceMetadata = parseModel(response, model);
|
857
|
-
var clientReference = resolveClientReference(response._bundlerConfig, clientReferenceMetadata); // TODO: Add an option to encode modules that are lazy loaded.
|
858
|
-
// For now we preload all modules as early as possible since it's likely
|
859
|
-
// that we'll need them.
|
784
|
+
if (_originalValue instanceof Date) {
|
785
|
+
return serializeDateFromDateJSON(value);
|
786
|
+
}
|
787
|
+
}
|
860
788
|
|
861
|
-
|
789
|
+
return escapeStringValue(value);
|
790
|
+
}
|
862
791
|
|
863
|
-
|
864
|
-
|
792
|
+
if (typeof value === 'boolean') {
|
793
|
+
return value;
|
794
|
+
}
|
865
795
|
|
866
|
-
if (
|
867
|
-
|
868
|
-
// case. Because it'll just behave as any other promise.
|
869
|
-
blockedChunk = createBlockedChunk(response);
|
870
|
-
chunks.set(id, blockedChunk);
|
871
|
-
} else {
|
872
|
-
// This can't actually happen because we don't have any forward
|
873
|
-
// references to modules.
|
874
|
-
blockedChunk = chunk;
|
875
|
-
blockedChunk.status = BLOCKED;
|
796
|
+
if (typeof value === 'number') {
|
797
|
+
return serializeNumber(value);
|
876
798
|
}
|
877
799
|
|
878
|
-
|
879
|
-
return
|
880
|
-
}, function (error) {
|
881
|
-
return triggerErrorOnChunk(blockedChunk, error);
|
882
|
-
});
|
883
|
-
} else {
|
884
|
-
if (!chunk) {
|
885
|
-
chunks.set(id, createResolvedModuleChunk(response, clientReference));
|
886
|
-
} else {
|
887
|
-
// This can't actually happen because we don't have any forward
|
888
|
-
// references to modules.
|
889
|
-
resolveModuleChunk(chunk, clientReference);
|
800
|
+
if (typeof value === 'undefined') {
|
801
|
+
return serializeUndefined();
|
890
802
|
}
|
891
|
-
}
|
892
|
-
}
|
893
|
-
function resolveErrorDev(response, id, digest, message, stack) {
|
894
803
|
|
804
|
+
if (typeof value === 'function') {
|
805
|
+
var metaData = knownServerReferences.get(value);
|
895
806
|
|
896
|
-
|
897
|
-
|
898
|
-
error.digest = digest;
|
899
|
-
var errorWithDigest = error;
|
900
|
-
var chunks = response._chunks;
|
901
|
-
var chunk = chunks.get(id);
|
807
|
+
if (metaData !== undefined) {
|
808
|
+
var metaDataJSON = JSON.stringify(metaData, resolveToJSON);
|
902
809
|
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
}
|
908
|
-
}
|
909
|
-
function resolveHint(response, code, model) {
|
910
|
-
var hintModel = parseModel(response, model);
|
911
|
-
dispatchHint(code, hintModel);
|
912
|
-
}
|
913
|
-
function close(response) {
|
914
|
-
// In case there are any remaining unresolved chunks, they won't
|
915
|
-
// be resolved now. So we need to issue an error to those.
|
916
|
-
// Ideally we should be able to early bail out if we kept a
|
917
|
-
// ref count of pending chunks.
|
918
|
-
reportGlobalError(response, new Error('Connection closed.'));
|
919
|
-
}
|
810
|
+
if (formData === null) {
|
811
|
+
// Upgrade to use FormData to allow us to stream this value.
|
812
|
+
formData = new FormData();
|
813
|
+
} // The reference to this function came from the same client so we can pass it back.
|
920
814
|
|
921
|
-
function processFullRow(response, row) {
|
922
|
-
if (row === '') {
|
923
|
-
return;
|
924
|
-
}
|
925
815
|
|
926
|
-
|
927
|
-
var id = parseInt(row.slice(0, colon), 16);
|
928
|
-
var tag = row[colon + 1]; // When tags that are not text are added, check them here before
|
929
|
-
// parsing the row as text.
|
930
|
-
// switch (tag) {
|
931
|
-
// }
|
816
|
+
var _refId = nextPartId++; // eslint-disable-next-line react-internal/safe-string-coercion
|
932
817
|
|
933
|
-
switch (tag) {
|
934
|
-
case 'I':
|
935
|
-
{
|
936
|
-
resolveModule(response, id, row.slice(colon + 2));
|
937
|
-
return;
|
938
|
-
}
|
939
818
|
|
940
|
-
|
941
|
-
|
942
|
-
var code = row[colon + 2];
|
943
|
-
resolveHint(response, code, row.slice(colon + 3));
|
944
|
-
return;
|
819
|
+
formData.set(formFieldPrefix + _refId, metaDataJSON);
|
820
|
+
return serializeServerReferenceID(_refId);
|
945
821
|
}
|
946
822
|
|
947
|
-
|
948
|
-
|
949
|
-
var errorInfo = JSON.parse(row.slice(colon + 2));
|
823
|
+
throw new Error('Client Functions cannot be passed directly to Server Functions. ' + 'Only Functions passed from the Server can be passed back again.');
|
824
|
+
}
|
950
825
|
|
951
|
-
|
952
|
-
|
953
|
-
|
826
|
+
if (typeof value === 'symbol') {
|
827
|
+
// $FlowFixMe[incompatible-type] `description` might be undefined
|
828
|
+
var name = value.description;
|
954
829
|
|
955
|
-
|
830
|
+
if (Symbol.for(name) !== value) {
|
831
|
+
throw new Error('Only global symbols received from Symbol.for(...) can be passed to Server Functions. ' + ("The symbol Symbol.for(" + // $FlowFixMe[incompatible-type] `description` might be undefined
|
832
|
+
value.description + ") cannot be found among global symbols."));
|
956
833
|
}
|
957
834
|
|
958
|
-
|
959
|
-
|
960
|
-
// We assume anything else is JSON.
|
961
|
-
resolveModel(response, id, row.slice(colon + 1));
|
962
|
-
return;
|
963
|
-
}
|
964
|
-
}
|
965
|
-
}
|
835
|
+
return serializeSymbolReference(name);
|
836
|
+
}
|
966
837
|
|
967
|
-
|
968
|
-
|
838
|
+
if (typeof value === 'bigint') {
|
839
|
+
return serializeBigInt(value);
|
840
|
+
}
|
969
841
|
|
970
|
-
|
971
|
-
|
972
|
-
processFullRow(response, fullrow);
|
973
|
-
response._partialRow = '';
|
974
|
-
offset = linebreak + 1;
|
975
|
-
linebreak = chunk.indexOf('\n', offset);
|
976
|
-
}
|
842
|
+
throw new Error("Type " + typeof value + " is not supported as an argument to a Server Function.");
|
843
|
+
} // $FlowFixMe[incompatible-type] it's not going to be undefined because we'll encode it.
|
977
844
|
|
978
|
-
response._partialRow += chunk.slice(offset);
|
979
|
-
}
|
980
|
-
function processBinaryChunk(response, chunk) {
|
981
845
|
|
982
|
-
var
|
983
|
-
var linebreak = chunk.indexOf(10); // newline
|
846
|
+
var json = JSON.stringify(root, resolveToJSON);
|
984
847
|
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
}
|
848
|
+
if (formData === null) {
|
849
|
+
// If it's a simple data structure, we just use plain JSON.
|
850
|
+
resolve(json);
|
851
|
+
} else {
|
852
|
+
// Otherwise, we use FormData to let us stream in the result.
|
853
|
+
formData.set(formFieldPrefix + '0', json);
|
992
854
|
|
993
|
-
|
855
|
+
if (pendingParts === 0) {
|
856
|
+
// $FlowFixMe[incompatible-call] this has already been refined.
|
857
|
+
resolve(formData);
|
858
|
+
}
|
859
|
+
}
|
994
860
|
}
|
861
|
+
var boundCache = new WeakMap();
|
995
862
|
|
996
|
-
function
|
997
|
-
//
|
998
|
-
|
999
|
-
if (typeof value === 'string') {
|
1000
|
-
// We can't use .bind here because we need the "this" value.
|
1001
|
-
return parseModelString(response, this, key, value);
|
1002
|
-
}
|
863
|
+
function encodeFormData(reference) {
|
864
|
+
var resolve, reject; // We need to have a handle on the thenable so that we can synchronously set
|
865
|
+
// its status from processReply, when it can complete synchronously.
|
1003
866
|
|
1004
|
-
|
1005
|
-
|
867
|
+
var thenable = new Promise(function (res, rej) {
|
868
|
+
resolve = res;
|
869
|
+
reject = rej;
|
870
|
+
});
|
871
|
+
processReply(reference, '', function (body) {
|
872
|
+
if (typeof body === 'string') {
|
873
|
+
var data = new FormData();
|
874
|
+
data.append('0', body);
|
875
|
+
body = data;
|
1006
876
|
}
|
1007
877
|
|
1008
|
-
|
1009
|
-
|
878
|
+
var fulfilled = thenable;
|
879
|
+
fulfilled.status = 'fulfilled';
|
880
|
+
fulfilled.value = body;
|
881
|
+
resolve(body);
|
882
|
+
}, function (e) {
|
883
|
+
var rejected = thenable;
|
884
|
+
rejected.status = 'rejected';
|
885
|
+
rejected.reason = e;
|
886
|
+
reject(e);
|
887
|
+
});
|
888
|
+
return thenable;
|
1010
889
|
}
|
1011
890
|
|
1012
|
-
function
|
1013
|
-
|
1014
|
-
// It should be inlined to one object literal but minor changes can break it.
|
1015
|
-
var stringDecoder = createStringDecoder() ;
|
1016
|
-
var response = createResponse$1(bundlerConfig, callServer);
|
1017
|
-
response._partialRow = '';
|
1018
|
-
|
1019
|
-
{
|
1020
|
-
response._stringDecoder = stringDecoder;
|
1021
|
-
} // Don't inline this call because it causes closure to outline the call above.
|
891
|
+
function encodeFormAction(identifierPrefix) {
|
892
|
+
var reference = knownServerReferences.get(this);
|
1022
893
|
|
894
|
+
if (!reference) {
|
895
|
+
throw new Error('Tried to encode a Server Action from a different instance than the encoder is from. ' + 'This is a bug in React.');
|
896
|
+
}
|
1023
897
|
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
898
|
+
var data = null;
|
899
|
+
var name;
|
900
|
+
var boundPromise = reference.bound;
|
1027
901
|
|
1028
|
-
|
1029
|
-
|
1030
|
-
{
|
1031
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
1032
|
-
args[_key2 - 1] = arguments[_key2];
|
1033
|
-
}
|
902
|
+
if (boundPromise !== null) {
|
903
|
+
var thenable = boundCache.get(reference);
|
1034
904
|
|
1035
|
-
|
905
|
+
if (!thenable) {
|
906
|
+
thenable = encodeFormData(reference);
|
907
|
+
boundCache.set(reference, thenable);
|
1036
908
|
}
|
1037
|
-
}
|
1038
|
-
}
|
1039
|
-
|
1040
|
-
function printWarning(level, format, args) {
|
1041
|
-
// When changing this logic, you might want to also
|
1042
|
-
// update consoleWithStackDev.www.js as well.
|
1043
|
-
{
|
1044
|
-
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
1045
|
-
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
1046
909
|
|
1047
|
-
if (
|
1048
|
-
|
1049
|
-
|
1050
|
-
|
910
|
+
if (thenable.status === 'rejected') {
|
911
|
+
throw thenable.reason;
|
912
|
+
} else if (thenable.status !== 'fulfilled') {
|
913
|
+
throw thenable;
|
914
|
+
}
|
1051
915
|
|
916
|
+
var encodedFormData = thenable.value; // This is hacky but we need the identifier prefix to be added to
|
917
|
+
// all fields but the suspense cache would break since we might get
|
918
|
+
// a new identifier each time. So we just append it at the end instead.
|
1052
919
|
|
1053
|
-
var
|
1054
|
-
return String(item);
|
1055
|
-
}); // Careful: RN currently depends on this prefix
|
920
|
+
var prefixedData = new FormData(); // $FlowFixMe[prop-missing]
|
1056
921
|
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
922
|
+
encodedFormData.forEach(function (value, key) {
|
923
|
+
prefixedData.append('$ACTION_' + identifierPrefix + ':' + key, value);
|
924
|
+
});
|
925
|
+
data = prefixedData; // We encode the name of the prefix containing the data.
|
1060
926
|
|
1061
|
-
|
927
|
+
name = '$ACTION_REF_' + identifierPrefix;
|
928
|
+
} else {
|
929
|
+
// This is the simple case so we can just encode the ID.
|
930
|
+
name = '$ACTION_ID_' + reference.id;
|
1062
931
|
}
|
1063
|
-
}
|
1064
|
-
|
1065
|
-
var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
|
1066
932
|
|
1067
|
-
|
1068
|
-
|
933
|
+
return {
|
934
|
+
name: name,
|
935
|
+
method: 'POST',
|
936
|
+
encType: 'multipart/form-data',
|
937
|
+
data: data
|
938
|
+
};
|
1069
939
|
}
|
940
|
+
function createServerReference(id, callServer) {
|
941
|
+
var proxy = function () {
|
942
|
+
// $FlowFixMe[method-unbinding]
|
943
|
+
var args = Array.prototype.slice.call(arguments);
|
944
|
+
return callServer(id, args);
|
945
|
+
}; // Expose encoder for use by SSR.
|
946
|
+
// TODO: Only expose this in SSR builds and not the browser client.
|
1070
947
|
|
1071
|
-
// in case they error.
|
1072
948
|
|
1073
|
-
|
1074
|
-
|
949
|
+
proxy.$$FORM_ACTION = encodeFormAction;
|
950
|
+
knownServerReferences.set(proxy, {
|
951
|
+
id: id,
|
952
|
+
bound: null
|
953
|
+
});
|
954
|
+
return proxy;
|
955
|
+
}
|
1075
956
|
|
1076
|
-
|
1077
|
-
|
1078
|
-
|
957
|
+
var ContextRegistry = ReactSharedInternals.ContextRegistry;
|
958
|
+
function getOrCreateServerContext(globalName) {
|
959
|
+
if (!ContextRegistry[globalName]) {
|
960
|
+
ContextRegistry[globalName] = React.createServerContext(globalName, // $FlowFixMe[incompatible-call] function signature doesn't reflect the symbol value
|
961
|
+
REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED);
|
1079
962
|
}
|
1080
963
|
|
1081
|
-
|
964
|
+
return ContextRegistry[globalName];
|
965
|
+
}
|
1082
966
|
|
1083
|
-
|
1084
|
-
|
1085
|
-
|
1086
|
-
|
967
|
+
var PENDING = 'pending';
|
968
|
+
var BLOCKED = 'blocked';
|
969
|
+
var RESOLVED_MODEL = 'resolved_model';
|
970
|
+
var RESOLVED_MODULE = 'resolved_module';
|
971
|
+
var INITIALIZED = 'fulfilled';
|
972
|
+
var ERRORED = 'rejected'; // $FlowFixMe[missing-this-annot]
|
1087
973
|
|
974
|
+
function Chunk(status, value, reason, response) {
|
975
|
+
this.status = status;
|
976
|
+
this.value = value;
|
977
|
+
this.reason = reason;
|
978
|
+
this._response = response;
|
979
|
+
} // We subclass Promise.prototype so that we get other methods like .catch
|
1088
980
|
|
1089
|
-
if (Object.getPrototypeOf(object)) {
|
1090
|
-
return false;
|
1091
|
-
}
|
1092
981
|
|
1093
|
-
|
982
|
+
Chunk.prototype = Object.create(Promise.prototype); // TODO: This doesn't return a new Promise chain unlike the real .then
|
1094
983
|
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
}
|
1099
|
-
}
|
984
|
+
Chunk.prototype.then = function (resolve, reject) {
|
985
|
+
var chunk = this; // If we have resolved content, we try to initialize it first which
|
986
|
+
// might put us back into one of the other states.
|
1100
987
|
|
1101
|
-
|
1102
|
-
|
988
|
+
switch (chunk.status) {
|
989
|
+
case RESOLVED_MODEL:
|
990
|
+
initializeModelChunk(chunk);
|
991
|
+
break;
|
1103
992
|
|
1104
|
-
|
1105
|
-
|
1106
|
-
|
1107
|
-
}
|
993
|
+
case RESOLVED_MODULE:
|
994
|
+
initializeModuleChunk(chunk);
|
995
|
+
break;
|
996
|
+
} // The status might have changed after initialization.
|
1108
997
|
|
1109
|
-
var names = Object.getOwnPropertyNames(object);
|
1110
998
|
|
1111
|
-
|
1112
|
-
|
999
|
+
switch (chunk.status) {
|
1000
|
+
case INITIALIZED:
|
1001
|
+
resolve(chunk.value);
|
1002
|
+
break;
|
1113
1003
|
|
1114
|
-
|
1115
|
-
|
1116
|
-
|
1004
|
+
case PENDING:
|
1005
|
+
case BLOCKED:
|
1006
|
+
if (resolve) {
|
1007
|
+
if (chunk.value === null) {
|
1008
|
+
chunk.value = [];
|
1009
|
+
}
|
1117
1010
|
|
1118
|
-
|
1119
|
-
if ((names[i] === 'key' || names[i] === 'ref') && typeof descriptor.get === 'function') {
|
1120
|
-
// React adds key and ref getters to props objects to issue warnings.
|
1121
|
-
// Those getters will not be transferred to the client, but that's ok,
|
1122
|
-
// so we'll special case them.
|
1123
|
-
continue;
|
1011
|
+
chunk.value.push(resolve);
|
1124
1012
|
}
|
1125
1013
|
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1014
|
+
if (reject) {
|
1015
|
+
if (chunk.reason === null) {
|
1016
|
+
chunk.reason = [];
|
1017
|
+
}
|
1129
1018
|
|
1130
|
-
|
1131
|
-
|
1132
|
-
function objectName(object) {
|
1133
|
-
// $FlowFixMe[method-unbinding]
|
1134
|
-
var name = Object.prototype.toString.call(object);
|
1135
|
-
return name.replace(/^\[object (.*)\]$/, function (m, p0) {
|
1136
|
-
return p0;
|
1137
|
-
});
|
1138
|
-
}
|
1019
|
+
chunk.reason.push(reject);
|
1020
|
+
}
|
1139
1021
|
|
1140
|
-
|
1141
|
-
var encodedKey = JSON.stringify(key);
|
1142
|
-
return '"' + key + '"' === encodedKey ? key : encodedKey;
|
1143
|
-
}
|
1022
|
+
break;
|
1144
1023
|
|
1145
|
-
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
}
|
1024
|
+
default:
|
1025
|
+
reject(chunk.reason);
|
1026
|
+
break;
|
1027
|
+
}
|
1028
|
+
};
|
1151
1029
|
|
1152
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
1030
|
+
function readChunk(chunk) {
|
1031
|
+
// If we have resolved content, we try to initialize it first which
|
1032
|
+
// might put us back into one of the other states.
|
1033
|
+
switch (chunk.status) {
|
1034
|
+
case RESOLVED_MODEL:
|
1035
|
+
initializeModelChunk(chunk);
|
1036
|
+
break;
|
1157
1037
|
|
1158
|
-
|
1038
|
+
case RESOLVED_MODULE:
|
1039
|
+
initializeModuleChunk(chunk);
|
1040
|
+
break;
|
1041
|
+
} // The status might have changed after initialization.
|
1159
1042
|
|
1160
|
-
if (name === 'Object') {
|
1161
|
-
return '{...}';
|
1162
|
-
}
|
1163
1043
|
|
1164
|
-
|
1165
|
-
|
1044
|
+
switch (chunk.status) {
|
1045
|
+
case INITIALIZED:
|
1046
|
+
return chunk.value;
|
1166
1047
|
|
1167
|
-
case
|
1168
|
-
|
1048
|
+
case PENDING:
|
1049
|
+
case BLOCKED:
|
1050
|
+
// eslint-disable-next-line no-throw-literal
|
1051
|
+
throw chunk;
|
1169
1052
|
|
1170
1053
|
default:
|
1171
|
-
|
1172
|
-
return String(value);
|
1054
|
+
throw chunk.reason;
|
1173
1055
|
}
|
1174
1056
|
}
|
1175
1057
|
|
1176
|
-
function
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1058
|
+
function getRoot(response) {
|
1059
|
+
var chunk = getChunk(response, 0);
|
1060
|
+
return chunk;
|
1061
|
+
}
|
1180
1062
|
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1063
|
+
function createPendingChunk(response) {
|
1064
|
+
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
1065
|
+
return new Chunk(PENDING, null, null, response);
|
1066
|
+
}
|
1184
1067
|
|
1185
|
-
|
1186
|
-
|
1068
|
+
function createBlockedChunk(response) {
|
1069
|
+
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
1070
|
+
return new Chunk(BLOCKED, null, null, response);
|
1071
|
+
}
|
1072
|
+
|
1073
|
+
function createErrorChunk(response, error) {
|
1074
|
+
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
1075
|
+
return new Chunk(ERRORED, null, error, response);
|
1076
|
+
}
|
1077
|
+
|
1078
|
+
function wakeChunk(listeners, value) {
|
1079
|
+
for (var i = 0; i < listeners.length; i++) {
|
1080
|
+
var listener = listeners[i];
|
1081
|
+
listener(value);
|
1187
1082
|
}
|
1083
|
+
}
|
1188
1084
|
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1085
|
+
function wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners) {
|
1086
|
+
switch (chunk.status) {
|
1087
|
+
case INITIALIZED:
|
1088
|
+
wakeChunk(resolveListeners, chunk.value);
|
1089
|
+
break;
|
1193
1090
|
|
1194
|
-
|
1195
|
-
|
1091
|
+
case PENDING:
|
1092
|
+
case BLOCKED:
|
1093
|
+
chunk.value = resolveListeners;
|
1094
|
+
chunk.reason = rejectListeners;
|
1095
|
+
break;
|
1196
1096
|
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
var init = lazyComponent._init;
|
1097
|
+
case ERRORED:
|
1098
|
+
if (rejectListeners) {
|
1099
|
+
wakeChunk(rejectListeners, chunk.reason);
|
1100
|
+
}
|
1202
1101
|
|
1203
|
-
|
1204
|
-
// Lazy may contain any component type so we recursively resolve it.
|
1205
|
-
return describeElementType(init(payload));
|
1206
|
-
} catch (x) {}
|
1207
|
-
}
|
1208
|
-
}
|
1102
|
+
break;
|
1209
1103
|
}
|
1210
|
-
|
1211
|
-
return '';
|
1212
1104
|
}
|
1213
1105
|
|
1214
|
-
function
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
return objKind;
|
1106
|
+
function triggerErrorOnChunk(chunk, error) {
|
1107
|
+
if (chunk.status !== PENDING && chunk.status !== BLOCKED) {
|
1108
|
+
// We already resolved. We didn't expect to see this.
|
1109
|
+
return;
|
1219
1110
|
}
|
1220
1111
|
|
1221
|
-
var
|
1222
|
-
var
|
1223
|
-
|
1112
|
+
var listeners = chunk.reason;
|
1113
|
+
var erroredChunk = chunk;
|
1114
|
+
erroredChunk.status = ERRORED;
|
1115
|
+
erroredChunk.reason = error;
|
1224
1116
|
|
1225
|
-
if (
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
str = '<' + describeElementType(type) + '>';
|
1230
|
-
var array = objectOrArray;
|
1117
|
+
if (listeners !== null) {
|
1118
|
+
wakeChunk(listeners, error);
|
1119
|
+
}
|
1120
|
+
}
|
1231
1121
|
|
1232
|
-
|
1233
|
-
|
1234
|
-
|
1122
|
+
function createResolvedModelChunk(response, value) {
|
1123
|
+
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
1124
|
+
return new Chunk(RESOLVED_MODEL, value, null, response);
|
1125
|
+
}
|
1235
1126
|
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1239
|
-
|
1240
|
-
substr = '{' + describeObjectForErrorMessage(value) + '}';
|
1241
|
-
} else {
|
1242
|
-
substr = '{' + describeValueForErrorMessage(value) + '}';
|
1243
|
-
}
|
1127
|
+
function createResolvedModuleChunk(response, value) {
|
1128
|
+
// $FlowFixMe[invalid-constructor] Flow doesn't support functions as constructors
|
1129
|
+
return new Chunk(RESOLVED_MODULE, value, null, response);
|
1130
|
+
}
|
1244
1131
|
|
1245
|
-
|
1246
|
-
|
1247
|
-
|
1248
|
-
|
1249
|
-
|
1250
|
-
str += substr;
|
1251
|
-
} else {
|
1252
|
-
str += '{...}';
|
1253
|
-
}
|
1254
|
-
}
|
1132
|
+
function resolveModelChunk(chunk, value) {
|
1133
|
+
if (chunk.status !== PENDING) {
|
1134
|
+
// We already resolved. We didn't expect to see this.
|
1135
|
+
return;
|
1136
|
+
}
|
1255
1137
|
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
|
1138
|
+
var resolveListeners = chunk.value;
|
1139
|
+
var rejectListeners = chunk.reason;
|
1140
|
+
var resolvedChunk = chunk;
|
1141
|
+
resolvedChunk.status = RESOLVED_MODEL;
|
1142
|
+
resolvedChunk.value = value;
|
1261
1143
|
|
1262
|
-
|
1263
|
-
|
1264
|
-
|
1265
|
-
|
1144
|
+
if (resolveListeners !== null) {
|
1145
|
+
// This is unfortunate that we're reading this eagerly if
|
1146
|
+
// we already have listeners attached since they might no
|
1147
|
+
// longer be rendered or might not be the highest pri.
|
1148
|
+
initializeModelChunk(resolvedChunk); // The status might have changed after initialization.
|
1266
1149
|
|
1267
|
-
|
1150
|
+
wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners);
|
1151
|
+
}
|
1152
|
+
}
|
1268
1153
|
|
1269
|
-
|
1154
|
+
function resolveModuleChunk(chunk, value) {
|
1155
|
+
if (chunk.status !== PENDING && chunk.status !== BLOCKED) {
|
1156
|
+
// We already resolved. We didn't expect to see this.
|
1157
|
+
return;
|
1158
|
+
}
|
1270
1159
|
|
1271
|
-
|
1272
|
-
|
1273
|
-
|
1274
|
-
|
1275
|
-
|
1276
|
-
}
|
1160
|
+
var resolveListeners = chunk.value;
|
1161
|
+
var rejectListeners = chunk.reason;
|
1162
|
+
var resolvedChunk = chunk;
|
1163
|
+
resolvedChunk.status = RESOLVED_MODULE;
|
1164
|
+
resolvedChunk.value = value;
|
1277
1165
|
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
str += _substr;
|
1284
|
-
} else {
|
1285
|
-
str += '...';
|
1286
|
-
}
|
1287
|
-
}
|
1166
|
+
if (resolveListeners !== null) {
|
1167
|
+
initializeModuleChunk(resolvedChunk);
|
1168
|
+
wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners);
|
1169
|
+
}
|
1170
|
+
}
|
1288
1171
|
|
1289
|
-
|
1290
|
-
|
1291
|
-
} else {
|
1292
|
-
if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
|
1293
|
-
str = '<' + describeElementType(objectOrArray.type) + '/>';
|
1294
|
-
} else if (jsxPropsParents.has(objectOrArray)) {
|
1295
|
-
// Print JSX
|
1296
|
-
var _type = jsxPropsParents.get(objectOrArray);
|
1172
|
+
var initializingChunk = null;
|
1173
|
+
var initializingChunkBlockedModel = null;
|
1297
1174
|
|
1298
|
-
|
1299
|
-
|
1300
|
-
|
1175
|
+
function initializeModelChunk(chunk) {
|
1176
|
+
var prevChunk = initializingChunk;
|
1177
|
+
var prevBlocked = initializingChunkBlockedModel;
|
1178
|
+
initializingChunk = chunk;
|
1179
|
+
initializingChunkBlockedModel = null;
|
1301
1180
|
|
1302
|
-
|
1303
|
-
|
1304
|
-
var name = names[_i2];
|
1305
|
-
str += describeKeyForErrorMessage(name) + '=';
|
1306
|
-
var _value2 = object[name];
|
1181
|
+
try {
|
1182
|
+
var value = parseModel(chunk._response, chunk.value);
|
1307
1183
|
|
1308
|
-
|
1184
|
+
if (initializingChunkBlockedModel !== null && initializingChunkBlockedModel.deps > 0) {
|
1185
|
+
initializingChunkBlockedModel.value = value; // We discovered new dependencies on modules that are not yet resolved.
|
1186
|
+
// We have to go the BLOCKED state until they're resolved.
|
1309
1187
|
|
1310
|
-
|
1311
|
-
|
1312
|
-
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1188
|
+
var blockedChunk = chunk;
|
1189
|
+
blockedChunk.status = BLOCKED;
|
1190
|
+
blockedChunk.value = null;
|
1191
|
+
blockedChunk.reason = null;
|
1192
|
+
} else {
|
1193
|
+
var initializedChunk = chunk;
|
1194
|
+
initializedChunk.status = INITIALIZED;
|
1195
|
+
initializedChunk.value = value;
|
1196
|
+
}
|
1197
|
+
} catch (error) {
|
1198
|
+
var erroredChunk = chunk;
|
1199
|
+
erroredChunk.status = ERRORED;
|
1200
|
+
erroredChunk.reason = error;
|
1201
|
+
} finally {
|
1202
|
+
initializingChunk = prevChunk;
|
1203
|
+
initializingChunkBlockedModel = prevBlocked;
|
1204
|
+
}
|
1205
|
+
}
|
1316
1206
|
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1207
|
+
function initializeModuleChunk(chunk) {
|
1208
|
+
try {
|
1209
|
+
var value = requireModule(chunk.value);
|
1210
|
+
var initializedChunk = chunk;
|
1211
|
+
initializedChunk.status = INITIALIZED;
|
1212
|
+
initializedChunk.value = value;
|
1213
|
+
} catch (error) {
|
1214
|
+
var erroredChunk = chunk;
|
1215
|
+
erroredChunk.status = ERRORED;
|
1216
|
+
erroredChunk.reason = error;
|
1217
|
+
}
|
1218
|
+
} // Report that any missing chunks in the model is now going to throw this
|
1219
|
+
// error upon read. Also notify any pending promises.
|
1320
1220
|
|
1321
|
-
if (name === expandedName) {
|
1322
|
-
start = str.length;
|
1323
|
-
length = _substr2.length;
|
1324
|
-
str += _substr2;
|
1325
|
-
} else if (_substr2.length < 10 && str.length + _substr2.length < 40) {
|
1326
|
-
str += _substr2;
|
1327
|
-
} else {
|
1328
|
-
str += '...';
|
1329
|
-
}
|
1330
|
-
}
|
1331
1221
|
|
1332
|
-
|
1333
|
-
|
1334
|
-
|
1335
|
-
|
1336
|
-
|
1222
|
+
function reportGlobalError(response, error) {
|
1223
|
+
response._chunks.forEach(function (chunk) {
|
1224
|
+
// If this chunk was already resolved or errored, it won't
|
1225
|
+
// trigger an error but if it wasn't then we need to
|
1226
|
+
// because we won't be getting any new data to resolve it.
|
1227
|
+
if (chunk.status === PENDING) {
|
1228
|
+
triggerErrorOnChunk(chunk, error);
|
1229
|
+
}
|
1230
|
+
});
|
1231
|
+
}
|
1337
1232
|
|
1338
|
-
|
1233
|
+
function createElement(type, key, props) {
|
1234
|
+
var element = {
|
1235
|
+
// This tag allows us to uniquely identify this as a React Element
|
1236
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
1237
|
+
// Built-in properties that belong on the element
|
1238
|
+
type: type,
|
1239
|
+
key: key,
|
1240
|
+
ref: null,
|
1241
|
+
props: props,
|
1242
|
+
// Record the component responsible for creating this element.
|
1243
|
+
_owner: null
|
1244
|
+
};
|
1339
1245
|
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1246
|
+
{
|
1247
|
+
// We don't really need to add any of these but keeping them for good measure.
|
1248
|
+
// Unfortunately, _store is enumerable in jest matchers so for equality to
|
1249
|
+
// work, I need to keep it or make _store non-enumerable in the other file.
|
1250
|
+
element._store = {};
|
1251
|
+
Object.defineProperty(element._store, 'validated', {
|
1252
|
+
configurable: false,
|
1253
|
+
enumerable: false,
|
1254
|
+
writable: true,
|
1255
|
+
value: true // This element has already been validated on the server.
|
1344
1256
|
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1257
|
+
});
|
1258
|
+
Object.defineProperty(element, '_self', {
|
1259
|
+
configurable: false,
|
1260
|
+
enumerable: false,
|
1261
|
+
writable: false,
|
1262
|
+
value: null
|
1263
|
+
});
|
1264
|
+
Object.defineProperty(element, '_source', {
|
1265
|
+
configurable: false,
|
1266
|
+
enumerable: false,
|
1267
|
+
writable: false,
|
1268
|
+
value: null
|
1269
|
+
});
|
1270
|
+
}
|
1348
1271
|
|
1349
|
-
|
1272
|
+
return element;
|
1273
|
+
}
|
1350
1274
|
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1275
|
+
function createLazyChunkWrapper(chunk) {
|
1276
|
+
var lazyType = {
|
1277
|
+
$$typeof: REACT_LAZY_TYPE,
|
1278
|
+
_payload: chunk,
|
1279
|
+
_init: readChunk
|
1280
|
+
};
|
1281
|
+
return lazyType;
|
1282
|
+
}
|
1357
1283
|
|
1358
|
-
|
1359
|
-
|
1360
|
-
|
1361
|
-
str += _substr3;
|
1362
|
-
} else if (_substr3.length < 10 && str.length + _substr3.length < 40) {
|
1363
|
-
str += _substr3;
|
1364
|
-
} else {
|
1365
|
-
str += '...';
|
1366
|
-
}
|
1367
|
-
}
|
1284
|
+
function getChunk(response, id) {
|
1285
|
+
var chunks = response._chunks;
|
1286
|
+
var chunk = chunks.get(id);
|
1368
1287
|
|
1369
|
-
|
1370
|
-
|
1288
|
+
if (!chunk) {
|
1289
|
+
chunk = createPendingChunk(response);
|
1290
|
+
chunks.set(id, chunk);
|
1371
1291
|
}
|
1372
1292
|
|
1373
|
-
|
1374
|
-
|
1375
|
-
}
|
1293
|
+
return chunk;
|
1294
|
+
}
|
1376
1295
|
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1296
|
+
function createModelResolver(chunk, parentObject, key) {
|
1297
|
+
var blocked;
|
1298
|
+
|
1299
|
+
if (initializingChunkBlockedModel) {
|
1300
|
+
blocked = initializingChunkBlockedModel;
|
1301
|
+
blocked.deps++;
|
1302
|
+
} else {
|
1303
|
+
blocked = initializingChunkBlockedModel = {
|
1304
|
+
deps: 1,
|
1305
|
+
value: null
|
1306
|
+
};
|
1380
1307
|
}
|
1381
1308
|
|
1382
|
-
return
|
1383
|
-
|
1309
|
+
return function (value) {
|
1310
|
+
parentObject[key] = value;
|
1311
|
+
blocked.deps--;
|
1384
1312
|
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1313
|
+
if (blocked.deps === 0) {
|
1314
|
+
if (chunk.status !== BLOCKED) {
|
1315
|
+
return;
|
1316
|
+
}
|
1389
1317
|
|
1390
|
-
|
1391
|
-
|
1318
|
+
var resolveListeners = chunk.value;
|
1319
|
+
var initializedChunk = chunk;
|
1320
|
+
initializedChunk.status = INITIALIZED;
|
1321
|
+
initializedChunk.value = blocked.value;
|
1322
|
+
|
1323
|
+
if (resolveListeners !== null) {
|
1324
|
+
wakeChunk(resolveListeners, blocked.value);
|
1325
|
+
}
|
1326
|
+
}
|
1327
|
+
};
|
1392
1328
|
}
|
1393
1329
|
|
1394
|
-
function
|
1395
|
-
return
|
1330
|
+
function createModelReject(chunk) {
|
1331
|
+
return function (error) {
|
1332
|
+
return triggerErrorOnChunk(chunk, error);
|
1333
|
+
};
|
1396
1334
|
}
|
1397
1335
|
|
1398
|
-
function
|
1399
|
-
|
1400
|
-
}
|
1336
|
+
function createServerReferenceProxy(response, metaData) {
|
1337
|
+
var callServer = response._callServer;
|
1401
1338
|
|
1402
|
-
|
1403
|
-
|
1404
|
-
|
1405
|
-
|
1339
|
+
var proxy = function () {
|
1340
|
+
// $FlowFixMe[method-unbinding]
|
1341
|
+
var args = Array.prototype.slice.call(arguments);
|
1342
|
+
var p = metaData.bound;
|
1406
1343
|
|
1407
|
-
|
1408
|
-
|
1409
|
-
if (number === 0 && 1 / number === -Infinity) {
|
1410
|
-
return '$-0';
|
1411
|
-
} else {
|
1412
|
-
return number;
|
1413
|
-
}
|
1414
|
-
} else {
|
1415
|
-
if (number === Infinity) {
|
1416
|
-
return '$Infinity';
|
1417
|
-
} else if (number === -Infinity) {
|
1418
|
-
return '$-Infinity';
|
1419
|
-
} else {
|
1420
|
-
return '$NaN';
|
1344
|
+
if (!p) {
|
1345
|
+
return callServer(metaData.id, args);
|
1421
1346
|
}
|
1422
|
-
}
|
1423
|
-
}
|
1424
1347
|
|
1425
|
-
|
1426
|
-
|
1427
|
-
|
1348
|
+
if (p.status === INITIALIZED) {
|
1349
|
+
var bound = p.value;
|
1350
|
+
return callServer(metaData.id, bound.concat(args));
|
1351
|
+
} // Since this is a fake Promise whose .then doesn't chain, we have to wrap it.
|
1352
|
+
// TODO: Remove the wrapper once that's fixed.
|
1428
1353
|
|
1429
|
-
function serializeDateFromDateJSON(dateJSON) {
|
1430
|
-
// JSON.stringify automatically calls Date.prototype.toJSON which calls toISOString.
|
1431
|
-
// We need only tack on a $D prefix.
|
1432
|
-
return '$D' + dateJSON;
|
1433
|
-
}
|
1434
1354
|
|
1435
|
-
|
1436
|
-
|
1355
|
+
return Promise.resolve(p).then(function (bound) {
|
1356
|
+
return callServer(metaData.id, bound.concat(args));
|
1357
|
+
});
|
1358
|
+
}; // Expose encoder for use by SSR.
|
1359
|
+
// TODO: Only expose this in SSR builds and not the browser client.
|
1360
|
+
|
1361
|
+
|
1362
|
+
proxy.$$FORM_ACTION = encodeFormAction;
|
1363
|
+
knownServerReferences.set(proxy, metaData);
|
1364
|
+
return proxy;
|
1437
1365
|
}
|
1438
1366
|
|
1439
|
-
function
|
1367
|
+
function parseModelString(response, parentObject, key, value) {
|
1440
1368
|
if (value[0] === '$') {
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
return value;
|
1446
|
-
}
|
1447
|
-
}
|
1369
|
+
if (value === '$') {
|
1370
|
+
// A very common symbol.
|
1371
|
+
return REACT_ELEMENT_TYPE;
|
1372
|
+
}
|
1448
1373
|
|
1449
|
-
|
1450
|
-
|
1451
|
-
|
1452
|
-
|
1374
|
+
switch (value[1]) {
|
1375
|
+
case '$':
|
1376
|
+
{
|
1377
|
+
// This was an escaped string value.
|
1378
|
+
return value.slice(1);
|
1379
|
+
}
|
1453
1380
|
|
1454
|
-
|
1455
|
-
|
1381
|
+
case 'L':
|
1382
|
+
{
|
1383
|
+
// Lazy node
|
1384
|
+
var id = parseInt(value.slice(2), 16);
|
1385
|
+
var chunk = getChunk(response, id); // We create a React.lazy wrapper around any lazy values.
|
1386
|
+
// When passed into React, we'll know how to suspend on this.
|
1456
1387
|
|
1457
|
-
|
1458
|
-
|
1459
|
-
var originalValue = parent[key];
|
1388
|
+
return createLazyChunkWrapper(chunk);
|
1389
|
+
}
|
1460
1390
|
|
1461
|
-
|
1462
|
-
|
1463
|
-
|
1464
|
-
|
1465
|
-
|
1391
|
+
case '@':
|
1392
|
+
{
|
1393
|
+
// Promise
|
1394
|
+
var _id = parseInt(value.slice(2), 16);
|
1395
|
+
|
1396
|
+
var _chunk = getChunk(response, _id);
|
1397
|
+
|
1398
|
+
return _chunk;
|
1466
1399
|
}
|
1467
|
-
}
|
1468
|
-
}
|
1469
1400
|
|
1470
|
-
|
1471
|
-
|
1472
|
-
|
1401
|
+
case 'S':
|
1402
|
+
{
|
1403
|
+
// Symbol
|
1404
|
+
return Symbol.for(value.slice(2));
|
1405
|
+
}
|
1473
1406
|
|
1474
|
-
|
1475
|
-
|
1476
|
-
|
1477
|
-
|
1478
|
-
// or a Promise type. Either of which can be represented by a Promise.
|
1479
|
-
if (formData === null) {
|
1480
|
-
// Upgrade to use FormData to allow us to stream this value.
|
1481
|
-
formData = new FormData();
|
1407
|
+
case 'P':
|
1408
|
+
{
|
1409
|
+
// Server Context Provider
|
1410
|
+
return getOrCreateServerContext(value.slice(2)).Provider;
|
1482
1411
|
}
|
1483
1412
|
|
1484
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
var partJSON = JSON.stringify(partValue, resolveToJSON); // $FlowFixMe[incompatible-type] We know it's not null because we assigned it above.
|
1413
|
+
case 'F':
|
1414
|
+
{
|
1415
|
+
// Server Reference
|
1416
|
+
var _id2 = parseInt(value.slice(2), 16);
|
1489
1417
|
|
1490
|
-
var
|
1418
|
+
var _chunk2 = getChunk(response, _id2);
|
1491
1419
|
|
1492
|
-
|
1493
|
-
|
1420
|
+
switch (_chunk2.status) {
|
1421
|
+
case RESOLVED_MODEL:
|
1422
|
+
initializeModelChunk(_chunk2);
|
1423
|
+
break;
|
1424
|
+
} // The status might have changed after initialization.
|
1494
1425
|
|
1495
|
-
if (pendingParts === 0) {
|
1496
|
-
resolve(data);
|
1497
|
-
}
|
1498
|
-
}, function (reason) {
|
1499
|
-
// In the future we could consider serializing this as an error
|
1500
|
-
// that throws on the server instead.
|
1501
|
-
reject(reason);
|
1502
|
-
});
|
1503
|
-
return serializePromiseID(promiseId);
|
1504
|
-
} // TODO: Should we the Object.prototype.toString.call() to test for cross-realm objects?
|
1505
1426
|
|
1427
|
+
switch (_chunk2.status) {
|
1428
|
+
case INITIALIZED:
|
1429
|
+
{
|
1430
|
+
var metadata = _chunk2.value;
|
1431
|
+
return createServerReferenceProxy(response, metadata);
|
1432
|
+
}
|
1433
|
+
// We always encode it first in the stream so it won't be pending.
|
1506
1434
|
|
1507
|
-
|
1508
|
-
|
1509
|
-
|
1510
|
-
formData = new FormData();
|
1435
|
+
default:
|
1436
|
+
throw _chunk2.reason;
|
1437
|
+
}
|
1511
1438
|
}
|
1512
1439
|
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1440
|
+
case 'I':
|
1441
|
+
{
|
1442
|
+
// $Infinity
|
1443
|
+
return Infinity;
|
1444
|
+
}
|
1517
1445
|
|
1518
|
-
|
1446
|
+
case '-':
|
1447
|
+
{
|
1448
|
+
// $-0 or $-Infinity
|
1449
|
+
if (value === '$-0') {
|
1450
|
+
return -0;
|
1451
|
+
} else {
|
1452
|
+
return -Infinity;
|
1453
|
+
}
|
1454
|
+
}
|
1519
1455
|
|
1520
|
-
|
1521
|
-
|
1522
|
-
|
1523
|
-
|
1524
|
-
|
1456
|
+
case 'N':
|
1457
|
+
{
|
1458
|
+
// $NaN
|
1459
|
+
return NaN;
|
1460
|
+
}
|
1525
1461
|
|
1526
|
-
|
1527
|
-
|
1462
|
+
case 'u':
|
1463
|
+
{
|
1464
|
+
// matches "$undefined"
|
1465
|
+
// Special encoding for `undefined` which can't be serialized as JSON otherwise.
|
1466
|
+
return undefined;
|
1467
|
+
}
|
1528
1468
|
|
1529
|
-
|
1530
|
-
|
1469
|
+
case 'D':
|
1470
|
+
{
|
1471
|
+
// Date
|
1472
|
+
return new Date(Date.parse(value.slice(2)));
|
1531
1473
|
}
|
1532
|
-
}
|
1533
1474
|
|
1534
|
-
|
1535
|
-
|
1536
|
-
//
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1475
|
+
case 'n':
|
1476
|
+
{
|
1477
|
+
// BigInt
|
1478
|
+
return BigInt(value.slice(2));
|
1479
|
+
}
|
1480
|
+
|
1481
|
+
default:
|
1482
|
+
{
|
1483
|
+
// We assume that anything else is a reference ID.
|
1484
|
+
var _id3 = parseInt(value.slice(1), 16);
|
1485
|
+
|
1486
|
+
var _chunk3 = getChunk(response, _id3);
|
1487
|
+
|
1488
|
+
switch (_chunk3.status) {
|
1489
|
+
case RESOLVED_MODEL:
|
1490
|
+
initializeModelChunk(_chunk3);
|
1491
|
+
break;
|
1492
|
+
|
1493
|
+
case RESOLVED_MODULE:
|
1494
|
+
initializeModuleChunk(_chunk3);
|
1495
|
+
break;
|
1496
|
+
} // The status might have changed after initialization.
|
1497
|
+
|
1498
|
+
|
1499
|
+
switch (_chunk3.status) {
|
1500
|
+
case INITIALIZED:
|
1501
|
+
return _chunk3.value;
|
1549
1502
|
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1503
|
+
case PENDING:
|
1504
|
+
case BLOCKED:
|
1505
|
+
var parentChunk = initializingChunk;
|
1506
|
+
|
1507
|
+
_chunk3.then(createModelResolver(parentChunk, parentObject, key), createModelReject(parentChunk));
|
1508
|
+
|
1509
|
+
return null;
|
1510
|
+
|
1511
|
+
default:
|
1512
|
+
throw _chunk3.reason;
|
1553
1513
|
}
|
1554
1514
|
}
|
1555
|
-
|
1515
|
+
}
|
1516
|
+
}
|
1556
1517
|
|
1518
|
+
return value;
|
1519
|
+
}
|
1520
|
+
function parseModelTuple(response, value) {
|
1521
|
+
var tuple = value;
|
1557
1522
|
|
1558
|
-
|
1559
|
-
|
1523
|
+
if (tuple[0] === REACT_ELEMENT_TYPE) {
|
1524
|
+
// TODO: Consider having React just directly accept these arrays as elements.
|
1525
|
+
// Or even change the ReactElement type to be an array.
|
1526
|
+
return createElement(tuple[1], tuple[2], tuple[3]);
|
1527
|
+
}
|
1560
1528
|
|
1561
|
-
|
1562
|
-
|
1563
|
-
if (value[value.length - 1] === 'Z') {
|
1564
|
-
// Possibly a Date, whose toJSON automatically calls toISOString
|
1565
|
-
// $FlowFixMe[incompatible-use]
|
1566
|
-
var _originalValue = parent[key]; // $FlowFixMe[method-unbinding]
|
1529
|
+
return value;
|
1530
|
+
}
|
1567
1531
|
|
1568
|
-
|
1569
|
-
|
1570
|
-
|
1571
|
-
}
|
1532
|
+
function missingCall() {
|
1533
|
+
throw new Error('Trying to call a function from "use server" but the callServer option ' + 'was not implemented in your router runtime.');
|
1534
|
+
}
|
1572
1535
|
|
1573
|
-
|
1574
|
-
|
1536
|
+
function createResponse$1(bundlerConfig, callServer) {
|
1537
|
+
var chunks = new Map();
|
1538
|
+
var response = {
|
1539
|
+
_bundlerConfig: bundlerConfig,
|
1540
|
+
_callServer: callServer !== undefined ? callServer : missingCall,
|
1541
|
+
_chunks: chunks
|
1542
|
+
};
|
1543
|
+
return response;
|
1544
|
+
}
|
1545
|
+
function resolveModel(response, id, model) {
|
1546
|
+
var chunks = response._chunks;
|
1547
|
+
var chunk = chunks.get(id);
|
1575
1548
|
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1549
|
+
if (!chunk) {
|
1550
|
+
chunks.set(id, createResolvedModelChunk(response, model));
|
1551
|
+
} else {
|
1552
|
+
resolveModelChunk(chunk, model);
|
1553
|
+
}
|
1554
|
+
}
|
1555
|
+
function resolveModule(response, id, model) {
|
1556
|
+
var chunks = response._chunks;
|
1557
|
+
var chunk = chunks.get(id);
|
1558
|
+
var clientReferenceMetadata = parseModel(response, model);
|
1559
|
+
var clientReference = resolveClientReference(response._bundlerConfig, clientReferenceMetadata); // TODO: Add an option to encode modules that are lazy loaded.
|
1560
|
+
// For now we preload all modules as early as possible since it's likely
|
1561
|
+
// that we'll need them.
|
1579
1562
|
|
1580
|
-
|
1581
|
-
|
1563
|
+
var promise = preloadModule(clientReference);
|
1564
|
+
|
1565
|
+
if (promise) {
|
1566
|
+
var blockedChunk;
|
1567
|
+
|
1568
|
+
if (!chunk) {
|
1569
|
+
// Technically, we should just treat promise as the chunk in this
|
1570
|
+
// case. Because it'll just behave as any other promise.
|
1571
|
+
blockedChunk = createBlockedChunk(response);
|
1572
|
+
chunks.set(id, blockedChunk);
|
1573
|
+
} else {
|
1574
|
+
// This can't actually happen because we don't have any forward
|
1575
|
+
// references to modules.
|
1576
|
+
blockedChunk = chunk;
|
1577
|
+
blockedChunk.status = BLOCKED;
|
1582
1578
|
}
|
1583
1579
|
|
1584
|
-
|
1585
|
-
return
|
1580
|
+
promise.then(function () {
|
1581
|
+
return resolveModuleChunk(blockedChunk, clientReference);
|
1582
|
+
}, function (error) {
|
1583
|
+
return triggerErrorOnChunk(blockedChunk, error);
|
1584
|
+
});
|
1585
|
+
} else {
|
1586
|
+
if (!chunk) {
|
1587
|
+
chunks.set(id, createResolvedModuleChunk(response, clientReference));
|
1588
|
+
} else {
|
1589
|
+
// This can't actually happen because we don't have any forward
|
1590
|
+
// references to modules.
|
1591
|
+
resolveModuleChunk(chunk, clientReference);
|
1586
1592
|
}
|
1593
|
+
}
|
1594
|
+
}
|
1595
|
+
function resolveErrorDev(response, id, digest, message, stack) {
|
1587
1596
|
|
1588
|
-
if (typeof value === 'function') {
|
1589
|
-
var metaData = knownServerReferences.get(value);
|
1590
1597
|
|
1591
|
-
|
1592
|
-
|
1598
|
+
var error = new Error(message || 'An error occurred in the Server Components render but no message was provided');
|
1599
|
+
error.stack = stack;
|
1600
|
+
error.digest = digest;
|
1601
|
+
var errorWithDigest = error;
|
1602
|
+
var chunks = response._chunks;
|
1603
|
+
var chunk = chunks.get(id);
|
1593
1604
|
|
1594
|
-
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1605
|
+
if (!chunk) {
|
1606
|
+
chunks.set(id, createErrorChunk(response, errorWithDigest));
|
1607
|
+
} else {
|
1608
|
+
triggerErrorOnChunk(chunk, errorWithDigest);
|
1609
|
+
}
|
1610
|
+
}
|
1611
|
+
function resolveHint(response, code, model) {
|
1612
|
+
var hintModel = parseModel(response, model);
|
1613
|
+
dispatchHint(code, hintModel);
|
1614
|
+
}
|
1615
|
+
function close(response) {
|
1616
|
+
// In case there are any remaining unresolved chunks, they won't
|
1617
|
+
// be resolved now. So we need to issue an error to those.
|
1618
|
+
// Ideally we should be able to early bail out if we kept a
|
1619
|
+
// ref count of pending chunks.
|
1620
|
+
reportGlobalError(response, new Error('Connection closed.'));
|
1621
|
+
}
|
1598
1622
|
|
1623
|
+
function processFullRow(response, row) {
|
1624
|
+
if (row === '') {
|
1625
|
+
return;
|
1626
|
+
}
|
1599
1627
|
|
1600
|
-
|
1628
|
+
var colon = row.indexOf(':', 0);
|
1629
|
+
var id = parseInt(row.slice(0, colon), 16);
|
1630
|
+
var tag = row[colon + 1]; // When tags that are not text are added, check them here before
|
1631
|
+
// parsing the row as text.
|
1632
|
+
// switch (tag) {
|
1633
|
+
// }
|
1601
1634
|
|
1635
|
+
switch (tag) {
|
1636
|
+
case 'I':
|
1637
|
+
{
|
1638
|
+
resolveModule(response, id, row.slice(colon + 2));
|
1639
|
+
return;
|
1640
|
+
}
|
1602
1641
|
|
1603
|
-
|
1604
|
-
|
1642
|
+
case 'H':
|
1643
|
+
{
|
1644
|
+
var code = row[colon + 2];
|
1645
|
+
resolveHint(response, code, row.slice(colon + 3));
|
1646
|
+
return;
|
1605
1647
|
}
|
1606
1648
|
|
1607
|
-
|
1608
|
-
|
1649
|
+
case 'E':
|
1650
|
+
{
|
1651
|
+
var errorInfo = JSON.parse(row.slice(colon + 2));
|
1609
1652
|
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
1653
|
+
{
|
1654
|
+
resolveErrorDev(response, id, errorInfo.digest, errorInfo.message, errorInfo.stack);
|
1655
|
+
}
|
1613
1656
|
|
1614
|
-
|
1615
|
-
throw new Error('Only global symbols received from Symbol.for(...) can be passed to Server Functions. ' + ("The symbol Symbol.for(" + // $FlowFixMe[incompatible-type] `description` might be undefined
|
1616
|
-
value.description + ") cannot be found among global symbols."));
|
1657
|
+
return;
|
1617
1658
|
}
|
1618
1659
|
|
1619
|
-
|
1660
|
+
default:
|
1661
|
+
{
|
1662
|
+
// We assume anything else is JSON.
|
1663
|
+
resolveModel(response, id, row.slice(colon + 1));
|
1664
|
+
return;
|
1665
|
+
}
|
1666
|
+
}
|
1667
|
+
}
|
1668
|
+
|
1669
|
+
function processStringChunk(response, chunk, offset) {
|
1670
|
+
var linebreak = chunk.indexOf('\n', offset);
|
1671
|
+
|
1672
|
+
while (linebreak > -1) {
|
1673
|
+
var fullrow = response._partialRow + chunk.slice(offset, linebreak);
|
1674
|
+
processFullRow(response, fullrow);
|
1675
|
+
response._partialRow = '';
|
1676
|
+
offset = linebreak + 1;
|
1677
|
+
linebreak = chunk.indexOf('\n', offset);
|
1678
|
+
}
|
1679
|
+
|
1680
|
+
response._partialRow += chunk.slice(offset);
|
1681
|
+
}
|
1682
|
+
function processBinaryChunk(response, chunk) {
|
1683
|
+
|
1684
|
+
var stringDecoder = response._stringDecoder;
|
1685
|
+
var linebreak = chunk.indexOf(10); // newline
|
1686
|
+
|
1687
|
+
while (linebreak > -1) {
|
1688
|
+
var fullrow = response._partialRow + readFinalStringChunk(stringDecoder, chunk.subarray(0, linebreak));
|
1689
|
+
processFullRow(response, fullrow);
|
1690
|
+
response._partialRow = '';
|
1691
|
+
chunk = chunk.subarray(linebreak + 1);
|
1692
|
+
linebreak = chunk.indexOf(10); // newline
|
1693
|
+
}
|
1694
|
+
|
1695
|
+
response._partialRow += readPartialStringChunk(stringDecoder, chunk);
|
1696
|
+
}
|
1697
|
+
|
1698
|
+
function createFromJSONCallback(response) {
|
1699
|
+
// $FlowFixMe[missing-this-annot]
|
1700
|
+
return function (key, value) {
|
1701
|
+
if (typeof value === 'string') {
|
1702
|
+
// We can't use .bind here because we need the "this" value.
|
1703
|
+
return parseModelString(response, this, key, value);
|
1620
1704
|
}
|
1621
1705
|
|
1622
|
-
if (typeof value === '
|
1623
|
-
return
|
1706
|
+
if (typeof value === 'object' && value !== null) {
|
1707
|
+
return parseModelTuple(response, value);
|
1624
1708
|
}
|
1625
1709
|
|
1626
|
-
|
1627
|
-
}
|
1710
|
+
return value;
|
1711
|
+
};
|
1712
|
+
}
|
1628
1713
|
|
1714
|
+
function createResponse(bundlerConfig, callServer) {
|
1715
|
+
// NOTE: CHECK THE COMPILER OUTPUT EACH TIME YOU CHANGE THIS.
|
1716
|
+
// It should be inlined to one object literal but minor changes can break it.
|
1717
|
+
var stringDecoder = createStringDecoder() ;
|
1718
|
+
var response = createResponse$1(bundlerConfig, callServer);
|
1719
|
+
response._partialRow = '';
|
1629
1720
|
|
1630
|
-
|
1721
|
+
{
|
1722
|
+
response._stringDecoder = stringDecoder;
|
1723
|
+
} // Don't inline this call because it causes closure to outline the call above.
|
1631
1724
|
|
1632
|
-
if (formData === null) {
|
1633
|
-
// If it's a simple data structure, we just use plain JSON.
|
1634
|
-
resolve(json);
|
1635
|
-
} else {
|
1636
|
-
// Otherwise, we use FormData to let us stream in the result.
|
1637
|
-
formData.set(formFieldPrefix + '0', json);
|
1638
1725
|
|
1639
|
-
|
1640
|
-
|
1641
|
-
resolve(formData);
|
1642
|
-
}
|
1643
|
-
}
|
1726
|
+
response._fromJSON = createFromJSONCallback(response);
|
1727
|
+
return response;
|
1644
1728
|
}
|
1645
1729
|
|
1646
1730
|
function createResponseFromOptions(options) {
|