@c0va23/react-router-dev 7.8.3-alpha.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.
@@ -0,0 +1,123 @@
1
+ import * as v from 'valibot';
2
+
3
+ declare global {
4
+ var __reactRouterAppDirectory: string;
5
+ }
6
+ /**
7
+ * Provides the absolute path to the app directory, for use within `routes.ts`.
8
+ * This is designed to support resolving file system routes.
9
+ */
10
+ declare function getAppDirectory(): string;
11
+ interface RouteManifestEntry {
12
+ /**
13
+ * The path this route uses to match on the URL pathname.
14
+ */
15
+ path?: string;
16
+ /**
17
+ * Should be `true` if it is an index route. This disallows child routes.
18
+ */
19
+ index?: boolean;
20
+ /**
21
+ * Should be `true` if the `path` is case-sensitive. Defaults to `false`.
22
+ */
23
+ caseSensitive?: boolean;
24
+ /**
25
+ * The unique id for this route, named like its `file` but without the
26
+ * extension. So `app/routes/gists/$username.tsx` will have an `id` of
27
+ * `routes/gists/$username`.
28
+ */
29
+ id: string;
30
+ /**
31
+ * The unique `id` for this route's parent route, if there is one.
32
+ */
33
+ parentId?: string;
34
+ /**
35
+ * The path to the entry point for this route, relative to
36
+ * `config.appDirectory`.
37
+ */
38
+ file: string;
39
+ }
40
+ interface RouteManifest {
41
+ [routeId: string]: RouteManifestEntry;
42
+ }
43
+ /**
44
+ * Configuration for an individual route, for use within `routes.ts`. As a
45
+ * convenience, route config entries can be created with the {@link route},
46
+ * {@link index} and {@link layout} helper functions.
47
+ */
48
+ interface RouteConfigEntry {
49
+ /**
50
+ * The unique id for this route.
51
+ */
52
+ id?: string;
53
+ /**
54
+ * The path this route uses to match on the URL pathname.
55
+ */
56
+ path?: string;
57
+ /**
58
+ * Should be `true` if it is an index route. This disallows child routes.
59
+ */
60
+ index?: boolean;
61
+ /**
62
+ * Should be `true` if the `path` is case-sensitive. Defaults to `false`.
63
+ */
64
+ caseSensitive?: boolean;
65
+ /**
66
+ * The path to the entry point for this route, relative to
67
+ * `config.appDirectory`.
68
+ */
69
+ file: string;
70
+ /**
71
+ * The child routes.
72
+ */
73
+ children?: RouteConfigEntry[];
74
+ }
75
+ declare const resolvedRouteConfigSchema: v.ArraySchema<v.BaseSchema<RouteConfigEntry, any, v.BaseIssue<unknown>>, undefined>;
76
+ type ResolvedRouteConfig = v.InferInput<typeof resolvedRouteConfigSchema>;
77
+ /**
78
+ * Route config to be exported via the default export from `app/routes.ts`.
79
+ */
80
+ type RouteConfig = ResolvedRouteConfig | Promise<ResolvedRouteConfig>;
81
+ declare const createConfigRouteOptionKeys: ["id", "index", "caseSensitive"];
82
+ type CreateRouteOptions = Pick<RouteConfigEntry, (typeof createConfigRouteOptionKeys)[number]>;
83
+ /**
84
+ * Helper function for creating a route config entry, for use within
85
+ * `routes.ts`.
86
+ */
87
+ declare function route(path: string | null | undefined, file: string, children?: RouteConfigEntry[]): RouteConfigEntry;
88
+ declare function route(path: string | null | undefined, file: string, options: CreateRouteOptions, children?: RouteConfigEntry[]): RouteConfigEntry;
89
+ declare const createIndexOptionKeys: ["id"];
90
+ type CreateIndexOptions = Pick<RouteConfigEntry, (typeof createIndexOptionKeys)[number]>;
91
+ /**
92
+ * Helper function for creating a route config entry for an index route, for use
93
+ * within `routes.ts`.
94
+ */
95
+ declare function index(file: string, options?: CreateIndexOptions): RouteConfigEntry;
96
+ declare const createLayoutOptionKeys: ["id"];
97
+ type CreateLayoutOptions = Pick<RouteConfigEntry, (typeof createLayoutOptionKeys)[number]>;
98
+ /**
99
+ * Helper function for creating a route config entry for a layout route, for use
100
+ * within `routes.ts`.
101
+ */
102
+ declare function layout(file: string, children?: RouteConfigEntry[]): RouteConfigEntry;
103
+ declare function layout(file: string, options: CreateLayoutOptions, children?: RouteConfigEntry[]): RouteConfigEntry;
104
+ /**
105
+ * Helper function for adding a path prefix to a set of routes without needing
106
+ * to introduce a parent route file, for use within `routes.ts`.
107
+ */
108
+ declare function prefix(prefixPath: string, routes: RouteConfigEntry[]): RouteConfigEntry[];
109
+ declare const helpers: {
110
+ route: typeof route;
111
+ index: typeof index;
112
+ layout: typeof layout;
113
+ prefix: typeof prefix;
114
+ };
115
+
116
+ /**
117
+ * Creates a set of route config helpers that resolve file paths relative to the
118
+ * given directory, for use within `routes.ts`. This is designed to support
119
+ * splitting route config into multiple files within different directories.
120
+ */
121
+ declare function relative(directory: string): typeof helpers;
122
+
123
+ export { type RouteManifest as R, type RouteManifestEntry as a, type RouteConfigEntry as b, type RouteConfig as c, relative as d, getAppDirectory as g, index as i, layout as l, prefix as p, route as r };
@@ -0,0 +1,2 @@
1
+ export { c as RouteConfig, b as RouteConfigEntry, g as getAppDirectory, i as index, l as layout, p as prefix, d as relative, r as route } from './routes-CZR-bKRt.js';
2
+ import 'valibot';
package/dist/routes.js ADDED
@@ -0,0 +1,199 @@
1
+ /**
2
+ * @c0va23/react-router-dev v7.8.3-alpha.1
3
+ *
4
+ * Copyright (c) Remix Software Inc.
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
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);
39
+
40
+ // routes.ts
41
+ var routes_exports = {};
42
+ __export(routes_exports, {
43
+ getAppDirectory: () => getAppDirectory,
44
+ index: () => index,
45
+ layout: () => layout,
46
+ prefix: () => prefix,
47
+ relative: () => relative2,
48
+ route: () => route
49
+ });
50
+ module.exports = __toCommonJS(routes_exports);
51
+
52
+ // config/routes.ts
53
+ var Path = __toESM(require("pathe"));
54
+ var v = __toESM(require("valibot"));
55
+ var import_pick = __toESM(require("lodash/pick"));
56
+
57
+ // invariant.ts
58
+ function invariant(value, message) {
59
+ if (value === false || value === null || typeof value === "undefined") {
60
+ console.error(
61
+ "The following error is a bug in React Router; please open an issue! https://github.com/remix-run/react-router/issues/new/choose"
62
+ );
63
+ throw new Error(message);
64
+ }
65
+ }
66
+
67
+ // config/routes.ts
68
+ function getAppDirectory() {
69
+ invariant(globalThis.__reactRouterAppDirectory);
70
+ return globalThis.__reactRouterAppDirectory;
71
+ }
72
+ var routeConfigEntrySchema = v.pipe(
73
+ v.custom((value) => {
74
+ return !(typeof value === "object" && value !== null && "then" in value && "catch" in value);
75
+ }, "Invalid type: Expected object but received a promise. Did you forget to await?"),
76
+ v.object({
77
+ id: v.optional(
78
+ v.pipe(
79
+ v.string(),
80
+ v.notValue("root", "A route cannot use the reserved id 'root'.")
81
+ )
82
+ ),
83
+ path: v.optional(v.string()),
84
+ index: v.optional(v.boolean()),
85
+ caseSensitive: v.optional(v.boolean()),
86
+ file: v.string(),
87
+ children: v.optional(v.array(v.lazy(() => routeConfigEntrySchema)))
88
+ })
89
+ );
90
+ var resolvedRouteConfigSchema = v.array(routeConfigEntrySchema);
91
+ var createConfigRouteOptionKeys = [
92
+ "id",
93
+ "index",
94
+ "caseSensitive"
95
+ ];
96
+ function route(path, file, optionsOrChildren, children) {
97
+ let options = {};
98
+ if (Array.isArray(optionsOrChildren) || !optionsOrChildren) {
99
+ children = optionsOrChildren;
100
+ } else {
101
+ options = optionsOrChildren;
102
+ }
103
+ return {
104
+ file,
105
+ children,
106
+ path: path ?? void 0,
107
+ ...(0, import_pick.default)(options, createConfigRouteOptionKeys)
108
+ };
109
+ }
110
+ var createIndexOptionKeys = ["id"];
111
+ function index(file, options) {
112
+ return {
113
+ file,
114
+ index: true,
115
+ ...(0, import_pick.default)(options, createIndexOptionKeys)
116
+ };
117
+ }
118
+ var createLayoutOptionKeys = ["id"];
119
+ function layout(file, optionsOrChildren, children) {
120
+ let options = {};
121
+ if (Array.isArray(optionsOrChildren) || !optionsOrChildren) {
122
+ children = optionsOrChildren;
123
+ } else {
124
+ options = optionsOrChildren;
125
+ }
126
+ return {
127
+ file,
128
+ children,
129
+ ...(0, import_pick.default)(options, createLayoutOptionKeys)
130
+ };
131
+ }
132
+ function prefix(prefixPath, routes) {
133
+ return routes.map((route2) => {
134
+ if (route2.index || typeof route2.path === "string") {
135
+ return {
136
+ ...route2,
137
+ path: route2.path ? joinRoutePaths(prefixPath, route2.path) : prefixPath,
138
+ children: route2.children
139
+ };
140
+ } else if (route2.children) {
141
+ return {
142
+ ...route2,
143
+ children: prefix(prefixPath, route2.children)
144
+ };
145
+ }
146
+ return route2;
147
+ });
148
+ }
149
+ function relative2(directory) {
150
+ return {
151
+ /**
152
+ * Helper function for creating a route config entry, for use within
153
+ * `routes.ts`. Note that this helper has been scoped, meaning that file
154
+ * path will be resolved relative to the directory provided to the
155
+ * `relative` call that created this helper.
156
+ */
157
+ route: (path, file, ...rest) => {
158
+ return route(path, Path.resolve(directory, file), ...rest);
159
+ },
160
+ /**
161
+ * Helper function for creating a route config entry for an index route, for
162
+ * use within `routes.ts`. Note that this helper has been scoped, meaning
163
+ * that file path will be resolved relative to the directory provided to the
164
+ * `relative` call that created this helper.
165
+ */
166
+ index: (file, ...rest) => {
167
+ return index(Path.resolve(directory, file), ...rest);
168
+ },
169
+ /**
170
+ * Helper function for creating a route config entry for a layout route, for
171
+ * use within `routes.ts`. Note that this helper has been scoped, meaning
172
+ * that file path will be resolved relative to the directory provided to the
173
+ * `relative` call that created this helper.
174
+ */
175
+ layout: (file, ...rest) => {
176
+ return layout(Path.resolve(directory, file), ...rest);
177
+ },
178
+ // Passthrough of helper functions that don't need relative scoping so that
179
+ // a complete API is still provided.
180
+ prefix
181
+ };
182
+ }
183
+ function joinRoutePaths(path1, path2) {
184
+ return [
185
+ path1.replace(/\/+$/, ""),
186
+ // Remove trailing slashes
187
+ path2.replace(/^\/+/, "")
188
+ // Remove leading slashes
189
+ ].join("/");
190
+ }
191
+ // Annotate the CommonJS export names for ESM import in node:
192
+ 0 && (module.exports = {
193
+ getAppDirectory,
194
+ index,
195
+ layout,
196
+ prefix,
197
+ relative,
198
+ route
199
+ });
@@ -0,0 +1,170 @@
1
+ // adapted from https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/src/refreshUtils.js
2
+ // This file gets injected into the browser as a part of the HMR runtime
3
+
4
+ function debounce(fn, delay) {
5
+ let handle;
6
+ return () => {
7
+ clearTimeout(handle);
8
+ handle = setTimeout(fn, delay);
9
+ };
10
+ }
11
+
12
+ /* eslint-disable no-undef */
13
+ const enqueueUpdate = debounce(async () => {
14
+ let manifest;
15
+ if (routeUpdates.size > 0) {
16
+ manifest = JSON.parse(JSON.stringify(__reactRouterManifest));
17
+
18
+ for (let route of routeUpdates.values()) {
19
+ manifest.routes[route.id] = route;
20
+ let imported = window.__reactRouterRouteModuleUpdates.get(route.id);
21
+ if (!imported) {
22
+ throw Error(
23
+ `[react-router:hmr] No module update found for route ${route.id}`,
24
+ );
25
+ }
26
+ let routeModule = {
27
+ ...imported,
28
+ // react-refresh takes care of updating these in-place,
29
+ // if we don't preserve existing values we'll loose state.
30
+ default: imported.default
31
+ ? (window.__reactRouterRouteModules[route.id]?.default ??
32
+ imported.default)
33
+ : imported.default,
34
+ ErrorBoundary: imported.ErrorBoundary
35
+ ? (window.__reactRouterRouteModules[route.id]?.ErrorBoundary ??
36
+ imported.ErrorBoundary)
37
+ : imported.ErrorBoundary,
38
+ HydrateFallback: imported.HydrateFallback
39
+ ? (window.__reactRouterRouteModules[route.id]?.HydrateFallback ??
40
+ imported.HydrateFallback)
41
+ : imported.HydrateFallback,
42
+ };
43
+ window.__reactRouterRouteModules[route.id] = routeModule;
44
+ }
45
+
46
+ let needsRevalidation = new Set(
47
+ Array.from(routeUpdates.values())
48
+ .filter(
49
+ (route) =>
50
+ route.hasLoader ||
51
+ route.hasClientLoader ||
52
+ route.hasClientMiddleware,
53
+ )
54
+ .map((route) => route.id),
55
+ );
56
+
57
+ let routes = __reactRouterDataRouter.createRoutesForHMR(
58
+ needsRevalidation,
59
+ manifest.routes,
60
+ window.__reactRouterRouteModules,
61
+ window.__reactRouterContext.ssr,
62
+ window.__reactRouterContext.isSpaMode,
63
+ );
64
+ __reactRouterDataRouter._internalSetRoutes(routes);
65
+ routeUpdates.clear();
66
+ window.__reactRouterRouteModuleUpdates.clear();
67
+ }
68
+
69
+ try {
70
+ window.__reactRouterHdrActive = true;
71
+ await __reactRouterDataRouter.revalidate();
72
+ } finally {
73
+ window.__reactRouterHdrActive = false;
74
+ }
75
+
76
+ if (manifest) {
77
+ Object.assign(window.__reactRouterManifest, manifest);
78
+ }
79
+ exports.performReactRefresh();
80
+ }, 16);
81
+
82
+ // Taken from https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/lib/runtime/RefreshUtils.js#L141
83
+ // This allows to resister components not detected by SWC like styled component
84
+ function registerExportsForReactRefresh(filename, moduleExports) {
85
+ for (let key in moduleExports) {
86
+ if (key === "__esModule") continue;
87
+ let exportValue = moduleExports[key];
88
+ if (exports.isLikelyComponentType(exportValue)) {
89
+ // 'export' is required to avoid key collision when renamed exports that
90
+ // shadow a local component name: https://github.com/vitejs/vite-plugin-react/issues/116
91
+ // The register function has an identity check to not register twice the same component,
92
+ // so this is safe to not used the same key here.
93
+ exports.register(exportValue, filename + " export " + key);
94
+ }
95
+ }
96
+ }
97
+
98
+ function validateRefreshBoundaryAndEnqueueUpdate(
99
+ prevExports,
100
+ nextExports,
101
+ // non-component exports that are handled by the framework (e.g. `meta` and `links` for route modules)
102
+ acceptExports = [],
103
+ ) {
104
+ if (
105
+ !predicateOnExport(
106
+ prevExports,
107
+ (key) => key in nextExports || acceptExports.includes(key),
108
+ )
109
+ ) {
110
+ return "Could not Fast Refresh (export removed)";
111
+ }
112
+ if (
113
+ !predicateOnExport(
114
+ nextExports,
115
+ (key) => key in prevExports || acceptExports.includes(key),
116
+ )
117
+ ) {
118
+ return "Could not Fast Refresh (new export)";
119
+ }
120
+
121
+ let hasExports = false;
122
+ let allExportsAreHandledOrUnchanged = predicateOnExport(
123
+ nextExports,
124
+ (key, value) => {
125
+ hasExports = true;
126
+ // Remix can handle Remix-specific exports (e.g. `meta` and `links`)
127
+ if (acceptExports.includes(key)) return true;
128
+ // React Fast Refresh can handle component exports
129
+ if (exports.isLikelyComponentType(value)) return true;
130
+ // Unchanged exports are implicitly handled
131
+ return prevExports[key] === nextExports[key];
132
+ },
133
+ );
134
+ if (hasExports && allExportsAreHandledOrUnchanged) {
135
+ enqueueUpdate();
136
+ } else {
137
+ return "Could not Fast Refresh. Learn more at https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#consistent-components-exports";
138
+ }
139
+ }
140
+
141
+ function predicateOnExport(moduleExports, predicate) {
142
+ for (let key in moduleExports) {
143
+ if (key === "__esModule") continue;
144
+ let desc = Object.getOwnPropertyDescriptor(moduleExports, key);
145
+ if (desc && desc.get) return false;
146
+ if (!predicate(key, moduleExports[key])) return false;
147
+ }
148
+ return true;
149
+ }
150
+
151
+ // Hides vite-ignored dynamic import so that Vite can skip analysis if no other
152
+ // dynamic import is present (https://github.com/vitejs/vite/pull/12732)
153
+ function __hmr_import(module) {
154
+ return import(/* @vite-ignore */ module);
155
+ }
156
+
157
+ const routeUpdates = new Map();
158
+ window.__reactRouterRouteModuleUpdates = new Map();
159
+
160
+ import.meta.hot.on("react-router:hmr", async ({ route }) => {
161
+ if (route) {
162
+ routeUpdates.set(route.id, route);
163
+ }
164
+ });
165
+
166
+ exports.__hmr_import = __hmr_import;
167
+ exports.registerExportsForReactRefresh = registerExportsForReactRefresh;
168
+ exports.validateRefreshBoundaryAndEnqueueUpdate =
169
+ validateRefreshBoundaryAndEnqueueUpdate;
170
+ exports.enqueueUpdate = enqueueUpdate;
@@ -0,0 +1,126 @@
1
+ // adapted from https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/src/refreshUtils.js
2
+ // This file gets injected into the browser as a part of the HMR runtime
3
+
4
+ function debounce(fn, delay) {
5
+ let handle;
6
+ return () => {
7
+ clearTimeout(handle);
8
+ handle = setTimeout(fn, delay);
9
+ };
10
+ }
11
+
12
+ /* eslint-disable no-undef */
13
+ const enqueueUpdate = debounce(async () => {
14
+ if (routeUpdates.size > 0) {
15
+ const routeUpdateByRouteId = new Map();
16
+ for (const routeUpdate of routeUpdates) {
17
+ const routeId = routeUpdate.routeId;
18
+ const routeModule = window.__reactRouterRouteModuleUpdates.get(routeId);
19
+ if (routeModule) {
20
+ routeUpdateByRouteId.set(routeId, { routeModule, ...routeUpdate });
21
+ }
22
+ }
23
+ routeUpdates.clear();
24
+ __reactRouterDataRouter._updateRoutesForHMR(routeUpdateByRouteId);
25
+ }
26
+
27
+ try {
28
+ window.__reactRouterHdrActive = true;
29
+ await __reactRouterDataRouter.revalidate();
30
+ } finally {
31
+ window.__reactRouterHdrActive = false;
32
+ }
33
+
34
+ exports.performReactRefresh();
35
+ }, 16);
36
+
37
+ // Taken from https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/lib/runtime/RefreshUtils.js#L141
38
+ // This allows to resister components not detected by SWC like styled component
39
+ function registerExportsForReactRefresh(filename, moduleExports) {
40
+ for (const key in moduleExports) {
41
+ if (key === "__esModule") continue;
42
+ const exportValue = moduleExports[key];
43
+ if (exports.isLikelyComponentType(exportValue)) {
44
+ // 'export' is required to avoid key collision when renamed exports that
45
+ // shadow a local component name: https://github.com/vitejs/vite-plugin-react/issues/116
46
+ // The register function has an identity check to not register twice the same component,
47
+ // so this is safe to not used the same key here.
48
+ exports.register(exportValue, filename + " export " + key);
49
+ }
50
+ }
51
+ }
52
+
53
+ function validateRefreshBoundaryAndEnqueueUpdate(
54
+ prevExports,
55
+ nextExports,
56
+ // non-component exports that are handled by the framework (e.g. `meta` and `links` for route modules)
57
+ acceptExports = [],
58
+ ) {
59
+ if (
60
+ !predicateOnExport(
61
+ prevExports,
62
+ (key) => key in nextExports || acceptExports.includes(key),
63
+ )
64
+ ) {
65
+ return "Could not Fast Refresh (export removed)";
66
+ }
67
+ if (
68
+ !predicateOnExport(
69
+ nextExports,
70
+ (key) => key in prevExports || acceptExports.includes(key),
71
+ )
72
+ ) {
73
+ return "Could not Fast Refresh (new export)";
74
+ }
75
+
76
+ let hasExports = false;
77
+ const allExportsAreHandledOrUnchanged = predicateOnExport(
78
+ nextExports,
79
+ (key, value) => {
80
+ hasExports = true;
81
+ // React Router can handle additional exports (e.g. `meta` and `links`)
82
+ if (acceptExports.includes(key)) return true;
83
+ // React Fast Refresh can handle component exports
84
+ if (exports.isLikelyComponentType(value)) return true;
85
+ // Unchanged exports are implicitly handled
86
+ return prevExports[key] === nextExports[key];
87
+ },
88
+ );
89
+ if (hasExports && allExportsAreHandledOrUnchanged) {
90
+ enqueueUpdate();
91
+ } else {
92
+ return "Could not Fast Refresh. Learn more at https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#consistent-components-exports";
93
+ }
94
+ }
95
+
96
+ function predicateOnExport(moduleExports, predicate) {
97
+ for (const key in moduleExports) {
98
+ if (key === "__esModule") continue;
99
+ const desc = Object.getOwnPropertyDescriptor(moduleExports, key);
100
+ if (desc && desc.get) return false;
101
+ if (!predicate(key, moduleExports[key])) return false;
102
+ }
103
+ return true;
104
+ }
105
+
106
+ // Hides vite-ignored dynamic import so that Vite can skip analysis if no other
107
+ // dynamic import is present (https://github.com/vitejs/vite/pull/12732)
108
+ function __hmr_import(module) {
109
+ return import(/* @vite-ignore */ module);
110
+ }
111
+
112
+ const routeUpdates = new Set();
113
+ window.__reactRouterRouteModuleUpdates = new Map();
114
+
115
+ import.meta.hot.on("react-router:hmr", async (routeUpdate) => {
116
+ routeUpdates.add(routeUpdate);
117
+ if (routeUpdate.isServerOnlyChange) {
118
+ enqueueUpdate();
119
+ }
120
+ });
121
+
122
+ exports.__hmr_import = __hmr_import;
123
+ exports.registerExportsForReactRefresh = registerExportsForReactRefresh;
124
+ exports.validateRefreshBoundaryAndEnqueueUpdate =
125
+ validateRefreshBoundaryAndEnqueueUpdate;
126
+ exports.enqueueUpdate = enqueueUpdate;
@@ -0,0 +1,24 @@
1
+ import { UNSAFE_MiddlewareEnabled, RouterContextProvider, AppLoadContext } from 'react-router';
2
+ import { Plugin } from 'vite';
3
+ import { PlatformProxy, GetPlatformProxyOptions } from 'wrangler';
4
+
5
+ type MaybePromise<T> = T | Promise<T>;
6
+ type CfProperties = Record<string, unknown>;
7
+ type LoadContext<Env, Cf extends CfProperties> = {
8
+ cloudflare: Omit<PlatformProxy<Env, Cf>, "dispose">;
9
+ };
10
+ type GetLoadContext<Env, Cf extends CfProperties> = (args: {
11
+ request: Request;
12
+ context: LoadContext<Env, Cf>;
13
+ }) => UNSAFE_MiddlewareEnabled extends true ? MaybePromise<RouterContextProvider> : MaybePromise<AppLoadContext>;
14
+ /**
15
+ * Vite plugin that provides [Node proxies to local workerd
16
+ * bindings](https://developers.cloudflare.com/workers/wrangler/api/#getplatformproxy)
17
+ * to `context.cloudflare` in your server loaders and server actions during
18
+ * development.
19
+ */
20
+ declare const cloudflareDevProxyVitePlugin: <Env, Cf extends CfProperties>(options?: {
21
+ getLoadContext?: GetLoadContext<Env, Cf>;
22
+ } & GetPlatformProxyOptions) => Plugin;
23
+
24
+ export { cloudflareDevProxyVitePlugin as cloudflareDevProxy };