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.
@@ -32,8 +32,8 @@
32
32
  }
33
33
  function preloadModule(metadata) {
34
34
  return Promise.all(
35
- metadata.bundles.map(function (bundlePath) {
36
- return import(parcelRequire.meta.distDir + "/" + bundlePath);
35
+ metadata.bundles.map(function (url) {
36
+ return parcelRequire.load(url);
37
37
  })
38
38
  );
39
39
  }
@@ -548,7 +548,7 @@
548
548
  ) {
549
549
  if (void 0 === temporaryReferences)
550
550
  throw Error(
551
- "Only plain objects, and a few built-ins, can be passed to Server Actions. Classes or null prototypes are not supported." +
551
+ "Only plain objects, and a few built-ins, can be passed to Server Functions. Classes or null prototypes are not supported." +
552
552
  describeObjectForErrorMessage(this, key)
553
553
  );
554
554
  return "$T";
@@ -1888,7 +1888,8 @@
1888
1888
  null === debugInfo.owner && null != response._debugRootOwner
1889
1889
  ? ((debugInfo.owner = response._debugRootOwner),
1890
1890
  (debugInfo.debugStack = response._debugRootStack))
1891
- : initializeFakeStack(response, debugInfo);
1891
+ : void 0 !== debugInfo.stack &&
1892
+ initializeFakeStack(response, debugInfo);
1892
1893
  response = getChunk(response, id);
1893
1894
  (response._debugInfo || (response._debugInfo = [])).push(debugInfo);
1894
1895
  }
@@ -20,8 +20,8 @@ function resolveServerReference(bundlerConfig, ref) {
20
20
  }
21
21
  function preloadModule(metadata) {
22
22
  return Promise.all(
23
- metadata.bundles.map(function (bundlePath) {
24
- return import(parcelRequire.meta.distDir + "/" + bundlePath);
23
+ metadata.bundles.map(function (url) {
24
+ return parcelRequire.load(url);
25
25
  })
26
26
  );
27
27
  }
@@ -331,7 +331,7 @@ function processReply(
331
331
  ) {
332
332
  if (void 0 === temporaryReferences)
333
333
  throw Error(
334
- "Only plain objects, and a few built-ins, can be passed to Server Actions. Classes or null prototypes are not supported."
334
+ "Only plain objects, and a few built-ins, can be passed to Server Functions. Classes or null prototypes are not supported."
335
335
  );
336
336
  return "$T";
337
337
  }
@@ -32,8 +32,8 @@
32
32
  }
33
33
  function preloadModule(metadata) {
34
34
  return Promise.all(
35
- metadata.bundles.map(function (bundlePath) {
36
- return import(parcelRequire.meta.distDir + "/" + bundlePath);
35
+ metadata.bundles.map(function (url) {
36
+ return parcelRequire.load(url);
37
37
  })
38
38
  );
39
39
  }
@@ -548,7 +548,7 @@
548
548
  ) {
549
549
  if (void 0 === temporaryReferences)
550
550
  throw Error(
551
- "Only plain objects, and a few built-ins, can be passed to Server Actions. Classes or null prototypes are not supported." +
551
+ "Only plain objects, and a few built-ins, can be passed to Server Functions. Classes or null prototypes are not supported." +
552
552
  describeObjectForErrorMessage(this, key)
553
553
  );
554
554
  return "$T";
@@ -2038,7 +2038,8 @@
2038
2038
  null === debugInfo.owner && null != response._debugRootOwner
2039
2039
  ? ((debugInfo.owner = response._debugRootOwner),
2040
2040
  (debugInfo.debugStack = response._debugRootStack))
2041
- : initializeFakeStack(response, debugInfo);
2041
+ : void 0 !== debugInfo.stack &&
2042
+ initializeFakeStack(response, debugInfo);
2042
2043
  response = getChunk(response, id);
2043
2044
  (response._debugInfo || (response._debugInfo = [])).push(debugInfo);
2044
2045
  }
@@ -20,8 +20,8 @@ function resolveServerReference(bundlerConfig, ref) {
20
20
  }
21
21
  function preloadModule(metadata) {
22
22
  return Promise.all(
23
- metadata.bundles.map(function (bundlePath) {
24
- return import(parcelRequire.meta.distDir + "/" + bundlePath);
23
+ metadata.bundles.map(function (url) {
24
+ return parcelRequire.load(url);
25
25
  })
26
26
  );
27
27
  }
@@ -331,7 +331,7 @@ function processReply(
331
331
  ) {
332
332
  if (void 0 === temporaryReferences)
333
333
  throw Error(
334
- "Only plain objects, and a few built-ins, can be passed to Server Actions. Classes or null prototypes are not supported."
334
+ "Only plain objects, and a few built-ins, can be passed to Server Functions. Classes or null prototypes are not supported."
335
335
  );
336
336
  return "$T";
337
337
  }
@@ -32,8 +32,8 @@
32
32
  }
33
33
  function preloadModule(metadata) {
34
34
  return Promise.all(
35
- metadata.bundles.map(function (bundlePath) {
36
- return import(parcelRequire.meta.distDir + "/" + bundlePath);
35
+ metadata.bundles.map(function (url) {
36
+ return parcelRequire.load(url);
37
37
  })
38
38
  );
39
39
  }
@@ -548,7 +548,7 @@
548
548
  ) {
549
549
  if (void 0 === temporaryReferences)
550
550
  throw Error(
551
- "Only plain objects, and a few built-ins, can be passed to Server Actions. Classes or null prototypes are not supported." +
551
+ "Only plain objects, and a few built-ins, can be passed to Server Functions. Classes or null prototypes are not supported." +
552
552
  describeObjectForErrorMessage(this, key)
553
553
  );
554
554
  return "$T";
@@ -2038,7 +2038,8 @@
2038
2038
  null === debugInfo.owner && null != response._debugRootOwner
2039
2039
  ? ((debugInfo.owner = response._debugRootOwner),
2040
2040
  (debugInfo.debugStack = response._debugRootStack))
2041
- : initializeFakeStack(response, debugInfo);
2041
+ : void 0 !== debugInfo.stack &&
2042
+ initializeFakeStack(response, debugInfo);
2042
2043
  response = getChunk(response, id);
2043
2044
  (response._debugInfo || (response._debugInfo = [])).push(debugInfo);
2044
2045
  }
@@ -21,8 +21,8 @@ function resolveServerReference(bundlerConfig, ref) {
21
21
  }
22
22
  function preloadModule(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
  }
@@ -332,7 +332,7 @@ function processReply(
332
332
  ) {
333
333
  if (void 0 === temporaryReferences)
334
334
  throw Error(
335
- "Only plain objects, and a few built-ins, can be passed to Server Actions. Classes or null prototypes are not supported."
335
+ "Only plain objects, and a few built-ins, can be passed to Server Functions. Classes or null prototypes are not supported."
336
336
  );
337
337
  return "$T";
338
338
  }
@@ -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
  }
@@ -229,14 +229,6 @@
229
229
  suspendedThenable = null;
230
230
  return thenable;
231
231
  }
232
- function prepareToUseHooksForComponent(
233
- prevThenableState,
234
- componentDebugInfo
235
- ) {
236
- thenableIndexCounter = 0;
237
- thenableState = prevThenableState;
238
- currentComponentDebugInfo = componentDebugInfo;
239
- }
240
232
  function getThenableStateAfterSuspending() {
241
233
  var state = thenableState || [];
242
234
  state._componentDebugInfo = currentComponentDebugInfo;
@@ -491,9 +483,8 @@
491
483
  1
492
484
  );
493
485
  request.pendingChunks++;
494
- var id = request.nextChunkId++,
495
- owner = resolveOwner();
496
- emitConsoleChunk(request, id, methodName, owner, stack, arguments);
486
+ var owner = resolveOwner();
487
+ emitConsoleChunk(request, methodName, owner, stack, arguments);
497
488
  }
498
489
  return originalMethod.apply(this, arguments);
499
490
  };
@@ -790,9 +781,7 @@
790
781
  }
791
782
  function emitHint(request, code, model) {
792
783
  model = stringify(model);
793
- var id = request.nextChunkId++;
794
- code = serializeRowHeader("H" + code, id) + model + "\n";
795
- code = stringToChunk(code);
784
+ code = stringToChunk(":H" + code + model + "\n");
796
785
  request.completedHintChunks.push(code);
797
786
  enqueueFlush(request);
798
787
  }
@@ -842,6 +831,71 @@
842
831
  currentOwner = null;
843
832
  }
844
833
  }
834
+ function processServerComponentReturnValue(
835
+ request,
836
+ task,
837
+ Component,
838
+ result
839
+ ) {
840
+ if (
841
+ "object" !== typeof result ||
842
+ null === result ||
843
+ isClientReference(result)
844
+ )
845
+ return result;
846
+ if ("function" === typeof result.then)
847
+ return (
848
+ result.then(function (resolvedValue) {
849
+ "object" === typeof resolvedValue &&
850
+ null !== resolvedValue &&
851
+ resolvedValue.$$typeof === REACT_ELEMENT_TYPE &&
852
+ (resolvedValue._store.validated = 1);
853
+ }, voidHandler),
854
+ "fulfilled" === result.status
855
+ ? result.value
856
+ : createLazyWrapperAroundWakeable(result)
857
+ );
858
+ result.$$typeof === REACT_ELEMENT_TYPE && (result._store.validated = 1);
859
+ var iteratorFn = getIteratorFn(result);
860
+ if (iteratorFn) {
861
+ var multiShot = _defineProperty({}, Symbol.iterator, function () {
862
+ var iterator = iteratorFn.call(result);
863
+ iterator !== result ||
864
+ ("[object GeneratorFunction]" ===
865
+ Object.prototype.toString.call(Component) &&
866
+ "[object Generator]" ===
867
+ Object.prototype.toString.call(result)) ||
868
+ callWithDebugContextInDEV(request, task, function () {
869
+ console.error(
870
+ "Returning an Iterator from a Server Component is not supported since it cannot be looped over more than once. "
871
+ );
872
+ });
873
+ return iterator;
874
+ });
875
+ multiShot._debugInfo = result._debugInfo;
876
+ return multiShot;
877
+ }
878
+ return "function" !== typeof result[ASYNC_ITERATOR] ||
879
+ ("function" === typeof ReadableStream &&
880
+ result instanceof ReadableStream)
881
+ ? result
882
+ : ((multiShot = _defineProperty({}, ASYNC_ITERATOR, function () {
883
+ var iterator = result[ASYNC_ITERATOR]();
884
+ iterator !== result ||
885
+ ("[object AsyncGeneratorFunction]" ===
886
+ Object.prototype.toString.call(Component) &&
887
+ "[object AsyncGenerator]" ===
888
+ Object.prototype.toString.call(result)) ||
889
+ callWithDebugContextInDEV(request, task, function () {
890
+ console.error(
891
+ "Returning an AsyncIterator from a Server Component is not supported since it cannot be looped over more than once. "
892
+ );
893
+ });
894
+ return iterator;
895
+ })),
896
+ (multiShot._debugInfo = result._debugInfo),
897
+ multiShot);
898
+ }
845
899
  function renderFunctionComponent(request, task, key, Component, props) {
846
900
  var prevThenableState = task.thenableState;
847
901
  task.thenableState = null;
@@ -864,7 +918,9 @@
864
918
  emitDebugChunk(request, componentDebugID, componentDebugInfo);
865
919
  task.environmentName = componentEnv;
866
920
  }
867
- prepareToUseHooksForComponent(prevThenableState, componentDebugInfo);
921
+ thenableIndexCounter = 0;
922
+ thenableState = prevThenableState;
923
+ currentComponentDebugInfo = componentDebugInfo;
868
924
  props = callComponentInDEV(Component, props, componentDebugInfo);
869
925
  if (request.status === ABORTING)
870
926
  throw (
@@ -875,76 +931,21 @@
875
931
  props.then(voidHandler, voidHandler),
876
932
  null)
877
933
  );
878
- if (
879
- "object" === typeof props &&
880
- null !== props &&
881
- !isClientReference(props)
882
- ) {
883
- if ("function" === typeof props.then) {
884
- prevThenableState = props;
885
- prevThenableState.then(function (resolvedValue) {
886
- "object" === typeof resolvedValue &&
887
- null !== resolvedValue &&
888
- resolvedValue.$$typeof === REACT_ELEMENT_TYPE &&
889
- (resolvedValue._store.validated = 1);
890
- }, voidHandler);
891
- if ("fulfilled" === prevThenableState.status)
892
- return prevThenableState.value;
893
- props = createLazyWrapperAroundWakeable(props);
894
- }
895
- var iteratorFn = getIteratorFn(props);
896
- if (iteratorFn) {
897
- var iterableChild = props;
898
- props = _defineProperty({}, Symbol.iterator, function () {
899
- var iterator = iteratorFn.call(iterableChild);
900
- iterator !== iterableChild ||
901
- ("[object GeneratorFunction]" ===
902
- Object.prototype.toString.call(Component) &&
903
- "[object Generator]" ===
904
- Object.prototype.toString.call(iterableChild)) ||
905
- callWithDebugContextInDEV(request, task, function () {
906
- console.error(
907
- "Returning an Iterator from a Server Component is not supported since it cannot be looped over more than once. "
908
- );
909
- });
910
- return iterator;
911
- });
912
- props._debugInfo = iterableChild._debugInfo;
913
- } else if (
914
- "function" !== typeof props[ASYNC_ITERATOR] ||
915
- ("function" === typeof ReadableStream &&
916
- props instanceof ReadableStream)
917
- )
918
- props.$$typeof === REACT_ELEMENT_TYPE && (props._store.validated = 1);
919
- else {
920
- var _iterableChild = props;
921
- props = _defineProperty({}, ASYNC_ITERATOR, function () {
922
- var iterator = _iterableChild[ASYNC_ITERATOR]();
923
- iterator !== _iterableChild ||
924
- ("[object AsyncGeneratorFunction]" ===
925
- Object.prototype.toString.call(Component) &&
926
- "[object AsyncGenerator]" ===
927
- Object.prototype.toString.call(_iterableChild)) ||
928
- callWithDebugContextInDEV(request, task, function () {
929
- console.error(
930
- "Returning an AsyncIterator 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
- }
937
- }
938
- prevThenableState = task.keyPath;
939
- componentDebugID = task.implicitSlot;
934
+ props = processServerComponentReturnValue(
935
+ request,
936
+ task,
937
+ Component,
938
+ props
939
+ );
940
+ Component = task.keyPath;
941
+ prevThenableState = task.implicitSlot;
940
942
  null !== key
941
- ? (task.keyPath =
942
- null === prevThenableState ? key : prevThenableState + "," + key)
943
- : null === prevThenableState && (task.implicitSlot = !0);
944
- key = renderModelDestructive(request, task, emptyRoot, "", props);
945
- task.keyPath = prevThenableState;
946
- task.implicitSlot = componentDebugID;
947
- return key;
943
+ ? (task.keyPath = null === Component ? key : Component + "," + key)
944
+ : null === Component && (task.implicitSlot = !0);
945
+ request = renderModelDestructive(request, task, emptyRoot, "", props);
946
+ task.keyPath = Component;
947
+ task.implicitSlot = prevThenableState;
948
+ return request;
948
949
  }
949
950
  function renderFragment(request, task, children) {
950
951
  for (var i = 0; i < children.length; i++) {
@@ -1147,9 +1148,6 @@
1147
1148
  ? "$-Infinity"
1148
1149
  : "$NaN";
1149
1150
  }
1150
- function serializeRowHeader(tag, id) {
1151
- return id.toString(16) + ":" + tag;
1152
- }
1153
1151
  function encodeReferenceChunk(request, id, reference) {
1154
1152
  request = stringify(reference);
1155
1153
  id = id.toString(16) + ":" + request + "\n";
@@ -1178,7 +1176,7 @@
1178
1176
  request.pendingChunks++;
1179
1177
  var importId = request.nextChunkId++,
1180
1178
  json = stringify(clientReferenceMetadata),
1181
- row = serializeRowHeader("I", importId) + json + "\n",
1179
+ row = importId.toString(16) + ":I" + json + "\n",
1182
1180
  processedChunk = stringToChunk(row);
1183
1181
  request.completedImportChunks.push(processedChunk);
1184
1182
  writtenClientReferences.set(clientReferenceKey, importId);
@@ -1730,7 +1728,7 @@
1730
1728
  (stack = []);
1731
1729
  }
1732
1730
  digest = { digest: digest, message: message, stack: stack, env: env };
1733
- id = serializeRowHeader("E", id) + stringify(digest) + "\n";
1731
+ id = id.toString(16) + ":E" + stringify(digest) + "\n";
1734
1732
  id = stringToChunk(id);
1735
1733
  request.completedErrorChunks.push(id);
1736
1734
  }
@@ -1754,7 +1752,7 @@
1754
1752
  value
1755
1753
  );
1756
1754
  });
1757
- id = serializeRowHeader("D", id) + debugInfo + "\n";
1755
+ id = id.toString(16) + ":D" + debugInfo + "\n";
1758
1756
  id = stringToChunk(id);
1759
1757
  request.completedRegularChunks.push(id);
1760
1758
  }
@@ -2012,14 +2010,7 @@
2012
2010
  request.completedRegularChunks.push(json);
2013
2011
  return model;
2014
2012
  }
2015
- function emitConsoleChunk(
2016
- request,
2017
- id,
2018
- methodName,
2019
- owner,
2020
- stackTrace,
2021
- args
2022
- ) {
2013
+ function emitConsoleChunk(request, methodName, owner, stackTrace, args) {
2023
2014
  function replacer(parentPropertyName, value) {
2024
2015
  try {
2025
2016
  return renderConsoleValue(
@@ -2056,9 +2047,8 @@
2056
2047
  replacer
2057
2048
  );
2058
2049
  }
2059
- id = serializeRowHeader("W", id) + json + "\n";
2060
- id = stringToChunk(id);
2061
- request.completedRegularChunks.push(id);
2050
+ methodName = stringToChunk(":W" + json + "\n");
2051
+ request.completedRegularChunks.push(methodName);
2062
2052
  }
2063
2053
  function forwardDebugInfo(request, id, debugInfo) {
2064
2054
  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
  }
@@ -837,11 +837,8 @@ function serializeAsyncIterable(request, task, iterable, iterator) {
837
837
  }
838
838
  function emitHint(request, code, model) {
839
839
  model = stringify(model);
840
- var id = request.nextChunkId++;
841
- code = "H" + code;
842
- code = id.toString(16) + ":" + code;
843
- model = stringToChunk(code + model + "\n");
844
- request.completedHintChunks.push(model);
840
+ code = stringToChunk(":H" + code + model + "\n");
841
+ request.completedHintChunks.push(code);
845
842
  enqueueFlush(request);
846
843
  }
847
844
  function readThenable(thenable) {
@@ -872,63 +869,57 @@ function createLazyWrapperAroundWakeable(wakeable) {
872
869
  return { $$typeof: REACT_LAZY_TYPE, _payload: wakeable, _init: readThenable };
873
870
  }
874
871
  function voidHandler() {}
872
+ function processServerComponentReturnValue(request, task, Component, result) {
873
+ if (
874
+ "object" !== typeof result ||
875
+ null === result ||
876
+ result.$$typeof === CLIENT_REFERENCE_TAG$1
877
+ )
878
+ return result;
879
+ if ("function" === typeof result.then)
880
+ return "fulfilled" === result.status
881
+ ? result.value
882
+ : createLazyWrapperAroundWakeable(result);
883
+ var iteratorFn = getIteratorFn(result);
884
+ return iteratorFn
885
+ ? ((request = {}),
886
+ (request[Symbol.iterator] = function () {
887
+ return iteratorFn.call(result);
888
+ }),
889
+ request)
890
+ : "function" !== typeof result[ASYNC_ITERATOR] ||
891
+ ("function" === typeof ReadableStream &&
892
+ result instanceof ReadableStream)
893
+ ? result
894
+ : ((request = {}),
895
+ (request[ASYNC_ITERATOR] = function () {
896
+ return result[ASYNC_ITERATOR]();
897
+ }),
898
+ request);
899
+ }
875
900
  function renderFunctionComponent(request, task, key, Component, props) {
876
901
  var prevThenableState = task.thenableState;
877
902
  task.thenableState = null;
878
903
  thenableIndexCounter = 0;
879
904
  thenableState = prevThenableState;
880
- Component = Component(props, void 0);
905
+ props = Component(props, void 0);
881
906
  if (12 === request.status)
882
907
  throw (
883
- ("object" === typeof Component &&
884
- null !== Component &&
885
- "function" === typeof Component.then &&
886
- Component.$$typeof !== CLIENT_REFERENCE_TAG$1 &&
887
- Component.then(voidHandler, voidHandler),
908
+ ("object" === typeof props &&
909
+ null !== props &&
910
+ "function" === typeof props.then &&
911
+ props.$$typeof !== CLIENT_REFERENCE_TAG$1 &&
912
+ props.then(voidHandler, voidHandler),
888
913
  null)
889
914
  );
890
- if (
891
- "object" === typeof Component &&
892
- null !== Component &&
893
- Component.$$typeof !== CLIENT_REFERENCE_TAG$1
894
- ) {
895
- if ("function" === typeof Component.then) {
896
- props = Component;
897
- if ("fulfilled" === props.status) return props.value;
898
- Component = createLazyWrapperAroundWakeable(Component);
899
- }
900
- var iteratorFn = getIteratorFn(Component);
901
- if (iteratorFn) {
902
- var iterableChild = Component;
903
- Component = {};
904
- Component =
905
- ((Component[Symbol.iterator] = function () {
906
- return iteratorFn.call(iterableChild);
907
- }),
908
- Component);
909
- } else if (
910
- !(
911
- "function" !== typeof Component[ASYNC_ITERATOR] ||
912
- ("function" === typeof ReadableStream &&
913
- Component instanceof ReadableStream)
914
- )
915
- ) {
916
- var iterableChild$10 = Component;
917
- Component = {};
918
- Component =
919
- ((Component[ASYNC_ITERATOR] = function () {
920
- return iterableChild$10[ASYNC_ITERATOR]();
921
- }),
922
- Component);
923
- }
924
- }
925
- props = task.keyPath;
915
+ props = processServerComponentReturnValue(request, task, Component, props);
916
+ Component = task.keyPath;
926
917
  prevThenableState = task.implicitSlot;
927
918
  null !== key
928
- ? (task.keyPath = null === props ? key : props + "," + key)
929
- : null === props && (task.implicitSlot = !0);
930
- request = renderModelDestructive(request, task, emptyRoot, "", Component);
931
- task.keyPath = props;
919
+ ? (task.keyPath = null === Component ? key : Component + "," + key)
920
+ : null === Component && (task.implicitSlot = !0);
921
+ request = renderModelDestructive(request, task, emptyRoot, "", props);
922
+ task.keyPath = Component;
932
923
  task.implicitSlot = prevThenableState;
933
924
  return request;
934
925
  }