@xfe-repo/web-router 1.0.3 → 1.0.5
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/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +4 -3
- package/dist/index.mjs +4 -3
- package/package.json +3 -3
package/dist/index.d.mts
CHANGED
|
@@ -10,7 +10,12 @@ type RouteConfig = {
|
|
|
10
10
|
path: string;
|
|
11
11
|
Component: PageComponent;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
type GetRoutesConfig = {
|
|
14
|
+
pagesIndexPath: string[];
|
|
15
|
+
getPageComponents: (path: string) => Promise<any>;
|
|
16
|
+
fallback?: ReactElement;
|
|
17
|
+
};
|
|
18
|
+
declare const getRoutes: (config: GetRoutesConfig) => RouteConfig[];
|
|
14
19
|
|
|
15
20
|
type RouterProps = {
|
|
16
21
|
navigator: NavigatorType;
|
|
@@ -50,4 +55,4 @@ declare function createNavigator(options: CreateNavigatorOptions): NavigatorType
|
|
|
50
55
|
declare const getClientNavigator: () => NavigatorType;
|
|
51
56
|
declare const routerReady: typeof loadableReady;
|
|
52
57
|
|
|
53
|
-
export { type CreateNavigatorOptions, Link, type NavigatorStack, type NavigatorType, type PageComponent, type RouteConfig, Router, createNavigator, getClientNavigator, getRoutes, routerReady };
|
|
58
|
+
export { type CreateNavigatorOptions, type GetRoutesConfig, Link, type NavigatorStack, type NavigatorType, type PageComponent, type RouteConfig, Router, createNavigator, getClientNavigator, getRoutes, routerReady };
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,12 @@ type RouteConfig = {
|
|
|
10
10
|
path: string;
|
|
11
11
|
Component: PageComponent;
|
|
12
12
|
};
|
|
13
|
-
|
|
13
|
+
type GetRoutesConfig = {
|
|
14
|
+
pagesIndexPath: string[];
|
|
15
|
+
getPageComponents: (path: string) => Promise<any>;
|
|
16
|
+
fallback?: ReactElement;
|
|
17
|
+
};
|
|
18
|
+
declare const getRoutes: (config: GetRoutesConfig) => RouteConfig[];
|
|
14
19
|
|
|
15
20
|
type RouterProps = {
|
|
16
21
|
navigator: NavigatorType;
|
|
@@ -50,4 +55,4 @@ declare function createNavigator(options: CreateNavigatorOptions): NavigatorType
|
|
|
50
55
|
declare const getClientNavigator: () => NavigatorType;
|
|
51
56
|
declare const routerReady: typeof loadableReady;
|
|
52
57
|
|
|
53
|
-
export { type CreateNavigatorOptions, Link, type NavigatorStack, type NavigatorType, type PageComponent, type RouteConfig, Router, createNavigator, getClientNavigator, getRoutes, routerReady };
|
|
58
|
+
export { type CreateNavigatorOptions, type GetRoutesConfig, Link, type NavigatorStack, type NavigatorType, type PageComponent, type RouteConfig, Router, createNavigator, getClientNavigator, getRoutes, routerReady };
|
package/dist/index.js
CHANGED
|
@@ -288,7 +288,8 @@ var import_query_string = __toESM(require("query-string"));
|
|
|
288
288
|
__reExport(src_exports, require("react-router-dom"), module.exports);
|
|
289
289
|
// src/routes.ts
|
|
290
290
|
var import_component = __toESM(require("@loadable/component"));
|
|
291
|
-
var getRoutes = function(
|
|
291
|
+
var getRoutes = function(config) {
|
|
292
|
+
var pagesIndexPath = config.pagesIndexPath, getPageComponents = config.getPageComponents, fallback = config.fallback;
|
|
292
293
|
var routes = [];
|
|
293
294
|
pagesIndexPath.forEach(function(pageIndexPath) {
|
|
294
295
|
if (pageIndexPath.startsWith("./")) return;
|
|
@@ -301,11 +302,11 @@ var getRoutes = function(pagesIndexPath, getPageComponents, fallback) {
|
|
|
301
302
|
});
|
|
302
303
|
var routerPath = "/".concat(pageRelativePath);
|
|
303
304
|
if (routerPath === "/home" || routerPath === "/index") routerPath = "/";
|
|
304
|
-
var
|
|
305
|
+
var config2 = {
|
|
305
306
|
path: routerPath,
|
|
306
307
|
Component: pageComponent
|
|
307
308
|
};
|
|
308
|
-
routes.push(
|
|
309
|
+
routes.push(config2);
|
|
309
310
|
});
|
|
310
311
|
return routes;
|
|
311
312
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,8 @@ export * from "react-router-dom";
|
|
|
7
7
|
|
|
8
8
|
// src/routes.ts
|
|
9
9
|
import loadable from "@loadable/component";
|
|
10
|
-
var getRoutes = (
|
|
10
|
+
var getRoutes = (config) => {
|
|
11
|
+
const { pagesIndexPath, getPageComponents, fallback } = config;
|
|
11
12
|
const routes = [];
|
|
12
13
|
pagesIndexPath.forEach((pageIndexPath) => {
|
|
13
14
|
if (pageIndexPath.startsWith("./"))
|
|
@@ -18,11 +19,11 @@ var getRoutes = (pagesIndexPath, getPageComponents, fallback) => {
|
|
|
18
19
|
let routerPath = `/${pageRelativePath}`;
|
|
19
20
|
if (routerPath === "/home" || routerPath === "/index")
|
|
20
21
|
routerPath = "/";
|
|
21
|
-
const
|
|
22
|
+
const config2 = {
|
|
22
23
|
path: routerPath,
|
|
23
24
|
Component: pageComponent
|
|
24
25
|
};
|
|
25
|
-
routes.push(
|
|
26
|
+
routes.push(config2);
|
|
26
27
|
});
|
|
27
28
|
return routes;
|
|
28
29
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xfe-repo/web-router",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"@types/node": "^20.10.4",
|
|
33
33
|
"@types/react": "^18.2.0",
|
|
34
34
|
"@xfe-repo/web-register": "1.0.3",
|
|
35
|
-
"@xfe-repo/
|
|
36
|
-
"@xfe-repo/
|
|
35
|
+
"@xfe-repo/typescript-config": "0.0.3",
|
|
36
|
+
"@xfe-repo/eslint-config": "0.0.2"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "tsup",
|