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