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.
- package/debug.codegen +24 -0
- package/debug.codegen.d.ts +11 -0
- package/dependencies.codegen +6 -4
- package/dependencies.codegen.d.ts +1 -0
- package/dependencies.codegen.native.js +1 -1
- package/esm/RootListener.js +1 -1
- package/esm/RootListener.js.map +1 -1
- package/esm/components/ErrorBoundary.js +2 -1
- package/esm/components/ErrorBoundary.js.map +1 -1
- package/esm/components/ExtensionSlot.js +20 -2
- package/esm/components/ExtensionSlot.js.map +1 -1
- package/esm/components/ForeignComponentContainer.d.ts +19 -0
- package/esm/components/ForeignComponentContainer.js +52 -0
- package/esm/components/ForeignComponentContainer.js.map +1 -0
- package/esm/components/index.d.ts +1 -0
- package/esm/components/index.js +1 -0
- package/esm/components/index.js.map +1 -1
- package/esm/components/wrapComponent.d.ts +7 -0
- package/esm/components/wrapComponent.js +42 -0
- package/esm/components/wrapComponent.js.map +1 -0
- package/esm/createInstance.js +1 -1
- package/esm/createInstance.js.map +1 -1
- package/esm/debugger.d.ts +1 -1
- package/esm/debugger.js +1 -1
- package/esm/debugger.js.map +1 -1
- package/esm/emulator.d.ts +1 -1
- package/esm/emulator.js +1 -1
- package/esm/emulator.js.map +1 -1
- package/esm/helpers.d.ts +1 -1
- package/esm/helpers.js +3 -10
- package/esm/helpers.js.map +1 -1
- package/esm/modules/dependencies.js +3 -23
- package/esm/modules/dependencies.js.map +1 -1
- package/esm/state/withApi.js +8 -92
- package/esm/state/withApi.js.map +1 -1
- package/esm/types/api.d.ts +2 -2
- package/esm/types/components.d.ts +12 -0
- package/esm/types/extension.d.ts +5 -1
- package/lib/RootListener.js +2 -2
- package/lib/RootListener.js.map +1 -1
- package/lib/components/ErrorBoundary.js +2 -1
- package/lib/components/ErrorBoundary.js.map +1 -1
- package/lib/components/ExtensionSlot.js +19 -1
- package/lib/components/ExtensionSlot.js.map +1 -1
- package/lib/components/ForeignComponentContainer.d.ts +19 -0
- package/lib/components/ForeignComponentContainer.js +56 -0
- package/lib/components/ForeignComponentContainer.js.map +1 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +1 -0
- package/lib/components/index.js.map +1 -1
- package/lib/components/wrapComponent.d.ts +7 -0
- package/lib/components/wrapComponent.js +46 -0
- package/lib/components/wrapComponent.js.map +1 -0
- package/lib/createInstance.js +1 -1
- package/lib/createInstance.js.map +1 -1
- package/lib/debugger.d.ts +1 -1
- package/lib/debugger.js +3 -3
- package/lib/debugger.js.map +1 -1
- package/lib/emulator.d.ts +1 -1
- package/lib/emulator.js +3 -3
- package/lib/emulator.js.map +1 -1
- package/lib/helpers.d.ts +1 -1
- package/lib/helpers.js +3 -10
- package/lib/helpers.js.map +1 -1
- package/lib/modules/dependencies.js +3 -23
- package/lib/modules/dependencies.js.map +1 -1
- package/lib/state/withApi.js +7 -91
- package/lib/state/withApi.js.map +1 -1
- package/lib/types/api.d.ts +2 -2
- package/lib/types/components.d.ts +12 -0
- package/lib/types/extension.d.ts +5 -1
- package/package.json +8 -5
- package/src/RootListener.tsx +1 -1
- package/src/components/ErrorBoundary.tsx +2 -1
- package/src/components/ExtensionSlot.tsx +25 -3
- package/src/components/ForeignComponentContainer.tsx +69 -0
- package/src/components/index.ts +1 -0
- package/src/components/wrapComponent.tsx +74 -0
- package/src/createInstance.tsx +1 -1
- package/src/debugger.ts +1 -1
- package/src/emulator.ts +1 -1
- package/src/helpers.tsx +4 -12
- package/src/modules/dependencies.ts +3 -22
- package/src/state/withApi.tsx +21 -156
- package/src/types/api.ts +2 -2
- package/src/types/components.ts +12 -0
- package/src/types/extension.ts +12 -3
package/esm/types/api.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { RouteComponentProps } from 'react-router';
|
|
|
3
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
|
-
import type { ExtensionSlotProps, PiralExtensionSlotMap } from './extension';
|
|
6
|
+
import type { ExtensionParams, ExtensionSlotProps, PiralExtensionSlotMap } from './extension';
|
|
7
7
|
import type { SharedData, DataStoreOptions } from './data';
|
|
8
8
|
import type { Disposable } from './utils';
|
|
9
9
|
export { PiletApi, Pilet, PiletMetadata, EventEmitter, PiletEntry, PiletEntries, PiletLoader, PiletLoadingStrategy };
|
|
@@ -93,7 +93,7 @@ export interface PiletCoreApi {
|
|
|
93
93
|
* @param Component The component to be rendered.
|
|
94
94
|
* @param defaults Optionally, sets the default values for the expected data.
|
|
95
95
|
*/
|
|
96
|
-
registerExtension<TName>(name: TName extends string ? TName : string, Component: AnyComponent<ExtensionComponentProps<TName>>, defaults?: TName): RegistrationDisposer;
|
|
96
|
+
registerExtension<TName>(name: TName extends string ? TName : string, Component: AnyComponent<ExtensionComponentProps<TName>>, defaults?: Partial<ExtensionParams<TName>>): RegistrationDisposer;
|
|
97
97
|
/**
|
|
98
98
|
* Unregisters a global extension component.
|
|
99
99
|
* Only previously registered extension components can be unregistered.
|
|
@@ -81,6 +81,10 @@ export interface PageErrorInfoProps extends RouteComponentProps {
|
|
|
81
81
|
* The provided error details.
|
|
82
82
|
*/
|
|
83
83
|
error: any;
|
|
84
|
+
/**
|
|
85
|
+
* The name of the pilet emitting the error.
|
|
86
|
+
*/
|
|
87
|
+
pilet?: string;
|
|
84
88
|
}
|
|
85
89
|
/**
|
|
86
90
|
* The error used when the app could not be loaded.
|
|
@@ -107,6 +111,10 @@ export interface ExtensionErrorInfoProps {
|
|
|
107
111
|
* The provided error details.
|
|
108
112
|
*/
|
|
109
113
|
error: any;
|
|
114
|
+
/**
|
|
115
|
+
* The name of the pilet emitting the error.
|
|
116
|
+
*/
|
|
117
|
+
pilet?: string;
|
|
110
118
|
}
|
|
111
119
|
/**
|
|
112
120
|
* The error used when the exact type is unknown.
|
|
@@ -120,6 +128,10 @@ export interface UnknownErrorInfoProps {
|
|
|
120
128
|
* The provided error details.
|
|
121
129
|
*/
|
|
122
130
|
error: any;
|
|
131
|
+
/**
|
|
132
|
+
* The name of the pilet emitting the error.
|
|
133
|
+
*/
|
|
134
|
+
pilet?: string;
|
|
123
135
|
}
|
|
124
136
|
/**
|
|
125
137
|
* Map of all error types to their respective props.
|
package/esm/types/extension.d.ts
CHANGED
|
@@ -32,7 +32,11 @@ export interface BaseExtensionSlotProps<TName, TParams> {
|
|
|
32
32
|
*/
|
|
33
33
|
name: TName;
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Gives the extension params shape for the given extension slot name.
|
|
37
|
+
*/
|
|
38
|
+
export declare type ExtensionParams<TName> = TName extends keyof PiralExtensionSlotMap ? PiralExtensionSlotMap[TName] : TName extends string ? any : TName;
|
|
35
39
|
/**
|
|
36
40
|
* The props for defining an extension slot.
|
|
37
41
|
*/
|
|
38
|
-
export declare type ExtensionSlotProps<
|
|
42
|
+
export declare type ExtensionSlotProps<TName = string> = BaseExtensionSlotProps<TName extends string ? TName : string, ExtensionParams<TName>>;
|
package/lib/RootListener.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RootListener = void 0;
|
|
4
4
|
const React = require("react");
|
|
5
|
-
const
|
|
5
|
+
const hooks_1 = require("./hooks");
|
|
6
6
|
const modules_1 = require("./modules");
|
|
7
7
|
const RootListener = () => {
|
|
8
|
-
const context = (0,
|
|
8
|
+
const context = (0, hooks_1.useGlobalStateContext)();
|
|
9
9
|
React.useLayoutEffect(() => {
|
|
10
10
|
if (typeof document !== 'undefined') {
|
|
11
11
|
const handler = (ev) => {
|
package/lib/RootListener.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RootListener.js","sourceRoot":"","sources":["../src/RootListener.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,
|
|
1
|
+
{"version":3,"file":"RootListener.js","sourceRoot":"","sources":["../src/RootListener.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,mCAAgD;AAChD,uCAA0C;AAEnC,MAAM,YAAY,GAAa,GAAG,EAAE;IACzC,MAAM,OAAO,GAAG,IAAA,6BAAqB,GAAE,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,IAAA,uBAAa,EAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;gBAChE,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;gBACzB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;YACzB,CAAC,CAAC;YACF,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,aAAa,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;YAE9D,OAAO,GAAG,EAAE;gBACV,QAAQ,CAAC,IAAI,CAAC,mBAAmB,CAAC,aAAa,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;AArBW,QAAA,YAAY,gBAqBvB"}
|
|
@@ -27,7 +27,8 @@ class ErrorBoundary extends React.Component {
|
|
|
27
27
|
const { error } = this.state;
|
|
28
28
|
const rest = renderProps;
|
|
29
29
|
if (error) {
|
|
30
|
-
|
|
30
|
+
const pilet = piral.meta.name;
|
|
31
|
+
return React.createElement(components_1.PiralError, Object.assign({ type: errorType, error: error, pilet: pilet }, rest));
|
|
31
32
|
}
|
|
32
33
|
return React.createElement(React.Suspense, { fallback: React.createElement(components_1.PiralLoadingIndicator, null) }, children);
|
|
33
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../src/components/ErrorBoundary.tsx"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAC/B,6CAAiE;AAqBjE;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK,CAAC,SAAiD;IAA1F;;QACE,UAAK,GAAG;YACN,KAAK,EAAE,SAAS;SACjB,CAAC;
|
|
1
|
+
{"version":3,"file":"ErrorBoundary.js","sourceRoot":"","sources":["../../src/components/ErrorBoundary.tsx"],"names":[],"mappings":";;;;AAAA,+BAA+B;AAC/B,6CAAiE;AAqBjE;;GAEG;AACH,MAAa,aAAc,SAAQ,KAAK,CAAC,SAAiD;IAA1F;;QACE,UAAK,GAAG;YACN,KAAK,EAAE,SAAS;SACjB,CAAC;IAwBJ,CAAC;IAtBC,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,2BAA5C,kCAA8C,CAAa,CAAC;QAClE,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC7B,MAAM,IAAI,GAAQ,WAAW,CAAC;QAE9B,IAAI,KAAK,EAAE;YACT,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;YAC9B,OAAO,oBAAC,uBAAU,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,kCAAqB,OAAG,IAAG,QAAQ,CAAkB,CAAC;IAC1F,CAAC;CACF;AA3BD,sCA2BC"}
|
|
@@ -3,8 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ExtensionSlot = void 0;
|
|
4
4
|
const React = require("react");
|
|
5
5
|
const piral_base_1 = require("piral-base");
|
|
6
|
+
const wrapComponent_1 = require("./wrapComponent");
|
|
6
7
|
const hooks_1 = require("../hooks");
|
|
7
8
|
const utils_1 = require("../utils");
|
|
9
|
+
const renderExtensions = [
|
|
10
|
+
{
|
|
11
|
+
component: (props) => {
|
|
12
|
+
const context = (0, hooks_1.useGlobalStateContext)();
|
|
13
|
+
const converters = context.converters;
|
|
14
|
+
const piral = context.apis._;
|
|
15
|
+
const { component, props: args } = props.params;
|
|
16
|
+
const Component = React.useMemo(() => (0, wrapComponent_1.wrapComponent)(converters, component, { piral }, utils_1.defaultRender), [component]);
|
|
17
|
+
return React.createElement(Component, Object.assign({}, args));
|
|
18
|
+
},
|
|
19
|
+
defaults: {},
|
|
20
|
+
pilet: '',
|
|
21
|
+
reference: {
|
|
22
|
+
displayName: 'RenderExtension',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
];
|
|
8
26
|
/**
|
|
9
27
|
* The extension slot component to be used when the available
|
|
10
28
|
* extensions of a given name should be rendered at a specific
|
|
@@ -12,7 +30,7 @@ const utils_1 = require("../utils");
|
|
|
12
30
|
*/
|
|
13
31
|
function ExtensionSlot(props) {
|
|
14
32
|
const { name, render = utils_1.defaultRender, empty, params, children } = props;
|
|
15
|
-
const extensions = (0, hooks_1.useGlobalState)((s) => s.registry.extensions[name] || utils_1.none);
|
|
33
|
+
const extensions = (0, hooks_1.useGlobalState)((s) => (name ? s.registry.extensions[name] || utils_1.none : renderExtensions));
|
|
16
34
|
return render(extensions.length === 0 && (0, piral_base_1.isfunc)(empty)
|
|
17
35
|
? [(0, utils_1.defaultRender)(empty(), 'empty')]
|
|
18
36
|
: 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,+BAA+B;AAC/B,2CAAoC;AACpC,
|
|
1
|
+
{"version":3,"file":"ExtensionSlot.js","sourceRoot":"","sources":["../../src/components/ExtensionSlot.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,2CAAoC;AACpC,mDAAgD;AAChD,oCAAiE;AACjE,oCAA+C;AAG/C,MAAM,gBAAgB,GAA4B;IAChD;QACE,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;YACnB,MAAM,OAAO,GAAG,IAAA,6BAAqB,GAAE,CAAC;YACxC,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;YACtC,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;YAC7B,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC;YAChD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAC7B,GAAG,EAAE,CAAC,IAAA,6BAAa,EAAC,UAAU,EAAE,SAAS,EAAE,EAAE,KAAK,EAAE,EAAE,qBAAa,CAAC,EACpE,CAAC,SAAS,CAAC,CACZ,CAAC;YACF,O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ignComponent, 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,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ForeignComponentContainer = void 0;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const piral_base_1 = require("piral-base");
|
|
6
|
+
class ForeignComponentContainer extends React.Component {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.handler = (ev) => {
|
|
10
|
+
const { innerProps } = this.props;
|
|
11
|
+
ev.stopPropagation();
|
|
12
|
+
innerProps.piral.renderHtmlExtension(ev.detail.target, ev.detail.props);
|
|
13
|
+
};
|
|
14
|
+
this.setNode = (node) => {
|
|
15
|
+
this.current = node;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
componentDidMount() {
|
|
19
|
+
const node = this.current;
|
|
20
|
+
const { $component, $context, innerProps } = this.props;
|
|
21
|
+
const { mount } = $component;
|
|
22
|
+
if (node && (0, piral_base_1.isfunc)(mount)) {
|
|
23
|
+
mount(node, innerProps, $context);
|
|
24
|
+
node.addEventListener('render-html', this.handler, false);
|
|
25
|
+
}
|
|
26
|
+
this.previous = node;
|
|
27
|
+
}
|
|
28
|
+
componentDidUpdate() {
|
|
29
|
+
const { current, previous } = this;
|
|
30
|
+
const { $component, $context, innerProps } = this.props;
|
|
31
|
+
const { update } = $component;
|
|
32
|
+
if (current !== previous) {
|
|
33
|
+
previous && this.componentWillUnmount();
|
|
34
|
+
current && this.componentDidMount();
|
|
35
|
+
}
|
|
36
|
+
else if ((0, piral_base_1.isfunc)(update)) {
|
|
37
|
+
update(current, innerProps, $context);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
componentWillUnmount() {
|
|
41
|
+
const node = this.previous;
|
|
42
|
+
const { $component } = this.props;
|
|
43
|
+
const { unmount } = $component;
|
|
44
|
+
if (node && (0, piral_base_1.isfunc)(unmount)) {
|
|
45
|
+
unmount(node);
|
|
46
|
+
node.removeEventListener('render-html', this.handler, false);
|
|
47
|
+
}
|
|
48
|
+
this.previous = undefined;
|
|
49
|
+
}
|
|
50
|
+
render() {
|
|
51
|
+
const { $portalId } = this.props;
|
|
52
|
+
return React.createElement("div", { "data-portal-id": $portalId, ref: this.setNode });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.ForeignComponentContainer = ForeignComponentContainer;
|
|
56
|
+
//# sourceMappingURL=ForeignComponentContainer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ForeignComponentContainer.js","sourceRoot":"","sources":["../../src/components/ForeignComponentContainer.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,2CAAoC;AAWpC,MAAa,yBAA6B,SAAQ,KAAK,CAAC,SAA4C;IAApG;;QAGU,YAAO,GAAG,CAAC,EAAe,EAAE,EAAE;YACpC,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;YAClC,EAAE,CAAC,eAAe,EAAE,CAAC;YACrB,UAAU,CAAC,KAAK,CAAC,mBAAmB,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1E,CAAC,CAAC;QAEM,Y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C;QAE/B,IAAI,IAAI,IAAI,IAAA,mBAAM,EAAC,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;AAxDD,8DAwDC"}
|
package/lib/components/index.js
CHANGED
|
@@ -21,4 +21,5 @@ const tslib_1 = require("tslib");
|
|
|
21
21
|
(0, tslib_1.__exportStar)(require("./SetRedirect"), exports);
|
|
22
22
|
(0, tslib_1.__exportStar)(require("./SetRoute"), exports);
|
|
23
23
|
(0, tslib_1.__exportStar)(require("./SwitchErrorInfo"), exports);
|
|
24
|
+
(0, tslib_1.__exportStar)(require("./wrapComponent"), exports);
|
|
24
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -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"}
|
|
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"}
|
|
@@ -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,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.wrapComponent = void 0;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const react_router_1 = require("react-router");
|
|
6
|
+
const PortalRenderer_1 = require("./PortalRenderer");
|
|
7
|
+
const ForeignComponentContainer_1 = require("./ForeignComponentContainer");
|
|
8
|
+
const hooks_1 = require("../hooks");
|
|
9
|
+
const utils_1 = require("../utils");
|
|
10
|
+
// this is an arbitrary start number to have 6 digits
|
|
11
|
+
let portalIdBase = 123456;
|
|
12
|
+
function wrapReactComponent(Component, captured, Wrapper) {
|
|
13
|
+
return (props) => (React.createElement(Wrapper, Object.assign({}, props),
|
|
14
|
+
React.createElement(Component, Object.assign({}, props, captured))));
|
|
15
|
+
}
|
|
16
|
+
function wrapForeignComponent(component, captured, Wrapper) {
|
|
17
|
+
return React.memo((props) => {
|
|
18
|
+
const { state, readState, destroyPortal } = (0, hooks_1.useGlobalStateContext)();
|
|
19
|
+
const router = React.useContext(react_router_1.__RouterContext);
|
|
20
|
+
const id = React.useMemo(() => (portalIdBase++).toString(26), utils_1.none);
|
|
21
|
+
const context = React.useMemo(() => ({ router, state, readState }), [router, state]);
|
|
22
|
+
const innerProps = React.useMemo(() => (Object.assign(Object.assign({}, props), captured)), [props]);
|
|
23
|
+
React.useEffect(() => () => destroyPortal(id), utils_1.none);
|
|
24
|
+
return (React.createElement(Wrapper, Object.assign({}, props),
|
|
25
|
+
React.createElement(PortalRenderer_1.PortalRenderer, { id: id }),
|
|
26
|
+
React.createElement(ForeignComponentContainer_1.ForeignComponentContainer, { innerProps: innerProps, "$portalId": id, "$component": component, "$context": context })));
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function isNotExotic(component) {
|
|
30
|
+
return !component.$$typeof;
|
|
31
|
+
}
|
|
32
|
+
function wrapComponent(converters, component, captured, Wrapper) {
|
|
33
|
+
if (!component) {
|
|
34
|
+
const pilet = captured.piral.meta.name;
|
|
35
|
+
console.error(`[${pilet}] The given value is not a valid component.`);
|
|
36
|
+
// tslint:disable-next-line:no-null-keyword
|
|
37
|
+
component = () => null;
|
|
38
|
+
}
|
|
39
|
+
if (typeof component === 'object' && isNotExotic(component)) {
|
|
40
|
+
const result = (0, utils_1.convertComponent)(converters[component.type], component);
|
|
41
|
+
return wrapForeignComponent(result, captured, Wrapper);
|
|
42
|
+
}
|
|
43
|
+
return wrapReactComponent(component, captured, Wrapper);
|
|
44
|
+
}
|
|
45
|
+
exports.wrapComponent = wrapComponent;
|
|
46
|
+
//# sourceMappingURL=wrapComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapComponent.js","sourceRoot":"","sources":["../../src/components/wrapComponent.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,+CAA+C;AAC/C,qDAAkD;AAClD,2EAAwE;AACxE,oCAAiD;A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AC,qDAAyB,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,SAAgB,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,IAAA,wBAAgB,EAAC,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;AAnBD,sCAmBC"}
|
package/lib/createInstance.js
CHANGED
|
@@ -36,7 +36,7 @@ function createInstance(config = {}) {
|
|
|
36
36
|
const usedPlugins = Array.isArray(definedPlugins) ? definedPlugins : [definedPlugins];
|
|
37
37
|
const createApi = apiFactory(context, usedPlugins);
|
|
38
38
|
const root = createApi({
|
|
39
|
-
name: '
|
|
39
|
+
name: '_',
|
|
40
40
|
version: process.env.BUILD_PCKG_VERSION || '1.0.0',
|
|
41
41
|
spec: 'v0',
|
|
42
42
|
basePath: '',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createInstance.js","sourceRoot":"","sources":["../src/createInstance.tsx"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,2CAAuF;AACvF,uCAAiG;AACjG,mCAA2E;AAC3E,uCAA+C;AAC/C,mCAAqC;AAGrC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,cAAc,CAAC,SAA+B,EAAE;IAC9D,MAAM,EACJ,EAAE,GAAG,IAAA,kBAAU,GAAE,EACjB,KAAK,EACL,OAAO,EACP,eAAe,GAAG,EAAE,EACpB,OAAO,EACP,aAAa,GAAG,gCAAsB,EACtC,YAAY,EACZ,KAAK,GAAG,KAAK,EACb,iBAAiB,GAAG,mCAAyB,EAC7C,SAAS,EACT,OAAO,EACP,KAAK,EACL,UAAU,GAAG,2BAAiB,GAC/B,GAAG,MAAM,CAAC;IACX,MAAM,WAAW,GAAG,IAAA,yBAAiB,EAAC,KAAK,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAA,2BAAc,EAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,IAAA,qBAAa,EAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACnD,MAAM,cAAc,GAAG,OAAO,IAAI,EAAE,CAAC;IACrC,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC;IACtF,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,SAAS,CAAC;QACrB,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"createInstance.js","sourceRoot":"","sources":["../src/createInstance.tsx"],"names":[],"mappings":";;;AAAA,iCAAiC;AACjC,2CAAuF;AACvF,uCAAiG;AACjG,mCAA2E;AAC3E,uCAA+C;AAC/C,mCAAqC;AAGrC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAgB,cAAc,CAAC,SAA+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Ae,CAAC,CAAC,CAAC,6BAAgB;QAC5E,aAAa;QACb,KAAK;KACN,CAAC,CAAC;IAEH,IAAI,OAAO,EAAE;QACX,IAAA,sBAAc,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;KAClC;IAED,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;IAE1B,OAAO,IAAA,gBAAQ,EAAC,MAAM,EAAE;QACtB,EAAE;QACF,SAAS;QACT,OAAO;QACP,IAAI;QACJ,OAAO;KACR,CAAC,CAAC;AACL,CAAC;AAzDD,wCAyDC"}
|
package/lib/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
|
|
4
|
+
export declare function integrateDebugger(context: GlobalStateContext, options: LoadPiletsOptions, debug?: DebuggerExtensionOptions): void;
|
package/lib/debugger.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.integrateDebugger = void 0;
|
|
4
4
|
const react_atom_1 = require("@dbeining/react-atom");
|
|
5
5
|
const piral_debug_utils_1 = require("piral-debug-utils");
|
|
6
|
-
function
|
|
6
|
+
function integrateDebugger(context, options, debug = {}) {
|
|
7
7
|
(0, piral_debug_utils_1.installPiralDebug)(Object.assign(Object.assign({}, debug), { addPilet: context.addPilet, removePilet: context.removePilet, updatePilet(pilet) {
|
|
8
8
|
if (!pilet.disabled) {
|
|
9
9
|
const { createApi } = options;
|
|
@@ -52,5 +52,5 @@ function integrate(context, options, debug = {}) {
|
|
|
52
52
|
});
|
|
53
53
|
} }));
|
|
54
54
|
}
|
|
55
|
-
exports.
|
|
55
|
+
exports.integrateDebugger = integrateDebugger;
|
|
56
56
|
//# sourceMappingURL=debugger.js.map
|
package/lib/debugger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debugger.js","sourceRoot":"","sources":["../src/debugger.ts"],"names":[],"mappings":";;;AAAA,qDAAwD;AAExD,yDAAgF;AAGhF,SAAgB,
|
|
1
|
+
{"version":3,"file":"debugger.js","sourceRoot":"","sources":["../src/debugger.ts"],"names":[],"mappings":";;;AAAA,qDAAwD;AAExD,yDAAgF;AAGhF,SAAgB,iBAAiB,CAC/B,OAA2B,EAC3B,OAA0B,EAC1B,QAAkC,EAAE;IAEpC,IAAA,qCAAiB,kCACZ,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,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AAC,MAAM,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;AA5ED,8CA4EC"}
|
package/lib/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
|
|
3
|
+
export declare function integrateEmulator(context: GlobalStateContext, options: LoadPiletsOptions): void;
|
package/lib/emulator.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.integrateEmulator = void 0;
|
|
4
4
|
const piral_debug_utils_1 = require("piral-debug-utils");
|
|
5
|
-
function
|
|
5
|
+
function integrateEmulator(context, options) {
|
|
6
6
|
options.fetchPilets = (0, piral_debug_utils_1.withEmulatorPilets)(options.fetchPilets, {
|
|
7
7
|
addPilet: context.addPilet,
|
|
8
8
|
removePilet: context.removePilet,
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
-
exports.
|
|
11
|
+
exports.integrateEmulator = integrateEmulator;
|
|
12
12
|
//# sourceMappingURL=emulator.js.map
|
package/lib/emulator.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emulator.js","sourceRoot":"","sources":["../src/emulator.ts"],"names":[],"mappings":";;;AACA,yDAAuD;AAGvD,SAAgB,
|
|
1
|
+
{"version":3,"file":"emulator.js","sourceRoot":"","sources":["../src/emulator.ts"],"names":[],"mappings":";;;AACA,yDAAuD;AAGvD,SAAgB,iBAAiB,CAAC,OAA2B,EAAE,OAA0B;IACvF,OAAO,CAAC,WAAW,GAAG,IAAA,sCAAkB,EAAC,OAAO,CAAC,WAAW,EAAE;QAC5D,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;KACjC,CAAC,CAAC;AACL,CAAC;AALD,8CAKC"}
|
package/lib/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/lib/helpers.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createPiletOptions = void 0;
|
|
4
4
|
const piral_base_1 = require("piral-base");
|
|
5
5
|
const modules_1 = require("./modules");
|
|
6
|
+
const debug_codegen_1 = require("../debug.codegen");
|
|
6
7
|
function createPiletOptions({ hooks, context, loaders, loaderConfig, availablePilets, strategy, createApi, loadPilet, requestPilets, shareDependencies, debug, }) {
|
|
7
8
|
const options = {
|
|
8
9
|
config: loaderConfig,
|
|
@@ -14,16 +15,8 @@ function createPiletOptions({ hooks, context, loaders, loaderConfig, availablePi
|
|
|
14
15
|
hooks,
|
|
15
16
|
dependencies: shareDependencies(modules_1.globalDependencies),
|
|
16
17
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const { integrate } = require('./debugger');
|
|
20
|
-
integrate(context, options, debug);
|
|
21
|
-
}
|
|
22
|
-
// if we build the emulator version of piral (shipped to pilets)
|
|
23
|
-
if (process.env.DEBUG_PILET) {
|
|
24
|
-
const { integrate } = require('./emulator');
|
|
25
|
-
integrate(context, options);
|
|
26
|
-
}
|
|
18
|
+
(0, debug_codegen_1.integrateDebugger)(context, options, debug);
|
|
19
|
+
(0, debug_codegen_1.integrateEmulator)(context, options, debug);
|
|
27
20
|
return options;
|
|
28
21
|
}
|
|
29
22
|
exports.createPiletOptions = createPiletOptions;
|
package/lib/helpers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.tsx"],"names":[],"mappings":";;;AAAA,2CASoB;AAEpB,uCAA+C;
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.tsx"],"names":[],"mappings":";;;AAAA,2CASoB;AAEpB,uCAA+C;AAE/C,oDAAwE;AAgBxE,SAAgB,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,IAAA,yBAAY,EAAC,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAA,6BAAgB,EAAC,YAAY,CAAC,EAAE,OAAO,CAAC;QAC7E,SAAS;QACT,MAAM,EAAE,eAAe;QACvB,WAAW,EAAE,aAAa;QAC1B,KAAK;QACL,YAAY,EAAE,iBAAiB,CAAC,4BAAkB,CAAC;KACpD,CAAC;IAEF,IAAA,iCAAiB,EAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAC3C,IAAA,iCAAiB,EAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IAE3C,OAAO,OAAO,CAAC;AACjB,CAAC;AA5BD,gDA4BC"}
|
|
@@ -2,34 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defaultModuleRequester = exports.defaultDependencySelector = exports.globalDependencies = void 0;
|
|
4
4
|
const piral_base_1 = require("piral-base");
|
|
5
|
-
const
|
|
5
|
+
const dependencies_codegen_1 = require("../../dependencies.codegen");
|
|
6
6
|
/**
|
|
7
7
|
* The global dependencies, which represent the dependencies
|
|
8
8
|
* shared from the app shell itself.
|
|
9
9
|
*/
|
|
10
10
|
exports.globalDependencies = {};
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
if ((0, piral_base_1.isfunc)(fillDependencies)) {
|
|
14
|
-
fillDependencies(exports.globalDependencies);
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
// fall back to the default list if the codegen is invalid / not supported
|
|
18
|
-
(0, tslib_1.__assign)(exports.globalDependencies, {
|
|
19
|
-
react: require('react'),
|
|
20
|
-
'react-dom': require('react-dom'),
|
|
21
|
-
'react-router': require('react-router'),
|
|
22
|
-
'react-router-dom': require('react-router-dom'),
|
|
23
|
-
history: require('history'),
|
|
24
|
-
tslib: require('tslib'),
|
|
25
|
-
'path-to-regexp': require('path-to-regexp'),
|
|
26
|
-
'@libre/atom': require('@libre/atom'),
|
|
27
|
-
'@dbeining/react-atom': require('@dbeining/react-atom'),
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
// App shell is built with something else than the Piral CLI - just don't fill ...
|
|
11
|
+
if ((0, piral_base_1.isfunc)(dependencies_codegen_1.default)) {
|
|
12
|
+
(0, dependencies_codegen_1.default)(exports.globalDependencies);
|
|
33
13
|
}
|
|
34
14
|
/**
|
|
35
15
|
* 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,2CAAoC;
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":";;;AAAA,2CAAoC;AAEpC,qEAA0D;AAE1D;;;GAGG;AACU,QAAA,kBAAkB,GAA0B,EAAE,CAAC;AAE5D,IAAI,IAAA,mBAAM,EAAC,8BAAgB,CAAC,EAAE;IAC5B,IAAA,8BAAgB,EAAC,0BAAkB,CAAC,CAAC;CACtC;AAED;;;GAGG;AACH,SAAgB,yBAAyB,CAAC,YAAmC;IAC3E,OAAO,YAAY,CAAC;AACtB,CAAC;AAFD,8DAEC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,sBAAsB;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC7B,CAAC;AAFD,wDAEC"}
|
package/lib/state/withApi.js
CHANGED
|
@@ -2,90 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withApi = void 0;
|
|
4
4
|
const React = require("react");
|
|
5
|
-
const piral_base_1 = require("piral-base");
|
|
6
|
-
const react_router_1 = require("react-router");
|
|
7
5
|
const components_1 = require("../components");
|
|
8
|
-
const hooks_1 = require("../hooks");
|
|
9
6
|
const utils_1 = require("../utils");
|
|
10
|
-
// this is an arbitrary start number to have 6 digits
|
|
11
|
-
let portalIdBase = 123456;
|
|
12
7
|
const DefaultWrapper = (props) => (0, utils_1.defaultRender)(props.children);
|
|
13
|
-
class ForeignComponentContainer extends React.Component {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(...arguments);
|
|
16
|
-
this.handler = (ev) => {
|
|
17
|
-
const { innerProps } = this.props;
|
|
18
|
-
ev.stopPropagation();
|
|
19
|
-
innerProps.piral.renderHtmlExtension(ev.detail.target, ev.detail.props);
|
|
20
|
-
};
|
|
21
|
-
this.setNode = (node) => {
|
|
22
|
-
this.current = node;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
componentDidMount() {
|
|
26
|
-
const node = this.current;
|
|
27
|
-
const { $component, $context, innerProps } = this.props;
|
|
28
|
-
const { mount } = $component;
|
|
29
|
-
if (node && (0, piral_base_1.isfunc)(mount)) {
|
|
30
|
-
mount(node, innerProps, $context);
|
|
31
|
-
node.addEventListener('render-html', this.handler, false);
|
|
32
|
-
}
|
|
33
|
-
this.previous = node;
|
|
34
|
-
}
|
|
35
|
-
componentDidUpdate() {
|
|
36
|
-
const { current, previous } = this;
|
|
37
|
-
const { $component, $context, innerProps } = this.props;
|
|
38
|
-
const { update } = $component;
|
|
39
|
-
if (current !== previous) {
|
|
40
|
-
previous && this.componentWillUnmount();
|
|
41
|
-
current && this.componentDidMount();
|
|
42
|
-
}
|
|
43
|
-
else if ((0, piral_base_1.isfunc)(update)) {
|
|
44
|
-
update(current, innerProps, $context);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
componentWillUnmount() {
|
|
48
|
-
const node = this.previous;
|
|
49
|
-
const { $component } = this.props;
|
|
50
|
-
const { unmount } = $component;
|
|
51
|
-
if (node && (0, piral_base_1.isfunc)(unmount)) {
|
|
52
|
-
unmount(node);
|
|
53
|
-
node.removeEventListener('render-html', this.handler, false);
|
|
54
|
-
}
|
|
55
|
-
this.previous = undefined;
|
|
56
|
-
}
|
|
57
|
-
render() {
|
|
58
|
-
const { $portalId } = this.props;
|
|
59
|
-
return React.createElement("div", { "data-portal-id": $portalId, ref: this.setNode });
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function wrapReactComponent(Component, captured, Wrapper) {
|
|
63
|
-
return (props) => (React.createElement(Wrapper, Object.assign({}, props),
|
|
64
|
-
React.createElement(Component, Object.assign({}, props, captured))));
|
|
65
|
-
}
|
|
66
|
-
function wrapForeignComponent(component, captured, Wrapper) {
|
|
67
|
-
return React.memo((props) => {
|
|
68
|
-
const { state, readState, destroyPortal } = (0, hooks_1.useGlobalStateContext)();
|
|
69
|
-
const router = React.useContext(react_router_1.__RouterContext);
|
|
70
|
-
const id = React.useMemo(() => (portalIdBase++).toString(26), utils_1.none);
|
|
71
|
-
const context = React.useMemo(() => ({ router, state, readState }), [router, state]);
|
|
72
|
-
const innerProps = React.useMemo(() => (Object.assign(Object.assign({}, props), captured)), [props]);
|
|
73
|
-
React.useEffect(() => () => destroyPortal(id), utils_1.none);
|
|
74
|
-
return (React.createElement(Wrapper, Object.assign({}, props),
|
|
75
|
-
React.createElement(components_1.PortalRenderer, { id: id }),
|
|
76
|
-
React.createElement(ForeignComponentContainer, { innerProps: innerProps, "$portalId": id, "$component": component, "$context": context })));
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
function isNotExotic(component) {
|
|
80
|
-
return !component.$$typeof;
|
|
81
|
-
}
|
|
82
|
-
function wrapComponent(converters, component, captured, Wrapper) {
|
|
83
|
-
if (typeof component === 'object' && isNotExotic(component)) {
|
|
84
|
-
const result = (0, utils_1.convertComponent)(converters[component.type], component);
|
|
85
|
-
return wrapForeignComponent(result, captured, Wrapper);
|
|
86
|
-
}
|
|
87
|
-
return wrapReactComponent(component, captured, Wrapper);
|
|
88
|
-
}
|
|
89
8
|
function getWrapper(wrappers, wrapperType) {
|
|
90
9
|
const WrapAll = wrappers['*'];
|
|
91
10
|
const WrapType = wrappers[wrapperType];
|
|
@@ -95,19 +14,16 @@ function getWrapper(wrappers, wrapperType) {
|
|
|
95
14
|
}
|
|
96
15
|
return WrapType || WrapAll || DefaultWrapper;
|
|
97
16
|
}
|
|
17
|
+
function makeWrapper(context, outerProps, wrapperType, errorType) {
|
|
18
|
+
const OuterWrapper = context.readState((m) => getWrapper(m.registry.wrappers, wrapperType));
|
|
19
|
+
return (props) => (React.createElement(OuterWrapper, Object.assign({}, outerProps, props),
|
|
20
|
+
React.createElement(components_1.ErrorBoundary, Object.assign({}, outerProps, props, { errorType: errorType }), props.children)));
|
|
21
|
+
}
|
|
98
22
|
function withApi(context, component, piral, errorType, wrapperType = errorType, captured = {}) {
|
|
99
23
|
const outerProps = Object.assign(Object.assign({}, captured), { piral });
|
|
100
24
|
const converters = context.converters;
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
React.createElement(components_1.ErrorBoundary, Object.assign({}, outerProps, props, { errorType: errorType }), props.children)));
|
|
104
|
-
if (!component) {
|
|
105
|
-
const pilet = piral.meta.name;
|
|
106
|
-
console.error(`[${pilet}] The given value is not a valid component.`);
|
|
107
|
-
// tslint:disable-next-line:no-null-keyword
|
|
108
|
-
component = () => null;
|
|
109
|
-
}
|
|
110
|
-
return wrapComponent(converters, component, outerProps, Wrapper);
|
|
25
|
+
const Wrapper = makeWrapper(context, outerProps, wrapperType, errorType);
|
|
26
|
+
return (0, components_1.wrapComponent)(converters, component, outerProps, Wrapper);
|
|
111
27
|
}
|
|
112
28
|
exports.withApi = withApi;
|
|
113
29
|
//# sourceMappingURL=withApi.js.map
|