piral-core 1.3.0-beta.6065 → 1.3.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/esm/components/PiralRoutes.js +20 -15
- package/esm/components/PiralRoutes.js.map +1 -1
- package/esm/types/state.d.ts +6 -1
- package/lib/components/PiralRoutes.js +20 -15
- package/lib/components/PiralRoutes.js.map +1 -1
- package/lib/types/state.d.ts +6 -1
- package/package.json +4 -4
- package/src/components/PiralRoutes.tsx +30 -15
- package/src/types/api.ts +1 -1
- package/src/types/state.ts +8 -1
|
@@ -3,23 +3,28 @@ import * as React from 'react';
|
|
|
3
3
|
import { useGlobalState } from '../hooks';
|
|
4
4
|
import { createRouteMatcher } from '../utils';
|
|
5
5
|
import { useRouteFilter } from '../../app.codegen';
|
|
6
|
-
function
|
|
6
|
+
function useShellRoutes() {
|
|
7
7
|
const routes = useGlobalState((s) => s.routes);
|
|
8
|
+
return React.useMemo(() => Object.entries(routes).map(([path, Component]) => ({
|
|
9
|
+
path,
|
|
10
|
+
Component,
|
|
11
|
+
meta: (Component === null || Component === void 0 ? void 0 : Component.meta) || {},
|
|
12
|
+
matcher: createRouteMatcher(path),
|
|
13
|
+
})), [routes]);
|
|
14
|
+
}
|
|
15
|
+
function usePiletRoutes() {
|
|
8
16
|
const pages = useGlobalState((s) => s.registry.pages);
|
|
9
|
-
return
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
matcher: createRouteMatcher(path),
|
|
21
|
-
})),
|
|
22
|
-
]);
|
|
17
|
+
return React.useMemo(() => Object.entries(pages).map(([path, entry]) => ({
|
|
18
|
+
path,
|
|
19
|
+
Component: entry.component,
|
|
20
|
+
meta: entry.meta,
|
|
21
|
+
matcher: createRouteMatcher(path),
|
|
22
|
+
})), [pages]);
|
|
23
|
+
}
|
|
24
|
+
function useRoutes() {
|
|
25
|
+
const shellRoutes = useShellRoutes();
|
|
26
|
+
const piletRoutes = usePiletRoutes();
|
|
27
|
+
return useRouteFilter([...shellRoutes, ...piletRoutes]);
|
|
23
28
|
}
|
|
24
29
|
/**
|
|
25
30
|
* The component for defining the exclusive routes to be used.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PiralRoutes.js","sourceRoot":"","sources":["../../src/components/PiralRoutes.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"PiralRoutes.js","sourceRoot":"","sources":["../../src/components/PiralRoutes.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG9C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,SAAS,cAAc;IACrB,MAAM,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC/C,OAAO,KAAK,CAAC,OAAO,CAClB,GAAG,EAAE,CACH,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;QACjD,IAAI;QACJ,SAAS;QACT,IAAI,EAAE,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,KAAI,EAAE;QAC3B,OAAO,EAAE,kBAAkB,CAAC,IAAI,CAAC;KAClC,CAAC,CAAC,EACL,CAAC,MAAM,CAAC,CACT,CAAC;AACJ,CAAC;AAED,SAAS,cAAc;IACrB,MAAM,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,OAAO,KAAK,CAAC,OAAO,CAClB,GAAG,EAAE,CACH,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5C,IAAI;QACJ,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,kBAAkB,CAAC,IAAI,CAAC;KAClC,CAAC,CAAC,EACL,CAAC,KAAK,CAAC,CACR,CAAC;AACJ,CAAC;AAED,SAAS,SAAS;IAChB,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,OAAO,cAAc,CAAC,CAAC,GAAG,WAAW,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC;AAC1D,CAAC;AAgBD;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAA0B,CAAC,EAAmC,EAAE,EAAE;QAAvC,EAAE,QAAQ,EAAE,WAAW,OAAY,EAAP,KAAK,cAAjC,2BAAmC,CAAF;IAClF,MAAM,KAAK,GAAG,SAAS,EAAE,CAAC;IAC1B,OAAO,oBAAC,WAAW,kBAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,IAAM,KAAK,EAAI,CAAC;AACtE,CAAC,CAAC;AACF,WAAW,CAAC,WAAW,GAAG,QAAQ,CAAC"}
|
package/esm/types/state.d.ts
CHANGED
|
@@ -150,7 +150,12 @@ export interface GlobalState extends PiralCustomState {
|
|
|
150
150
|
/**
|
|
151
151
|
* The used (exact) application routes.
|
|
152
152
|
*/
|
|
153
|
-
routes: Dict<ComponentType<RouteComponentProps<any
|
|
153
|
+
routes: Dict<ComponentType<RouteComponentProps<any>> & {
|
|
154
|
+
/**
|
|
155
|
+
* The optional meta data registered with the page.
|
|
156
|
+
*/
|
|
157
|
+
meta?: PiralPageMeta;
|
|
158
|
+
}>;
|
|
154
159
|
/**
|
|
155
160
|
* The current provider.
|
|
156
161
|
*/
|
|
@@ -6,23 +6,28 @@ const React = require("react");
|
|
|
6
6
|
const hooks_1 = require("../hooks");
|
|
7
7
|
const utils_1 = require("../utils");
|
|
8
8
|
const app_codegen_1 = require("../../app.codegen");
|
|
9
|
-
function
|
|
9
|
+
function useShellRoutes() {
|
|
10
10
|
const routes = (0, hooks_1.useGlobalState)((s) => s.routes);
|
|
11
|
+
return React.useMemo(() => Object.entries(routes).map(([path, Component]) => ({
|
|
12
|
+
path,
|
|
13
|
+
Component,
|
|
14
|
+
meta: (Component === null || Component === void 0 ? void 0 : Component.meta) || {},
|
|
15
|
+
matcher: (0, utils_1.createRouteMatcher)(path),
|
|
16
|
+
})), [routes]);
|
|
17
|
+
}
|
|
18
|
+
function usePiletRoutes() {
|
|
11
19
|
const pages = (0, hooks_1.useGlobalState)((s) => s.registry.pages);
|
|
12
|
-
return (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
matcher: (0, utils_1.createRouteMatcher)(path),
|
|
24
|
-
})),
|
|
25
|
-
]);
|
|
20
|
+
return React.useMemo(() => Object.entries(pages).map(([path, entry]) => ({
|
|
21
|
+
path,
|
|
22
|
+
Component: entry.component,
|
|
23
|
+
meta: entry.meta,
|
|
24
|
+
matcher: (0, utils_1.createRouteMatcher)(path),
|
|
25
|
+
})), [pages]);
|
|
26
|
+
}
|
|
27
|
+
function useRoutes() {
|
|
28
|
+
const shellRoutes = useShellRoutes();
|
|
29
|
+
const piletRoutes = usePiletRoutes();
|
|
30
|
+
return (0, app_codegen_1.useRouteFilter)([...shellRoutes, ...piletRoutes]);
|
|
26
31
|
}
|
|
27
32
|
/**
|
|
28
33
|
* The component for defining the exclusive routes to be used.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PiralRoutes.js","sourceRoot":"","sources":["../../src/components/PiralRoutes.tsx"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAE/B,oCAA0C;AAC1C,oCAA8C;
|
|
1
|
+
{"version":3,"file":"PiralRoutes.js","sourceRoot":"","sources":["../../src/components/PiralRoutes.tsx"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAE/B,oCAA0C;AAC1C,oCAA8C;AAG9C,mDAAmD;AAEnD,SAAS,cAAc;IACrB,MAAM,MAAM,GAAG,IAAA,sBAAc,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC/C,OAAO,KAAK,CAAC,OAAO,CAClB,GAAG,EAAE,CACH,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,CAAC,CAAC;QACjD,IAAI;QACJ,SAAS;QACT,IAAI,EAAE,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,KAAI,EAAE;QAC3B,OAAO,EAAE,IAAA,0BAAkB,EAAC,IAAI,CAAC;KAClC,CAAC,CAAC,EACL,CAAC,MAAM,CAAC,CACT,CAAC;AACJ,CAAC;AAED,SAAS,cAAc;IACrB,MAAM,KAAK,GAAG,IAAA,sBAAc,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,OAAO,KAAK,CAAC,OAAO,CAClB,GAAG,EAAE,CACH,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5C,IAAI;QACJ,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,IAAA,0BAAkB,EAAC,IAAI,CAAC;KAClC,CAAC,CAAC,EACL,CAAC,KAAK,CAAC,CACR,CAAC;AACJ,CAAC;AAED,SAAS,SAAS;IAChB,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,OAAO,IAAA,4BAAc,EAAC,CAAC,GAAG,WAAW,EAAE,GAAG,WAAW,CAAC,CAAC,CAAC;AAC1D,CAAC;AAgBD;;GAEG;AACI,MAAM,WAAW,GAA0B,CAAC,EAAmC,EAAE,EAAE;QAAvC,EAAE,QAAQ,EAAE,WAAW,OAAY,EAAP,KAAK,sBAAjC,2BAAmC,CAAF;IAClF,MAAM,KAAK,GAAG,SAAS,EAAE,CAAC;IAC1B,OAAO,oBAAC,WAAW,kBAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,IAAM,KAAK,EAAI,CAAC;AACtE,CAAC,CAAC;AAHW,QAAA,WAAW,eAGtB;AACF,mBAAW,CAAC,WAAW,GAAG,QAAQ,CAAC"}
|
package/lib/types/state.d.ts
CHANGED
|
@@ -150,7 +150,12 @@ export interface GlobalState extends PiralCustomState {
|
|
|
150
150
|
/**
|
|
151
151
|
* The used (exact) application routes.
|
|
152
152
|
*/
|
|
153
|
-
routes: Dict<ComponentType<RouteComponentProps<any
|
|
153
|
+
routes: Dict<ComponentType<RouteComponentProps<any>> & {
|
|
154
|
+
/**
|
|
155
|
+
* The optional meta data registered with the page.
|
|
156
|
+
*/
|
|
157
|
+
meta?: PiralPageMeta;
|
|
158
|
+
}>;
|
|
154
159
|
/**
|
|
155
160
|
* The current provider.
|
|
156
161
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-core",
|
|
3
|
-
"version": "1.3.0
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "The core library for creating a Piral instance.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"portal",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"path-to-regexp": "^1.8.0",
|
|
76
|
-
"piral-base": "1.3.0
|
|
77
|
-
"piral-debug-utils": "1.3.0
|
|
76
|
+
"piral-base": "^1.3.0",
|
|
77
|
+
"piral-debug-utils": "^1.3.0",
|
|
78
78
|
"zustand": "^3.0.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
"react-router-dom",
|
|
95
95
|
"tslib"
|
|
96
96
|
],
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "f5d3d79391f06237aa1e2ce1802c69a09e472251"
|
|
98
98
|
}
|
|
@@ -3,26 +3,41 @@ import { RouteComponentProps, SwitchProps } from 'react-router';
|
|
|
3
3
|
import { useGlobalState } from '../hooks';
|
|
4
4
|
import { createRouteMatcher } from '../utils';
|
|
5
5
|
import { RouteSwitchProps } from '../types';
|
|
6
|
+
|
|
6
7
|
import { useRouteFilter } from '../../app.codegen';
|
|
7
8
|
|
|
8
|
-
function
|
|
9
|
+
function useShellRoutes() {
|
|
9
10
|
const routes = useGlobalState((s) => s.routes);
|
|
11
|
+
return React.useMemo(
|
|
12
|
+
() =>
|
|
13
|
+
Object.entries(routes).map(([path, Component]) => ({
|
|
14
|
+
path,
|
|
15
|
+
Component,
|
|
16
|
+
meta: Component?.meta || {},
|
|
17
|
+
matcher: createRouteMatcher(path),
|
|
18
|
+
})),
|
|
19
|
+
[routes],
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function usePiletRoutes() {
|
|
10
24
|
const pages = useGlobalState((s) => s.registry.pages);
|
|
25
|
+
return React.useMemo(
|
|
26
|
+
() =>
|
|
27
|
+
Object.entries(pages).map(([path, entry]) => ({
|
|
28
|
+
path,
|
|
29
|
+
Component: entry.component,
|
|
30
|
+
meta: entry.meta,
|
|
31
|
+
matcher: createRouteMatcher(path),
|
|
32
|
+
})),
|
|
33
|
+
[pages],
|
|
34
|
+
);
|
|
35
|
+
}
|
|
11
36
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
meta: {},
|
|
17
|
-
matcher: createRouteMatcher(path),
|
|
18
|
-
})),
|
|
19
|
-
...Object.entries(pages).map(([path, entry]) => ({
|
|
20
|
-
path,
|
|
21
|
-
Component: entry.component,
|
|
22
|
-
meta: entry.meta,
|
|
23
|
-
matcher: createRouteMatcher(path),
|
|
24
|
-
})),
|
|
25
|
-
]);
|
|
37
|
+
function useRoutes() {
|
|
38
|
+
const shellRoutes = useShellRoutes();
|
|
39
|
+
const piletRoutes = usePiletRoutes();
|
|
40
|
+
return useRouteFilter([...shellRoutes, ...piletRoutes]);
|
|
26
41
|
}
|
|
27
42
|
|
|
28
43
|
/**
|
package/src/types/api.ts
CHANGED
|
@@ -11,7 +11,7 @@ import type {
|
|
|
11
11
|
PiletLoadingStrategy,
|
|
12
12
|
} from 'piral-base';
|
|
13
13
|
import type {} from 'piral-debug-utils';
|
|
14
|
-
import type { PiletCustomApi
|
|
14
|
+
import type { PiletCustomApi } from './custom';
|
|
15
15
|
import type { AnyComponent, PiralPageMeta } from './components';
|
|
16
16
|
import type { ExtensionParams, ExtensionSlotProps, PiralExtensionSlotMap } from './extension';
|
|
17
17
|
import type { SharedData, DataStoreOptions } from './data';
|
package/src/types/state.ts
CHANGED
|
@@ -182,7 +182,14 @@ export interface GlobalState extends PiralCustomState {
|
|
|
182
182
|
/**
|
|
183
183
|
* The used (exact) application routes.
|
|
184
184
|
*/
|
|
185
|
-
routes: Dict<
|
|
185
|
+
routes: Dict<
|
|
186
|
+
ComponentType<RouteComponentProps<any>> & {
|
|
187
|
+
/**
|
|
188
|
+
* The optional meta data registered with the page.
|
|
189
|
+
*/
|
|
190
|
+
meta?: PiralPageMeta;
|
|
191
|
+
}
|
|
192
|
+
>;
|
|
186
193
|
/**
|
|
187
194
|
* The current provider.
|
|
188
195
|
*/
|