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