piral-core 0.14.13 → 0.14.14-beta.3765

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.
Files changed (48) hide show
  1. package/debug-pilet.js +17 -2
  2. package/esm/components/DefaultRouteSwitch.d.ts +3 -0
  3. package/esm/components/DefaultRouteSwitch.js +10 -0
  4. package/esm/components/DefaultRouteSwitch.js.map +1 -0
  5. package/esm/components/PiralRoutes.d.ts +5 -0
  6. package/esm/components/PiralRoutes.js +5 -6
  7. package/esm/components/PiralRoutes.js.map +1 -1
  8. package/esm/components/PiralView.js +2 -2
  9. package/esm/components/PiralView.js.map +1 -1
  10. package/esm/components/components.d.ts +6 -1
  11. package/esm/components/components.js +6 -0
  12. package/esm/components/components.js.map +1 -1
  13. package/esm/components/index.d.ts +1 -0
  14. package/esm/components/index.js +1 -0
  15. package/esm/components/index.js.map +1 -1
  16. package/esm/state/createGlobalState.js +2 -1
  17. package/esm/state/createGlobalState.js.map +1 -1
  18. package/esm/types/components.d.ts +23 -1
  19. package/esm/types/state.d.ts +5 -1
  20. package/lib/components/DefaultRouteSwitch.d.ts +3 -0
  21. package/lib/components/DefaultRouteSwitch.js +14 -0
  22. package/lib/components/DefaultRouteSwitch.js.map +1 -0
  23. package/lib/components/PiralRoutes.d.ts +5 -0
  24. package/lib/components/PiralRoutes.js +5 -6
  25. package/lib/components/PiralRoutes.js.map +1 -1
  26. package/lib/components/PiralView.js +2 -2
  27. package/lib/components/PiralView.js.map +1 -1
  28. package/lib/components/components.d.ts +6 -1
  29. package/lib/components/components.js +7 -1
  30. package/lib/components/components.js.map +1 -1
  31. package/lib/components/index.d.ts +1 -0
  32. package/lib/components/index.js +1 -0
  33. package/lib/components/index.js.map +1 -1
  34. package/lib/state/createGlobalState.js +1 -0
  35. package/lib/state/createGlobalState.js.map +1 -1
  36. package/lib/types/components.d.ts +23 -1
  37. package/lib/types/state.d.ts +5 -1
  38. package/package.json +5 -4
  39. package/src/components/DefaultRouteSwitch.tsx +14 -0
  40. package/src/components/PiralRoutes.test.tsx +7 -6
  41. package/src/components/PiralRoutes.tsx +12 -13
  42. package/src/components/PiralView.tsx +9 -2
  43. package/src/components/components.tsx +15 -1
  44. package/src/components/index.ts +1 -0
  45. package/src/state/createGlobalState.test.ts +15 -1
  46. package/src/state/createGlobalState.ts +8 -1
  47. package/src/types/components.ts +24 -1
  48. package/src/types/state.ts +5 -0
package/debug-pilet.js CHANGED
@@ -1,12 +1,27 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  exports.__esModule = true;
3
14
  exports.integrate = void 0;
4
15
  var piral_debug_utils_1 = require("piral-debug-utils");
5
16
  function integrate(context, options) {
6
- options.fetchPilets = (0, piral_debug_utils_1.withEmulatorPilets)(options.fetchPilets, {
17
+ (0, piral_debug_utils_1.installPiletsEmulator)(options.fetchPilets, {
7
18
  injectPilet: context.injectPilet,
8
19
  createApi: options.createApi,
9
- loadPilet: options.loadPilet
20
+ loadPilet: options.loadPilet,
21
+ integrate: function (emulator) {
22
+ context.dispatch(function (s) { return (__assign(__assign({}, s), { components: __assign(__assign({}, s.components), emulator.components) })); });
23
+ options.fetchPilets = emulator.requester;
24
+ }
10
25
  });
11
26
  }
12
27
  exports.integrate = integrate;
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import { RouteSwitchProps } from '../types';
3
+ export declare const DefaultRouteSwitch: React.FC<RouteSwitchProps>;
@@ -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
- return (React.createElement(Switch, Object.assign({}, props),
13
- Object.keys(routes).map((url) => (React.createElement(Route, { exact: true, key: url, path: url, component: routes[url] }))),
14
- Object.keys(pages).map((url) => (React.createElement(Route, { exact: true, key: url, path: url, component: pages[url].component }))),
15
- React.createElement(Route, { component: NotFound })));
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;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,EAAoC,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAY1C;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAA0B,CAAC,EAAsB,EAAE,EAAE;QAA1B,EAAE,QAAQ,OAAY,EAAP,KAAK,cAApB,YAAsB,CAAF;IACrE,MAAM,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,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C,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,UAAU,EAAE,WAAW,EAAE,qBAAqB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AACvG,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,QAAQ,GAAkC,CAAC,KAAK,EAAE,EAAE,CAAC,oBAAC,UAAU,kBAAC,IAAI,EAAC,WAAW,IAAK,KAAK,EAAI,CAAC;AAEtG,MAAM,YAAY,GAAa,GAAG,EAAE;IAClC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IAEhE,OAAO,KAAK,CAAC,CAAC,CAAC,CACb,oBAAC,UAAU,IAAC,IAAI,EAAC,SAAS,EAAC,KAAK,EAAE,KAAK,GAAI,CAC5C,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CACZ,oBAAC,qBAAqB,OAAG,CAC1B,CAAC,CAAC,CAAC,CACF,oBAAC,WAAW,IAAC,aAAa,EAAE,MAAM;QAChC,oBAAC,WAAW,IAAC,QAAQ,EAAE,QAAQ,GAAI,CACvB,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,cAAc,GAAa,CAAC,KAAK,EAAE,EAAE;IACzC,MAAM,UAAU,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;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OF;;;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;AAG1C,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,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,WAAW,GAAqC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAEzF;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAwB,iBAAiB,CAAC,OAAO,CAAC,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';
@@ -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"}
@@ -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,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGxG,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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M,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
+ }
@@ -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 { PiletMetadata, EventEmitter, Pilet, BaseComponentProps, PageComponentProps, ExtensionComponentProps, PiletsBag, PiralPageMeta } 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
  */
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import { RouteSwitchProps } from '../types';
3
+ export declare const DefaultRouteSwitch: React.FC<RouteSwitchProps>;
@@ -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
- return (React.createElement(react_router_1.Switch, Object.assign({}, props),
16
- Object.keys(routes).map((url) => (React.createElement(react_router_1.Route, { exact: true, key: url, path: url, component: routes[url] }))),
17
- Object.keys(pages).map((url) => (React.createElement(react_router_1.Route, { exact: true, key: url, path: url, component: pages[url].component }))),
18
- React.createElement(react_router_1.Route, { component: NotFound })));
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;AAC/B,+CAA+E;AAC/E,oCAA0C;AAY1C;;GAEG;AACI,MAAM,WAAW,GAA0B,CAAC,EAAsB,EAAE,EAAE;QAA1B,EAAE,QAAQ,OAAY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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,6CAAuG;AACvG,+CAA4C;AAC5C,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,CAAC,CAAC,CACb,oBAAC,uBAAU,IAAC,IAAI,EAAC,SAAS,EAAC,KAAK,EAAE,KAAK,GAAI,CAC5C,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CACZ,oBAAC,kCAAqB,OAAG,CAC1B,CAAC,CAAC,CAAC,CACF,oBAAC,wBAAW,IAAC,aAAa,EAAE,MAAM;QAChC,oBAAC,yBAAW,IAAC,QAAQ,EAAE,QAAQ,GAAI,CACvB,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,cAAc,GAAa,CAAC,KAAK,EAAE,EAAE;IACzC,MAAM,UAAU,GAAG,IAAA,sBAAc,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IAC3D,OAAO,oBAAC,2BAAY,kBAAC,QAAQ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AAA,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.
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PiralDebug = exports.PiralLayout = exports.PiralRouter = exports.PiralLoadingIndicator = exports.PiralError = exports.getPiralComponent = void 0;
3
+ exports.PiralDebug = exports.PiralLayout = exports.PiralRouteSwitch = exports.PiralRouter = exports.PiralLoadingIndicator = exports.PiralError = exports.getPiralComponent = void 0;
4
4
  const React = require("react");
5
5
  const hooks_1 = require("../hooks");
6
6
  function getPiralComponent(name) {
7
7
  return (props) => {
8
8
  const Component = (0, hooks_1.useGlobalState)((s) => s.components[name]);
9
+ // tslint:disable-next-line:no-null-keyword
9
10
  return Component ? React.createElement(Component, Object.assign({}, props)) : null;
10
11
  };
11
12
  }
@@ -25,6 +26,11 @@ exports.PiralLoadingIndicator = getPiralComponent('LoadingIndicator');
25
26
  * By default the BrowserRouter is used.
26
27
  */
27
28
  exports.PiralRouter = getPiralComponent('Router');
29
+ /**
30
+ * Gets the currently registered Route Switch component.
31
+ * By default the DefaultRouteSwitch component is used.
32
+ */
33
+ exports.PiralRouteSwitch = getPiralComponent('RouteSwitch');
28
34
  /**
29
35
  * Gets the currently registered Layout component.
30
36
  * By default the children are rendered.
@@ -1 +1 @@
1
- {"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/components/components.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,oCAA0C;AAG1C,SAAgB,iBAAiB,CAAqC,IAAU;IAC9E,OAAO,CAAC,KAAK,EAAE,EAAE;QACf,MAAM,SAAS,GAAG,IAAA,sBAAc,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5D,OAAO,SAAS,CAAC,CAAC,CAAC,oBAAC,SAAS,oBAAK,KAAK,EAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACrD,CAAC,CAAC;AACJ,CAAC;AALD,8CAKC;AAED;;;GAGG;AACU,QAAA,UAAU,GAAwC,iBAAiB,CAAC,WAAW,CAAC,CAAC;AAE9F;;;GAGG;AACU,QAAA,qBAAqB,GAA+C,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;AAEvH;;;GAGG;AACU,QAAA,WAAW,GAAqC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAEzF;;;GAGG;AACU,QAAA,WAAW,GAAqC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAEzF;;;GAGG;AACU,QAAA,UAAU,GAAwB,iBAAiB,CAAC,OAAO,CAAC,CAAC"}
1
+ {"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/components/components.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,oCAA0C;AAU1C,SAAgB,iBAAiB,CAAqC,IAAU;IAC9E,OAAO,CAAC,KAAK,EAAE,EAAE;QACf,MAAM,SAAS,GAAG,IAAA,sBAAc,EAAC,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;AAND,8CAMC;AAED;;;GAGG;AACU,QAAA,UAAU,GAAwC,iBAAiB,CAAC,WAAW,CAAC,CAAC;AAE9F;;;GAGG;AACU,QAAA,qBAAqB,GAA+C,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;AAEvH;;;GAGG;AACU,QAAA,WAAW,GAAqC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAEzF;;;GAGG;AACU,QAAA,gBAAgB,GAA0C,iBAAiB,CAAC,aAAa,CAAC,CAAC;AAExG;;;GAGG;AACU,QAAA,WAAW,GAAqC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;AAEzF;;;GAGG;AACU,QAAA,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';
@@ -6,6 +6,7 @@ const tslib_1 = require("tslib");
6
6
  (0, tslib_1.__exportStar)(require("./DefaultLayout"), exports);
7
7
  (0, tslib_1.__exportStar)(require("./DefaultLoader"), exports);
8
8
  (0, tslib_1.__exportStar)(require("./DefaultRouter"), exports);
9
+ (0, tslib_1.__exportStar)(require("./DefaultRouteSwitch"), exports);
9
10
  (0, tslib_1.__exportStar)(require("./ErrorBoundary"), exports);
10
11
  (0, tslib_1.__exportStar)(require("./ExtensionSlot"), exports);
11
12
  (0, tslib_1.__exportStar)(require("./Mediator"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":";;;AAAA,4DAA6B;AAC7B,kEAAmC;AACnC,+DAAgC;AAChC,+DAAgC;AAChC,+DAAgC;AAChC,+DAAgC;AAChC,+DAAgC;AAChC,0DAA2B;AAC3B,6DAA8B;AAC9B,2DAA4B;AAC5B,gEAAiC;AACjC,kEAAmC;AACnC,8DAA+B;AAC/B,0DAA2B;AAC3B,2DAA4B;AAC5B,2DAA4B;AAC5B,6DAA8B;AAC9B,6DAA8B;AAC9B,0DAA2B;AAC3B,iEAAkC;AAClC,+DAAgC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":";;;AAAA,4DAA6B;AAC7B,kEAAmC;AACnC,+DAAgC;AAChC,+DAAgC;AAChC,+DAAgC;AAChC,oEAAqC;AACrC,+DAAgC;AAChC,+DAAgC;AAChC,0DAA2B;AAC3B,6DAA8B;AAC9B,2DAA4B;AAC5B,gEAAiC;AACjC,kEAAmC;AACnC,8DAA+B;AAC/B,0DAA2B;AAC3B,2DAA4B;AAC5B,2DAA4B;AAC5B,6DAA8B;AAC9B,6DAA8B;AAC9B,0DAA2B;AAC3B,iEAAkC;AAClC,+DAAgC"}
@@ -27,6 +27,7 @@ function createGlobalState(customState = {}) {
27
27
  ErrorInfo: components_1.DefaultErrorInfo,
28
28
  LoadingIndicator: components_1.DefaultLoadingIndicator,
29
29
  Router: components_1.DefaultRouter,
30
+ RouteSwitch: components_1.DefaultRouteSwitch,
30
31
  Layout: components_1.DefaultLayout,
31
32
  },
32
33
  errorComponents: {},
@@ -1 +1 @@
1
- {"version":3,"file":"createGlobalState.js","sourceRoot":"","sources":["../../src/state/createGlobalState.ts"],"names":[],"mappings":";;;AAAA,qDAA4C;AAC5C,8CAAwG;AAGxG,SAAS,MAAM,CAAI,YAAe,EAAE,WAA6B;IAC/D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;QAC1C,IAAI,GAA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AAM,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;AACpD,CAAC;AA5BD,8CA4BC"}
@@ -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
+ }
@@ -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 { PiletMetadata, EventEmitter, Pilet, BaseComponentProps, PageComponentProps, ExtensionComponentProps, PiletsBag, PiralPageMeta } 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
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-core",
3
- "version": "0.14.13",
3
+ "version": "0.14.14-beta.3765",
4
4
  "description": "The core library for creating a Piral instance.",
5
5
  "keywords": [
6
6
  "portal",
@@ -50,8 +50,8 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@dbeining/react-atom": "^4.0.0",
53
- "piral-base": "^0.14.13",
54
- "piral-debug-utils": "^0.14.13"
53
+ "piral-base": "0.14.14-beta.3765",
54
+ "piral-debug-utils": "0.14.14-beta.3765"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "react": ">=16.8.0",
@@ -77,5 +77,6 @@
77
77
  "path-to-regexp",
78
78
  "@libre/atom",
79
79
  "@dbeining/react-atom"
80
- ]
80
+ ],
81
+ "gitHead": "f933f63d8d746f6f592e6d62a4f74921d8fbcc01"
81
82
  }
@@ -0,0 +1,14 @@
1
+ import * as React from 'react';
2
+ import { Switch, Route } from 'react-router';
3
+ import { RouteSwitchProps } from '../types';
4
+
5
+ export const DefaultRouteSwitch: React.FC<RouteSwitchProps> = ({ paths, NotFound, ...props }) => {
6
+ return (
7
+ <Switch {...props}>
8
+ {paths.map(({ path, Component }) => (
9
+ <Route exact key={path} path={path} component={Component} />
10
+ ))}
11
+ <Route component={NotFound} />
12
+ </Switch>
13
+ );
14
+ };
@@ -2,6 +2,7 @@ import * as React from 'react';
2
2
  import * as hooks from '../hooks';
3
3
  import { MemoryRouter } from 'react-router';
4
4
  import { mount } from 'enzyme';
5
+ import { DefaultRouteSwitch } from './DefaultRouteSwitch';
5
6
  import { PiralRoutes } from './PiralRoutes';
6
7
 
7
8
  const mountWithRouter = (node, url = '/') =>
@@ -52,7 +53,7 @@ StubBarPage.displayName = 'StubBarPage';
52
53
 
53
54
  describe('Routes Module', () => {
54
55
  it('always goes to the given home on "/"', () => {
55
- const node = mountWithRouter(<PiralRoutes NotFound={StubNotFound} />, '/');
56
+ const node = mountWithRouter(<PiralRoutes NotFound={StubNotFound} RouteSwitch={DefaultRouteSwitch} />, '/');
56
57
  expect(node.find(StubHome).length).toBe(1);
57
58
  expect(node.find(StubNotFound).length).toBe(0);
58
59
  expect(node.find(StubCustomPage).length).toBe(0);
@@ -60,7 +61,7 @@ describe('Routes Module', () => {
60
61
  });
61
62
 
62
63
  it('goes to the not found on an invalid path', () => {
63
- const node = mountWithRouter(<PiralRoutes NotFound={StubNotFound} />, '/qxz');
64
+ const node = mountWithRouter(<PiralRoutes NotFound={StubNotFound} RouteSwitch={DefaultRouteSwitch} />, '/qxz');
64
65
  expect(node.find(StubHome).length).toBe(0);
65
66
  expect(node.find(StubNotFound).length).toBe(1);
66
67
  expect(node.find(StubCustomPage).length).toBe(0);
@@ -68,7 +69,7 @@ describe('Routes Module', () => {
68
69
  });
69
70
 
70
71
  it('goes to the custom page on "/custom"', () => {
71
- const node = mountWithRouter(<PiralRoutes NotFound={StubNotFound} />, '/custom');
72
+ const node = mountWithRouter(<PiralRoutes NotFound={StubNotFound} RouteSwitch={DefaultRouteSwitch} />, '/custom');
72
73
  expect(node.find(StubHome).length).toBe(0);
73
74
  expect(node.find(StubNotFound).length).toBe(0);
74
75
  expect(node.find(StubCustomPage).length).toBe(1);
@@ -76,7 +77,7 @@ describe('Routes Module', () => {
76
77
  });
77
78
 
78
79
  it('goes exactly to the page on "/foo/bar"', () => {
79
- const node = mountWithRouter(<PiralRoutes NotFound={StubNotFound} />, '/foo/bar');
80
+ const node = mountWithRouter(<PiralRoutes NotFound={StubNotFound} RouteSwitch={DefaultRouteSwitch} />, '/foo/bar');
80
81
  expect(node.find(StubHome).length).toBe(0);
81
82
  expect(node.find(StubNotFound).length).toBe(0);
82
83
  expect(node.find(StubCustomPage).length).toBe(0);
@@ -84,7 +85,7 @@ describe('Routes Module', () => {
84
85
  });
85
86
 
86
87
  it('goes exactly to the page on "/foo"', () => {
87
- const node = mountWithRouter(<PiralRoutes NotFound={StubNotFound} />, '/foo');
88
+ const node = mountWithRouter(<PiralRoutes NotFound={StubNotFound} RouteSwitch={DefaultRouteSwitch} />, '/foo');
88
89
  expect(node.find(StubHome).length).toBe(0);
89
90
  expect(node.find(StubNotFound).length).toBe(0);
90
91
  expect(node.find(StubCustomPage).length).toBe(0);
@@ -93,7 +94,7 @@ describe('Routes Module', () => {
93
94
  });
94
95
 
95
96
  it('goes exactly to the page on "/bar"', () => {
96
- const node = mountWithRouter(<PiralRoutes NotFound={StubNotFound} />, '/bar');
97
+ const node = mountWithRouter(<PiralRoutes NotFound={StubNotFound} RouteSwitch={DefaultRouteSwitch} />, '/bar');
97
98
  expect(node.find(StubHome).length).toBe(0);
98
99
  expect(node.find(StubNotFound).length).toBe(0);
99
100
  expect(node.find(StubCustomPage).length).toBe(0);
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
- import { Route, Switch, RouteComponentProps, SwitchProps } from 'react-router';
2
+ import { RouteComponentProps, SwitchProps } from 'react-router';
3
3
  import { useGlobalState } from '../hooks';
4
+ import { RouteSwitchProps } from '../types';
4
5
 
5
6
  /**
6
7
  * The props used by the PiralRoutes component.
@@ -10,25 +11,23 @@ export interface RoutesProps extends SwitchProps {
10
11
  * Sets the component for showing the not found page.
11
12
  */
12
13
  NotFound: React.ComponentType<RouteComponentProps>;
14
+ /**
15
+ * Sets the component for actually switching the routes.
16
+ */
17
+ RouteSwitch: React.ComponentType<RouteSwitchProps>;
13
18
  }
14
19
 
15
20
  /**
16
21
  * The component for defining the exclusive routes to be used.
17
22
  */
18
- export const PiralRoutes: React.FC<RoutesProps> = ({ NotFound, ...props }) => {
23
+ export const PiralRoutes: React.FC<RoutesProps> = ({ NotFound, RouteSwitch, ...props }) => {
19
24
  const routes = useGlobalState((s) => s.routes);
20
25
  const pages = useGlobalState((s) => s.registry.pages);
26
+ const paths = [];
27
+
28
+ Object.keys(routes).map((path) => paths.push({ path, Component: routes[path] }));
29
+ Object.keys(pages).map((path) => paths.push({ path, Component: pages[path].component }));
21
30
 
22
- return (
23
- <Switch {...props}>
24
- {Object.keys(routes).map((url) => (
25
- <Route exact key={url} path={url} component={routes[url]} />
26
- ))}
27
- {Object.keys(pages).map((url) => (
28
- <Route exact key={url} path={url} component={pages[url].component} />
29
- ))}
30
- <Route component={NotFound} />
31
- </Switch>
32
- );
31
+ return <RouteSwitch NotFound={NotFound} paths={paths} {...props} />;
33
32
  };
34
33
  PiralRoutes.displayName = 'Routes';
@@ -1,7 +1,14 @@
1
1
  import * as React from 'react';
2
2
  import { RouteComponentProps, StaticRouter } from 'react-router';
3
- import { PiralError, PiralRouter, PiralLoadingIndicator, PiralLayout, PiralDebug } from './components';
4
3
  import { PiralRoutes } from './PiralRoutes';
4
+ import {
5
+ PiralError,
6
+ PiralRouter,
7
+ PiralLoadingIndicator,
8
+ PiralRouteSwitch,
9
+ PiralLayout,
10
+ PiralDebug,
11
+ } from './components';
5
12
  import { useGlobalState } from '../hooks';
6
13
 
7
14
  const NotFound: React.FC<RouteComponentProps> = (props) => <PiralError type="not_found" {...props} />;
@@ -15,7 +22,7 @@ const PiralContent: React.FC = () => {
15
22
  <PiralLoadingIndicator />
16
23
  ) : (
17
24
  <PiralLayout currentLayout={layout}>
18
- <PiralRoutes NotFound={NotFound} />
25
+ <PiralRoutes NotFound={NotFound} RouteSwitch={PiralRouteSwitch} />
19
26
  </PiralLayout>
20
27
  );
21
28
  };
@@ -1,10 +1,18 @@
1
1
  import * as React from 'react';
2
2
  import { useGlobalState } from '../hooks';
3
- import { ComponentsState, ErrorInfoProps, LoadingIndicatorProps, RouterProps, LayoutProps } from '../types';
3
+ import {
4
+ ComponentsState,
5
+ ErrorInfoProps,
6
+ LoadingIndicatorProps,
7
+ RouterProps,
8
+ LayoutProps,
9
+ RouteSwitchProps,
10
+ } from '../types';
4
11
 
5
12
  export function getPiralComponent<TKey extends keyof ComponentsState>(name: TKey): ComponentsState[TKey] {
6
13
  return (props) => {
7
14
  const Component = useGlobalState((s) => s.components[name]);
15
+ // tslint:disable-next-line:no-null-keyword
8
16
  return Component ? <Component {...props} /> : null;
9
17
  };
10
18
  }
@@ -27,6 +35,12 @@ export const PiralLoadingIndicator: React.ComponentType<LoadingIndicatorProps> =
27
35
  */
28
36
  export const PiralRouter: React.ComponentType<RouterProps> = getPiralComponent('Router');
29
37
 
38
+ /**
39
+ * Gets the currently registered Route Switch component.
40
+ * By default the DefaultRouteSwitch component is used.
41
+ */
42
+ export const PiralRouteSwitch: React.ComponentType<RouteSwitchProps> = getPiralComponent('RouteSwitch');
43
+
30
44
  /**
31
45
  * Gets the currently registered Layout component.
32
46
  * By default the children are rendered.
@@ -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,6 +1,12 @@
1
1
  import { deref } from '@dbeining/react-atom';
2
2
  import { createGlobalState } from './createGlobalState';
3
- import { DefaultErrorInfo, DefaultLoadingIndicator, DefaultLayout, DefaultRouter } from '../components';
3
+ import {
4
+ DefaultErrorInfo,
5
+ DefaultLoadingIndicator,
6
+ DefaultLayout,
7
+ DefaultRouter,
8
+ DefaultRouteSwitch,
9
+ } from '../components';
4
10
 
5
11
  process.env.PIRAL_PUBLIC_PATH = '/';
6
12
 
@@ -22,6 +28,7 @@ describe('Create Global State Module', () => {
22
28
  LoadingIndicator: DefaultLoadingIndicator,
23
29
  Router: DefaultRouter,
24
30
  Layout: DefaultLayout,
31
+ RouteSwitch: DefaultRouteSwitch,
25
32
  },
26
33
  routes: {},
27
34
  registry: {
@@ -50,6 +57,7 @@ describe('Create Global State Module', () => {
50
57
  LoadingIndicator: DefaultLoadingIndicator,
51
58
  Router: DefaultRouter,
52
59
  Layout: DefaultLayout,
60
+ RouteSwitch: DefaultRouteSwitch,
53
61
  },
54
62
  routes: {},
55
63
  registry: {
@@ -82,6 +90,7 @@ describe('Create Global State Module', () => {
82
90
  LoadingIndicator: DefaultLoadingIndicator,
83
91
  Router: DefaultRouter,
84
92
  Layout: DefaultLayout,
93
+ RouteSwitch: DefaultRouteSwitch,
85
94
  },
86
95
  routes,
87
96
  registry: {
@@ -110,6 +119,7 @@ describe('Create Global State Module', () => {
110
119
  LoadingIndicator: DefaultLoadingIndicator,
111
120
  Router: DefaultRouter,
112
121
  Layout: DefaultLayout,
122
+ RouteSwitch: DefaultRouteSwitch,
113
123
  },
114
124
  registry: {
115
125
  extensions: {},
@@ -140,6 +150,7 @@ describe('Create Global State Module', () => {
140
150
  LoadingIndicator: DefaultLoadingIndicator,
141
151
  Router: DefaultRouter,
142
152
  Layout: DefaultLayout,
153
+ RouteSwitch: DefaultRouteSwitch,
143
154
  },
144
155
  registry: {
145
156
  extensions: {},
@@ -170,6 +181,7 @@ describe('Create Global State Module', () => {
170
181
  LoadingIndicator: DefaultLoadingIndicator,
171
182
  Router: DefaultRouter,
172
183
  Layout: DefaultLayout,
184
+ RouteSwitch: DefaultRouteSwitch,
173
185
  },
174
186
  registry: {
175
187
  extensions: {},
@@ -206,6 +218,7 @@ describe('Create Global State Module', () => {
206
218
  LoadingIndicator: DefaultLoadingIndicator,
207
219
  Router: DefaultRouter,
208
220
  Layout: DefaultLayout,
221
+ RouteSwitch: DefaultRouteSwitch,
209
222
  },
210
223
  registry: {
211
224
  extensions: {},
@@ -241,6 +254,7 @@ describe('Create Global State Module', () => {
241
254
  LoadingIndicator: DefaultLoadingIndicator,
242
255
  Router: DefaultRouter,
243
256
  Layout: DefaultLayout,
257
+ RouteSwitch: DefaultRouteSwitch,
244
258
  },
245
259
  registry: {
246
260
  extensions: {},
@@ -1,5 +1,11 @@
1
1
  import { Atom } from '@dbeining/react-atom';
2
- import { DefaultErrorInfo, DefaultLoadingIndicator, DefaultLayout, DefaultRouter } from '../components';
2
+ import {
3
+ DefaultErrorInfo,
4
+ DefaultLoadingIndicator,
5
+ DefaultLayout,
6
+ DefaultRouter,
7
+ DefaultRouteSwitch,
8
+ } from '../components';
3
9
  import { GlobalState, NestedPartial } from '../types';
4
10
 
5
11
  function extend<T>(defaultState: T, customState: NestedPartial<T>) {
@@ -29,6 +35,7 @@ export function createGlobalState(customState: NestedPartial<GlobalState> = {})
29
35
  ErrorInfo: DefaultErrorInfo,
30
36
  LoadingIndicator: DefaultLoadingIndicator,
31
37
  Router: DefaultRouter,
38
+ RouteSwitch: DefaultRouteSwitch,
32
39
  Layout: DefaultLayout,
33
40
  },
34
41
  errorComponents: {},
@@ -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';
@@ -194,3 +194,26 @@ export interface LayoutProps {
194
194
  * The props of a Router component.
195
195
  */
196
196
  export interface RouterProps {}
197
+
198
+ /**
199
+ * The props of the RouteSwitch component.
200
+ */
201
+ export interface RouteSwitchProps extends SwitchProps {
202
+ /**
203
+ * The component that should be used in case nothing was found.
204
+ */
205
+ NotFound: ComponentType<RouteComponentProps>;
206
+ /**
207
+ * The component to register for the different paths.
208
+ */
209
+ paths: Array<{
210
+ /**
211
+ * The exact path to use.
212
+ */
213
+ path: string;
214
+ /**
215
+ * The component to register for this path.
216
+ */
217
+ Component: ComponentType<RouteComponentProps>;
218
+ }>;
219
+ }
@@ -28,6 +28,7 @@ import type {
28
28
  RouterProps,
29
29
  LayoutProps,
30
30
  Errors,
31
+ RouteSwitchProps,
31
32
  } from './components';
32
33
 
33
34
  export interface StateDispatcher<TState> {
@@ -87,6 +88,10 @@ export interface ComponentsState extends PiralCustomComponentsState {
87
88
  * The layout used for pages.
88
89
  */
89
90
  Layout: ComponentType<LayoutProps>;
91
+ /**
92
+ * The route switch used for determining the route registration.
93
+ */
94
+ RouteSwitch: ComponentType<RouteSwitchProps>;
90
95
  /**
91
96
  * A component that can be used for debugging purposes.
92
97
  */