react-router 0.0.0-experimental-e16afd9b7 → 0.0.0-experimental-13d6d438f

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router v0.0.0-experimental-e16afd9b7
2
+ * React Router v0.0.0-experimental-13d6d438f
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -7155,8 +7155,7 @@
7155
7155
  context,
7156
7156
  identifier,
7157
7157
  reader,
7158
- textDecoder,
7159
- isAction
7158
+ textDecoder
7160
7159
  } = _ref;
7161
7160
  // If the user didn't render the <Scripts> component then we don't have to
7162
7161
  // bother streaming anything in
@@ -7166,16 +7165,9 @@
7166
7165
  if (!context.renderMeta.streamCache) {
7167
7166
  context.renderMeta.streamCache = {};
7168
7167
  }
7169
- let streamCache = isAction ? context.renderMeta.streamCacheAction : context.renderMeta.streamCache;
7170
- if (!streamCache) {
7171
- if (isAction) {
7172
- context.renderMeta.streamCacheAction = {};
7173
- streamCache = context.renderMeta.streamCacheAction;
7174
- } else {
7175
- context.renderMeta.streamCache = {};
7176
- streamCache = context.renderMeta.streamCache;
7177
- }
7178
- }
7168
+ let {
7169
+ streamCache
7170
+ } = context.renderMeta;
7179
7171
  let promise = streamCache[identifier];
7180
7172
  if (!promise) {
7181
7173
  promise = streamCache[identifier] = reader.read().then(result => {
@@ -7201,13 +7193,13 @@
7201
7193
  } = promise.result;
7202
7194
  let scriptTag = value ? /*#__PURE__*/React__namespace.createElement("script", {
7203
7195
  dangerouslySetInnerHTML: {
7204
- __html: "window.__remixContext.streamController" + (isAction ? "Action" : "") + ".enqueue(" + escapeHtml(JSON.stringify(value)) + ");"
7196
+ __html: "window.__remixContext.streamController.enqueue(" + escapeHtml(JSON.stringify(value)) + ");"
7205
7197
  }
7206
7198
  }) : null;
7207
7199
  if (done) {
7208
7200
  return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, scriptTag, /*#__PURE__*/React__namespace.createElement("script", {
7209
7201
  dangerouslySetInnerHTML: {
7210
- __html: "window.__remixContext.streamController" + (isAction ? "Action" : "") + ".close();"
7202
+ __html: "window.__remixContext.streamController.close();"
7211
7203
  }
7212
7204
  }));
7213
7205
  } else {
@@ -7215,8 +7207,7 @@
7215
7207
  context: context,
7216
7208
  identifier: identifier + 1,
7217
7209
  reader: reader,
7218
- textDecoder: textDecoder,
7219
- isAction: isAction
7210
+ textDecoder: textDecoder
7220
7211
  })));
7221
7212
  }
7222
7213
  }
@@ -7360,18 +7351,8 @@
7360
7351
  return url;
7361
7352
  }
7362
7353
  async function fetchAndDecode(url, init) {
7363
- var _res$headers$get;
7364
7354
  let res = await fetch(url, init);
7365
7355
  !res.body ? invariant(false, "No response body to decode") : void 0;
7366
- if ((_res$headers$get = res.headers.get("Content-Type")) != null && _res$headers$get.includes("text/x-component")) {
7367
- !res.body ? invariant(false, "No response body to decode") : void 0;
7368
- // @ts-expect-error - TODO: Figure out where this comes from
7369
- let decoded = await window.createFromReadableStream(res.body);
7370
- return {
7371
- status: res.status,
7372
- data: decoded
7373
- };
7374
- }
7375
7356
  try {
7376
7357
  let decoded = await decodeViaTurboStream(res.body, window);
7377
7358
  return {
@@ -7898,8 +7879,7 @@
7898
7879
  manifest,
7899
7880
  serverHandoffString,
7900
7881
  isSpaMode,
7901
- renderMeta,
7902
- future
7882
+ renderMeta
7903
7883
  } = useRemixContext();
7904
7884
  let {
7905
7885
  router,
@@ -7923,9 +7903,6 @@
7923
7903
  let initialScripts = React__namespace.useMemo(() => {
7924
7904
  var _manifest$hmr;
7925
7905
  let streamScript = "window.__remixContext.stream = new ReadableStream({" + "start(controller){" + "window.__remixContext.streamController = controller;" + "}" + "}).pipeThrough(new TextEncoderStream());";
7926
- if (future.unstable_serverComponents && staticContext != null && staticContext.actionData) {
7927
- streamScript += "window.__remixContext.streamAction = new ReadableStream({" + "start(controller){" + "window.__remixContext.streamControllerAction = controller;" + "}" + "}).pipeThrough(new TextEncoderStream());";
7928
- }
7929
7906
  let contextScript = staticContext ? "window.__remixContext = " + serverHandoffString + ";" + streamScript : " ";
7930
7907
  let routeModulesScript = !isStatic ? " " : ((_manifest$hmr = manifest.hmr) != null && _manifest$hmr.runtime ? "import " + JSON.stringify(manifest.hmr.runtime) + ";" : "") + "import " + JSON.stringify(manifest.url) + ";\n" + matches.map((match, index) => "import * as route" + index + " from " + JSON.stringify(manifest.routes[match.route.id].module) + ";").join("\n") + "\nwindow.__remixRouteModules = {" + matches.map((match, index) => JSON.stringify(match.route.id) + ":route" + index).join(",") + "};\n\nimport(" + JSON.stringify(manifest.entry.module) + ");";
7931
7908
  return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement("script", _extends({}, props, {
@@ -9995,7 +9972,7 @@
9995
9972
  // has a loader/clientLoader, but it won't ever be called during the static
9996
9973
  // render, so just give it a no-op function so we can render down to the
9997
9974
  // proper fallback
9998
- loader: route.hasLoader || route.hasClientLoader ? true : undefined
9975
+ loader: route.hasLoader || route.hasClientLoader ? () => null : undefined
9999
9976
  // We don't need action/shouldRevalidate on these routes since they're
10000
9977
  // for a static render
10001
9978
  });
@@ -10371,50 +10348,14 @@
10371
10348
  // then only get past here and create the `router` one time
10372
10349
  if (!ssrInfo.stateDecodingPromise) {
10373
10350
  let stream = ssrInfo.context.stream;
10374
- let streamAction = ssrInfo.context.streamAction;
10375
10351
  !stream ? invariant(false, "No stream found for single fetch decoding") : void 0;
10376
10352
  ssrInfo.context.stream = undefined;
10377
- if (ssrInfo.context.future.unstable_serverComponents) {
10378
- ssrInfo.stateDecodingPromise = Promise.all([
10379
- // @ts-expect-error - TODO: Get this from somewhere else
10380
- window.createFromReadableStream(stream), streamAction ?
10381
- // @ts-expect-error - TODO: Get this from somewhere else
10382
- window.createFromReadableStream(streamAction) : undefined]).then(_ref2 => {
10383
- let [loaderPayload, actionPayload] = _ref2;
10384
- let state = {};
10385
- for (let routeId of Object.keys(ssrInfo.routeModules)) {
10386
- if ("error" in loaderPayload[routeId]) {
10387
- state.errors = state.errors || {};
10388
- state.errors[routeId] = loaderPayload[routeId].error;
10389
- } else if ("data" in loaderPayload[routeId]) {
10390
- state.loaderData = state.loaderData || {};
10391
- state.loaderData[routeId] = loaderPayload[routeId].data;
10392
- }
10393
- }
10394
- if (actionPayload) {
10395
- // @ts-expect-error - TODO: Fix types and don't get it off the window directly
10396
- const actionId = window.__remixContext.serverHandoffActionId;
10397
- if ("error" in actionPayload) {
10398
- state.errors = state.errors || {};
10399
- state.errors[actionId] = actionPayload.error;
10400
- } else if ("data" in actionPayload) {
10401
- state.actionData = state.actionData || {};
10402
- state.actionData[actionId] = actionPayload.data;
10403
- }
10404
- }
10405
- ssrInfo.context.state = state;
10406
- localSsrInfo.stateDecodingPromise.value = true;
10407
- }).catch(e => {
10408
- localSsrInfo.stateDecodingPromise.error = e;
10409
- });
10410
- } else {
10411
- ssrInfo.stateDecodingPromise = decodeViaTurboStream(stream, window).then(value => {
10412
- ssrInfo.context.state = value.value;
10413
- localSsrInfo.stateDecodingPromise.value = true;
10414
- }).catch(e => {
10415
- localSsrInfo.stateDecodingPromise.error = e;
10416
- });
10417
- }
10353
+ ssrInfo.stateDecodingPromise = decodeViaTurboStream(stream, window).then(value => {
10354
+ ssrInfo.context.state = value.value;
10355
+ localSsrInfo.stateDecodingPromise.value = true;
10356
+ }).catch(e => {
10357
+ localSsrInfo.stateDecodingPromise.error = e;
10358
+ });
10418
10359
  }
10419
10360
  if (ssrInfo.stateDecodingPromise.error) {
10420
10361
  throw ssrInfo.stateDecodingPromise.error;
@@ -10626,18 +10567,11 @@
10626
10567
  router: router,
10627
10568
  context: context.staticHandlerContext,
10628
10569
  hydrate: false
10629
- }))), context.serverHandoffStreamAction ? /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, null, /*#__PURE__*/React__namespace.createElement(StreamTransfer, {
10630
- context: context,
10631
- identifier: 0,
10632
- reader: context.serverHandoffStreamAction.getReader(),
10633
- textDecoder: new TextDecoder(),
10634
- isAction: true
10635
- })) : null, context.serverHandoffStream ? /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, null, /*#__PURE__*/React__namespace.createElement(StreamTransfer, {
10570
+ }))), context.serverHandoffStream ? /*#__PURE__*/React__namespace.createElement(React__namespace.Suspense, null, /*#__PURE__*/React__namespace.createElement(StreamTransfer, {
10636
10571
  context: context,
10637
10572
  identifier: 0,
10638
10573
  reader: context.serverHandoffStream.getReader(),
10639
- textDecoder: new TextDecoder(),
10640
- isAction: false
10574
+ textDecoder: new TextDecoder()
10641
10575
  })) : null);
10642
10576
  }
10643
10577
 
@@ -10658,8 +10592,7 @@
10658
10592
  remixContextRef.current = {
10659
10593
  future: {
10660
10594
  v3_fetcherPersist: (future == null ? void 0 : future.v3_fetcherPersist) === true,
10661
- v3_relativeSplatPath: (future == null ? void 0 : future.v3_relativeSplatPath) === true,
10662
- unstable_serverComponents: (future == null ? void 0 : future.unstable_serverComponents) === true
10595
+ v3_relativeSplatPath: (future == null ? void 0 : future.v3_relativeSplatPath) === true
10663
10596
  },
10664
10597
  manifest: {
10665
10598
  routes: {},