piral-core 0.15.0-alpha.3740 → 0.15.0-alpha.3809
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/debug.codegen +1 -1
- package/debug.codegen.d.ts +5 -1
- package/esm/actions/app.d.ts +3 -3
- package/esm/actions/app.js +8 -10
- package/esm/actions/app.js.map +1 -1
- package/esm/components/DefaultRouteSwitch.d.ts +3 -0
- package/esm/components/DefaultRouteSwitch.js +10 -0
- package/esm/components/DefaultRouteSwitch.js.map +1 -0
- package/esm/components/PiralRoutes.d.ts +5 -0
- package/esm/components/PiralRoutes.js +5 -6
- package/esm/components/PiralRoutes.js.map +1 -1
- package/esm/components/PiralView.js +2 -2
- package/esm/components/PiralView.js.map +1 -1
- package/esm/components/components.d.ts +6 -1
- package/esm/components/components.js +6 -0
- package/esm/components/components.js.map +1 -1
- package/esm/components/index.d.ts +1 -0
- package/esm/components/index.js +1 -0
- package/esm/components/index.js.map +1 -1
- package/esm/emulator.js +6 -2
- package/esm/emulator.js.map +1 -1
- package/esm/state/createGlobalState.js +2 -1
- package/esm/state/createGlobalState.js.map +1 -1
- package/esm/types/components.d.ts +23 -1
- package/esm/types/state.d.ts +10 -4
- package/lib/actions/app.d.ts +3 -3
- package/lib/actions/app.js +7 -9
- package/lib/actions/app.js.map +1 -1
- package/lib/components/DefaultRouteSwitch.d.ts +3 -0
- package/lib/components/DefaultRouteSwitch.js +14 -0
- package/lib/components/DefaultRouteSwitch.js.map +1 -0
- package/lib/components/PiralRoutes.d.ts +5 -0
- package/lib/components/PiralRoutes.js +5 -6
- package/lib/components/PiralRoutes.js.map +1 -1
- package/lib/components/PiralView.js +2 -2
- package/lib/components/PiralView.js.map +1 -1
- package/lib/components/components.d.ts +6 -1
- package/lib/components/components.js +7 -1
- package/lib/components/components.js.map +1 -1
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +1 -0
- package/lib/components/index.js.map +1 -1
- package/lib/emulator.js +5 -1
- package/lib/emulator.js.map +1 -1
- package/lib/state/createGlobalState.js +1 -0
- package/lib/state/createGlobalState.js.map +1 -1
- package/lib/types/components.d.ts +23 -1
- package/lib/types/state.d.ts +10 -4
- package/package.json +4 -4
- package/src/actions/app.ts +13 -12
- package/src/components/DefaultRouteSwitch.tsx +14 -0
- package/src/components/PiralRoutes.test.tsx +7 -6
- package/src/components/PiralRoutes.tsx +12 -13
- package/src/components/PiralView.tsx +9 -2
- package/src/components/components.tsx +15 -1
- package/src/components/index.ts +1 -0
- package/src/emulator.ts +13 -2
- package/src/state/createGlobalState.test.ts +15 -1
- package/src/state/createGlobalState.ts +8 -1
- package/src/types/components.ts +24 -1
- package/src/types/state.ts +10 -3
package/debug.codegen
CHANGED
|
@@ -12,7 +12,7 @@ module.exports = function () {
|
|
|
12
12
|
|
|
13
13
|
// if we build the emulator version of piral (shipped to pilets)
|
|
14
14
|
if (process.env.DEBUG_PILET) {
|
|
15
|
-
imports.push('import { integrateEmulator } from "./esm/
|
|
15
|
+
imports.push('import { integrateEmulator } from "./esm/emulator"');
|
|
16
16
|
exports.push(`export { integrateEmulator }`);
|
|
17
17
|
} else {
|
|
18
18
|
exports.push(`export function integrateEmulator() {}`);
|
package/debug.codegen.d.ts
CHANGED
|
@@ -8,4 +8,8 @@ export function integrateDebugger(
|
|
|
8
8
|
debug?: DebuggerExtensionOptions,
|
|
9
9
|
): void;
|
|
10
10
|
|
|
11
|
-
export function integrateEmulator(
|
|
11
|
+
export function integrateEmulator(
|
|
12
|
+
context: GlobalStateContext,
|
|
13
|
+
options: LoadPiletsOptions,
|
|
14
|
+
debug?: DebuggerExtensionOptions,
|
|
15
|
+
): void;
|
package/esm/actions/app.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { RouteComponentProps } from 'react-router';
|
|
|
3
3
|
import { LayoutType, ComponentsState, ErrorComponentsState, GlobalStateContext, Pilet, PiletEntry } from '../types';
|
|
4
4
|
export declare function changeLayout(ctx: GlobalStateContext, current: LayoutType): void;
|
|
5
5
|
export declare function initialize(ctx: GlobalStateContext, loading: boolean, error: Error | undefined, modules: Array<Pilet>): void;
|
|
6
|
-
export declare function addPilet(ctx: GlobalStateContext, meta: PiletEntry): void
|
|
7
|
-
export declare function removePilet(ctx: GlobalStateContext, name: string): void
|
|
8
|
-
export declare function injectPilet(ctx: GlobalStateContext, pilet: Pilet):
|
|
6
|
+
export declare function addPilet(ctx: GlobalStateContext, meta: PiletEntry): Promise<void>;
|
|
7
|
+
export declare function removePilet(ctx: GlobalStateContext, name: string): Promise<void>;
|
|
8
|
+
export declare function injectPilet(ctx: GlobalStateContext, pilet: Pilet): Pilet;
|
|
9
9
|
export declare function setComponent<TKey extends keyof ComponentsState>(ctx: GlobalStateContext, name: TKey, component: ComponentsState[TKey]): void;
|
|
10
10
|
export declare function setErrorComponent<TKey extends keyof ErrorComponentsState>(ctx: GlobalStateContext, type: TKey, component: ErrorComponentsState[TKey]): void;
|
|
11
11
|
export declare function setRoute<T = {}>(ctx: GlobalStateContext, path: string, component: ComponentType<RouteComponentProps<T>>): void;
|
package/esm/actions/app.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { runPilet } from 'piral-base';
|
|
2
|
-
import { withKey, replaceOrAddItem, removeNested, withProvider, withRoute } from '../utils';
|
|
2
|
+
import { withKey, replaceOrAddItem, removeNested, withProvider, withRoute, noop } from '../utils';
|
|
3
3
|
export function changeLayout(ctx, current) {
|
|
4
4
|
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { app: withKey(state.app, 'layout', current) })));
|
|
5
5
|
}
|
|
@@ -8,27 +8,25 @@ export function initialize(ctx, loading, error, modules) {
|
|
|
8
8
|
loading }), modules })));
|
|
9
9
|
}
|
|
10
10
|
export function addPilet(ctx, meta) {
|
|
11
|
-
ctx.options
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
catch (error) {
|
|
17
|
-
console.error(error);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
11
|
+
return ctx.options
|
|
12
|
+
.loadPilet(meta)
|
|
13
|
+
.then((pilet) => ctx.injectPilet(pilet))
|
|
14
|
+
.then((pilet) => runPilet(ctx.options.createApi, pilet, ctx.options.hooks))
|
|
15
|
+
.then(noop);
|
|
20
16
|
}
|
|
21
17
|
export function removePilet(ctx, name) {
|
|
22
18
|
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { modules: state.modules.filter((m) => m.name !== name), registry: removeNested(state.registry, (m) => m.pilet === name) })));
|
|
23
19
|
ctx.emit('unload-pilet', {
|
|
24
20
|
name,
|
|
25
21
|
});
|
|
22
|
+
return Promise.resolve();
|
|
26
23
|
}
|
|
27
24
|
export function injectPilet(ctx, pilet) {
|
|
28
25
|
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { modules: replaceOrAddItem(state.modules, pilet, (m) => m.name === pilet.name), registry: removeNested(state.registry, (m) => m.pilet === pilet.name) })));
|
|
29
26
|
ctx.emit('unload-pilet', {
|
|
30
27
|
name: pilet.name,
|
|
31
28
|
});
|
|
29
|
+
return pilet;
|
|
32
30
|
}
|
|
33
31
|
export function setComponent(ctx, name, component) {
|
|
34
32
|
ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { components: withKey(state.components, name, component) })));
|
package/esm/actions/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/actions/app.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/actions/app.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,YAAY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CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,QAAQ,CACtB,GAAuB,EACvB,IAAY,EACZ,SAAgD;IAEhD,GAAG,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,GAAuB,EAAE,QAAqB;IAC5E,GAAG,CAAC,QAAQ,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { __rest } from "tslib";
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import { Switch, Route } from 'react-router';
|
|
4
|
+
export const DefaultRouteSwitch = (_a) => {
|
|
5
|
+
var { paths, NotFound } = _a, props = __rest(_a, ["paths", "NotFound"]);
|
|
6
|
+
return (React.createElement(Switch, Object.assign({}, props),
|
|
7
|
+
paths.map(({ path, Component }) => (React.createElement(Route, { exact: true, key: path, path: path, component: Component }))),
|
|
8
|
+
React.createElement(Route, { component: NotFound })));
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=DefaultRouteSwitch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultRouteSwitch.js","sourceRoot":"","sources":["../../src/components/DefaultRouteSwitch.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAG7C,MAAM,CAAC,MAAM,kBAAkB,GAA+B,CAAC,EAA6B,EAAE,EAAE;QAAjC,EAAE,KAAK,EAAE,QAAQ,OAAY,EAAP,KAAK,cAA3B,qBAA6B,CAAF;IACxF,OAAO,CACL,oBAAC,MAAM,oBAAK,KAAK;QACd,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAClC,oBAAC,KAAK,IAAC,KAAK,QAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,GAAI,CAC7D,CAAC;QACF,oBAAC,KAAK,IAAC,SAAS,EAAE,QAAQ,GAAI,CACvB,CACV,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { RouteComponentProps, SwitchProps } from 'react-router';
|
|
3
|
+
import { RouteSwitchProps } from '../types';
|
|
3
4
|
/**
|
|
4
5
|
* The props used by the PiralRoutes component.
|
|
5
6
|
*/
|
|
@@ -8,6 +9,10 @@ export interface RoutesProps extends SwitchProps {
|
|
|
8
9
|
* Sets the component for showing the not found page.
|
|
9
10
|
*/
|
|
10
11
|
NotFound: React.ComponentType<RouteComponentProps>;
|
|
12
|
+
/**
|
|
13
|
+
* Sets the component for actually switching the routes.
|
|
14
|
+
*/
|
|
15
|
+
RouteSwitch: React.ComponentType<RouteSwitchProps>;
|
|
11
16
|
}
|
|
12
17
|
/**
|
|
13
18
|
* The component for defining the exclusive routes to be used.
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { __rest } from "tslib";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { Route, Switch } from 'react-router';
|
|
4
3
|
import { useGlobalState } from '../hooks';
|
|
5
4
|
/**
|
|
6
5
|
* The component for defining the exclusive routes to be used.
|
|
7
6
|
*/
|
|
8
7
|
export const PiralRoutes = (_a) => {
|
|
9
|
-
var { NotFound } = _a, props = __rest(_a, ["NotFound"]);
|
|
8
|
+
var { NotFound, RouteSwitch } = _a, props = __rest(_a, ["NotFound", "RouteSwitch"]);
|
|
10
9
|
const routes = useGlobalState((s) => s.routes);
|
|
11
10
|
const pages = useGlobalState((s) => s.registry.pages);
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
const paths = [];
|
|
12
|
+
Object.keys(routes).map((path) => paths.push({ path, Component: routes[path] }));
|
|
13
|
+
Object.keys(pages).map((path) => paths.push({ path, Component: pages[path].component }));
|
|
14
|
+
return React.createElement(RouteSwitch, Object.assign({ NotFound: NotFound, paths: paths }, props));
|
|
16
15
|
};
|
|
17
16
|
PiralRoutes.displayName = 'Routes';
|
|
18
17
|
//# sourceMappingURL=PiralRoutes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PiralRoutes.js","sourceRoot":"","sources":["../../src/components/PiralRoutes.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,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;AAiB1C;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAA0B,CAAC,EAAmC,EAAE,EAAE;QAAvC,EAAE,QAAQ,EAAE,WAAW,OAAY,EAAP,KAAK,cAAjC,2BAAmC,CAAF;IAClF,MAAM,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,KAAK,GAAG,EAAE,CAAC;IAEjB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACjF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAEzF,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"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { StaticRouter } from 'react-router';
|
|
3
|
-
import { PiralError, PiralRouter, PiralLoadingIndicator, PiralLayout, PiralDebug } from './components';
|
|
4
3
|
import { PiralRoutes } from './PiralRoutes';
|
|
4
|
+
import { PiralError, PiralRouter, PiralLoadingIndicator, PiralRouteSwitch, PiralLayout, PiralDebug, } from './components';
|
|
5
5
|
import { useGlobalState } from '../hooks';
|
|
6
6
|
const NotFound = (props) => React.createElement(PiralError, Object.assign({ type: "not_found" }, props));
|
|
7
7
|
const PiralContent = () => {
|
|
8
8
|
const { error, loading, layout } = useGlobalState((m) => m.app);
|
|
9
9
|
return error ? (React.createElement(PiralError, { type: "loading", error: error })) : loading ? (React.createElement(PiralLoadingIndicator, null)) : (React.createElement(PiralLayout, { currentLayout: layout },
|
|
10
|
-
React.createElement(PiralRoutes, { NotFound: NotFound })));
|
|
10
|
+
React.createElement(PiralRoutes, { NotFound: NotFound, RouteSwitch: PiralRouteSwitch })));
|
|
11
11
|
};
|
|
12
12
|
const FallbackRouter = (props) => {
|
|
13
13
|
const publicPath = useGlobalState((s) => s.app.publicPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PiralView.js","sourceRoot":"","sources":["../../src/components/PiralView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAuB,YAAY,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,
|
|
1
|
+
{"version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K,KAAK,IAAE,QAAQ,EAAE,UAAU,IAAI,CAAC;AACxE,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,WAAW,CAAC;AAE5E,MAAM,aAAa,GAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC/C,MAAM,QAAQ,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC;IACrE,OAAO,KAAK,CAAC,aAAa,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAC5D,CAAC,CAAC;AAOF;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAA6B,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CACnE,oBAAC,aAAa;IACZ,oBAAC,MAAM;QACL,oBAAC,YAAY,OAAG;QACf,QAAQ;QACT,oBAAC,UAAU,OAAG,CACP,CACK,CACjB,CAAC;AACF,SAAS,CAAC,WAAW,GAAG,WAAW,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { ComponentsState, ErrorInfoProps, LoadingIndicatorProps, RouterProps, LayoutProps } from '../types';
|
|
2
|
+
import { ComponentsState, ErrorInfoProps, LoadingIndicatorProps, RouterProps, LayoutProps, RouteSwitchProps } from '../types';
|
|
3
3
|
export declare function getPiralComponent<TKey extends keyof ComponentsState>(name: TKey): ComponentsState[TKey];
|
|
4
4
|
/**
|
|
5
5
|
* Gets the currently registered ErrorInfo component.
|
|
@@ -16,6 +16,11 @@ export declare const PiralLoadingIndicator: React.ComponentType<LoadingIndicator
|
|
|
16
16
|
* By default the BrowserRouter is used.
|
|
17
17
|
*/
|
|
18
18
|
export declare const PiralRouter: React.ComponentType<RouterProps>;
|
|
19
|
+
/**
|
|
20
|
+
* Gets the currently registered Route Switch component.
|
|
21
|
+
* By default the DefaultRouteSwitch component is used.
|
|
22
|
+
*/
|
|
23
|
+
export declare const PiralRouteSwitch: React.ComponentType<RouteSwitchProps>;
|
|
19
24
|
/**
|
|
20
25
|
* Gets the currently registered Layout component.
|
|
21
26
|
* By default the children are rendered.
|
|
@@ -3,6 +3,7 @@ import { useGlobalState } from '../hooks';
|
|
|
3
3
|
export function getPiralComponent(name) {
|
|
4
4
|
return (props) => {
|
|
5
5
|
const Component = useGlobalState((s) => s.components[name]);
|
|
6
|
+
// tslint:disable-next-line:no-null-keyword
|
|
6
7
|
return Component ? React.createElement(Component, Object.assign({}, props)) : null;
|
|
7
8
|
};
|
|
8
9
|
}
|
|
@@ -21,6 +22,11 @@ export const PiralLoadingIndicator = getPiralComponent('LoadingIndicator');
|
|
|
21
22
|
* By default the BrowserRouter is used.
|
|
22
23
|
*/
|
|
23
24
|
export const PiralRouter = getPiralComponent('Router');
|
|
25
|
+
/**
|
|
26
|
+
* Gets the currently registered Route Switch component.
|
|
27
|
+
* By default the DefaultRouteSwitch component is used.
|
|
28
|
+
*/
|
|
29
|
+
export const PiralRouteSwitch = getPiralComponent('RouteSwitch');
|
|
24
30
|
/**
|
|
25
31
|
* Gets the currently registered Layout component.
|
|
26
32
|
* By default the children are rendered.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/components/components.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/components/components.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAU1C,MAAM,UAAU,iBAAiB,CAAqC,IAAU;IAC9E,OAAO,CAAC,KAAK,EAAE,EAAE;QACf,MAAM,SAAS,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5D,2CAA2C;QAC3C,OAAO,SAAS,CAAC,CAAC,CAAC,oBAAC,SAAS,oBAAK,KAAK,EAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACrD,CAAC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAwC,iBAAiB,CAAC,WAAW,CAAC,CAAC;AAE9F;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA+C,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;AAEvH;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAqC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAEzF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA0C,iBAAiB,CAAC,aAAa,CAAC,CAAC;AAExG;;;GAGG;AACH,MAAM,CAAC,MAAM,WAAW,GAAqC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAEzF;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAwB,iBAAiB,CAAC,OAAO,CAAC,CAAC"}
|
|
@@ -3,6 +3,7 @@ export * from './DefaultErrorInfo';
|
|
|
3
3
|
export * from './DefaultLayout';
|
|
4
4
|
export * from './DefaultLoader';
|
|
5
5
|
export * from './DefaultRouter';
|
|
6
|
+
export * from './DefaultRouteSwitch';
|
|
6
7
|
export * from './ErrorBoundary';
|
|
7
8
|
export * from './ExtensionSlot';
|
|
8
9
|
export * from './Mediator';
|
package/esm/components/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export * from './DefaultErrorInfo';
|
|
|
3
3
|
export * from './DefaultLayout';
|
|
4
4
|
export * from './DefaultLoader';
|
|
5
5
|
export * from './DefaultRouter';
|
|
6
|
+
export * from './DefaultRouteSwitch';
|
|
6
7
|
export * from './ErrorBoundary';
|
|
7
8
|
export * from './ExtensionSlot';
|
|
8
9
|
export * from './Mediator';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC"}
|
package/esm/emulator.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { installPiletEmulator } from 'piral-debug-utils';
|
|
2
2
|
export function integrateEmulator(context, options) {
|
|
3
|
-
|
|
3
|
+
installPiletEmulator(options.fetchPilets, {
|
|
4
4
|
addPilet: context.addPilet,
|
|
5
5
|
removePilet: context.removePilet,
|
|
6
|
+
integrate(emulator) {
|
|
7
|
+
context.dispatch((s) => (Object.assign(Object.assign({}, s), { components: Object.assign(Object.assign({}, s.components), emulator.components) })));
|
|
8
|
+
options.fetchPilets = emulator.requester;
|
|
9
|
+
},
|
|
6
10
|
});
|
|
7
11
|
}
|
|
8
12
|
//# sourceMappingURL=emulator.js.map
|
package/esm/emulator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emulator.js","sourceRoot":"","sources":["../src/emulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"emulator.js","sourceRoot":"","sources":["../src/emulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAGzD,MAAM,UAAU,iBAAiB,CAAC,OAA2B,EAAE,OAA0B;IACvF,oBAAoB,CAAC,OAAO,CAAC,WAAW,EAAE;QACxC,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,SAAS,CAAC,QAAQ;YAChB,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,iCACnB,CAAC,KACJ,UAAU,kCACL,CAAC,CAAC,UAAU,GACZ,QAAQ,CAAC,UAAU,KAExB,CAAC,CAAC;YAEJ,OAAO,CAAC,WAAW,GAAG,QAAQ,CAAC,SAAS,CAAC;QAC3C,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Atom } from '@dbeining/react-atom';
|
|
2
|
-
import { DefaultErrorInfo, DefaultLoadingIndicator, DefaultLayout, DefaultRouter } from '../components';
|
|
2
|
+
import { DefaultErrorInfo, DefaultLoadingIndicator, DefaultLayout, DefaultRouter, DefaultRouteSwitch, } from '../components';
|
|
3
3
|
function extend(defaultState, customState) {
|
|
4
4
|
for (const key of Object.keys(customState)) {
|
|
5
5
|
if (key === '__proto__' || key === 'constructor') {
|
|
@@ -24,6 +24,7 @@ export function createGlobalState(customState = {}) {
|
|
|
24
24
|
ErrorInfo: DefaultErrorInfo,
|
|
25
25
|
LoadingIndicator: DefaultLoadingIndicator,
|
|
26
26
|
Router: DefaultRouter,
|
|
27
|
+
RouteSwitch: DefaultRouteSwitch,
|
|
27
28
|
Layout: DefaultLayout,
|
|
28
29
|
},
|
|
29
30
|
errorComponents: {},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGlobalState.js","sourceRoot":"","sources":["../../src/state/createGlobalState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,
|
|
1
|
+
{"version":3,"file":"createGlobalState.js","sourceRoot":"","sources":["../../src/state/createGlobalState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,aAAa,EACb,aAAa,EACb,kBAAkB,GACnB,MAAM,eAAe,CAAC;AAGvB,SAAS,MAAM,CAAI,YAAe,EAAE,WAA6B;IAC/D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;QAC1C,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,aAAa,EAAE;YAChD,SAAS;SACV;QAED,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,MAAM,GAAG,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;QACzE,YAAY,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;KAC9D;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,cAA0C,EAAE;IAC5E,MAAM,YAAY,GAAgB;QAChC,GAAG,EAAE;YACH,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,OAAO,MAAM,KAAK,WAAW;YACtC,MAAM,EAAE,SAAS;YACjB,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,GAAG;SACjD;QACD,UAAU,EAAE;YACV,SAAS,EAAE,gBAAgB;YAC3B,gBAAgB,EAAE,uBAAuB;YACzC,MAAM,EAAE,aAAa;YACrB,WAAW,EAAE,kBAAkB;YAC/B,MAAM,EAAE,aAAa;SACtB;QACD,eAAe,EAAE,EAAE;QACnB,QAAQ,EAAE;YACR,UAAU,EAAE,EAAE;YACd,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,EAAE;SACb;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,EAAE;KACZ,CAAC;IAEF,OAAO,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ComponentType } from 'react';
|
|
2
|
-
import type { RouteComponentProps } from 'react-router';
|
|
2
|
+
import type { RouteComponentProps, SwitchProps } from 'react-router';
|
|
3
3
|
import type { FirstParametersOf, UnionOf } from './common';
|
|
4
4
|
import type { PiralCustomErrors, PiralCustomComponentConverters } from './custom';
|
|
5
5
|
import type { LayoutType } from './layout';
|
|
@@ -181,3 +181,25 @@ export interface LayoutProps {
|
|
|
181
181
|
*/
|
|
182
182
|
export interface RouterProps {
|
|
183
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* The props of the RouteSwitch component.
|
|
186
|
+
*/
|
|
187
|
+
export interface RouteSwitchProps extends SwitchProps {
|
|
188
|
+
/**
|
|
189
|
+
* The component that should be used in case nothing was found.
|
|
190
|
+
*/
|
|
191
|
+
NotFound: ComponentType<RouteComponentProps>;
|
|
192
|
+
/**
|
|
193
|
+
* The component to register for the different paths.
|
|
194
|
+
*/
|
|
195
|
+
paths: Array<{
|
|
196
|
+
/**
|
|
197
|
+
* The exact path to use.
|
|
198
|
+
*/
|
|
199
|
+
path: string;
|
|
200
|
+
/**
|
|
201
|
+
* The component to register for this path.
|
|
202
|
+
*/
|
|
203
|
+
Component: ComponentType<RouteComponentProps>;
|
|
204
|
+
}>;
|
|
205
|
+
}
|
package/esm/types/state.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { LayoutType } from './layout';
|
|
|
7
7
|
import type { SharedDataItem, DataStoreTarget } from './data';
|
|
8
8
|
import type { PiralCustomActions, PiralCustomState, PiralCustomRegistryState, PiralCustomComponentsState } from './custom';
|
|
9
9
|
import type { EventEmitter, Pilet, BaseComponentProps, PageComponentProps, ExtensionComponentProps, PiletsBag, PiralPageMeta, PiletEntry } from './api';
|
|
10
|
-
import type { ComponentConverters, LoadingIndicatorProps, ErrorInfoProps, RouterProps, LayoutProps, Errors } from './components';
|
|
10
|
+
import type { ComponentConverters, LoadingIndicatorProps, ErrorInfoProps, RouterProps, LayoutProps, Errors, RouteSwitchProps } from './components';
|
|
11
11
|
export interface StateDispatcher<TState> {
|
|
12
12
|
(state: TState): Partial<TState>;
|
|
13
13
|
}
|
|
@@ -59,6 +59,10 @@ export interface ComponentsState extends PiralCustomComponentsState {
|
|
|
59
59
|
* The layout used for pages.
|
|
60
60
|
*/
|
|
61
61
|
Layout: ComponentType<LayoutProps>;
|
|
62
|
+
/**
|
|
63
|
+
* The route switch used for determining the route registration.
|
|
64
|
+
*/
|
|
65
|
+
RouteSwitch: ComponentType<RouteSwitchProps>;
|
|
62
66
|
/**
|
|
63
67
|
* A component that can be used for debugging purposes.
|
|
64
68
|
*/
|
|
@@ -174,18 +178,20 @@ export interface PiralActions extends PiralCustomActions {
|
|
|
174
178
|
/**
|
|
175
179
|
* Injects an evaluated pilet at runtime - removes the pilet from registry first if available.
|
|
176
180
|
* @param pilet The pilet to be injected.
|
|
181
|
+
* @returns The injected pilet.
|
|
177
182
|
*/
|
|
178
|
-
injectPilet(pilet: Pilet):
|
|
183
|
+
injectPilet(pilet: Pilet): Pilet;
|
|
179
184
|
/**
|
|
180
185
|
* Adds a pilet at runtime by loading it, evaluating it, and then injecting it.
|
|
181
186
|
* @param pilet The pilet to be added.
|
|
187
|
+
* @returns The promise indicating when the pilet was fully added.
|
|
182
188
|
*/
|
|
183
|
-
addPilet(pilet: PiletEntry): void
|
|
189
|
+
addPilet(pilet: PiletEntry): Promise<void>;
|
|
184
190
|
/**
|
|
185
191
|
* Removes a pilet by unloading it and deleting all component registrations.
|
|
186
192
|
* @param name The name of the pilet to remove.
|
|
187
193
|
*/
|
|
188
|
-
removePilet(name: string): void
|
|
194
|
+
removePilet(name: string): Promise<void>;
|
|
189
195
|
/**
|
|
190
196
|
* Defines a single action for Piral.
|
|
191
197
|
* @param actionName The name of the action to define.
|
package/lib/actions/app.d.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { RouteComponentProps } from 'react-router';
|
|
|
3
3
|
import { LayoutType, ComponentsState, ErrorComponentsState, GlobalStateContext, Pilet, PiletEntry } from '../types';
|
|
4
4
|
export declare function changeLayout(ctx: GlobalStateContext, current: LayoutType): void;
|
|
5
5
|
export declare function initialize(ctx: GlobalStateContext, loading: boolean, error: Error | undefined, modules: Array<Pilet>): void;
|
|
6
|
-
export declare function addPilet(ctx: GlobalStateContext, meta: PiletEntry): void
|
|
7
|
-
export declare function removePilet(ctx: GlobalStateContext, name: string): void
|
|
8
|
-
export declare function injectPilet(ctx: GlobalStateContext, pilet: Pilet):
|
|
6
|
+
export declare function addPilet(ctx: GlobalStateContext, meta: PiletEntry): Promise<void>;
|
|
7
|
+
export declare function removePilet(ctx: GlobalStateContext, name: string): Promise<void>;
|
|
8
|
+
export declare function injectPilet(ctx: GlobalStateContext, pilet: Pilet): Pilet;
|
|
9
9
|
export declare function setComponent<TKey extends keyof ComponentsState>(ctx: GlobalStateContext, name: TKey, component: ComponentsState[TKey]): void;
|
|
10
10
|
export declare function setErrorComponent<TKey extends keyof ErrorComponentsState>(ctx: GlobalStateContext, type: TKey, component: ErrorComponentsState[TKey]): void;
|
|
11
11
|
export declare function setRoute<T = {}>(ctx: GlobalStateContext, path: string, component: ComponentType<RouteComponentProps<T>>): void;
|
package/lib/actions/app.js
CHANGED
|
@@ -13,15 +13,11 @@ function initialize(ctx, loading, error, modules) {
|
|
|
13
13
|
}
|
|
14
14
|
exports.initialize = initialize;
|
|
15
15
|
function addPilet(ctx, meta) {
|
|
16
|
-
ctx.options
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
catch (error) {
|
|
22
|
-
console.error(error);
|
|
23
|
-
}
|
|
24
|
-
});
|
|
16
|
+
return ctx.options
|
|
17
|
+
.loadPilet(meta)
|
|
18
|
+
.then((pilet) => ctx.injectPilet(pilet))
|
|
19
|
+
.then((pilet) => (0, piral_base_1.runPilet)(ctx.options.createApi, pilet, ctx.options.hooks))
|
|
20
|
+
.then(utils_1.noop);
|
|
25
21
|
}
|
|
26
22
|
exports.addPilet = addPilet;
|
|
27
23
|
function removePilet(ctx, name) {
|
|
@@ -29,6 +25,7 @@ function removePilet(ctx, name) {
|
|
|
29
25
|
ctx.emit('unload-pilet', {
|
|
30
26
|
name,
|
|
31
27
|
});
|
|
28
|
+
return Promise.resolve();
|
|
32
29
|
}
|
|
33
30
|
exports.removePilet = removePilet;
|
|
34
31
|
function injectPilet(ctx, pilet) {
|
|
@@ -36,6 +33,7 @@ function injectPilet(ctx, pilet) {
|
|
|
36
33
|
ctx.emit('unload-pilet', {
|
|
37
34
|
name: pilet.name,
|
|
38
35
|
});
|
|
36
|
+
return pilet;
|
|
39
37
|
}
|
|
40
38
|
exports.injectPilet = injectPilet;
|
|
41
39
|
function setComponent(ctx, name, component) {
|
package/lib/actions/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/actions/app.ts"],"names":[],"mappings":";;;AAEA,2CAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/actions/app.ts"],"names":[],"mappings":";;;AAEA,2CAAsC;AACtC,oCAAkG;AAYlG,SAAgB,YAAY,CAAC,GAAuB,EAAE,OAAmB;IACvE,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,GAAG,EAAE,IAAA,eAAO,EAAC,KAAK,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,IAC1C,CAAC,CAAC;AACN,CAAC;AALD,oCAKC;AAED,SAAgB,UAAU,CAAC,GAAuB,EAAE,OAAgB,EAAE,KAAwB,EAAE,OAAqB;IACnH,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,GAAG,kCACE,KAAK,CAAC,GAAG,KACZ,KAAK;YACL,OAAO,KAET,OAAO,IACP,CAAC,CAAC;AACN,CAAC;AAVD,gCAUC;AAED,SAAgB,QAAQ,CAAC,GAAuB,EAAE,IAAgB;IAChE,OAAO,GAAG,CAAC,OAAO;SACf,SAAS,CAAC,IAAI,CAAC;SACf,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,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AAc,EAAE;QACvB,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACf,CAAC;AAZD,kCAYC;AAED,SAAgB,YAAY,CAC1B,GAAuB,EACvB,IAAU,EACV,SAAgC;IAEhC,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,UAAU,EAAE,IAAA,eAAO,EAAC,KAAK,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,IACtD,CAAC,CAAC;AACN,CAAC;AATD,oCASC;AAED,SAAgB,iBAAiB,CAC/B,GAAuB,EACvB,IAAU,EACV,SAAqC;IAErC,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,eAAe,EAAE,IAAA,eAAO,EAAC,KAAK,CAAC,eAAe,EAAE,IAAI,EAAE,SAAS,CAAC,IAChE,CAAC,CAAC;AACN,CAAC;AATD,8CASC;AAED,SAAgB,QAAQ,CACtB,GAAuB,EACvB,IAAY,EACZ,SAAgD;IAEhD,GAAG,CAAC,QAAQ,CAAC,IAAA,iBAAS,EAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;AAC3C,CAAC;AAND,4BAMC;AAED,SAAgB,eAAe,CAAC,GAAuB,EAAE,QAAqB;IAC5E,GAAG,CAAC,QAAQ,CAAC,IAAA,oBAAY,EAAC,QAAQ,CAAC,CAAC,CAAC;AACvC,CAAC;AAFD,0CAEC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultRouteSwitch = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const React = require("react");
|
|
6
|
+
const react_router_1 = require("react-router");
|
|
7
|
+
const DefaultRouteSwitch = (_a) => {
|
|
8
|
+
var { paths, NotFound } = _a, props = (0, tslib_1.__rest)(_a, ["paths", "NotFound"]);
|
|
9
|
+
return (React.createElement(react_router_1.Switch, Object.assign({}, props),
|
|
10
|
+
paths.map(({ path, Component }) => (React.createElement(react_router_1.Route, { exact: true, key: path, path: path, component: Component }))),
|
|
11
|
+
React.createElement(react_router_1.Route, { component: NotFound })));
|
|
12
|
+
};
|
|
13
|
+
exports.DefaultRouteSwitch = DefaultRouteSwitch;
|
|
14
|
+
//# sourceMappingURL=DefaultRouteSwitch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultRouteSwitch.js","sourceRoot":"","sources":["../../src/components/DefaultRouteSwitch.tsx"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAC/B,+CAA6C;AAGtC,MAAM,kBAAkB,GAA+B,CAAC,EAA6B,EAAE,EAAE;QAAjC,EAAE,KAAK,EAAE,QAAQ,OAAY,EAAP,KAAK,2BAA3B,qBAA6B,CAAF;IACxF,OAAO,CACL,oBAAC,qBAAM,oBAAK,KAAK;QACd,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAClC,oBAAC,oBAAK,IAAC,KAAK,QAAC,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,SAAS,GAAI,CAC7D,CAAC;QACF,oBAAC,oBAAK,IAAC,SAAS,EAAE,QAAQ,GAAI,CACvB,CACV,CAAC;AACJ,CAAC,CAAC;AATW,QAAA,kBAAkB,sBAS7B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { RouteComponentProps, SwitchProps } from 'react-router';
|
|
3
|
+
import { RouteSwitchProps } from '../types';
|
|
3
4
|
/**
|
|
4
5
|
* The props used by the PiralRoutes component.
|
|
5
6
|
*/
|
|
@@ -8,6 +9,10 @@ export interface RoutesProps extends SwitchProps {
|
|
|
8
9
|
* Sets the component for showing the not found page.
|
|
9
10
|
*/
|
|
10
11
|
NotFound: React.ComponentType<RouteComponentProps>;
|
|
12
|
+
/**
|
|
13
|
+
* Sets the component for actually switching the routes.
|
|
14
|
+
*/
|
|
15
|
+
RouteSwitch: React.ComponentType<RouteSwitchProps>;
|
|
11
16
|
}
|
|
12
17
|
/**
|
|
13
18
|
* The component for defining the exclusive routes to be used.
|
|
@@ -3,19 +3,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PiralRoutes = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const React = require("react");
|
|
6
|
-
const react_router_1 = require("react-router");
|
|
7
6
|
const hooks_1 = require("../hooks");
|
|
8
7
|
/**
|
|
9
8
|
* The component for defining the exclusive routes to be used.
|
|
10
9
|
*/
|
|
11
10
|
const PiralRoutes = (_a) => {
|
|
12
|
-
var { NotFound } = _a, props = (0, tslib_1.__rest)(_a, ["NotFound"]);
|
|
11
|
+
var { NotFound, RouteSwitch } = _a, props = (0, tslib_1.__rest)(_a, ["NotFound", "RouteSwitch"]);
|
|
13
12
|
const routes = (0, hooks_1.useGlobalState)((s) => s.routes);
|
|
14
13
|
const pages = (0, hooks_1.useGlobalState)((s) => s.registry.pages);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const paths = [];
|
|
15
|
+
Object.keys(routes).map((path) => paths.push({ path, Component: routes[path] }));
|
|
16
|
+
Object.keys(pages).map((path) => paths.push({ path, Component: pages[path].component }));
|
|
17
|
+
return React.createElement(RouteSwitch, Object.assign({ NotFound: NotFound, paths: paths }, props));
|
|
19
18
|
};
|
|
20
19
|
exports.PiralRoutes = PiralRoutes;
|
|
21
20
|
exports.PiralRoutes.displayName = 'Routes';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PiralRoutes.js","sourceRoot":"","sources":["../../src/components/PiralRoutes.tsx"],"names":[],"mappings":";;;;AAAA,+BAA+B;
|
|
1
|
+
{"version":3,"file":"PiralRoutes.js","sourceRoot":"","sources":["../../src/components/PiralRoutes.tsx"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAE/B,oCAA0C;AAiB1C;;GAEG;AACI,MAAM,WAAW,GAA0B,CAAC,EAAmC,EAAE,EAAE;QAAvC,EAAE,QAAQ,EAAE,WAAW,OAAY,EAAP,KAAK,2BAAjC,2BAAmC,CAAF;IAClF,MAAM,MAAM,GAAG,IAAA,sBAAc,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,IAAA,sBAAc,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,KAAK,GAAG,EAAE,CAAC;IAEjB,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACjF,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC;IAEzF,OAAO,oBAAC,WAAW,kBAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,IAAM,KAAK,EAAI,CAAC;AACtE,CAAC,CAAC;AATW,QAAA,WAAW,eAStB;AACF,mBAAW,CAAC,WAAW,GAAG,QAAQ,CAAC"}
|
|
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PiralView = void 0;
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const react_router_1 = require("react-router");
|
|
6
|
-
const components_1 = require("./components");
|
|
7
6
|
const PiralRoutes_1 = require("./PiralRoutes");
|
|
7
|
+
const components_1 = require("./components");
|
|
8
8
|
const hooks_1 = require("../hooks");
|
|
9
9
|
const NotFound = (props) => React.createElement(components_1.PiralError, Object.assign({ type: "not_found" }, props));
|
|
10
10
|
const PiralContent = () => {
|
|
11
11
|
const { error, loading, layout } = (0, hooks_1.useGlobalState)((m) => m.app);
|
|
12
12
|
return error ? (React.createElement(components_1.PiralError, { type: "loading", error: error })) : loading ? (React.createElement(components_1.PiralLoadingIndicator, null)) : (React.createElement(components_1.PiralLayout, { currentLayout: layout },
|
|
13
|
-
React.createElement(PiralRoutes_1.PiralRoutes, { NotFound: NotFound })));
|
|
13
|
+
React.createElement(PiralRoutes_1.PiralRoutes, { NotFound: NotFound, RouteSwitch: components_1.PiralRouteSwitch })));
|
|
14
14
|
};
|
|
15
15
|
const FallbackRouter = (props) => {
|
|
16
16
|
const publicPath = (0, hooks_1.useGlobalState)((s) => s.app.publicPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PiralView.js","sourceRoot":"","sources":["../../src/components/PiralView.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,+CAAiE;AACjE
|
|
1
|
+
{"version":3,"file":"PiralView.js","sourceRoot":"","sources":["../../src/components/PiralView.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,+CAAiE;AACjE,+CAA4C;AAC5C,6CAOsB;AACtB,oCAA0C;AAE1C,MAAM,QAAQ,GAAkC,CAAC,KAAK,EAAE,EAAE,CAAC,oBAAC,uBAAU,kBAAC,IAAI,EAAC,WAAW,IAAK,KAAK,EAAI,CAAC;AAEtG,MAAM,YAAY,GAAa,GAAG,EAAE;IAClC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAA,sBAAc,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEhE,OAAO,KAAK,CAAC,CAA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,QAAA,SAAS,aAQpB;AACF,iBAAS,CAAC,WAAW,GAAG,WAAW,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { ComponentsState, ErrorInfoProps, LoadingIndicatorProps, RouterProps, LayoutProps } from '../types';
|
|
2
|
+
import { ComponentsState, ErrorInfoProps, LoadingIndicatorProps, RouterProps, LayoutProps, RouteSwitchProps } from '../types';
|
|
3
3
|
export declare function getPiralComponent<TKey extends keyof ComponentsState>(name: TKey): ComponentsState[TKey];
|
|
4
4
|
/**
|
|
5
5
|
* Gets the currently registered ErrorInfo component.
|
|
@@ -16,6 +16,11 @@ export declare const PiralLoadingIndicator: React.ComponentType<LoadingIndicator
|
|
|
16
16
|
* By default the BrowserRouter is used.
|
|
17
17
|
*/
|
|
18
18
|
export declare const PiralRouter: React.ComponentType<RouterProps>;
|
|
19
|
+
/**
|
|
20
|
+
* Gets the currently registered Route Switch component.
|
|
21
|
+
* By default the DefaultRouteSwitch component is used.
|
|
22
|
+
*/
|
|
23
|
+
export declare const PiralRouteSwitch: React.ComponentType<RouteSwitchProps>;
|
|
19
24
|
/**
|
|
20
25
|
* Gets the currently registered Layout component.
|
|
21
26
|
* By default the children are rendered.
|