@c0va23/react-router-dev 7.10.1 → 7.13.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.
- package/CHANGELOG.md +84 -8
- package/dist/cli/index.js +72 -59
- package/dist/config/default-rsc-entries/entry.rsc.tsx +33 -11
- package/dist/config/default-rsc-entries/entry.ssr.tsx +22 -15
- package/dist/config.d.ts +51 -0
- package/dist/config.js +1 -1
- package/dist/routes.js +1 -1
- package/dist/vite/cloudflare.js +11 -9
- package/dist/vite.js +892 -280
- package/package.json +21 -10
- package/rsc-types.d.ts +21 -0
package/dist/config.d.ts
CHANGED
|
@@ -39,6 +39,11 @@ type ServerModuleFormat = "esm" | "cjs";
|
|
|
39
39
|
interface FutureConfig {
|
|
40
40
|
unstable_optimizeDeps: boolean;
|
|
41
41
|
unstable_subResourceIntegrity: boolean;
|
|
42
|
+
unstable_trailingSlashAwareDataRequests: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Prerender with Vite Preview server
|
|
45
|
+
*/
|
|
46
|
+
unstable_previewServerPrerendering?: boolean;
|
|
42
47
|
/**
|
|
43
48
|
* Enable route middleware
|
|
44
49
|
*/
|
|
@@ -147,6 +152,47 @@ type ReactRouterConfig = {
|
|
|
147
152
|
* SPA without server-rendering. Default's to `true`.
|
|
148
153
|
*/
|
|
149
154
|
ssr?: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* An array of allowed origin hosts for action submissions to UI routes (does not apply
|
|
157
|
+
* to resource routes). Supports micromatch glob patterns (`*` to match one segment,
|
|
158
|
+
* `**` to match multiple).
|
|
159
|
+
*
|
|
160
|
+
* ```tsx
|
|
161
|
+
* export default {
|
|
162
|
+
* allowedActionOrigins: [
|
|
163
|
+
* "example.com",
|
|
164
|
+
* "*.example.com", // sub.example.com
|
|
165
|
+
* "**.example.com", // sub.domain.example.com
|
|
166
|
+
* ],
|
|
167
|
+
* } satisfies Config;
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* If you need to set this value at runtime, you can do in by setting the value
|
|
171
|
+
* on the server build in your custom server. For example, when using `express`:
|
|
172
|
+
*
|
|
173
|
+
* ```ts
|
|
174
|
+
* import express from "express";
|
|
175
|
+
* import { createRequestHandler } from "@react-router/express";
|
|
176
|
+
* import type { ServerBuild } from "react-router";
|
|
177
|
+
*
|
|
178
|
+
* export const app = express();
|
|
179
|
+
*
|
|
180
|
+
* async function getBuild() {
|
|
181
|
+
* let build: ServerBuild = await import(
|
|
182
|
+
* "virtual:react-router/server-build"
|
|
183
|
+
* );
|
|
184
|
+
* return {
|
|
185
|
+
* ...build,
|
|
186
|
+
* allowedActionOrigins:
|
|
187
|
+
* process.env.NODE_ENV === "development"
|
|
188
|
+
* ? undefined
|
|
189
|
+
* : ["staging.example.com", "www.example.com"],
|
|
190
|
+
* };
|
|
191
|
+
* }
|
|
192
|
+
*
|
|
193
|
+
* app.use(createRequestHandler({ build: getBuild }));
|
|
194
|
+
*/
|
|
195
|
+
allowedActionOrigins?: string[];
|
|
150
196
|
};
|
|
151
197
|
type ResolvedReactRouterConfig = Readonly<{
|
|
152
198
|
/**
|
|
@@ -212,6 +258,11 @@ type ResolvedReactRouterConfig = Readonly<{
|
|
|
212
258
|
* SPA without server-rendering. Default's to `true`.
|
|
213
259
|
*/
|
|
214
260
|
ssr: boolean;
|
|
261
|
+
/**
|
|
262
|
+
* The allowed origins for actions / mutations. Does not apply to routes
|
|
263
|
+
* without a component. micromatch glob patterns are supported.
|
|
264
|
+
*/
|
|
265
|
+
allowedActionOrigins: string[] | false;
|
|
215
266
|
/**
|
|
216
267
|
* The resolved array of route config entries exported from `routes.ts`
|
|
217
268
|
*/
|
package/dist/config.js
CHANGED
package/dist/routes.js
CHANGED
package/dist/vite/cloudflare.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @react-router/dev v7.
|
|
2
|
+
* @react-router/dev v7.13.1
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -45,12 +45,8 @@ __export(cloudflare_exports, {
|
|
|
45
45
|
module.exports = __toCommonJS(cloudflare_exports);
|
|
46
46
|
|
|
47
47
|
// vite/cloudflare-dev-proxy.ts
|
|
48
|
-
var import_node_fetch_server2 = require("@remix-run/node-fetch-server");
|
|
49
48
|
var import_react_router = require("react-router");
|
|
50
49
|
|
|
51
|
-
// vite/node-adapter.ts
|
|
52
|
-
var import_node_fetch_server = require("@remix-run/node-fetch-server");
|
|
53
|
-
|
|
54
50
|
// invariant.ts
|
|
55
51
|
function invariant(value, message) {
|
|
56
52
|
if (value === false || value === null || typeof value === "undefined") {
|
|
@@ -62,13 +58,14 @@ function invariant(value, message) {
|
|
|
62
58
|
}
|
|
63
59
|
|
|
64
60
|
// vite/node-adapter.ts
|
|
65
|
-
function fromNodeRequest(nodeReq, nodeRes) {
|
|
61
|
+
async function fromNodeRequest(nodeReq, nodeRes) {
|
|
66
62
|
invariant(
|
|
67
63
|
nodeReq.originalUrl,
|
|
68
64
|
"Expected `nodeReq.originalUrl` to be defined"
|
|
69
65
|
);
|
|
70
66
|
nodeReq.url = nodeReq.originalUrl;
|
|
71
|
-
|
|
67
|
+
const { createRequest } = await import("@remix-run/node-fetch-server");
|
|
68
|
+
return createRequest(nodeReq, nodeRes);
|
|
72
69
|
}
|
|
73
70
|
|
|
74
71
|
// vite/vite.ts
|
|
@@ -535,10 +532,13 @@ async function resolveConfig({
|
|
|
535
532
|
let future = {
|
|
536
533
|
unstable_optimizeDeps: userAndPresetConfigs.future?.unstable_optimizeDeps ?? false,
|
|
537
534
|
unstable_subResourceIntegrity: userAndPresetConfigs.future?.unstable_subResourceIntegrity ?? false,
|
|
535
|
+
unstable_trailingSlashAwareDataRequests: userAndPresetConfigs.future?.unstable_trailingSlashAwareDataRequests ?? false,
|
|
536
|
+
unstable_previewServerPrerendering: userAndPresetConfigs.future?.unstable_previewServerPrerendering ?? false,
|
|
538
537
|
v8_middleware: userAndPresetConfigs.future?.v8_middleware ?? false,
|
|
539
538
|
v8_splitRouteModules: userAndPresetConfigs.future?.v8_splitRouteModules ?? false,
|
|
540
539
|
v8_viteEnvironmentApi: userAndPresetConfigs.future?.v8_viteEnvironmentApi ?? false
|
|
541
540
|
};
|
|
541
|
+
let allowedActionOrigins = userAndPresetConfigs.allowedActionOrigins ?? false;
|
|
542
542
|
let reactRouterConfig = deepFreeze({
|
|
543
543
|
appDirectory,
|
|
544
544
|
basename,
|
|
@@ -552,6 +552,7 @@ async function resolveConfig({
|
|
|
552
552
|
serverBundles,
|
|
553
553
|
serverModuleFormat,
|
|
554
554
|
ssr,
|
|
555
|
+
allowedActionOrigins,
|
|
555
556
|
unstable_routeConfig: routeConfig
|
|
556
557
|
});
|
|
557
558
|
for (let preset of reactRouterUserConfig.presets ?? []) {
|
|
@@ -817,6 +818,7 @@ var cloudflareDevProxyVitePlugin = (options = {}) => {
|
|
|
817
818
|
}
|
|
818
819
|
},
|
|
819
820
|
configureServer: async (viteDevServer) => {
|
|
821
|
+
const { sendResponse } = await import("@remix-run/node-fetch-server");
|
|
820
822
|
let context;
|
|
821
823
|
let getContext = async () => {
|
|
822
824
|
let { getPlatformProxy } = await importWrangler();
|
|
@@ -833,11 +835,11 @@ var cloudflareDevProxyVitePlugin = (options = {}) => {
|
|
|
833
835
|
serverBuildId
|
|
834
836
|
);
|
|
835
837
|
let handler = (0, import_react_router.createRequestHandler)(build, "development");
|
|
836
|
-
let req = fromNodeRequest(nodeReq, nodeRes);
|
|
838
|
+
let req = await fromNodeRequest(nodeReq, nodeRes);
|
|
837
839
|
context ??= await getContext();
|
|
838
840
|
let loadContext = getLoadContext ? await getLoadContext({ request: req, context }) : context;
|
|
839
841
|
let res = await handler(req, loadContext);
|
|
840
|
-
await
|
|
842
|
+
await sendResponse(nodeRes, res);
|
|
841
843
|
} catch (error) {
|
|
842
844
|
next(error);
|
|
843
845
|
}
|