react-server-dom-webpack 19.0.0-rc-a26e3f403e-20240611 → 19.0.0-rc-dfd30974ab-20240613

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.
@@ -539,7 +539,15 @@
539
539
  this.onPostpone =
540
540
  void 0 === onPostpone ? defaultPostponeHandler : onPostpone;
541
541
  this.environmentName =
542
- void 0 === environmentName ? "Server" : environmentName;
542
+ void 0 === environmentName
543
+ ? function () {
544
+ return "Server";
545
+ }
546
+ : "function" !== typeof environmentName
547
+ ? function () {
548
+ return environmentName;
549
+ }
550
+ : environmentName;
543
551
  this.didWarnForKey = null;
544
552
  model = createTask(this, model, null, !1, abortSet);
545
553
  pingedTasks.push(model);
@@ -802,16 +810,14 @@
802
810
  if (null !== prevThenableState)
803
811
  owner = prevThenableState._componentDebugInfo;
804
812
  else {
805
- var componentName = Component.displayName || Component.name || "";
813
+ var componentDebugID = debugID,
814
+ componentName = Component.displayName || Component.name || "",
815
+ componentEnv = request.environmentName();
806
816
  request.pendingChunks++;
807
- var componentDebugID = debugID;
808
- owner = {
809
- name: componentName,
810
- env: request.environmentName,
811
- owner: owner
812
- };
817
+ owner = { name: componentName, env: componentEnv, owner: owner };
813
818
  outlineModel(request, owner);
814
819
  emitDebugChunk(request, componentDebugID, owner);
820
+ task.environmentName = componentEnv;
815
821
  }
816
822
  prepareToUseHooksForComponent(prevThenableState, owner);
817
823
  props = callComponentInDEV(Component, props, owner);
@@ -1097,28 +1103,28 @@
1097
1103
  ? serializeLazyID(JSCompiler_inline_result.id)
1098
1104
  : serializeByValueID(JSCompiler_inline_result.id);
1099
1105
  }
1100
- else if (thrownValue === AbortSigil)
1101
- (originalValue.status = 3),
1102
- (originalValue = request.fatalError),
1103
- (JSCompiler_inline_result = parentPropertyName
1104
- ? serializeLazyID(originalValue)
1105
- : serializeByValueID(originalValue));
1106
- else if (
1107
- ((originalValue.keyPath = prevKeyPath),
1108
- (originalValue.implicitSlot = prevImplicitSlot),
1109
- parentPropertyName)
1110
- )
1111
- request.pendingChunks++,
1112
- (originalValue = request.nextChunkId++),
1113
- (prevKeyPath = logRecoverableError(request, value)),
1114
- emitErrorChunk(request, originalValue, prevKeyPath, value),
1115
- (JSCompiler_inline_result = serializeLazyID(originalValue));
1116
- else throw value;
1106
+ else
1107
+ thrownValue === AbortSigil
1108
+ ? ((originalValue.status = 3),
1109
+ (originalValue = request.fatalError),
1110
+ (JSCompiler_inline_result = parentPropertyName
1111
+ ? serializeLazyID(originalValue)
1112
+ : serializeByValueID(originalValue)))
1113
+ : ((originalValue.keyPath = prevKeyPath),
1114
+ (originalValue.implicitSlot = prevImplicitSlot),
1115
+ request.pendingChunks++,
1116
+ (originalValue = request.nextChunkId++),
1117
+ (prevKeyPath = logRecoverableError(request, value)),
1118
+ emitErrorChunk(request, originalValue, prevKeyPath, value),
1119
+ (JSCompiler_inline_result = parentPropertyName
1120
+ ? serializeLazyID(originalValue)
1121
+ : serializeByValueID(originalValue)));
1117
1122
  }
1118
1123
  return JSCompiler_inline_result;
1119
1124
  },
1120
1125
  thenableState: null
1121
1126
  };
1127
+ task.environmentName = request.environmentName();
1122
1128
  abortSet.add(task);
1123
1129
  return task;
1124
1130
  }
@@ -1272,7 +1278,8 @@
1272
1278
  if ("object" === typeof value) {
1273
1279
  switch (value.$$typeof) {
1274
1280
  case REACT_ELEMENT_TYPE:
1275
- var _writtenObjects = request.writtenObjects;
1281
+ var elementReference = null,
1282
+ _writtenObjects = request.writtenObjects;
1276
1283
  if (null === task.keyPath && !task.implicitSlot) {
1277
1284
  var _existingReference = _writtenObjects.get(value);
1278
1285
  if (void 0 !== _existingReference)
@@ -1282,10 +1289,8 @@
1282
1289
  -1 === parentPropertyName.indexOf(":") &&
1283
1290
  ((parent = _writtenObjects.get(parent)),
1284
1291
  void 0 !== parent &&
1285
- _writtenObjects.set(
1286
- value,
1287
- parent + ":" + parentPropertyName
1288
- ));
1292
+ ((elementReference = parent + ":" + parentPropertyName),
1293
+ _writtenObjects.set(value, elementReference)));
1289
1294
  }
1290
1295
  if ((parentPropertyName = value._debugInfo)) {
1291
1296
  if (null === debugID) return outlineTask(request, task);
@@ -1293,7 +1298,7 @@
1293
1298
  }
1294
1299
  parentPropertyName = value.props;
1295
1300
  parent = parentPropertyName.ref;
1296
- return renderElement(
1301
+ value = renderElement(
1297
1302
  request,
1298
1303
  task,
1299
1304
  value.type,
@@ -1302,6 +1307,12 @@
1302
1307
  parentPropertyName,
1303
1308
  value._owner
1304
1309
  );
1310
+ "object" === typeof value &&
1311
+ null !== value &&
1312
+ null !== elementReference &&
1313
+ (_writtenObjects.has(value) ||
1314
+ _writtenObjects.set(value, elementReference));
1315
+ return value;
1305
1316
  case REACT_LAZY_TYPE:
1306
1317
  task.thenableState = null;
1307
1318
  parentPropertyName = callLazyInitInDEV(value);
@@ -1331,46 +1342,49 @@
1331
1342
  );
1332
1343
  if (
1333
1344
  void 0 !== request.temporaryReferences &&
1334
- ((_writtenObjects = request.temporaryReferences.get(value)),
1335
- void 0 !== _writtenObjects)
1345
+ ((elementReference = request.temporaryReferences.get(value)),
1346
+ void 0 !== elementReference)
1336
1347
  )
1337
- return "$T" + _writtenObjects;
1338
- _writtenObjects = request.writtenObjects;
1339
- _existingReference = _writtenObjects.get(value);
1348
+ return "$T" + elementReference;
1349
+ elementReference = request.writtenObjects;
1350
+ _writtenObjects = elementReference.get(value);
1340
1351
  if ("function" === typeof value.then) {
1341
- if (void 0 !== _existingReference) {
1352
+ if (void 0 !== _writtenObjects) {
1342
1353
  if (null !== task.keyPath || task.implicitSlot)
1343
1354
  return (
1344
1355
  "$@" + serializeThenable(request, task, value).toString(16)
1345
1356
  );
1346
1357
  if (modelRoot === value) modelRoot = null;
1347
- else return _existingReference;
1358
+ else return _writtenObjects;
1348
1359
  }
1349
1360
  request = "$@" + serializeThenable(request, task, value).toString(16);
1350
- _writtenObjects.set(value, request);
1361
+ elementReference.set(value, request);
1351
1362
  return request;
1352
1363
  }
1353
- if (void 0 !== _existingReference)
1364
+ if (void 0 !== _writtenObjects)
1354
1365
  if (modelRoot === value) modelRoot = null;
1355
- else return _existingReference;
1366
+ else return _writtenObjects;
1356
1367
  else if (
1357
1368
  -1 === parentPropertyName.indexOf(":") &&
1358
- ((_existingReference = _writtenObjects.get(parent)),
1359
- void 0 !== _existingReference)
1369
+ ((_writtenObjects = elementReference.get(parent)),
1370
+ void 0 !== _writtenObjects)
1360
1371
  ) {
1361
- var propertyName = parentPropertyName;
1372
+ _existingReference = parentPropertyName;
1362
1373
  if (isArrayImpl(parent) && parent[0] === REACT_ELEMENT_TYPE)
1363
1374
  switch (parentPropertyName) {
1364
1375
  case "1":
1365
- propertyName = "type";
1376
+ _existingReference = "type";
1366
1377
  break;
1367
1378
  case "2":
1368
- propertyName = "key";
1379
+ _existingReference = "key";
1369
1380
  break;
1370
1381
  case "3":
1371
- propertyName = "props";
1382
+ _existingReference = "props";
1372
1383
  }
1373
- _writtenObjects.set(value, _existingReference + ":" + propertyName);
1384
+ elementReference.set(
1385
+ value,
1386
+ _writtenObjects + ":" + _existingReference
1387
+ );
1374
1388
  }
1375
1389
  if (isArrayImpl(value)) return renderFragment(request, task, value);
1376
1390
  if (value instanceof Map) return serializeMap(request, value);
@@ -1405,9 +1419,9 @@
1405
1419
  return serializeTypedArray(request, "V", value);
1406
1420
  if ("function" === typeof Blob && value instanceof Blob)
1407
1421
  return serializeBlob(request, value);
1408
- if ((_writtenObjects = getIteratorFn(value)))
1422
+ if ((elementReference = getIteratorFn(value)))
1409
1423
  return (
1410
- (parentPropertyName = _writtenObjects.call(value)),
1424
+ (parentPropertyName = elementReference.call(value)),
1411
1425
  parentPropertyName === value
1412
1426
  ? "$i" +
1413
1427
  outlineModel(request, Array.from(parentPropertyName)).toString(
@@ -1420,8 +1434,8 @@
1420
1434
  value instanceof ReadableStream
1421
1435
  )
1422
1436
  return serializeReadableStream(request, task, value);
1423
- _writtenObjects = value[ASYNC_ITERATOR];
1424
- if ("function" === typeof _writtenObjects)
1437
+ elementReference = value[ASYNC_ITERATOR];
1438
+ if ("function" === typeof elementReference)
1425
1439
  return (
1426
1440
  null !== task.keyPath
1427
1441
  ? ((value = [
@@ -1432,7 +1446,7 @@
1432
1446
  null
1433
1447
  ]),
1434
1448
  (value = task.implicitSlot ? [value] : value))
1435
- : ((parentPropertyName = _writtenObjects.call(value)),
1449
+ : ((parentPropertyName = elementReference.call(value)),
1436
1450
  (value = serializeAsyncIterable(
1437
1451
  request,
1438
1452
  task,
@@ -1449,6 +1463,16 @@
1449
1463
  throw Error(
1450
1464
  "Only plain objects, and a few built-ins, can be passed to Client Components from Server Components. Classes or null prototypes are not supported."
1451
1465
  );
1466
+ if (
1467
+ "object" === typeof value.task &&
1468
+ null !== value.task &&
1469
+ "function" === typeof value.task.run &&
1470
+ "string" === typeof value.name &&
1471
+ "string" === typeof value.env &&
1472
+ void 0 !== value.owner &&
1473
+ "undefined" === typeof value.stack
1474
+ )
1475
+ return { name: value.name, env: value.env, owner: value.owner };
1452
1476
  if ("Object" !== objectName(value))
1453
1477
  error$jscomp$0(
1454
1478
  "Only plain objects can be passed to Client Components from Server Components. %s objects are not supported.%s",
@@ -1460,14 +1484,14 @@
1460
1484
  request = Object.getOwnPropertyNames(value);
1461
1485
  for (task = 0; task < request.length; task++)
1462
1486
  if (
1463
- ((_writtenObjects = Object.getOwnPropertyDescriptor(
1487
+ ((elementReference = Object.getOwnPropertyDescriptor(
1464
1488
  value,
1465
1489
  request[task]
1466
1490
  )),
1467
- !_writtenObjects ||
1468
- (!_writtenObjects.enumerable &&
1491
+ !elementReference ||
1492
+ (!elementReference.enumerable &&
1469
1493
  (("key" !== request[task] && "ref" !== request[task]) ||
1470
- "function" !== typeof _writtenObjects.get)))
1494
+ "function" !== typeof elementReference.get)))
1471
1495
  ) {
1472
1496
  request = !1;
1473
1497
  break a;
@@ -1564,11 +1588,11 @@
1564
1588
  }
1565
1589
  if ("symbol" === typeof value) {
1566
1590
  task = request.writtenSymbols;
1567
- _writtenObjects = task.get(value);
1568
- if (void 0 !== _writtenObjects)
1569
- return serializeByValueID(_writtenObjects);
1570
- _writtenObjects = value.description;
1571
- if (Symbol.for(_writtenObjects) !== value)
1591
+ elementReference = task.get(value);
1592
+ if (void 0 !== elementReference)
1593
+ return serializeByValueID(elementReference);
1594
+ elementReference = value.description;
1595
+ if (Symbol.for(elementReference) !== value)
1572
1596
  throw Error(
1573
1597
  "Only global symbols received from Symbol.for(...) can be passed to Client Components. The symbol Symbol.for(" +
1574
1598
  (value.description + ") cannot be found among global symbols.") +
@@ -1579,7 +1603,7 @@
1579
1603
  parent = encodeReferenceChunk(
1580
1604
  request,
1581
1605
  parentPropertyName,
1582
- "$S" + _writtenObjects
1606
+ "$S" + elementReference
1583
1607
  );
1584
1608
  request.completedImportChunks.push(parent);
1585
1609
  task.set(value, parentPropertyName);
@@ -1821,7 +1845,10 @@
1821
1845
  }
1822
1846
  function forwardDebugInfo(request, id, debugInfo) {
1823
1847
  for (var i = 0; i < debugInfo.length; i++)
1824
- request.pendingChunks++, emitDebugChunk(request, id, debugInfo[i]);
1848
+ request.pendingChunks++,
1849
+ "string" === typeof debugInfo[i].name &&
1850
+ outlineModel(request, debugInfo[i]),
1851
+ emitDebugChunk(request, id, debugInfo[i]);
1825
1852
  }
1826
1853
  function emitChunk(request, task, value) {
1827
1854
  var id = task.id;
@@ -1874,14 +1901,20 @@
1874
1901
  modelRoot = resolvedModel;
1875
1902
  task.keyPath = null;
1876
1903
  task.implicitSlot = !1;
1877
- if ("object" === typeof resolvedModel && null !== resolvedModel)
1904
+ if ("object" === typeof resolvedModel && null !== resolvedModel) {
1878
1905
  request.writtenObjects.set(
1879
1906
  resolvedModel,
1880
1907
  serializeByValueID(task.id)
1881
- ),
1882
- emitChunk(request, task, resolvedModel);
1883
- else {
1884
- var json = stringify(resolvedModel);
1908
+ );
1909
+ var currentEnv = request.environmentName();
1910
+ currentEnv !== task.environmentName &&
1911
+ emitDebugChunk(request, task.id, { env: currentEnv });
1912
+ emitChunk(request, task, resolvedModel);
1913
+ } else {
1914
+ var json = stringify(resolvedModel),
1915
+ _currentEnv = request.environmentName();
1916
+ _currentEnv !== task.environmentName &&
1917
+ emitDebugChunk(request, task.id, { env: _currentEnv });
1885
1918
  emitModelChunk(request, task.id, json);
1886
1919
  }
1887
1920
  request.abortableTasks.delete(task);
@@ -1165,23 +1165,22 @@ function createTask(request, model, keyPath, implicitSlot, abortSet) {
1165
1165
  ? "$L" + JSCompiler_inline_result.id.toString(16)
1166
1166
  : serializeByValueID(JSCompiler_inline_result.id);
1167
1167
  }
1168
- else if (thrownValue === AbortSigil)
1169
- (task.status = 3),
1170
- (prevKeyPath = request.fatalError),
1171
- (JSCompiler_inline_result = parentPropertyName
1172
- ? "$L" + prevKeyPath.toString(16)
1173
- : serializeByValueID(prevKeyPath));
1174
- else if (
1175
- ((task.keyPath = prevKeyPath),
1176
- (task.implicitSlot = prevImplicitSlot),
1177
- parentPropertyName)
1178
- )
1179
- request.pendingChunks++,
1180
- (prevKeyPath = request.nextChunkId++),
1181
- (prevImplicitSlot = logRecoverableError(request, value)),
1182
- emitErrorChunk(request, prevKeyPath, prevImplicitSlot),
1183
- (JSCompiler_inline_result = "$L" + prevKeyPath.toString(16));
1184
- else throw value;
1168
+ else
1169
+ thrownValue === AbortSigil
1170
+ ? ((task.status = 3),
1171
+ (prevKeyPath = request.fatalError),
1172
+ (JSCompiler_inline_result = parentPropertyName
1173
+ ? "$L" + prevKeyPath.toString(16)
1174
+ : serializeByValueID(prevKeyPath)))
1175
+ : ((task.keyPath = prevKeyPath),
1176
+ (task.implicitSlot = prevImplicitSlot),
1177
+ request.pendingChunks++,
1178
+ (prevKeyPath = request.nextChunkId++),
1179
+ (prevImplicitSlot = logRecoverableError(request, value)),
1180
+ emitErrorChunk(request, prevKeyPath, prevImplicitSlot),
1181
+ (JSCompiler_inline_result = parentPropertyName
1182
+ ? "$L" + prevKeyPath.toString(16)
1183
+ : serializeByValueID(prevKeyPath)));
1185
1184
  }
1186
1185
  return JSCompiler_inline_result;
1187
1186
  },
@@ -1309,7 +1308,8 @@ function renderModelDestructive(
1309
1308
  if ("object" === typeof value) {
1310
1309
  switch (value.$$typeof) {
1311
1310
  case REACT_ELEMENT_TYPE:
1312
- var writtenObjects = request.writtenObjects;
1311
+ var elementReference = null,
1312
+ writtenObjects = request.writtenObjects;
1313
1313
  if (null === task.keyPath && !task.implicitSlot) {
1314
1314
  var existingReference = writtenObjects.get(value);
1315
1315
  if (void 0 !== existingReference)
@@ -1319,11 +1319,12 @@ function renderModelDestructive(
1319
1319
  -1 === parentPropertyName.indexOf(":") &&
1320
1320
  ((parent = writtenObjects.get(parent)),
1321
1321
  void 0 !== parent &&
1322
- writtenObjects.set(value, parent + ":" + parentPropertyName));
1322
+ ((elementReference = parent + ":" + parentPropertyName),
1323
+ writtenObjects.set(value, elementReference)));
1323
1324
  }
1324
1325
  parentPropertyName = value.props;
1325
1326
  parent = parentPropertyName.ref;
1326
- return renderElement(
1327
+ request = renderElement(
1327
1328
  request,
1328
1329
  task,
1329
1330
  value.type,
@@ -1331,6 +1332,12 @@ function renderModelDestructive(
1331
1332
  void 0 !== parent ? parent : null,
1332
1333
  parentPropertyName
1333
1334
  );
1335
+ "object" === typeof request &&
1336
+ null !== request &&
1337
+ null !== elementReference &&
1338
+ (writtenObjects.has(request) ||
1339
+ writtenObjects.set(request, elementReference));
1340
+ return request;
1334
1341
  case REACT_LAZY_TYPE:
1335
1342
  task.thenableState = null;
1336
1343
  parentPropertyName = value._init;
@@ -1351,44 +1358,44 @@ function renderModelDestructive(
1351
1358
  );
1352
1359
  if (
1353
1360
  void 0 !== request.temporaryReferences &&
1354
- ((writtenObjects = request.temporaryReferences.get(value)),
1355
- void 0 !== writtenObjects)
1361
+ ((elementReference = request.temporaryReferences.get(value)),
1362
+ void 0 !== elementReference)
1356
1363
  )
1357
- return "$T" + writtenObjects;
1358
- writtenObjects = request.writtenObjects;
1359
- existingReference = writtenObjects.get(value);
1364
+ return "$T" + elementReference;
1365
+ elementReference = request.writtenObjects;
1366
+ writtenObjects = elementReference.get(value);
1360
1367
  if ("function" === typeof value.then) {
1361
- if (void 0 !== existingReference) {
1368
+ if (void 0 !== writtenObjects) {
1362
1369
  if (null !== task.keyPath || task.implicitSlot)
1363
1370
  return "$@" + serializeThenable(request, task, value).toString(16);
1364
1371
  if (modelRoot === value) modelRoot = null;
1365
- else return existingReference;
1372
+ else return writtenObjects;
1366
1373
  }
1367
1374
  request = "$@" + serializeThenable(request, task, value).toString(16);
1368
- writtenObjects.set(value, request);
1375
+ elementReference.set(value, request);
1369
1376
  return request;
1370
1377
  }
1371
- if (void 0 !== existingReference)
1378
+ if (void 0 !== writtenObjects)
1372
1379
  if (modelRoot === value) modelRoot = null;
1373
- else return existingReference;
1380
+ else return writtenObjects;
1374
1381
  else if (
1375
1382
  -1 === parentPropertyName.indexOf(":") &&
1376
- ((existingReference = writtenObjects.get(parent)),
1377
- void 0 !== existingReference)
1383
+ ((writtenObjects = elementReference.get(parent)),
1384
+ void 0 !== writtenObjects)
1378
1385
  ) {
1379
- var propertyName = parentPropertyName;
1386
+ existingReference = parentPropertyName;
1380
1387
  if (isArrayImpl(parent) && parent[0] === REACT_ELEMENT_TYPE)
1381
1388
  switch (parentPropertyName) {
1382
1389
  case "1":
1383
- propertyName = "type";
1390
+ existingReference = "type";
1384
1391
  break;
1385
1392
  case "2":
1386
- propertyName = "key";
1393
+ existingReference = "key";
1387
1394
  break;
1388
1395
  case "3":
1389
- propertyName = "props";
1396
+ existingReference = "props";
1390
1397
  }
1391
- writtenObjects.set(value, existingReference + ":" + propertyName);
1398
+ elementReference.set(value, writtenObjects + ":" + existingReference);
1392
1399
  }
1393
1400
  if (isArrayImpl(value)) return renderFragment(request, task, value);
1394
1401
  if (value instanceof Map)
@@ -1550,10 +1557,11 @@ function renderModelDestructive(
1550
1557
  }
1551
1558
  if ("symbol" === typeof value) {
1552
1559
  task = request.writtenSymbols;
1553
- writtenObjects = task.get(value);
1554
- if (void 0 !== writtenObjects) return serializeByValueID(writtenObjects);
1555
- writtenObjects = value.description;
1556
- if (Symbol.for(writtenObjects) !== value)
1560
+ elementReference = task.get(value);
1561
+ if (void 0 !== elementReference)
1562
+ return serializeByValueID(elementReference);
1563
+ elementReference = value.description;
1564
+ if (Symbol.for(elementReference) !== value)
1557
1565
  throw Error(
1558
1566
  "Only global symbols received from Symbol.for(...) can be passed to Client Components. The symbol Symbol.for(" +
1559
1567
  (value.description + ") cannot be found among global symbols.") +
@@ -1564,7 +1572,7 @@ function renderModelDestructive(
1564
1572
  parent = encodeReferenceChunk(
1565
1573
  request,
1566
1574
  parentPropertyName,
1567
- "$S" + writtenObjects
1575
+ "$S" + elementReference
1568
1576
  );
1569
1577
  request.completedImportChunks.push(parent);
1570
1578
  task.set(value, parentPropertyName);