react-server-dom-webpack 19.0.0-canary-4c12339ce-20240408 → 19.0.0-canary-96c584661-20240412

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.
Files changed (38) hide show
  1. package/cjs/react-server-dom-webpack-client.browser.development.js +115 -100
  2. package/cjs/react-server-dom-webpack-client.browser.production.js +92 -72
  3. package/cjs/react-server-dom-webpack-client.browser.production.min.js +24 -24
  4. package/cjs/react-server-dom-webpack-client.browser.production.min.js.map +1 -1
  5. package/cjs/react-server-dom-webpack-client.edge.development.js +123 -108
  6. package/cjs/react-server-dom-webpack-client.edge.production.js +100 -80
  7. package/cjs/react-server-dom-webpack-client.edge.production.min.js +24 -23
  8. package/cjs/react-server-dom-webpack-client.edge.production.min.js.map +1 -1
  9. package/cjs/react-server-dom-webpack-client.node.development.js +123 -108
  10. package/cjs/react-server-dom-webpack-client.node.production.js +100 -80
  11. package/cjs/react-server-dom-webpack-client.node.production.min.js +23 -22
  12. package/cjs/react-server-dom-webpack-client.node.production.min.js.map +1 -1
  13. package/cjs/react-server-dom-webpack-client.node.unbundled.development.js +123 -108
  14. package/cjs/react-server-dom-webpack-client.node.unbundled.production.js +100 -80
  15. package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js +22 -21
  16. package/cjs/react-server-dom-webpack-client.node.unbundled.production.min.js.map +1 -1
  17. package/cjs/react-server-dom-webpack-node-register.js.map +1 -1
  18. package/cjs/react-server-dom-webpack-server.browser.development.js +75 -39
  19. package/cjs/react-server-dom-webpack-server.browser.production.js +70 -32
  20. package/cjs/react-server-dom-webpack-server.browser.production.min.js +68 -68
  21. package/cjs/react-server-dom-webpack-server.browser.production.min.js.map +1 -1
  22. package/cjs/react-server-dom-webpack-server.edge.development.js +75 -39
  23. package/cjs/react-server-dom-webpack-server.edge.production.js +70 -32
  24. package/cjs/react-server-dom-webpack-server.edge.production.min.js +53 -53
  25. package/cjs/react-server-dom-webpack-server.edge.production.min.js.map +1 -1
  26. package/cjs/react-server-dom-webpack-server.node.development.js +75 -39
  27. package/cjs/react-server-dom-webpack-server.node.production.js +70 -32
  28. package/cjs/react-server-dom-webpack-server.node.production.min.js +56 -56
  29. package/cjs/react-server-dom-webpack-server.node.production.min.js.map +1 -1
  30. package/cjs/react-server-dom-webpack-server.node.unbundled.development.js +75 -39
  31. package/cjs/react-server-dom-webpack-server.node.unbundled.production.js +70 -32
  32. package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js +53 -53
  33. package/cjs/react-server-dom-webpack-server.node.unbundled.production.min.js.map +1 -1
  34. package/package.json +3 -3
  35. package/umd/react-server-dom-webpack-client.browser.development.js +115 -100
  36. package/umd/react-server-dom-webpack-client.browser.production.min.js +24 -24
  37. package/umd/react-server-dom-webpack-server.browser.development.js +75 -39
  38. package/umd/react-server-dom-webpack-server.browser.production.min.js +53 -53
@@ -244,19 +244,21 @@ function loadChunk(chunkId, filename) {
244
244
  return __webpack_chunk_load__(chunkId);
245
245
  }
246
246
 
247
- var ReactDOMSharedInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
247
+ var ReactDOMSharedInternals = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
248
248
 
249
249
  // This client file is in the shared folder because it applies to both SSR and browser contexts.
250
- var ReactDOMCurrentDispatcher = ReactDOMSharedInternals.ReactDOMCurrentDispatcher;
251
250
  function dispatchHint(code, model) {
252
- var dispatcher = ReactDOMCurrentDispatcher.current;
251
+ var dispatcher = ReactDOMSharedInternals.d;
252
+ /* ReactDOMCurrentDispatcher */
253
253
 
254
254
  switch (code) {
255
255
  case 'D':
256
256
  {
257
257
  var refined = refineModel(code, model);
258
258
  var href = refined;
259
- dispatcher.prefetchDNS(href);
259
+ dispatcher.D(
260
+ /* prefetchDNS */
261
+ href);
260
262
  return;
261
263
  }
262
264
 
@@ -266,11 +268,15 @@ function dispatchHint(code, model) {
266
268
 
267
269
  if (typeof _refined === 'string') {
268
270
  var _href = _refined;
269
- dispatcher.preconnect(_href);
271
+ dispatcher.C(
272
+ /* preconnect */
273
+ _href);
270
274
  } else {
271
275
  var _href2 = _refined[0];
272
276
  var crossOrigin = _refined[1];
273
- dispatcher.preconnect(_href2, crossOrigin);
277
+ dispatcher.C(
278
+ /* preconnect */
279
+ _href2, crossOrigin);
274
280
  }
275
281
 
276
282
  return;
@@ -285,9 +291,13 @@ function dispatchHint(code, model) {
285
291
 
286
292
  if (_refined2.length === 3) {
287
293
  var options = _refined2[2];
288
- dispatcher.preload(_href3, as, options);
294
+ dispatcher.L(
295
+ /* preload */
296
+ _href3, as, options);
289
297
  } else {
290
- dispatcher.preload(_href3, as);
298
+ dispatcher.L(
299
+ /* preload */
300
+ _href3, as);
291
301
  }
292
302
 
293
303
  return;
@@ -299,46 +309,58 @@ function dispatchHint(code, model) {
299
309
 
300
310
  if (typeof _refined3 === 'string') {
301
311
  var _href4 = _refined3;
302
- dispatcher.preloadModule(_href4);
312
+ dispatcher.m(
313
+ /* preloadModule */
314
+ _href4);
303
315
  } else {
304
316
  var _href5 = _refined3[0];
305
317
  var _options = _refined3[1];
306
- dispatcher.preloadModule(_href5, _options);
318
+ dispatcher.m(
319
+ /* preloadModule */
320
+ _href5, _options);
307
321
  }
308
322
 
309
323
  return;
310
324
  }
311
325
 
312
- case 'S':
326
+ case 'X':
313
327
  {
314
328
  var _refined4 = refineModel(code, model);
315
329
 
316
330
  if (typeof _refined4 === 'string') {
317
331
  var _href6 = _refined4;
318
- dispatcher.preinitStyle(_href6);
332
+ dispatcher.X(
333
+ /* preinitScript */
334
+ _href6);
319
335
  } else {
320
336
  var _href7 = _refined4[0];
321
- var precedence = _refined4[1] === 0 ? undefined : _refined4[1];
322
-
323
- var _options2 = _refined4.length === 3 ? _refined4[2] : undefined;
324
-
325
- dispatcher.preinitStyle(_href7, precedence, _options2);
337
+ var _options2 = _refined4[1];
338
+ dispatcher.X(
339
+ /* preinitScript */
340
+ _href7, _options2);
326
341
  }
327
342
 
328
343
  return;
329
344
  }
330
345
 
331
- case 'X':
346
+ case 'S':
332
347
  {
333
348
  var _refined5 = refineModel(code, model);
334
349
 
335
350
  if (typeof _refined5 === 'string') {
336
351
  var _href8 = _refined5;
337
- dispatcher.preinitScript(_href8);
352
+ dispatcher.S(
353
+ /* preinitStyle */
354
+ _href8);
338
355
  } else {
339
356
  var _href9 = _refined5[0];
340
- var _options3 = _refined5[1];
341
- dispatcher.preinitScript(_href9, _options3);
357
+ var precedence = _refined5[1] === 0 ? undefined : _refined5[1];
358
+
359
+ var _options3 = _refined5.length === 3 ? _refined5[2] : undefined;
360
+
361
+ dispatcher.S(
362
+ /* preinitStyle */
363
+ _href9, precedence, _options3);
342
364
  }
343
365
 
344
366
  return;
@@ -350,11 +372,15 @@ function dispatchHint(code, model) {
350
372
 
351
373
  if (typeof _refined6 === 'string') {
352
374
  var _href10 = _refined6;
353
- dispatcher.preinitModuleScript(_href10);
375
+ dispatcher.M(
376
+ /* preinitModuleScript */
377
+ _href10);
354
378
  } else {
355
379
  var _href11 = _refined6[0];
356
380
  var _options4 = _refined6[1];
357
- dispatcher.preinitModuleScript(_href11, _options4);
381
+ dispatcher.M(
382
+ /* preinitModuleScript */
383
+ _href11, _options4);
358
384
  }
359
385
 
360
386
  return;
@@ -367,7 +393,7 @@ function refineModel(code, model) {
367
393
  return model;
368
394
  }
369
395
 
370
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
396
+ var ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
371
397
 
372
398
  function error(format) {
373
399
  {
@@ -385,8 +411,7 @@ function printWarning(level, format, args) {
385
411
  // When changing this logic, you might want to also
386
412
  // update consoleWithStackDev.www.js as well.
387
413
  {
388
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
389
- var stack = ReactDebugCurrentFrame.getStackAddendum();
414
+ var stack = ReactSharedInternals.getStackAddendum();
390
415
 
391
416
  if (stack !== '') {
392
417
  format += '%s';
@@ -1574,7 +1599,7 @@ function getChunk(response, id) {
1574
1599
  return chunk;
1575
1600
  }
1576
1601
 
1577
- function createModelResolver(chunk, parentObject, key, cyclic) {
1602
+ function createModelResolver(chunk, parentObject, key, cyclic, response, map) {
1578
1603
  var blocked;
1579
1604
 
1580
1605
  if (initializingChunkBlockedModel) {
@@ -1591,11 +1616,11 @@ function createModelResolver(chunk, parentObject, key, cyclic) {
1591
1616
  }
1592
1617
 
1593
1618
  return function (value) {
1594
- parentObject[key] = value; // If this is the root object for a model reference, where `blocked.value`
1619
+ parentObject[key] = map(response, value); // If this is the root object for a model reference, where `blocked.value`
1595
1620
  // is a stale `null`, the resolved value can be used directly.
1596
1621
 
1597
1622
  if (key === '' && blocked.value === null) {
1598
- blocked.value = value;
1623
+ blocked.value = parentObject[key];
1599
1624
  }
1600
1625
 
1601
1626
  blocked.deps--;
@@ -1651,28 +1676,80 @@ function createServerReferenceProxy(response, metaData) {
1651
1676
  return proxy;
1652
1677
  }
1653
1678
 
1654
- function getOutlinedModel(response, id) {
1679
+ function getOutlinedModel(response, id, parentObject, key, map) {
1655
1680
  var chunk = getChunk(response, id);
1656
1681
 
1657
1682
  switch (chunk.status) {
1658
1683
  case RESOLVED_MODEL:
1659
1684
  initializeModelChunk(chunk);
1660
1685
  break;
1686
+
1687
+ case RESOLVED_MODULE:
1688
+ initializeModuleChunk(chunk);
1689
+ break;
1661
1690
  } // The status might have changed after initialization.
1662
1691
 
1663
1692
 
1664
1693
  switch (chunk.status) {
1665
1694
  case INITIALIZED:
1666
- {
1667
- return chunk.value;
1695
+ var chunkValue = map(response, chunk.value);
1696
+
1697
+ if (chunk._debugInfo) {
1698
+ // If we have a direct reference to an object that was rendered by a synchronous
1699
+ // server component, it might have some debug info about how it was rendered.
1700
+ // We forward this to the underlying object. This might be a React Element or
1701
+ // an Array fragment.
1702
+ // If this was a string / number return value we lose the debug info. We choose
1703
+ // that tradeoff to allow sync server components to return plain values and not
1704
+ // use them as React Nodes necessarily. We could otherwise wrap them in a Lazy.
1705
+ if (typeof chunkValue === 'object' && chunkValue !== null && (Array.isArray(chunkValue) || chunkValue.$$typeof === REACT_ELEMENT_TYPE) && !chunkValue._debugInfo) {
1706
+ // We should maybe use a unique symbol for arrays but this is a React owned array.
1707
+ // $FlowFixMe[prop-missing]: This should be added to elements.
1708
+ Object.defineProperty(chunkValue, '_debugInfo', {
1709
+ configurable: false,
1710
+ enumerable: false,
1711
+ writable: true,
1712
+ value: chunk._debugInfo
1713
+ });
1714
+ }
1668
1715
  }
1669
- // We always encode it first in the stream so it won't be pending.
1716
+
1717
+ return chunkValue;
1718
+
1719
+ case PENDING:
1720
+ case BLOCKED:
1721
+ case CYCLIC:
1722
+ var parentChunk = initializingChunk;
1723
+ chunk.then(createModelResolver(parentChunk, parentObject, key, chunk.status === CYCLIC, response, map), createModelReject(parentChunk));
1724
+ return null;
1670
1725
 
1671
1726
  default:
1672
1727
  throw chunk.reason;
1673
1728
  }
1674
1729
  }
1675
1730
 
1731
+ function createMap(response, model) {
1732
+ return new Map(model);
1733
+ }
1734
+
1735
+ function createSet(response, model) {
1736
+ return new Set(model);
1737
+ }
1738
+
1739
+ function createFormData(response, model) {
1740
+ var formData = new FormData();
1741
+
1742
+ for (var i = 0; i < model.length; i++) {
1743
+ formData.append(model[i][0], model[i][1]);
1744
+ }
1745
+
1746
+ return formData;
1747
+ }
1748
+
1749
+ function createModel(response, model) {
1750
+ return model;
1751
+ }
1752
+
1676
1753
  function parseModelString(response, parentObject, key, value) {
1677
1754
  if (value[0] === '$') {
1678
1755
  if (value === '$') {
@@ -1723,8 +1800,7 @@ function parseModelString(response, parentObject, key, value) {
1723
1800
  // Server Reference
1724
1801
  var _id2 = parseInt(value.slice(2), 16);
1725
1802
 
1726
- var metadata = getOutlinedModel(response, _id2);
1727
- return createServerReferenceProxy(response, metadata);
1803
+ return getOutlinedModel(response, _id2, parentObject, key, createServerReferenceProxy);
1728
1804
  }
1729
1805
 
1730
1806
  case 'T':
@@ -1746,8 +1822,7 @@ function parseModelString(response, parentObject, key, value) {
1746
1822
  // Map
1747
1823
  var _id4 = parseInt(value.slice(2), 16);
1748
1824
 
1749
- var data = getOutlinedModel(response, _id4);
1750
- return new Map(data);
1825
+ return getOutlinedModel(response, _id4, parentObject, key, createMap);
1751
1826
  }
1752
1827
 
1753
1828
  case 'W':
@@ -1755,9 +1830,7 @@ function parseModelString(response, parentObject, key, value) {
1755
1830
  // Set
1756
1831
  var _id5 = parseInt(value.slice(2), 16);
1757
1832
 
1758
- var _data = getOutlinedModel(response, _id5);
1759
-
1760
- return new Set(_data);
1833
+ return getOutlinedModel(response, _id5, parentObject, key, createSet);
1761
1834
  }
1762
1835
 
1763
1836
  case 'B':
@@ -1771,15 +1844,7 @@ function parseModelString(response, parentObject, key, value) {
1771
1844
  // FormData
1772
1845
  var _id7 = parseInt(value.slice(2), 16);
1773
1846
 
1774
- var _data3 = getOutlinedModel(response, _id7);
1775
-
1776
- var formData = new FormData();
1777
-
1778
- for (var i = 0; i < _data3.length; i++) {
1779
- formData.append(_data3[i][0], _data3[i][1]);
1780
- }
1781
-
1782
- return formData;
1847
+ return getOutlinedModel(response, _id7, parentObject, key, createFormData);
1783
1848
  }
1784
1849
 
1785
1850
  case 'I':
@@ -1845,57 +1910,7 @@ function parseModelString(response, parentObject, key, value) {
1845
1910
  // We assume that anything else is a reference ID.
1846
1911
  var _id8 = parseInt(value.slice(1), 16);
1847
1912
 
1848
- var _chunk2 = getChunk(response, _id8);
1849
-
1850
- switch (_chunk2.status) {
1851
- case RESOLVED_MODEL:
1852
- initializeModelChunk(_chunk2);
1853
- break;
1854
-
1855
- case RESOLVED_MODULE:
1856
- initializeModuleChunk(_chunk2);
1857
- break;
1858
- } // The status might have changed after initialization.
1859
-
1860
-
1861
- switch (_chunk2.status) {
1862
- case INITIALIZED:
1863
- var chunkValue = _chunk2.value;
1864
-
1865
- if (_chunk2._debugInfo) {
1866
- // If we have a direct reference to an object that was rendered by a synchronous
1867
- // server component, it might have some debug info about how it was rendered.
1868
- // We forward this to the underlying object. This might be a React Element or
1869
- // an Array fragment.
1870
- // If this was a string / number return value we lose the debug info. We choose
1871
- // that tradeoff to allow sync server components to return plain values and not
1872
- // use them as React Nodes necessarily. We could otherwise wrap them in a Lazy.
1873
- if (typeof chunkValue === 'object' && chunkValue !== null && (Array.isArray(chunkValue) || chunkValue.$$typeof === REACT_ELEMENT_TYPE) && !chunkValue._debugInfo) {
1874
- // We should maybe use a unique symbol for arrays but this is a React owned array.
1875
- // $FlowFixMe[prop-missing]: This should be added to elements.
1876
- Object.defineProperty(chunkValue, '_debugInfo', {
1877
- configurable: false,
1878
- enumerable: false,
1879
- writable: true,
1880
- value: _chunk2._debugInfo
1881
- });
1882
- }
1883
- }
1884
-
1885
- return chunkValue;
1886
-
1887
- case PENDING:
1888
- case BLOCKED:
1889
- case CYCLIC:
1890
- var parentChunk = initializingChunk;
1891
-
1892
- _chunk2.then(createModelResolver(parentChunk, parentObject, key, _chunk2.status === CYCLIC), createModelReject(parentChunk));
1893
-
1894
- return null;
1895
-
1896
- default:
1897
- throw _chunk2.reason;
1898
- }
1913
+ return getOutlinedModel(response, _id8, parentObject, key, createModel);
1899
1914
  }
1900
1915
  }
1901
1916
  }
@@ -197,19 +197,21 @@ function loadChunk(chunkId, filename) {
197
197
  return __webpack_chunk_load__(chunkId);
198
198
  }
199
199
 
200
- const ReactDOMSharedInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
200
+ const ReactDOMSharedInternals = ReactDOM.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;
201
201
 
202
202
  // This client file is in the shared folder because it applies to both SSR and browser contexts.
203
- const ReactDOMCurrentDispatcher = ReactDOMSharedInternals.ReactDOMCurrentDispatcher;
204
203
  function dispatchHint(code, model) {
205
- const dispatcher = ReactDOMCurrentDispatcher.current;
204
+ const dispatcher = ReactDOMSharedInternals.d;
205
+ /* ReactDOMCurrentDispatcher */
206
206
 
207
207
  switch (code) {
208
208
  case 'D':
209
209
  {
210
210
  const refined = refineModel(code, model);
211
211
  const href = refined;
212
- dispatcher.prefetchDNS(href);
212
+ dispatcher.D(
213
+ /* prefetchDNS */
214
+ href);
213
215
  return;
214
216
  }
215
217
 
@@ -219,11 +221,15 @@ function dispatchHint(code, model) {
219
221
 
220
222
  if (typeof refined === 'string') {
221
223
  const href = refined;
222
- dispatcher.preconnect(href);
224
+ dispatcher.C(
225
+ /* preconnect */
226
+ href);
223
227
  } else {
224
228
  const href = refined[0];
225
229
  const crossOrigin = refined[1];
226
- dispatcher.preconnect(href, crossOrigin);
230
+ dispatcher.C(
231
+ /* preconnect */
232
+ href, crossOrigin);
227
233
  }
228
234
 
229
235
  return;
@@ -237,9 +243,13 @@ function dispatchHint(code, model) {
237
243
 
238
244
  if (refined.length === 3) {
239
245
  const options = refined[2];
240
- dispatcher.preload(href, as, options);
246
+ dispatcher.L(
247
+ /* preload */
248
+ href, as, options);
241
249
  } else {
242
- dispatcher.preload(href, as);
250
+ dispatcher.L(
251
+ /* preload */
252
+ href, as);
243
253
  }
244
254
 
245
255
  return;
@@ -251,44 +261,56 @@ function dispatchHint(code, model) {
251
261
 
252
262
  if (typeof refined === 'string') {
253
263
  const href = refined;
254
- dispatcher.preloadModule(href);
264
+ dispatcher.m(
265
+ /* preloadModule */
266
+ href);
255
267
  } else {
256
268
  const href = refined[0];
257
269
  const options = refined[1];
258
- dispatcher.preloadModule(href, options);
270
+ dispatcher.m(
271
+ /* preloadModule */
272
+ href, options);
259
273
  }
260
274
 
261
275
  return;
262
276
  }
263
277
 
264
- case 'S':
278
+ case 'X':
265
279
  {
266
280
  const refined = refineModel(code, model);
267
281
 
268
282
  if (typeof refined === 'string') {
269
283
  const href = refined;
270
- dispatcher.preinitStyle(href);
284
+ dispatcher.X(
285
+ /* preinitScript */
286
+ href);
271
287
  } else {
272
288
  const href = refined[0];
273
- const precedence = refined[1] === 0 ? undefined : refined[1];
274
- const options = refined.length === 3 ? refined[2] : undefined;
275
- dispatcher.preinitStyle(href, precedence, options);
289
+ const options = refined[1];
290
+ dispatcher.X(
291
+ /* preinitScript */
292
+ href, options);
276
293
  }
277
294
 
278
295
  return;
279
296
  }
280
297
 
281
- case 'X':
298
+ case 'S':
282
299
  {
283
300
  const refined = refineModel(code, model);
284
301
 
285
302
  if (typeof refined === 'string') {
286
303
  const href = refined;
287
- dispatcher.preinitScript(href);
304
+ dispatcher.S(
305
+ /* preinitStyle */
306
+ href);
288
307
  } else {
289
308
  const href = refined[0];
290
- const options = refined[1];
291
- dispatcher.preinitScript(href, options);
309
+ const precedence = refined[1] === 0 ? undefined : refined[1];
310
+ const options = refined.length === 3 ? refined[2] : undefined;
311
+ dispatcher.S(
312
+ /* preinitStyle */
313
+ href, precedence, options);
292
314
  }
293
315
 
294
316
  return;
@@ -300,11 +322,15 @@ function dispatchHint(code, model) {
300
322
 
301
323
  if (typeof refined === 'string') {
302
324
  const href = refined;
303
- dispatcher.preinitModuleScript(href);
325
+ dispatcher.M(
326
+ /* preinitModuleScript */
327
+ href);
304
328
  } else {
305
329
  const href = refined[0];
306
330
  const options = refined[1];
307
- dispatcher.preinitModuleScript(href, options);
331
+ dispatcher.M(
332
+ /* preinitModuleScript */
333
+ href, options);
308
334
  }
309
335
 
310
336
  return;
@@ -1071,7 +1097,7 @@ function getChunk(response, id) {
1071
1097
  return chunk;
1072
1098
  }
1073
1099
 
1074
- function createModelResolver(chunk, parentObject, key, cyclic) {
1100
+ function createModelResolver(chunk, parentObject, key, cyclic, response, map) {
1075
1101
  let blocked;
1076
1102
 
1077
1103
  if (initializingChunkBlockedModel) {
@@ -1088,11 +1114,11 @@ function createModelResolver(chunk, parentObject, key, cyclic) {
1088
1114
  }
1089
1115
 
1090
1116
  return value => {
1091
- parentObject[key] = value; // If this is the root object for a model reference, where `blocked.value`
1117
+ parentObject[key] = map(response, value); // If this is the root object for a model reference, where `blocked.value`
1092
1118
  // is a stale `null`, the resolved value can be used directly.
1093
1119
 
1094
1120
  if (key === '' && blocked.value === null) {
1095
- blocked.value = value;
1121
+ blocked.value = parentObject[key];
1096
1122
  }
1097
1123
 
1098
1124
  blocked.deps--;
@@ -1146,28 +1172,60 @@ function createServerReferenceProxy(response, metaData) {
1146
1172
  return proxy;
1147
1173
  }
1148
1174
 
1149
- function getOutlinedModel(response, id) {
1175
+ function getOutlinedModel(response, id, parentObject, key, map) {
1150
1176
  const chunk = getChunk(response, id);
1151
1177
 
1152
1178
  switch (chunk.status) {
1153
1179
  case RESOLVED_MODEL:
1154
1180
  initializeModelChunk(chunk);
1155
1181
  break;
1182
+
1183
+ case RESOLVED_MODULE:
1184
+ initializeModuleChunk(chunk);
1185
+ break;
1156
1186
  } // The status might have changed after initialization.
1157
1187
 
1158
1188
 
1159
1189
  switch (chunk.status) {
1160
1190
  case INITIALIZED:
1161
- {
1162
- return chunk.value;
1163
- }
1164
- // We always encode it first in the stream so it won't be pending.
1191
+ const chunkValue = map(response, chunk.value);
1192
+
1193
+ return chunkValue;
1194
+
1195
+ case PENDING:
1196
+ case BLOCKED:
1197
+ case CYCLIC:
1198
+ const parentChunk = initializingChunk;
1199
+ chunk.then(createModelResolver(parentChunk, parentObject, key, chunk.status === CYCLIC, response, map), createModelReject(parentChunk));
1200
+ return null;
1165
1201
 
1166
1202
  default:
1167
1203
  throw chunk.reason;
1168
1204
  }
1169
1205
  }
1170
1206
 
1207
+ function createMap(response, model) {
1208
+ return new Map(model);
1209
+ }
1210
+
1211
+ function createSet(response, model) {
1212
+ return new Set(model);
1213
+ }
1214
+
1215
+ function createFormData(response, model) {
1216
+ const formData = new FormData();
1217
+
1218
+ for (let i = 0; i < model.length; i++) {
1219
+ formData.append(model[i][0], model[i][1]);
1220
+ }
1221
+
1222
+ return formData;
1223
+ }
1224
+
1225
+ function createModel(response, model) {
1226
+ return model;
1227
+ }
1228
+
1171
1229
  function parseModelString(response, parentObject, key, value) {
1172
1230
  if (value[0] === '$') {
1173
1231
  if (value === '$') {
@@ -1215,8 +1273,7 @@ function parseModelString(response, parentObject, key, value) {
1215
1273
  {
1216
1274
  // Server Reference
1217
1275
  const id = parseInt(value.slice(2), 16);
1218
- const metadata = getOutlinedModel(response, id);
1219
- return createServerReferenceProxy(response, metadata);
1276
+ return getOutlinedModel(response, id, parentObject, key, createServerReferenceProxy);
1220
1277
  }
1221
1278
 
1222
1279
  case 'T':
@@ -1236,16 +1293,14 @@ function parseModelString(response, parentObject, key, value) {
1236
1293
  {
1237
1294
  // Map
1238
1295
  const id = parseInt(value.slice(2), 16);
1239
- const data = getOutlinedModel(response, id);
1240
- return new Map(data);
1296
+ return getOutlinedModel(response, id, parentObject, key, createMap);
1241
1297
  }
1242
1298
 
1243
1299
  case 'W':
1244
1300
  {
1245
1301
  // Set
1246
1302
  const id = parseInt(value.slice(2), 16);
1247
- const data = getOutlinedModel(response, id);
1248
- return new Set(data);
1303
+ return getOutlinedModel(response, id, parentObject, key, createSet);
1249
1304
  }
1250
1305
 
1251
1306
  case 'B':
@@ -1258,14 +1313,7 @@ function parseModelString(response, parentObject, key, value) {
1258
1313
  {
1259
1314
  // FormData
1260
1315
  const id = parseInt(value.slice(2), 16);
1261
- const data = getOutlinedModel(response, id);
1262
- const formData = new FormData();
1263
-
1264
- for (let i = 0; i < data.length; i++) {
1265
- formData.append(data[i][0], data[i][1]);
1266
- }
1267
-
1268
- return formData;
1316
+ return getOutlinedModel(response, id, parentObject, key, createFormData);
1269
1317
  }
1270
1318
 
1271
1319
  case 'I':
@@ -1315,35 +1363,7 @@ function parseModelString(response, parentObject, key, value) {
1315
1363
  {
1316
1364
  // We assume that anything else is a reference ID.
1317
1365
  const id = parseInt(value.slice(1), 16);
1318
- const chunk = getChunk(response, id);
1319
-
1320
- switch (chunk.status) {
1321
- case RESOLVED_MODEL:
1322
- initializeModelChunk(chunk);
1323
- break;
1324
-
1325
- case RESOLVED_MODULE:
1326
- initializeModuleChunk(chunk);
1327
- break;
1328
- } // The status might have changed after initialization.
1329
-
1330
-
1331
- switch (chunk.status) {
1332
- case INITIALIZED:
1333
- const chunkValue = chunk.value;
1334
-
1335
- return chunkValue;
1336
-
1337
- case PENDING:
1338
- case BLOCKED:
1339
- case CYCLIC:
1340
- const parentChunk = initializingChunk;
1341
- chunk.then(createModelResolver(parentChunk, parentObject, key, chunk.status === CYCLIC), createModelReject(parentChunk));
1342
- return null;
1343
-
1344
- default:
1345
- throw chunk.reason;
1346
- }
1366
+ return getOutlinedModel(response, id, parentObject, key, createModel);
1347
1367
  }
1348
1368
  }
1349
1369
  }