react-server-dom-parcel 0.0.0 → 0.0.1

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.
@@ -22,8 +22,8 @@
22
22
  }
23
23
  function preloadModule$1(metadata) {
24
24
  return Promise.all(
25
- metadata.bundles.map(function (bundlePath) {
26
- return import(parcelRequire.meta.distDir + "/" + bundlePath);
25
+ metadata.bundles.map(function (url) {
26
+ return parcelRequire.load(url);
27
27
  })
28
28
  );
29
29
  }
@@ -231,14 +231,6 @@
231
231
  suspendedThenable = null;
232
232
  return thenable;
233
233
  }
234
- function prepareToUseHooksForComponent(
235
- prevThenableState,
236
- componentDebugInfo
237
- ) {
238
- thenableIndexCounter = 0;
239
- thenableState = prevThenableState;
240
- currentComponentDebugInfo = componentDebugInfo;
241
- }
242
234
  function getThenableStateAfterSuspending() {
243
235
  var state = thenableState || [];
244
236
  state._componentDebugInfo = currentComponentDebugInfo;
@@ -498,9 +490,8 @@
498
490
  1
499
491
  );
500
492
  request.pendingChunks++;
501
- var id = request.nextChunkId++,
502
- owner = resolveOwner();
503
- emitConsoleChunk(request, id, methodName, owner, stack, arguments);
493
+ var owner = resolveOwner();
494
+ emitConsoleChunk(request, methodName, owner, stack, arguments);
504
495
  }
505
496
  return originalMethod.apply(this, arguments);
506
497
  };
@@ -805,9 +796,7 @@
805
796
  }
806
797
  function emitHint(request, code, model) {
807
798
  model = stringify(model);
808
- var id = request.nextChunkId++;
809
- code = serializeRowHeader("H" + code, id) + model + "\n";
810
- code = stringToChunk(code);
799
+ code = stringToChunk(":H" + code + model + "\n");
811
800
  request.completedHintChunks.push(code);
812
801
  enqueueFlush(request);
813
802
  }
@@ -857,6 +846,71 @@
857
846
  currentOwner = null;
858
847
  }
859
848
  }
849
+ function processServerComponentReturnValue(
850
+ request,
851
+ task,
852
+ Component,
853
+ result
854
+ ) {
855
+ if (
856
+ "object" !== typeof result ||
857
+ null === result ||
858
+ isClientReference(result)
859
+ )
860
+ return result;
861
+ if ("function" === typeof result.then)
862
+ return (
863
+ result.then(function (resolvedValue) {
864
+ "object" === typeof resolvedValue &&
865
+ null !== resolvedValue &&
866
+ resolvedValue.$$typeof === REACT_ELEMENT_TYPE &&
867
+ (resolvedValue._store.validated = 1);
868
+ }, voidHandler),
869
+ "fulfilled" === result.status
870
+ ? result.value
871
+ : createLazyWrapperAroundWakeable(result)
872
+ );
873
+ result.$$typeof === REACT_ELEMENT_TYPE && (result._store.validated = 1);
874
+ var iteratorFn = getIteratorFn(result);
875
+ if (iteratorFn) {
876
+ var multiShot = _defineProperty({}, Symbol.iterator, function () {
877
+ var iterator = iteratorFn.call(result);
878
+ iterator !== result ||
879
+ ("[object GeneratorFunction]" ===
880
+ Object.prototype.toString.call(Component) &&
881
+ "[object Generator]" ===
882
+ Object.prototype.toString.call(result)) ||
883
+ callWithDebugContextInDEV(request, task, function () {
884
+ console.error(
885
+ "Returning an Iterator from a Server Component is not supported since it cannot be looped over more than once. "
886
+ );
887
+ });
888
+ return iterator;
889
+ });
890
+ multiShot._debugInfo = result._debugInfo;
891
+ return multiShot;
892
+ }
893
+ return "function" !== typeof result[ASYNC_ITERATOR] ||
894
+ ("function" === typeof ReadableStream &&
895
+ result instanceof ReadableStream)
896
+ ? result
897
+ : ((multiShot = _defineProperty({}, ASYNC_ITERATOR, function () {
898
+ var iterator = result[ASYNC_ITERATOR]();
899
+ iterator !== result ||
900
+ ("[object AsyncGeneratorFunction]" ===
901
+ Object.prototype.toString.call(Component) &&
902
+ "[object AsyncGenerator]" ===
903
+ Object.prototype.toString.call(result)) ||
904
+ callWithDebugContextInDEV(request, task, function () {
905
+ console.error(
906
+ "Returning an AsyncIterator from a Server Component is not supported since it cannot be looped over more than once. "
907
+ );
908
+ });
909
+ return iterator;
910
+ })),
911
+ (multiShot._debugInfo = result._debugInfo),
912
+ multiShot);
913
+ }
860
914
  function renderFunctionComponent(request, task, key, Component, props) {
861
915
  var prevThenableState = task.thenableState;
862
916
  task.thenableState = null;
@@ -879,7 +933,9 @@
879
933
  emitDebugChunk(request, componentDebugID, componentDebugInfo);
880
934
  task.environmentName = componentEnv;
881
935
  }
882
- prepareToUseHooksForComponent(prevThenableState, componentDebugInfo);
936
+ thenableIndexCounter = 0;
937
+ thenableState = prevThenableState;
938
+ currentComponentDebugInfo = componentDebugInfo;
883
939
  props = supportsComponentStorage
884
940
  ? componentStorage.run(
885
941
  componentDebugInfo,
@@ -898,76 +954,21 @@
898
954
  props.then(voidHandler, voidHandler),
899
955
  null)
900
956
  );
901
- if (
902
- "object" === typeof props &&
903
- null !== props &&
904
- !isClientReference(props)
905
- ) {
906
- if ("function" === typeof props.then) {
907
- prevThenableState = props;
908
- prevThenableState.then(function (resolvedValue) {
909
- "object" === typeof resolvedValue &&
910
- null !== resolvedValue &&
911
- resolvedValue.$$typeof === REACT_ELEMENT_TYPE &&
912
- (resolvedValue._store.validated = 1);
913
- }, voidHandler);
914
- if ("fulfilled" === prevThenableState.status)
915
- return prevThenableState.value;
916
- props = createLazyWrapperAroundWakeable(props);
917
- }
918
- var iteratorFn = getIteratorFn(props);
919
- if (iteratorFn) {
920
- var iterableChild = props;
921
- props = _defineProperty({}, Symbol.iterator, function () {
922
- var iterator = iteratorFn.call(iterableChild);
923
- iterator !== iterableChild ||
924
- ("[object GeneratorFunction]" ===
925
- Object.prototype.toString.call(Component) &&
926
- "[object Generator]" ===
927
- Object.prototype.toString.call(iterableChild)) ||
928
- callWithDebugContextInDEV(request, task, function () {
929
- console.error(
930
- "Returning an Iterator from a Server Component is not supported since it cannot be looped over more than once. "
931
- );
932
- });
933
- return iterator;
934
- });
935
- props._debugInfo = iterableChild._debugInfo;
936
- } else if (
937
- "function" !== typeof props[ASYNC_ITERATOR] ||
938
- ("function" === typeof ReadableStream &&
939
- props instanceof ReadableStream)
940
- )
941
- props.$$typeof === REACT_ELEMENT_TYPE && (props._store.validated = 1);
942
- else {
943
- var _iterableChild = props;
944
- props = _defineProperty({}, ASYNC_ITERATOR, function () {
945
- var iterator = _iterableChild[ASYNC_ITERATOR]();
946
- iterator !== _iterableChild ||
947
- ("[object AsyncGeneratorFunction]" ===
948
- Object.prototype.toString.call(Component) &&
949
- "[object AsyncGenerator]" ===
950
- Object.prototype.toString.call(_iterableChild)) ||
951
- callWithDebugContextInDEV(request, task, function () {
952
- console.error(
953
- "Returning an AsyncIterator from a Server Component is not supported since it cannot be looped over more than once. "
954
- );
955
- });
956
- return iterator;
957
- });
958
- props._debugInfo = _iterableChild._debugInfo;
959
- }
960
- }
961
- prevThenableState = task.keyPath;
962
- componentDebugID = task.implicitSlot;
957
+ props = processServerComponentReturnValue(
958
+ request,
959
+ task,
960
+ Component,
961
+ props
962
+ );
963
+ Component = task.keyPath;
964
+ prevThenableState = task.implicitSlot;
963
965
  null !== key
964
- ? (task.keyPath =
965
- null === prevThenableState ? key : prevThenableState + "," + key)
966
- : null === prevThenableState && (task.implicitSlot = !0);
967
- key = renderModelDestructive(request, task, emptyRoot, "", props);
968
- task.keyPath = prevThenableState;
969
- task.implicitSlot = componentDebugID;
970
- return key;
966
+ ? (task.keyPath = null === Component ? key : Component + "," + key)
967
+ : null === Component && (task.implicitSlot = !0);
968
+ request = renderModelDestructive(request, task, emptyRoot, "", props);
969
+ task.keyPath = Component;
970
+ task.implicitSlot = prevThenableState;
971
+ return request;
971
972
  }
972
973
  function renderFragment(request, task, children) {
973
974
  for (var i = 0; i < children.length; i++) {
@@ -1170,9 +1171,6 @@
1170
1171
  ? "$-Infinity"
1171
1172
  : "$NaN";
1172
1173
  }
1173
- function serializeRowHeader(tag, id) {
1174
- return id.toString(16) + ":" + tag;
1175
- }
1176
1174
  function encodeReferenceChunk(request, id, reference) {
1177
1175
  request = stringify(reference);
1178
1176
  id = id.toString(16) + ":" + request + "\n";
@@ -1201,7 +1199,7 @@
1201
1199
  request.pendingChunks++;
1202
1200
  var importId = request.nextChunkId++,
1203
1201
  json = stringify(clientReferenceMetadata),
1204
- row = serializeRowHeader("I", importId) + json + "\n",
1202
+ row = importId.toString(16) + ":I" + json + "\n",
1205
1203
  processedChunk = stringToChunk(row);
1206
1204
  request.completedImportChunks.push(processedChunk);
1207
1205
  writtenClientReferences.set(clientReferenceKey, importId);
@@ -1764,7 +1762,7 @@
1764
1762
  (stack = []);
1765
1763
  }
1766
1764
  digest = { digest: digest, message: message, stack: stack, env: env };
1767
- id = serializeRowHeader("E", id) + stringify(digest) + "\n";
1765
+ id = id.toString(16) + ":E" + stringify(digest) + "\n";
1768
1766
  id = stringToChunk(id);
1769
1767
  request.completedErrorChunks.push(id);
1770
1768
  }
@@ -1788,7 +1786,7 @@
1788
1786
  value
1789
1787
  );
1790
1788
  });
1791
- id = serializeRowHeader("D", id) + debugInfo + "\n";
1789
+ id = id.toString(16) + ":D" + debugInfo + "\n";
1792
1790
  id = stringToChunk(id);
1793
1791
  request.completedRegularChunks.push(id);
1794
1792
  }
@@ -2046,14 +2044,7 @@
2046
2044
  request.completedRegularChunks.push(json);
2047
2045
  return model;
2048
2046
  }
2049
- function emitConsoleChunk(
2050
- request,
2051
- id,
2052
- methodName,
2053
- owner,
2054
- stackTrace,
2055
- args
2056
- ) {
2047
+ function emitConsoleChunk(request, methodName, owner, stackTrace, args) {
2057
2048
  function replacer(parentPropertyName, value) {
2058
2049
  try {
2059
2050
  return renderConsoleValue(
@@ -2090,9 +2081,8 @@
2090
2081
  replacer
2091
2082
  );
2092
2083
  }
2093
- id = serializeRowHeader("W", id) + json + "\n";
2094
- id = stringToChunk(id);
2095
- request.completedRegularChunks.push(id);
2084
+ methodName = stringToChunk(":W" + json + "\n");
2085
+ request.completedRegularChunks.push(methodName);
2096
2086
  }
2097
2087
  function forwardDebugInfo(request, id, debugInfo) {
2098
2088
  for (var i = 0; i < debugInfo.length; i++)
@@ -21,8 +21,8 @@ function resolveServerReference(bundlerConfig, ref) {
21
21
  }
22
22
  function preloadModule$1(metadata) {
23
23
  return Promise.all(
24
- metadata.bundles.map(function (bundlePath) {
25
- return import(parcelRequire.meta.distDir + "/" + bundlePath);
24
+ metadata.bundles.map(function (url) {
25
+ return parcelRequire.load(url);
26
26
  })
27
27
  );
28
28
  }
@@ -842,11 +842,8 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
842
842
  }
843
843
  function emitHint(request, code, model) {
844
844
  model = stringify(model);
845
- var id = request.nextChunkId++;
846
- code = "H" + code;
847
- code = id.toString(16) + ":" + code;
848
- model = stringToChunk(code + model + "\n");
849
- request.completedHintChunks.push(model);
845
+ code = stringToChunk(":H" + code + model + "\n");
846
+ request.completedHintChunks.push(code);
850
847
  enqueueFlush(request);
851
848
  }
852
849
  function readThenable(thenable) {
@@ -877,63 +874,57 @@ function createLazyWrapperAroundWakeable(wakeable) {
877
874
  return { $$typeof: REACT_LAZY_TYPE, _payload: wakeable, _init: readThenable };
878
875
  }
879
876
  function voidHandler() {}
877
+ function processServerComponentReturnValue(request, task, Component, result) {
878
+ if (
879
+ "object" !== typeof result ||
880
+ null === result ||
881
+ result.$$typeof === CLIENT_REFERENCE_TAG$1
882
+ )
883
+ return result;
884
+ if ("function" === typeof result.then)
885
+ return "fulfilled" === result.status
886
+ ? result.value
887
+ : createLazyWrapperAroundWakeable(result);
888
+ var iteratorFn = getIteratorFn(result);
889
+ return iteratorFn
890
+ ? ((request = {}),
891
+ (request[Symbol.iterator] = function () {
892
+ return iteratorFn.call(result);
893
+ }),
894
+ request)
895
+ : "function" !== typeof result[ASYNC_ITERATOR] ||
896
+ ("function" === typeof ReadableStream &&
897
+ result instanceof ReadableStream)
898
+ ? result
899
+ : ((request = {}),
900
+ (request[ASYNC_ITERATOR] = function () {
901
+ return result[ASYNC_ITERATOR]();
902
+ }),
903
+ request);
904
+ }
880
905
  function renderFunctionComponent(request, task, key, Component, props) {
881
906
  var prevThenableState = task.thenableState;
882
907
  task.thenableState = null;
883
908
  thenableIndexCounter = 0;
884
909
  thenableState = prevThenableState;
885
- Component = Component(props, void 0);
910
+ props = Component(props, void 0);
886
911
  if (12 === request.status)
887
912
  throw (
888
- ("object" === typeof Component &&
889
- null !== Component &&
890
- "function" === typeof Component.then &&
891
- Component.$$typeof !== CLIENT_REFERENCE_TAG$1 &&
892
- Component.then(voidHandler, voidHandler),
913
+ ("object" === typeof props &&
914
+ null !== props &&
915
+ "function" === typeof props.then &&
916
+ props.$$typeof !== CLIENT_REFERENCE_TAG$1 &&
917
+ props.then(voidHandler, voidHandler),
893
918
  null)
894
919
  );
895
- if (
896
- "object" === typeof Component &&
897
- null !== Component &&
898
- Component.$$typeof !== CLIENT_REFERENCE_TAG$1
899
- ) {
900
- if ("function" === typeof Component.then) {
901
- props = Component;
902
- if ("fulfilled" === props.status) return props.value;
903
- Component = createLazyWrapperAroundWakeable(Component);
904
- }
905
- var iteratorFn = getIteratorFn(Component);
906
- if (iteratorFn) {
907
- var iterableChild = Component;
908
- Component = {};
909
- Component =
910
- ((Component[Symbol.iterator] = function () {
911
- return iteratorFn.call(iterableChild);
912
- }),
913
- Component);
914
- } else if (
915
- !(
916
- "function" !== typeof Component[ASYNC_ITERATOR] ||
917
- ("function" === typeof ReadableStream &&
918
- Component instanceof ReadableStream)
919
- )
920
- ) {
921
- var iterableChild$10 = Component;
922
- Component = {};
923
- Component =
924
- ((Component[ASYNC_ITERATOR] = function () {
925
- return iterableChild$10[ASYNC_ITERATOR]();
926
- }),
927
- Component);
928
- }
929
- }
930
- props = task.keyPath;
920
+ props = processServerComponentReturnValue(request, task, Component, props);
921
+ Component = task.keyPath;
931
922
  prevThenableState = task.implicitSlot;
932
923
  null !== key
933
- ? (task.keyPath = null === props ? key : props + "," + key)
934
- : null === props && (task.implicitSlot = !0);
935
- request = renderModelDestructive(request, task, emptyRoot, "", Component);
936
- task.keyPath = props;
924
+ ? (task.keyPath = null === Component ? key : Component + "," + key)
925
+ : null === Component && (task.implicitSlot = !0);
926
+ request = renderModelDestructive(request, task, emptyRoot, "", props);
927
+ task.keyPath = Component;
937
928
  task.implicitSlot = prevThenableState;
938
929
  return request;
939
930
  }