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.js
CHANGED
|
@@ -31,21 +31,30 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var react_exports = {};
|
|
32
32
|
__export(react_exports, {
|
|
33
33
|
Link: () => Link,
|
|
34
|
-
NavLink: () =>
|
|
35
|
-
Navigate: () =>
|
|
34
|
+
NavLink: () => NavLink,
|
|
35
|
+
Navigate: () => Navigate,
|
|
36
|
+
RouteTransition: () => RouteTransition,
|
|
36
37
|
RouterProvider: () => RouterProvider,
|
|
37
38
|
useLink: () => useLink,
|
|
38
|
-
useLocation: () =>
|
|
39
|
-
useNavigate: () =>
|
|
40
|
-
useParams: () =>
|
|
41
|
-
useSearchParams: () =>
|
|
39
|
+
useLocation: () => useLocation,
|
|
40
|
+
useNavigate: () => useNavigate,
|
|
41
|
+
useParams: () => useParams,
|
|
42
|
+
useSearchParams: () => useSearchParams
|
|
42
43
|
});
|
|
43
44
|
module.exports = __toCommonJS(react_exports);
|
|
44
45
|
|
|
45
|
-
// src/components/
|
|
46
|
+
// src/components/link.tsx
|
|
47
|
+
var import_react_router_dom2 = require("react-router-dom");
|
|
48
|
+
|
|
49
|
+
// src/components/hooks/use-location.ts
|
|
46
50
|
var import_react_router_dom = require("react-router-dom");
|
|
51
|
+
function useLocation() {
|
|
52
|
+
return (0, import_react_router_dom.useLocation)();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// src/components/hooks/use-links.tsx
|
|
47
56
|
function useLink(props) {
|
|
48
|
-
const location =
|
|
57
|
+
const location = useLocation();
|
|
49
58
|
const currentPath = location.pathname;
|
|
50
59
|
return {
|
|
51
60
|
href: props.href,
|
|
@@ -54,33 +63,161 @@ function useLink(props) {
|
|
|
54
63
|
}
|
|
55
64
|
|
|
56
65
|
// src/components/link.tsx
|
|
57
|
-
var import_react_router_dom2 = require("react-router-dom");
|
|
58
66
|
var Link = import_react_router_dom2.Link;
|
|
59
67
|
|
|
68
|
+
// src/components/nav-link.tsx
|
|
69
|
+
var import_react_router_dom3 = require("react-router-dom");
|
|
70
|
+
var NavLink = import_react_router_dom3.NavLink;
|
|
71
|
+
|
|
72
|
+
// src/components/navigate.tsx
|
|
73
|
+
var import_react_router_dom4 = require("react-router-dom");
|
|
74
|
+
var Navigate = import_react_router_dom4.Navigate;
|
|
75
|
+
|
|
76
|
+
// src/components/route-transition.tsx
|
|
77
|
+
var import_react = require("react");
|
|
78
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
79
|
+
function RouteTransition({
|
|
80
|
+
children,
|
|
81
|
+
enterClass = "route-enter",
|
|
82
|
+
enterActiveClass = "route-enter-active",
|
|
83
|
+
exitClass = "route-exit",
|
|
84
|
+
exitActiveClass = "route-exit-active",
|
|
85
|
+
duration = 300,
|
|
86
|
+
onTransition,
|
|
87
|
+
mode = "fade"
|
|
88
|
+
}) {
|
|
89
|
+
const location = useLocation();
|
|
90
|
+
const [displayChildren, setDisplayChildren] = (0, import_react.useState)(children);
|
|
91
|
+
const [isExiting, setIsExiting] = (0, import_react.useState)(false);
|
|
92
|
+
const [isEntering, setIsEntering] = (0, import_react.useState)(false);
|
|
93
|
+
const prevLocationRef = (0, import_react.useRef)(location.pathname);
|
|
94
|
+
const timeoutRef = (0, import_react.useRef)(null);
|
|
95
|
+
(0, import_react.useEffect)(() => {
|
|
96
|
+
if (prevLocationRef.current !== location.pathname) {
|
|
97
|
+
if (timeoutRef.current) {
|
|
98
|
+
clearTimeout(timeoutRef.current);
|
|
99
|
+
}
|
|
100
|
+
setIsExiting(true);
|
|
101
|
+
setIsEntering(false);
|
|
102
|
+
onTransition?.("exit");
|
|
103
|
+
timeoutRef.current = setTimeout(() => {
|
|
104
|
+
setDisplayChildren(children);
|
|
105
|
+
setIsExiting(false);
|
|
106
|
+
setIsEntering(true);
|
|
107
|
+
onTransition?.("enter");
|
|
108
|
+
timeoutRef.current = setTimeout(() => {
|
|
109
|
+
setIsEntering(false);
|
|
110
|
+
timeoutRef.current = null;
|
|
111
|
+
}, duration);
|
|
112
|
+
}, duration);
|
|
113
|
+
prevLocationRef.current = location.pathname;
|
|
114
|
+
} else {
|
|
115
|
+
setDisplayChildren(children);
|
|
116
|
+
}
|
|
117
|
+
return () => {
|
|
118
|
+
if (timeoutRef.current) {
|
|
119
|
+
clearTimeout(timeoutRef.current);
|
|
120
|
+
timeoutRef.current = null;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}, [location.pathname, children, duration, onTransition]);
|
|
124
|
+
const getClassName = () => {
|
|
125
|
+
if (isExiting) {
|
|
126
|
+
return `${exitClass} ${exitActiveClass}`;
|
|
127
|
+
}
|
|
128
|
+
if (isEntering) {
|
|
129
|
+
return `${enterClass} ${enterActiveClass}`;
|
|
130
|
+
}
|
|
131
|
+
return "";
|
|
132
|
+
};
|
|
133
|
+
const getDefaultStyles = () => {
|
|
134
|
+
if (mode === "fade") {
|
|
135
|
+
return {
|
|
136
|
+
transition: `opacity ${duration}ms ease-in-out`,
|
|
137
|
+
opacity: isExiting ? 0 : isEntering ? 0 : 1
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
if (mode === "slide") {
|
|
141
|
+
return {
|
|
142
|
+
transition: `transform ${duration}ms ease-in-out, opacity ${duration}ms ease-in-out`,
|
|
143
|
+
transform: isExiting ? "translateX(-100%)" : isEntering ? "translateX(100%)" : "translateX(0)",
|
|
144
|
+
opacity: isExiting ? 0 : isEntering ? 0 : 1
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
return {};
|
|
148
|
+
};
|
|
149
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: getClassName(), style: getDefaultStyles(), children: displayChildren });
|
|
150
|
+
}
|
|
151
|
+
|
|
60
152
|
// src/components/router-provider.tsx
|
|
61
153
|
var import_virtual_routes = require("virtual:routes");
|
|
62
154
|
|
|
63
155
|
// src/components/router-layout.tsx
|
|
156
|
+
var import_react4 = __toESM(require("react"), 1);
|
|
157
|
+
var import_react_router_dom6 = require("react-router-dom");
|
|
158
|
+
|
|
159
|
+
// src/components/router-utils.tsx
|
|
160
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
161
|
+
var import_react_router_dom5 = require("react-router-dom");
|
|
162
|
+
|
|
163
|
+
// src/components/error-boundary.tsx
|
|
64
164
|
var import_react2 = __toESM(require("react"), 1);
|
|
65
|
-
var
|
|
165
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
166
|
+
var ErrorBoundary = class extends import_react2.default.Component {
|
|
167
|
+
constructor(props) {
|
|
168
|
+
super(props);
|
|
169
|
+
this.state = { hasError: false, error: null };
|
|
170
|
+
}
|
|
171
|
+
static getDerivedStateFromError(error) {
|
|
172
|
+
return { hasError: true, error };
|
|
173
|
+
}
|
|
174
|
+
componentDidCatch(error, errorInfo) {
|
|
175
|
+
this.props.onError?.(error, errorInfo);
|
|
176
|
+
}
|
|
177
|
+
resetError = () => {
|
|
178
|
+
this.setState({ hasError: false, error: null });
|
|
179
|
+
};
|
|
180
|
+
render() {
|
|
181
|
+
if (this.state.hasError && this.state.error) {
|
|
182
|
+
if (this.props.fallback) {
|
|
183
|
+
const Fallback = this.props.fallback;
|
|
184
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Fallback, { error: this.state.error, resetError: this.resetError });
|
|
185
|
+
}
|
|
186
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { padding: "20px" }, children: [
|
|
187
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h2", { children: "Something went wrong" }),
|
|
188
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("pre", { children: this.state.error.message }),
|
|
189
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", { onClick: this.resetError, children: "Try again" })
|
|
190
|
+
] });
|
|
191
|
+
}
|
|
192
|
+
return this.props.children;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
66
195
|
|
|
67
196
|
// src/components/router-utils.tsx
|
|
68
|
-
var
|
|
69
|
-
var import_react_router_dom3 = require("react-router-dom");
|
|
70
|
-
var import_jsx_runtime = require("react/jsx-runtime");
|
|
197
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
71
198
|
function wrapLayouts(layouts, pageEl) {
|
|
72
199
|
if (!layouts || layouts.length === 0) return pageEl;
|
|
73
200
|
return layouts.reduceRight((child, loader) => {
|
|
74
|
-
const Layout =
|
|
201
|
+
const Layout = import_react3.default.lazy(async () => {
|
|
75
202
|
const module2 = await loader();
|
|
76
203
|
return "default" in module2 ? module2 : { default: module2.Layout };
|
|
77
204
|
});
|
|
78
|
-
return /* @__PURE__ */ (0,
|
|
205
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Layout, { children: child });
|
|
79
206
|
}, pageEl);
|
|
80
207
|
}
|
|
81
|
-
|
|
208
|
+
function createLoadingFallback(loadingLoader) {
|
|
209
|
+
if (!loadingLoader) return void 0;
|
|
210
|
+
const Loading = import_react3.default.lazy(loadingLoader);
|
|
211
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Loading, {});
|
|
212
|
+
}
|
|
213
|
+
function createErrorFallback(errorLoader) {
|
|
214
|
+
if (!errorLoader) return void 0;
|
|
215
|
+
const ErrorComponent = import_react3.default.lazy(errorLoader);
|
|
216
|
+
return (props) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorComponent, { ...props });
|
|
217
|
+
}
|
|
218
|
+
var renderManifestAsRoutes = (manifest2, globalNotFound2) => {
|
|
82
219
|
return manifest2.map((n) => {
|
|
83
|
-
const Page =
|
|
220
|
+
const Page = import_react3.default.lazy(async () => {
|
|
84
221
|
const module2 = await n.loader();
|
|
85
222
|
if (module2 && typeof module2 === "object" && "default" in module2 && module2.default) {
|
|
86
223
|
return module2;
|
|
@@ -103,38 +240,101 @@ var renderManifestAsRoutes = (manifest2) => {
|
|
|
103
240
|
`No valid export found in module for route ${n.path}. Available exports: ${availableExports}`
|
|
104
241
|
);
|
|
105
242
|
});
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
243
|
+
const loadingFallback = createLoadingFallback(n.loading);
|
|
244
|
+
const errorFallback = createErrorFallback(n.error);
|
|
245
|
+
const pageElement = wrapLayouts(n.layouts, /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Page, {}));
|
|
246
|
+
const wrappedElement = errorFallback ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ErrorBoundary, { fallback: errorFallback, children: pageElement }) : pageElement;
|
|
247
|
+
const element = loadingFallback ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react3.default.Suspense, { fallback: loadingFallback, children: wrappedElement }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react3.default.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: "Loading..." }), children: wrappedElement });
|
|
248
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_router_dom5.Route, { path: n.path, element }, n.id);
|
|
249
|
+
}).concat(
|
|
250
|
+
// Добавляем 404 маршрут в конец
|
|
251
|
+
globalNotFound2 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
252
|
+
import_react_router_dom5.Route,
|
|
253
|
+
{
|
|
254
|
+
path: "*",
|
|
255
|
+
element: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react3.default.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: "Loading..." }), children: (() => {
|
|
256
|
+
const NotFound = import_react3.default.lazy(globalNotFound2);
|
|
257
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(NotFound, {});
|
|
258
|
+
})() })
|
|
259
|
+
},
|
|
260
|
+
"__not_found__"
|
|
261
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
262
|
+
import_react_router_dom5.Route,
|
|
263
|
+
{
|
|
264
|
+
path: "*",
|
|
265
|
+
element: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { padding: "20px", textAlign: "center" }, children: [
|
|
266
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("h1", { children: "404" }),
|
|
267
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: "Page not found" })
|
|
268
|
+
] })
|
|
269
|
+
},
|
|
270
|
+
"__not_found__"
|
|
271
|
+
)
|
|
272
|
+
);
|
|
109
273
|
};
|
|
110
274
|
|
|
111
275
|
// src/components/router-layout.tsx
|
|
112
|
-
var
|
|
276
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
113
277
|
var RouterLayout = ({
|
|
114
278
|
manifest: manifest2,
|
|
115
279
|
children,
|
|
116
280
|
preloader,
|
|
117
|
-
basePath = "/"
|
|
118
|
-
|
|
281
|
+
basePath = "/",
|
|
282
|
+
globalNotFound: globalNotFound2,
|
|
283
|
+
enableTransitions = false,
|
|
284
|
+
transitionConfig
|
|
285
|
+
}) => {
|
|
286
|
+
const routes = renderManifestAsRoutes(manifest2, globalNotFound2);
|
|
287
|
+
const routesElement = /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_router_dom6.Routes, { children: routes });
|
|
288
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_router_dom6.BrowserRouter, { basename: basePath, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react4.default.Suspense, { fallback: children || preloader || /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: "Loading..." }), children: enableTransitions ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RouteTransition, { ...transitionConfig, children: routesElement }) : routesElement }) });
|
|
289
|
+
};
|
|
119
290
|
|
|
120
291
|
// src/components/router-provider.tsx
|
|
121
|
-
var
|
|
292
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
122
293
|
function RouterProvider({
|
|
123
294
|
children,
|
|
124
295
|
preloader,
|
|
125
|
-
basePath
|
|
296
|
+
basePath,
|
|
297
|
+
enableTransitions,
|
|
298
|
+
transitionConfig
|
|
126
299
|
}) {
|
|
127
300
|
const finalBasePath = basePath ?? import_virtual_routes.basePath ?? "/";
|
|
128
|
-
return /* @__PURE__ */ (0,
|
|
301
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
302
|
+
RouterLayout,
|
|
303
|
+
{
|
|
304
|
+
manifest: import_virtual_routes.manifest,
|
|
305
|
+
preloader,
|
|
306
|
+
basePath: finalBasePath,
|
|
307
|
+
globalNotFound: import_virtual_routes.globalNotFound,
|
|
308
|
+
enableTransitions,
|
|
309
|
+
transitionConfig,
|
|
310
|
+
children
|
|
311
|
+
}
|
|
312
|
+
);
|
|
129
313
|
}
|
|
130
314
|
|
|
131
|
-
// src/
|
|
132
|
-
var
|
|
315
|
+
// src/components/hooks/use-navigate.ts
|
|
316
|
+
var import_react_router_dom7 = require("react-router-dom");
|
|
317
|
+
function useNavigate() {
|
|
318
|
+
return (0, import_react_router_dom7.useNavigate)();
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// src/components/hooks/use-params.ts
|
|
322
|
+
var import_react_router_dom8 = require("react-router-dom");
|
|
323
|
+
function useParams() {
|
|
324
|
+
return (0, import_react_router_dom8.useParams)();
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
// src/components/hooks/use-search-params.ts
|
|
328
|
+
var import_react_router_dom9 = require("react-router-dom");
|
|
329
|
+
function useSearchParams() {
|
|
330
|
+
return (0, import_react_router_dom9.useSearchParams)();
|
|
331
|
+
}
|
|
133
332
|
// Annotate the CommonJS export names for ESM import in node:
|
|
134
333
|
0 && (module.exports = {
|
|
135
334
|
Link,
|
|
136
335
|
NavLink,
|
|
137
336
|
Navigate,
|
|
337
|
+
RouteTransition,
|
|
138
338
|
RouterProvider,
|
|
139
339
|
useLink,
|
|
140
340
|
useLocation,
|
package/dist/react.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/react.ts","../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"],"sourcesContent":["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","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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AAAA,QACD;AAAA,MACD;AAGA,YAAM,mBACLA,WAAU,OAAOA,YAAW,WACzB,OAAO,KAAKA,OAAM,EAAE,KAAK,IAAI,IAC7B;AACJ,YAAM,IAAI;AAAA,QACT,6CAA6C,EAAE,IAAI,wBAAwB,gBAAgB;AAAA,MAC5F;AAAA,IACD,CAAC;AAED,UAAM,UAAU,YAAY,EAAE,SAAS,4CAAC,QAAK,CAAE;AAC/C,WAAO,4CAAC,kCAAiB,MAAM,EAAE,MAAM,WAApB,EAAE,EAAoC;AAAA,EAC1D,CAAC;AACF;;;ADtDqD,IAAAE,sBAAA;AAP9C,IAAM,eAAe,CAAC;AAAA,EAC5B,UAAAC;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AACZ,MACC,6CAAC,0CAAc,UAAU,UACxB,uDAAC,cAAAC,QAAM,UAAN,EAAe,UAAU,YAAY,aAAa,6CAAC,SAAI,wBAAU,GACjE,uDAAC,mCAAQ,iCAAuBD,SAAQ,GAAE,GAC3C,GACD;;;ADFC,IAAAE,sBAAA;AATa,SAAR,eAAgC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AACD,GAAkC;AAEjC,QAAM,gBAAgB,YAAY,sBAAAC,YAAkB;AAEpD,SACC,6CAAC,gBAAa,UAAU,gCAAU,WAAsB,UAAU,eAChE,UACF;AAEF;;;AHZA,IAAAC,2BASO;","names":["import_react_router_dom","ReactRouterLink","import_react","import_react_router_dom","import_react_router_dom","React","module","manifest","import_jsx_runtime","manifest","React","import_jsx_runtime","configBasePath","import_react_router_dom"]}
|
|
1
|
+
{"version":3,"sources":["../src/react.ts","../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":["// Компоненты\r\nexport { Link } from './components/link'\r\nexport { NavLink } from './components/nav-link'\r\nexport { Navigate } from './components/navigate'\r\nexport { RouteTransition } from './components/route-transition'\r\nexport { default as RouterProvider } from './components/router-provider'\r\n\r\n// Хуки\r\nexport { useLink } from './components/hooks/use-links'\r\nexport { useLocation } from './components/hooks/use-location'\r\nexport { useNavigate } from './components/hooks/use-navigate'\r\nexport { useParams } from './components/hooks/use-params'\r\nexport { useSearchParams } from './components/hooks/use-search-params'\r\n\r\n// Типы\r\nexport type {\r\n\tLinkProps,\r\n\tLocation,\r\n\tNavigateOptions,\r\n\tNavigateProps,\r\n\tNavLinkProps,\r\n\tParams,\r\n\tTo,\r\n} from './components/types/router-types'\r\n\r\nexport type { RouteTransitionProps } from './components/route-transition'\r\nexport type { RouterProviderProps } from './components/types/types'\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\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 *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;;ADVE,IAAAC,sBAAA;AAXa,SAAR,eAAgC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAAkC;AAEjC,QAAM,gBAAgB,YAAY,sBAAAC,YAAkB;AAEpD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,UAAU;AAAA,MACV;AAAA,MACA,UAAU;AAAA,MACV,gBAAgB;AAAA,MAChB;AAAA,MACA;AAAA,MAEC;AAAA;AAAA,EACF;AAEF;;;AI9BA,IAAAC,2BAAiD;AAuB1C,SAAS,cAAc;AAC7B,aAAO,yBAAAC,aAAkB;AAC1B;;;ACzBA,IAAAC,2BAA6C;AAetC,SAAS,YAA0C;AACzD,aAAO,yBAAAC,WAAgB;AACxB;;;ACjBA,IAAAC,2BAAyD;AAclD,SAAS,kBAAkB;AACjC,aAAO,yBAAAC,iBAAsB;AAC9B;","names":["import_react_router_dom","useRouterLocation","ReactRouterLink","import_react_router_dom","ReactRouterNavLink","import_react_router_dom","ReactRouterNavigate","import_react","import_react_router_dom","import_react","import_react_router_dom","import_react","import_jsx_runtime","React","import_jsx_runtime","React","module","manifest","globalNotFound","import_jsx_runtime","manifest","globalNotFound","React","import_jsx_runtime","configBasePath","import_react_router_dom","useRouterNavigate","import_react_router_dom","useRouterParams","import_react_router_dom","useRouterSearchParams"]}
|