piral-core 0.15.0-alpha.3589 → 0.15.0-alpha.3711

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 (87) hide show
  1. package/debug.codegen +24 -0
  2. package/debug.codegen.d.ts +11 -0
  3. package/dependencies.codegen +6 -4
  4. package/dependencies.codegen.d.ts +1 -0
  5. package/dependencies.codegen.native.js +1 -1
  6. package/esm/RootListener.js +1 -1
  7. package/esm/RootListener.js.map +1 -1
  8. package/esm/components/ErrorBoundary.js +2 -1
  9. package/esm/components/ErrorBoundary.js.map +1 -1
  10. package/esm/components/ExtensionSlot.js +20 -2
  11. package/esm/components/ExtensionSlot.js.map +1 -1
  12. package/esm/components/ForeignComponentContainer.d.ts +19 -0
  13. package/esm/components/ForeignComponentContainer.js +52 -0
  14. package/esm/components/ForeignComponentContainer.js.map +1 -0
  15. package/esm/components/index.d.ts +1 -0
  16. package/esm/components/index.js +1 -0
  17. package/esm/components/index.js.map +1 -1
  18. package/esm/components/wrapComponent.d.ts +7 -0
  19. package/esm/components/wrapComponent.js +42 -0
  20. package/esm/components/wrapComponent.js.map +1 -0
  21. package/esm/createInstance.js +1 -1
  22. package/esm/createInstance.js.map +1 -1
  23. package/esm/debugger.d.ts +1 -1
  24. package/esm/debugger.js +1 -1
  25. package/esm/debugger.js.map +1 -1
  26. package/esm/emulator.d.ts +1 -1
  27. package/esm/emulator.js +1 -1
  28. package/esm/emulator.js.map +1 -1
  29. package/esm/helpers.d.ts +1 -1
  30. package/esm/helpers.js +3 -10
  31. package/esm/helpers.js.map +1 -1
  32. package/esm/modules/dependencies.js +3 -23
  33. package/esm/modules/dependencies.js.map +1 -1
  34. package/esm/state/withApi.js +8 -92
  35. package/esm/state/withApi.js.map +1 -1
  36. package/esm/types/api.d.ts +2 -2
  37. package/esm/types/components.d.ts +12 -0
  38. package/esm/types/extension.d.ts +5 -1
  39. package/lib/RootListener.js +2 -2
  40. package/lib/RootListener.js.map +1 -1
  41. package/lib/components/ErrorBoundary.js +2 -1
  42. package/lib/components/ErrorBoundary.js.map +1 -1
  43. package/lib/components/ExtensionSlot.js +19 -1
  44. package/lib/components/ExtensionSlot.js.map +1 -1
  45. package/lib/components/ForeignComponentContainer.d.ts +19 -0
  46. package/lib/components/ForeignComponentContainer.js +56 -0
  47. package/lib/components/ForeignComponentContainer.js.map +1 -0
  48. package/lib/components/index.d.ts +1 -0
  49. package/lib/components/index.js +1 -0
  50. package/lib/components/index.js.map +1 -1
  51. package/lib/components/wrapComponent.d.ts +7 -0
  52. package/lib/components/wrapComponent.js +46 -0
  53. package/lib/components/wrapComponent.js.map +1 -0
  54. package/lib/createInstance.js +1 -1
  55. package/lib/createInstance.js.map +1 -1
  56. package/lib/debugger.d.ts +1 -1
  57. package/lib/debugger.js +3 -3
  58. package/lib/debugger.js.map +1 -1
  59. package/lib/emulator.d.ts +1 -1
  60. package/lib/emulator.js +3 -3
  61. package/lib/emulator.js.map +1 -1
  62. package/lib/helpers.d.ts +1 -1
  63. package/lib/helpers.js +3 -10
  64. package/lib/helpers.js.map +1 -1
  65. package/lib/modules/dependencies.js +3 -23
  66. package/lib/modules/dependencies.js.map +1 -1
  67. package/lib/state/withApi.js +7 -91
  68. package/lib/state/withApi.js.map +1 -1
  69. package/lib/types/api.d.ts +2 -2
  70. package/lib/types/components.d.ts +12 -0
  71. package/lib/types/extension.d.ts +5 -1
  72. package/package.json +8 -5
  73. package/src/RootListener.tsx +1 -1
  74. package/src/components/ErrorBoundary.tsx +2 -1
  75. package/src/components/ExtensionSlot.tsx +25 -3
  76. package/src/components/ForeignComponentContainer.tsx +69 -0
  77. package/src/components/index.ts +1 -0
  78. package/src/components/wrapComponent.tsx +74 -0
  79. package/src/createInstance.tsx +1 -1
  80. package/src/debugger.ts +1 -1
  81. package/src/emulator.ts +1 -1
  82. package/src/helpers.tsx +4 -12
  83. package/src/modules/dependencies.ts +3 -22
  84. package/src/state/withApi.tsx +21 -156
  85. package/src/types/api.ts +2 -2
  86. package/src/types/components.ts +12 -0
  87. package/src/types/extension.ts +12 -3
package/debug.codegen ADDED
@@ -0,0 +1,24 @@
1
+ module.exports = function () {
2
+ const imports = [];
3
+ const exports = [];
4
+
5
+ // if we build the debug version of piral (debug and emulator build)
6
+ if (process.env.DEBUG_PIRAL) {
7
+ imports.push('import { integrateDebugger } from "./esm/debugger"');
8
+ exports.push(`export { integrateDebugger }`);
9
+ } else {
10
+ exports.push(`export function integrateDebugger() {}`);
11
+ }
12
+
13
+ // if we build the emulator version of piral (shipped to pilets)
14
+ if (process.env.DEBUG_PILET) {
15
+ imports.push('import { integrateEmulator } from "./esm/debugger"');
16
+ exports.push(`export { integrateEmulator }`);
17
+ } else {
18
+ exports.push(`export function integrateEmulator() {}`);
19
+ }
20
+
21
+ return `${imports.join(';\n')}
22
+ ${exports.join('\n')}
23
+ `;
24
+ };
@@ -0,0 +1,11 @@
1
+ import type { LoadPiletsOptions } from 'prial-base';
2
+ import type { DebuggerExtensionOptions } from 'piral-debug-utils';
3
+ import type { GlobalStateContext } from './src/types';
4
+
5
+ export function integrateDebugger(
6
+ context: GlobalStateContext,
7
+ options: LoadPiletsOptions,
8
+ debug?: DebuggerExtensionOptions,
9
+ ): void;
10
+
11
+ export function integrateEmulator(context: GlobalStateContext, options, debug?: DebuggerExtensionOptions): void;
@@ -16,6 +16,7 @@ module.exports = function () {
16
16
  const appName = process.env.BUILD_PCKG_NAME || '';
17
17
  const externals = (process.env.SHARED_DEPENDENCIES || '').split(',').filter(Boolean);
18
18
  const assignments = [];
19
+ const imports = [];
19
20
 
20
21
  if (appName) {
21
22
  assignments.push(`deps['${appName}']={}`);
@@ -23,13 +24,14 @@ module.exports = function () {
23
24
 
24
25
  for (const name of externals) {
25
26
  const identifiers = getIdentifiers(name);
27
+ const ref = `_${imports.length}`;
28
+ imports.push(`import * as ${ref} from ${JSON.stringify(name)}`);
26
29
 
27
30
  for (const id of identifiers) {
28
- assignments.push(`deps[${JSON.stringify(id)}]=require(${JSON.stringify(name)})`);
31
+ assignments.push(`deps[${JSON.stringify(id)}]=${ref}`);
29
32
  }
30
33
  }
31
34
 
32
- return `module.exports = function(deps){
33
- ${assignments.join(';')}
34
- }`;
35
+ return `${imports.join(';\n')}
36
+ export default function(deps) {${assignments.join(';')}}`;
35
37
  };
@@ -0,0 +1 @@
1
+ export default function (deps: Record<string, any>): void;
@@ -1,2 +1,2 @@
1
1
  // required for piral-native; otherwise non-essential
2
- module.exports = function() {};
2
+ export default function() {};
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { useGlobalStateContext } from '.';
2
+ import { useGlobalStateContext } from './hooks';
3
3
  import { renderElement } from './modules';
4
4
  export const RootListener = () => {
5
5
  const context = useGlobalStateContext();
@@ -1 +1 @@
1
- {"version":3,"file":"RootListener.js","sourceRoot":"","sources":["../src/RootListener.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,GAAG,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,CAAC,MAAM,YAAY,GAAa,GAAG,EAAE;IACzC,MAAM,OAAO,GAAG,qBAAqB,EAAE,CAAC;IAExC,KAAK,CAAC,eAAe,CAAC,GAAG,EAAE;QACzB,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;YACnC,MAAM,OAAO,GAAG,CAAC,EAAe,EAAE,EAAE;gBAClC,EAAE,CAAC,eAAe,EAAE,CAAC;gBACrB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC;gBACpC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;gBAChE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;gBACzB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;YACzB,CAAC,CAA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AAa,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;YACnE,CAAC,CAAC;SACH;IACH,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
@@ -24,7 +24,8 @@ export class ErrorBoundary extends React.Component {
24
24
  const { error } = this.state;
25
25
  const rest = renderProps;
26
26
  if (error) {
27
- return React.createElement(PiralError, Object.assign({ type: errorType, error: error }, rest));
27
+ const pilet = piral.meta.name;
28
+ return React.createElement(PiralError, Object.assign({ type: errorType, error: error, pilet: pilet }, rest));
28
29
  }
29
30
  return React.createElement(React.Suspense, { fallback: React.createElement(PiralLoadingIndicator, null) }, children);
30
31
  }
@@ -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,UAAU,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAqBjE;;GAEG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK,CAAC,SAAiD;IAA1F;;QACE,UAAK,GAAG;YACN,KAAK,EAAE,SAAS;SACjB,CAAC;IAuBJ,CAAC;IArBC,iBAAiB,CAAC,KAAY;QAC5B,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACxC,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QAC9B,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,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,C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GAAQ,WAAW,CAAC;QAE9B,IAAI,KAAK,EAAE;YACT,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9B,OAAO,oBAAC,UAAU,kBAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,IAAM,IAAI,EAAI,CAAC;SAC9E;QAED,OAAO,oBAAC,KAAK,CAAC,QAAQ,IAAC,QAAQ,EAAE,oBAAC,qBAAqB,OAAG,IAAG,QAAQ,CAAkB,CAAC;IAC1F,CAAC;CACF"}
@@ -1,7 +1,25 @@
1
1
  import * as React from 'react';
2
2
  import { isfunc } from 'piral-base';
3
- import { useGlobalState } from '../hooks';
3
+ import { wrapComponent } from './wrapComponent';
4
+ import { useGlobalState, useGlobalStateContext } from '../hooks';
4
5
  import { defaultRender, none } from '../utils';
6
+ const renderExtensions = [
7
+ {
8
+ component: (props) => {
9
+ const context = useGlobalStateContext();
10
+ const converters = context.converters;
11
+ const piral = context.apis._;
12
+ const { component, props: args } = props.params;
13
+ const Component = React.useMemo(() => wrapComponent(converters, component, { piral }, defaultRender), [component]);
14
+ return React.createElement(Component, Object.assign({}, args));
15
+ },
16
+ defaults: {},
17
+ pilet: '',
18
+ reference: {
19
+ displayName: 'RenderExtension',
20
+ },
21
+ },
22
+ ];
5
23
  /**
6
24
  * The extension slot component to be used when the available
7
25
  * extensions of a given name should be rendered at a specific
@@ -9,7 +27,7 @@ import { defaultRender, none } from '../utils';
9
27
  */
10
28
  export function ExtensionSlot(props) {
11
29
  const { name, render = defaultRender, empty, params, children } = props;
12
- const extensions = useGlobalState((s) => s.registry.extensions[name] || none);
30
+ const extensions = useGlobalState((s) => (name ? s.registry.extensions[name] || none : renderExtensions));
13
31
  return render(extensions.length === 0 && isfunc(empty)
14
32
  ? [defaultRender(empty(), 'empty')]
15
33
  : extensions.map(({ component: Component, reference, defaults = {} }, i) => (React.createElement(Component, { key: `${(reference === null || reference === void 0 ? void 0 : reference.displayName) || '_'}${i}`, children: children, params: Object.assign(Object.assign({}, defaults), (params || {})) }))));
@@ -1 +1 @@
1
- {"version":3,"file":"ExtensionSlot.js","sourceRoot":"","sources":["../../src/components/ExtensionSlot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAG/C;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAmB,KAA4B;IAC1E,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IACxE,MAAM,UAAU,GAAG,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC;IAC9E,OAAO,MAAM,CACX,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC;QACtC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;QACnC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CACxE,oBAAC,SAAS,IACR,GAAG,EAAE,GAAG,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,WAAW,KAAI,GAAG,GAAG,CAAC,EAAE,EAC3C,QAAQ,EAAE,QAAQ,EAClB,MAAM,kCACD,QAAQ,GACR,CAAC,MAAM,IAAI,EAAE,CAAC,IAEnB,CACH,CAAC,CACP,CAAC;AACJ,CAAC;AAED,aAAa,CAAC,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CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC;IAC1G,OAAO,MAAM,CACX,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC;QACtC,CAAC,CAAC,CAAC,aAAa,CAAC,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;QACnC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CACxE,oBAAC,SAAS,IACR,GAAG,EAAE,GAAG,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,WAAW,KAAI,GAAG,GAAG,CAAC,EAAE,EAC3C,QAAQ,EAAE,QAAQ,EAClB,MAAM,kCACD,QAAQ,GACR,CAAC,MAAM,IAAI,EAAE,CAAC,IAEnB,CACH,CAAC,CACP,CAAC;AACJ,CAAC;AAED,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC"}
@@ -0,0 +1,19 @@
1
+ import * as React from 'react';
2
+ import { ForeignComponent, BaseComponentProps, ComponentContext } from '../types';
3
+ interface ForeignComponentContainerProps<T> {
4
+ $portalId: string;
5
+ $component: ForeignComponent<T>;
6
+ $context: ComponentContext;
7
+ innerProps: T & BaseComponentProps;
8
+ }
9
+ export declare class ForeignComponentContainer<T> extends React.Component<ForeignComponentContainerProps<T>> {
10
+ private current?;
11
+ private previous?;
12
+ private handler;
13
+ private setNode;
14
+ componentDidMount(): void;
15
+ componentDidUpdate(): void;
16
+ componentWillUnmount(): void;
17
+ render(): JSX.Element;
18
+ }
19
+ export {};
@@ -0,0 +1,52 @@
1
+ import * as React from 'react';
2
+ import { isfunc } from 'piral-base';
3
+ export class ForeignComponentContainer extends React.Component {
4
+ constructor() {
5
+ super(...arguments);
6
+ this.handler = (ev) => {
7
+ const { innerProps } = this.props;
8
+ ev.stopPropagation();
9
+ innerProps.piral.renderHtmlExtension(ev.detail.target, ev.detail.props);
10
+ };
11
+ this.setNode = (node) => {
12
+ this.current = node;
13
+ };
14
+ }
15
+ componentDidMount() {
16
+ const node = this.current;
17
+ const { $component, $context, innerProps } = this.props;
18
+ const { mount } = $component;
19
+ if (node && isfunc(mount)) {
20
+ mount(node, innerProps, $context);
21
+ node.addEventListener('render-html', this.handler, false);
22
+ }
23
+ this.previous = node;
24
+ }
25
+ componentDidUpdate() {
26
+ const { current, previous } = this;
27
+ const { $component, $context, innerProps } = this.props;
28
+ const { update } = $component;
29
+ if (current !== previous) {
30
+ previous && this.componentWillUnmount();
31
+ current && this.componentDidMount();
32
+ }
33
+ else if (isfunc(update)) {
34
+ update(current, innerProps, $context);
35
+ }
36
+ }
37
+ componentWillUnmount() {
38
+ const node = this.previous;
39
+ const { $component } = this.props;
40
+ const { unmount } = $component;
41
+ if (node && isfunc(unmount)) {
42
+ unmount(node);
43
+ node.removeEventListener('render-html', this.handler, false);
44
+ }
45
+ this.previous = undefined;
46
+ }
47
+ render() {
48
+ const { $portalId } = this.props;
49
+ return React.createElement("div", { "data-portal-id": $portalId, ref: this.setNode });
50
+ }
51
+ }
52
+ //# sourceMappingURL=ForeignComponentContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ForeignComponentContainer.js","sourceRoot":"","sources":["../../src/components/ForeignComponentContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAWpC,MAAM,OAAO,yBAA6B,SAAQ,KAAK,CAAC,SAA4C;IAApG;;QAGU,YAAO,GAAG,CAAC,EAAe,EAAE,EAAE;YACpC,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;Y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IAED,oBAAoB;QAClB,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC3B,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAClC,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;QAE/B,IAAI,IAAI,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE;YAC3B,OAAO,CAAC,IAAI,CAAC,CAAC;YACd,IAAI,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;SAC9D;QAED,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;IAC5B,CAAC;IAED,MAAM;QACJ,MAAM,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QACjC,OAAO,+CAAqB,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,OAAO,GAAI,CAAC;IAC/D,CAAC;CACF"}
@@ -18,3 +18,4 @@ export * from './SetProvider';
18
18
  export * from './SetRedirect';
19
19
  export * from './SetRoute';
20
20
  export * from './SwitchErrorInfo';
21
+ export * from './wrapComponent';
@@ -18,4 +18,5 @@ export * from './SetProvider';
18
18
  export * from './SetRedirect';
19
19
  export * from './SetRoute';
20
20
  export * from './SwitchErrorInfo';
21
+ export * from './wrapComponent';
21
22
  //# sourceMappingURL=index.js.map
@@ -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"}
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"}
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import { AnyComponent, ComponentConverters, PiletApi, BaseComponentProps } from '../types';
3
+ interface CapturedProps {
4
+ piral: PiletApi;
5
+ }
6
+ export declare function wrapComponent<T>(converters: ComponentConverters<T & BaseComponentProps>, component: AnyComponent<T & BaseComponentProps>, captured: CapturedProps, Wrapper: React.FC<T>): React.MemoExoticComponent<(props: T) => JSX.Element> | React.ComponentType<T>;
7
+ export {};
@@ -0,0 +1,42 @@
1
+ import * as React from 'react';
2
+ import { __RouterContext } from 'react-router';
3
+ import { PortalRenderer } from './PortalRenderer';
4
+ import { ForeignComponentContainer } from './ForeignComponentContainer';
5
+ import { useGlobalStateContext } from '../hooks';
6
+ import { convertComponent, none } from '../utils';
7
+ // this is an arbitrary start number to have 6 digits
8
+ let portalIdBase = 123456;
9
+ function wrapReactComponent(Component, captured, Wrapper) {
10
+ return (props) => (React.createElement(Wrapper, Object.assign({}, props),
11
+ React.createElement(Component, Object.assign({}, props, captured))));
12
+ }
13
+ function wrapForeignComponent(component, captured, Wrapper) {
14
+ return React.memo((props) => {
15
+ const { state, readState, destroyPortal } = useGlobalStateContext();
16
+ const router = React.useContext(__RouterContext);
17
+ const id = React.useMemo(() => (portalIdBase++).toString(26), none);
18
+ const context = React.useMemo(() => ({ router, state, readState }), [router, state]);
19
+ const innerProps = React.useMemo(() => (Object.assign(Object.assign({}, props), captured)), [props]);
20
+ React.useEffect(() => () => destroyPortal(id), none);
21
+ return (React.createElement(Wrapper, Object.assign({}, props),
22
+ React.createElement(PortalRenderer, { id: id }),
23
+ React.createElement(ForeignComponentContainer, { innerProps: innerProps, "$portalId": id, "$component": component, "$context": context })));
24
+ });
25
+ }
26
+ function isNotExotic(component) {
27
+ return !component.$$typeof;
28
+ }
29
+ export function wrapComponent(converters, component, captured, Wrapper) {
30
+ if (!component) {
31
+ const pilet = captured.piral.meta.name;
32
+ console.error(`[${pilet}] The given value is not a valid component.`);
33
+ // tslint:disable-next-line:no-null-keyword
34
+ component = () => null;
35
+ }
36
+ if (typeof component === 'object' && isNotExotic(component)) {
37
+ const result = convertComponent(converters[component.type], component);
38
+ return wrapForeignComponent(result, captured, Wrapper);
39
+ }
40
+ return wrapReactComponent(component, captured, Wrapper);
41
+ }
42
+ //# sourceMappingURL=wrapComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapComponent.js","sourceRoot":"","sources":["../../src/components/wrapComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE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G,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;QAErD,OAAO,CACL,oBAAC,OAAO,oBAAK,KAAK;YAChB,oBAAC,cAAc,IAAC,EAAE,EAAE,EAAE,GAAI;YAC1B,oBAAC,yBAAyB,IAAC,UAAU,EAAE,UAAU,eAAa,EAAE,gBAAc,SAAS,cAAY,OAAO,GAAI,CACtG,CACX,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,WAAW,CAAC,SAAc;IACjC,OAAO,CAAE,SAAmC,CAAC,QAAQ,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,UAAuD,EACvD,SAA+C,EAC/C,QAAuB,EACvB,OAAoB;IAEpB,IAAI,CAAC,SAAS,EAAE;QACd,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QACvC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,6CAA6C,CAAC,CAAC;QACtE,2CAA2C;QAC3C,SAAS,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;KACxB;IAED,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,WAAW,CAAC,SAAS,CAAC,EAAE;QAC3D,MAAM,MAAM,GAAG,gBAAgB,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,CAAC;QACvE,OAAO,oBAAoB,CAAI,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;KAC3D;IAED,OAAO,kBAAkB,CAAI,SAAS,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC7D,CAAC"}
@@ -33,7 +33,7 @@ export function createInstance(config = {}) {
33
33
  const usedPlugins = Array.isArray(definedPlugins) ? definedPlugins : [definedPlugins];
34
34
  const createApi = apiFactory(context, usedPlugins);
35
35
  const root = createApi({
36
- name: 'root',
36
+ name: '_',
37
37
  version: process.env.BUILD_PCKG_VERSION || '1.0.0',
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AAQ,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,gBAAgB;QAC5E,aAAa;QACb,KAAK;KACN,CAAC,CAAC;IAEH,IAAI,OAAO,EAAE;QACX,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;KAClC;IAED,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAE1B,OAAO,QAAQ,CAAC,MAAM,EAAE;QACtB,EAAE;QACF,SAAS;QACT,OAAO;QACP,IAAI;QACJ,OAAO;KACR,CAAC,CAAC;AACL,CAAC"}
package/esm/debugger.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { LoadPiletsOptions } from 'piral-base';
2
2
  import { DebuggerExtensionOptions } from 'piral-debug-utils';
3
3
  import { GlobalStateContext } from './types';
4
- export declare function integrate(context: GlobalStateContext, options: LoadPiletsOptions, debug?: DebuggerExtensionOptions): void;
4
+ export declare function integrateDebugger(context: GlobalStateContext, options: LoadPiletsOptions, debug?: DebuggerExtensionOptions): void;
package/esm/debugger.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { addChangeHandler } from '@dbeining/react-atom';
2
2
  import { installPiralDebug } from 'piral-debug-utils';
3
- export function integrate(context, options, debug = {}) {
3
+ export function integrateDebugger(context, options, debug = {}) {
4
4
  installPiralDebug(Object.assign(Object.assign({}, debug), { addPilet: context.addPilet, removePilet: context.removePilet, updatePilet(pilet) {
5
5
  if (!pilet.disabled) {
6
6
  const { createApi } = options;
@@ -1 +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,QAAk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,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"}
package/esm/emulator.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { LoadPiletsOptions } from 'piral-base';
2
2
  import { GlobalStateContext } from './types';
3
- export declare function integrate(context: GlobalStateContext, options: LoadPiletsOptions): void;
3
+ export declare function integrateEmulator(context: GlobalStateContext, options: LoadPiletsOptions): void;
package/esm/emulator.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { withEmulatorPilets } from 'piral-debug-utils';
2
- export function integrate(context, options) {
2
+ export function integrateEmulator(context, options) {
3
3
  options.fetchPilets = withEmulatorPilets(options.fetchPilets, {
4
4
  addPilet: context.addPilet,
5
5
  removePilet: context.removePilet,
@@ -1 +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"}
1
+ {"version":3,"file":"emulator.js","sourceRoot":"","sources":["../src/emulator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD,MAAM,UAAU,iBAAiB,CAAC,OAA2B,EAAE,OAA0B;IACvF,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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { PiletApiCreator, LoadPiletsOptions, CustomSpecLoaders, DefaultLoaderConfig, PiletLoader, PiletLifecycleHooks } from 'piral-base';
2
- import { DebuggerExtensionOptions } from 'piral-debug-utils';
2
+ import type { DebuggerExtensionOptions } from 'piral-debug-utils';
3
3
  import type { Pilet, PiletRequester, GlobalStateContext, PiletLoadingStrategy, DependencySelector } from './types';
4
4
  export interface PiletOptionsConfig {
5
5
  context: GlobalStateContext;
package/esm/helpers.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { getDefaultLoader, extendLoader, } from 'piral-base';
2
2
  import { globalDependencies } from './modules';
3
+ import { integrateDebugger, integrateEmulator } from '../debug.codegen';
3
4
  export function createPiletOptions({ hooks, context, loaders, loaderConfig, availablePilets, strategy, createApi, loadPilet, requestPilets, shareDependencies, debug, }) {
4
5
  const options = {
5
6
  config: loaderConfig,
@@ -11,16 +12,8 @@ export function createPiletOptions({ hooks, context, loaders, loaderConfig, avai
11
12
  hooks,
12
13
  dependencies: shareDependencies(globalDependencies),
13
14
  };
14
- // if we build the debug version of piral (debug and emulator build)
15
- if (process.env.DEBUG_PIRAL) {
16
- const { integrate } = require('./debugger');
17
- integrate(context, options, debug);
18
- }
19
- // if we build the emulator version of piral (shipped to pilets)
20
- if (process.env.DEBUG_PILET) {
21
- const { integrate } = require('./emulator');
22
- integrate(context, options);
23
- }
15
+ integrateDebugger(context, options, debug);
16
+ integrateEmulator(context, options, debug);
24
17
  return options;
25
18
  }
26
19
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKL,gBAAgB,EAChB,YAAY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AAU,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,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC3C,iBAAiB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAE3C,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,32 +1,12 @@
1
1
  import { isfunc } from 'piral-base';
2
- import { __assign } from 'tslib';
2
+ import fillDependencies from '../../dependencies.codegen';
3
3
  /**
4
4
  * The global dependencies, which represent the dependencies
5
5
  * shared from the app shell itself.
6
6
  */
7
7
  export const globalDependencies = {};
8
- if (process.env.SHARED_DEPENDENCIES) {
9
- const fillDependencies = require('../../dependencies.codegen');
10
- if (isfunc(fillDependencies)) {
11
- fillDependencies(globalDependencies);
12
- }
13
- else {
14
- // fall back to the default list if the codegen is invalid / not supported
15
- __assign(globalDependencies, {
16
- react: require('react'),
17
- 'react-dom': require('react-dom'),
18
- 'react-router': require('react-router'),
19
- 'react-router-dom': require('react-router-dom'),
20
- history: require('history'),
21
- tslib: require('tslib'),
22
- 'path-to-regexp': require('path-to-regexp'),
23
- '@libre/atom': require('@libre/atom'),
24
- '@dbeining/react-atom': require('@dbeining/react-atom'),
25
- });
26
- }
27
- }
28
- else {
29
- // App shell is built with something else than the Piral CLI - just don't fill ...
8
+ if (isfunc(fillDependencies)) {
9
+ fillDependencies(globalDependencies);
30
10
  }
31
11
  /**
32
12
  * The default dependency selector, which just returns the provided
@@ -1 +1 @@
1
- {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjC;;;GAGG;AACH,MAAM,CAAC,MAAM,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
+ {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEpC,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA0B,EAAE,CAAC;AAE5D,IAAI,MAAM,CAAC,gBAAgB,CAAC,EAAE;IAC5B,gBAAgB,CAAC,kBAAkB,CAAC,CAAC;CACtC;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,88 +1,7 @@
1
1
  import * as React from 'react';
2
- import { isfunc } from 'piral-base';
3
- import { __RouterContext } from 'react-router';
4
- import { ErrorBoundary, PortalRenderer } from '../components';
5
- import { useGlobalStateContext } from '../hooks';
6
- import { defaultRender, convertComponent, none } from '../utils';
7
- // this is an arbitrary start number to have 6 digits
8
- let portalIdBase = 123456;
2
+ import { ErrorBoundary, wrapComponent } from '../components';
3
+ import { defaultRender } from '../utils';
9
4
  const DefaultWrapper = (props) => defaultRender(props.children);
10
- class ForeignComponentContainer extends React.Component {
11
- constructor() {
12
- super(...arguments);
13
- this.handler = (ev) => {
14
- const { innerProps } = this.props;
15
- ev.stopPropagation();
16
- innerProps.piral.renderHtmlExtension(ev.detail.target, ev.detail.props);
17
- };
18
- this.setNode = (node) => {
19
- this.current = node;
20
- };
21
- }
22
- componentDidMount() {
23
- const node = this.current;
24
- const { $component, $context, innerProps } = this.props;
25
- const { mount } = $component;
26
- if (node && isfunc(mount)) {
27
- mount(node, innerProps, $context);
28
- node.addEventListener('render-html', this.handler, false);
29
- }
30
- this.previous = node;
31
- }
32
- componentDidUpdate() {
33
- const { current, previous } = this;
34
- const { $component, $context, innerProps } = this.props;
35
- const { update } = $component;
36
- if (current !== previous) {
37
- previous && this.componentWillUnmount();
38
- current && this.componentDidMount();
39
- }
40
- else if (isfunc(update)) {
41
- update(current, innerProps, $context);
42
- }
43
- }
44
- componentWillUnmount() {
45
- const node = this.previous;
46
- const { $component } = this.props;
47
- const { unmount } = $component;
48
- if (node && isfunc(unmount)) {
49
- unmount(node);
50
- node.removeEventListener('render-html', this.handler, false);
51
- }
52
- this.previous = undefined;
53
- }
54
- render() {
55
- const { $portalId } = this.props;
56
- return React.createElement("div", { "data-portal-id": $portalId, ref: this.setNode });
57
- }
58
- }
59
- function wrapReactComponent(Component, captured, Wrapper) {
60
- return (props) => (React.createElement(Wrapper, Object.assign({}, props),
61
- React.createElement(Component, Object.assign({}, props, captured))));
62
- }
63
- function wrapForeignComponent(component, captured, Wrapper) {
64
- return React.memo((props) => {
65
- const { state, readState, destroyPortal } = useGlobalStateContext();
66
- const router = React.useContext(__RouterContext);
67
- const id = React.useMemo(() => (portalIdBase++).toString(26), none);
68
- const context = React.useMemo(() => ({ router, state, readState }), [router, state]);
69
- const innerProps = React.useMemo(() => (Object.assign(Object.assign({}, props), captured)), [props]);
70
- React.useEffect(() => () => destroyPortal(id), none);
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 })));
74
- });
75
- }
76
- function isNotExotic(component) {
77
- return !component.$$typeof;
78
- }
79
- function wrapComponent(converters, component, captured, Wrapper) {
80
- if (typeof component === 'object' && isNotExotic(component)) {
81
- const result = convertComponent(converters[component.type], component);
82
- return wrapForeignComponent(result, captured, Wrapper);
83
- }
84
- return wrapReactComponent(component, captured, Wrapper);
85
- }
86
5
  function getWrapper(wrappers, wrapperType) {
87
6
  const WrapAll = wrappers['*'];
88
7
  const WrapType = wrappers[wrapperType];
@@ -92,18 +11,15 @@ function getWrapper(wrappers, wrapperType) {
92
11
  }
93
12
  return WrapType || WrapAll || DefaultWrapper;
94
13
  }
14
+ function makeWrapper(context, outerProps, wrapperType, errorType) {
15
+ const OuterWrapper = context.readState((m) => getWrapper(m.registry.wrappers, wrapperType));
16
+ return (props) => (React.createElement(OuterWrapper, Object.assign({}, outerProps, props),
17
+ React.createElement(ErrorBoundary, Object.assign({}, outerProps, props, { errorType: errorType }), props.children)));
18
+ }
95
19
  export function withApi(context, component, piral, errorType, wrapperType = errorType, captured = {}) {
96
20
  const outerProps = Object.assign(Object.assign({}, captured), { piral });
97
21
  const converters = context.converters;
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
- }
22
+ const Wrapper = makeWrapper(context, outerProps, wrapperType, errorType);
107
23
  return wrapComponent(converters, component, outerProps, Wrapper);
108
24
  }
109
25
  //# 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,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAYjE,qDAA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