react-server-dom-webpack 18.3.0-next-a8875eab7-20230310 → 18.3.0-next-56a3c18e5-20230314
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 +582 -1
- package/cjs/react-server-dom-webpack-client.browser.production.min.js +22 -19
- package/cjs/react-server-dom-webpack-client.edge.development.js +4 -1
- package/cjs/react-server-dom-webpack-client.edge.production.min.js +16 -16
- package/cjs/react-server-dom-webpack-client.node.development.js +4 -1
- package/cjs/react-server-dom-webpack-client.node.production.min.js +18 -18
- package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +3 -0
- package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +15 -15
- package/cjs/react-server-dom-webpack-server.browser.development.js +1146 -617
- package/cjs/react-server-dom-webpack-server.browser.production.min.js +57 -46
- package/cjs/react-server-dom-webpack-server.edge.development.js +1146 -617
- package/cjs/react-server-dom-webpack-server.edge.production.min.js +55 -44
- package/cjs/react-server-dom-webpack-server.node.development.js +1181 -613
- package/cjs/react-server-dom-webpack-server.node.production.min.js +58 -46
- package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +1145 -617
- package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +52 -41
- package/package.json +3 -3
- package/umd/react-server-dom-webpack-client.browser.development.js +582 -1
- package/umd/react-server-dom-webpack-client.browser.production.min.js +17 -14
- package/umd/react-server-dom-webpack-server.browser.development.js +1146 -617
- package/umd/react-server-dom-webpack-server.browser.production.min.js +44 -37
@@ -205,7 +205,7 @@ function completeWriting(destination) {
|
|
205
205
|
writtenBytes = 0;
|
206
206
|
destinationHasCapacity = true;
|
207
207
|
}
|
208
|
-
function close(destination) {
|
208
|
+
function close$1(destination) {
|
209
209
|
destination.end();
|
210
210
|
}
|
211
211
|
var textEncoder = new util.TextEncoder();
|
@@ -541,7 +541,13 @@ var capitalize = function (token) {
|
|
541
541
|
new PropertyInfoRecord('xlinkHref', STRING, false, // mustUseProperty
|
542
542
|
'xlink:href', 'http://www.w3.org/1999/xlink', true, // sanitizeURL
|
543
543
|
false);
|
544
|
-
|
544
|
+
|
545
|
+
new PropertyInfoRecord('formAction', STRING, false, // mustUseProperty
|
546
|
+
'formaction', // attributeName
|
547
|
+
null, // attributeNamespace
|
548
|
+
true, // sanitizeURL
|
549
|
+
false);
|
550
|
+
['src', 'href', 'action'].forEach(function (attributeName) {
|
545
551
|
// $FlowFixMe[invalid-constructor] Flow no longer supports calling new on functions
|
546
552
|
new PropertyInfoRecord(attributeName, STRING, false, // mustUseProperty
|
547
553
|
attributeName.toLowerCase(), // attributeName
|
@@ -1231,779 +1237,779 @@ function getCurrentCache() {
|
|
1231
1237
|
return currentCache;
|
1232
1238
|
}
|
1233
1239
|
|
1234
|
-
|
1235
|
-
|
1236
|
-
|
1237
|
-
|
1238
|
-
|
1240
|
+
// in case they error.
|
1241
|
+
|
1242
|
+
var jsxPropsParents = new WeakMap();
|
1243
|
+
var jsxChildrenParents = new WeakMap();
|
1244
|
+
|
1245
|
+
function isObjectPrototype(object) {
|
1246
|
+
if (!object) {
|
1247
|
+
return false;
|
1239
1248
|
}
|
1240
1249
|
|
1241
|
-
|
1242
|
-
}
|
1250
|
+
var ObjectPrototype = Object.prototype;
|
1243
1251
|
|
1244
|
-
|
1252
|
+
if (object === ObjectPrototype) {
|
1253
|
+
return true;
|
1254
|
+
} // It might be an object from a different Realm which is
|
1255
|
+
// still just a plain simple object.
|
1245
1256
|
|
1246
|
-
var PENDING = 0;
|
1247
|
-
var COMPLETED = 1;
|
1248
|
-
var ABORTED = 3;
|
1249
|
-
var ERRORED = 4;
|
1250
|
-
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
1251
|
-
var ReactCurrentCache = ReactSharedInternals.ReactCurrentCache;
|
1252
1257
|
|
1253
|
-
|
1254
|
-
|
1258
|
+
if (Object.getPrototypeOf(object)) {
|
1259
|
+
return false;
|
1260
|
+
}
|
1261
|
+
|
1262
|
+
var names = Object.getOwnPropertyNames(object);
|
1263
|
+
|
1264
|
+
for (var i = 0; i < names.length; i++) {
|
1265
|
+
if (!(names[i] in ObjectPrototype)) {
|
1266
|
+
return false;
|
1267
|
+
}
|
1268
|
+
}
|
1269
|
+
|
1270
|
+
return true;
|
1255
1271
|
}
|
1256
1272
|
|
1257
|
-
|
1258
|
-
|
1259
|
-
|
1260
|
-
function createRequest(model, bundlerConfig, onError, context, identifierPrefix) {
|
1261
|
-
if (ReactCurrentCache.current !== null && ReactCurrentCache.current !== DefaultCacheDispatcher) {
|
1262
|
-
throw new Error('Currently React only supports one RSC renderer at a time.');
|
1273
|
+
function isSimpleObject(object) {
|
1274
|
+
if (!isObjectPrototype(Object.getPrototypeOf(object))) {
|
1275
|
+
return false;
|
1263
1276
|
}
|
1264
1277
|
|
1265
|
-
|
1266
|
-
|
1267
|
-
var
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
bundlerConfig: bundlerConfig,
|
1273
|
-
cache: new Map(),
|
1274
|
-
nextChunkId: 0,
|
1275
|
-
pendingChunks: 0,
|
1276
|
-
abortableTasks: abortSet,
|
1277
|
-
pingedTasks: pingedTasks,
|
1278
|
-
completedImportChunks: [],
|
1279
|
-
completedJSONChunks: [],
|
1280
|
-
completedErrorChunks: [],
|
1281
|
-
writtenSymbols: new Map(),
|
1282
|
-
writtenClientReferences: new Map(),
|
1283
|
-
writtenServerReferences: new Map(),
|
1284
|
-
writtenProviders: new Map(),
|
1285
|
-
identifierPrefix: identifierPrefix || '',
|
1286
|
-
identifierCount: 1,
|
1287
|
-
onError: onError === undefined ? defaultErrorHandler : onError,
|
1288
|
-
// $FlowFixMe[missing-this-annot]
|
1289
|
-
toJSON: function (key, value) {
|
1290
|
-
return resolveModelToJSON(request, this, key, value);
|
1278
|
+
var names = Object.getOwnPropertyNames(object);
|
1279
|
+
|
1280
|
+
for (var i = 0; i < names.length; i++) {
|
1281
|
+
var descriptor = Object.getOwnPropertyDescriptor(object, names[i]);
|
1282
|
+
|
1283
|
+
if (!descriptor) {
|
1284
|
+
return false;
|
1291
1285
|
}
|
1292
|
-
};
|
1293
|
-
request.pendingChunks++;
|
1294
|
-
var rootContext = createRootContext(context);
|
1295
|
-
var rootTask = createTask(request, model, rootContext, abortSet);
|
1296
|
-
pingedTasks.push(rootTask);
|
1297
|
-
return request;
|
1298
|
-
}
|
1299
1286
|
|
1300
|
-
|
1301
|
-
|
1302
|
-
|
1287
|
+
if (!descriptor.enumerable) {
|
1288
|
+
if ((names[i] === 'key' || names[i] === 'ref') && typeof descriptor.get === 'function') {
|
1289
|
+
// React adds key and ref getters to props objects to issue warnings.
|
1290
|
+
// Those getters will not be transferred to the client, but that's ok,
|
1291
|
+
// so we'll special case them.
|
1292
|
+
continue;
|
1293
|
+
}
|
1303
1294
|
|
1304
|
-
|
1305
|
-
|
1295
|
+
return false;
|
1296
|
+
}
|
1297
|
+
}
|
1306
1298
|
|
1307
|
-
|
1308
|
-
|
1299
|
+
return true;
|
1300
|
+
}
|
1301
|
+
function objectName(object) {
|
1302
|
+
// $FlowFixMe[method-unbinding]
|
1303
|
+
var name = Object.prototype.toString.call(object);
|
1304
|
+
return name.replace(/^\[object (.*)\]$/, function (m, p0) {
|
1305
|
+
return p0;
|
1306
|
+
});
|
1307
|
+
}
|
1309
1308
|
|
1310
|
-
function
|
1311
|
-
|
1312
|
-
|
1309
|
+
function describeKeyForErrorMessage(key) {
|
1310
|
+
var encodedKey = JSON.stringify(key);
|
1311
|
+
return '"' + key + '"' === encodedKey ? key : encodedKey;
|
1312
|
+
}
|
1313
1313
|
|
1314
|
-
|
1315
|
-
|
1314
|
+
function describeValueForErrorMessage(value) {
|
1315
|
+
switch (typeof value) {
|
1316
|
+
case 'string':
|
1316
1317
|
{
|
1317
|
-
|
1318
|
-
newTask.model = thenable.value;
|
1319
|
-
pingTask(request, newTask);
|
1320
|
-
return newTask.id;
|
1318
|
+
return JSON.stringify(value.length <= 10 ? value : value.substr(0, 10) + '...');
|
1321
1319
|
}
|
1322
1320
|
|
1323
|
-
case '
|
1321
|
+
case 'object':
|
1324
1322
|
{
|
1325
|
-
|
1326
|
-
|
1323
|
+
if (isArray(value)) {
|
1324
|
+
return '[...]';
|
1325
|
+
}
|
1327
1326
|
|
1328
|
-
|
1329
|
-
var _getErrorMessageAndSt = getErrorMessageAndStackDev(x),
|
1330
|
-
message = _getErrorMessageAndSt.message,
|
1331
|
-
stack = _getErrorMessageAndSt.stack;
|
1327
|
+
var name = objectName(value);
|
1332
1328
|
|
1333
|
-
|
1329
|
+
if (name === 'Object') {
|
1330
|
+
return '{...}';
|
1334
1331
|
}
|
1335
1332
|
|
1336
|
-
return
|
1333
|
+
return name;
|
1337
1334
|
}
|
1338
1335
|
|
1336
|
+
case 'function':
|
1337
|
+
return 'function';
|
1338
|
+
|
1339
1339
|
default:
|
1340
|
-
|
1341
|
-
|
1342
|
-
|
1343
|
-
|
1344
|
-
// some custom userspace implementation. We treat it as "pending".
|
1345
|
-
break;
|
1346
|
-
}
|
1340
|
+
// eslint-disable-next-line react-internal/safe-string-coercion
|
1341
|
+
return String(value);
|
1342
|
+
}
|
1343
|
+
}
|
1347
1344
|
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
if (thenable.status === 'pending') {
|
1352
|
-
var fulfilledThenable = thenable;
|
1353
|
-
fulfilledThenable.status = 'fulfilled';
|
1354
|
-
fulfilledThenable.value = fulfilledValue;
|
1355
|
-
}
|
1356
|
-
}, function (error) {
|
1357
|
-
if (thenable.status === 'pending') {
|
1358
|
-
var rejectedThenable = thenable;
|
1359
|
-
rejectedThenable.status = 'rejected';
|
1360
|
-
rejectedThenable.reason = error;
|
1361
|
-
}
|
1362
|
-
});
|
1363
|
-
break;
|
1364
|
-
}
|
1345
|
+
function describeElementType(type) {
|
1346
|
+
if (typeof type === 'string') {
|
1347
|
+
return type;
|
1365
1348
|
}
|
1366
1349
|
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
}, function (reason) {
|
1371
|
-
newTask.status = ERRORED; // TODO: We should ideally do this inside performWork so it's scheduled
|
1350
|
+
switch (type) {
|
1351
|
+
case REACT_SUSPENSE_TYPE:
|
1352
|
+
return 'Suspense';
|
1372
1353
|
|
1373
|
-
|
1354
|
+
case REACT_SUSPENSE_LIST_TYPE:
|
1355
|
+
return 'SuspenseList';
|
1356
|
+
}
|
1374
1357
|
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1358
|
+
if (typeof type === 'object') {
|
1359
|
+
switch (type.$$typeof) {
|
1360
|
+
case REACT_FORWARD_REF_TYPE:
|
1361
|
+
return describeElementType(type.render);
|
1379
1362
|
|
1380
|
-
|
1381
|
-
|
1363
|
+
case REACT_MEMO_TYPE:
|
1364
|
+
return describeElementType(type.type);
|
1382
1365
|
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
}
|
1366
|
+
case REACT_LAZY_TYPE:
|
1367
|
+
{
|
1368
|
+
var lazyComponent = type;
|
1369
|
+
var payload = lazyComponent._payload;
|
1370
|
+
var init = lazyComponent._init;
|
1389
1371
|
|
1390
|
-
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
1372
|
+
try {
|
1373
|
+
// Lazy may contain any component type so we recursively resolve it.
|
1374
|
+
return describeElementType(init(payload));
|
1375
|
+
} catch (x) {}
|
1376
|
+
}
|
1377
|
+
}
|
1395
1378
|
}
|
1396
1379
|
|
1397
|
-
|
1380
|
+
return '';
|
1398
1381
|
}
|
1399
1382
|
|
1400
|
-
function
|
1401
|
-
|
1402
|
-
// promises everywhere.
|
1403
|
-
var thenable = wakeable;
|
1383
|
+
function describeObjectForErrorMessage(objectOrArray, expandedName) {
|
1384
|
+
var objKind = objectName(objectOrArray);
|
1404
1385
|
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
break;
|
1386
|
+
if (objKind !== 'Object' && objKind !== 'Array') {
|
1387
|
+
return objKind;
|
1388
|
+
}
|
1409
1389
|
|
1410
|
-
|
1411
|
-
|
1412
|
-
|
1413
|
-
// Only instrument the thenable if the status if not defined. If
|
1414
|
-
// it's defined, but an unknown value, assume it's been instrumented by
|
1415
|
-
// some custom userspace implementation. We treat it as "pending".
|
1416
|
-
break;
|
1417
|
-
}
|
1390
|
+
var str = '';
|
1391
|
+
var start = -1;
|
1392
|
+
var length = 0;
|
1418
1393
|
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1425
|
-
fulfilledThenable.value = fulfilledValue;
|
1426
|
-
}
|
1427
|
-
}, function (error) {
|
1428
|
-
if (thenable.status === 'pending') {
|
1429
|
-
var rejectedThenable = thenable;
|
1430
|
-
rejectedThenable.status = 'rejected';
|
1431
|
-
rejectedThenable.reason = error;
|
1432
|
-
}
|
1433
|
-
});
|
1434
|
-
break;
|
1435
|
-
}
|
1436
|
-
}
|
1437
|
-
|
1438
|
-
var lazyType = {
|
1439
|
-
$$typeof: REACT_LAZY_TYPE,
|
1440
|
-
_payload: thenable,
|
1441
|
-
_init: readThenable
|
1442
|
-
};
|
1443
|
-
return lazyType;
|
1444
|
-
}
|
1394
|
+
if (isArray(objectOrArray)) {
|
1395
|
+
if (jsxChildrenParents.has(objectOrArray)) {
|
1396
|
+
// Print JSX Children
|
1397
|
+
var type = jsxChildrenParents.get(objectOrArray);
|
1398
|
+
str = '<' + describeElementType(type) + '>';
|
1399
|
+
var array = objectOrArray;
|
1445
1400
|
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1449
|
-
// throw for functions. We could probably relax it to a DEV warning for other
|
1450
|
-
// cases.
|
1451
|
-
throw new Error('Refs cannot be used in Server Components, nor passed to Client Components.');
|
1452
|
-
}
|
1401
|
+
for (var i = 0; i < array.length; i++) {
|
1402
|
+
var value = array[i];
|
1403
|
+
var substr = void 0;
|
1453
1404
|
|
1454
|
-
|
1455
|
-
|
1405
|
+
if (typeof value === 'string') {
|
1406
|
+
substr = value;
|
1407
|
+
} else if (typeof value === 'object' && value !== null) {
|
1408
|
+
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1409
|
+
substr = '{' + describeObjectForErrorMessage(value) + '}';
|
1410
|
+
} else {
|
1411
|
+
substr = '{' + describeValueForErrorMessage(value) + '}';
|
1412
|
+
}
|
1456
1413
|
|
1457
|
-
|
1458
|
-
|
1459
|
-
|
1460
|
-
|
1414
|
+
if ('' + i === expandedName) {
|
1415
|
+
start = str.length;
|
1416
|
+
length = substr.length;
|
1417
|
+
str += substr;
|
1418
|
+
} else if (substr.length < 15 && str.length + substr.length < 40) {
|
1419
|
+
str += substr;
|
1420
|
+
} else {
|
1421
|
+
str += '{...}';
|
1422
|
+
}
|
1423
|
+
}
|
1461
1424
|
|
1462
|
-
|
1463
|
-
|
1464
|
-
//
|
1465
|
-
|
1466
|
-
|
1425
|
+
str += '</' + describeElementType(type) + '>';
|
1426
|
+
} else {
|
1427
|
+
// Print Array
|
1428
|
+
str = '[';
|
1429
|
+
var _array = objectOrArray;
|
1467
1430
|
|
1431
|
+
for (var _i = 0; _i < _array.length; _i++) {
|
1432
|
+
if (_i > 0) {
|
1433
|
+
str += ', ';
|
1434
|
+
}
|
1468
1435
|
|
1469
|
-
|
1470
|
-
var result = type(props);
|
1436
|
+
var _value = _array[_i];
|
1471
1437
|
|
1472
|
-
|
1473
|
-
// When the return value is in children position we can resolve it immediately,
|
1474
|
-
// to its value without a wrapper if it's synchronously available.
|
1475
|
-
var thenable = result;
|
1438
|
+
var _substr = void 0;
|
1476
1439
|
|
1477
|
-
|
1478
|
-
|
1479
|
-
|
1480
|
-
|
1440
|
+
if (typeof _value === 'object' && _value !== null) {
|
1441
|
+
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1442
|
+
_substr = describeObjectForErrorMessage(_value);
|
1443
|
+
} else {
|
1444
|
+
_substr = describeValueForErrorMessage(_value);
|
1445
|
+
}
|
1481
1446
|
|
1447
|
+
if ('' + _i === expandedName) {
|
1448
|
+
start = str.length;
|
1449
|
+
length = _substr.length;
|
1450
|
+
str += _substr;
|
1451
|
+
} else if (_substr.length < 10 && str.length + _substr.length < 40) {
|
1452
|
+
str += _substr;
|
1453
|
+
} else {
|
1454
|
+
str += '...';
|
1455
|
+
}
|
1456
|
+
}
|
1482
1457
|
|
1483
|
-
|
1458
|
+
str += ']';
|
1484
1459
|
}
|
1460
|
+
} else {
|
1461
|
+
if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
|
1462
|
+
str = '<' + describeElementType(objectOrArray.type) + '/>';
|
1463
|
+
} else if (jsxPropsParents.has(objectOrArray)) {
|
1464
|
+
// Print JSX
|
1465
|
+
var _type = jsxPropsParents.get(objectOrArray);
|
1485
1466
|
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
return [REACT_ELEMENT_TYPE, type, key, props];
|
1490
|
-
} else if (typeof type === 'symbol') {
|
1491
|
-
if (type === REACT_FRAGMENT_TYPE) {
|
1492
|
-
// For key-less fragments, we add a small optimization to avoid serializing
|
1493
|
-
// it as a wrapper.
|
1494
|
-
// TODO: If a key is specified, we should propagate its key to any children.
|
1495
|
-
// Same as if a Server Component has a key.
|
1496
|
-
return props.children;
|
1497
|
-
} // This might be a built-in React component. We'll let the client decide.
|
1498
|
-
// Any built-in works as long as its props are serializable.
|
1467
|
+
str = '<' + (describeElementType(_type) || '...');
|
1468
|
+
var object = objectOrArray;
|
1469
|
+
var names = Object.keys(object);
|
1499
1470
|
|
1471
|
+
for (var _i2 = 0; _i2 < names.length; _i2++) {
|
1472
|
+
str += ' ';
|
1473
|
+
var name = names[_i2];
|
1474
|
+
str += describeKeyForErrorMessage(name) + '=';
|
1475
|
+
var _value2 = object[name];
|
1500
1476
|
|
1501
|
-
|
1502
|
-
} else if (type != null && typeof type === 'object') {
|
1503
|
-
if (isClientReference(type)) {
|
1504
|
-
// This is a reference to a Client Component.
|
1505
|
-
return [REACT_ELEMENT_TYPE, type, key, props];
|
1506
|
-
}
|
1477
|
+
var _substr2 = void 0;
|
1507
1478
|
|
1508
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
var wrappedType = init(payload);
|
1514
|
-
return attemptResolveElement(request, wrappedType, key, ref, props, prevThenableState);
|
1479
|
+
if (name === expandedName && typeof _value2 === 'object' && _value2 !== null) {
|
1480
|
+
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1481
|
+
_substr2 = describeObjectForErrorMessage(_value2);
|
1482
|
+
} else {
|
1483
|
+
_substr2 = describeValueForErrorMessage(_value2);
|
1515
1484
|
}
|
1516
1485
|
|
1517
|
-
|
1518
|
-
|
1519
|
-
var render = type.render;
|
1520
|
-
prepareToUseHooksForComponent(prevThenableState);
|
1521
|
-
return render(props, undefined);
|
1486
|
+
if (typeof _value2 !== 'string') {
|
1487
|
+
_substr2 = '{' + _substr2 + '}';
|
1522
1488
|
}
|
1523
1489
|
|
1524
|
-
|
1525
|
-
|
1526
|
-
|
1490
|
+
if (name === expandedName) {
|
1491
|
+
start = str.length;
|
1492
|
+
length = _substr2.length;
|
1493
|
+
str += _substr2;
|
1494
|
+
} else if (_substr2.length < 10 && str.length + _substr2.length < 40) {
|
1495
|
+
str += _substr2;
|
1496
|
+
} else {
|
1497
|
+
str += '...';
|
1527
1498
|
}
|
1499
|
+
}
|
1528
1500
|
|
1529
|
-
|
1530
|
-
|
1531
|
-
|
1501
|
+
str += '>';
|
1502
|
+
} else {
|
1503
|
+
// Print Object
|
1504
|
+
str = '{';
|
1505
|
+
var _object = objectOrArray;
|
1532
1506
|
|
1533
|
-
|
1534
|
-
var extraKeys = Object.keys(props).filter(function (value) {
|
1535
|
-
if (value === 'children' || value === 'value') {
|
1536
|
-
return false;
|
1537
|
-
}
|
1507
|
+
var _names = Object.keys(_object);
|
1538
1508
|
|
1539
|
-
|
1540
|
-
|
1509
|
+
for (var _i3 = 0; _i3 < _names.length; _i3++) {
|
1510
|
+
if (_i3 > 0) {
|
1511
|
+
str += ', ';
|
1512
|
+
}
|
1541
1513
|
|
1542
|
-
|
1543
|
-
|
1544
|
-
|
1545
|
-
}
|
1514
|
+
var _name = _names[_i3];
|
1515
|
+
str += describeKeyForErrorMessage(_name) + ': ';
|
1516
|
+
var _value3 = _object[_name];
|
1546
1517
|
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1518
|
+
var _substr3 = void 0;
|
1519
|
+
|
1520
|
+
if (typeof _value3 === 'object' && _value3 !== null) {
|
1521
|
+
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1522
|
+
_substr3 = describeObjectForErrorMessage(_value3);
|
1523
|
+
} else {
|
1524
|
+
_substr3 = describeValueForErrorMessage(_value3);
|
1525
|
+
}
|
1526
|
+
|
1527
|
+
if (_name === expandedName) {
|
1528
|
+
start = str.length;
|
1529
|
+
length = _substr3.length;
|
1530
|
+
str += _substr3;
|
1531
|
+
} else if (_substr3.length < 10 && str.length + _substr3.length < 40) {
|
1532
|
+
str += _substr3;
|
1533
|
+
} else {
|
1534
|
+
str += '...';
|
1553
1535
|
}
|
1536
|
+
}
|
1537
|
+
|
1538
|
+
str += '}';
|
1554
1539
|
}
|
1555
1540
|
}
|
1556
1541
|
|
1557
|
-
|
1558
|
-
|
1542
|
+
if (expandedName === undefined) {
|
1543
|
+
return str;
|
1544
|
+
}
|
1559
1545
|
|
1560
|
-
|
1561
|
-
|
1562
|
-
|
1546
|
+
if (start > -1 && length > 0) {
|
1547
|
+
var highlight = ' '.repeat(start) + '^'.repeat(length);
|
1548
|
+
return '\n ' + str + '\n ' + highlight;
|
1549
|
+
}
|
1563
1550
|
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
1567
|
-
|
1551
|
+
return '\n ' + str;
|
1552
|
+
}
|
1553
|
+
|
1554
|
+
var ContextRegistry = ReactSharedInternals.ContextRegistry;
|
1555
|
+
function getOrCreateServerContext(globalName) {
|
1556
|
+
if (!ContextRegistry[globalName]) {
|
1557
|
+
ContextRegistry[globalName] = React.createServerContext(globalName, // $FlowFixMe function signature doesn't reflect the symbol value
|
1558
|
+
REACT_SERVER_CONTEXT_DEFAULT_VALUE_NOT_LOADED);
|
1568
1559
|
}
|
1560
|
+
|
1561
|
+
return ContextRegistry[globalName];
|
1569
1562
|
}
|
1570
1563
|
|
1571
|
-
|
1572
|
-
var id = request.nextChunkId++;
|
1573
|
-
var task = {
|
1574
|
-
id: id,
|
1575
|
-
status: PENDING,
|
1576
|
-
model: model,
|
1577
|
-
context: context,
|
1578
|
-
ping: function () {
|
1579
|
-
return pingTask(request, task);
|
1580
|
-
},
|
1581
|
-
thenableState: null
|
1582
|
-
};
|
1583
|
-
abortSet.add(task);
|
1584
|
-
return task;
|
1585
|
-
}
|
1586
|
-
|
1587
|
-
function serializeByValueID(id) {
|
1588
|
-
return '$' + id.toString(16);
|
1589
|
-
}
|
1590
|
-
|
1591
|
-
function serializeLazyID(id) {
|
1592
|
-
return '$L' + id.toString(16);
|
1593
|
-
}
|
1564
|
+
// Thenable<ReactClientValue>
|
1594
1565
|
|
1595
|
-
|
1596
|
-
|
1597
|
-
|
1566
|
+
var PENDING$1 = 0;
|
1567
|
+
var COMPLETED = 1;
|
1568
|
+
var ABORTED = 3;
|
1569
|
+
var ERRORED$1 = 4;
|
1570
|
+
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
1571
|
+
var ReactCurrentCache = ReactSharedInternals.ReactCurrentCache;
|
1598
1572
|
|
1599
|
-
function
|
1600
|
-
|
1573
|
+
function defaultErrorHandler(error) {
|
1574
|
+
console['error'](error); // Don't transform to our wrapper
|
1601
1575
|
}
|
1602
1576
|
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1577
|
+
var OPEN = 0;
|
1578
|
+
var CLOSING = 1;
|
1579
|
+
var CLOSED = 2;
|
1580
|
+
function createRequest(model, bundlerConfig, onError, context, identifierPrefix) {
|
1581
|
+
if (ReactCurrentCache.current !== null && ReactCurrentCache.current !== DefaultCacheDispatcher) {
|
1582
|
+
throw new Error('Currently React only supports one RSC renderer at a time.');
|
1583
|
+
}
|
1606
1584
|
|
1607
|
-
|
1608
|
-
|
1585
|
+
ReactCurrentCache.current = DefaultCacheDispatcher;
|
1586
|
+
var abortSet = new Set();
|
1587
|
+
var pingedTasks = [];
|
1588
|
+
var request = {
|
1589
|
+
status: OPEN,
|
1590
|
+
fatalError: null,
|
1591
|
+
destination: null,
|
1592
|
+
bundlerConfig: bundlerConfig,
|
1593
|
+
cache: new Map(),
|
1594
|
+
nextChunkId: 0,
|
1595
|
+
pendingChunks: 0,
|
1596
|
+
abortableTasks: abortSet,
|
1597
|
+
pingedTasks: pingedTasks,
|
1598
|
+
completedImportChunks: [],
|
1599
|
+
completedJSONChunks: [],
|
1600
|
+
completedErrorChunks: [],
|
1601
|
+
writtenSymbols: new Map(),
|
1602
|
+
writtenClientReferences: new Map(),
|
1603
|
+
writtenServerReferences: new Map(),
|
1604
|
+
writtenProviders: new Map(),
|
1605
|
+
identifierPrefix: identifierPrefix || '',
|
1606
|
+
identifierCount: 1,
|
1607
|
+
onError: onError === undefined ? defaultErrorHandler : onError,
|
1608
|
+
// $FlowFixMe[missing-this-annot]
|
1609
|
+
toJSON: function (key, value) {
|
1610
|
+
return resolveModelToJSON(request, this, key, value);
|
1611
|
+
}
|
1612
|
+
};
|
1613
|
+
request.pendingChunks++;
|
1614
|
+
var rootContext = createRootContext(context);
|
1615
|
+
var rootTask = createTask(request, model, rootContext, abortSet);
|
1616
|
+
pingedTasks.push(rootTask);
|
1617
|
+
return request;
|
1609
1618
|
}
|
1610
1619
|
|
1611
|
-
function
|
1612
|
-
return
|
1620
|
+
function createRootContext(reqContext) {
|
1621
|
+
return importServerContexts(reqContext);
|
1613
1622
|
}
|
1614
1623
|
|
1615
|
-
|
1616
|
-
var clientReferenceKey = getClientReferenceKey(clientReference);
|
1617
|
-
var writtenClientReferences = request.writtenClientReferences;
|
1618
|
-
var existingId = writtenClientReferences.get(clientReferenceKey);
|
1624
|
+
var POP = {};
|
1619
1625
|
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
// to that by a lazy reference instead of directly since React
|
1624
|
-
// knows how to deal with lazy values. This lets us suspend
|
1625
|
-
// on this component rather than its parent until the code has
|
1626
|
-
// loaded.
|
1627
|
-
return serializeLazyID(existingId);
|
1628
|
-
}
|
1626
|
+
function serializeThenable(request, thenable) {
|
1627
|
+
request.pendingChunks++;
|
1628
|
+
var newTask = createTask(request, null, getActiveContext(), request.abortableTasks);
|
1629
1629
|
|
1630
|
-
|
1631
|
-
|
1630
|
+
switch (thenable.status) {
|
1631
|
+
case 'fulfilled':
|
1632
|
+
{
|
1633
|
+
// We have the resolved value, we can go ahead and schedule it for serialization.
|
1634
|
+
newTask.model = thenable.value;
|
1635
|
+
pingTask(request, newTask);
|
1636
|
+
return newTask.id;
|
1637
|
+
}
|
1632
1638
|
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
emitImportChunk(request, importId, clientReferenceMetadata);
|
1638
|
-
writtenClientReferences.set(clientReferenceKey, importId);
|
1639
|
+
case 'rejected':
|
1640
|
+
{
|
1641
|
+
var x = thenable.reason;
|
1642
|
+
var digest = logRecoverableError(request, x);
|
1639
1643
|
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1643
|
-
|
1644
|
-
// on this component rather than its parent until the code has
|
1645
|
-
// loaded.
|
1646
|
-
return serializeLazyID(importId);
|
1647
|
-
}
|
1644
|
+
{
|
1645
|
+
var _getErrorMessageAndSt = getErrorMessageAndStackDev(x),
|
1646
|
+
message = _getErrorMessageAndSt.message,
|
1647
|
+
stack = _getErrorMessageAndSt.stack;
|
1648
1648
|
|
1649
|
-
|
1650
|
-
|
1651
|
-
request.pendingChunks++;
|
1652
|
-
var errorId = request.nextChunkId++;
|
1653
|
-
var digest = logRecoverableError(request, x);
|
1649
|
+
emitErrorChunkDev(request, newTask.id, digest, message, stack);
|
1650
|
+
}
|
1654
1651
|
|
1655
|
-
|
1656
|
-
|
1657
|
-
message = _getErrorMessageAndSt3.message,
|
1658
|
-
stack = _getErrorMessageAndSt3.stack;
|
1652
|
+
return newTask.id;
|
1653
|
+
}
|
1659
1654
|
|
1660
|
-
|
1661
|
-
|
1655
|
+
default:
|
1656
|
+
{
|
1657
|
+
if (typeof thenable.status === 'string') {
|
1658
|
+
// Only instrument the thenable if the status if not defined. If
|
1659
|
+
// it's defined, but an unknown value, assume it's been instrumented by
|
1660
|
+
// some custom userspace implementation. We treat it as "pending".
|
1661
|
+
break;
|
1662
|
+
}
|
1662
1663
|
|
1663
|
-
|
1664
|
+
var pendingThenable = thenable;
|
1665
|
+
pendingThenable.status = 'pending';
|
1666
|
+
pendingThenable.then(function (fulfilledValue) {
|
1667
|
+
if (thenable.status === 'pending') {
|
1668
|
+
var fulfilledThenable = thenable;
|
1669
|
+
fulfilledThenable.status = 'fulfilled';
|
1670
|
+
fulfilledThenable.value = fulfilledValue;
|
1671
|
+
}
|
1672
|
+
}, function (error) {
|
1673
|
+
if (thenable.status === 'pending') {
|
1674
|
+
var rejectedThenable = thenable;
|
1675
|
+
rejectedThenable.status = 'rejected';
|
1676
|
+
rejectedThenable.reason = error;
|
1677
|
+
}
|
1678
|
+
});
|
1679
|
+
break;
|
1680
|
+
}
|
1664
1681
|
}
|
1665
|
-
}
|
1666
1682
|
|
1667
|
-
function
|
1668
|
-
|
1669
|
-
|
1683
|
+
thenable.then(function (value) {
|
1684
|
+
newTask.model = value;
|
1685
|
+
pingTask(request, newTask);
|
1686
|
+
}, function (reason) {
|
1687
|
+
newTask.status = ERRORED$1; // TODO: We should ideally do this inside performWork so it's scheduled
|
1670
1688
|
|
1671
|
-
|
1672
|
-
return serializeServerReferenceID(existingId);
|
1673
|
-
}
|
1689
|
+
var digest = logRecoverableError(request, reason);
|
1674
1690
|
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
};
|
1680
|
-
request.pendingChunks++;
|
1681
|
-
var metadataId = request.nextChunkId++; // We assume that this object doesn't suspend.
|
1691
|
+
{
|
1692
|
+
var _getErrorMessageAndSt2 = getErrorMessageAndStackDev(reason),
|
1693
|
+
_message = _getErrorMessageAndSt2.message,
|
1694
|
+
_stack = _getErrorMessageAndSt2.stack;
|
1682
1695
|
|
1683
|
-
|
1684
|
-
|
1685
|
-
writtenServerReferences.set(serverReference, metadataId);
|
1686
|
-
return serializeServerReferenceID(metadataId);
|
1687
|
-
}
|
1696
|
+
emitErrorChunkDev(request, newTask.id, digest, _message, _stack);
|
1697
|
+
}
|
1688
1698
|
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
} else {
|
1695
|
-
return value;
|
1696
|
-
}
|
1699
|
+
if (request.destination !== null) {
|
1700
|
+
flushCompletedChunks(request, request.destination);
|
1701
|
+
}
|
1702
|
+
});
|
1703
|
+
return newTask.id;
|
1697
1704
|
}
|
1698
1705
|
|
1699
|
-
function
|
1700
|
-
if (
|
1701
|
-
return
|
1706
|
+
function readThenable(thenable) {
|
1707
|
+
if (thenable.status === 'fulfilled') {
|
1708
|
+
return thenable.value;
|
1709
|
+
} else if (thenable.status === 'rejected') {
|
1710
|
+
throw thenable.reason;
|
1702
1711
|
}
|
1703
1712
|
|
1704
|
-
|
1705
|
-
|
1706
|
-
if (object === ObjectPrototype) {
|
1707
|
-
return true;
|
1708
|
-
} // It might be an object from a different Realm which is
|
1709
|
-
// still just a plain simple object.
|
1713
|
+
throw thenable;
|
1714
|
+
}
|
1710
1715
|
|
1716
|
+
function createLazyWrapperAroundWakeable(wakeable) {
|
1717
|
+
// This is a temporary fork of the `use` implementation until we accept
|
1718
|
+
// promises everywhere.
|
1719
|
+
var thenable = wakeable;
|
1711
1720
|
|
1712
|
-
|
1713
|
-
|
1714
|
-
|
1721
|
+
switch (thenable.status) {
|
1722
|
+
case 'fulfilled':
|
1723
|
+
case 'rejected':
|
1724
|
+
break;
|
1715
1725
|
|
1716
|
-
|
1726
|
+
default:
|
1727
|
+
{
|
1728
|
+
if (typeof thenable.status === 'string') {
|
1729
|
+
// Only instrument the thenable if the status if not defined. If
|
1730
|
+
// it's defined, but an unknown value, assume it's been instrumented by
|
1731
|
+
// some custom userspace implementation. We treat it as "pending".
|
1732
|
+
break;
|
1733
|
+
}
|
1717
1734
|
|
1718
|
-
|
1719
|
-
|
1720
|
-
|
1721
|
-
|
1735
|
+
var pendingThenable = thenable;
|
1736
|
+
pendingThenable.status = 'pending';
|
1737
|
+
pendingThenable.then(function (fulfilledValue) {
|
1738
|
+
if (thenable.status === 'pending') {
|
1739
|
+
var fulfilledThenable = thenable;
|
1740
|
+
fulfilledThenable.status = 'fulfilled';
|
1741
|
+
fulfilledThenable.value = fulfilledValue;
|
1742
|
+
}
|
1743
|
+
}, function (error) {
|
1744
|
+
if (thenable.status === 'pending') {
|
1745
|
+
var rejectedThenable = thenable;
|
1746
|
+
rejectedThenable.status = 'rejected';
|
1747
|
+
rejectedThenable.reason = error;
|
1748
|
+
}
|
1749
|
+
});
|
1750
|
+
break;
|
1751
|
+
}
|
1722
1752
|
}
|
1723
1753
|
|
1724
|
-
|
1754
|
+
var lazyType = {
|
1755
|
+
$$typeof: REACT_LAZY_TYPE,
|
1756
|
+
_payload: thenable,
|
1757
|
+
_init: readThenable
|
1758
|
+
};
|
1759
|
+
return lazyType;
|
1725
1760
|
}
|
1726
1761
|
|
1727
|
-
function
|
1728
|
-
if (
|
1729
|
-
|
1762
|
+
function attemptResolveElement(request, type, key, ref, props, prevThenableState) {
|
1763
|
+
if (ref !== null && ref !== undefined) {
|
1764
|
+
// When the ref moves to the regular props object this will implicitly
|
1765
|
+
// throw for functions. We could probably relax it to a DEV warning for other
|
1766
|
+
// cases.
|
1767
|
+
throw new Error('Refs cannot be used in Server Components, nor passed to Client Components.');
|
1730
1768
|
}
|
1731
1769
|
|
1732
|
-
|
1733
|
-
|
1734
|
-
for (var i = 0; i < names.length; i++) {
|
1735
|
-
var descriptor = Object.getOwnPropertyDescriptor(object, names[i]);
|
1736
|
-
|
1737
|
-
if (!descriptor) {
|
1738
|
-
return false;
|
1739
|
-
}
|
1740
|
-
|
1741
|
-
if (!descriptor.enumerable) {
|
1742
|
-
if ((names[i] === 'key' || names[i] === 'ref') && typeof descriptor.get === 'function') {
|
1743
|
-
// React adds key and ref getters to props objects to issue warnings.
|
1744
|
-
// Those getters will not be transferred to the client, but that's ok,
|
1745
|
-
// so we'll special case them.
|
1746
|
-
continue;
|
1747
|
-
}
|
1770
|
+
{
|
1771
|
+
jsxPropsParents.set(props, type);
|
1748
1772
|
|
1749
|
-
|
1773
|
+
if (typeof props.children === 'object' && props.children !== null) {
|
1774
|
+
jsxChildrenParents.set(props.children, type);
|
1750
1775
|
}
|
1751
1776
|
}
|
1752
1777
|
|
1753
|
-
|
1754
|
-
|
1755
|
-
|
1756
|
-
|
1757
|
-
|
1758
|
-
var name = Object.prototype.toString.call(object);
|
1759
|
-
return name.replace(/^\[object (.*)\]$/, function (m, p0) {
|
1760
|
-
return p0;
|
1761
|
-
});
|
1762
|
-
}
|
1763
|
-
|
1764
|
-
function describeKeyForErrorMessage(key) {
|
1765
|
-
var encodedKey = JSON.stringify(key);
|
1766
|
-
return '"' + key + '"' === encodedKey ? key : encodedKey;
|
1767
|
-
}
|
1768
|
-
|
1769
|
-
function describeValueForErrorMessage(value) {
|
1770
|
-
switch (typeof value) {
|
1771
|
-
case 'string':
|
1772
|
-
{
|
1773
|
-
return JSON.stringify(value.length <= 10 ? value : value.substr(0, 10) + '...');
|
1774
|
-
}
|
1778
|
+
if (typeof type === 'function') {
|
1779
|
+
if (isClientReference(type)) {
|
1780
|
+
// This is a reference to a Client Component.
|
1781
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1782
|
+
} // This is a server-side component.
|
1775
1783
|
|
1776
|
-
case 'object':
|
1777
|
-
{
|
1778
|
-
if (isArray(value)) {
|
1779
|
-
return '[...]';
|
1780
|
-
}
|
1781
1784
|
|
1782
|
-
|
1785
|
+
prepareToUseHooksForComponent(prevThenableState);
|
1786
|
+
var result = type(props);
|
1783
1787
|
|
1784
|
-
|
1785
|
-
|
1786
|
-
|
1788
|
+
if (typeof result === 'object' && result !== null && typeof result.then === 'function') {
|
1789
|
+
// When the return value is in children position we can resolve it immediately,
|
1790
|
+
// to its value without a wrapper if it's synchronously available.
|
1791
|
+
var thenable = result;
|
1787
1792
|
|
1788
|
-
|
1789
|
-
|
1793
|
+
if (thenable.status === 'fulfilled') {
|
1794
|
+
return thenable.value;
|
1795
|
+
} // TODO: Once we accept Promises as children on the client, we can just return
|
1796
|
+
// the thenable here.
|
1790
1797
|
|
1791
|
-
case 'function':
|
1792
|
-
return 'function';
|
1793
1798
|
|
1794
|
-
|
1795
|
-
|
1796
|
-
return String(value);
|
1797
|
-
}
|
1798
|
-
}
|
1799
|
+
return createLazyWrapperAroundWakeable(result);
|
1800
|
+
}
|
1799
1801
|
|
1800
|
-
|
1801
|
-
if (typeof type === 'string') {
|
1802
|
-
|
1803
|
-
|
1802
|
+
return result;
|
1803
|
+
} else if (typeof type === 'string') {
|
1804
|
+
// This is a host element. E.g. HTML.
|
1805
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1806
|
+
} else if (typeof type === 'symbol') {
|
1807
|
+
if (type === REACT_FRAGMENT_TYPE) {
|
1808
|
+
// For key-less fragments, we add a small optimization to avoid serializing
|
1809
|
+
// it as a wrapper.
|
1810
|
+
// TODO: If a key is specified, we should propagate its key to any children.
|
1811
|
+
// Same as if a Server Component has a key.
|
1812
|
+
return props.children;
|
1813
|
+
} // This might be a built-in React component. We'll let the client decide.
|
1814
|
+
// Any built-in works as long as its props are serializable.
|
1804
1815
|
|
1805
|
-
switch (type) {
|
1806
|
-
case REACT_SUSPENSE_TYPE:
|
1807
|
-
return 'Suspense';
|
1808
1816
|
|
1809
|
-
|
1810
|
-
|
1811
|
-
|
1817
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1818
|
+
} else if (type != null && typeof type === 'object') {
|
1819
|
+
if (isClientReference(type)) {
|
1820
|
+
// This is a reference to a Client Component.
|
1821
|
+
return [REACT_ELEMENT_TYPE, type, key, props];
|
1822
|
+
}
|
1812
1823
|
|
1813
|
-
if (typeof type === 'object') {
|
1814
1824
|
switch (type.$$typeof) {
|
1825
|
+
case REACT_LAZY_TYPE:
|
1826
|
+
{
|
1827
|
+
var payload = type._payload;
|
1828
|
+
var init = type._init;
|
1829
|
+
var wrappedType = init(payload);
|
1830
|
+
return attemptResolveElement(request, wrappedType, key, ref, props, prevThenableState);
|
1831
|
+
}
|
1832
|
+
|
1815
1833
|
case REACT_FORWARD_REF_TYPE:
|
1816
|
-
|
1834
|
+
{
|
1835
|
+
var render = type.render;
|
1836
|
+
prepareToUseHooksForComponent(prevThenableState);
|
1837
|
+
return render(props, undefined);
|
1838
|
+
}
|
1817
1839
|
|
1818
1840
|
case REACT_MEMO_TYPE:
|
1819
|
-
|
1841
|
+
{
|
1842
|
+
return attemptResolveElement(request, type.type, key, ref, props, prevThenableState);
|
1843
|
+
}
|
1820
1844
|
|
1821
|
-
case
|
1845
|
+
case REACT_PROVIDER_TYPE:
|
1822
1846
|
{
|
1823
|
-
|
1824
|
-
var payload = lazyComponent._payload;
|
1825
|
-
var init = lazyComponent._init;
|
1847
|
+
pushProvider(type._context, props.value);
|
1826
1848
|
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
|
1849
|
+
{
|
1850
|
+
var extraKeys = Object.keys(props).filter(function (value) {
|
1851
|
+
if (value === 'children' || value === 'value') {
|
1852
|
+
return false;
|
1853
|
+
}
|
1854
|
+
|
1855
|
+
return true;
|
1856
|
+
});
|
1857
|
+
|
1858
|
+
if (extraKeys.length !== 0) {
|
1859
|
+
error('ServerContext can only have a value prop and children. Found: %s', JSON.stringify(extraKeys));
|
1860
|
+
}
|
1861
|
+
}
|
1862
|
+
|
1863
|
+
return [REACT_ELEMENT_TYPE, type, key, // Rely on __popProvider being serialized last to pop the provider.
|
1864
|
+
{
|
1865
|
+
value: props.value,
|
1866
|
+
children: props.children,
|
1867
|
+
__pop: POP
|
1868
|
+
}];
|
1831
1869
|
}
|
1832
1870
|
}
|
1833
1871
|
}
|
1834
1872
|
|
1835
|
-
|
1873
|
+
throw new Error("Unsupported Server Component type: " + describeValueForErrorMessage(type));
|
1836
1874
|
}
|
1837
1875
|
|
1838
|
-
function
|
1839
|
-
var
|
1876
|
+
function pingTask(request, task) {
|
1877
|
+
var pingedTasks = request.pingedTasks;
|
1878
|
+
pingedTasks.push(task);
|
1840
1879
|
|
1841
|
-
if (
|
1842
|
-
|
1880
|
+
if (pingedTasks.length === 1) {
|
1881
|
+
scheduleWork(function () {
|
1882
|
+
return performWork(request);
|
1883
|
+
});
|
1843
1884
|
}
|
1885
|
+
}
|
1844
1886
|
|
1845
|
-
|
1846
|
-
var
|
1847
|
-
var
|
1848
|
-
|
1849
|
-
|
1850
|
-
|
1851
|
-
|
1852
|
-
|
1853
|
-
|
1854
|
-
|
1855
|
-
|
1856
|
-
|
1857
|
-
|
1858
|
-
|
1887
|
+
function createTask(request, model, context, abortSet) {
|
1888
|
+
var id = request.nextChunkId++;
|
1889
|
+
var task = {
|
1890
|
+
id: id,
|
1891
|
+
status: PENDING$1,
|
1892
|
+
model: model,
|
1893
|
+
context: context,
|
1894
|
+
ping: function () {
|
1895
|
+
return pingTask(request, task);
|
1896
|
+
},
|
1897
|
+
thenableState: null
|
1898
|
+
};
|
1899
|
+
abortSet.add(task);
|
1900
|
+
return task;
|
1901
|
+
}
|
1859
1902
|
|
1860
|
-
|
1861
|
-
|
1862
|
-
|
1863
|
-
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1864
|
-
substr = '{' + describeObjectForErrorMessage(value) + '}';
|
1865
|
-
} else {
|
1866
|
-
substr = '{' + describeValueForErrorMessage(value) + '}';
|
1867
|
-
}
|
1903
|
+
function serializeByValueID(id) {
|
1904
|
+
return '$' + id.toString(16);
|
1905
|
+
}
|
1868
1906
|
|
1869
|
-
|
1870
|
-
|
1871
|
-
|
1872
|
-
str += substr;
|
1873
|
-
} else if (substr.length < 15 && str.length + substr.length < 40) {
|
1874
|
-
str += substr;
|
1875
|
-
} else {
|
1876
|
-
str += '{...}';
|
1877
|
-
}
|
1878
|
-
}
|
1907
|
+
function serializeLazyID(id) {
|
1908
|
+
return '$L' + id.toString(16);
|
1909
|
+
}
|
1879
1910
|
|
1880
|
-
|
1881
|
-
|
1882
|
-
|
1883
|
-
str = '[';
|
1884
|
-
var _array = objectOrArray;
|
1911
|
+
function serializePromiseID(id) {
|
1912
|
+
return '$@' + id.toString(16);
|
1913
|
+
}
|
1885
1914
|
|
1886
|
-
|
1887
|
-
|
1888
|
-
|
1889
|
-
}
|
1915
|
+
function serializeServerReferenceID(id) {
|
1916
|
+
return '$F' + id.toString(16);
|
1917
|
+
}
|
1890
1918
|
|
1891
|
-
|
1919
|
+
function serializeSymbolReference(name) {
|
1920
|
+
return '$S' + name;
|
1921
|
+
}
|
1892
1922
|
|
1893
|
-
|
1923
|
+
function serializeProviderReference(name) {
|
1924
|
+
return '$P' + name;
|
1925
|
+
}
|
1894
1926
|
|
1895
|
-
|
1896
|
-
|
1897
|
-
|
1898
|
-
} else {
|
1899
|
-
_substr = describeValueForErrorMessage(_value);
|
1900
|
-
}
|
1927
|
+
function serializeUndefined() {
|
1928
|
+
return '$undefined';
|
1929
|
+
}
|
1901
1930
|
|
1902
|
-
|
1903
|
-
|
1904
|
-
|
1905
|
-
|
1906
|
-
} else if (_substr.length < 10 && str.length + _substr.length < 40) {
|
1907
|
-
str += _substr;
|
1908
|
-
} else {
|
1909
|
-
str += '...';
|
1910
|
-
}
|
1911
|
-
}
|
1931
|
+
function serializeClientReference(request, parent, key, clientReference) {
|
1932
|
+
var clientReferenceKey = getClientReferenceKey(clientReference);
|
1933
|
+
var writtenClientReferences = request.writtenClientReferences;
|
1934
|
+
var existingId = writtenClientReferences.get(clientReferenceKey);
|
1912
1935
|
|
1913
|
-
|
1936
|
+
if (existingId !== undefined) {
|
1937
|
+
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
|
1938
|
+
// If we're encoding the "type" of an element, we can refer
|
1939
|
+
// to that by a lazy reference instead of directly since React
|
1940
|
+
// knows how to deal with lazy values. This lets us suspend
|
1941
|
+
// on this component rather than its parent until the code has
|
1942
|
+
// loaded.
|
1943
|
+
return serializeLazyID(existingId);
|
1914
1944
|
}
|
1915
|
-
} else {
|
1916
|
-
if (objectOrArray.$$typeof === REACT_ELEMENT_TYPE) {
|
1917
|
-
str = '<' + describeElementType(objectOrArray.type) + '/>';
|
1918
|
-
} else if (jsxPropsParents.has(objectOrArray)) {
|
1919
|
-
// Print JSX
|
1920
|
-
var _type = jsxPropsParents.get(objectOrArray);
|
1921
|
-
|
1922
|
-
str = '<' + (describeElementType(_type) || '...');
|
1923
|
-
var object = objectOrArray;
|
1924
|
-
var names = Object.keys(object);
|
1925
|
-
|
1926
|
-
for (var _i2 = 0; _i2 < names.length; _i2++) {
|
1927
|
-
str += ' ';
|
1928
|
-
var name = names[_i2];
|
1929
|
-
str += describeKeyForErrorMessage(name) + '=';
|
1930
|
-
var _value2 = object[name];
|
1931
|
-
|
1932
|
-
var _substr2 = void 0;
|
1933
|
-
|
1934
|
-
if (name === expandedName && typeof _value2 === 'object' && _value2 !== null) {
|
1935
|
-
// $FlowFixMe[incompatible-call] found when upgrading Flow
|
1936
|
-
_substr2 = describeObjectForErrorMessage(_value2);
|
1937
|
-
} else {
|
1938
|
-
_substr2 = describeValueForErrorMessage(_value2);
|
1939
|
-
}
|
1940
|
-
|
1941
|
-
if (typeof _value2 !== 'string') {
|
1942
|
-
_substr2 = '{' + _substr2 + '}';
|
1943
|
-
}
|
1944
1945
|
|
1945
|
-
|
1946
|
-
|
1947
|
-
length = _substr2.length;
|
1948
|
-
str += _substr2;
|
1949
|
-
} else if (_substr2.length < 10 && str.length + _substr2.length < 40) {
|
1950
|
-
str += _substr2;
|
1951
|
-
} else {
|
1952
|
-
str += '...';
|
1953
|
-
}
|
1954
|
-
}
|
1946
|
+
return serializeByValueID(existingId);
|
1947
|
+
}
|
1955
1948
|
|
1956
|
-
|
1957
|
-
|
1958
|
-
|
1959
|
-
|
1960
|
-
|
1949
|
+
try {
|
1950
|
+
var clientReferenceMetadata = resolveClientReferenceMetadata(request.bundlerConfig, clientReference);
|
1951
|
+
request.pendingChunks++;
|
1952
|
+
var importId = request.nextChunkId++;
|
1953
|
+
emitImportChunk(request, importId, clientReferenceMetadata);
|
1954
|
+
writtenClientReferences.set(clientReferenceKey, importId);
|
1961
1955
|
|
1962
|
-
|
1956
|
+
if (parent[0] === REACT_ELEMENT_TYPE && key === '1') {
|
1957
|
+
// If we're encoding the "type" of an element, we can refer
|
1958
|
+
// to that by a lazy reference instead of directly since React
|
1959
|
+
// knows how to deal with lazy values. This lets us suspend
|
1960
|
+
// on this component rather than its parent until the code has
|
1961
|
+
// loaded.
|
1962
|
+
return serializeLazyID(importId);
|
1963
|
+
}
|
1963
1964
|
|
1964
|
-
|
1965
|
-
|
1966
|
-
|
1967
|
-
|
1965
|
+
return serializeByValueID(importId);
|
1966
|
+
} catch (x) {
|
1967
|
+
request.pendingChunks++;
|
1968
|
+
var errorId = request.nextChunkId++;
|
1969
|
+
var digest = logRecoverableError(request, x);
|
1968
1970
|
|
1969
|
-
|
1970
|
-
|
1971
|
-
|
1971
|
+
{
|
1972
|
+
var _getErrorMessageAndSt3 = getErrorMessageAndStackDev(x),
|
1973
|
+
message = _getErrorMessageAndSt3.message,
|
1974
|
+
stack = _getErrorMessageAndSt3.stack;
|
1972
1975
|
|
1973
|
-
|
1976
|
+
emitErrorChunkDev(request, errorId, digest, message, stack);
|
1977
|
+
}
|
1974
1978
|
|
1975
|
-
|
1976
|
-
|
1977
|
-
|
1978
|
-
} else {
|
1979
|
-
_substr3 = describeValueForErrorMessage(_value3);
|
1980
|
-
}
|
1979
|
+
return serializeByValueID(errorId);
|
1980
|
+
}
|
1981
|
+
}
|
1981
1982
|
|
1982
|
-
|
1983
|
-
|
1984
|
-
|
1985
|
-
str += _substr3;
|
1986
|
-
} else if (_substr3.length < 10 && str.length + _substr3.length < 40) {
|
1987
|
-
str += _substr3;
|
1988
|
-
} else {
|
1989
|
-
str += '...';
|
1990
|
-
}
|
1991
|
-
}
|
1983
|
+
function serializeServerReference(request, parent, key, serverReference) {
|
1984
|
+
var writtenServerReferences = request.writtenServerReferences;
|
1985
|
+
var existingId = writtenServerReferences.get(serverReference);
|
1992
1986
|
|
1993
|
-
|
1994
|
-
|
1987
|
+
if (existingId !== undefined) {
|
1988
|
+
return serializeServerReferenceID(existingId);
|
1995
1989
|
}
|
1996
1990
|
|
1997
|
-
|
1998
|
-
|
1999
|
-
|
1991
|
+
var bound = getServerReferenceBoundArguments(request.bundlerConfig, serverReference);
|
1992
|
+
var serverReferenceMetadata = {
|
1993
|
+
id: getServerReferenceId(request.bundlerConfig, serverReference),
|
1994
|
+
bound: bound ? Promise.resolve(bound) : null
|
1995
|
+
};
|
1996
|
+
request.pendingChunks++;
|
1997
|
+
var metadataId = request.nextChunkId++; // We assume that this object doesn't suspend.
|
2000
1998
|
|
2001
|
-
|
2002
|
-
|
2003
|
-
|
2004
|
-
|
1999
|
+
var processedChunk = processModelChunk(request, metadataId, serverReferenceMetadata);
|
2000
|
+
request.completedJSONChunks.push(processedChunk);
|
2001
|
+
writtenServerReferences.set(serverReference, metadataId);
|
2002
|
+
return serializeServerReferenceID(metadataId);
|
2003
|
+
}
|
2005
2004
|
|
2006
|
-
|
2005
|
+
function escapeStringValue(value) {
|
2006
|
+
if (value[0] === '$') {
|
2007
|
+
// We need to escape $ prefixed strings since we use those to encode
|
2008
|
+
// references to IDs and as special symbol values.
|
2009
|
+
return '$' + value;
|
2010
|
+
} else {
|
2011
|
+
return value;
|
2012
|
+
}
|
2007
2013
|
}
|
2008
2014
|
|
2009
2015
|
var insideContextProps = null;
|
@@ -2307,7 +2313,7 @@ function emitProviderChunk(request, id, contextName) {
|
|
2307
2313
|
}
|
2308
2314
|
|
2309
2315
|
function retryTask(request, task) {
|
2310
|
-
if (task.status !== PENDING) {
|
2316
|
+
if (task.status !== PENDING$1) {
|
2311
2317
|
// We completed this by other means before we had a chance to retry it.
|
2312
2318
|
return;
|
2313
2319
|
}
|
@@ -2362,7 +2368,7 @@ function retryTask(request, task) {
|
|
2362
2368
|
return;
|
2363
2369
|
} else {
|
2364
2370
|
request.abortableTasks.delete(task);
|
2365
|
-
task.status = ERRORED;
|
2371
|
+
task.status = ERRORED$1;
|
2366
2372
|
var digest = logRecoverableError(request, x);
|
2367
2373
|
|
2368
2374
|
{
|
@@ -2482,7 +2488,7 @@ function flushCompletedChunks(request, destination) {
|
|
2482
2488
|
|
2483
2489
|
if (request.pendingChunks === 0) {
|
2484
2490
|
// We're done.
|
2485
|
-
close(destination);
|
2491
|
+
close$1(destination);
|
2486
2492
|
}
|
2487
2493
|
}
|
2488
2494
|
|
@@ -2575,6 +2581,515 @@ function importServerContexts(contexts) {
|
|
2575
2581
|
return rootContextSnapshot;
|
2576
2582
|
}
|
2577
2583
|
|
2584
|
+
// eslint-disable-next-line no-unused-vars
|
2585
|
+
function resolveServerReference(bundlerConfig, id) {
|
2586
|
+
// This needs to return async: true if it's an async module.
|
2587
|
+
return bundlerConfig[id];
|
2588
|
+
} // The chunk cache contains all the chunks we've preloaded so far.
|
2589
|
+
// If they're still pending they're a thenable. This map also exists
|
2590
|
+
// in Webpack but unfortunately it's not exposed so we have to
|
2591
|
+
// replicate it in user space. null means that it has already loaded.
|
2592
|
+
|
2593
|
+
var chunkCache = new Map();
|
2594
|
+
var asyncModuleCache = new Map();
|
2595
|
+
|
2596
|
+
function ignoreReject() {// We rely on rejected promises to be handled by another listener.
|
2597
|
+
} // Start preloading the modules since we might need them soon.
|
2598
|
+
// This function doesn't suspend.
|
2599
|
+
|
2600
|
+
|
2601
|
+
function preloadModule(metadata) {
|
2602
|
+
var chunks = metadata.chunks;
|
2603
|
+
var promises = [];
|
2604
|
+
|
2605
|
+
for (var i = 0; i < chunks.length; i++) {
|
2606
|
+
var chunkId = chunks[i];
|
2607
|
+
var entry = chunkCache.get(chunkId);
|
2608
|
+
|
2609
|
+
if (entry === undefined) {
|
2610
|
+
var thenable = __webpack_chunk_load__(chunkId);
|
2611
|
+
|
2612
|
+
promises.push(thenable); // $FlowFixMe[method-unbinding]
|
2613
|
+
|
2614
|
+
var resolve = chunkCache.set.bind(chunkCache, chunkId, null);
|
2615
|
+
thenable.then(resolve, ignoreReject);
|
2616
|
+
chunkCache.set(chunkId, thenable);
|
2617
|
+
} else if (entry !== null) {
|
2618
|
+
promises.push(entry);
|
2619
|
+
}
|
2620
|
+
}
|
2621
|
+
|
2622
|
+
if (metadata.async) {
|
2623
|
+
var existingPromise = asyncModuleCache.get(metadata.id);
|
2624
|
+
|
2625
|
+
if (existingPromise) {
|
2626
|
+
if (existingPromise.status === 'fulfilled') {
|
2627
|
+
return null;
|
2628
|
+
}
|
2629
|
+
|
2630
|
+
return existingPromise;
|
2631
|
+
} else {
|
2632
|
+
var modulePromise = Promise.all(promises).then(function () {
|
2633
|
+
return __webpack_require__(metadata.id);
|
2634
|
+
});
|
2635
|
+
modulePromise.then(function (value) {
|
2636
|
+
var fulfilledThenable = modulePromise;
|
2637
|
+
fulfilledThenable.status = 'fulfilled';
|
2638
|
+
fulfilledThenable.value = value;
|
2639
|
+
}, function (reason) {
|
2640
|
+
var rejectedThenable = modulePromise;
|
2641
|
+
rejectedThenable.status = 'rejected';
|
2642
|
+
rejectedThenable.reason = reason;
|
2643
|
+
});
|
2644
|
+
asyncModuleCache.set(metadata.id, modulePromise);
|
2645
|
+
return modulePromise;
|
2646
|
+
}
|
2647
|
+
} else if (promises.length > 0) {
|
2648
|
+
return Promise.all(promises);
|
2649
|
+
} else {
|
2650
|
+
return null;
|
2651
|
+
}
|
2652
|
+
} // Actually require the module or suspend if it's not yet ready.
|
2653
|
+
// Increase priority if necessary.
|
2654
|
+
|
2655
|
+
function requireModule(metadata) {
|
2656
|
+
var moduleExports;
|
2657
|
+
|
2658
|
+
if (metadata.async) {
|
2659
|
+
// We assume that preloadModule has been called before, which
|
2660
|
+
// should have added something to the module cache.
|
2661
|
+
var promise = asyncModuleCache.get(metadata.id);
|
2662
|
+
|
2663
|
+
if (promise.status === 'fulfilled') {
|
2664
|
+
moduleExports = promise.value;
|
2665
|
+
} else {
|
2666
|
+
throw promise.reason;
|
2667
|
+
}
|
2668
|
+
} else {
|
2669
|
+
moduleExports = __webpack_require__(metadata.id);
|
2670
|
+
}
|
2671
|
+
|
2672
|
+
if (metadata.name === '*') {
|
2673
|
+
// This is a placeholder value that represents that the caller imported this
|
2674
|
+
// as a CommonJS module as is.
|
2675
|
+
return moduleExports;
|
2676
|
+
}
|
2677
|
+
|
2678
|
+
if (metadata.name === '') {
|
2679
|
+
// This is a placeholder value that represents that the caller accessed the
|
2680
|
+
// default property of this if it was an ESM interop module.
|
2681
|
+
return moduleExports.__esModule ? moduleExports.default : moduleExports;
|
2682
|
+
}
|
2683
|
+
|
2684
|
+
return moduleExports[metadata.name];
|
2685
|
+
}
|
2686
|
+
|
2687
|
+
// The server acts as a Client of itself when resolving Server References.
|
2688
|
+
var PENDING = 'pending';
|
2689
|
+
var BLOCKED = 'blocked';
|
2690
|
+
var RESOLVED_MODEL = 'resolved_model';
|
2691
|
+
var INITIALIZED = 'fulfilled';
|
2692
|
+
var ERRORED = 'rejected'; // $FlowFixMe[missing-this-annot]
|
2693
|
+
|
2694
|
+
function Chunk(status, value, reason, response) {
|
2695
|
+
this.status = status;
|
2696
|
+
this.value = value;
|
2697
|
+
this.reason = reason;
|
2698
|
+
this._response = response;
|
2699
|
+
} // We subclass Promise.prototype so that we get other methods like .catch
|
2700
|
+
|
2701
|
+
|
2702
|
+
Chunk.prototype = Object.create(Promise.prototype); // TODO: This doesn't return a new Promise chain unlike the real .then
|
2703
|
+
|
2704
|
+
Chunk.prototype.then = function (resolve, reject) {
|
2705
|
+
var chunk = this; // If we have resolved content, we try to initialize it first which
|
2706
|
+
// might put us back into one of the other states.
|
2707
|
+
|
2708
|
+
switch (chunk.status) {
|
2709
|
+
case RESOLVED_MODEL:
|
2710
|
+
initializeModelChunk(chunk);
|
2711
|
+
break;
|
2712
|
+
} // The status might have changed after initialization.
|
2713
|
+
|
2714
|
+
|
2715
|
+
switch (chunk.status) {
|
2716
|
+
case INITIALIZED:
|
2717
|
+
resolve(chunk.value);
|
2718
|
+
break;
|
2719
|
+
|
2720
|
+
case PENDING:
|
2721
|
+
case BLOCKED:
|
2722
|
+
if (resolve) {
|
2723
|
+
if (chunk.value === null) {
|
2724
|
+
chunk.value = [];
|
2725
|
+
}
|
2726
|
+
|
2727
|
+
chunk.value.push(resolve);
|
2728
|
+
}
|
2729
|
+
|
2730
|
+
if (reject) {
|
2731
|
+
if (chunk.reason === null) {
|
2732
|
+
chunk.reason = [];
|
2733
|
+
}
|
2734
|
+
|
2735
|
+
chunk.reason.push(reject);
|
2736
|
+
}
|
2737
|
+
|
2738
|
+
break;
|
2739
|
+
|
2740
|
+
default:
|
2741
|
+
reject(chunk.reason);
|
2742
|
+
break;
|
2743
|
+
}
|
2744
|
+
};
|
2745
|
+
|
2746
|
+
function getRoot(response) {
|
2747
|
+
var chunk = getChunk(response, 0);
|
2748
|
+
return chunk;
|
2749
|
+
}
|
2750
|
+
|
2751
|
+
function createPendingChunk(response) {
|
2752
|
+
// $FlowFixMe Flow doesn't support functions as constructors
|
2753
|
+
return new Chunk(PENDING, null, null, response);
|
2754
|
+
}
|
2755
|
+
|
2756
|
+
function wakeChunk(listeners, value) {
|
2757
|
+
for (var i = 0; i < listeners.length; i++) {
|
2758
|
+
var listener = listeners[i];
|
2759
|
+
listener(value);
|
2760
|
+
}
|
2761
|
+
}
|
2762
|
+
|
2763
|
+
function wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners) {
|
2764
|
+
switch (chunk.status) {
|
2765
|
+
case INITIALIZED:
|
2766
|
+
wakeChunk(resolveListeners, chunk.value);
|
2767
|
+
break;
|
2768
|
+
|
2769
|
+
case PENDING:
|
2770
|
+
case BLOCKED:
|
2771
|
+
chunk.value = resolveListeners;
|
2772
|
+
chunk.reason = rejectListeners;
|
2773
|
+
break;
|
2774
|
+
|
2775
|
+
case ERRORED:
|
2776
|
+
if (rejectListeners) {
|
2777
|
+
wakeChunk(rejectListeners, chunk.reason);
|
2778
|
+
}
|
2779
|
+
|
2780
|
+
break;
|
2781
|
+
}
|
2782
|
+
}
|
2783
|
+
|
2784
|
+
function triggerErrorOnChunk(chunk, error) {
|
2785
|
+
if (chunk.status !== PENDING && chunk.status !== BLOCKED) {
|
2786
|
+
// We already resolved. We didn't expect to see this.
|
2787
|
+
return;
|
2788
|
+
}
|
2789
|
+
|
2790
|
+
var listeners = chunk.reason;
|
2791
|
+
var erroredChunk = chunk;
|
2792
|
+
erroredChunk.status = ERRORED;
|
2793
|
+
erroredChunk.reason = error;
|
2794
|
+
|
2795
|
+
if (listeners !== null) {
|
2796
|
+
wakeChunk(listeners, error);
|
2797
|
+
}
|
2798
|
+
}
|
2799
|
+
|
2800
|
+
function createResolvedModelChunk(response, value) {
|
2801
|
+
// $FlowFixMe Flow doesn't support functions as constructors
|
2802
|
+
return new Chunk(RESOLVED_MODEL, value, null, response);
|
2803
|
+
}
|
2804
|
+
|
2805
|
+
function resolveModelChunk(chunk, value) {
|
2806
|
+
if (chunk.status !== PENDING) {
|
2807
|
+
// We already resolved. We didn't expect to see this.
|
2808
|
+
return;
|
2809
|
+
}
|
2810
|
+
|
2811
|
+
var resolveListeners = chunk.value;
|
2812
|
+
var rejectListeners = chunk.reason;
|
2813
|
+
var resolvedChunk = chunk;
|
2814
|
+
resolvedChunk.status = RESOLVED_MODEL;
|
2815
|
+
resolvedChunk.value = value;
|
2816
|
+
|
2817
|
+
if (resolveListeners !== null) {
|
2818
|
+
// This is unfortunate that we're reading this eagerly if
|
2819
|
+
// we already have listeners attached since they might no
|
2820
|
+
// longer be rendered or might not be the highest pri.
|
2821
|
+
initializeModelChunk(resolvedChunk); // The status might have changed after initialization.
|
2822
|
+
|
2823
|
+
wakeChunkIfInitialized(chunk, resolveListeners, rejectListeners);
|
2824
|
+
}
|
2825
|
+
}
|
2826
|
+
|
2827
|
+
function bindArgs(fn, args) {
|
2828
|
+
return fn.bind.apply(fn, [null].concat(args));
|
2829
|
+
}
|
2830
|
+
|
2831
|
+
function loadServerReference(response, id, bound, parentChunk, parentObject, key) {
|
2832
|
+
var serverReference = resolveServerReference(response._bundlerConfig, id); // We expect most servers to not really need this because you'd just have all
|
2833
|
+
// the relevant modules already loaded but it allows for lazy loading of code
|
2834
|
+
// if needed.
|
2835
|
+
|
2836
|
+
var preloadPromise = preloadModule(serverReference);
|
2837
|
+
var promise;
|
2838
|
+
|
2839
|
+
if (bound) {
|
2840
|
+
promise = Promise.all([bound, preloadPromise]).then(function (_ref) {
|
2841
|
+
var args = _ref[0];
|
2842
|
+
return bindArgs(requireModule(serverReference), args);
|
2843
|
+
});
|
2844
|
+
} else {
|
2845
|
+
if (preloadPromise) {
|
2846
|
+
promise = Promise.resolve(preloadPromise).then(function () {
|
2847
|
+
return requireModule(serverReference);
|
2848
|
+
});
|
2849
|
+
} else {
|
2850
|
+
// Synchronously available
|
2851
|
+
return requireModule(serverReference);
|
2852
|
+
}
|
2853
|
+
}
|
2854
|
+
|
2855
|
+
promise.then(createModelResolver(parentChunk, parentObject, key), createModelReject(parentChunk)); // We need a placeholder value that will be replaced later.
|
2856
|
+
|
2857
|
+
return null;
|
2858
|
+
}
|
2859
|
+
|
2860
|
+
var initializingChunk = null;
|
2861
|
+
var initializingChunkBlockedModel = null;
|
2862
|
+
|
2863
|
+
function initializeModelChunk(chunk) {
|
2864
|
+
var prevChunk = initializingChunk;
|
2865
|
+
var prevBlocked = initializingChunkBlockedModel;
|
2866
|
+
initializingChunk = chunk;
|
2867
|
+
initializingChunkBlockedModel = null;
|
2868
|
+
|
2869
|
+
try {
|
2870
|
+
var value = JSON.parse(chunk.value, chunk._response._fromJSON);
|
2871
|
+
|
2872
|
+
if (initializingChunkBlockedModel !== null && initializingChunkBlockedModel.deps > 0) {
|
2873
|
+
initializingChunkBlockedModel.value = value; // We discovered new dependencies on modules that are not yet resolved.
|
2874
|
+
// We have to go the BLOCKED state until they're resolved.
|
2875
|
+
|
2876
|
+
var blockedChunk = chunk;
|
2877
|
+
blockedChunk.status = BLOCKED;
|
2878
|
+
blockedChunk.value = null;
|
2879
|
+
blockedChunk.reason = null;
|
2880
|
+
} else {
|
2881
|
+
var initializedChunk = chunk;
|
2882
|
+
initializedChunk.status = INITIALIZED;
|
2883
|
+
initializedChunk.value = value;
|
2884
|
+
}
|
2885
|
+
} catch (error) {
|
2886
|
+
var erroredChunk = chunk;
|
2887
|
+
erroredChunk.status = ERRORED;
|
2888
|
+
erroredChunk.reason = error;
|
2889
|
+
} finally {
|
2890
|
+
initializingChunk = prevChunk;
|
2891
|
+
initializingChunkBlockedModel = prevBlocked;
|
2892
|
+
}
|
2893
|
+
} // Report that any missing chunks in the model is now going to throw this
|
2894
|
+
// error upon read. Also notify any pending promises.
|
2895
|
+
|
2896
|
+
|
2897
|
+
function reportGlobalError(response, error) {
|
2898
|
+
response._chunks.forEach(function (chunk) {
|
2899
|
+
// If this chunk was already resolved or errored, it won't
|
2900
|
+
// trigger an error but if it wasn't then we need to
|
2901
|
+
// because we won't be getting any new data to resolve it.
|
2902
|
+
if (chunk.status === PENDING) {
|
2903
|
+
triggerErrorOnChunk(chunk, error);
|
2904
|
+
}
|
2905
|
+
});
|
2906
|
+
}
|
2907
|
+
|
2908
|
+
function getChunk(response, id) {
|
2909
|
+
var chunks = response._chunks;
|
2910
|
+
var chunk = chunks.get(id);
|
2911
|
+
|
2912
|
+
if (!chunk) {
|
2913
|
+
chunk = createPendingChunk(response);
|
2914
|
+
chunks.set(id, chunk);
|
2915
|
+
}
|
2916
|
+
|
2917
|
+
return chunk;
|
2918
|
+
}
|
2919
|
+
|
2920
|
+
function createModelResolver(chunk, parentObject, key) {
|
2921
|
+
var blocked;
|
2922
|
+
|
2923
|
+
if (initializingChunkBlockedModel) {
|
2924
|
+
blocked = initializingChunkBlockedModel;
|
2925
|
+
blocked.deps++;
|
2926
|
+
} else {
|
2927
|
+
blocked = initializingChunkBlockedModel = {
|
2928
|
+
deps: 1,
|
2929
|
+
value: null
|
2930
|
+
};
|
2931
|
+
}
|
2932
|
+
|
2933
|
+
return function (value) {
|
2934
|
+
parentObject[key] = value;
|
2935
|
+
blocked.deps--;
|
2936
|
+
|
2937
|
+
if (blocked.deps === 0) {
|
2938
|
+
if (chunk.status !== BLOCKED) {
|
2939
|
+
return;
|
2940
|
+
}
|
2941
|
+
|
2942
|
+
var resolveListeners = chunk.value;
|
2943
|
+
var initializedChunk = chunk;
|
2944
|
+
initializedChunk.status = INITIALIZED;
|
2945
|
+
initializedChunk.value = blocked.value;
|
2946
|
+
|
2947
|
+
if (resolveListeners !== null) {
|
2948
|
+
wakeChunk(resolveListeners, blocked.value);
|
2949
|
+
}
|
2950
|
+
}
|
2951
|
+
};
|
2952
|
+
}
|
2953
|
+
|
2954
|
+
function createModelReject(chunk) {
|
2955
|
+
return function (error) {
|
2956
|
+
return triggerErrorOnChunk(chunk, error);
|
2957
|
+
};
|
2958
|
+
}
|
2959
|
+
|
2960
|
+
function parseModelString(response, parentObject, key, value) {
|
2961
|
+
if (value[0] === '$') {
|
2962
|
+
switch (value[1]) {
|
2963
|
+
case '$':
|
2964
|
+
{
|
2965
|
+
// This was an escaped string value.
|
2966
|
+
return value.substring(1);
|
2967
|
+
}
|
2968
|
+
|
2969
|
+
case '@':
|
2970
|
+
{
|
2971
|
+
// Promise
|
2972
|
+
var id = parseInt(value.substring(2), 16);
|
2973
|
+
var chunk = getChunk(response, id);
|
2974
|
+
return chunk;
|
2975
|
+
}
|
2976
|
+
|
2977
|
+
case 'S':
|
2978
|
+
{
|
2979
|
+
// Symbol
|
2980
|
+
return Symbol.for(value.substring(2));
|
2981
|
+
}
|
2982
|
+
|
2983
|
+
case 'F':
|
2984
|
+
{
|
2985
|
+
// Server Reference
|
2986
|
+
var _id = parseInt(value.substring(2), 16);
|
2987
|
+
|
2988
|
+
var _chunk = getChunk(response, _id);
|
2989
|
+
|
2990
|
+
if (_chunk.status === RESOLVED_MODEL) {
|
2991
|
+
initializeModelChunk(_chunk);
|
2992
|
+
}
|
2993
|
+
|
2994
|
+
if (_chunk.status !== INITIALIZED) {
|
2995
|
+
// We know that this is emitted earlier so otherwise it's an error.
|
2996
|
+
throw _chunk.reason;
|
2997
|
+
} // TODO: Just encode this in the reference inline instead of as a model.
|
2998
|
+
|
2999
|
+
|
3000
|
+
var metaData = _chunk.value;
|
3001
|
+
return loadServerReference(response, metaData.id, metaData.bound, initializingChunk, parentObject, key);
|
3002
|
+
}
|
3003
|
+
|
3004
|
+
case 'u':
|
3005
|
+
{
|
3006
|
+
// matches "$undefined"
|
3007
|
+
// Special encoding for `undefined` which can't be serialized as JSON otherwise.
|
3008
|
+
return undefined;
|
3009
|
+
}
|
3010
|
+
|
3011
|
+
default:
|
3012
|
+
{
|
3013
|
+
// We assume that anything else is a reference ID.
|
3014
|
+
var _id2 = parseInt(value.substring(1), 16);
|
3015
|
+
|
3016
|
+
var _chunk2 = getChunk(response, _id2);
|
3017
|
+
|
3018
|
+
switch (_chunk2.status) {
|
3019
|
+
case RESOLVED_MODEL:
|
3020
|
+
initializeModelChunk(_chunk2);
|
3021
|
+
break;
|
3022
|
+
} // The status might have changed after initialization.
|
3023
|
+
|
3024
|
+
|
3025
|
+
switch (_chunk2.status) {
|
3026
|
+
case INITIALIZED:
|
3027
|
+
return _chunk2.value;
|
3028
|
+
|
3029
|
+
case PENDING:
|
3030
|
+
case BLOCKED:
|
3031
|
+
var parentChunk = initializingChunk;
|
3032
|
+
|
3033
|
+
_chunk2.then(createModelResolver(parentChunk, parentObject, key), createModelReject(parentChunk));
|
3034
|
+
|
3035
|
+
return null;
|
3036
|
+
|
3037
|
+
default:
|
3038
|
+
throw _chunk2.reason;
|
3039
|
+
}
|
3040
|
+
}
|
3041
|
+
}
|
3042
|
+
}
|
3043
|
+
|
3044
|
+
return value;
|
3045
|
+
}
|
3046
|
+
|
3047
|
+
function createResponse(bundlerConfig) {
|
3048
|
+
var chunks = new Map();
|
3049
|
+
var response = {
|
3050
|
+
_bundlerConfig: bundlerConfig,
|
3051
|
+
_chunks: chunks,
|
3052
|
+
_fromJSON: function (key, value) {
|
3053
|
+
if (typeof value === 'string') {
|
3054
|
+
// We can't use .bind here because we need the "this" value.
|
3055
|
+
return parseModelString(response, this, key, value);
|
3056
|
+
}
|
3057
|
+
|
3058
|
+
return value;
|
3059
|
+
}
|
3060
|
+
};
|
3061
|
+
return response;
|
3062
|
+
}
|
3063
|
+
function resolveField(response, id, model) {
|
3064
|
+
var chunks = response._chunks;
|
3065
|
+
var chunk = chunks.get(id);
|
3066
|
+
|
3067
|
+
if (!chunk) {
|
3068
|
+
chunks.set(id, createResolvedModelChunk(response, model));
|
3069
|
+
} else {
|
3070
|
+
resolveModelChunk(chunk, model);
|
3071
|
+
}
|
3072
|
+
}
|
3073
|
+
function resolveFile(response, id, file) {
|
3074
|
+
throw new Error('Not implemented.');
|
3075
|
+
}
|
3076
|
+
function resolveFileInfo(response, id, filename, mime) {
|
3077
|
+
throw new Error('Not implemented.');
|
3078
|
+
}
|
3079
|
+
function resolveFileChunk(response, handle, chunk) {
|
3080
|
+
throw new Error('Not implemented.');
|
3081
|
+
}
|
3082
|
+
function resolveFileComplete(response, handle) {
|
3083
|
+
throw new Error('Not implemented.');
|
3084
|
+
}
|
3085
|
+
function close(response) {
|
3086
|
+
// In case there are any remaining unresolved chunks, they won't
|
3087
|
+
// be resolved now. So we need to issue an error to those.
|
3088
|
+
// Ideally we should be able to early bail out if we kept a
|
3089
|
+
// ref count of pending chunks.
|
3090
|
+
reportGlobalError(response, new Error('Connection closed.'));
|
3091
|
+
}
|
3092
|
+
|
2578
3093
|
function createDrainHandler(destination, request) {
|
2579
3094
|
return function () {
|
2580
3095
|
return startFlowing(request, destination);
|
@@ -2602,6 +3117,59 @@ function renderToPipeableStream(model, webpackMap, options) {
|
|
2602
3117
|
};
|
2603
3118
|
}
|
2604
3119
|
|
3120
|
+
function decodeReplyFromBusboy(busboyStream, webpackMap) {
|
3121
|
+
var response = createResponse(webpackMap);
|
3122
|
+
busboyStream.on('field', function (name, value) {
|
3123
|
+
var id = +name;
|
3124
|
+
resolveField(response, id, value);
|
3125
|
+
});
|
3126
|
+
busboyStream.on('file', function (name, value, _ref) {
|
3127
|
+
var encoding = _ref.encoding;
|
3128
|
+
|
3129
|
+
if (encoding.toLowerCase() === 'base64') {
|
3130
|
+
throw new Error("React doesn't accept base64 encoded file uploads because we don't expect " + "form data passed from a browser to ever encode data that way. If that's " + 'the wrong assumption, we can easily fix it.');
|
3131
|
+
}
|
3132
|
+
resolveFileInfo();
|
3133
|
+
value.on('data', function (chunk) {
|
3134
|
+
resolveFileChunk();
|
3135
|
+
});
|
3136
|
+
value.on('end', function () {
|
3137
|
+
resolveFileComplete();
|
3138
|
+
});
|
3139
|
+
});
|
3140
|
+
busboyStream.on('finish', function () {
|
3141
|
+
close(response);
|
3142
|
+
});
|
3143
|
+
busboyStream.on('error', function (err) {
|
3144
|
+
reportGlobalError(response, err);
|
3145
|
+
});
|
3146
|
+
return getRoot(response);
|
3147
|
+
}
|
3148
|
+
|
3149
|
+
function decodeReply(body, webpackMap) {
|
3150
|
+
var response = createResponse(webpackMap);
|
3151
|
+
|
3152
|
+
if (typeof body === 'string') {
|
3153
|
+
resolveField(response, 0, body);
|
3154
|
+
} else {
|
3155
|
+
// $FlowFixMe[prop-missing] Flow doesn't know that forEach exists.
|
3156
|
+
body.forEach(function (value, key) {
|
3157
|
+
var id = +key;
|
3158
|
+
|
3159
|
+
if (typeof value === 'string') {
|
3160
|
+
resolveField(response, id, value);
|
3161
|
+
} else {
|
3162
|
+
resolveFile();
|
3163
|
+
}
|
3164
|
+
});
|
3165
|
+
}
|
3166
|
+
|
3167
|
+
close(response);
|
3168
|
+
return getRoot(response);
|
3169
|
+
}
|
3170
|
+
|
3171
|
+
exports.decodeReply = decodeReply;
|
3172
|
+
exports.decodeReplyFromBusboy = decodeReplyFromBusboy;
|
2605
3173
|
exports.renderToPipeableStream = renderToPipeableStream;
|
2606
3174
|
})();
|
2607
3175
|
}
|