@remix-run/server-runtime
Advanced tools
Comparing version 0.0.0-nightly-5fb59ccb4-20240730 to 0.0.0-nightly-5ffb6f5c2-20241121
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -37,3 +37,3 @@ * Copyright (c) Remix Software Inc. | ||
let result = await action({ | ||
request: stripDataParam(stripIndexParam(request)), | ||
request: singleFetch ? stripRoutesParam(stripIndexParam(request)) : stripDataParam(stripIndexParam(request)), | ||
context: loadContext, | ||
@@ -61,3 +61,3 @@ params | ||
let result = await loader({ | ||
request: stripDataParam(stripIndexParam(request)), | ||
request: singleFetch ? stripRoutesParam(stripIndexParam(request)) : stripDataParam(stripIndexParam(request)), | ||
context: loadContext, | ||
@@ -126,4 +126,18 @@ params | ||
} | ||
function stripRoutesParam(request) { | ||
let url = new URL(request.url); | ||
url.searchParams.delete("_routes"); | ||
let init = { | ||
method: request.method, | ||
body: request.body, | ||
headers: request.headers, | ||
signal: request.signal | ||
}; | ||
if (init.body) { | ||
init.duplex = "half"; | ||
} | ||
return new Request(url.href, init); | ||
} | ||
exports.callRouteAction = callRouteAction; | ||
exports.callRouteLoader = callRouteLoader; |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -16,5 +16,5 @@ * Copyright (c) Remix Software Inc. | ||
function resourceRouteJsonWarning(type, routeId) { | ||
return "⚠️ REMIX FUTURE CHANGE: Resource routes will no longer be able to " + "return raw JavaScript objects in v3 when Single Fetch becomes the default. " + "You can prepare for this change at your convenience by wrapping the data " + `returned from your \`${type}\` function in the \`${routeId}\` route with ` + "`json()`. For instructions on making this change see " + "https://remix.run/docs/en/v2.9.2/guides/single-fetch#resource-routes"; | ||
return "⚠️ REMIX FUTURE CHANGE: Externally-accessed resource routes will no longer be " + "able to return raw JavaScript objects or `null` in React Router v7 when " + "Single Fetch becomes the default. You can prepare for this change at your " + `convenience by wrapping the data returned from your \`${type}\` function in ` + `the \`${routeId}\` route with \`json()\`. For instructions on making this ` + "change, see https://remix.run/docs/en/v2.13.1/guides/single-fetch#resource-routes"; | ||
} | ||
exports.resourceRouteJsonWarning = resourceRouteJsonWarning; |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -30,4 +30,4 @@ import type { StaticHandlerContext } from "@remix-run/router"; | ||
v3_throwAbortReason: boolean; | ||
unstable_lazyRouteDiscovery: boolean; | ||
unstable_singleFetch: boolean; | ||
v3_lazyRouteDiscovery: boolean; | ||
v3_singleFetch: boolean; | ||
} | ||
@@ -34,0 +34,0 @@ export interface AssetsManifest { |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -33,3 +33,3 @@ * Copyright (c) Remix Software Inc. | ||
let result = await action({ | ||
request: stripDataParam(stripIndexParam(request)), | ||
request: singleFetch ? stripRoutesParam(stripIndexParam(request)) : stripDataParam(stripIndexParam(request)), | ||
context: loadContext, | ||
@@ -57,3 +57,3 @@ params | ||
let result = await loader({ | ||
request: stripDataParam(stripIndexParam(request)), | ||
request: singleFetch ? stripRoutesParam(stripIndexParam(request)) : stripDataParam(stripIndexParam(request)), | ||
context: loadContext, | ||
@@ -122,3 +122,17 @@ params | ||
} | ||
function stripRoutesParam(request) { | ||
let url = new URL(request.url); | ||
url.searchParams.delete("_routes"); | ||
let init = { | ||
method: request.method, | ||
body: request.body, | ||
headers: request.headers, | ||
signal: request.signal | ||
}; | ||
if (init.body) { | ||
init.duplex = "half"; | ||
} | ||
return new Request(url.href, init); | ||
} | ||
export { callRouteAction, callRouteLoader }; |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -12,5 +12,5 @@ * Copyright (c) Remix Software Inc. | ||
function resourceRouteJsonWarning(type, routeId) { | ||
return "⚠️ REMIX FUTURE CHANGE: Resource routes will no longer be able to " + "return raw JavaScript objects in v3 when Single Fetch becomes the default. " + "You can prepare for this change at your convenience by wrapping the data " + `returned from your \`${type}\` function in the \`${routeId}\` route with ` + "`json()`. For instructions on making this change see " + "https://remix.run/docs/en/v2.9.2/guides/single-fetch#resource-routes"; | ||
return "⚠️ REMIX FUTURE CHANGE: Externally-accessed resource routes will no longer be " + "able to return raw JavaScript objects or `null` in React Router v7 when " + "Single Fetch becomes the default. You can prepare for this change at your " + `convenience by wrapping the data returned from your \`${type}\` function in ` + `the \`${routeId}\` route with \`json()\`. For instructions on making this ` + "change, see https://remix.run/docs/en/v2.13.1/guides/single-fetch#resource-routes"; | ||
} | ||
export { resourceRouteJsonWarning }; |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -14,3 +14,3 @@ * Copyright (c) Remix Software Inc. | ||
export { defer, json, redirect, redirectDocument, replace } from './responses.js'; | ||
export { SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, data as unstable_data, defineAction as unstable_defineAction, defineLoader as unstable_defineLoader } from './single-fetch.js'; | ||
export { SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, data } from './single-fetch.js'; | ||
export { createRequestHandler } from './server.js'; | ||
@@ -17,0 +17,0 @@ export { createSession, createSessionStorageFactory, isSession } from './sessions.js'; |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -21,2 +21,7 @@ * Copyright (c) Remix Software Inc. | ||
* | ||
* @deprecated This utility is deprecated in favor of opting into Single Fetch | ||
* via `future.v3_singleFetch` and returning raw objects. This method will be | ||
* removed in React Router v7. If you need to return a JSON Response, you can | ||
* use `Response.json()`. | ||
* | ||
* @see https://remix.run/utils/json | ||
@@ -31,2 +36,6 @@ */ | ||
* | ||
* @deprecated This utility is deprecated in favor of opting into Single Fetch | ||
* via `future.v3_singleFetch` and returning raw objects. This method will be | ||
* removed in React Router v7. | ||
* | ||
* @see https://remix.run/utils/defer | ||
@@ -33,0 +42,0 @@ */ |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -56,3 +56,3 @@ * Copyright (c) Remix Software Inc. | ||
routeId: route.id, | ||
singleFetch: future.unstable_singleFetch === true | ||
singleFetch: future.v3_singleFetch === true | ||
}) : undefined, | ||
@@ -65,3 +65,3 @@ action: route.module.action ? (args, dataStrategyCtx) => callRouteAction({ | ||
routeId: route.id, | ||
singleFetch: future.unstable_singleFetch === true | ||
singleFetch: future.v3_singleFetch === true | ||
}) : undefined, | ||
@@ -68,0 +68,0 @@ handle: route.module.handle |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -110,3 +110,3 @@ * Copyright (c) Remix Software Inc. | ||
if (url.searchParams.has("_data")) { | ||
if (_build.future.unstable_singleFetch) { | ||
if (_build.future.v3_singleFetch) { | ||
handleError(new Error("Warning: Single fetch-enabled apps should not be making ?_data requests, " + "this is likely to break in the future")); | ||
@@ -126,3 +126,3 @@ } | ||
} | ||
} else if (_build.future.unstable_singleFetch && url.pathname.endsWith(".data")) { | ||
} else if (_build.future.v3_singleFetch && url.pathname.endsWith(".data")) { | ||
let handlerUrl = new URL(request.url); | ||
@@ -139,3 +139,3 @@ handlerUrl.pathname = handlerUrl.pathname.replace(/\.data$/, "").replace(/^\/_root$/, "/"); | ||
if (isRedirectResponse(response)) { | ||
let result = getSingleFetchRedirect(response.status, response.headers); | ||
let result = getSingleFetchRedirect(response.status, response.headers, _build.basename); | ||
if (request.method === "GET") { | ||
@@ -147,3 +147,3 @@ result = { | ||
let headers = new Headers(response.headers); | ||
headers.set("Content-Type", "text/x-turbo"); | ||
headers.set("Content-Type", "text/x-script"); | ||
return new Response(encodeViaTurboStream(result, request.signal, _build.entry.module.streamTimeout, serverMode), { | ||
@@ -173,6 +173,3 @@ status: SINGLE_FETCH_REDIRECT_STATUS, | ||
async function handleManifestRequest(build, routes, url) { | ||
let data = { | ||
patches: {}, | ||
notFoundPaths: [] | ||
}; | ||
let patches = {}; | ||
if (url.searchParams.has("p")) { | ||
@@ -184,9 +181,7 @@ for (let path of url.searchParams.getAll("p")) { | ||
let routeId = match.route.id; | ||
data.patches[routeId] = build.assets.routes[routeId]; | ||
patches[routeId] = build.assets.routes[routeId]; | ||
} | ||
} else { | ||
data.notFoundPaths.push(path); | ||
} | ||
} | ||
return json(data, { | ||
return json(patches, { | ||
headers: { | ||
@@ -257,4 +252,17 @@ "Cache-Control": "public, max-age=31536000, immutable" | ||
resultHeaders.set("X-Remix-Response", "yes"); | ||
resultHeaders.set("Content-Type", "text/x-turbo"); | ||
// 304 responses should not have a body | ||
if (status === 304) { | ||
return new Response(null, { | ||
status: 304, | ||
headers: resultHeaders | ||
}); | ||
} | ||
// We use a less-descriptive `text/x-script` here instead of something like | ||
// `text/x-turbo` to enable compression when deployed via Cloudflare. See: | ||
// - https://github.com/remix-run/remix/issues/9884 | ||
// - https://developers.cloudflare.com/speed/optimization/content/brotli/content-compression/ | ||
resultHeaders.set("Content-Type", "text/x-script"); | ||
// Note: Deferred data is already just Promises, so we don't have to mess | ||
@@ -284,2 +292,10 @@ // `activeDeferreds` or anything :) | ||
// 304 responses should not have a body or a content-type | ||
if (context.statusCode === 304) { | ||
return new Response(null, { | ||
status: 304, | ||
headers | ||
}); | ||
} | ||
// Sanitize errors outside of development environments | ||
@@ -310,3 +326,2 @@ if (context.errors) { | ||
serverHandoffString: createServerHandoffString({ | ||
ssrMatches: context.matches.map(m => m.route.id), | ||
basename: build.basename, | ||
@@ -316,7 +331,7 @@ criticalCss, | ||
isSpaMode: build.isSpaMode, | ||
...(!build.future.unstable_singleFetch ? { | ||
...(!build.future.v3_singleFetch ? { | ||
state | ||
} : null) | ||
}), | ||
...(build.future.unstable_singleFetch ? { | ||
...(build.future.v3_singleFetch ? { | ||
serverHandoffStream: encodeViaTurboStream(state, request.signal, build.entry.module.streamTimeout, serverMode), | ||
@@ -368,11 +383,10 @@ renderMeta: {} | ||
serverHandoffString: createServerHandoffString({ | ||
ssrMatches: context.matches.map(m => m.route.id), | ||
basename: build.basename, | ||
future: build.future, | ||
isSpaMode: build.isSpaMode, | ||
...(!build.future.unstable_singleFetch ? { | ||
...(!build.future.v3_singleFetch ? { | ||
state | ||
} : null) | ||
}), | ||
...(build.future.unstable_singleFetch ? { | ||
...(build.future.v3_singleFetch ? { | ||
serverHandoffStream: encodeViaTurboStream(state, request.signal, build.entry.module.streamTimeout, serverMode), | ||
@@ -402,3 +416,3 @@ renderMeta: {} | ||
} | ||
if (build.future.unstable_singleFetch && !isResponse(response)) { | ||
if (build.future.v3_singleFetch && !isResponse(response)) { | ||
console.warn(resourceRouteJsonWarning(request.method === "GET" ? "loader" : "action", routeId)); | ||
@@ -405,0 +419,0 @@ response = json(response); |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -11,5 +11,5 @@ * Copyright (c) Remix Software Inc. | ||
*/ | ||
import { unstable_data, UNSAFE_ErrorResponseImpl, isRouteErrorResponse } from '@remix-run/router'; | ||
import { data as data$1, isRouteErrorResponse, stripBasename, UNSAFE_ErrorResponseImpl } from '@remix-run/router'; | ||
import { encode } from 'turbo-stream'; | ||
import { sanitizeError, sanitizeErrors } from './errors.js'; | ||
import { sanitizeErrors, sanitizeError } from './errors.js'; | ||
import { getDocumentHeaders } from './headers.js'; | ||
@@ -36,19 +36,11 @@ import { ServerMode } from './mode.js'; | ||
if (isActionDataRequest && request.method === "GET") { | ||
return await Promise.all(matches.map(m => m.resolve(async () => ({ | ||
type: "data", | ||
result: null | ||
})))); | ||
return {}; | ||
} | ||
let results = await Promise.all(matches.map(async match => { | ||
let result = await match.resolve(async handler => { | ||
// Only run opt-in loaders when fine-grained revalidation is enabled | ||
let data = loadRouteIds && !loadRouteIds.includes(match.route.id) ? null : await handler(); | ||
return { | ||
type: "data", | ||
result: data | ||
}; | ||
}); | ||
return result; | ||
})); | ||
return results; | ||
// Only run opt-in loaders when fine-grained revalidation is enabled | ||
let matchesToLoad = loadRouteIds ? matches.filter(m => loadRouteIds.includes(m.route.id)) : matches; | ||
let results = await Promise.all(matchesToLoad.map(match => match.resolve())); | ||
return results.reduce((acc, result, i) => Object.assign(acc, { | ||
[matchesToLoad[i].route.id]: result | ||
}), {}); | ||
}; | ||
@@ -70,3 +62,3 @@ } | ||
skipLoaderErrorBubbling: true, | ||
unstable_dataStrategy: getSingleFetchDataStrategy({ | ||
dataStrategy: getSingleFetchDataStrategy({ | ||
isActionDataRequest: true | ||
@@ -80,3 +72,3 @@ }) | ||
return { | ||
result: getSingleFetchRedirect(result.status, result.headers), | ||
result: getSingleFetchRedirect(result.status, result.headers, build.basename), | ||
headers: result.headers, | ||
@@ -90,3 +82,3 @@ status: SINGLE_FETCH_REDIRECT_STATUS | ||
return { | ||
result: getSingleFetchRedirect(context.statusCode, headers), | ||
result: getSingleFetchRedirect(context.statusCode, headers, build.basename), | ||
headers, | ||
@@ -145,3 +137,3 @@ status: SINGLE_FETCH_REDIRECT_STATUS | ||
skipLoaderErrorBubbling: true, | ||
unstable_dataStrategy: getSingleFetchDataStrategy({ | ||
dataStrategy: getSingleFetchDataStrategy({ | ||
loadRouteIds | ||
@@ -153,3 +145,3 @@ }) | ||
result: { | ||
[SingleFetchRedirectSymbol]: getSingleFetchRedirect(result.status, result.headers) | ||
[SingleFetchRedirectSymbol]: getSingleFetchRedirect(result.status, result.headers, build.basename) | ||
}, | ||
@@ -165,3 +157,3 @@ headers: result.headers, | ||
result: { | ||
[SingleFetchRedirectSymbol]: getSingleFetchRedirect(context.statusCode, headers) | ||
[SingleFetchRedirectSymbol]: getSingleFetchRedirect(context.statusCode, headers, build.basename) | ||
}, | ||
@@ -221,5 +213,9 @@ headers, | ||
} | ||
function getSingleFetchRedirect(status, headers) { | ||
function getSingleFetchRedirect(status, headers, basename) { | ||
let redirect = headers.get("Location"); | ||
if (basename) { | ||
redirect = stripBasename(redirect, basename) || redirect; | ||
} | ||
return { | ||
redirect: headers.get("Location"), | ||
redirect, | ||
status, | ||
@@ -277,18 +273,17 @@ revalidate: | ||
} | ||
}] | ||
}], | ||
postPlugins: [value => { | ||
if (!value) return; | ||
if (typeof value !== "object") return; | ||
return ["SingleFetchClassInstance", Object.fromEntries(Object.entries(value))]; | ||
}, () => ["SingleFetchFallback"]] | ||
}); | ||
} | ||
function data(value, init) { | ||
return unstable_data(value, init); | ||
return data$1(value, init); | ||
} | ||
// Backwards-compatible type for Remix v2 where json/defer still use the old types, | ||
// and only non-json/defer returns use the new types. This allows for incremental | ||
// migration of loaders to return naked objects. In the next major version, | ||
// json/defer will be removed so everything will use the new simplified typings. | ||
// prettier-ignore | ||
// eslint-disable-next-line | ||
let defineLoader = loader => loader; | ||
let defineAction = action => action; | ||
export { SINGLE_FETCH_REDIRECT_STATUS, SingleFetchRedirectSymbol, data, defineAction, defineLoader, encodeViaTurboStream, getSingleFetchDataStrategy, getSingleFetchRedirect, singleFetchAction, singleFetchLoaders }; | ||
export { SINGLE_FETCH_REDIRECT_STATUS, SingleFetchRedirectSymbol, data, encodeViaTurboStream, getSingleFetchDataStrategy, getSingleFetchRedirect, singleFetchAction, singleFetchLoaders }; |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
export { createCookieFactory, isCookie } from "./cookies"; | ||
export { composeUploadHandlers as unstable_composeUploadHandlers, parseMultipartFormData as unstable_parseMultipartFormData, } from "./formData"; | ||
export { defer, json, redirect, redirectDocument, replace } from "./responses"; | ||
export { SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, data as unstable_data, defineLoader as unstable_defineLoader, defineAction as unstable_defineAction, } from "./single-fetch"; | ||
export type { Loader as unstable_Loader, Action as unstable_Action, Serialize as unstable_Serialize, SingleFetchResult as UNSAFE_SingleFetchResult, SingleFetchResults as UNSAFE_SingleFetchResults, } from "./single-fetch"; | ||
export { SingleFetchRedirectSymbol as UNSAFE_SingleFetchRedirectSymbol, data, } from "./single-fetch"; | ||
export type { SingleFetchResult as UNSAFE_SingleFetchResult, SingleFetchResults as UNSAFE_SingleFetchResults, } from "./single-fetch"; | ||
export { createRequestHandler } from "./server"; | ||
@@ -14,2 +14,3 @@ export { createSession, createSessionStorageFactory, isSession, } from "./sessions"; | ||
export type { CreateCookieFunction, CreateCookieSessionStorageFunction, CreateMemorySessionStorageFunction, CreateRequestHandlerFunction, CreateSessionFunction, CreateSessionStorageFunction, IsCookieFunction, IsSessionFunction, JsonFunction, RedirectFunction, } from "./interface"; | ||
export type { Future } from "./future"; | ||
export type { ActionFunction, ActionFunctionArgs, AppLoadContext, Cookie, CookieOptions, CookieParseOptions, CookieSerializeOptions, CookieSignatureOptions, DataFunctionArgs, EntryContext, ErrorResponse, FlashSessionData, HandleDataRequestFunction, HandleDocumentRequestFunction, HeadersArgs, HeadersFunction, HtmlLinkDescriptor, LinkDescriptor, LinksFunction, LoaderFunction, LoaderFunctionArgs, MemoryUploadHandlerFilterArgs, MemoryUploadHandlerOptions, HandleErrorFunction, PageLinkDescriptor, RequestHandler, SerializeFrom, ServerBuild, ServerEntryModule, ServerRuntimeMetaArgs, ServerRuntimeMetaDescriptor, ServerRuntimeMetaFunction, Session, SessionData, SessionIdStorageStrategy, SessionStorage, SignFunction, TypedDeferredData, TypedResponse, UnsignFunction, UploadHandler, UploadHandlerPart, } from "./reexport"; |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -39,5 +39,3 @@ * Copyright (c) Remix Software Inc. | ||
exports.UNSAFE_SingleFetchRedirectSymbol = singleFetch.SingleFetchRedirectSymbol; | ||
exports.unstable_data = singleFetch.data; | ||
exports.unstable_defineAction = singleFetch.defineAction; | ||
exports.unstable_defineLoader = singleFetch.defineLoader; | ||
exports.data = singleFetch.data; | ||
exports.createRequestHandler = server.createRequestHandler; | ||
@@ -44,0 +42,0 @@ exports.createSession = sessions.createSession; |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
export type { ErrorResponse } from "@remix-run/router"; | ||
export type { HandleDataRequestFunction, HandleDocumentRequestFunction, HandleErrorFunction, ServerBuild, ServerEntryModule, } from "./build"; | ||
export type { Future } from "./future"; | ||
export type { UploadHandlerPart, UploadHandler } from "./formData"; | ||
@@ -4,0 +5,0 @@ export type { MemoryUploadHandlerOptions, MemoryUploadHandlerFilterArgs, } from "./upload/memoryUploadHandler"; |
@@ -17,2 +17,7 @@ import { type UNSAFE_DeferredData as DeferredData } from "@remix-run/router"; | ||
* | ||
* @deprecated This utility is deprecated in favor of opting into Single Fetch | ||
* via `future.v3_singleFetch` and returning raw objects. This method will be | ||
* removed in React Router v7. If you need to return a JSON Response, you can | ||
* use `Response.json()`. | ||
* | ||
* @see https://remix.run/utils/json | ||
@@ -24,2 +29,6 @@ */ | ||
* | ||
* @deprecated This utility is deprecated in favor of opting into Single Fetch | ||
* via `future.v3_singleFetch` and returning raw objects. This method will be | ||
* removed in React Router v7. | ||
* | ||
* @see https://remix.run/utils/defer | ||
@@ -26,0 +35,0 @@ */ |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -25,2 +25,7 @@ * Copyright (c) Remix Software Inc. | ||
* | ||
* @deprecated This utility is deprecated in favor of opting into Single Fetch | ||
* via `future.v3_singleFetch` and returning raw objects. This method will be | ||
* removed in React Router v7. If you need to return a JSON Response, you can | ||
* use `Response.json()`. | ||
* | ||
* @see https://remix.run/utils/json | ||
@@ -35,2 +40,6 @@ */ | ||
* | ||
* @deprecated This utility is deprecated in favor of opting into Single Fetch | ||
* via `future.v3_singleFetch` and returning raw objects. This method will be | ||
* removed in React Router v7. | ||
* | ||
* @see https://remix.run/utils/defer | ||
@@ -37,0 +46,0 @@ */ |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -60,3 +60,3 @@ * Copyright (c) Remix Software Inc. | ||
routeId: route.id, | ||
singleFetch: future.unstable_singleFetch === true | ||
singleFetch: future.v3_singleFetch === true | ||
}) : undefined, | ||
@@ -69,3 +69,3 @@ action: route.module.action ? (args, dataStrategyCtx) => data.callRouteAction({ | ||
routeId: route.id, | ||
singleFetch: future.unstable_singleFetch === true | ||
singleFetch: future.v3_singleFetch === true | ||
}) : undefined, | ||
@@ -72,0 +72,0 @@ handle: route.module.handle |
import type { Jsonify } from "./jsonify"; | ||
import type { TypedDeferredData, TypedResponse } from "./responses"; | ||
import type { ClientActionFunctionArgs, ClientLoaderFunctionArgs } from "./routeModules"; | ||
import { type SerializeFrom as SingleFetch_SerializeFrom } from "./single-fetch"; | ||
import type { Future } from "./future"; | ||
type SingleFetchEnabled = Future extends { | ||
v3_singleFetch: infer T extends boolean; | ||
} ? T : false; | ||
/** | ||
@@ -11,4 +16,9 @@ * Infer JSON serialized data type returned by a loader or action, while | ||
* `type LoaderData = SerializeFrom<typeof loader>` | ||
* | ||
* @deprecated SerializeFrom is deprecated and will be removed in React Router | ||
* v7. Please use the generics on `useLoaderData`/etc. instead of manually | ||
* deserializing in Remix v2. You can convert to the generated types once you | ||
* migrate to React Router v7. | ||
*/ | ||
export type SerializeFrom<T> = T extends (...args: any[]) => infer Output ? Parameters<T> extends [ClientLoaderFunctionArgs | ClientActionFunctionArgs] ? SerializeClient<Awaited<Output>> : Serialize<Awaited<Output>> : Jsonify<Awaited<T>>; | ||
export type SerializeFrom<T> = SingleFetchEnabled extends true ? SingleFetch_SerializeFrom<T> : T extends (...args: any[]) => infer Output ? Parameters<T> extends [ClientLoaderFunctionArgs | ClientActionFunctionArgs] ? SerializeClient<Awaited<Output>> : Serialize<Awaited<Output>> : Jsonify<Awaited<T>>; | ||
type SerializeClient<Output> = Output extends TypedDeferredData<infer U> ? { | ||
@@ -15,0 +25,0 @@ [K in keyof U as K extends symbol ? never : Promise<any> extends U[K] ? K : never]: DeferValueClient<U[K]>; |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -114,3 +114,3 @@ * Copyright (c) Remix Software Inc. | ||
if (url.searchParams.has("_data")) { | ||
if (_build.future.unstable_singleFetch) { | ||
if (_build.future.v3_singleFetch) { | ||
handleError(new Error("Warning: Single fetch-enabled apps should not be making ?_data requests, " + "this is likely to break in the future")); | ||
@@ -130,3 +130,3 @@ } | ||
} | ||
} else if (_build.future.unstable_singleFetch && url.pathname.endsWith(".data")) { | ||
} else if (_build.future.v3_singleFetch && url.pathname.endsWith(".data")) { | ||
let handlerUrl = new URL(request.url); | ||
@@ -143,3 +143,3 @@ handlerUrl.pathname = handlerUrl.pathname.replace(/\.data$/, "").replace(/^\/_root$/, "/"); | ||
if (responses.isRedirectResponse(response)) { | ||
let result = singleFetch.getSingleFetchRedirect(response.status, response.headers); | ||
let result = singleFetch.getSingleFetchRedirect(response.status, response.headers, _build.basename); | ||
if (request.method === "GET") { | ||
@@ -151,3 +151,3 @@ result = { | ||
let headers = new Headers(response.headers); | ||
headers.set("Content-Type", "text/x-turbo"); | ||
headers.set("Content-Type", "text/x-script"); | ||
return new Response(singleFetch.encodeViaTurboStream(result, request.signal, _build.entry.module.streamTimeout, serverMode), { | ||
@@ -177,6 +177,3 @@ status: singleFetch.SINGLE_FETCH_REDIRECT_STATUS, | ||
async function handleManifestRequest(build, routes, url) { | ||
let data = { | ||
patches: {}, | ||
notFoundPaths: [] | ||
}; | ||
let patches = {}; | ||
if (url.searchParams.has("p")) { | ||
@@ -188,9 +185,7 @@ for (let path of url.searchParams.getAll("p")) { | ||
let routeId = match.route.id; | ||
data.patches[routeId] = build.assets.routes[routeId]; | ||
patches[routeId] = build.assets.routes[routeId]; | ||
} | ||
} else { | ||
data.notFoundPaths.push(path); | ||
} | ||
} | ||
return responses.json(data, { | ||
return responses.json(patches, { | ||
headers: { | ||
@@ -261,4 +256,17 @@ "Cache-Control": "public, max-age=31536000, immutable" | ||
resultHeaders.set("X-Remix-Response", "yes"); | ||
resultHeaders.set("Content-Type", "text/x-turbo"); | ||
// 304 responses should not have a body | ||
if (status === 304) { | ||
return new Response(null, { | ||
status: 304, | ||
headers: resultHeaders | ||
}); | ||
} | ||
// We use a less-descriptive `text/x-script` here instead of something like | ||
// `text/x-turbo` to enable compression when deployed via Cloudflare. See: | ||
// - https://github.com/remix-run/remix/issues/9884 | ||
// - https://developers.cloudflare.com/speed/optimization/content/brotli/content-compression/ | ||
resultHeaders.set("Content-Type", "text/x-script"); | ||
// Note: Deferred data is already just Promises, so we don't have to mess | ||
@@ -288,2 +296,10 @@ // `activeDeferreds` or anything :) | ||
// 304 responses should not have a body or a content-type | ||
if (context.statusCode === 304) { | ||
return new Response(null, { | ||
status: 304, | ||
headers: headers$1 | ||
}); | ||
} | ||
// Sanitize errors outside of development environments | ||
@@ -314,3 +330,2 @@ if (context.errors) { | ||
serverHandoffString: serverHandoff.createServerHandoffString({ | ||
ssrMatches: context.matches.map(m => m.route.id), | ||
basename: build.basename, | ||
@@ -320,7 +335,7 @@ criticalCss, | ||
isSpaMode: build.isSpaMode, | ||
...(!build.future.unstable_singleFetch ? { | ||
...(!build.future.v3_singleFetch ? { | ||
state | ||
} : null) | ||
}), | ||
...(build.future.unstable_singleFetch ? { | ||
...(build.future.v3_singleFetch ? { | ||
serverHandoffStream: singleFetch.encodeViaTurboStream(state, request.signal, build.entry.module.streamTimeout, serverMode), | ||
@@ -372,11 +387,10 @@ renderMeta: {} | ||
serverHandoffString: serverHandoff.createServerHandoffString({ | ||
ssrMatches: context.matches.map(m => m.route.id), | ||
basename: build.basename, | ||
future: build.future, | ||
isSpaMode: build.isSpaMode, | ||
...(!build.future.unstable_singleFetch ? { | ||
...(!build.future.v3_singleFetch ? { | ||
state | ||
} : null) | ||
}), | ||
...(build.future.unstable_singleFetch ? { | ||
...(build.future.v3_singleFetch ? { | ||
serverHandoffStream: singleFetch.encodeViaTurboStream(state, request.signal, build.entry.module.streamTimeout, serverMode), | ||
@@ -406,3 +420,3 @@ renderMeta: {} | ||
} | ||
if (build.future.unstable_singleFetch && !responses.isResponse(response)) { | ||
if (build.future.v3_singleFetch && !responses.isResponse(response)) { | ||
console.warn(deprecations.resourceRouteJsonWarning(request.method === "GET" ? "loader" : "action", routeId)); | ||
@@ -409,0 +423,0 @@ response = responses.json(response); |
@@ -7,3 +7,2 @@ import type { HydrationState } from "@remix-run/router"; | ||
criticalCss?: string; | ||
ssrMatches: string[]; | ||
basename: string | undefined; | ||
@@ -10,0 +9,0 @@ future: FutureConfig; |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
@@ -1,2 +0,2 @@ | ||
import type { StaticHandler, unstable_DataStrategyFunction as DataStrategyFunction } from "@remix-run/router"; | ||
import type { StaticHandler, DataStrategyFunction, UNSAFE_DataWithResponseInit as DataWithResponseInit } from "@remix-run/router"; | ||
import type { ServerBuild } from "./build"; | ||
@@ -6,4 +6,4 @@ import type { AppLoadContext } from "./data"; | ||
import type { TypedDeferredData, TypedResponse } from "./responses"; | ||
import type { ActionFunctionArgs, LoaderFunctionArgs } from "./routeModules"; | ||
import type { SerializeFrom } from "./serialize"; | ||
import type { Jsonify } from "./jsonify"; | ||
import type { ClientActionFunctionArgs, ClientLoaderFunctionArgs } from "./routeModules"; | ||
export declare const SingleFetchRedirectSymbol: unique symbol; | ||
@@ -41,15 +41,14 @@ type SingleFetchRedirectResult = { | ||
}>; | ||
export declare function getSingleFetchRedirect(status: number, headers: Headers): SingleFetchRedirectResult; | ||
export declare function getSingleFetchRedirect(status: number, headers: Headers, basename: string | undefined): SingleFetchRedirectResult; | ||
export declare function encodeViaTurboStream(data: any, requestSignal: AbortSignal, streamTimeout: number | undefined, serverMode: ServerMode): ReadableStream<Uint8Array>; | ||
export declare function data(value: Serializable, init?: number | ResponseInit): import("@remix-run/router/dist/utils").DataWithResponseInit<Serializable>; | ||
type MaybePromise<T> = T | Promise<T>; | ||
type Serializable = undefined | null | boolean | string | symbol | number | Array<Serializable> | { | ||
export declare function data<T>(value: T, init?: number | ResponseInit): DataWithResponseInit<T>; | ||
type Serializable = undefined | null | boolean | string | symbol | number | bigint | Date | URL | RegExp | Error | ReadonlyArray<Serializable> | Array<Serializable> | { | ||
[key: PropertyKey]: Serializable; | ||
} | bigint | Date | URL | RegExp | Error | Map<Serializable, Serializable> | Set<Serializable> | Promise<Serializable>; | ||
type DataFunctionReturnValue = Serializable | TypedDeferredData<Record<string, unknown>> | TypedResponse<Record<string, unknown>>; | ||
export type Serialize<T extends Loader | Action> = Awaited<ReturnType<T>> extends TypedDeferredData<infer D> ? D : Awaited<ReturnType<T>> extends TypedResponse<Record<string, unknown>> ? SerializeFrom<T> : Awaited<ReturnType<T>>; | ||
export type Loader = (args: LoaderFunctionArgs) => MaybePromise<DataFunctionReturnValue>; | ||
export declare let defineLoader: <T extends Loader>(loader: T) => T; | ||
export type Action = (args: ActionFunctionArgs) => MaybePromise<DataFunctionReturnValue>; | ||
export declare let defineAction: <T extends Action>(action: T) => T; | ||
} | Map<Serializable, Serializable> | Set<Serializable> | Promise<Serializable>; | ||
type Serialize<T> = T extends void ? undefined : T extends Serializable ? T : T extends (...args: any[]) => unknown ? undefined : T extends Promise<infer U> ? Promise<Serialize<U>> : T extends Map<infer K, infer V> ? Map<Serialize<K>, Serialize<V>> : T extends Set<infer U> ? Set<Serialize<U>> : T extends [] ? [] : T extends readonly [infer F, ...infer R] ? [Serialize<F>, ...Serialize<R>] : T extends Array<infer U> ? Array<Serialize<U>> : T extends readonly unknown[] ? readonly Serialize<T[number]>[] : T extends Record<any, any> ? { | ||
[K in keyof T]: Serialize<T[K]>; | ||
} : undefined; | ||
type ClientData<T> = T extends TypedResponse<infer U> ? Jsonify<U> : T extends TypedDeferredData<infer U> ? U : T; | ||
type ServerData<T> = T extends TypedResponse<infer U> ? Jsonify<U> : T extends TypedDeferredData<infer U> ? Serialize<U> : T extends DataWithResponseInit<infer U> ? Serialize<U> : Serialize<T>; | ||
export type SerializeFrom<T> = T extends (...args: infer Args) => infer Return ? Args extends [ClientLoaderFunctionArgs | ClientActionFunctionArgs] ? ClientData<Awaited<Return>> : ServerData<Awaited<Return>> : T; | ||
export {}; |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -39,19 +39,11 @@ * Copyright (c) Remix Software Inc. | ||
if (isActionDataRequest && request.method === "GET") { | ||
return await Promise.all(matches.map(m => m.resolve(async () => ({ | ||
type: "data", | ||
result: null | ||
})))); | ||
return {}; | ||
} | ||
let results = await Promise.all(matches.map(async match => { | ||
let result = await match.resolve(async handler => { | ||
// Only run opt-in loaders when fine-grained revalidation is enabled | ||
let data = loadRouteIds && !loadRouteIds.includes(match.route.id) ? null : await handler(); | ||
return { | ||
type: "data", | ||
result: data | ||
}; | ||
}); | ||
return result; | ||
})); | ||
return results; | ||
// Only run opt-in loaders when fine-grained revalidation is enabled | ||
let matchesToLoad = loadRouteIds ? matches.filter(m => loadRouteIds.includes(m.route.id)) : matches; | ||
let results = await Promise.all(matchesToLoad.map(match => match.resolve())); | ||
return results.reduce((acc, result, i) => Object.assign(acc, { | ||
[matchesToLoad[i].route.id]: result | ||
}), {}); | ||
}; | ||
@@ -73,3 +65,3 @@ } | ||
skipLoaderErrorBubbling: true, | ||
unstable_dataStrategy: getSingleFetchDataStrategy({ | ||
dataStrategy: getSingleFetchDataStrategy({ | ||
isActionDataRequest: true | ||
@@ -83,3 +75,3 @@ }) | ||
return { | ||
result: getSingleFetchRedirect(result.status, result.headers), | ||
result: getSingleFetchRedirect(result.status, result.headers, build.basename), | ||
headers: result.headers, | ||
@@ -93,3 +85,3 @@ status: SINGLE_FETCH_REDIRECT_STATUS | ||
return { | ||
result: getSingleFetchRedirect(context.statusCode, headers$1), | ||
result: getSingleFetchRedirect(context.statusCode, headers$1, build.basename), | ||
headers: headers$1, | ||
@@ -148,3 +140,3 @@ status: SINGLE_FETCH_REDIRECT_STATUS | ||
skipLoaderErrorBubbling: true, | ||
unstable_dataStrategy: getSingleFetchDataStrategy({ | ||
dataStrategy: getSingleFetchDataStrategy({ | ||
loadRouteIds | ||
@@ -156,3 +148,3 @@ }) | ||
result: { | ||
[SingleFetchRedirectSymbol]: getSingleFetchRedirect(result.status, result.headers) | ||
[SingleFetchRedirectSymbol]: getSingleFetchRedirect(result.status, result.headers, build.basename) | ||
}, | ||
@@ -168,3 +160,3 @@ headers: result.headers, | ||
result: { | ||
[SingleFetchRedirectSymbol]: getSingleFetchRedirect(context.statusCode, headers$1) | ||
[SingleFetchRedirectSymbol]: getSingleFetchRedirect(context.statusCode, headers$1, build.basename) | ||
}, | ||
@@ -224,5 +216,9 @@ headers: headers$1, | ||
} | ||
function getSingleFetchRedirect(status, headers) { | ||
function getSingleFetchRedirect(status, headers, basename) { | ||
let redirect = headers.get("Location"); | ||
if (basename) { | ||
redirect = router.stripBasename(redirect, basename) || redirect; | ||
} | ||
return { | ||
redirect: headers.get("Location"), | ||
redirect, | ||
status, | ||
@@ -280,23 +276,20 @@ revalidate: | ||
} | ||
}] | ||
}], | ||
postPlugins: [value => { | ||
if (!value) return; | ||
if (typeof value !== "object") return; | ||
return ["SingleFetchClassInstance", Object.fromEntries(Object.entries(value))]; | ||
}, () => ["SingleFetchFallback"]] | ||
}); | ||
} | ||
function data(value, init) { | ||
return router.unstable_data(value, init); | ||
return router.data(value, init); | ||
} | ||
// Backwards-compatible type for Remix v2 where json/defer still use the old types, | ||
// and only non-json/defer returns use the new types. This allows for incremental | ||
// migration of loaders to return naked objects. In the next major version, | ||
// json/defer will be removed so everything will use the new simplified typings. | ||
// prettier-ignore | ||
// eslint-disable-next-line | ||
let defineLoader = loader => loader; | ||
let defineAction = action => action; | ||
exports.SINGLE_FETCH_REDIRECT_STATUS = SINGLE_FETCH_REDIRECT_STATUS; | ||
exports.SingleFetchRedirectSymbol = SingleFetchRedirectSymbol; | ||
exports.data = data; | ||
exports.defineAction = defineAction; | ||
exports.defineLoader = defineLoader; | ||
exports.encodeViaTurboStream = encodeViaTurboStream; | ||
@@ -303,0 +296,0 @@ exports.getSingleFetchDataStrategy = getSingleFetchDataStrategy; |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
/** | ||
* @remix-run/server-runtime v0.0.0-nightly-5fb59ccb4-20240730 | ||
* @remix-run/server-runtime v0.0.0-nightly-5ffb6f5c2-20241121 | ||
* | ||
@@ -4,0 +4,0 @@ * Copyright (c) Remix Software Inc. |
{ | ||
"name": "@remix-run/server-runtime", | ||
"version": "0.0.0-nightly-5fb59ccb4-20240730", | ||
"version": "0.0.0-nightly-5ffb6f5c2-20241121", | ||
"description": "Server runtime for Remix", | ||
@@ -19,3 +19,3 @@ "bugs": { | ||
"dependencies": { | ||
"@remix-run/router": "0.0.0-experimental-9ffbba722", | ||
"@remix-run/router": "1.21.0", | ||
"@types/cookie": "^0.6.0", | ||
@@ -26,3 +26,3 @@ "@web3-storage/multipart-parser": "^1.0.0", | ||
"source-map": "^0.7.3", | ||
"turbo-stream": "2.2.0" | ||
"turbo-stream": "2.4.0" | ||
}, | ||
@@ -29,0 +29,0 @@ "devDependencies": { |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
204962
85
5245
2
+ Added@remix-run/router@1.21.0(transitive)
+ Addedturbo-stream@2.4.0(transitive)
- Removed@remix-run/router@0.0.0-experimental-9ffbba722(transitive)
- Removedturbo-stream@2.2.0(transitive)
Updated@remix-run/router@1.21.0
Updatedturbo-stream@2.4.0