@react-router/dev 7.0.0-pre.2 → 7.0.0-pre.4

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cli/index.d.ts +2 -1
  3. package/dist/cli/index.js +1198 -8
  4. package/dist/{config/routes.d.ts → routes-C14jcF98.d.ts} +15 -21
  5. package/dist/routes.d.ts +2 -2
  6. package/dist/routes.js +181 -11
  7. package/dist/typescript/plugin.d.ts +5 -2
  8. package/dist/typescript/plugin.js +479 -31
  9. package/dist/vite/cloudflare.d.ts +23 -1
  10. package/dist/vite/cloudflare.js +171 -5
  11. package/dist/vite.d.ts +169 -2
  12. package/dist/vite.js +2394 -5
  13. package/package.json +28 -7
  14. package/dist/cli/commands.d.ts +0 -13
  15. package/dist/cli/commands.js +0 -179
  16. package/dist/cli/detectPackageManager.d.ts +0 -10
  17. package/dist/cli/detectPackageManager.js +0 -39
  18. package/dist/cli/run.d.ts +0 -5
  19. package/dist/cli/run.js +0 -188
  20. package/dist/cli/useJavascript.d.ts +0 -4
  21. package/dist/cli/useJavascript.js +0 -66
  22. package/dist/colors.d.ts +0 -17
  23. package/dist/colors.js +0 -49
  24. package/dist/config/format.d.ts +0 -5
  25. package/dist/config/format.js +0 -68
  26. package/dist/config/routes.js +0 -253
  27. package/dist/config/serverModes.d.ts +0 -9
  28. package/dist/invariant.d.ts +0 -2
  29. package/dist/invariant.js +0 -20
  30. package/dist/manifest.d.ts +0 -28
  31. package/dist/typescript/typegen.d.ts +0 -10
  32. package/dist/typescript/typegen.js +0 -190
  33. package/dist/vite/babel.d.ts +0 -20
  34. package/dist/vite/babel.js +0 -49
  35. package/dist/vite/build.d.ts +0 -15
  36. package/dist/vite/build.js +0 -249
  37. package/dist/vite/cloudflare-dev-proxy.d.ts +0 -21
  38. package/dist/vite/cloudflare-dev-proxy.js +0 -89
  39. package/dist/vite/combine-urls-test.d.ts +0 -1
  40. package/dist/vite/combine-urls.d.ts +0 -1
  41. package/dist/vite/combine-urls.js +0 -20
  42. package/dist/vite/config.d.ts +0 -234
  43. package/dist/vite/config.js +0 -282
  44. package/dist/vite/dev.d.ts +0 -15
  45. package/dist/vite/dev.js +0 -81
  46. package/dist/vite/import-vite-esm-sync.d.ts +0 -4
  47. package/dist/vite/import-vite-esm-sync.js +0 -28
  48. package/dist/vite/node-adapter.d.ts +0 -6
  49. package/dist/vite/node-adapter.js +0 -90
  50. package/dist/vite/plugin.d.ts +0 -75
  51. package/dist/vite/plugin.js +0 -1301
  52. package/dist/vite/profiler.d.ts +0 -5
  53. package/dist/vite/profiler.js +0 -55
  54. package/dist/vite/remove-exports-test.d.ts +0 -1
  55. package/dist/vite/remove-exports.d.ts +0 -2
  56. package/dist/vite/remove-exports.js +0 -148
  57. package/dist/vite/resolve-file-url.d.ts +0 -3
  58. package/dist/vite/resolve-file-url.js +0 -53
  59. package/dist/vite/styles.d.ts +0 -14
  60. package/dist/vite/styles.js +0 -199
  61. package/dist/vite/vite-node.d.ts +0 -9
  62. package/dist/vite/vite-node.js +0 -57
  63. package/dist/vite/vmod.d.ts +0 -3
  64. package/dist/vite/vmod.js +0 -21
  65. package/dist/vite/with-props.d.ts +0 -4
  66. package/dist/vite/with-props.js +0 -151
  67. /package/dist/{vite/static → static}/refresh-utils.cjs +0 -0
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @react-router/dev v7.0.0-pre.2
2
+ * @react-router/dev v7.0.0-pre.4
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -8,12 +8,178 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- 'use strict';
11
+ "use strict";
12
+ var __create = Object.create;
13
+ var __defProp = Object.defineProperty;
14
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
15
+ var __getOwnPropNames = Object.getOwnPropertyNames;
16
+ var __getProtoOf = Object.getPrototypeOf;
17
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
18
+ var __export = (target, all) => {
19
+ for (var name in all)
20
+ __defProp(target, name, { get: all[name], enumerable: true });
21
+ };
22
+ var __copyProps = (to, from, except, desc) => {
23
+ if (from && typeof from === "object" || typeof from === "function") {
24
+ for (let key of __getOwnPropNames(from))
25
+ if (!__hasOwnProp.call(to, key) && key !== except)
26
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
27
+ }
28
+ return to;
29
+ };
30
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
31
+ // If the importer is in node compatibility mode or this is not an ESM
32
+ // file that has been converted to a CommonJS file using a Babel-
33
+ // compatible transform (i.e. "__esModule" has not been set), then set
34
+ // "default" to the CommonJS "module.exports" for node compatibility.
35
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
36
+ mod
37
+ ));
38
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
12
39
 
13
- Object.defineProperty(exports, '__esModule', { value: true });
40
+ // vite/cloudflare.ts
41
+ var cloudflare_exports = {};
42
+ __export(cloudflare_exports, {
43
+ cloudflareDevProxy: () => cloudflareDevProxyVitePlugin
44
+ });
45
+ module.exports = __toCommonJS(cloudflare_exports);
14
46
 
15
- var cloudflareDevProxy = require('./cloudflare-dev-proxy.js');
47
+ // vite/cloudflare-dev-proxy.ts
48
+ var import_react_router = require("react-router");
16
49
 
50
+ // vite/node-adapter.ts
51
+ var import_node_events = require("events");
52
+ var import_node_stream = require("stream");
53
+ var import_set_cookie_parser = require("set-cookie-parser");
54
+ var import_node = require("@react-router/node");
17
55
 
56
+ // invariant.ts
57
+ function invariant(value, message) {
58
+ if (value === false || value === null || typeof value === "undefined") {
59
+ console.error(
60
+ "The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
61
+ );
62
+ throw new Error(message);
63
+ }
64
+ }
18
65
 
19
- exports.cloudflareDevProxy = cloudflareDevProxy.cloudflareDevProxyVitePlugin;
66
+ // vite/node-adapter.ts
67
+ function fromNodeHeaders(nodeHeaders) {
68
+ let headers = new Headers();
69
+ for (let [key, values] of Object.entries(nodeHeaders)) {
70
+ if (values) {
71
+ if (Array.isArray(values)) {
72
+ for (let value of values) {
73
+ headers.append(key, value);
74
+ }
75
+ } else {
76
+ headers.set(key, values);
77
+ }
78
+ }
79
+ }
80
+ return headers;
81
+ }
82
+ function fromNodeRequest(nodeReq, nodeRes) {
83
+ let origin = nodeReq.headers.origin && "null" !== nodeReq.headers.origin ? nodeReq.headers.origin : `http://${nodeReq.headers.host}`;
84
+ invariant(
85
+ nodeReq.originalUrl,
86
+ "Expected `nodeReq.originalUrl` to be defined"
87
+ );
88
+ let url = new URL(nodeReq.originalUrl, origin);
89
+ let controller = new AbortController();
90
+ let init = {
91
+ method: nodeReq.method,
92
+ headers: fromNodeHeaders(nodeReq.headers),
93
+ signal: controller.signal
94
+ };
95
+ nodeRes.on("finish", () => controller = null);
96
+ nodeRes.on("close", () => controller?.abort());
97
+ if (nodeReq.method !== "GET" && nodeReq.method !== "HEAD") {
98
+ init.body = (0, import_node.createReadableStreamFromReadable)(nodeReq);
99
+ init.duplex = "half";
100
+ }
101
+ return new Request(url.href, init);
102
+ }
103
+ async function toNodeRequest(res, nodeRes) {
104
+ nodeRes.statusCode = res.status;
105
+ nodeRes.statusMessage = res.statusText;
106
+ let cookiesStrings = [];
107
+ for (let [name, value] of res.headers) {
108
+ if (name === "set-cookie") {
109
+ cookiesStrings.push(...(0, import_set_cookie_parser.splitCookiesString)(value));
110
+ } else nodeRes.setHeader(name, value);
111
+ }
112
+ if (cookiesStrings.length) {
113
+ nodeRes.setHeader("set-cookie", cookiesStrings);
114
+ }
115
+ if (res.body) {
116
+ let responseBody = res.body;
117
+ let readable = import_node_stream.Readable.from(responseBody);
118
+ readable.pipe(nodeRes);
119
+ await (0, import_node_events.once)(readable, "end");
120
+ } else {
121
+ nodeRes.end();
122
+ }
123
+ }
124
+
125
+ // vite/cloudflare-dev-proxy.ts
126
+ var serverBuildId = "virtual:react-router/server-build";
127
+ function importWrangler() {
128
+ try {
129
+ return import("wrangler");
130
+ } catch (_) {
131
+ throw Error("Could not import `wrangler`. Do you have it installed?");
132
+ }
133
+ }
134
+ var PLUGIN_NAME = "react-router-cloudflare-vite-dev-proxy";
135
+ var cloudflareDevProxyVitePlugin = (options = {}) => {
136
+ let { getLoadContext, ...restOptions } = options;
137
+ return {
138
+ name: PLUGIN_NAME,
139
+ config: () => ({
140
+ ssr: {
141
+ resolve: {
142
+ externalConditions: ["workerd", "worker"]
143
+ }
144
+ }
145
+ }),
146
+ configResolved: (viteConfig) => {
147
+ let pluginIndex = (name) => viteConfig.plugins.findIndex((plugin) => plugin.name === name);
148
+ let reactRouterPluginIndex = pluginIndex("react-router");
149
+ if (reactRouterPluginIndex >= 0 && reactRouterPluginIndex < pluginIndex(PLUGIN_NAME)) {
150
+ throw new Error(
151
+ `The "${PLUGIN_NAME}" plugin should be placed before the React Router plugin in your Vite config file`
152
+ );
153
+ }
154
+ },
155
+ configureServer: async (viteDevServer) => {
156
+ let { getPlatformProxy } = await importWrangler();
157
+ let { dispose, ...cloudflare } = await getPlatformProxy(
158
+ restOptions
159
+ );
160
+ let context = { cloudflare };
161
+ return () => {
162
+ if (!viteDevServer.config.server.middlewareMode) {
163
+ viteDevServer.middlewares.use(async (nodeReq, nodeRes, next) => {
164
+ try {
165
+ let build = await viteDevServer.ssrLoadModule(
166
+ serverBuildId
167
+ );
168
+ let handler = (0, import_react_router.createRequestHandler)(build, "development");
169
+ let req = fromNodeRequest(nodeReq, nodeRes);
170
+ let loadContext = getLoadContext ? await getLoadContext({ request: req, context }) : context;
171
+ let res = await handler(req, loadContext);
172
+ await toNodeRequest(res, nodeRes);
173
+ } catch (error) {
174
+ next(error);
175
+ }
176
+ });
177
+ }
178
+ };
179
+ }
180
+ };
181
+ };
182
+ // Annotate the CommonJS export names for ESM import in node:
183
+ 0 && (module.exports = {
184
+ cloudflareDevProxy
185
+ });
package/dist/vite.d.ts CHANGED
@@ -1,2 +1,169 @@
1
- export type { BuildManifest, Preset, ServerBundlesFunction, ReactRouterConfig, } from "./vite/config";
2
- export { reactRouterVitePlugin as reactRouter } from "./vite/plugin";
1
+ import * as Vite from 'vite';
2
+ import { R as RouteManifest, a as RouteManifestEntry } from './routes-C14jcF98.js';
3
+ import 'valibot';
4
+
5
+ declare const excludedConfigPresetKeys: readonly ["presets"];
6
+ type ExcludedConfigPresetKey = (typeof excludedConfigPresetKeys)[number];
7
+ type ConfigPreset = Omit<ReactRouterConfig, ExcludedConfigPresetKey>;
8
+ type Preset = {
9
+ name: string;
10
+ reactRouterConfig?: (args: {
11
+ reactRouterUserConfig: ReactRouterConfig;
12
+ }) => ConfigPreset | Promise<ConfigPreset>;
13
+ reactRouterConfigResolved?: (args: {
14
+ reactRouterConfig: ResolvedReactRouterConfig;
15
+ }) => void | Promise<void>;
16
+ };
17
+ declare const branchRouteProperties: readonly ["id", "path", "file", "index"];
18
+ type BranchRoute = Pick<RouteManifestEntry, (typeof branchRouteProperties)[number]>;
19
+ type ServerBundlesFunction = (args: {
20
+ branch: BranchRoute[];
21
+ }) => string | Promise<string>;
22
+ type BaseBuildManifest = {
23
+ routes: RouteManifest;
24
+ };
25
+ type DefaultBuildManifest = BaseBuildManifest & {
26
+ serverBundles?: never;
27
+ routeIdToServerBundleId?: never;
28
+ };
29
+ type ServerBundlesBuildManifest = BaseBuildManifest & {
30
+ serverBundles: {
31
+ [serverBundleId: string]: {
32
+ id: string;
33
+ file: string;
34
+ };
35
+ };
36
+ routeIdToServerBundleId: Record<string, string>;
37
+ };
38
+ type ServerModuleFormat = "esm" | "cjs";
39
+ interface FutureConfig {
40
+ }
41
+ type BuildManifest = DefaultBuildManifest | ServerBundlesBuildManifest;
42
+ type BuildEndHook = (args: {
43
+ buildManifest: BuildManifest | undefined;
44
+ reactRouterConfig: ResolvedReactRouterConfig;
45
+ viteConfig: Vite.ResolvedConfig;
46
+ }) => void | Promise<void>;
47
+ type ReactRouterConfig = {
48
+ /**
49
+ * The path to the `app` directory, relative to `remix.config.js`. Defaults
50
+ * to `"app"`.
51
+ */
52
+ appDirectory?: string;
53
+ /**
54
+ * The output format of the server build. Defaults to "esm".
55
+ */
56
+ serverModuleFormat?: ServerModuleFormat;
57
+ /**
58
+ * Enabled future flags
59
+ */
60
+ future?: [keyof FutureConfig] extends [never] ? {
61
+ [key: string]: never;
62
+ } : Partial<FutureConfig>;
63
+ /**
64
+ * The React Router app basename. Defaults to `"/"`.
65
+ */
66
+ basename?: string;
67
+ /**
68
+ * The path to the build directory, relative to the project. Defaults to
69
+ * `"build"`.
70
+ */
71
+ buildDirectory?: string;
72
+ /**
73
+ * A function that is called after the full React Router build is complete.
74
+ */
75
+ buildEnd?: BuildEndHook;
76
+ /**
77
+ * An array of URLs to prerender to HTML files at build time. Can also be a
78
+ * function returning an array to dynamically generate URLs.
79
+ */
80
+ prerender?: boolean | Array<string> | ((args: {
81
+ getStaticPaths: () => string[];
82
+ }) => Array<string> | Promise<Array<string>>);
83
+ /**
84
+ * An array of React Router plugin config presets to ease integration with
85
+ * other platforms and tools.
86
+ */
87
+ presets?: Array<Preset>;
88
+ /**
89
+ * The file name of the server build output. This file
90
+ * should end in a `.js` extension and should be deployed to your server.
91
+ * Defaults to `"index.js"`.
92
+ */
93
+ serverBuildFile?: string;
94
+ /**
95
+ * A function for assigning routes to different server bundles. This
96
+ * function should return a server bundle ID which will be used as the
97
+ * bundle's directory name within the server build directory.
98
+ */
99
+ serverBundles?: ServerBundlesFunction;
100
+ /**
101
+ * Enable server-side rendering for your application. Disable to use "SPA
102
+ * Mode", which will request the `/` path at build-time and save it as an
103
+ * `index.html` file with your assets so your application can be deployed as a
104
+ * SPA without server-rendering. Default's to `true`.
105
+ */
106
+ ssr?: boolean;
107
+ };
108
+ type ResolvedReactRouterConfig = Readonly<{
109
+ /**
110
+ * The absolute path to the application source directory.
111
+ */
112
+ appDirectory: string;
113
+ /**
114
+ * The React Router app basename. Defaults to `"/"`.
115
+ */
116
+ basename: string;
117
+ /**
118
+ * The absolute path to the build directory.
119
+ */
120
+ buildDirectory: string;
121
+ /**
122
+ * A function that is called after the full React Router build is complete.
123
+ */
124
+ buildEnd?: BuildEndHook;
125
+ /**
126
+ * Enabled future flags
127
+ */
128
+ future: FutureConfig;
129
+ /**
130
+ * An array of URLs to prerender to HTML files at build time. Can also be a
131
+ * function returning an array to dynamically generate URLs.
132
+ */
133
+ prerender: ReactRouterConfig["prerender"];
134
+ /**
135
+ * An object of all available routes, keyed by route id.
136
+ */
137
+ routes: RouteManifest;
138
+ /**
139
+ * The file name of the server build output. This file
140
+ * should end in a `.js` extension and should be deployed to your server.
141
+ * Defaults to `"index.js"`.
142
+ */
143
+ serverBuildFile: string;
144
+ /**
145
+ * A function for assigning routes to different server bundles. This
146
+ * function should return a server bundle ID which will be used as the
147
+ * bundle's directory name within the server build directory.
148
+ */
149
+ serverBundles?: ServerBundlesFunction;
150
+ /**
151
+ * The output format of the server build. Defaults to "esm".
152
+ */
153
+ serverModuleFormat: ServerModuleFormat;
154
+ /**
155
+ * Enable server-side rendering for your application. Disable to use "SPA
156
+ * Mode", which will request the `/` path at build-time and save it as an
157
+ * `index.html` file with your assets so your application can be deployed as a
158
+ * SPA without server-rendering. Default's to `true`.
159
+ */
160
+ ssr: boolean;
161
+ }>;
162
+
163
+ type ReactRouterVitePlugin = (config?: ReactRouterConfig) => Vite.Plugin[];
164
+ /**
165
+ * React Router [Vite plugin.](https://vitejs.dev/guide/using-plugins.html)
166
+ */
167
+ declare const reactRouterVitePlugin: ReactRouterVitePlugin;
168
+
169
+ export { type BuildManifest, type Preset, type ReactRouterConfig, type ServerBundlesFunction, reactRouterVitePlugin as reactRouter };