@etsoo/react 1.7.92 → 1.7.94
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { RouteObject } from 'react-router-dom';
|
|
2
3
|
/**
|
|
3
4
|
* Dynamic router props
|
|
4
5
|
*/
|
|
@@ -14,3 +15,10 @@ export type DynamicRouterProps = {
|
|
|
14
15
|
* @returns Component
|
|
15
16
|
*/
|
|
16
17
|
export declare function DynamicRouter(props: React.PropsWithChildren<DynamicRouterProps>): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* Create dynamic router
|
|
20
|
+
* @param routes Routes
|
|
21
|
+
* @param opts Options
|
|
22
|
+
* @returns Router
|
|
23
|
+
*/
|
|
24
|
+
export declare function createDynamicRouter(routes: RouteObject[], opts?: DynamicRouterProps): import("@remix-run/router").Router;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { BridgeUtils } from '@etsoo/appscript';
|
|
3
|
-
import { BrowserRouter, MemoryRouter } from 'react-router-dom';
|
|
3
|
+
import { BrowserRouter, createBrowserRouter, createMemoryRouter, MemoryRouter } from 'react-router-dom';
|
|
4
4
|
function getEntries(host) {
|
|
5
5
|
const startUrl = host.getStartUrl();
|
|
6
6
|
return startUrl == null ? undefined : [startUrl];
|
|
@@ -17,3 +17,19 @@ export function DynamicRouter(props) {
|
|
|
17
17
|
const host = BridgeUtils.host;
|
|
18
18
|
return host == null ? (_jsx(BrowserRouter, { basename: basename, children: children })) : (_jsx(MemoryRouter, { basename: basename, initialEntries: getEntries(host), children: children }));
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Create dynamic router
|
|
22
|
+
* @param routes Routes
|
|
23
|
+
* @param opts Options
|
|
24
|
+
* @returns Router
|
|
25
|
+
*/
|
|
26
|
+
export function createDynamicRouter(routes, opts) {
|
|
27
|
+
// Is host?
|
|
28
|
+
const host = BridgeUtils.host;
|
|
29
|
+
if (host == null) {
|
|
30
|
+
return createBrowserRouter(routes, opts);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return createMemoryRouter(routes, opts);
|
|
34
|
+
}
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.94",
|
|
4
4
|
"description": "TypeScript ReactJs UI Independent Framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"@emotion/css": "^11.13.4",
|
|
51
51
|
"@emotion/react": "^11.13.3",
|
|
52
52
|
"@emotion/styled": "^11.13.0",
|
|
53
|
-
"@etsoo/appscript": "^1.5.
|
|
53
|
+
"@etsoo/appscript": "^1.5.62",
|
|
54
54
|
"@etsoo/notificationbase": "^1.1.52",
|
|
55
55
|
"@etsoo/shared": "^1.2.51",
|
|
56
56
|
"react": "^18.3.1",
|
|
@@ -59,15 +59,15 @@
|
|
|
59
59
|
"react-window": "^1.8.10"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@babel/cli": "^7.25.
|
|
63
|
-
"@babel/core": "^7.25.
|
|
64
|
-
"@babel/plugin-transform-runtime": "^7.25.
|
|
65
|
-
"@babel/preset-env": "^7.25.
|
|
66
|
-
"@babel/runtime-corejs3": "^7.25.
|
|
62
|
+
"@babel/cli": "^7.25.9",
|
|
63
|
+
"@babel/core": "^7.25.9",
|
|
64
|
+
"@babel/plugin-transform-runtime": "^7.25.9",
|
|
65
|
+
"@babel/preset-env": "^7.25.9",
|
|
66
|
+
"@babel/runtime-corejs3": "^7.25.9",
|
|
67
67
|
"@testing-library/jest-dom": "^6.6.2",
|
|
68
68
|
"@testing-library/react": "^16.0.1",
|
|
69
|
-
"@types/jest": "^29.5.
|
|
70
|
-
"@types/react": "^18.3.
|
|
69
|
+
"@types/jest": "^29.5.14",
|
|
70
|
+
"@types/react": "^18.3.12",
|
|
71
71
|
"@types/react-dom": "^18.3.1",
|
|
72
72
|
"@types/react-window": "^1.8.8",
|
|
73
73
|
"jest": "^29.7.0",
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { BridgeUtils, IBridgeHost } from '@etsoo/appscript';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
BrowserRouter,
|
|
5
|
+
createBrowserRouter,
|
|
6
|
+
createMemoryRouter,
|
|
7
|
+
MemoryRouter,
|
|
8
|
+
RouteObject
|
|
9
|
+
} from 'react-router-dom';
|
|
4
10
|
|
|
5
11
|
/**
|
|
6
12
|
* Dynamic router props
|
|
@@ -38,3 +44,22 @@ export function DynamicRouter(
|
|
|
38
44
|
</MemoryRouter>
|
|
39
45
|
);
|
|
40
46
|
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Create dynamic router
|
|
50
|
+
* @param routes Routes
|
|
51
|
+
* @param opts Options
|
|
52
|
+
* @returns Router
|
|
53
|
+
*/
|
|
54
|
+
export function createDynamicRouter(
|
|
55
|
+
routes: RouteObject[],
|
|
56
|
+
opts?: DynamicRouterProps
|
|
57
|
+
) {
|
|
58
|
+
// Is host?
|
|
59
|
+
const host = BridgeUtils.host;
|
|
60
|
+
if (host == null) {
|
|
61
|
+
return createBrowserRouter(routes, opts);
|
|
62
|
+
} else {
|
|
63
|
+
return createMemoryRouter(routes, opts);
|
|
64
|
+
}
|
|
65
|
+
}
|