path-rush 1.4.1 → 1.6.0
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/dist/{chunk-VBEFTPIV.mjs → chunk-VZP7N76J.mjs} +105 -52
- package/dist/chunk-VZP7N76J.mjs.map +1 -0
- package/dist/core.js +66 -13
- package/dist/core.js.map +1 -1
- package/dist/core.mjs +1 -1
- package/dist/plugin.d.cts +30 -0
- package/dist/plugin.d.ts +30 -0
- package/dist/plugin.js +66 -13
- package/dist/plugin.js.map +1 -1
- package/dist/plugin.mjs +1 -1
- package/dist/react.d.cts +168 -4
- package/dist/react.d.ts +168 -4
- package/dist/react.js +228 -28
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +225 -29
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-VBEFTPIV.mjs.map +0 -1
package/dist/react.mjs
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
+
// src/components/link.tsx
|
|
2
|
+
import { Link as ReactRouterLink } from "react-router-dom";
|
|
3
|
+
|
|
4
|
+
// src/components/hooks/use-location.ts
|
|
5
|
+
import { useLocation as useRouterLocation } from "react-router-dom";
|
|
6
|
+
function useLocation() {
|
|
7
|
+
return useRouterLocation();
|
|
8
|
+
}
|
|
9
|
+
|
|
1
10
|
// src/components/hooks/use-links.tsx
|
|
2
|
-
import { useLocation } from "react-router-dom";
|
|
3
11
|
function useLink(props) {
|
|
4
12
|
const location = useLocation();
|
|
5
13
|
const currentPath = location.pathname;
|
|
@@ -10,33 +18,165 @@ function useLink(props) {
|
|
|
10
18
|
}
|
|
11
19
|
|
|
12
20
|
// src/components/link.tsx
|
|
13
|
-
import { Link as ReactRouterLink } from "react-router-dom";
|
|
14
21
|
var Link = ReactRouterLink;
|
|
15
22
|
|
|
23
|
+
// src/components/nav-link.tsx
|
|
24
|
+
import { NavLink as ReactRouterNavLink } from "react-router-dom";
|
|
25
|
+
var NavLink = ReactRouterNavLink;
|
|
26
|
+
|
|
27
|
+
// src/components/navigate.tsx
|
|
28
|
+
import { Navigate as ReactRouterNavigate } from "react-router-dom";
|
|
29
|
+
var Navigate = ReactRouterNavigate;
|
|
30
|
+
|
|
31
|
+
// src/components/route-transition.tsx
|
|
32
|
+
import { useEffect, useState, useRef } from "react";
|
|
33
|
+
import { jsx } from "react/jsx-runtime";
|
|
34
|
+
function RouteTransition({
|
|
35
|
+
children,
|
|
36
|
+
enterClass = "route-enter",
|
|
37
|
+
enterActiveClass = "route-enter-active",
|
|
38
|
+
exitClass = "route-exit",
|
|
39
|
+
exitActiveClass = "route-exit-active",
|
|
40
|
+
duration = 300,
|
|
41
|
+
onTransition,
|
|
42
|
+
mode = "fade"
|
|
43
|
+
}) {
|
|
44
|
+
const location = useLocation();
|
|
45
|
+
const [displayChildren, setDisplayChildren] = useState(children);
|
|
46
|
+
const [isExiting, setIsExiting] = useState(false);
|
|
47
|
+
const [isEntering, setIsEntering] = useState(false);
|
|
48
|
+
const prevLocationRef = useRef(location.pathname);
|
|
49
|
+
const timeoutRef = useRef(null);
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (prevLocationRef.current !== location.pathname) {
|
|
52
|
+
if (timeoutRef.current) {
|
|
53
|
+
clearTimeout(timeoutRef.current);
|
|
54
|
+
}
|
|
55
|
+
setIsExiting(true);
|
|
56
|
+
setIsEntering(false);
|
|
57
|
+
onTransition?.("exit");
|
|
58
|
+
timeoutRef.current = setTimeout(() => {
|
|
59
|
+
setDisplayChildren(children);
|
|
60
|
+
setIsExiting(false);
|
|
61
|
+
setIsEntering(true);
|
|
62
|
+
onTransition?.("enter");
|
|
63
|
+
timeoutRef.current = setTimeout(() => {
|
|
64
|
+
setIsEntering(false);
|
|
65
|
+
timeoutRef.current = null;
|
|
66
|
+
}, duration);
|
|
67
|
+
}, duration);
|
|
68
|
+
prevLocationRef.current = location.pathname;
|
|
69
|
+
} else {
|
|
70
|
+
setDisplayChildren(children);
|
|
71
|
+
}
|
|
72
|
+
return () => {
|
|
73
|
+
if (timeoutRef.current) {
|
|
74
|
+
clearTimeout(timeoutRef.current);
|
|
75
|
+
timeoutRef.current = null;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}, [location.pathname, children, duration, onTransition]);
|
|
79
|
+
const getClassName = () => {
|
|
80
|
+
if (isExiting) {
|
|
81
|
+
return `${exitClass} ${exitActiveClass}`;
|
|
82
|
+
}
|
|
83
|
+
if (isEntering) {
|
|
84
|
+
return `${enterClass} ${enterActiveClass}`;
|
|
85
|
+
}
|
|
86
|
+
return "";
|
|
87
|
+
};
|
|
88
|
+
const getDefaultStyles = () => {
|
|
89
|
+
if (mode === "fade") {
|
|
90
|
+
return {
|
|
91
|
+
transition: `opacity ${duration}ms ease-in-out`,
|
|
92
|
+
opacity: isExiting ? 0 : isEntering ? 0 : 1
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
if (mode === "slide") {
|
|
96
|
+
return {
|
|
97
|
+
transition: `transform ${duration}ms ease-in-out, opacity ${duration}ms ease-in-out`,
|
|
98
|
+
transform: isExiting ? "translateX(-100%)" : isEntering ? "translateX(100%)" : "translateX(0)",
|
|
99
|
+
opacity: isExiting ? 0 : isEntering ? 0 : 1
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return {};
|
|
103
|
+
};
|
|
104
|
+
return /* @__PURE__ */ jsx("div", { className: getClassName(), style: getDefaultStyles(), children: displayChildren });
|
|
105
|
+
}
|
|
106
|
+
|
|
16
107
|
// src/components/router-provider.tsx
|
|
17
|
-
import {
|
|
108
|
+
import {
|
|
109
|
+
basePath as configBasePath,
|
|
110
|
+
globalNotFound,
|
|
111
|
+
manifest
|
|
112
|
+
} from "virtual:routes";
|
|
18
113
|
|
|
19
114
|
// src/components/router-layout.tsx
|
|
20
|
-
import
|
|
115
|
+
import React4 from "react";
|
|
21
116
|
import { BrowserRouter, Routes } from "react-router-dom";
|
|
22
117
|
|
|
23
118
|
// src/components/router-utils.tsx
|
|
24
|
-
import
|
|
119
|
+
import React3 from "react";
|
|
25
120
|
import { Route } from "react-router-dom";
|
|
26
|
-
|
|
121
|
+
|
|
122
|
+
// src/components/error-boundary.tsx
|
|
123
|
+
import React2 from "react";
|
|
124
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
125
|
+
var ErrorBoundary = class extends React2.Component {
|
|
126
|
+
constructor(props) {
|
|
127
|
+
super(props);
|
|
128
|
+
this.state = { hasError: false, error: null };
|
|
129
|
+
}
|
|
130
|
+
static getDerivedStateFromError(error) {
|
|
131
|
+
return { hasError: true, error };
|
|
132
|
+
}
|
|
133
|
+
componentDidCatch(error, errorInfo) {
|
|
134
|
+
this.props.onError?.(error, errorInfo);
|
|
135
|
+
}
|
|
136
|
+
resetError = () => {
|
|
137
|
+
this.setState({ hasError: false, error: null });
|
|
138
|
+
};
|
|
139
|
+
render() {
|
|
140
|
+
if (this.state.hasError && this.state.error) {
|
|
141
|
+
if (this.props.fallback) {
|
|
142
|
+
const Fallback = this.props.fallback;
|
|
143
|
+
return /* @__PURE__ */ jsx2(Fallback, { error: this.state.error, resetError: this.resetError });
|
|
144
|
+
}
|
|
145
|
+
return /* @__PURE__ */ jsxs("div", { style: { padding: "20px" }, children: [
|
|
146
|
+
/* @__PURE__ */ jsx2("h2", { children: "Something went wrong" }),
|
|
147
|
+
/* @__PURE__ */ jsx2("pre", { children: this.state.error.message }),
|
|
148
|
+
/* @__PURE__ */ jsx2("button", { onClick: this.resetError, children: "Try again" })
|
|
149
|
+
] });
|
|
150
|
+
}
|
|
151
|
+
return this.props.children;
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// src/components/router-utils.tsx
|
|
156
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
27
157
|
function wrapLayouts(layouts, pageEl) {
|
|
28
158
|
if (!layouts || layouts.length === 0) return pageEl;
|
|
29
159
|
return layouts.reduceRight((child, loader) => {
|
|
30
|
-
const Layout =
|
|
160
|
+
const Layout = React3.lazy(async () => {
|
|
31
161
|
const module = await loader();
|
|
32
162
|
return "default" in module ? module : { default: module.Layout };
|
|
33
163
|
});
|
|
34
|
-
return /* @__PURE__ */
|
|
164
|
+
return /* @__PURE__ */ jsx3(Layout, { children: child });
|
|
35
165
|
}, pageEl);
|
|
36
166
|
}
|
|
37
|
-
|
|
167
|
+
function createLoadingFallback(loadingLoader) {
|
|
168
|
+
if (!loadingLoader) return void 0;
|
|
169
|
+
const Loading = React3.lazy(loadingLoader);
|
|
170
|
+
return /* @__PURE__ */ jsx3(Loading, {});
|
|
171
|
+
}
|
|
172
|
+
function createErrorFallback(errorLoader) {
|
|
173
|
+
if (!errorLoader) return void 0;
|
|
174
|
+
const ErrorComponent = React3.lazy(errorLoader);
|
|
175
|
+
return (props) => /* @__PURE__ */ jsx3(ErrorComponent, { ...props });
|
|
176
|
+
}
|
|
177
|
+
var renderManifestAsRoutes = (manifest2, globalNotFound2) => {
|
|
38
178
|
return manifest2.map((n) => {
|
|
39
|
-
const Page =
|
|
179
|
+
const Page = React3.lazy(async () => {
|
|
40
180
|
const module = await n.loader();
|
|
41
181
|
if (module && typeof module === "object" && "default" in module && module.default) {
|
|
42
182
|
return module;
|
|
@@ -59,47 +199,103 @@ var renderManifestAsRoutes = (manifest2) => {
|
|
|
59
199
|
`No valid export found in module for route ${n.path}. Available exports: ${availableExports}`
|
|
60
200
|
);
|
|
61
201
|
});
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
202
|
+
const loadingFallback = createLoadingFallback(n.loading);
|
|
203
|
+
const errorFallback = createErrorFallback(n.error);
|
|
204
|
+
const pageElement = wrapLayouts(n.layouts, /* @__PURE__ */ jsx3(Page, {}));
|
|
205
|
+
const wrappedElement = errorFallback ? /* @__PURE__ */ jsx3(ErrorBoundary, { fallback: errorFallback, children: pageElement }) : pageElement;
|
|
206
|
+
const element = loadingFallback ? /* @__PURE__ */ jsx3(React3.Suspense, { fallback: loadingFallback, children: wrappedElement }) : /* @__PURE__ */ jsx3(React3.Suspense, { fallback: /* @__PURE__ */ jsx3("div", { children: "Loading..." }), children: wrappedElement });
|
|
207
|
+
return /* @__PURE__ */ jsx3(Route, { path: n.path, element }, n.id);
|
|
208
|
+
}).concat(
|
|
209
|
+
// Добавляем 404 маршрут в конец
|
|
210
|
+
globalNotFound2 ? /* @__PURE__ */ jsx3(
|
|
211
|
+
Route,
|
|
212
|
+
{
|
|
213
|
+
path: "*",
|
|
214
|
+
element: /* @__PURE__ */ jsx3(React3.Suspense, { fallback: /* @__PURE__ */ jsx3("div", { children: "Loading..." }), children: (() => {
|
|
215
|
+
const NotFound = React3.lazy(globalNotFound2);
|
|
216
|
+
return /* @__PURE__ */ jsx3(NotFound, {});
|
|
217
|
+
})() })
|
|
218
|
+
},
|
|
219
|
+
"__not_found__"
|
|
220
|
+
) : /* @__PURE__ */ jsx3(
|
|
221
|
+
Route,
|
|
222
|
+
{
|
|
223
|
+
path: "*",
|
|
224
|
+
element: /* @__PURE__ */ jsxs2("div", { style: { padding: "20px", textAlign: "center" }, children: [
|
|
225
|
+
/* @__PURE__ */ jsx3("h1", { children: "404" }),
|
|
226
|
+
/* @__PURE__ */ jsx3("p", { children: "Page not found" })
|
|
227
|
+
] })
|
|
228
|
+
},
|
|
229
|
+
"__not_found__"
|
|
230
|
+
)
|
|
231
|
+
);
|
|
65
232
|
};
|
|
66
233
|
|
|
67
234
|
// src/components/router-layout.tsx
|
|
68
|
-
import { jsx as
|
|
235
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
69
236
|
var RouterLayout = ({
|
|
70
237
|
manifest: manifest2,
|
|
71
238
|
children,
|
|
72
239
|
preloader,
|
|
73
|
-
basePath = "/"
|
|
74
|
-
|
|
240
|
+
basePath = "/",
|
|
241
|
+
globalNotFound: globalNotFound2,
|
|
242
|
+
enableTransitions = false,
|
|
243
|
+
transitionConfig
|
|
244
|
+
}) => {
|
|
245
|
+
const routes = renderManifestAsRoutes(manifest2, globalNotFound2);
|
|
246
|
+
const routesElement = /* @__PURE__ */ jsx4(Routes, { children: routes });
|
|
247
|
+
return /* @__PURE__ */ jsx4(BrowserRouter, { basename: basePath, children: /* @__PURE__ */ jsx4(React4.Suspense, { fallback: children || preloader || /* @__PURE__ */ jsx4("div", { children: "Loading..." }), children: enableTransitions ? /* @__PURE__ */ jsx4(RouteTransition, { ...transitionConfig, children: routesElement }) : routesElement }) });
|
|
248
|
+
};
|
|
75
249
|
|
|
76
250
|
// src/components/router-provider.tsx
|
|
77
|
-
import { jsx as
|
|
251
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
78
252
|
function RouterProvider({
|
|
79
253
|
children,
|
|
80
254
|
preloader,
|
|
81
|
-
basePath
|
|
255
|
+
basePath,
|
|
256
|
+
enableTransitions,
|
|
257
|
+
transitionConfig
|
|
82
258
|
}) {
|
|
83
259
|
const finalBasePath = basePath ?? configBasePath ?? "/";
|
|
84
|
-
return /* @__PURE__ */
|
|
260
|
+
return /* @__PURE__ */ jsx5(
|
|
261
|
+
RouterLayout,
|
|
262
|
+
{
|
|
263
|
+
manifest,
|
|
264
|
+
preloader,
|
|
265
|
+
basePath: finalBasePath,
|
|
266
|
+
globalNotFound,
|
|
267
|
+
enableTransitions,
|
|
268
|
+
transitionConfig,
|
|
269
|
+
children
|
|
270
|
+
}
|
|
271
|
+
);
|
|
85
272
|
}
|
|
86
273
|
|
|
87
|
-
// src/
|
|
88
|
-
import {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
274
|
+
// src/components/hooks/use-navigate.ts
|
|
275
|
+
import { useNavigate as useRouterNavigate } from "react-router-dom";
|
|
276
|
+
function useNavigate() {
|
|
277
|
+
return useRouterNavigate();
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// src/components/hooks/use-params.ts
|
|
281
|
+
import { useParams as useRouterParams } from "react-router-dom";
|
|
282
|
+
function useParams() {
|
|
283
|
+
return useRouterParams();
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// src/components/hooks/use-search-params.ts
|
|
287
|
+
import { useSearchParams as useRouterSearchParams } from "react-router-dom";
|
|
288
|
+
function useSearchParams() {
|
|
289
|
+
return useRouterSearchParams();
|
|
290
|
+
}
|
|
96
291
|
export {
|
|
97
292
|
Link,
|
|
98
293
|
NavLink,
|
|
99
294
|
Navigate,
|
|
295
|
+
RouteTransition,
|
|
100
296
|
RouterProvider,
|
|
101
297
|
useLink,
|
|
102
|
-
|
|
298
|
+
useLocation,
|
|
103
299
|
useNavigate,
|
|
104
300
|
useParams,
|
|
105
301
|
useSearchParams
|
package/dist/react.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/hooks/use-links.tsx","../src/components/link.tsx","../src/components/router-provider.tsx","../src/components/router-layout.tsx","../src/components/router-utils.tsx","../src/react.ts"],"sourcesContent":["import { useLocation } from 'react-router-dom'\r\n\r\nexport function useLink(props: { href: string }) {\r\n const location = useLocation()\r\n const currentPath = location.pathname\r\n \r\n return {\r\n href: props.href,\r\n isActive: currentPath === props.href,\r\n }\r\n}","import type { LinkProps as ReactRouterLinkProps } from 'react-router-dom'\r\nimport { Link as ReactRouterLink } from 'react-router-dom'\r\n\r\nexport type LinkProps = ReactRouterLinkProps\r\n\r\nexport const Link = ReactRouterLink\r\n\r\nexport { useLink } from './hooks/use-links'\r\n","import { manifest, basePath as configBasePath } from 'virtual:routes'\r\nimport { RouterLayout } from './router-layout'\r\nimport type { RouterProviderProps } from './types/types'\r\n\r\nexport default function RouterProvider({\r\n\tchildren,\r\n\tpreloader,\r\n\tbasePath,\r\n}: Readonly<RouterProviderProps>) {\r\n\t// Используем basePath из пропсов, если указан, иначе из конфигурации\r\n\tconst finalBasePath = basePath ?? configBasePath ?? '/'\r\n\t\r\n\treturn (\r\n\t\t<RouterLayout manifest={manifest} preloader={preloader} basePath={finalBasePath}>\r\n\t\t\t{children}\r\n\t\t</RouterLayout>\r\n\t)\r\n}\r\n","import React from 'react'\r\nimport { BrowserRouter, Routes } from 'react-router-dom'\r\nimport { renderManifestAsRoutes } from './router-utils'\r\nimport type { RouterLayoutProps } from './types/types'\r\n\r\nexport const RouterLayout = ({\r\n\tmanifest,\r\n\tchildren,\r\n\tpreloader,\r\n\tbasePath = '/',\r\n}: RouterLayoutProps) => (\r\n\t<BrowserRouter basename={basePath}>\r\n\t\t<React.Suspense fallback={children || preloader || <div>Loading...</div>}>\r\n\t\t\t<Routes>{renderManifestAsRoutes(manifest)}</Routes>\r\n\t\t</React.Suspense>\r\n\t</BrowserRouter>\r\n)\r\n","import React from 'react'\r\nimport { Route } from 'react-router-dom'\r\nimport type { Node } from './types/types'\r\n\r\nfunction wrapLayouts(\r\n\tlayouts: Node['layouts'] | undefined,\r\n\tpageEl: React.ReactNode\r\n) {\r\n\tif (!layouts || layouts.length === 0) return pageEl\r\n\r\n\treturn layouts.reduceRight((child, loader) => {\r\n\t\tconst Layout = React.lazy(async () => {\r\n\t\t\tconst module = await loader()\r\n\t\t\t// Поддерживаем как default, так и именованный экспорт Layout\r\n\t\t\treturn 'default' in module ? module : { default: module.Layout }\r\n\t\t})\r\n\t\treturn <Layout>{child}</Layout>\r\n\t}, pageEl as React.ReactElement)\r\n}\r\n\r\nexport const renderManifestAsRoutes = (manifest: Node[]) => {\r\n\treturn manifest.map(n => {\r\n\t\tconst Page = React.lazy(async () => {\r\n\t\t\tconst module = await n.loader()\r\n\r\n\t\t\t// Если есть default экспорт, используем его\r\n\t\t\tif (\r\n\t\t\t\tmodule &&\r\n\t\t\t\ttypeof module === 'object' &&\r\n\t\t\t\t'default' in module &&\r\n\t\t\t\tmodule.default\r\n\t\t\t) {\r\n\t\t\t\treturn module as { default: React.ComponentType }\r\n\t\t\t}\r\n\r\n\t\t\t// Ищем любой именованный экспорт, который является функцией или компонентом\r\n\t\t\tif (module && typeof module === 'object') {\r\n\t\t\t\tconst namedExports = Object.keys(module).filter(\r\n\t\t\t\t\tkey => key !== 'default'\r\n\t\t\t\t)\r\n\t\t\t\tfor (const key of namedExports) {\r\n\t\t\t\t\tconst exportValue = module[key]\r\n\t\t\t\t\tif (\r\n\t\t\t\t\t\ttypeof exportValue === 'function' ||\r\n\t\t\t\t\t\t(typeof exportValue === 'object' && exportValue !== null)\r\n\t\t\t\t\t) {\r\n\t\t\t\t\t\treturn {\r\n\t\t\t\t\t\t\tdefault: exportValue as React.ComponentType,\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Если ничего не найдено, возвращаем ошибку\r\n\t\t\tconst availableExports =\r\n\t\t\t\tmodule && typeof module === 'object'\r\n\t\t\t\t\t? Object.keys(module).join(', ')\r\n\t\t\t\t\t: 'unknown'\r\n\t\t\tthrow new Error(\r\n\t\t\t\t`No valid export found in module for route ${n.path}. Available exports: ${availableExports}`\r\n\t\t\t)\r\n\t\t})\r\n\r\n\t\tconst element = wrapLayouts(n.layouts, <Page />)\r\n\t\treturn <Route key={n.id} path={n.path} element={element} />\r\n\t})\r\n}\r\n","import { useLink } from './components/hooks/use-links'\r\nimport { Link } from './components/link'\r\nimport RouterProvider from './components/router-provider'\r\n\r\n// Реэкспорт всего необходимого из react-router-dom\r\nexport {\r\n\tNavigate,\r\n\t// Компоненты\r\n\tNavLink, useLocation,\r\n\t// Хуки\r\n\tuseNavigate, useParams,\r\n\tuseSearchParams,\r\n\t// Типы\r\n\ttype LinkProps, type Location, type NavigateOptions, type NavigateProps, type NavLinkProps, type Params, type To\r\n} from 'react-router-dom'\r\n\r\n// Основные экспорты плагина\r\nexport { Link, RouterProvider, useLink }\r\n\r\n// Собственные типы\r\nexport type { RouterProviderProps } from './components/types/types'\r\n"],"mappings":";AAAA,SAAS,mBAAmB;AAErB,SAAS,QAAQ,OAAyB;AAC/C,QAAM,WAAW,YAAY;AAC7B,QAAM,cAAc,SAAS;AAE7B,SAAO;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AI,wBAAwB,gBAAgB;AAAA,MAC5F;AAAA,IACD,CAAC;AAED,UAAM,UAAU,YAAY,EAAE,SAAS,oBAAC,QAAK,CAAE;AAC/C,WAAO,oBAAC,SAAiB,MAAM,EAAE,MAAM,WAApB,EAAE,EAAoC;AAAA,EAC1D,CAAC;AACF;;;ADtDqD,gBAAAC,YAAA;AAP9C,IAAM,eAAe,CAAC;AAAA,EAC5B,UAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AACZ,MACC,gBAAAD,KAAC,iBAAc,UAAU,UACxB,0BAAAA,KAACE,OAAM,UAAN,EAAe,UAAU,YAAY,aAAa,gBAAAF,KAAC,SAAI,wBAAU,GACjE,0BAAAA,KAAC,UAAQ,iCAAuBC,SAAQ,GAAE,GAC3C,GACD;;;ADFC,gBAAAE,YAAA;AATa,SAAR,eAAgC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AACD,GAAkC;AAEjC,QAAM,gBAAgB,YAAY,kBAAkB;AAEpD,SACC,gBAAAA,KAAC,gBAAa,UAAoB,WAAsB,UAAU,eAChE,UACF;AAEF;;;AGZA;AAAA,EACC;AAAA,EAEA;AAAA,EAAS,eAAAC;AAAA,EAET;AAAA,EAAa;AAAA,EACb;AAAA,OAGM;","names":["React","manifest","jsx","manifest","React","jsx","useLocation"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/link.tsx","../src/components/hooks/use-location.ts","../src/components/hooks/use-links.tsx","../src/components/nav-link.tsx","../src/components/navigate.tsx","../src/components/route-transition.tsx","../src/components/router-provider.tsx","../src/components/router-layout.tsx","../src/components/router-utils.tsx","../src/components/error-boundary.tsx","../src/components/hooks/use-navigate.ts","../src/components/hooks/use-params.ts","../src/components/hooks/use-search-params.ts"],"sourcesContent":["import type { LinkProps as ReactRouterLinkProps } from 'react-router-dom'\r\nimport { Link as ReactRouterLink } from 'react-router-dom'\r\n\r\nexport type LinkProps = ReactRouterLinkProps\r\n\r\n/**\r\n * Компонент для навигационных ссылок\r\n * \r\n * Используется для клиентской навигации без перезагрузки страницы\r\n * \r\n * @example\r\n * ```tsx\r\n * <Link to=\"/about\">About</Link>\r\n * <Link to=\"/users/123\" state={{ from: 'home' }}>User Profile</Link>\r\n * ```\r\n */\r\nexport const Link = ReactRouterLink\r\n\r\nexport { useLink } from './hooks/use-links'\r\n","import { useLocation as useRouterLocation } from 'react-router-dom'\r\nimport type { Location as RouterLocation } from 'react-router-dom'\r\n\r\n/**\r\n * Тип локации с информацией о текущем маршруте\r\n */\r\nexport type Location = RouterLocation\r\n\r\n/**\r\n * Хук для получения текущей локации\r\n * \r\n * @returns Объект с информацией о текущем маршруте\r\n * \r\n * @example\r\n * ```tsx\r\n * const location = useLocation()\r\n * console.log(location.pathname) // '/about'\r\n * console.log(location.search) // '?id=123'\r\n * ```\r\n */\r\nexport function useLocation(): Location {\r\n\treturn useRouterLocation()\r\n}\r\n","import { useLocation } from './use-location'\r\n\r\nexport function useLink(props: { href: string }) {\r\n const location = useLocation()\r\n const currentPath = location.pathname\r\n \r\n return {\r\n href: props.href,\r\n isActive: currentPath === props.href,\r\n }\r\n}","import type { NavLinkProps as ReactRouterNavLinkProps } from 'react-router-dom'\r\nimport { NavLink as ReactRouterNavLink } from 'react-router-dom'\r\n\r\nexport type NavLinkProps = ReactRouterNavLinkProps\r\n\r\n/**\r\n * Компонент для навигационных ссылок с поддержкой активного состояния\r\n * \r\n * Автоматически добавляет класс 'active' когда маршрут активен\r\n * \r\n * @example\r\n * ```tsx\r\n * <NavLink to=\"/about\">About</NavLink>\r\n * <NavLink to=\"/users\" className={({ isActive }) => isActive ? 'active' : ''}>\r\n * Users\r\n * </NavLink>\r\n * ```\r\n */\r\nexport const NavLink = ReactRouterNavLink\r\n","import type { NavigateProps as ReactRouterNavigateProps } from 'react-router-dom'\r\nimport { Navigate as ReactRouterNavigate } from 'react-router-dom'\r\n\r\nexport type NavigateProps = ReactRouterNavigateProps\r\n\r\n/**\r\n * Компонент для программного редиректа\r\n * \r\n * @example\r\n * ```tsx\r\n * <Navigate to=\"/login\" replace />\r\n * <Navigate to=\"/dashboard\" state={{ from: location }} />\r\n * ```\r\n */\r\nexport const Navigate = ReactRouterNavigate\r\n","import React, { useEffect, useState, useRef } from 'react'\r\nimport { useLocation } from './hooks/use-location'\r\n\r\nexport interface RouteTransitionProps {\r\n\tchildren: React.ReactNode\r\n\t/**\r\n\t * CSS класс для анимации входа\r\n\t * @default 'route-enter'\r\n\t */\r\n\tenterClass?: string\r\n\t/**\r\n\t * CSS класс для активного состояния (после входа)\r\n\t * @default 'route-enter-active'\r\n\t */\r\n\tenterActiveClass?: string\r\n\t/**\r\n\t * CSS класс для анимации выхода\r\n\t * @default 'route-exit'\r\n\t */\r\n\texitClass?: string\r\n\t/**\r\n\t * CSS класс для активного состояния выхода\r\n\t * @default 'route-exit-active'\r\n\t */\r\n\texitActiveClass?: string\r\n\t/**\r\n\t * Длительность анимации в миллисекундах\r\n\t * @default 300\r\n\t */\r\n\tduration?: number\r\n\t/**\r\n\t * Кастомная функция для анимации\r\n\t */\r\n\tonTransition?: (direction: 'enter' | 'exit') => void\r\n\t/**\r\n\t * Режим анимации: 'fade', 'slide', 'custom'\r\n\t * @default 'fade'\r\n\t */\r\n\tmode?: 'fade' | 'slide' | 'custom'\r\n}\r\n\r\nexport function RouteTransition({\r\n\tchildren,\r\n\tenterClass = 'route-enter',\r\n\tenterActiveClass = 'route-enter-active',\r\n\texitClass = 'route-exit',\r\n\texitActiveClass = 'route-exit-active',\r\n\tduration = 300,\r\n\tonTransition,\r\n\tmode = 'fade',\r\n}: RouteTransitionProps) {\r\n\tconst location = useLocation()\r\n\tconst [displayChildren, setDisplayChildren] = useState(children)\r\n\tconst [isExiting, setIsExiting] = useState(false)\r\n\tconst [isEntering, setIsEntering] = useState(false)\r\n\tconst prevLocationRef = useRef(location.pathname)\r\n\tconst timeoutRef = useRef<NodeJS.Timeout | null>(null)\r\n\r\n\tuseEffect(() => {\r\n\t\tif (prevLocationRef.current !== location.pathname) {\r\n\t\t\t// Очищаем предыдущий таймер если есть\r\n\t\t\tif (timeoutRef.current) {\r\n\t\t\t\tclearTimeout(timeoutRef.current)\r\n\t\t\t}\r\n\r\n\t\t\t// Начинаем анимацию выхода\r\n\t\t\tsetIsExiting(true)\r\n\t\t\tsetIsEntering(false)\r\n\t\t\tonTransition?.('exit')\r\n\r\n\t\t\ttimeoutRef.current = setTimeout(() => {\r\n\t\t\t\t// Меняем контент\r\n\t\t\t\tsetDisplayChildren(children)\r\n\t\t\t\tsetIsExiting(false)\r\n\t\t\t\tsetIsEntering(true)\r\n\t\t\t\tonTransition?.('enter')\r\n\r\n\t\t\t\t// Начинаем анимацию входа\r\n\t\t\t\ttimeoutRef.current = setTimeout(() => {\r\n\t\t\t\t\tsetIsEntering(false)\r\n\t\t\t\t\ttimeoutRef.current = null\r\n\t\t\t\t}, duration)\r\n\t\t\t}, duration)\r\n\r\n\t\t\tprevLocationRef.current = location.pathname\r\n\t\t} else {\r\n\t\t\t// Если location не изменился, просто обновляем children\r\n\t\t\tsetDisplayChildren(children)\r\n\t\t}\r\n\r\n\t\treturn () => {\r\n\t\t\tif (timeoutRef.current) {\r\n\t\t\t\tclearTimeout(timeoutRef.current)\r\n\t\t\t\ttimeoutRef.current = null\r\n\t\t\t}\r\n\t\t}\r\n\t}, [location.pathname, children, duration, onTransition])\r\n\r\n\t// Определяем классы в зависимости от состояния\r\n\tconst getClassName = () => {\r\n\t\tif (isExiting) {\r\n\t\t\treturn `${exitClass} ${exitActiveClass}`\r\n\t\t}\r\n\t\tif (isEntering) {\r\n\t\t\treturn `${enterClass} ${enterActiveClass}`\r\n\t\t}\r\n\t\treturn ''\r\n\t}\r\n\r\n\t// Стили для режима fade (по умолчанию)\r\n\tconst getDefaultStyles = () => {\r\n\t\tif (mode === 'fade') {\r\n\t\t\treturn {\r\n\t\t\t\ttransition: `opacity ${duration}ms ease-in-out`,\r\n\t\t\t\topacity: isExiting ? 0 : isEntering ? 0 : 1,\r\n\t\t\t}\r\n\t\t}\r\n\t\tif (mode === 'slide') {\r\n\t\t\treturn {\r\n\t\t\t\ttransition: `transform ${duration}ms ease-in-out, opacity ${duration}ms ease-in-out`,\r\n\t\t\t\ttransform: isExiting\r\n\t\t\t\t\t? 'translateX(-100%)'\r\n\t\t\t\t\t: isEntering\r\n\t\t\t\t\t\t? 'translateX(100%)'\r\n\t\t\t\t\t\t: 'translateX(0)',\r\n\t\t\t\topacity: isExiting ? 0 : isEntering ? 0 : 1,\r\n\t\t\t}\r\n\t\t}\r\n\t\treturn {}\r\n\t}\r\n\r\n\treturn (\r\n\t\t<div className={getClassName()} style={getDefaultStyles()}>\r\n\t\t\t{displayChildren}\r\n\t\t</div>\r\n\t)\r\n}\r\n","import {\r\n\tbasePath as configBasePath,\r\n\tglobalNotFound,\r\n\tmanifest,\r\n} from 'virtual:routes'\r\nimport { RouterLayout } from './router-layout'\r\nimport type { RouterProviderProps } from './types/types'\r\n\r\nexport default function RouterProvider({\r\n\tchildren,\r\n\tpreloader,\r\n\tbasePath,\r\n\tenableTransitions,\r\n\ttransitionConfig,\r\n}: Readonly<RouterProviderProps>) {\r\n\t// Используем basePath из пропсов, если указан, иначе из конфигурации\r\n\tconst finalBasePath = basePath ?? configBasePath ?? '/'\r\n\t\r\n\treturn (\r\n\t\t<RouterLayout\r\n\t\t\tmanifest={manifest}\r\n\t\t\tpreloader={preloader}\r\n\t\t\tbasePath={finalBasePath}\r\n\t\t\tglobalNotFound={globalNotFound}\r\n\t\t\tenableTransitions={enableTransitions}\r\n\t\t\ttransitionConfig={transitionConfig}\r\n\t\t>\r\n\t\t\t{children}\r\n\t\t</RouterLayout>\r\n\t)\r\n}\r\n","import React from 'react'\r\nimport { BrowserRouter, Routes } from 'react-router-dom'\r\nimport { RouteTransition } from './route-transition'\r\nimport { renderManifestAsRoutes } from './router-utils'\r\nimport type { RouterLayoutProps } from './types/types'\r\n\r\nexport const RouterLayout = ({\r\n\tmanifest,\r\n\tchildren,\r\n\tpreloader,\r\n\tbasePath = '/',\r\n\tglobalNotFound,\r\n\tenableTransitions = false,\r\n\ttransitionConfig,\r\n}: RouterLayoutProps) => {\r\n\tconst routes = renderManifestAsRoutes(manifest, globalNotFound)\r\n\tconst routesElement = <Routes>{routes}</Routes>\r\n\r\n\treturn (\r\n\t\t<BrowserRouter basename={basePath}>\r\n\t\t\t<React.Suspense fallback={children || preloader || <div>Loading...</div>}>\r\n\t\t\t\t{enableTransitions ? (\r\n\t\t\t\t\t<RouteTransition {...transitionConfig}>{routesElement}</RouteTransition>\r\n\t\t\t\t) : (\r\n\t\t\t\t\troutesElement\r\n\t\t\t\t)}\r\n\t\t\t</React.Suspense>\r\n\t\t</BrowserRouter>\r\n\t)\r\n}\r\n","import React from 'react'\r\nimport { Route } from 'react-router-dom'\r\nimport { ErrorBoundary } from './error-boundary'\r\nimport type { Node } from './types/types'\r\n\r\nfunction wrapLayouts(\r\n\tlayouts: Node['layouts'] | undefined,\r\n\tpageEl: React.ReactNode\r\n) {\r\n\tif (!layouts || layouts.length === 0) return pageEl\r\n\r\n\treturn layouts.reduceRight((child, loader) => {\r\n\t\tconst Layout = React.lazy(async () => {\r\n\t\t\tconst module = await loader()\r\n\t\t\t// Поддерживаем как default, так и именованный экспорт Layout\r\n\t\t\treturn 'default' in module ? module : { default: module.Layout }\r\n\t\t})\r\n\t\treturn <Layout>{child}</Layout>\r\n\t}, pageEl as React.ReactElement)\r\n}\r\n\r\nfunction createLoadingFallback(loadingLoader?: () => Promise<{ default: React.ComponentType }>) {\r\n\tif (!loadingLoader) return undefined\r\n\t\r\n\t// Loading компонент lazy, но он используется как fallback в Suspense\r\n\tconst Loading = React.lazy(loadingLoader)\r\n\treturn <Loading />\r\n}\r\n\r\nfunction createErrorFallback(errorLoader?: () => Promise<{ default: React.ComponentType<{ error?: Error; resetError?: () => void }> }>) {\r\n\tif (!errorLoader) return undefined\r\n\t\r\n\tconst ErrorComponent = React.lazy(errorLoader)\r\n\treturn (props: { error?: Error; resetError?: () => void }) => <ErrorComponent {...props} />\r\n}\r\n\r\nexport const renderManifestAsRoutes = (\r\n\tmanifest: Node[],\r\n\tglobalNotFound?: () => Promise<{ default: React.ComponentType }>\r\n) => {\r\n\treturn manifest.map(n => {\r\n\t\tconst Page = React.lazy(async () => {\r\n\t\t\tconst module = await n.loader()\r\n\r\n\t\t\t// Если есть default экспорт, используем его\r\n\t\t\tif (\r\n\t\t\t\tmodule &&\r\n\t\t\t\ttypeof module === 'object' &&\r\n\t\t\t\t'default' in module &&\r\n\t\t\t\tmodule.default\r\n\t\t\t) {\r\n\t\t\t\treturn module as { default: React.ComponentType }\r\n\t\t\t}\r\n\r\n\t\t\t// Ищем любой именованный экспорт, который является функцией или компонентом\r\n\t\t\tif (module && typeof module === 'object') {\r\n\t\t\t\tconst namedExports = Object.keys(module).filter(\r\n\t\t\t\t\tkey => key !== 'default'\r\n\t\t\t\t)\r\n\t\t\t\tfor (const key of namedExports) {\r\n\t\t\t\t\tconst exportValue = module[key]\r\n\t\t\t\t\tif (\r\n\t\t\t\t\t\ttypeof exportValue === 'function' ||\r\n\t\t\t\t\t\t(typeof exportValue === 'object' && exportValue !== null)\r\n\t\t\t\t\t) {\r\n\t\t\t\t\t\treturn {\r\n\t\t\t\t\t\t\tdefault: exportValue as React.ComponentType,\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Если ничего не найдено, возвращаем ошибку\r\n\t\t\tconst availableExports =\r\n\t\t\t\tmodule && typeof module === 'object'\r\n\t\t\t\t\t? Object.keys(module).join(', ')\r\n\t\t\t\t\t: 'unknown'\r\n\t\t\tthrow new Error(\r\n\t\t\t\t`No valid export found in module for route ${n.path}. Available exports: ${availableExports}`\r\n\t\t\t)\r\n\t\t})\r\n\r\n\t\tconst loadingFallback = createLoadingFallback(n.loading)\r\n\t\tconst errorFallback = createErrorFallback(n.error)\r\n\t\t\r\n\t\tconst pageElement = wrapLayouts(n.layouts, <Page />)\r\n\t\t\r\n\t\t// Оборачиваем в ErrorBoundary если есть error компонент\r\n\t\tconst wrappedElement = errorFallback ? (\r\n\t\t\t<ErrorBoundary fallback={errorFallback}>\r\n\t\t\t\t{pageElement}\r\n\t\t\t</ErrorBoundary>\r\n\t\t) : pageElement\r\n\r\n\t\t// Оборачиваем в Suspense с loading fallback\r\n\t\tconst element = loadingFallback ? (\r\n\t\t\t<React.Suspense fallback={loadingFallback}>\r\n\t\t\t\t{wrappedElement}\r\n\t\t\t</React.Suspense>\r\n\t\t) : (\r\n\t\t\t<React.Suspense fallback={<div>Loading...</div>}>\r\n\t\t\t\t{wrappedElement}\r\n\t\t\t</React.Suspense>\r\n\t\t)\r\n\r\n\t\treturn <Route key={n.id} path={n.path} element={element} />\r\n\t}).concat(\r\n\t\t// Добавляем 404 маршрут в конец\r\n\t\tglobalNotFound ? (\r\n\t\t\t<Route\r\n\t\t\t\tkey=\"__not_found__\"\r\n\t\t\t\tpath=\"*\"\r\n\t\t\t\telement={\r\n\t\t\t\t\t<React.Suspense fallback={<div>Loading...</div>}>\r\n\t\t\t\t\t\t{(() => {\r\n\t\t\t\t\t\t\tconst NotFound = React.lazy(globalNotFound)\r\n\t\t\t\t\t\t\treturn <NotFound />\r\n\t\t\t\t\t\t})()}\r\n\t\t\t\t\t</React.Suspense>\r\n\t\t\t\t}\r\n\t\t\t/>\r\n\t\t) : (\r\n\t\t\t<Route\r\n\t\t\t\tkey=\"__not_found__\"\r\n\t\t\t\tpath=\"*\"\r\n\t\t\t\telement={\r\n\t\t\t\t\t<div style={{ padding: '20px', textAlign: 'center' }}>\r\n\t\t\t\t\t\t<h1>404</h1>\r\n\t\t\t\t\t\t<p>Page not found</p>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t}\r\n\t\t\t/>\r\n\t\t)\r\n\t)\r\n}\r\n","import React from 'react'\r\n\r\nexport interface ErrorBoundaryProps {\r\n\tchildren: React.ReactNode\r\n\tfallback?: React.ComponentType<{ error?: Error; resetError?: () => void }>\r\n\tonError?: (error: Error, errorInfo: React.ErrorInfo) => void\r\n}\r\n\r\ninterface ErrorBoundaryState {\r\n\thasError: boolean\r\n\terror: Error | null\r\n}\r\n\r\n/**\r\n * ErrorBoundary компонент для обработки ошибок рендеринга\r\n */\r\nexport class ErrorBoundary extends React.Component<\r\n\tErrorBoundaryProps,\r\n\tErrorBoundaryState\r\n> {\r\n\tconstructor(props: ErrorBoundaryProps) {\r\n\t\tsuper(props)\r\n\t\tthis.state = { hasError: false, error: null }\r\n\t}\r\n\r\n\tstatic getDerivedStateFromError(error: Error): ErrorBoundaryState {\r\n\t\treturn { hasError: true, error }\r\n\t}\r\n\r\n\tcomponentDidCatch(error: Error, errorInfo: React.ErrorInfo) {\r\n\t\tthis.props.onError?.(error, errorInfo)\r\n\t}\r\n\r\n\tresetError = () => {\r\n\t\tthis.setState({ hasError: false, error: null })\r\n\t}\r\n\r\n\trender() {\r\n\t\tif (this.state.hasError && this.state.error) {\r\n\t\t\tif (this.props.fallback) {\r\n\t\t\t\tconst Fallback = this.props.fallback\r\n\t\t\t\treturn <Fallback error={this.state.error} resetError={this.resetError} />\r\n\t\t\t}\r\n\t\t\treturn (\r\n\t\t\t\t<div style={{ padding: '20px' }}>\r\n\t\t\t\t\t<h2>Something went wrong</h2>\r\n\t\t\t\t\t<pre>{this.state.error.message}</pre>\r\n\t\t\t\t\t<button onClick={this.resetError}>Try again</button>\r\n\t\t\t\t</div>\r\n\t\t\t)\r\n\t\t}\r\n\r\n\t\treturn this.props.children\r\n\t}\r\n}\r\n","import { useNavigate as useRouterNavigate } from 'react-router-dom'\r\n\r\nexport type NavigateOptions = {\r\n\treplace?: boolean\r\n\tstate?: unknown\r\n\trelative?: 'route' | 'path'\r\n}\r\n\r\nexport type To = string | number | { pathname?: string; search?: string; hash?: string }\r\n\r\n/**\r\n * Хук для программной навигации\r\n * \r\n * @returns Функция для навигации\r\n * \r\n * @example\r\n * ```tsx\r\n * const navigate = useNavigate()\r\n * navigate('/about')\r\n * navigate('/users', { replace: true })\r\n * navigate(-1) // назад\r\n * ```\r\n */\r\nexport function useNavigate() {\r\n\treturn useRouterNavigate()\r\n}\r\n","import { useParams as useRouterParams } from 'react-router-dom'\r\n\r\nexport type Params = Record<string, string | undefined>\r\n\r\n/**\r\n * Хук для получения параметров маршрута\r\n * \r\n * @returns Объект с параметрами текущего маршрута\r\n * \r\n * @example\r\n * ```tsx\r\n * // Для маршрута /users/:id\r\n * const { id } = useParams()\r\n * ```\r\n */\r\nexport function useParams<T extends Params = Params>(): T {\r\n\treturn useRouterParams() as T\r\n}\r\n","import { useSearchParams as useRouterSearchParams } from 'react-router-dom'\r\n\r\n/**\r\n * Хук для работы с query параметрами URL\r\n * \r\n * @returns Кортеж из [searchParams, setSearchParams]\r\n * \r\n * @example\r\n * ```tsx\r\n * const [searchParams, setSearchParams] = useSearchParams()\r\n * const id = searchParams.get('id')\r\n * setSearchParams({ id: '123' })\r\n * ```\r\n */\r\nexport function useSearchParams() {\r\n\treturn useRouterSearchParams()\r\n}\r\n"],"mappings":";AACA,SAAS,QAAQ,uBAAuB;;;ACDxC,SAAS,eAAe,yBAAyB;AAoB1C,SAAS,cAAwB;AACvC,SAAO,kBAAkB;AAC1B;;;ACpBO,SAAS,QAAQ,OAAyB;AAC/C,QAAM,WAAW,YAAY;AAC7B,QAAM,cAAc,SAAS;AAE7B,SAAO;AAAA,IACL,MAAM,MAAM;AAAA,IACZ,UAAU,gBAAgB,MAAM;AAAA,EAClC;AACF;;;AFMO,IAAM,OAAO;;;AGfpB,SAAS,WAAW,0BAA0B;AAiBvC,IAAM,UAAU;;;ACjBvB,SAAS,YAAY,2BAA2B;AAazC,IAAM,WAAW;;;ACdxB,SAAgB,WAAW,UAAU,cAAc;AAoIjD;AA3FK,SAAS,gBAAgB;AAAA,EAC/B;AAAA,EACA,aAAa;AAAA,EACb,mBAAmB;AAAA,EACnB,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,WAAW;AAAA,EACX;AA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AAS,GAClD;AAAA,0BAAAD,KAAC,QAAG,iBAAG;AAAA,UACP,gBAAAA,KAAC,OAAE,4BAAc;AAAA,WAClB;AAAA;AAAA,MANG;AAAA,IAQL;AAAA,EAEF;AACD;;;ADtHuB,gBAAAK,YAAA;AAVhB,IAAM,eAAe,CAAC;AAAA,EAC5B,UAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,gBAAAC;AAAA,EACA,oBAAoB;AAAA,EACpB;AACD,MAAyB;AACxB,QAAM,SAAS,uBAAuBD,WAAUC,eAAc;AAC9D,QAAM,gBAAgB,gBAAAF,KAAC,UAAQ,kBAAO;AAEtC,SACC,gBAAAA,KAAC,iBAAc,UAAU,UACxB,0BAAAA,KAACG,OAAM,UAAN,EAAe,UAAU,YAAY,aAAa,gBAAAH,KAAC,SAAI,wBAAU,GAChE,8BACA,gBAAAA,KAAC,mBAAiB,GAAG,kBAAmB,yBAAc,IAEtD,eAEF,GACD;AAEF;;;ADVE,gBAAAI,YAAA;AAXa,SAAR,eAAgC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAkC;AAEjC,QAAM,gBAAgB,YAAY,kBAAkB;AAEpD,SACC,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA;AAAA,MACA;AAAA,MAEC;AAAA;AAAA,EACF;AAEF;;;AI9BA,SAAS,eAAe,yBAAyB;AAuB1C,SAAS,cAAc;AAC7B,SAAO,kBAAkB;AAC1B;;;ACzBA,SAAS,aAAa,uBAAuB;AAetC,SAAS,YAA0C;AACzD,SAAO,gBAAgB;AACxB;;;ACjBA,SAAS,mBAAmB,6BAA6B;AAclD,SAAS,kBAAkB;AACjC,SAAO,sBAAsB;AAC9B;","names":["React","React","React","jsx","jsx","jsxs","React","manifest","globalNotFound","jsx","manifest","globalNotFound","React","jsx"]}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts","../src/core/build-generator.ts","../src/core/metadata.ts","../src/core/route-generator.ts","../src/core/scanner.ts","../src/core/utils.ts","../src/core/type-generator.ts","../src/core/hmr-handlers.ts","../src/core/manifest-loader.ts","../src/core/virtual-module.ts"],"sourcesContent":["import fs from 'node:fs'\r\nimport path from 'node:path'\r\nimport type { Plugin, UserConfig } from 'vite'\r\nimport { generateSEOFiles, generateTypes } from './core/build-generator'\r\nimport { createHMRHandlers } from './core/hmr-handlers'\r\nimport { loadGeneratedManifest } from './core/manifest-loader'\r\nimport type { Options } from './core/types/types'\r\nimport { generateVirtualModuleCode } from './core/virtual-module'\r\n\r\nexport type { Options } from './core/types/types'\r\n\r\nexport function pathRushRouting(rawOpts: Options = {}): Plugin {\r\n\tconst opts: Required<Options> = {\r\n\t\tpagesDir: rawOpts.pagesDir ?? 'src/pages',\r\n\t\tpageFileName: rawOpts.pageFileName ?? 'page',\r\n\t\tlayoutFileName: rawOpts.layoutFileName ?? 'layout',\r\n\t\textensions: rawOpts.extensions ?? ['tsx'],\r\n\t\tbaseUrl: rawOpts.baseUrl ?? 'http://localhost:5173',\r\n\t\tbasePath: rawOpts.basePath ?? '/',\r\n\t\tdisallowPaths: rawOpts.disallowPaths ?? [],\r\n\t\tgenerateTypes: rawOpts.generateTypes ?? true,\r\n\t\tenableSEO: rawOpts.enableSEO ?? true,\r\n\t}\r\n\r\n\tconst VIRTUAL_ID = 'virtual:routes'\r\n\tconst RESOLVED_VIRTUAL_ID = '\\0' + VIRTUAL_ID\r\n\tlet root = process.cwd()\r\n\tlet resolvedPagesDir = path.resolve(root, opts.pagesDir)\r\n\r\n\tconst plugin: Plugin = {\r\n\t\tname: 'vite-plugin-file-router-mwv',\r\n\t\tenforce: 'pre',\r\n\r\n\t\t// Автоматическая настройка Vite конфигурации\r\n\t\tconfig(userConfig: UserConfig): UserConfig {\r\n\t\t\tconst existingAlias = userConfig.resolve?.alias\r\n\t\t\tconst existingExclude = userConfig.optimizeDeps?.exclude\r\n\r\n\t\t\t// Безопасно мерджим с существующей конфигурацией\r\n\t\t\treturn {\r\n\t\t\t\toptimizeDeps: {\r\n\t\t\t\t\texclude: [\r\n\t\t\t\t\t\t...(Array.isArray(existingExclude) ? existingExclude : []),\r\n\t\t\t\t\t\t'virtual:routes',\r\n\t\t\t\t\t],\r\n\t\t\t\t},\r\n\t\t\t\tresolve: {\r\n\t\t\t\t\talias: {\r\n\t\t\t\t\t\t...(typeof existingAlias === 'object' ? existingAlias : {}),\r\n\t\t\t\t\t\t'virtual:routes': 'virtual:routes',\r\n\t\t\t\t\t},\r\n\t\t\t\t},\r\n\t\t\t}\r\n\t\t},\r\n\r\n\t\tresolveId(id: string) {\r\n\t\t\tif (id === VIRTUAL_ID) return RESOLVED_VIRTUAL_ID\r\n\t\t\treturn null\r\n\t\t},\r\n\r\n\t\tasync load(id: string) {\r\n\t\t\tif (id === RESOLVED_VIRTUAL_ID) {\r\n\t\t\t\t// В production режиме проверяем существование директории pages\r\n\t\t\t\tif (!fs.existsSync(resolvedPagesDir)) {\r\n\t\t\t\t\t// В production пытаемся загрузить сгенерированный манифест\r\n\t\t\t\t\treturn await loadGeneratedManifest(root)\r\n\t\t\t\t}\r\n\r\n\t\t\t\treturn await generateVirtualModuleCode(resolvedPagesDir, opts)\r\n\t\t\t}\r\n\t\t\treturn null\r\n\t\t},\r\n\r\n\t\tasync buildStart() {\r\n\t\t\troot = process.cwd()\r\n\t\t\tresolvedPagesDir = path.resolve(root, opts.pagesDir)\r\n\r\n\t\t\tif (!fs.existsSync(resolvedPagesDir)) {\r\n\t\t\t\tconsole.warn(\r\n\t\t\t\t\t`[vite-plugin-file-router] pagesDir \"${resolvedPagesDir}\" not found.`\r\n\t\t\t\t)\r\n\t\t\t}\r\n\t\t},\r\n\r\n\t\tasync generateBundle() {\r\n\t\t\t// Проверяем существование директории pages\r\n\t\t\tif (!fs.existsSync(resolvedPagesDir)) {\r\n\t\t\t\tconsole.warn(\r\n\t\t\t\t\t`[vite-plugin-file-router] pagesDir \"${resolvedPagesDir}\" not found in production build. Skipping route generation.`\r\n\t\t\t\t)\r\n\t\t\t\treturn\r\n\t\t\t}\r\n\r\n\t\t\t// Генерируем TypeScript типы\r\n\t\t\tif (opts.generateTypes) {\r\n\t\t\t\ttry {\r\n\t\t\t\t\tawait generateTypes(resolvedPagesDir, opts)\r\n\t\t\t\t} catch (error) {\r\n\t\t\t\t\tconsole.warn(\r\n\t\t\t\t\t\t`[vite-plugin-file-router] Failed to generate types: ${error}`\r\n\t\t\t\t\t)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\t// Генерируем SEO файлы\r\n\t\t\tif (opts.enableSEO) {\r\n\t\t\t\ttry {\r\n\t\t\t\t\tawait generateSEOFiles(resolvedPagesDir, opts)\r\n\t\t\t\t} catch (error) {\r\n\t\t\t\t\tconsole.warn(\r\n\t\t\t\t\t\t`[vite-plugin-file-router] Failed to generate SEO files: ${error}`\r\n\t\t\t\t\t)\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t},\r\n\t}\r\n\r\n\t// Добавляем HMR только если в development режиме\r\n\tif (process.env.NODE_ENV !== 'production') {\r\n\t\tconst { configureServer, handleHotUpdate } = createHMRHandlers(\r\n\t\t\tresolvedPagesDir,\r\n\t\t\tRESOLVED_VIRTUAL_ID,\r\n\t\t\troot\r\n\t\t)\r\n\t\tplugin.configureServer = configureServer\r\n\t\tplugin.handleHotUpdate = handleHotUpdate\r\n\t}\r\n\r\n\treturn plugin\r\n}\r\n","import fs from 'node:fs'\r\nimport path from 'node:path'\r\nimport { extractMetadata, generateRobots, generateSitemap } from './metadata'\r\nimport { createRouteEntry } from './route-generator'\r\nimport { scanPages } from './scanner'\r\nimport { generateMetadataTypes, generateRouteTypes } from './type-generator'\r\nimport type { Options } from './types/types'\r\n\r\nexport async function generateTypes(\r\n\tresolvedPagesDir: string,\r\n\topts: Required<Options>\r\n) {\r\n\tconst pages = await scanPages(resolvedPagesDir, opts)\r\n\tconst routes = pages.map(fp => createRouteEntry(fp, resolvedPagesDir, opts))\r\n\r\n\tconst routeTypes = generateRouteTypes(routes)\r\n\tconst metadataTypes = generateMetadataTypes()\r\n\r\n\t// Создаем директорию для типов\r\n\tconst typesDir = path.join(process.cwd(), 'dist', 'types')\r\n\tif (!fs.existsSync(typesDir)) {\r\n\t\tfs.mkdirSync(typesDir, { recursive: true })\r\n\t}\r\n\r\n\tfs.writeFileSync(path.join(typesDir, 'routes.d.ts'), routeTypes)\r\n\tfs.writeFileSync(path.join(typesDir, 'metadata.d.ts'), metadataTypes)\r\n}\r\n\r\nexport async function generateSEOFiles(\r\n\tresolvedPagesDir: string,\r\n\topts: Required<Options>\r\n) {\r\n\tconst pages = await scanPages(resolvedPagesDir, opts)\r\n\tconst routesWithMetadata = pages\r\n\t\t.map(fp => {\r\n\t\t\tconst entry = createRouteEntry(fp, resolvedPagesDir, opts)\r\n\t\t\tconst metadata = extractMetadata(fp)\r\n\t\t\treturn {\r\n\t\t\t\tpath: entry.path,\r\n\t\t\t\tmetadata: metadata || undefined,\r\n\t\t\t}\r\n\t\t})\r\n\t\t.filter(\r\n\t\t\troute =>\r\n\t\t\t\t!opts.disallowPaths.some(disallow => route.path.startsWith(disallow))\r\n\t\t)\r\n\r\n\t// Генерируем sitemap.xml и robots.txt\r\n\tconst sitemap = generateSitemap(routesWithMetadata, opts.baseUrl)\r\n\tconst robots = generateRobots(opts.baseUrl, opts.disallowPaths)\r\n\r\n\tconst distDir = path.join(process.cwd(), 'dist')\r\n\tif (!fs.existsSync(distDir)) {\r\n\t\tfs.mkdirSync(distDir, { recursive: true })\r\n\t}\r\n\r\n\tfs.writeFileSync(path.join(distDir, 'sitemap.xml'), sitemap)\r\n\tfs.writeFileSync(path.join(distDir, 'robots.txt'), robots)\r\n}\r\n","import fs from 'node:fs'\r\nimport type { PageMetadata } from './types/types'\r\n\r\nexport function extractMetadata(filePath: string): PageMetadata | null {\r\n\ttry {\r\n\t\tconst content = fs.readFileSync(filePath, 'utf-8')\r\n\r\n\t\t// Парсинг JSDoc комментариев\r\n\t\tconst jsdocMetadata = extractJSDocMetadata(content)\r\n\t\tif (jsdocMetadata) {\r\n\t\t\treturn jsdocMetadata\r\n\t\t}\r\n\r\n\t\t// Парсинг экспорта metadata\r\n\t\tconst exportMetadata = extractExportMetadata(content)\r\n\t\tif (exportMetadata) {\r\n\t\t\treturn exportMetadata\r\n\t\t}\r\n\r\n\t\treturn null\r\n\t} catch (error) {\r\n\t\tconsole.warn(\r\n\t\t\t`[vite-plugin-file-router] Failed to extract metadata from ${filePath}:`,\r\n\t\t\terror\r\n\t\t)\r\n\t\treturn null\r\n\t}\r\n}\r\n\r\nfunction extractJSDocMetadata(content: string): PageMetadata | null {\r\n\tconst jsdocMatch = content.match(/\\/\\*\\*([\\s\\S]*?)\\*\\//)\r\n\tif (!jsdocMatch) return null\r\n\r\n\tconst jsdoc = jsdocMatch[1]\r\n\tconst metadata: PageMetadata = {}\r\n\r\n\t// Парсинг JSDoc тегов\r\n\tconst titleMatch = jsdoc.match(/@title\\s+(.+)/)\r\n\tif (titleMatch) metadata.title = titleMatch[1].trim()\r\n\r\n\tconst descMatch = jsdoc.match(/@description\\s+(.+)/)\r\n\tif (descMatch) metadata.description = descMatch[1].trim()\r\n\r\n\tconst keywordsMatch = jsdoc.match(/@keywords\\s+(.+)/)\r\n\tif (keywordsMatch) {\r\n\t\tmetadata.keywords = keywordsMatch[1].split(',').map(k => k.trim())\r\n\t}\r\n\r\n\tconst authorMatch = jsdoc.match(/@author\\s+(.+)/)\r\n\tif (authorMatch) metadata.author = authorMatch[1].trim()\r\n\r\n\tconst changefreqMatch = jsdoc.match(\r\n\t\t/@changefreq\\s+(always|hourly|daily|weekly|monthly|yearly|never)/\r\n\t)\r\n\tif (changefreqMatch) {\r\n\t\tmetadata.changefreq = changefreqMatch[1] as PageMetadata['changefreq']\r\n\t}\r\n\r\n\tconst priorityMatch = jsdoc.match(/@priority\\s+([0-9.]+)/)\r\n\tif (priorityMatch) {\r\n\t\tmetadata.priority = parseFloat(priorityMatch[1])\r\n\t}\r\n\r\n\treturn Object.keys(metadata).length > 0 ? metadata : null\r\n}\r\n\r\nfunction extractExportMetadata(content: string): PageMetadata | null {\r\n\t// Ищем экспорт const metadata = { ... }\r\n\tconst metadataMatch = content.match(\r\n\t\t/export\\s+const\\s+metadata\\s*=\\s*({[\\s\\S]*?});?/\r\n\t)\r\n\tif (!metadataMatch) return null\r\n\r\n\ttry {\r\n\t\t// Безопасное выполнение кода для извлечения объекта\r\n\t\tconst metadataCode = metadataMatch[1]\r\n\t\t// Заменяем возможные импорты и функции на безопасные значения\r\n\t\tconst safeCode = metadataCode\r\n\t\t\t.replace(/import\\s+.*?from\\s+['\"][^'\"]*['\"];?/g, '')\r\n\t\t\t.replace(/require\\s*\\([^)]*\\)/g, '\"\"')\r\n\t\t\t.replace(/process\\.env\\.[A-Z_]+/g, '\"\"')\r\n\r\n\t\t// Создаем функцию для безопасного выполнения\r\n\t\tconst func = new Function(`return ${safeCode}`)\r\n\t\treturn func()\r\n\t} catch (error) {\r\n\t\tconsole.warn(\r\n\t\t\t`[vite-plugin-file-router] Failed to parse metadata export:`,\r\n\t\t\terror\r\n\t\t)\r\n\t\treturn null\r\n\t}\r\n}\r\n\r\nexport function generateSitemap(\r\n\troutes: Array<{ path: string; metadata?: PageMetadata }>,\r\n\tbaseUrl: string\r\n): string {\r\n\tconst urls = routes\r\n\t\t.map(route => {\r\n\t\t\tconst lastmod = new Date().toISOString()\r\n\t\t\tconst changefreq = route.metadata?.changefreq || 'monthly'\r\n\t\t\tconst priority = route.metadata?.priority || 0.8\r\n\r\n\t\t\treturn ` <url>\r\n <loc>${baseUrl}${route.path}</loc>\r\n <lastmod>${lastmod}</lastmod>\r\n <changefreq>${changefreq}</changefreq>\r\n <priority>${priority}</priority>\r\n </url>`\r\n\t\t})\r\n\t\t.join('\\n')\r\n\r\n\treturn `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\r\n${urls}\r\n</urlset>`\r\n}\r\n\r\nexport function generateRobots(\r\n\tbaseUrl: string,\r\n\tdisallowPaths: string[] = []\r\n): string {\r\n\tconst disallowRules = disallowPaths\r\n\t\t.map(path => `Disallow: ${path}`)\r\n\t\t.join('\\n')\r\n\r\n\treturn `User-agent: *\r\nAllow: /\r\n${disallowRules ? `\\n${disallowRules}` : ''}\r\n\r\nSitemap: ${baseUrl}/sitemap.xml`\r\n}\r\n","import path from 'node:path'\r\nimport { collectLayouts } from './scanner'\r\nimport type { Options, RouteEntry } from './types/types'\r\nimport { detectExportType, slash } from './utils'\r\n\r\nexport function segmentToRoute(seg: string): string {\r\n\tif (/^\\[\\.{3}.+\\]$/.test(seg)) {\r\n\t\tconst name = seg.slice(4, -1)\r\n\t\treturn `:${name}(.*)`\r\n\t}\r\n\tif (/^\\[.+\\]$/.test(seg)) {\r\n\t\tconst name = seg.slice(1, -1)\r\n\t\treturn `:${name}`\r\n\t}\r\n\treturn seg\r\n}\r\n\r\nexport function filePathToRoute(\r\n\tfilePath: string,\r\n\tresolvedPagesDir: string\r\n): string {\r\n\tconst rel = slash(path.relative(resolvedPagesDir, filePath))\r\n\tconst dir = path.dirname(rel)\r\n\tconst parts = dir === '.' ? [] : dir.split('/').filter(Boolean)\r\n\t// 1. Выбрасываем группы маршрутов (auth), (shop) …\r\n\t// 2. Добавляем фильтр папок, начинающихся с _\r\n\tconst filteredParts = parts.filter(\r\n\t\tpart =>\r\n\t\t\t(!part.startsWith('(') || !part.endsWith(')')) && !part.startsWith('_')\r\n\t)\r\n\tconst segments = filteredParts.map(segmentToRoute)\r\n\tconst route = '/' + segments.join('/')\r\n\treturn route === '/' ? '/' : route.replace(/\\/+/g, '/')\r\n}\r\n\r\nexport function createRouteEntry(\r\n\tfilePath: string,\r\n\tresolvedPagesDir: string,\r\n\topts: Required<Options>\r\n): RouteEntry {\r\n\tconst route = filePathToRoute(filePath, resolvedPagesDir)\r\n\tconst id = slash(path.relative(resolvedPagesDir, filePath))\r\n\t\t.replace(/\\//g, '_')\r\n\t\t.replace(/\\.[^.]+$/, '')\r\n\tconst exportType = detectExportType(filePath)\r\n\tconst loader = `() => import(${JSON.stringify(slash(filePath))})`\r\n\tconst layouts = collectLayouts(filePath, resolvedPagesDir, opts).map(\r\n\t\tlp => `() => import(${JSON.stringify(slash(lp))})`\r\n\t)\r\n\r\n\treturn {\r\n\t\tid,\r\n\t\tpath: route,\r\n\t\tfilePath: slash(filePath),\r\n\t\tloader,\r\n\t\texportType,\r\n\t\tlayouts,\r\n\t}\r\n}\r\n","import fg from 'fast-glob'\r\nimport fs from 'node:fs'\r\nimport path from 'node:path'\r\nimport type { Options } from './types/types'\r\nimport { slash } from './utils'\r\n\r\nexport async function scanPages(\r\n\tresolvedPagesDir: string,\r\n\topts: Required<Options>\r\n): Promise<string[]> {\r\n\t// pattern like /abs/path/**/page.tsx\r\n\tconst exts = opts.extensions.join('|')\r\n\tconst pattern = `${slash(resolvedPagesDir)}/**/${\r\n\t\topts.pageFileName\r\n\t}.+(${exts})`\r\n\tconst files = await fg(pattern, { dot: true })\r\n\t// return absolute normalized paths\r\n\treturn files.map((f: string) => path.resolve(f))\r\n}\r\n\r\nexport function collectLayouts(\r\n\tfilePath: string,\r\n\tresolvedPagesDir: string,\r\n\topts: Required<Options>\r\n): string[] {\r\n\tconst rel = slash(path.relative(resolvedPagesDir, filePath))\r\n\tconst dir = path.dirname(rel)\r\n\tconst parts = dir === '.' ? [] : dir.split('/').filter(Boolean)\r\n\r\n\tconst layouts: string[] = []\r\n\t// for each level from 0..parts.length include layout if exists\r\n\t// НЕ фильтруем группы маршрутов при поиске layout файлов\r\n\tfor (let i = 0; i <= parts.length; i++) {\r\n\t\tconst p = parts.slice(0, i).join('/')\r\n\t\tfor (const ext of opts.extensions) {\r\n\t\t\tconst candidate = path.resolve(\r\n\t\t\t\tresolvedPagesDir,\r\n\t\t\t\tp || '',\r\n\t\t\t\t`${opts.layoutFileName}.${ext}`\r\n\t\t\t)\r\n\t\t\tif (fs.existsSync(candidate)) {\r\n\t\t\t\tlayouts.push(candidate)\r\n\t\t\t\tbreak\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\treturn layouts\r\n}\r\n","import fs from 'node:fs'\r\nimport type { ExportType } from './types/types'\r\n\r\nexport const slash = (p: string) => p.replace(/\\\\/g, '/')\r\n\r\nexport function detectExportType(filePath: string): ExportType {\r\n\ttry {\r\n\t\tconst content = fs.readFileSync(filePath, 'utf-8')\r\n\r\n\t\t// Проверяем наличие default экспорта\r\n\t\tconst hasDefaultExport = /export\\s+default\\s+/.test(content)\r\n\r\n\t\t// Проверяем наличие любого именованного экспорта (функция, константа или класс)\r\n\t\tconst hasNamedExport = /export\\s+(const|function|class)\\s+\\w+\\s*[=(]/.test(\r\n\t\t\tcontent\r\n\t\t)\r\n\r\n\t\tif (hasDefaultExport) {\r\n\t\t\treturn 'default'\r\n\t\t} else if (hasNamedExport) {\r\n\t\t\treturn 'named'\r\n\t\t}\r\n\r\n\t\t// По умолчанию предполагаем default экспорт для обратной совместимости\r\n\t\treturn 'default'\r\n\t} catch (error) {\r\n\t\t// В случае ошибки чтения файла, предполагаем default экспорт\r\n\t\tconsole.warn(\r\n\t\t\t`[vite-plugin-file-router] Failed to read file ${filePath}:`,\r\n\t\t\terror\r\n\t\t)\r\n\t\treturn 'default'\r\n\t}\r\n}\r\n","import type { RouteEntry } from './types/types'\r\n\r\nexport function generateRouteTypes(routes: RouteEntry[]): string {\r\n\tconst routePaths = routes.map(route => `'${route.path}'`).join(' | ')\r\n\r\n\t// Извлекаем параметры из динамических маршрутов\r\n\tconst routeParams: Record<string, Record<string, string>> = {}\r\n\troutes.forEach(route => {\r\n\t\tconst params: Record<string, string> = {}\r\n\r\n\t\t// Парсим [id] параметры\r\n\t\tconst idMatches = route.path.match(/\\[([^\\]]+)\\]/g)\r\n\t\tif (idMatches) {\r\n\t\t\tidMatches.forEach(match => {\r\n\t\t\t\tconst paramName = match.slice(1, -1)\r\n\t\t\t\tif (paramName.startsWith('...')) {\r\n\t\t\t\t\t// Catch-all параметр\r\n\t\t\t\t\tparams[paramName.slice(3)] = 'string[]'\r\n\t\t\t\t} else {\r\n\t\t\t\t\tparams[paramName] = 'string'\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t}\r\n\r\n\t\tif (Object.keys(params).length > 0) {\r\n\t\t\trouteParams[route.path] = params\r\n\t\t}\r\n\t})\r\n\r\n\tconst routeParamsType =\r\n\t\tObject.keys(routeParams).length > 0\r\n\t\t\t? `export type RouteParams = {\r\n${Object.entries(routeParams)\r\n\t.map(([path, params]) => {\r\n\t\tconst paramEntries = Object.entries(params)\r\n\t\t\t.map(([key, type]) => `${key}: ${type}`)\r\n\t\t\t.join(', ')\r\n\t\treturn ` '${path}': { ${paramEntries} }`\r\n\t})\r\n\t.join('\\n')}\r\n}`\r\n\t\t\t: 'export type RouteParams = Record<string, never>'\r\n\r\n\treturn `// Автогенерированные типы маршрутов\r\nexport type RoutePath = ${routePaths || 'never'}\r\n\r\n${routeParamsType}\r\n\r\nexport type PageProps<T extends RoutePath = RoutePath> = {\r\n params: RouteParams[T]\r\n searchParams?: Record<string, string>\r\n}\r\n\r\nexport interface LayoutProps {\r\n children: React.ReactNode\r\n}\r\n\r\nexport interface RouteInfo {\r\n id: string\r\n path: string\r\n filePath: string\r\n exportType: 'default' | 'named'\r\n layouts: string[]\r\n}\r\n\r\n// Утилиты для навигации\r\nexport function navigate<T extends RoutePath>(\r\n path: T, \r\n params?: RouteParams[T]\r\n): void {\r\n // Реализация навигации\r\n window.location.href = path\r\n}\r\n\r\nexport function useParams<T extends RoutePath>(): RouteParams[T] {\r\n // Реализация хука для получения параметров\r\n return {} as RouteParams[T]\r\n}\r\n`\r\n}\r\n\r\nexport function generateMetadataTypes(): string {\r\n\treturn `// Типы для метаданных страниц\r\nexport interface PageMetadata {\r\n title?: string\r\n description?: string\r\n keywords?: string[]\r\n author?: string\r\n changefreq?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never'\r\n priority?: number\r\n}\r\n\r\nexport interface SEOConfig {\r\n baseUrl: string\r\n defaultTitle?: string\r\n defaultDescription?: string\r\n disallowPaths?: string[]\r\n}\r\n`\r\n}\r\n","import fs from 'node:fs'\r\n\r\nexport function createHMRHandlers(\r\n\tresolvedPagesDir: string,\r\n\tresolvedVirtualId: string,\r\n\troot: string\r\n) {\r\n\tconst configureServer = (srv: any) => {\r\n\t\tconst invalidateVirtual = async () => {\r\n\t\t\tconst mod = srv.moduleGraph?.getModuleById?.(resolvedVirtualId)\r\n\t\t\tif (mod) {\r\n\t\t\t\tsrv.moduleGraph?.invalidateModule?.(mod)\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tconst watchPath = fs.existsSync(resolvedPagesDir) ? resolvedPagesDir : root\r\n\t\tsrv.watcher?.add?.(watchPath)\r\n\r\n\t\tsrv.watcher?.on?.('add', (p: string) => {\r\n\t\t\tif (p.startsWith(resolvedPagesDir)) invalidateVirtual()\r\n\t\t})\r\n\t\tsrv.watcher?.on?.('unlink', (p: string) => {\r\n\t\t\tif (p.startsWith(resolvedPagesDir)) invalidateVirtual()\r\n\t\t})\r\n\t}\r\n\r\n\tconst handleHotUpdate = (ctx: any) => {\r\n\t\tconst f = ctx.file\r\n\t\tif (!f?.startsWith(resolvedPagesDir)) return\r\n\r\n\t\tconst mod = ctx.server.moduleGraph?.getModuleById?.(resolvedVirtualId)\r\n\t\tif (mod) {\r\n\t\t\tctx.server.moduleGraph?.invalidateModule?.(mod)\r\n\t\t\treturn [mod]\r\n\t\t}\r\n\t}\r\n\r\n\treturn { configureServer, handleHotUpdate }\r\n}\r\n","import fs from 'node:fs'\r\nimport path from 'node:path'\r\n\r\nexport async function loadGeneratedManifest(root: string): Promise<string> {\r\n\tconst manifestPath = path.join(root, 'dist', 'routes-manifest.js')\r\n\tif (fs.existsSync(manifestPath)) {\r\n\t\ttry {\r\n\t\t\tconst manifestContent = fs.readFileSync(manifestPath, 'utf-8')\r\n\t\t\tconst manifestRegex = /export const manifest = \\[.*?\\];/s\r\n\t\t\tconst manifestMatch = manifestRegex.exec(manifestContent)\r\n\t\t\tconst basePathRegex = /export const basePath = ['\"](.*?)['\"];/\r\n\t\t\tconst basePathMatch = basePathRegex.exec(manifestContent)\r\n\t\t\tconst basePath = basePathMatch ? basePathMatch[1] : '/'\r\n\t\t\t\r\n\t\t\tif (manifestMatch) {\r\n\t\t\t\treturn `// virtual routes (production mode - using generated manifest)\r\n${manifestMatch[0]}\r\nexport const basePath = ${JSON.stringify(basePath)};\r\nexport default manifest;\r\n`\r\n\t\t\t}\r\n\t\t} catch (error) {\r\n\t\t\tconsole.warn(\r\n\t\t\t\t'[vite-plugin-file-router] Failed to load generated manifest:',\r\n\t\t\t\terror\r\n\t\t\t)\r\n\t\t}\r\n\t}\r\n\r\n\t// Fallback - пустой манифест\r\n\treturn `// virtual routes (production mode - empty manifest)\r\nexport const manifest = [];\r\nexport const basePath = '/';\r\nexport default manifest;\r\n`\r\n}\r\n","import { createRouteEntry } from './route-generator'\r\nimport { scanPages } from './scanner'\r\nimport type { Options } from './types/types'\r\n\r\nexport async function generateVirtualModuleCode(\r\n\tresolvedPagesDir: string,\r\n\topts: Required<Options>\r\n): Promise<string> {\r\n\tconst pages = await scanPages(resolvedPagesDir, opts)\r\n\tconst entries = pages.map(fp => {\r\n\t\tconst entry = createRouteEntry(fp, resolvedPagesDir, opts)\r\n\t\treturn `{\r\n id: ${JSON.stringify(entry.id)},\r\n path: ${JSON.stringify(entry.path)},\r\n filePath: ${JSON.stringify(entry.filePath)},\r\n loader: ${entry.loader},\r\n exportType: ${JSON.stringify(entry.exportType)},\r\n layouts: [${entry.layouts.join(',')}]\r\n }`\r\n\t})\r\n\r\n\treturn `// Auto-generated routes manifest\r\nconst manifest = [${entries.join(',\\n')}];\r\n\r\nexport const basePath = ${JSON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AAI;AAAA,MAC9D;AACA,aAAO;AAAA,IACR;AAAA,IAEA,MAAM,aAAa;AAClB,aAAO,QAAQ,IAAI;AACnB,yBAAmBD,MAAK,QAAQ,MAAM,KAAK,QAAQ;AAEnD,UAAI,CAACC,IAAG,WAAW,gBAAgB,GAAG;AACrC,gBAAQ;AAAA,UACP,uCAAuC,gBAAgB;AAAA,QACxD;AAAA,MACD;AAAA,IACD;AAAA,IAEA,MAAM,iBAAiB;AAEtB,UAAI,CAACA,IAAG,WAAW,gBAAgB,GAAG;AACrC,gBAAQ;AAAA,UACP,uCAAuC,gBAAgB;AAAA,QACxD;AACA;AAAA,MACD;AAGA,UAAI,KAAK,eAAe;AACvB,YAAI;AACH,gBAAM,cAAc,kBAAkB,IAAI;AAAA,QAC3C,SAAS,OAAO;AACf,kBAAQ;AAAA,YACP,uDAAuD,KAAK;AAAA,UAC7D;AAAA,QACD;AAAA,MACD;AAGA,UAAI,KAAK,WAAW;AACnB,YAAI;AACH,gBAAM,iBAAiB,kBAAkB,IAAI;AAAA,QAC9C,SAAS,OAAO;AACf,kBAAQ;AAAA,YACP,2DAA2D,KAAK;AAAA,UACjE;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AAGA,MAAI,QAAQ,IAAI,aAAa,cAAc;AAC1C,UAAM,EAAE,iBAAiB,gBAAgB,IAAI;AAAA,MAC5C;AAAA,MACA;AAAA,MACA;AAAA,IACD;AACA,WAAO,kBAAkB;AACzB,WAAO,kBAAkB;AAAA,EAC1B;AAEA,SAAO;AACR;","names":["fs","path","fs","path","path","path","fs","fs","fs","path","path","path","fs","fs","fs","path","path","fs"]}
|