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