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