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.
@@ -11,8 +11,6 @@ export type WindowRemixContext = {
11
11
  isSpaMode: boolean;
12
12
  stream: ReadableStream<Uint8Array> | undefined;
13
13
  streamController: ReadableStreamDefaultController<Uint8Array>;
14
- streamAction?: ReadableStream<Uint8Array> | undefined;
15
- streamControllerAction?: ReadableStreamDefaultController<Uint8Array>;
16
14
  a?: number;
17
15
  dev?: {
18
16
  port?: number;
@@ -24,9 +24,8 @@ interface StreamTransferProps {
24
24
  identifier: number;
25
25
  reader: ReadableStreamDefaultReader<Uint8Array>;
26
26
  textDecoder: TextDecoder;
27
- isAction: boolean;
28
27
  }
29
- export declare function StreamTransfer({ context, identifier, reader, textDecoder, isAction, }: StreamTransferProps): React.JSX.Element | null;
28
+ export declare function StreamTransfer({ context, identifier, reader, textDecoder, }: StreamTransferProps): React.JSX.Element | null;
30
29
  export declare function getSingleFetchDataStrategy(manifest: AssetsManifest, routeModules: RouteModules): DataStrategyFunction;
31
30
  export declare function addRevalidationParam(manifest: AssetsManifest, routeModules: RouteModules, matchedRoutes: DataRouteObject[], loadRoutes: DataRouteObject[], url: URL): URL;
32
31
  export declare function singleFetchUrl(reqUrl: URL | string): URL;
package/dist/main.js CHANGED
@@ -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
  *
@@ -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
  *
@@ -7020,8 +7020,7 @@ function StreamTransfer({
7020
7020
  context,
7021
7021
  identifier,
7022
7022
  reader,
7023
- textDecoder,
7024
- isAction
7023
+ textDecoder
7025
7024
  }) {
7026
7025
  // If the user didn't render the <Scripts> component then we don't have to
7027
7026
  // bother streaming anything in
@@ -7031,16 +7030,9 @@ function StreamTransfer({
7031
7030
  if (!context.renderMeta.streamCache) {
7032
7031
  context.renderMeta.streamCache = {};
7033
7032
  }
7034
- let streamCache = isAction ? context.renderMeta.streamCacheAction : context.renderMeta.streamCache;
7035
- if (!streamCache) {
7036
- if (isAction) {
7037
- context.renderMeta.streamCacheAction = {};
7038
- streamCache = context.renderMeta.streamCacheAction;
7039
- } else {
7040
- context.renderMeta.streamCache = {};
7041
- streamCache = context.renderMeta.streamCache;
7042
- }
7043
- }
7033
+ let {
7034
+ streamCache
7035
+ } = context.renderMeta;
7044
7036
  let promise = streamCache[identifier];
7045
7037
  if (!promise) {
7046
7038
  promise = streamCache[identifier] = reader.read().then(result => {
@@ -7066,13 +7058,13 @@ function StreamTransfer({
7066
7058
  } = promise.result;
7067
7059
  let scriptTag = value ? /*#__PURE__*/React.createElement("script", {
7068
7060
  dangerouslySetInnerHTML: {
7069
- __html: `window.__remixContext.streamController${isAction ? "Action" : ""}.enqueue(${escapeHtml(JSON.stringify(value))});`
7061
+ __html: `window.__remixContext.streamController.enqueue(${escapeHtml(JSON.stringify(value))});`
7070
7062
  }
7071
7063
  }) : null;
7072
7064
  if (done) {
7073
7065
  return /*#__PURE__*/React.createElement(React.Fragment, null, scriptTag, /*#__PURE__*/React.createElement("script", {
7074
7066
  dangerouslySetInnerHTML: {
7075
- __html: `window.__remixContext.streamController${isAction ? "Action" : ""}.close();`
7067
+ __html: `window.__remixContext.streamController.close();`
7076
7068
  }
7077
7069
  }));
7078
7070
  } else {
@@ -7080,8 +7072,7 @@ function StreamTransfer({
7080
7072
  context: context,
7081
7073
  identifier: identifier + 1,
7082
7074
  reader: reader,
7083
- textDecoder: textDecoder,
7084
- isAction: isAction
7075
+ textDecoder: textDecoder
7085
7076
  })));
7086
7077
  }
7087
7078
  }
@@ -7216,15 +7207,6 @@ function singleFetchUrl(reqUrl) {
7216
7207
  async function fetchAndDecode(url, init) {
7217
7208
  let res = await fetch(url, init);
7218
7209
  !res.body ? invariant(false, "No response body to decode") : void 0;
7219
- if (res.headers.get("Content-Type")?.includes("text/x-component")) {
7220
- !res.body ? invariant(false, "No response body to decode") : void 0;
7221
- // @ts-expect-error - TODO: Figure out where this comes from
7222
- let decoded = await window.createFromReadableStream(res.body);
7223
- return {
7224
- status: res.status,
7225
- data: decoded
7226
- };
7227
- }
7228
7210
  try {
7229
7211
  let decoded = await decodeViaTurboStream(res.body, window);
7230
7212
  return {
@@ -7734,8 +7716,7 @@ function Scripts(props) {
7734
7716
  manifest,
7735
7717
  serverHandoffString,
7736
7718
  isSpaMode,
7737
- renderMeta,
7738
- future
7719
+ renderMeta
7739
7720
  } = useRemixContext();
7740
7721
  let {
7741
7722
  router,
@@ -7758,9 +7739,6 @@ function Scripts(props) {
7758
7739
  }, []);
7759
7740
  let initialScripts = React.useMemo(() => {
7760
7741
  let streamScript = "window.__remixContext.stream = new ReadableStream({" + "start(controller){" + "window.__remixContext.streamController = controller;" + "}" + "}).pipeThrough(new TextEncoderStream());";
7761
- if (future.unstable_serverComponents && staticContext?.actionData) {
7762
- streamScript += "window.__remixContext.streamAction = new ReadableStream({" + "start(controller){" + "window.__remixContext.streamControllerAction = controller;" + "}" + "}).pipeThrough(new TextEncoderStream());";
7763
- }
7764
7742
  let contextScript = staticContext ? `window.__remixContext = ${serverHandoffString};${streamScript}` : " ";
7765
7743
  let routeModulesScript = !isStatic ? " " : `${manifest.hmr?.runtime ? `import ${JSON.stringify(manifest.hmr.runtime)};` : ""}import ${JSON.stringify(manifest.url)};
7766
7744
  ${matches.map((match, index) => `import * as route${index} from ${JSON.stringify(manifest.routes[match.route.id].module)};`).join("\n")}
@@ -9811,7 +9789,7 @@ function createServerRoutes(manifest, routeModules, future, isSpaMode, parentId
9811
9789
  // has a loader/clientLoader, but it won't ever be called during the static
9812
9790
  // render, so just give it a no-op function so we can render down to the
9813
9791
  // proper fallback
9814
- loader: route.hasLoader || route.hasClientLoader ? true : undefined
9792
+ loader: route.hasLoader || route.hasClientLoader ? () => null : undefined
9815
9793
  // We don't need action/shouldRevalidate on these routes since they're
9816
9794
  // for a static render
9817
9795
  };
@@ -10183,49 +10161,14 @@ function createHydratedRouter() {
10183
10161
  // then only get past here and create the `router` one time
10184
10162
  if (!ssrInfo.stateDecodingPromise) {
10185
10163
  let stream = ssrInfo.context.stream;
10186
- let streamAction = ssrInfo.context.streamAction;
10187
10164
  !stream ? invariant(false, "No stream found for single fetch decoding") : void 0;
10188
10165
  ssrInfo.context.stream = undefined;
10189
- if (ssrInfo.context.future.unstable_serverComponents) {
10190
- ssrInfo.stateDecodingPromise = Promise.all([
10191
- // @ts-expect-error - TODO: Get this from somewhere else
10192
- window.createFromReadableStream(stream), streamAction ?
10193
- // @ts-expect-error - TODO: Get this from somewhere else
10194
- window.createFromReadableStream(streamAction) : undefined]).then(([loaderPayload, actionPayload]) => {
10195
- let state = {};
10196
- for (let routeId of Object.keys(ssrInfo.routeModules)) {
10197
- if ("error" in loaderPayload[routeId]) {
10198
- state.errors = state.errors || {};
10199
- state.errors[routeId] = loaderPayload[routeId].error;
10200
- } else if ("data" in loaderPayload[routeId]) {
10201
- state.loaderData = state.loaderData || {};
10202
- state.loaderData[routeId] = loaderPayload[routeId].data;
10203
- }
10204
- }
10205
- if (actionPayload) {
10206
- // @ts-expect-error - TODO: Fix types and don't get it off the window directly
10207
- const actionId = window.__remixContext.serverHandoffActionId;
10208
- if ("error" in actionPayload) {
10209
- state.errors = state.errors || {};
10210
- state.errors[actionId] = actionPayload.error;
10211
- } else if ("data" in actionPayload) {
10212
- state.actionData = state.actionData || {};
10213
- state.actionData[actionId] = actionPayload.data;
10214
- }
10215
- }
10216
- ssrInfo.context.state = state;
10217
- localSsrInfo.stateDecodingPromise.value = true;
10218
- }).catch(e => {
10219
- localSsrInfo.stateDecodingPromise.error = e;
10220
- });
10221
- } else {
10222
- ssrInfo.stateDecodingPromise = decodeViaTurboStream(stream, window).then(value => {
10223
- ssrInfo.context.state = value.value;
10224
- localSsrInfo.stateDecodingPromise.value = true;
10225
- }).catch(e => {
10226
- localSsrInfo.stateDecodingPromise.error = e;
10227
- });
10228
- }
10166
+ ssrInfo.stateDecodingPromise = decodeViaTurboStream(stream, window).then(value => {
10167
+ ssrInfo.context.state = value.value;
10168
+ localSsrInfo.stateDecodingPromise.value = true;
10169
+ }).catch(e => {
10170
+ localSsrInfo.stateDecodingPromise.error = e;
10171
+ });
10229
10172
  }
10230
10173
  if (ssrInfo.stateDecodingPromise.error) {
10231
10174
  throw ssrInfo.stateDecodingPromise.error;
@@ -10440,18 +10383,11 @@ function RemixServer({
10440
10383
  router: router,
10441
10384
  context: context.staticHandlerContext,
10442
10385
  hydrate: false
10443
- }))), context.serverHandoffStreamAction ? /*#__PURE__*/React.createElement(React.Suspense, null, /*#__PURE__*/React.createElement(StreamTransfer, {
10444
- context: context,
10445
- identifier: 0,
10446
- reader: context.serverHandoffStreamAction.getReader(),
10447
- textDecoder: new TextDecoder(),
10448
- isAction: true
10449
- })) : null, context.serverHandoffStream ? /*#__PURE__*/React.createElement(React.Suspense, null, /*#__PURE__*/React.createElement(StreamTransfer, {
10386
+ }))), context.serverHandoffStream ? /*#__PURE__*/React.createElement(React.Suspense, null, /*#__PURE__*/React.createElement(StreamTransfer, {
10450
10387
  context: context,
10451
10388
  identifier: 0,
10452
10389
  reader: context.serverHandoffStream.getReader(),
10453
- textDecoder: new TextDecoder(),
10454
- isAction: false
10390
+ textDecoder: new TextDecoder()
10455
10391
  })) : null);
10456
10392
  }
10457
10393
 
@@ -10468,8 +10404,7 @@ function createRemixStub(routes, context = {}) {
10468
10404
  remixContextRef.current = {
10469
10405
  future: {
10470
10406
  v3_fetcherPersist: future?.v3_fetcherPersist === true,
10471
- v3_relativeSplatPath: future?.v3_relativeSplatPath === true,
10472
- unstable_serverComponents: future?.unstable_serverComponents === true
10407
+ v3_relativeSplatPath: future?.v3_relativeSplatPath === true
10473
10408
  },
10474
10409
  manifest: {
10475
10410
  routes: {},