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