piral-core 0.15.0-alpha.3549 → 0.15.0-alpha.3592

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 (75) hide show
  1. package/esm/actions/app.d.ts +3 -1
  2. package/esm/actions/app.js +18 -0
  3. package/esm/actions/app.js.map +1 -1
  4. package/esm/components/ErrorBoundary.d.ts +12 -33
  5. package/esm/components/ErrorBoundary.js +12 -14
  6. package/esm/components/ErrorBoundary.js.map +1 -1
  7. package/esm/createInstance.js +5 -1
  8. package/esm/createInstance.js.map +1 -1
  9. package/{debug-piral.d.ts → esm/debugger.d.ts} +1 -1
  10. package/esm/debugger.js +52 -0
  11. package/esm/debugger.js.map +1 -0
  12. package/{debug-pilet.d.ts → esm/emulator.d.ts} +1 -1
  13. package/esm/emulator.js +8 -0
  14. package/esm/emulator.js.map +1 -0
  15. package/esm/helpers.js +2 -2
  16. package/esm/helpers.js.map +1 -1
  17. package/esm/modules/core.js +8 -6
  18. package/esm/modules/core.js.map +1 -1
  19. package/esm/modules/dependencies.d.ts +2 -2
  20. package/esm/modules/dependencies.js.map +1 -1
  21. package/esm/state/withApi.d.ts +1 -1
  22. package/esm/state/withApi.js +31 -33
  23. package/esm/state/withApi.js.map +1 -1
  24. package/esm/types/api.d.ts +12 -8
  25. package/esm/types/state.d.ts +13 -3
  26. package/esm/types/utils.d.ts +1 -1
  27. package/esm/utils/index.d.ts +1 -0
  28. package/esm/utils/index.js +1 -0
  29. package/esm/utils/index.js.map +1 -1
  30. package/lib/actions/app.d.ts +3 -1
  31. package/lib/actions/app.js +21 -1
  32. package/lib/actions/app.js.map +1 -1
  33. package/lib/components/ErrorBoundary.d.ts +12 -33
  34. package/lib/components/ErrorBoundary.js +12 -14
  35. package/lib/components/ErrorBoundary.js.map +1 -1
  36. package/lib/createInstance.js +5 -1
  37. package/lib/createInstance.js.map +1 -1
  38. package/lib/debugger.d.ts +4 -0
  39. package/lib/debugger.js +56 -0
  40. package/lib/debugger.js.map +1 -0
  41. package/lib/emulator.d.ts +3 -0
  42. package/lib/emulator.js +12 -0
  43. package/lib/emulator.js.map +1 -0
  44. package/lib/helpers.js +2 -2
  45. package/lib/helpers.js.map +1 -1
  46. package/lib/modules/core.js +8 -6
  47. package/lib/modules/core.js.map +1 -1
  48. package/lib/modules/dependencies.d.ts +2 -2
  49. package/lib/modules/dependencies.js.map +1 -1
  50. package/lib/state/withApi.d.ts +1 -1
  51. package/lib/state/withApi.js +30 -32
  52. package/lib/state/withApi.js.map +1 -1
  53. package/lib/types/api.d.ts +12 -8
  54. package/lib/types/state.d.ts +13 -3
  55. package/lib/types/utils.d.ts +1 -1
  56. package/lib/utils/index.d.ts +1 -0
  57. package/lib/utils/index.js +4 -0
  58. package/lib/utils/index.js.map +1 -1
  59. package/package.json +9 -11
  60. package/src/actions/app.ts +25 -0
  61. package/src/components/ErrorBoundary.tsx +19 -51
  62. package/src/createInstance.tsx +5 -1
  63. package/src/debugger.ts +82 -0
  64. package/src/emulator.ts +10 -0
  65. package/src/helpers.tsx +2 -2
  66. package/src/modules/core.ts +10 -8
  67. package/src/modules/dependencies.ts +3 -2
  68. package/src/state/withApi.test.tsx +20 -4
  69. package/src/state/withApi.tsx +51 -42
  70. package/src/types/api.ts +23 -9
  71. package/src/types/state.ts +13 -3
  72. package/src/types/utils.ts +1 -1
  73. package/src/utils/index.ts +2 -0
  74. package/debug-pilet.js +0 -13
  75. package/debug-piral.js +0 -59
@@ -1,8 +1,10 @@
1
1
  import { ComponentType } from 'react';
2
2
  import { RouteComponentProps } from 'react-router';
3
- import { LayoutType, ComponentsState, ErrorComponentsState, GlobalStateContext, Pilet } from '../types';
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;
6
8
  export declare function injectPilet(ctx: GlobalStateContext, pilet: Pilet): void;
7
9
  export declare function setComponent<TKey extends keyof ComponentsState>(ctx: GlobalStateContext, name: TKey, component: ComponentsState[TKey]): void;
8
10
  export declare function setErrorComponent<TKey extends keyof ErrorComponentsState>(ctx: GlobalStateContext, type: TKey, component: ErrorComponentsState[TKey]): void;
@@ -1,3 +1,4 @@
1
+ import { runPilet } from 'piral-base';
1
2
  import { withKey, replaceOrAddItem, removeNested, withProvider, withRoute } from '../utils';
2
3
  export function changeLayout(ctx, current) {
3
4
  ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { app: withKey(state.app, 'layout', current) })));
@@ -6,6 +7,23 @@ export function initialize(ctx, loading, error, modules) {
6
7
  ctx.dispatch((state) => (Object.assign(Object.assign({}, state), { app: Object.assign(Object.assign({}, state.app), { error,
7
8
  loading }), modules })));
8
9
  }
10
+ export function addPilet(ctx, meta) {
11
+ ctx.options.loadPilet(meta).then((pilet) => {
12
+ try {
13
+ ctx.injectPilet(pilet);
14
+ runPilet(ctx.options.createApi, pilet, ctx.options.hooks);
15
+ }
16
+ catch (error) {
17
+ console.error(error);
18
+ }
19
+ });
20
+ }
21
+ export function removePilet(ctx, name) {
22
+ 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
+ ctx.emit('unload-pilet', {
24
+ name,
25
+ });
26
+ }
9
27
  export function injectPilet(ctx, pilet) {
10
28
  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) })));
11
29
  ctx.emit('unload-pilet', {
@@ -1 +1 @@
1
- {"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/actions/app.ts"],"names":[],"mappings":"AAE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E,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,EAC7E,QAAQ,EAAE,YAAY,CAAkC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,CAAC,IACtG,CAAC,CAAC;IAEJ,GAAG,CAAC,IAAI,CAAC,cAAc,EAAE;QACvB,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,GAAuB,EACvB,IAAU,EACV,SAAgC;IAEhC,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,UAAU,EAAE,IAAI,EAAE,SAAS,CAAC,IACtD,CAAC,CAAC;AACN,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,GAAuB,EACvB,IAAU,EACV,SAAqC;IAErC,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iCACnB,KAAK,KACR,eAAe,EAAE,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,IAAI,EAAE,SAAS,CAAC,IAChE,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"}
@@ -1,38 +1,15 @@
1
1
  import * as React from 'react';
2
- /**
3
- * The options to be used for determining the boundary's behavior.
4
- */
5
- export interface ErrorBoundaryOptions<T> {
6
- /**
7
- * Callback to be used in case of an emitted error.
8
- * @param error The error caught by the boundary.
9
- */
10
- onError(error: Error): void;
2
+ import { Errors, PiletApi } from '../types';
3
+ export interface ErrorBoundaryProps {
11
4
  /**
12
- * Callback to be used when an error should be rendered.
13
- * @param error The error caught by the boundary.
14
- * @param props The props used by the boundary.
5
+ * The type of error to indicate when caught.
15
6
  */
16
- renderError?(error: Error, props: T): React.ReactNode;
7
+ errorType: keyof Errors;
17
8
  /**
18
- * Callback to used when no error should be rendered.
19
- * @param children The standard children to render.
20
- * @param props The props used by the boundary.
9
+ * The associated pilet api for the metadata.
21
10
  */
22
- renderChild(children: React.ReactNode, props: T): React.ReactNode;
11
+ piral: PiletApi;
23
12
  }
24
- /**
25
- * The props of the ErrorBoundary component.
26
- */
27
- export interface ErrorBoundaryProps<T> extends ErrorBoundaryOptions<T> {
28
- /**
29
- * The render props for the specific ErrorBoundary.
30
- */
31
- renderProps: T;
32
- }
33
- /**
34
- * The state of the ErrorBoundary component.
35
- */
36
13
  export interface ErrorBoundaryState {
37
14
  /**
38
15
  * The current error (if any) caught by the boundary.
@@ -40,10 +17,12 @@ export interface ErrorBoundaryState {
40
17
  error?: Error;
41
18
  }
42
19
  /**
43
- * The React component for catching errors and displaying error information.
20
+ * The component for catching errors and displaying error information.
44
21
  */
45
- export declare class ErrorBoundary<T> extends React.Component<ErrorBoundaryProps<T>, ErrorBoundaryState> {
46
- constructor(props: ErrorBoundaryProps<T>);
22
+ export declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
23
+ state: {
24
+ error: any;
25
+ };
47
26
  componentDidCatch(error: Error): void;
48
- render(): React.ReactNode;
27
+ render(): JSX.Element;
49
28
  }
@@ -1,34 +1,32 @@
1
+ import { __rest } from "tslib";
1
2
  import * as React from 'react';
2
- import { isfunc } from 'piral-base';
3
+ import { PiralError, PiralLoadingIndicator } from './components';
3
4
  /**
4
- * The React component for catching errors and displaying error information.
5
+ * The component for catching errors and displaying error information.
5
6
  */
6
7
  export class ErrorBoundary extends React.Component {
7
- constructor(props) {
8
- super(props);
8
+ constructor() {
9
+ super(...arguments);
9
10
  this.state = {
10
11
  error: undefined,
11
12
  };
12
13
  }
13
14
  componentDidCatch(error) {
14
- const { onError } = this.props;
15
- if (isfunc(onError)) {
16
- onError(error);
17
- }
15
+ const { piral, errorType } = this.props;
16
+ const pilet = piral.meta.name;
17
+ console.error(`[${pilet}] Exception in component of type "${errorType}".`, error);
18
18
  this.setState({
19
19
  error,
20
20
  });
21
21
  }
22
22
  render() {
23
- const { children, renderError, renderChild, renderProps } = this.props;
23
+ const _a = this.props, { children, piral, errorType } = _a, renderProps = __rest(_a, ["children", "piral", "errorType"]);
24
24
  const { error } = this.state;
25
+ const rest = renderProps;
25
26
  if (error) {
26
- if (isfunc(renderError)) {
27
- return renderError(error, renderProps);
28
- }
29
- return React.createElement("div", { style: { whiteSpace: 'pre-wrap' } }, error && error.message);
27
+ return React.createElement(PiralError, Object.assign({ type: errorType, error: error }, rest));
30
28
  }
31
- return isfunc(renderChild) ? renderChild(children, renderProps) : children;
29
+ return React.createElement(React.Suspense, { fallback: React.createElement(PiralLoadingIndicator, null) }, children);
32
30
  }
33
31
  }
34
32
  //# sourceMappingURL=ErrorBoundary.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../src/components/ErrorBoundary.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AA6CpC;;GAEG;AACH,MAAM,OAAO,aAAiB,SAAQ,KAAK,CAAC,SAAoD;IAC9F,YAAY,KAA4B;QACtC,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG;YACX,KAAK,EAAE,SAAS;SACjB,CAAC;IACJ,CAAC;IAED,iBAAiB,CAAC,KAAY;QAC5B,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAE/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AK,qCAAqC,SAAS,IAAI,EAAE,KAAK,CAAC,CAAC;QAElF,IAAI,CAAC,QAAQ,CAAC;YACZ,KAAK;SACN,CAAC,CAAC;IACL,CAAC;IAED,MAAM;QACJ,MAAM,KAAiD,IAAI,CAAC,KAAK,EAA3D,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,OAA+B,EAA1B,WAAW,cAA5C,kCAA8C,CAAa,CAAC;QAClE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC7B,MAAM,IAAI,GAAQ,WAAW,CAAC;QAE9B,IAAI,KAAK,EAAE;YACT,OAAO,oBAAC,UAAU,kBAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,IAAM,IAAI,EAAI,CAAC;SAChE;QAED,OAAO,oBAAC,KAAK,CAAC,QAAQ,IAAC,QAAQ,EAAE,oBAAC,qBAAqB,OAAG,IAAG,QAAQ,CAAkB,CAAC;IAC1F,CAAC;CACF"}
@@ -35,7 +35,11 @@ export function createInstance(config = {}) {
35
35
  const root = createApi({
36
36
  name: 'root',
37
37
  version: process.env.BUILD_PCKG_VERSION || '1.0.0',
38
- spec: '',
38
+ spec: 'v0',
39
+ basePath: '',
40
+ link: '',
41
+ config: {},
42
+ dependencies: {},
39
43
  });
40
44
  const options = createPiletOptions({
41
45
  context,
@@ -1 +1 @@
1
- {"version":3,"file":"createInstance.js","sourceRoot":"","sources":["../src/createInstance.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AACjG,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,kBAAk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Context } from './lib/types';
3
+ import { GlobalStateContext } from './types';
4
4
  export declare function integrate(context: GlobalStateContext, options: LoadPiletsOptions, debug?: DebuggerExtensionOptions): void;
@@ -0,0 +1,52 @@
1
+ import { addChangeHandler } from '@dbeining/react-atom';
2
+ import { installPiralDebug } from 'piral-debug-utils';
3
+ export function integrate(context, options, debug = {}) {
4
+ installPiralDebug(Object.assign(Object.assign({}, debug), { addPilet: context.addPilet, removePilet: context.removePilet, updatePilet(pilet) {
5
+ if (!pilet.disabled) {
6
+ const { createApi } = options;
7
+ const newApi = createApi(pilet);
8
+ try {
9
+ context.injectPilet(pilet);
10
+ pilet.setup(newApi);
11
+ }
12
+ catch (error) {
13
+ console.error(error);
14
+ }
15
+ }
16
+ else {
17
+ context.injectPilet(pilet);
18
+ }
19
+ }, fireEvent: context.emit, getDependencies() {
20
+ return Object.keys(options.dependencies);
21
+ },
22
+ getExtensions() {
23
+ return context.readState((s) => Object.keys(s.registry.extensions));
24
+ },
25
+ getRoutes() {
26
+ const registeredRoutes = context.readState((state) => Object.keys(state.registry.pages));
27
+ const componentRoutes = context.readState((state) => Object.keys(state.routes));
28
+ return [...componentRoutes, ...registeredRoutes];
29
+ },
30
+ getGlobalState() {
31
+ return context.readState((s) => s);
32
+ },
33
+ getPilets() {
34
+ return context.readState((s) => s.modules);
35
+ },
36
+ integrate(dbg) {
37
+ context.dispatch((s) => (Object.assign(Object.assign({}, s), { components: Object.assign(Object.assign({}, s.components), dbg.components), routes: Object.assign(Object.assign({}, s.routes), dbg.routes), registry: Object.assign(Object.assign({}, s.registry), { wrappers: Object.assign(Object.assign({}, s.registry.wrappers), dbg.wrappers) }) })));
38
+ addChangeHandler(context.state, 'debugging', ({ previous, current }) => {
39
+ const pilets = current.modules !== previous.modules;
40
+ const pages = current.registry.pages !== previous.registry.pages || current.routes !== previous.routes;
41
+ const extensions = current.registry.extensions !== previous.registry.extensions;
42
+ const state = current !== previous;
43
+ dbg.onChange(previous, current, {
44
+ pilets,
45
+ pages,
46
+ extensions,
47
+ state,
48
+ });
49
+ });
50
+ } }));
51
+ }
52
+ //# sourceMappingURL=debugger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debugger.js","sourceRoot":"","sources":["../src/debugger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAA4B,MAAM,mBAAmB,CAAC;AAGhF,MAAM,UAAU,SAAS,CACvB,OAA2B,EAC3B,OAA0B,EAC1B,QAAkC,EAAE;IAEpC,iBAAiB,iCACZ,KAAK,KACR,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,WAAW,EAAE,OAAO,CAAC,WAAW,EAChC,WAAW,CAAC,KAAK;YACf,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;gBACnB,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;gBAC9B,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;gBAEhC,IAAI;oBACF,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;oBAC3B,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;iBACrB;gBAAC,OAAO,KAAK,EAAE;oBACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBACtB;aACF;iBAAM;gBACL,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;aAC5B;QACH,CAAC,EACD,SAAS,EAAE,OAAO,CAAC,IAAI,EACvB,eAAe;YACb,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAC3C,CAAC;QACD,aAAa;YACX,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;QACtE,CAAC;QACD,SAAS;YACP,MAAM,gBAAgB,GAAG,OAAO,CAA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,CAAC;gBACvG,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,KAAK,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;gBAChF,MAAM,KAAK,GAAG,OAAO,KAAK,QAAQ,CAAC;gBACnC,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE;oBAC9B,MAAM;oBACN,KAAK;oBACL,UAAU;oBACV,KAAK;iBACN,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,IACD,CAAC;AACL,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import { LoadPiletsOptions } from 'piral-base';
2
- import { GlobalStateContext } from './lib/types';
2
+ import { GlobalStateContext } from './types';
3
3
  export declare function integrate(context: GlobalStateContext, options: LoadPiletsOptions): void;
@@ -0,0 +1,8 @@
1
+ import { withEmulatorPilets } from 'piral-debug-utils';
2
+ export function integrate(context, options) {
3
+ options.fetchPilets = withEmulatorPilets(options.fetchPilets, {
4
+ addPilet: context.addPilet,
5
+ removePilet: context.removePilet,
6
+ });
7
+ }
8
+ //# sourceMappingURL=emulator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emulator.js","sourceRoot":"","sources":["../src/emulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD,MAAM,UAAU,SAAS,CAAC,OAA2B,EAAE,OAA0B;IAC/E,OAAO,CAAC,WAAW,GAAG,kBAAkB,CAAC,OAAO,CAAC,WAAW,EAAE;QAC5D,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;KACjC,CAAC,CAAC;AACL,CAAC"}
package/esm/helpers.js CHANGED
@@ -13,12 +13,12 @@ export function createPiletOptions({ hooks, context, loaders, loaderConfig, avai
13
13
  };
14
14
  // if we build the debug version of piral (debug and emulator build)
15
15
  if (process.env.DEBUG_PIRAL) {
16
- const { integrate } = require('../debug-piral');
16
+ const { integrate } = require('./debugger');
17
17
  integrate(context, options, debug);
18
18
  }
19
19
  // if we build the emulator version of piral (shipped to pilets)
20
20
  if (process.env.DEBUG_PILET) {
21
- const { integrate } = require('../debug-pilet');
21
+ const { integrate } = require('./emulator');
22
22
  integrate(context, options);
23
23
  }
24
24
  return options;
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,gBAAgB,EAChB,YAAY,GAGb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAiB/C,MAAM,UAAU,kBAAkB,CAAC,EACjC,KAAK,EACL,OAAO,EACP,OAAO,EACP,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,SAAS,EACT,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,KAAK,GACc;IACnB,MAAM,OAAO,GAAsB;QACjC,MAAM,EAAE,YAAY;QACpB,QAAQ;QACR,SAAS,EAAE,YAAY,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,gBAAgB,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;QAC7E,SAAS;QACT,MAAM,EAAE,eAAe;QACvB,WAAW,EAAE,aAAa;QAC1B,KAAK;QACL,YAAY,EAAE,iBAAiB,CAAC,kBAAkB,CAAC;KACpD,CAAC;IAEF,oEAAoE;IACpE,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE;QAC3B,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAChD,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;KACpC;IAED,gEAAgE;IAChE,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE;QAC3B,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;QAChD,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;KAC7B;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,gBAAgB,EAChB,YAAY,GAGb,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAiB/C,MAAM,UAAU,kBAAkB,CAAC,EACjC,KAAK,EACL,OAAO,EACP,OAAO,EACP,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,SAAS,EACT,SAAS,EACT,aAAa,EACb,iBAAiB,EACjB,KAAK,GACc;IACnB,MAAM,OAAO,GAAsB;QACjC,MAAM,EAAE,YAAY;QACpB,QAAQ;QACR,SAAS,EAAE,YAAY,CAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,gBAAgB,CAAC,YAAY,CAAC,EAAE,OAAO,CAAC;QAC7E,SAAS;QACT,MAAM,EAAE,eAAe;QACvB,WAAW,EAAE,aAAa;QAC1B,KAAK;QACL,YAAY,EAAE,iBAAiB,CAAC,kBAAkB,CAAC;KACpD,CAAC;IAEF,oEAAoE;IACpE,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE;QAC3B,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;QAC5C,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;KACpC;IAED,gEAAgE;IAChE,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE;QAC3B,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;QAC5C,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;KAC7B;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -14,25 +14,27 @@ export function createCoreApi(context) {
14
14
  const expiration = getDataExpiration(expires);
15
15
  return context.tryWriteDataItem(name, value, pilet, target, expiration);
16
16
  },
17
- registerPage(route, arg, meta) {
17
+ registerPage(route, arg, meta = {}) {
18
+ const component = withApi(context, arg, api, 'page', undefined, { meta });
18
19
  context.registerPage(route, {
19
20
  pilet,
20
21
  meta,
21
- component: withApi(context, arg, api, 'page'),
22
+ component,
22
23
  });
23
24
  return () => api.unregisterPage(route);
24
25
  },
25
26
  unregisterPage(route) {
26
27
  context.unregisterPage(route);
27
28
  },
28
- registerExtension(name, arg, defaults) {
29
+ registerExtension(name, reference, defaults) {
30
+ const component = withApi(context, reference, api, 'extension');
29
31
  context.registerExtension(name, {
30
32
  pilet,
31
- component: withApi(context, arg, api, 'extension'),
32
- reference: arg,
33
+ component,
34
+ reference,
33
35
  defaults,
34
36
  });
35
- return () => api.unregisterExtension(name, arg);
37
+ return () => api.unregisterExtension(name, reference);
36
38
  },
37
39
  unregisterExtension(name, arg) {
38
40
  context.unregisterExtension(name, arg);
@@ -1 +1 @@
1
- {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/modules/core.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGhE,MAAM,UAAU,aAAa,CAAC,OAA2B;IACvD,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;QACnB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC;QACxB,OAAO;YACL,OAAO,CAAC,IAAI;gBACV,OAAO,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;YACrC,CAAC;YACD,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO;gBAC1B,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE,OAAO,EAAE,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;gBAClE,MAAM,UAAU,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;gBAClB,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;YAChC,CAAC;YACD,iBAAiB,CAAC,IAAI,EAAE,SAAS,EAAE,QAAQ;gBACzC,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,WAAW,CAAC,CAAC;gBAChE,OAAO,CAAC,iBAAiB,CAAC,IAAI,EAAE;oBAC9B,KAAK;oBACL,SAAS;oBACT,SAAS;oBACT,QAAQ;iBACT,CAAC,CAAC;gBACH,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;YACxD,CAAC;YACD,mBAAmB,CAAC,IAAI,EAAE,GAAG;gBAC3B,OAAO,CAAC,mBAAmB,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;YACzC,CAAC;YACD,mBAAmB,CAAC,OAAO,EAAE,KAAK;gBAChC,MAAM,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;gBACzD,OAAO,OAAO,CAAC;YACjB,CAAC;YACD,SAAS,EAAE,aAAa;SACzB,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC"}
@@ -1,4 +1,4 @@
1
- import { PiletMetadata, AvailableDependencies } from 'piral-base';
1
+ import type { AvailableDependencies, PiletEntries } from '../types';
2
2
  /**
3
3
  * The global dependencies, which represent the dependencies
4
4
  * shared from the app shell itself.
@@ -20,4 +20,4 @@ return fetch('https://feed.piral.cloud/api/v1/pilet/sample')
20
20
  .then(res => res.items);
21
21
  ```
22
22
  */
23
- export declare function defaultModuleRequester(): Promise<Array<PiletMetadata>>;
23
+ export declare function defaultModuleRequester(): Promise<PiletEntries>;
@@ -1 +1 @@
1
- {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,MAAM,EAAE,MAAM,YAAY,CAAC;AAC1E,O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M,kBAAkB,GAA0B,EAAE,CAAC;AAE5D,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE;IACnC,MAAM,gBAAgB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAE/D,IAAI,MAAM,CAAC,gBAAgB,CAAC,EAAE;QAC5B,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;KACtC;SAAM;QACL,0EAA0E;QAC1E,QAAQ,CAAC,kBAAkB,EAAE;YAC3B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;YACvB,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC;YACjC,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC;YACvC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,CAAC;YAC/C,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;YAC3B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;YACvB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,CAAC;YAC3C,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;YACrC,sBAAsB,EAAE,OAAO,CAAC,sBAAsB,CAAC;SACxD,CAAC,CAAC;KACJ;CACF;KAAM;IACL,kFAAkF;CACnF;AAED;;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,YAAmC;IAC3E,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC7B,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import * as React from 'react';
2
2
  import { AnyComponent, Errors, PiletApi, BaseComponentProps, GlobalStateContext } from '../types';
3
- export declare function withApi<TProps>(context: GlobalStateContext, component: AnyComponent<TProps & BaseComponentProps>, piral: PiletApi, errorType: keyof Errors, wrapperType?: string): React.MemoExoticComponent<(props: TProps) => JSX.Element> | React.ComponentType<TProps>;
3
+ export declare function withApi<TProps>(context: GlobalStateContext, component: AnyComponent<TProps & BaseComponentProps>, piral: PiletApi, errorType: keyof Errors, wrapperType?: string, captured?: {}): React.MemoExoticComponent<(props: TProps) => JSX.Element> | React.ComponentType<TProps>;
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { isfunc } from 'piral-base';
3
3
  import { __RouterContext } from 'react-router';
4
- import { PiralError, PiralLoadingIndicator, ErrorBoundary, PortalRenderer } from '../components';
4
+ import { ErrorBoundary, PortalRenderer } from '../components';
5
5
  import { useGlobalStateContext } from '../hooks';
6
6
  import { defaultRender, convertComponent, none } from '../utils';
7
7
  // this is an arbitrary start number to have 6 digits
@@ -56,56 +56,54 @@ class ForeignComponentContainer extends React.Component {
56
56
  return React.createElement("div", { "data-portal-id": $portalId, ref: this.setNode });
57
57
  }
58
58
  }
59
- function wrapReactComponent(Component, stasisOptions, piral, Wrapper) {
60
- return (props) => (React.createElement(Wrapper, Object.assign({}, props, { piral: piral }),
61
- React.createElement(ErrorBoundary, Object.assign({}, stasisOptions, { renderProps: props }),
62
- React.createElement(Component, Object.assign({}, props, { piral: piral })))));
59
+ function wrapReactComponent(Component, captured, Wrapper) {
60
+ return (props) => (React.createElement(Wrapper, Object.assign({}, props),
61
+ React.createElement(Component, Object.assign({}, props, captured))));
63
62
  }
64
- function wrapForeignComponent(component, stasisOptions, piral, Wrapper) {
63
+ function wrapForeignComponent(component, captured, Wrapper) {
65
64
  return React.memo((props) => {
66
65
  const { state, readState, destroyPortal } = useGlobalStateContext();
67
66
  const router = React.useContext(__RouterContext);
68
67
  const id = React.useMemo(() => (portalIdBase++).toString(26), none);
69
68
  const context = React.useMemo(() => ({ router, state, readState }), [router, state]);
70
- const innerProps = React.useMemo(() => (Object.assign(Object.assign({}, props), { piral })), [props]);
69
+ const innerProps = React.useMemo(() => (Object.assign(Object.assign({}, props), captured)), [props]);
71
70
  React.useEffect(() => () => destroyPortal(id), none);
72
- return (React.createElement(Wrapper, Object.assign({}, innerProps),
73
- React.createElement(ErrorBoundary, Object.assign({}, stasisOptions, { renderProps: props }),
74
- React.createElement(PortalRenderer, { id: id }),
75
- React.createElement(ForeignComponentContainer, { innerProps: innerProps, "$portalId": id, "$component": component, "$context": context }))));
71
+ return (React.createElement(Wrapper, Object.assign({}, props),
72
+ React.createElement(PortalRenderer, { id: id }),
73
+ React.createElement(ForeignComponentContainer, { innerProps: innerProps, "$portalId": id, "$component": component, "$context": context })));
76
74
  });
77
75
  }
78
76
  function isNotExotic(component) {
79
77
  return !component.$$typeof;
80
78
  }
81
- function wrapComponent(converters, component, piral, Wrapper, stasisOptions) {
82
- if (!component) {
83
- console.error('The given value is not a valid component.');
84
- // tslint:disable-next-line:no-null-keyword
85
- component = () => null;
86
- }
79
+ function wrapComponent(converters, component, captured, Wrapper) {
87
80
  if (typeof component === 'object' && isNotExotic(component)) {
88
81
  const result = convertComponent(converters[component.type], component);
89
- return wrapForeignComponent(result, stasisOptions, piral, Wrapper);
82
+ return wrapForeignComponent(result, captured, Wrapper);
90
83
  }
91
- return wrapReactComponent(component, stasisOptions, piral, Wrapper);
84
+ return wrapReactComponent(component, captured, Wrapper);
92
85
  }
93
86
  function getWrapper(wrappers, wrapperType) {
94
- return wrappers[wrapperType] || wrappers['*'] || DefaultWrapper;
87
+ const WrapAll = wrappers['*'];
88
+ const WrapType = wrappers[wrapperType];
89
+ if (WrapAll && WrapType) {
90
+ return (props) => (React.createElement(WrapAll, Object.assign({}, props),
91
+ React.createElement(WrapType, Object.assign({}, props))));
92
+ }
93
+ return WrapType || WrapAll || DefaultWrapper;
95
94
  }
96
- export function withApi(context, component, piral, errorType, wrapperType = errorType) {
95
+ export function withApi(context, component, piral, errorType, wrapperType = errorType, captured = {}) {
96
+ const outerProps = Object.assign(Object.assign({}, captured), { piral });
97
97
  const converters = context.converters;
98
- const Wrapper = context.readState((m) => getWrapper(m.registry.wrappers, wrapperType));
99
- return wrapComponent(converters, component, piral, Wrapper, {
100
- onError(error) {
101
- console.error(piral, error);
102
- },
103
- renderChild(child) {
104
- return React.createElement(React.Suspense, { fallback: React.createElement(PiralLoadingIndicator, null) }, child);
105
- },
106
- renderError(error, props) {
107
- return React.createElement(PiralError, Object.assign({ type: errorType, error: error }, props));
108
- },
109
- });
98
+ const OuterWrapper = context.readState((m) => getWrapper(m.registry.wrappers, wrapperType));
99
+ const Wrapper = (props) => (React.createElement(OuterWrapper, Object.assign({}, outerProps, props),
100
+ React.createElement(ErrorBoundary, Object.assign({}, outerProps, props, { errorType: errorType }), props.children)));
101
+ if (!component) {
102
+ const pilet = piral.meta.name;
103
+ console.error(`[${pilet}] The given value is not a valid component.`);
104
+ // tslint:disable-next-line:no-null-keyword
105
+ component = () => null;
106
+ }
107
+ return wrapComponent(converters, component, outerProps, Wrapper);
110
108
  }
111
109
  //# sourceMappingURL=withApi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"withApi.js","sourceRoot":"","sources":["../../src/state/withApi.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,aAAa,EAAwB,cAAc,EAAE,MAAM,eAAe,CAAC;AACvH,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAYjE,qDAAqD;AACrD,IAAI,YAAY,GAAG,MAAM,CAAC;AAE1B,MAAM,cAAc,GAAa,CAAC,KAAK,EAAE,EAAE,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAS1E,MAAM,yBAA6B,SAAQ,KAAK,CAAC,SAA4C;IAA7F;;QAGU,YAAO,GAAG,CAAC,EAAe,EAAE,EAAE;YACpC,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;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AC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC;IAE5F,MAAM,OAAO,GAAqB,CAAC,KAAK,EAAE,EAAE,CAAC,CAC3C,oBAAC,YAAY,oBAAK,UAAU,EAAM,KAAK;QACrC,oBAAC,aAAa,oBAAK,UAAU,EAAM,KAAK,IAAE,SAAS,EAAE,SAAS,KAC3D,KAAK,CAAC,QAAQ,CACD,CACH,CAChB,CAAC;IAEF,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QAC9B,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,6CAA6C,CAAC,CAAC;QACtE,2CAA2C;QAC3C,SAAS,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;KACxB;IAED,OAAO,aAAa,CAAS,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AAC3E,CAAC"}
@@ -1,12 +1,12 @@
1
1
  import type { ReactElement } from 'react';
2
2
  import type { RouteComponentProps } from 'react-router';
3
- import type { PiletApi, Pilet, PiletMetadata, EventEmitter, SinglePilet, MultiPilet } from 'piral-base';
3
+ import type { PiletApi, Pilet, PiletEntry, PiletEntries, PiletMetadata, EventEmitter, PiletLoader, PiletLoadingStrategy } from 'piral-base';
4
4
  import type { PiletCustomApi, PiralCustomPageMeta } from './custom';
5
5
  import type { AnyComponent } from './components';
6
6
  import type { ExtensionSlotProps, PiralExtensionSlotMap } from './extension';
7
7
  import type { SharedData, DataStoreOptions } from './data';
8
8
  import type { Disposable } from './utils';
9
- export { PiletApi, Pilet, PiletMetadata, EventEmitter, SinglePilet, MultiPilet };
9
+ export { PiletApi, Pilet, PiletMetadata, EventEmitter, PiletEntry, PiletEntries, PiletLoader, PiletLoadingStrategy };
10
10
  /**
11
11
  * The props that every registered component obtains.
12
12
  */
@@ -34,6 +34,11 @@ export interface ExtensionComponentProps<T> extends BaseComponentProps {
34
34
  */
35
35
  params: T extends keyof PiralExtensionSlotMap ? PiralExtensionSlotMap[T] : T extends string ? any : T;
36
36
  }
37
+ /**
38
+ * The meta data registered for a page.
39
+ */
40
+ export interface PiralPageMeta extends PiralCustomPageMeta {
41
+ }
37
42
  /**
38
43
  * The props that every registered page component obtains.
39
44
  */
@@ -43,11 +48,10 @@ export interface RouteBaseProps<UrlParams = any, UrlState = any> extends RouteCo
43
48
  * The props used by a page component.
44
49
  */
45
50
  export interface PageComponentProps<T = any, S = any> extends RouteBaseProps<T, S> {
46
- }
47
- /**
48
- * The meta data registered for a page.
49
- */
50
- export interface PiralPageMeta extends PiralCustomPageMeta {
51
+ /**
52
+ * The meta data registered with the page.
53
+ */
54
+ meta: PiralPageMeta;
51
55
  }
52
56
  /**
53
57
  * Defines the Pilet API from piral-core.
@@ -111,7 +115,7 @@ export interface PiletCoreApi {
111
115
  */
112
116
  renderHtmlExtension<TName>(element: HTMLElement | ShadowRoot, props: ExtensionSlotProps<TName>): Disposable;
113
117
  }
114
- declare module 'piral-base/lib/types' {
118
+ declare module 'piral-base/lib/types/runtime' {
115
119
  interface PiletApi extends PiletCustomApi, PiletCoreApi {
116
120
  }
117
121
  }
@@ -6,7 +6,7 @@ import type { Dict, Without } from './common';
6
6
  import type { LayoutType } from './layout';
7
7
  import type { SharedDataItem, DataStoreTarget } from './data';
8
8
  import type { PiralCustomActions, PiralCustomState, PiralCustomRegistryState, PiralCustomComponentsState } from './custom';
9
- import type { PiletMetadata, EventEmitter, Pilet, BaseComponentProps, PageComponentProps, ExtensionComponentProps, PiletsBag, PiralPageMeta } from './api';
9
+ import type { EventEmitter, Pilet, BaseComponentProps, PageComponentProps, ExtensionComponentProps, PiletsBag, PiralPageMeta, PiletEntry } from './api';
10
10
  import type { ComponentConverters, LoadingIndicatorProps, ErrorInfoProps, RouterProps, LayoutProps, Errors } from './components';
11
11
  export interface StateDispatcher<TState> {
12
12
  (state: TState): Partial<TState>;
@@ -130,7 +130,7 @@ export interface GlobalState extends PiralCustomState {
130
130
  /**
131
131
  * Gets the loaded modules.
132
132
  */
133
- modules: Array<PiletMetadata>;
133
+ modules: Array<Pilet>;
134
134
  /**
135
135
  * The foreign component portals to render.
136
136
  */
@@ -172,10 +172,20 @@ export interface PiralActions extends PiralCustomActions {
172
172
  */
173
173
  initialize(loading: boolean, error: Error | undefined, modules: Array<Pilet>): void;
174
174
  /**
175
- * Injects a pilet at runtime - removes the pilet from registry first if available.
175
+ * Injects an evaluated pilet at runtime - removes the pilet from registry first if available.
176
176
  * @param pilet The pilet to be injected.
177
177
  */
178
178
  injectPilet(pilet: Pilet): void;
179
+ /**
180
+ * Adds a pilet at runtime by loading it, evaluating it, and then injecting it.
181
+ * @param pilet The pilet to be added.
182
+ */
183
+ addPilet(pilet: PiletEntry): void;
184
+ /**
185
+ * Removes a pilet by unloading it and deleting all component registrations.
186
+ * @param name The name of the pilet to remove.
187
+ */
188
+ removePilet(name: string): void;
179
189
  /**
180
190
  * Defines a single action for Piral.
181
191
  * @param actionName The name of the action to define.
@@ -55,7 +55,7 @@ export interface PiralStoreDataEvent<TValue = any> {
55
55
  */
56
56
  expires: number;
57
57
  }
58
- declare module 'piral-base/lib/types' {
58
+ declare module 'piral-base/lib/types/api' {
59
59
  interface PiralEventMap extends PiralCustomEventMap {
60
60
  'store-data': PiralStoreDataEvent;
61
61
  }