path-rush 1.4.0 → 1.5.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 +102 -2
- package/dist/react.d.ts +102 -2
- package/dist/react.js +147 -20
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +144 -19
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-VBEFTPIV.mjs.map +0 -1
package/dist/react.d.cts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import
|
|
3
|
+
import * as react_router_dom from 'react-router-dom';
|
|
4
|
+
import { LinkProps, NavLinkProps, Navigate as Navigate$1, Location as Location$1 } from 'react-router-dom';
|
|
5
|
+
export { LinkProps, NavLinkProps, NavigateOptions, NavigateProps, To } from 'react-router-dom';
|
|
4
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
7
|
|
|
6
8
|
declare function useLink(props: {
|
|
@@ -10,8 +12,45 @@ declare function useLink(props: {
|
|
|
10
12
|
isActive: boolean;
|
|
11
13
|
};
|
|
12
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Компонент для навигационных ссылок
|
|
17
|
+
*
|
|
18
|
+
* Используется для клиентской навигации без перезагрузки страницы
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <Link to="/about">About</Link>
|
|
23
|
+
* <Link to="/users/123" state={{ from: 'home' }}>User Profile</Link>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
13
26
|
declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
14
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Компонент для навигационных ссылок с поддержкой активного состояния
|
|
30
|
+
*
|
|
31
|
+
* Автоматически добавляет класс 'active' когда маршрут активен
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* <NavLink to="/about">About</NavLink>
|
|
36
|
+
* <NavLink to="/users" className={({ isActive }) => isActive ? 'active' : ''}>
|
|
37
|
+
* Users
|
|
38
|
+
* </NavLink>
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Компонент для программного редиректа
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* <Navigate to="/login" replace />
|
|
49
|
+
* <Navigate to="/dashboard" state={{ from: location }} />
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare const Navigate: typeof Navigate$1;
|
|
53
|
+
|
|
15
54
|
type RouterProviderProps = {
|
|
16
55
|
/**
|
|
17
56
|
* ⏳ Кастомный индикатор загрузки
|
|
@@ -43,4 +82,65 @@ type RouterProviderProps = {
|
|
|
43
82
|
|
|
44
83
|
declare function RouterProvider({ children, preloader, basePath, }: Readonly<RouterProviderProps>): react_jsx_runtime.JSX.Element;
|
|
45
84
|
|
|
46
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Тип локации с информацией о текущем маршруте
|
|
87
|
+
*/
|
|
88
|
+
type Location = Location$1;
|
|
89
|
+
/**
|
|
90
|
+
* Хук для получения текущей локации
|
|
91
|
+
*
|
|
92
|
+
* @returns Объект с информацией о текущем маршруте
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```tsx
|
|
96
|
+
* const location = useLocation()
|
|
97
|
+
* console.log(location.pathname) // '/about'
|
|
98
|
+
* console.log(location.search) // '?id=123'
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare function useLocation(): Location;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Хук для программной навигации
|
|
105
|
+
*
|
|
106
|
+
* @returns Функция для навигации
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```tsx
|
|
110
|
+
* const navigate = useNavigate()
|
|
111
|
+
* navigate('/about')
|
|
112
|
+
* navigate('/users', { replace: true })
|
|
113
|
+
* navigate(-1) // назад
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
declare function useNavigate(): react_router_dom.NavigateFunction;
|
|
117
|
+
|
|
118
|
+
type Params = Record<string, string | undefined>;
|
|
119
|
+
/**
|
|
120
|
+
* Хук для получения параметров маршрута
|
|
121
|
+
*
|
|
122
|
+
* @returns Объект с параметрами текущего маршрута
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```tsx
|
|
126
|
+
* // Для маршрута /users/:id
|
|
127
|
+
* const { id } = useParams()
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
declare function useParams<T extends Params = Params>(): T;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Хук для работы с query параметрами URL
|
|
134
|
+
*
|
|
135
|
+
* @returns Кортеж из [searchParams, setSearchParams]
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```tsx
|
|
139
|
+
* const [searchParams, setSearchParams] = useSearchParams()
|
|
140
|
+
* const id = searchParams.get('id')
|
|
141
|
+
* setSearchParams({ id: '123' })
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
declare function useSearchParams(): [URLSearchParams, react_router_dom.SetURLSearchParams];
|
|
145
|
+
|
|
146
|
+
export { Link, type Location, NavLink, Navigate, type Params, RouterProvider, type RouterProviderProps, useLink, useLocation, useNavigate, useParams, useSearchParams };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import
|
|
3
|
+
import * as react_router_dom from 'react-router-dom';
|
|
4
|
+
import { LinkProps, NavLinkProps, Navigate as Navigate$1, Location as Location$1 } from 'react-router-dom';
|
|
5
|
+
export { LinkProps, NavLinkProps, NavigateOptions, NavigateProps, To } from 'react-router-dom';
|
|
4
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
7
|
|
|
6
8
|
declare function useLink(props: {
|
|
@@ -10,8 +12,45 @@ declare function useLink(props: {
|
|
|
10
12
|
isActive: boolean;
|
|
11
13
|
};
|
|
12
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Компонент для навигационных ссылок
|
|
17
|
+
*
|
|
18
|
+
* Используется для клиентской навигации без перезагрузки страницы
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```tsx
|
|
22
|
+
* <Link to="/about">About</Link>
|
|
23
|
+
* <Link to="/users/123" state={{ from: 'home' }}>User Profile</Link>
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
13
26
|
declare const Link: React.ForwardRefExoticComponent<LinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
14
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Компонент для навигационных ссылок с поддержкой активного состояния
|
|
30
|
+
*
|
|
31
|
+
* Автоматически добавляет класс 'active' когда маршрут активен
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* <NavLink to="/about">About</NavLink>
|
|
36
|
+
* <NavLink to="/users" className={({ isActive }) => isActive ? 'active' : ''}>
|
|
37
|
+
* Users
|
|
38
|
+
* </NavLink>
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
declare const NavLink: React.ForwardRefExoticComponent<NavLinkProps & React.RefAttributes<HTMLAnchorElement>>;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Компонент для программного редиректа
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* <Navigate to="/login" replace />
|
|
49
|
+
* <Navigate to="/dashboard" state={{ from: location }} />
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
declare const Navigate: typeof Navigate$1;
|
|
53
|
+
|
|
15
54
|
type RouterProviderProps = {
|
|
16
55
|
/**
|
|
17
56
|
* ⏳ Кастомный индикатор загрузки
|
|
@@ -43,4 +82,65 @@ type RouterProviderProps = {
|
|
|
43
82
|
|
|
44
83
|
declare function RouterProvider({ children, preloader, basePath, }: Readonly<RouterProviderProps>): react_jsx_runtime.JSX.Element;
|
|
45
84
|
|
|
46
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Тип локации с информацией о текущем маршруте
|
|
87
|
+
*/
|
|
88
|
+
type Location = Location$1;
|
|
89
|
+
/**
|
|
90
|
+
* Хук для получения текущей локации
|
|
91
|
+
*
|
|
92
|
+
* @returns Объект с информацией о текущем маршруте
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```tsx
|
|
96
|
+
* const location = useLocation()
|
|
97
|
+
* console.log(location.pathname) // '/about'
|
|
98
|
+
* console.log(location.search) // '?id=123'
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare function useLocation(): Location;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Хук для программной навигации
|
|
105
|
+
*
|
|
106
|
+
* @returns Функция для навигации
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```tsx
|
|
110
|
+
* const navigate = useNavigate()
|
|
111
|
+
* navigate('/about')
|
|
112
|
+
* navigate('/users', { replace: true })
|
|
113
|
+
* navigate(-1) // назад
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
declare function useNavigate(): react_router_dom.NavigateFunction;
|
|
117
|
+
|
|
118
|
+
type Params = Record<string, string | undefined>;
|
|
119
|
+
/**
|
|
120
|
+
* Хук для получения параметров маршрута
|
|
121
|
+
*
|
|
122
|
+
* @returns Объект с параметрами текущего маршрута
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```tsx
|
|
126
|
+
* // Для маршрута /users/:id
|
|
127
|
+
* const { id } = useParams()
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
declare function useParams<T extends Params = Params>(): T;
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Хук для работы с query параметрами URL
|
|
134
|
+
*
|
|
135
|
+
* @returns Кортеж из [searchParams, setSearchParams]
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```tsx
|
|
139
|
+
* const [searchParams, setSearchParams] = useSearchParams()
|
|
140
|
+
* const id = searchParams.get('id')
|
|
141
|
+
* setSearchParams({ id: '123' })
|
|
142
|
+
* ```
|
|
143
|
+
*/
|
|
144
|
+
declare function useSearchParams(): [URLSearchParams, react_router_dom.SetURLSearchParams];
|
|
145
|
+
|
|
146
|
+
export { Link, type Location, NavLink, Navigate, type Params, RouterProvider, type RouterProviderProps, useLink, useLocation, useNavigate, useParams, useSearchParams };
|
package/dist/react.js
CHANGED
|
@@ -31,15 +31,29 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var react_exports = {};
|
|
32
32
|
__export(react_exports, {
|
|
33
33
|
Link: () => Link,
|
|
34
|
+
NavLink: () => NavLink,
|
|
35
|
+
Navigate: () => Navigate,
|
|
34
36
|
RouterProvider: () => RouterProvider,
|
|
35
|
-
useLink: () => useLink
|
|
37
|
+
useLink: () => useLink,
|
|
38
|
+
useLocation: () => useLocation,
|
|
39
|
+
useNavigate: () => useNavigate,
|
|
40
|
+
useParams: () => useParams,
|
|
41
|
+
useSearchParams: () => useSearchParams
|
|
36
42
|
});
|
|
37
43
|
module.exports = __toCommonJS(react_exports);
|
|
38
44
|
|
|
39
|
-
// src/components/
|
|
45
|
+
// src/components/link.tsx
|
|
46
|
+
var import_react_router_dom2 = require("react-router-dom");
|
|
47
|
+
|
|
48
|
+
// src/components/hooks/use-location.ts
|
|
40
49
|
var import_react_router_dom = require("react-router-dom");
|
|
50
|
+
function useLocation() {
|
|
51
|
+
return (0, import_react_router_dom.useLocation)();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/components/hooks/use-links.tsx
|
|
41
55
|
function useLink(props) {
|
|
42
|
-
const location =
|
|
56
|
+
const location = useLocation();
|
|
43
57
|
const currentPath = location.pathname;
|
|
44
58
|
return {
|
|
45
59
|
href: props.href,
|
|
@@ -48,33 +62,85 @@ function useLink(props) {
|
|
|
48
62
|
}
|
|
49
63
|
|
|
50
64
|
// src/components/link.tsx
|
|
51
|
-
var import_react_router_dom2 = require("react-router-dom");
|
|
52
65
|
var Link = import_react_router_dom2.Link;
|
|
53
66
|
|
|
67
|
+
// src/components/nav-link.tsx
|
|
68
|
+
var import_react_router_dom3 = require("react-router-dom");
|
|
69
|
+
var NavLink = import_react_router_dom3.NavLink;
|
|
70
|
+
|
|
71
|
+
// src/components/navigate.tsx
|
|
72
|
+
var import_react_router_dom4 = require("react-router-dom");
|
|
73
|
+
var Navigate = import_react_router_dom4.Navigate;
|
|
74
|
+
|
|
54
75
|
// src/components/router-provider.tsx
|
|
55
76
|
var import_virtual_routes = require("virtual:routes");
|
|
56
77
|
|
|
57
78
|
// src/components/router-layout.tsx
|
|
58
|
-
var
|
|
59
|
-
var
|
|
79
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
80
|
+
var import_react_router_dom6 = require("react-router-dom");
|
|
60
81
|
|
|
61
82
|
// src/components/router-utils.tsx
|
|
83
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
84
|
+
var import_react_router_dom5 = require("react-router-dom");
|
|
85
|
+
|
|
86
|
+
// src/components/error-boundary.tsx
|
|
62
87
|
var import_react = __toESM(require("react"), 1);
|
|
63
|
-
var import_react_router_dom3 = require("react-router-dom");
|
|
64
88
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
89
|
+
var ErrorBoundary = class extends import_react.default.Component {
|
|
90
|
+
constructor(props) {
|
|
91
|
+
super(props);
|
|
92
|
+
this.state = { hasError: false, error: null };
|
|
93
|
+
}
|
|
94
|
+
static getDerivedStateFromError(error) {
|
|
95
|
+
return { hasError: true, error };
|
|
96
|
+
}
|
|
97
|
+
componentDidCatch(error, errorInfo) {
|
|
98
|
+
this.props.onError?.(error, errorInfo);
|
|
99
|
+
}
|
|
100
|
+
resetError = () => {
|
|
101
|
+
this.setState({ hasError: false, error: null });
|
|
102
|
+
};
|
|
103
|
+
render() {
|
|
104
|
+
if (this.state.hasError && this.state.error) {
|
|
105
|
+
if (this.props.fallback) {
|
|
106
|
+
const Fallback = this.props.fallback;
|
|
107
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Fallback, { error: this.state.error, resetError: this.resetError });
|
|
108
|
+
}
|
|
109
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { style: { padding: "20px" }, children: [
|
|
110
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: "Something went wrong" }),
|
|
111
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { children: this.state.error.message }),
|
|
112
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { onClick: this.resetError, children: "Try again" })
|
|
113
|
+
] });
|
|
114
|
+
}
|
|
115
|
+
return this.props.children;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// src/components/router-utils.tsx
|
|
120
|
+
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
65
121
|
function wrapLayouts(layouts, pageEl) {
|
|
66
122
|
if (!layouts || layouts.length === 0) return pageEl;
|
|
67
123
|
return layouts.reduceRight((child, loader) => {
|
|
68
|
-
const Layout =
|
|
124
|
+
const Layout = import_react2.default.lazy(async () => {
|
|
69
125
|
const module2 = await loader();
|
|
70
126
|
return "default" in module2 ? module2 : { default: module2.Layout };
|
|
71
127
|
});
|
|
72
|
-
return /* @__PURE__ */ (0,
|
|
128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Layout, { children: child });
|
|
73
129
|
}, pageEl);
|
|
74
130
|
}
|
|
75
|
-
|
|
131
|
+
function createLoadingFallback(loadingLoader) {
|
|
132
|
+
if (!loadingLoader) return void 0;
|
|
133
|
+
const Loading = import_react2.default.lazy(loadingLoader);
|
|
134
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Loading, {});
|
|
135
|
+
}
|
|
136
|
+
function createErrorFallback(errorLoader) {
|
|
137
|
+
if (!errorLoader) return void 0;
|
|
138
|
+
const ErrorComponent = import_react2.default.lazy(errorLoader);
|
|
139
|
+
return (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ErrorComponent, { ...props });
|
|
140
|
+
}
|
|
141
|
+
var renderManifestAsRoutes = (manifest2, globalNotFound2) => {
|
|
76
142
|
return manifest2.map((n) => {
|
|
77
|
-
const Page =
|
|
143
|
+
const Page = import_react2.default.lazy(async () => {
|
|
78
144
|
const module2 = await n.loader();
|
|
79
145
|
if (module2 && typeof module2 === "object" && "default" in module2 && module2.default) {
|
|
80
146
|
return module2;
|
|
@@ -97,34 +163,95 @@ var renderManifestAsRoutes = (manifest2) => {
|
|
|
97
163
|
`No valid export found in module for route ${n.path}. Available exports: ${availableExports}`
|
|
98
164
|
);
|
|
99
165
|
});
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
166
|
+
const loadingFallback = createLoadingFallback(n.loading);
|
|
167
|
+
const errorFallback = createErrorFallback(n.error);
|
|
168
|
+
const pageElement = wrapLayouts(n.layouts, /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Page, {}));
|
|
169
|
+
const wrappedElement = errorFallback ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ErrorBoundary, { fallback: errorFallback, children: pageElement }) : pageElement;
|
|
170
|
+
const element = loadingFallback ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.default.Suspense, { fallback: loadingFallback, children: wrappedElement }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.default.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: "Loading..." }), children: wrappedElement });
|
|
171
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react_router_dom5.Route, { path: n.path, element }, n.id);
|
|
172
|
+
}).concat(
|
|
173
|
+
// Добавляем 404 маршрут в конец
|
|
174
|
+
globalNotFound2 ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
175
|
+
import_react_router_dom5.Route,
|
|
176
|
+
{
|
|
177
|
+
path: "*",
|
|
178
|
+
element: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.default.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { children: "Loading..." }), children: (() => {
|
|
179
|
+
const NotFound = import_react2.default.lazy(globalNotFound2);
|
|
180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(NotFound, {});
|
|
181
|
+
})() })
|
|
182
|
+
},
|
|
183
|
+
"__not_found__"
|
|
184
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
185
|
+
import_react_router_dom5.Route,
|
|
186
|
+
{
|
|
187
|
+
path: "*",
|
|
188
|
+
element: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: { padding: "20px", textAlign: "center" }, children: [
|
|
189
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("h1", { children: "404" }),
|
|
190
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { children: "Page not found" })
|
|
191
|
+
] })
|
|
192
|
+
},
|
|
193
|
+
"__not_found__"
|
|
194
|
+
)
|
|
195
|
+
);
|
|
103
196
|
};
|
|
104
197
|
|
|
105
198
|
// src/components/router-layout.tsx
|
|
106
|
-
var
|
|
199
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
107
200
|
var RouterLayout = ({
|
|
108
201
|
manifest: manifest2,
|
|
109
202
|
children,
|
|
110
203
|
preloader,
|
|
111
|
-
basePath = "/"
|
|
112
|
-
|
|
204
|
+
basePath = "/",
|
|
205
|
+
globalNotFound: globalNotFound2
|
|
206
|
+
}) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_router_dom6.BrowserRouter, { basename: basePath, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react3.default.Suspense, { fallback: children || preloader || /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: "Loading..." }), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_router_dom6.Routes, { children: renderManifestAsRoutes(manifest2, globalNotFound2) }) }) });
|
|
113
207
|
|
|
114
208
|
// src/components/router-provider.tsx
|
|
115
|
-
var
|
|
209
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
116
210
|
function RouterProvider({
|
|
117
211
|
children,
|
|
118
212
|
preloader,
|
|
119
213
|
basePath
|
|
120
214
|
}) {
|
|
121
215
|
const finalBasePath = basePath ?? import_virtual_routes.basePath ?? "/";
|
|
122
|
-
return /* @__PURE__ */ (0,
|
|
216
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
217
|
+
RouterLayout,
|
|
218
|
+
{
|
|
219
|
+
manifest: import_virtual_routes.manifest,
|
|
220
|
+
preloader,
|
|
221
|
+
basePath: finalBasePath,
|
|
222
|
+
globalNotFound: import_virtual_routes.globalNotFound,
|
|
223
|
+
children
|
|
224
|
+
}
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// src/components/hooks/use-navigate.ts
|
|
229
|
+
var import_react_router_dom7 = require("react-router-dom");
|
|
230
|
+
function useNavigate() {
|
|
231
|
+
return (0, import_react_router_dom7.useNavigate)();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// src/components/hooks/use-params.ts
|
|
235
|
+
var import_react_router_dom8 = require("react-router-dom");
|
|
236
|
+
function useParams() {
|
|
237
|
+
return (0, import_react_router_dom8.useParams)();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// src/components/hooks/use-search-params.ts
|
|
241
|
+
var import_react_router_dom9 = require("react-router-dom");
|
|
242
|
+
function useSearchParams() {
|
|
243
|
+
return (0, import_react_router_dom9.useSearchParams)();
|
|
123
244
|
}
|
|
124
245
|
// Annotate the CommonJS export names for ESM import in node:
|
|
125
246
|
0 && (module.exports = {
|
|
126
247
|
Link,
|
|
248
|
+
NavLink,
|
|
249
|
+
Navigate,
|
|
127
250
|
RouterProvider,
|
|
128
|
-
useLink
|
|
251
|
+
useLink,
|
|
252
|
+
useLocation,
|
|
253
|
+
useNavigate,
|
|
254
|
+
useParams,
|
|
255
|
+
useSearchParams
|
|
129
256
|
});
|
|
130
257
|
//# sourceMappingURL=react.js.map
|
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":["export { useLink } from './components/hooks/use-links'\r\nexport { Link } from './components/link'\r\nexport { default as RouterProvider } from './components/router-provider'\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;;;ACAA,8BAA4B;AAErB,SAAS,QAAQ,OAAyB;AAC/C,QAAM,eAAW,qCAAY;AAC7B,QAAM,cAAc,SAAS;AAE7B,SAAO;AAAA,IACL,MAAM,MAAM;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AAwB,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;","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"]}
|
|
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/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 { 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 { 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 {\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}: 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>\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\tglobalNotFound,\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, globalNotFound)}</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 { 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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,IAAAA,2BAAwC;;;ACDxC,8BAAiD;AAoB1C,SAAS,cAAwB;AACvC,aAAO,wBAAAC,aAAkB;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,yBAAAC;;;AGfpB,IAAAC,2BAA8C;AAiBvC,IAAM,UAAU,yBAAAC;;;ACjBvB,IAAAC,2BAAgD;AAazC,IAAM,WAAW,yBAAAC;;;ACdxB,4BAIO;;;ACJP,IAAAC,gBAAkB;AAClB,IAAAC,2BAAsC;;;ACDtC,IAAAC,gBAAkB;AAClB,IAAAC,2BAAsB;;;ACDtB,mBAAkB;AAyCP;AAzBJ,IAAM,gBAAN,cAA4B,aAAAC,QAAM,UAGvC;AAAA,EACD,YAAY,OAA2B;AACtC,UAAM,KAAK;AACX,SAAK,QAAQ,EAAE,UAAU,OAAO,OAAO,KAAK;AAAA,EAC7C;AAAA,EAEA,OAAO,yBAAyB,OAAkC;AACjE,WAAO,EAAE,UA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,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","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"]}
|