path-rush 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react.d.cts +1 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.js +17 -2
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +17 -1
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.d.cts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { LinkProps } from 'react-router-dom';
|
|
4
|
+
export { LinkProps, Location, NavLink, NavLinkProps, Navigate, NavigateOptions, NavigateProps, Params, To, useLocation, useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
|
4
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
6
|
|
|
6
7
|
declare function useLink(props: {
|
package/dist/react.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import { LinkProps } from 'react-router-dom';
|
|
4
|
+
export { LinkProps, Location, NavLink, NavLinkProps, Navigate, NavigateOptions, NavigateProps, Params, To, useLocation, useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
|
4
5
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
6
|
|
|
6
7
|
declare function useLink(props: {
|
package/dist/react.js
CHANGED
|
@@ -31,8 +31,14 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var react_exports = {};
|
|
32
32
|
__export(react_exports, {
|
|
33
33
|
Link: () => Link,
|
|
34
|
+
NavLink: () => import_react_router_dom5.NavLink,
|
|
35
|
+
Navigate: () => import_react_router_dom5.Navigate,
|
|
34
36
|
RouterProvider: () => RouterProvider,
|
|
35
|
-
useLink: () => useLink
|
|
37
|
+
useLink: () => useLink,
|
|
38
|
+
useLocation: () => import_react_router_dom5.useLocation,
|
|
39
|
+
useNavigate: () => import_react_router_dom5.useNavigate,
|
|
40
|
+
useParams: () => import_react_router_dom5.useParams,
|
|
41
|
+
useSearchParams: () => import_react_router_dom5.useSearchParams
|
|
36
42
|
});
|
|
37
43
|
module.exports = __toCommonJS(react_exports);
|
|
38
44
|
|
|
@@ -121,10 +127,19 @@ function RouterProvider({
|
|
|
121
127
|
const finalBasePath = basePath ?? import_virtual_routes.basePath ?? "/";
|
|
122
128
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(RouterLayout, { manifest: import_virtual_routes.manifest, preloader, basePath: finalBasePath, children });
|
|
123
129
|
}
|
|
130
|
+
|
|
131
|
+
// src/react.ts
|
|
132
|
+
var import_react_router_dom5 = require("react-router-dom");
|
|
124
133
|
// Annotate the CommonJS export names for ESM import in node:
|
|
125
134
|
0 && (module.exports = {
|
|
126
135
|
Link,
|
|
136
|
+
NavLink,
|
|
137
|
+
Navigate,
|
|
127
138
|
RouterProvider,
|
|
128
|
-
useLink
|
|
139
|
+
useLink,
|
|
140
|
+
useLocation,
|
|
141
|
+
useNavigate,
|
|
142
|
+
useParams,
|
|
143
|
+
useSearchParams
|
|
129
144
|
});
|
|
130
145
|
//# 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":["
|
|
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;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;AAAA,IACZ,UAAU,gBAAgB,MAAM;AAAA,EAClC;AACF;;;ACTA,IAAAA,2BAAwC;AAIjC,IAAM,OAAO,yBAAAC;;;ACLpB,4BAAqD;;;ACArD,IAAAC,gBAAkB;AAClB,IAAAC,2BAAsC;;;ACDtC,mBAAkB;AAClB,IAAAC,2BAAsB;AAeb;AAZT,SAAS,YACR,SACA,QACC;AACD,MAAI,CAAC,WAAW,QAAQ,WAAW,EAAG,QAAO;AAE7C,SAAO,QAAQ,YAAY,CAAC,OAAO,WAAW;AAC7C,UAAM,SAAS,aAAAC,QAAM,KAAK,YAAY;AACrC,YAAMC,UAAS,MAAM,OAAO;AAE5B,aAAO,aAAaA,UAASA,UAAS,EAAE,SAASA,QAAO,OAAO;AAAA,IAChE,CAAC;AACD,WAAO,4CAAC,UAAQ,iBAAM;AAAA,EACvB,GAAG,MAA4B;AAChC;AAEO,IAAM,yBAAyB,CAACC,cAAqB;AAC3D,SAAOA,UAAS,IAAI,OAAK;A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,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"]}
|
package/dist/react.mjs
CHANGED
|
@@ -83,9 +83,25 @@ function RouterProvider({
|
|
|
83
83
|
const finalBasePath = basePath ?? configBasePath ?? "/";
|
|
84
84
|
return /* @__PURE__ */ jsx3(RouterLayout, { manifest, preloader, basePath: finalBasePath, children });
|
|
85
85
|
}
|
|
86
|
+
|
|
87
|
+
// src/react.ts
|
|
88
|
+
import {
|
|
89
|
+
Navigate,
|
|
90
|
+
NavLink,
|
|
91
|
+
useLocation as useLocation2,
|
|
92
|
+
useNavigate,
|
|
93
|
+
useParams,
|
|
94
|
+
useSearchParams
|
|
95
|
+
} from "react-router-dom";
|
|
86
96
|
export {
|
|
87
97
|
Link,
|
|
98
|
+
NavLink,
|
|
99
|
+
Navigate,
|
|
88
100
|
RouterProvider,
|
|
89
|
-
useLink
|
|
101
|
+
useLink,
|
|
102
|
+
useLocation2 as useLocation,
|
|
103
|
+
useNavigate,
|
|
104
|
+
useParams,
|
|
105
|
+
useSearchParams
|
|
90
106
|
};
|
|
91
107
|
//# sourceMappingURL=react.mjs.map
|
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"],"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"],"mappings":";AAAA,SAAS,mBAAmB;AAErB,SAAS,QAAQ,OAAyB;AAC/C,QAAM,WAAW,YAAY;AAC7B,QAAM,cAAc,SAAS;AAE7B,SA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,IAAI,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;","names":["React","manifest","jsx","manifest","React","jsx"]}
|
|
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;AAAA,IACL,MAAM,MAAM;AAAA,IACZ,UAAU,gBAAgB,MAAM;AAAA,EAClC;AACF;;;ACTA,SAAS,QAAQ,uBAAuB;AAIjC,IAAM,OAAO;;;ACLpB,SAAS,UAAU,YAAY,sBAAsB;;;ACArD,OAAOA,YAAW;AAClB,SAAS,eAAe,cAAc;;;ACDtC,OAAO,WAAW;AAClB,SAAS,aAAa;AAeb;AAZT,SAAS,YACR,SACA,QACC;AACD,MAAI,CAAC,WAAW,QAAQ,WAAW,EAAG,QAAO;AAE7C,SAAO,QAAQ,YAAY,CAAC,OAAO,WAAW;AAC7C,UAAM,SAAS,MAAM,KAAK,YAAY;AACrC,YAAM,SAAS,MAAM,OAAO;AAE5B,aAAO,aAAa,SAAS,SAAS,EAAE,SAAS,OAAO,OAAO;AAAA,IAChE,CAAC;AACD,WAAO,oBAAC,UAAQ,iBAAM;AAAA,EACvB,GAAG,MAA4B;AAChC;AAEO,IAAM,yBAAyB,CAACC,cAAqB;AAC3D,SAAOA,UAAS,IAAI,OAAK;AACxB,UAAM,OAAO,MAAM,KAAK,YAAY;AACnC,YAAM,SAAS,MAAM,EAAE,OAAO;AAG9B,UACC,UACA,OAAO,WAAW,YAClB,aAAa,UACb,OAAO,SACN;AACD,eAAO;AAAA,MACR;AAGA,UAAI,UAAU,OAAO,WAAW,UAAU;AACzC,cAAM,eAAe,OAAO,KAAK,MAAM,EAAE;AAAA,UACxC,SAAO,QAAQ;AAAA,QAChB;AACA,mBAAW,OAAO,cAAc;AAC/B,gBAAM,cAAc,OAAO,GAAG;AAC9B,cACC,OAAO,g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