piral-core 0.13.9 → 0.14.0-beta.3157
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-pilet.d.ts +3 -0
- package/debug-pilet.js +12 -0
- package/debug-piral.d.ts +4 -0
- package/debug-piral.js +59 -0
- package/dependencies.codegen +1 -1
- package/esm/Piral.js +6 -8
- package/esm/Piral.js.map +1 -1
- package/esm/actions/app.js +9 -10
- package/esm/actions/app.js.map +1 -1
- package/esm/actions/components.js +4 -5
- package/esm/actions/components.js.map +1 -1
- package/esm/actions/data.js +16 -17
- package/esm/actions/data.js.map +1 -1
- package/esm/actions/define.js +2 -3
- package/esm/actions/define.js.map +1 -1
- package/esm/actions/portal.d.ts +2 -0
- package/esm/actions/portal.js +9 -4
- package/esm/actions/portal.js.map +1 -1
- package/esm/actions/state.js +1 -1
- package/esm/actions/state.js.map +1 -1
- package/esm/components/DefaultErrorInfo.js +1 -2
- package/esm/components/DefaultErrorInfo.js.map +1 -1
- package/esm/components/DefaultLayout.js +1 -4
- package/esm/components/DefaultLayout.js.map +1 -1
- package/esm/components/DefaultLoader.js +1 -1
- package/esm/components/DefaultLoader.js.map +1 -1
- package/esm/components/ErrorBoundary.js +13 -18
- package/esm/components/ErrorBoundary.js.map +1 -1
- package/esm/components/ExtensionSlot.js +5 -9
- package/esm/components/ExtensionSlot.js.map +1 -1
- package/esm/components/Mediator.js +8 -8
- package/esm/components/Mediator.js.map +1 -1
- package/esm/components/PiralRoutes.js +8 -8
- package/esm/components/PiralRoutes.js.map +1 -1
- package/esm/components/PiralView.js +11 -16
- package/esm/components/PiralView.js.map +1 -1
- package/esm/components/PortalRenderer.d.ts +5 -0
- package/esm/components/PortalRenderer.js +7 -0
- package/esm/components/PortalRenderer.js.map +1 -0
- package/esm/components/ResponsiveLayout.js +5 -6
- package/esm/components/ResponsiveLayout.js.map +1 -1
- package/esm/components/SetComponent.js +3 -4
- package/esm/components/SetComponent.js.map +1 -1
- package/esm/components/SetError.js +3 -4
- package/esm/components/SetError.js.map +1 -1
- package/esm/components/SetErrors.js +2 -3
- package/esm/components/SetErrors.js.map +1 -1
- package/esm/components/SetLayout.js +2 -3
- package/esm/components/SetLayout.js.map +1 -1
- package/esm/components/SetProvider.js +3 -4
- package/esm/components/SetProvider.js.map +1 -1
- package/esm/components/SetRedirect.js +3 -4
- package/esm/components/SetRedirect.js.map +1 -1
- package/esm/components/SetRoute.js +3 -4
- package/esm/components/SetRoute.js.map +1 -1
- package/esm/components/SwitchErrorInfo.js +12 -10
- package/esm/components/SwitchErrorInfo.js.map +1 -1
- package/esm/components/components.js +8 -9
- package/esm/components/components.js.map +1 -1
- package/esm/components/index.d.ts +1 -0
- package/esm/components/index.js +1 -0
- package/esm/components/index.js.map +1 -1
- package/esm/createInstance.js +24 -25
- package/esm/createInstance.js.map +1 -1
- package/esm/helpers.d.ts +11 -26
- package/esm/helpers.js +18 -56
- package/esm/helpers.js.map +1 -1
- package/esm/hooks/action.js +1 -1
- package/esm/hooks/action.js.map +1 -1
- package/esm/hooks/actions.js +1 -1
- package/esm/hooks/actions.js.map +1 -1
- package/esm/hooks/globalState.js +5 -5
- package/esm/hooks/globalState.js.map +1 -1
- package/esm/hooks/index.d.ts +0 -5
- package/esm/hooks/index.js +0 -5
- package/esm/hooks/index.js.map +1 -1
- package/esm/hooks/media.js +8 -7
- package/esm/hooks/media.js.map +1 -1
- package/esm/hooks/setter.js +3 -2
- package/esm/hooks/setter.js.map +1 -1
- package/esm/hooks/sharedData.js +2 -2
- package/esm/hooks/sharedData.js.map +1 -1
- package/esm/modules/api.js +79 -28
- package/esm/modules/api.js.map +1 -1
- package/esm/modules/dependencies.d.ts +3 -4
- package/esm/modules/dependencies.js +11 -14
- package/esm/modules/dependencies.js.map +1 -1
- package/esm/state/createActions.js +7 -12
- package/esm/state/createActions.js.map +1 -1
- package/esm/state/createGlobalState.js +6 -8
- package/esm/state/createGlobalState.js.map +1 -1
- package/esm/state/stateContext.js +1 -1
- package/esm/state/stateContext.js.map +1 -1
- package/esm/state/withApi.js +59 -62
- package/esm/state/withApi.js.map +1 -1
- package/esm/types/config.d.ts +23 -16
- package/esm/types/state.d.ts +13 -0
- package/esm/utils/compare.js +4 -4
- package/esm/utils/compare.js.map +1 -1
- package/esm/utils/data.js +6 -7
- package/esm/utils/data.js.map +1 -1
- package/esm/utils/foreign.d.ts +4 -2
- package/esm/utils/foreign.js +16 -8
- package/esm/utils/foreign.js.map +1 -1
- package/esm/utils/guid.js +3 -3
- package/esm/utils/guid.js.map +1 -1
- package/esm/utils/helpers.d.ts +11 -8
- package/esm/utils/helpers.js +28 -17
- package/esm/utils/helpers.js.map +1 -1
- package/esm/utils/media.js +8 -7
- package/esm/utils/media.js.map +1 -1
- package/esm/utils/storage.js +13 -14
- package/esm/utils/storage.js.map +1 -1
- package/lib/Piral.js +9 -11
- package/lib/Piral.js.map +1 -1
- package/lib/actions/app.js +11 -12
- package/lib/actions/app.js.map +1 -1
- package/lib/actions/components.js +5 -6
- package/lib/actions/components.js.map +1 -1
- package/lib/actions/data.js +17 -18
- package/lib/actions/data.js.map +1 -1
- package/lib/actions/define.js +2 -3
- package/lib/actions/define.js.map +1 -1
- package/lib/actions/index.js +7 -7
- package/lib/actions/index.js.map +1 -1
- package/lib/actions/portal.d.ts +2 -0
- package/lib/actions/portal.js +12 -5
- package/lib/actions/portal.js.map +1 -1
- package/lib/actions/state.js +3 -3
- package/lib/actions/state.js.map +1 -1
- package/lib/components/DefaultErrorInfo.js +4 -5
- package/lib/components/DefaultErrorInfo.js.map +1 -1
- package/lib/components/DefaultLayout.js +2 -5
- package/lib/components/DefaultLayout.js.map +1 -1
- package/lib/components/DefaultLoader.js +2 -2
- package/lib/components/DefaultLoader.js.map +1 -1
- package/lib/components/ErrorBoundary.js +18 -22
- package/lib/components/ErrorBoundary.js.map +1 -1
- package/lib/components/ExtensionSlot.js +10 -14
- package/lib/components/ExtensionSlot.js.map +1 -1
- package/lib/components/Mediator.js +11 -11
- package/lib/components/Mediator.js.map +1 -1
- package/lib/components/PiralRoutes.js +11 -11
- package/lib/components/PiralRoutes.js.map +1 -1
- package/lib/components/PiralView.js +16 -21
- package/lib/components/PiralView.js.map +1 -1
- package/lib/components/PortalRenderer.d.ts +5 -0
- package/lib/components/PortalRenderer.js +11 -0
- package/lib/components/PortalRenderer.js.map +1 -0
- package/lib/components/ResponsiveLayout.js +9 -10
- package/lib/components/ResponsiveLayout.js.map +1 -1
- package/lib/components/SetComponent.js +4 -5
- package/lib/components/SetComponent.js.map +1 -1
- package/lib/components/SetError.js +4 -5
- package/lib/components/SetError.js.map +1 -1
- package/lib/components/SetErrors.js +4 -5
- package/lib/components/SetErrors.js.map +1 -1
- package/lib/components/SetLayout.js +4 -5
- package/lib/components/SetLayout.js.map +1 -1
- package/lib/components/SetProvider.js +4 -5
- package/lib/components/SetProvider.js.map +1 -1
- package/lib/components/SetRedirect.js +6 -7
- package/lib/components/SetRedirect.js.map +1 -1
- package/lib/components/SetRoute.js +4 -5
- package/lib/components/SetRoute.js.map +1 -1
- package/lib/components/SwitchErrorInfo.js +14 -12
- package/lib/components/SwitchErrorInfo.js.map +1 -1
- package/lib/components/components.js +5 -6
- package/lib/components/components.js.map +1 -1
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +20 -19
- package/lib/components/index.js.map +1 -1
- package/lib/createInstance.js +31 -32
- package/lib/createInstance.js.map +1 -1
- package/lib/helpers.d.ts +11 -26
- package/lib/helpers.js +19 -59
- package/lib/helpers.js.map +1 -1
- package/lib/hooks/action.js +3 -3
- package/lib/hooks/action.js.map +1 -1
- package/lib/hooks/actions.js +4 -4
- package/lib/hooks/actions.js.map +1 -1
- package/lib/hooks/globalState.js +8 -8
- package/lib/hooks/globalState.js.map +1 -1
- package/lib/hooks/index.d.ts +0 -5
- package/lib/hooks/index.js +7 -12
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/media.js +10 -9
- package/lib/hooks/media.js.map +1 -1
- package/lib/hooks/setter.js +4 -3
- package/lib/hooks/setter.js.map +1 -1
- package/lib/hooks/sharedData.js +3 -3
- package/lib/hooks/sharedData.js.map +1 -1
- package/lib/index.js +9 -9
- package/lib/index.js.map +1 -1
- package/lib/modules/api.js +86 -35
- package/lib/modules/api.js.map +1 -1
- package/lib/modules/dependencies.d.ts +3 -4
- package/lib/modules/dependencies.js +13 -16
- package/lib/modules/dependencies.js.map +1 -1
- package/lib/modules/index.js +3 -3
- package/lib/modules/index.js.map +1 -1
- package/lib/state/createActions.js +8 -13
- package/lib/state/createActions.js.map +1 -1
- package/lib/state/createGlobalState.js +9 -11
- package/lib/state/createGlobalState.js.map +1 -1
- package/lib/state/index.js +5 -5
- package/lib/state/index.js.map +1 -1
- package/lib/state/stateContext.js +1 -1
- package/lib/state/stateContext.js.map +1 -1
- package/lib/state/withApi.js +67 -70
- package/lib/state/withApi.js.map +1 -1
- package/lib/types/config.d.ts +23 -16
- package/lib/types/index.js +13 -13
- package/lib/types/index.js.map +1 -1
- package/lib/types/state.d.ts +13 -0
- package/lib/utils/compare.js +4 -4
- package/lib/utils/compare.js.map +1 -1
- package/lib/utils/data.js +6 -7
- package/lib/utils/data.js.map +1 -1
- package/lib/utils/foreign.d.ts +4 -2
- package/lib/utils/foreign.js +21 -11
- package/lib/utils/foreign.js.map +1 -1
- package/lib/utils/guid.js +3 -3
- package/lib/utils/guid.js.map +1 -1
- package/lib/utils/helpers.d.ts +11 -8
- package/lib/utils/helpers.js +30 -17
- package/lib/utils/helpers.js.map +1 -1
- package/lib/utils/index.js +9 -9
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/media.js +7 -6
- package/lib/utils/media.js.map +1 -1
- package/lib/utils/react.js +1 -1
- package/lib/utils/react.js.map +1 -1
- package/lib/utils/storage.js +11 -12
- package/lib/utils/storage.js.map +1 -1
- package/package.json +21 -5
- package/src/Piral.tsx +2 -1
- package/src/actions/portal.ts +19 -1
- package/src/components/ExtensionSlot.tsx +2 -2
- package/src/components/Mediator.tsx +2 -1
- package/src/components/PortalRenderer.tsx +12 -0
- package/src/components/SwitchErrorInfo.tsx +5 -1
- package/src/components/index.ts +1 -0
- package/src/createInstance.tsx +6 -7
- package/src/helpers.test.tsx +7 -39
- package/src/helpers.tsx +32 -85
- package/src/hooks/index.ts +0 -5
- package/src/hooks/media.ts +2 -1
- package/src/hooks/setter.ts +2 -1
- package/src/modules/api.ts +72 -4
- package/src/modules/dependencies.test.ts +18 -5
- package/src/modules/dependencies.ts +12 -18
- package/src/state/withApi.tsx +12 -14
- package/src/types/config.ts +23 -17
- package/src/types/state.ts +13 -0
- package/src/utils/foreign.test.ts +4 -4
- package/src/utils/foreign.ts +28 -5
- package/src/utils/helpers.ts +21 -7
- package/src/utils/media.ts +2 -1
- package/esm/hooks/debounce.d.ts +0 -8
- package/esm/hooks/debounce.js +0 -18
- package/esm/hooks/debounce.js.map +0 -1
- package/esm/hooks/lockBodyScroll.d.ts +0 -6
- package/esm/hooks/lockBodyScroll.js +0 -15
- package/esm/hooks/lockBodyScroll.js.map +0 -1
- package/esm/hooks/onClickOutside.d.ts +0 -8
- package/esm/hooks/onClickOutside.js +0 -23
- package/esm/hooks/onClickOutside.js.map +0 -1
- package/esm/hooks/onScreenVisible.d.ts +0 -11
- package/esm/hooks/onScreenVisible.js +0 -28
- package/esm/hooks/onScreenVisible.js.map +0 -1
- package/esm/hooks/promise.d.ts +0 -13
- package/esm/hooks/promise.js +0 -21
- package/esm/hooks/promise.js.map +0 -1
- package/lib/hooks/debounce.d.ts +0 -8
- package/lib/hooks/debounce.js +0 -22
- package/lib/hooks/debounce.js.map +0 -1
- package/lib/hooks/lockBodyScroll.d.ts +0 -6
- package/lib/hooks/lockBodyScroll.js +0 -19
- package/lib/hooks/lockBodyScroll.js.map +0 -1
- package/lib/hooks/onClickOutside.d.ts +0 -8
- package/lib/hooks/onClickOutside.js +0 -27
- package/lib/hooks/onClickOutside.js.map +0 -1
- package/lib/hooks/onScreenVisible.d.ts +0 -11
- package/lib/hooks/onScreenVisible.js +0 -32
- package/lib/hooks/onScreenVisible.js.map +0 -1
- package/lib/hooks/promise.d.ts +0 -13
- package/lib/hooks/promise.js +0 -25
- package/lib/hooks/promise.js.map +0 -1
- package/src/hooks/debounce.test.ts +0 -67
- package/src/hooks/debounce.ts +0 -19
- package/src/hooks/lockBodyScroll.test.ts +0 -24
- package/src/hooks/lockBodyScroll.ts +0 -15
- package/src/hooks/onClickOutside.test.ts +0 -113
- package/src/hooks/onClickOutside.ts +0 -25
- package/src/hooks/onScreenVisible.test.ts +0 -68
- package/src/hooks/onScreenVisible.ts +0 -28
- package/src/hooks/promise.test.ts +0 -76
- package/src/hooks/promise.ts +0 -35
package/lib/modules/api.js
CHANGED
|
@@ -1,49 +1,100 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defaultApiFactory = exports.createExtenders = exports.createCoreApi = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const piral_base_1 = require("piral-base");
|
|
5
|
+
const state_1 = require("../state");
|
|
6
|
+
const components_1 = require("../components");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
if ('customElements' in window) {
|
|
9
|
+
class PiralExtension extends HTMLElement {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(...arguments);
|
|
12
|
+
this.dispose = utils_1.noop;
|
|
13
|
+
this.update = utils_1.noop;
|
|
14
|
+
}
|
|
15
|
+
getProps() {
|
|
16
|
+
const name = this.getAttribute('name');
|
|
17
|
+
const params = (0, utils_1.tryParseJson)(this.getAttribute('params'));
|
|
18
|
+
return { name, params };
|
|
19
|
+
}
|
|
20
|
+
connectedCallback() {
|
|
21
|
+
if (this.isConnected) {
|
|
22
|
+
this.dispatchEvent(new CustomEvent('render-html', {
|
|
23
|
+
bubbles: true,
|
|
24
|
+
detail: {
|
|
25
|
+
target: this,
|
|
26
|
+
props: this.getProps(),
|
|
27
|
+
},
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
disconnectedCallback() {
|
|
32
|
+
this.dispose();
|
|
33
|
+
this.dispose = utils_1.noop;
|
|
34
|
+
this.update = utils_1.noop;
|
|
35
|
+
}
|
|
36
|
+
attributeChangedCallback() {
|
|
37
|
+
this.update(this.getProps());
|
|
38
|
+
}
|
|
39
|
+
static get observedAttributes() {
|
|
40
|
+
return ['name', 'params'];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
customElements.define('piral-extension', PiralExtension);
|
|
44
|
+
}
|
|
45
|
+
function render(context, element, props) {
|
|
46
|
+
let [id, portal] = (0, utils_1.renderInDom)(context, element, components_1.ExtensionSlot, props);
|
|
47
|
+
const dispose = () => context.hidePortal(id, portal);
|
|
48
|
+
const update = (newProps) => {
|
|
49
|
+
[id, portal] = (0, utils_1.changeDomPortal)(id, portal, context, element, components_1.ExtensionSlot, newProps);
|
|
50
|
+
};
|
|
51
|
+
return [dispose, update];
|
|
52
|
+
}
|
|
9
53
|
function createCoreApi(context) {
|
|
10
|
-
|
|
11
|
-
|
|
54
|
+
document.body.addEventListener('render-html', (ev) => {
|
|
55
|
+
ev.stopPropagation();
|
|
56
|
+
const container = ev.detail.target;
|
|
57
|
+
const [dispose, update] = render(context, container, ev.detail.props);
|
|
58
|
+
container.dispose = dispose;
|
|
59
|
+
container.update = update;
|
|
60
|
+
}, false);
|
|
61
|
+
return (api, target) => {
|
|
62
|
+
const pilet = target.name;
|
|
12
63
|
return {
|
|
13
|
-
getData
|
|
64
|
+
getData(name) {
|
|
14
65
|
return context.readDataValue(name);
|
|
15
66
|
},
|
|
16
|
-
setData
|
|
17
|
-
|
|
18
|
-
|
|
67
|
+
setData(name, value, options) {
|
|
68
|
+
const { target = 'memory', expires } = (0, utils_1.createDataOptions)(options);
|
|
69
|
+
const expiration = (0, utils_1.getDataExpiration)(expires);
|
|
19
70
|
return context.tryWriteDataItem(name, value, pilet, target, expiration);
|
|
20
71
|
},
|
|
21
|
-
registerPage
|
|
72
|
+
registerPage(route, arg, meta) {
|
|
22
73
|
context.registerPage(route, {
|
|
23
|
-
pilet
|
|
24
|
-
meta
|
|
25
|
-
component: state_1.withApi(context, arg, api, 'page'),
|
|
74
|
+
pilet,
|
|
75
|
+
meta,
|
|
76
|
+
component: (0, state_1.withApi)(context, arg, api, 'page'),
|
|
26
77
|
});
|
|
27
|
-
return
|
|
78
|
+
return () => api.unregisterPage(route);
|
|
28
79
|
},
|
|
29
|
-
unregisterPage
|
|
80
|
+
unregisterPage(route) {
|
|
30
81
|
context.unregisterPage(route);
|
|
31
82
|
},
|
|
32
|
-
registerExtension
|
|
83
|
+
registerExtension(name, arg, defaults) {
|
|
33
84
|
context.registerExtension(name, {
|
|
34
|
-
pilet
|
|
35
|
-
component: state_1.withApi(context, arg, api, 'extension'),
|
|
85
|
+
pilet,
|
|
86
|
+
component: (0, state_1.withApi)(context, arg, api, 'extension'),
|
|
36
87
|
reference: arg,
|
|
37
|
-
defaults
|
|
88
|
+
defaults,
|
|
38
89
|
});
|
|
39
|
-
return
|
|
90
|
+
return () => api.unregisterExtension(name, arg);
|
|
40
91
|
},
|
|
41
|
-
unregisterExtension
|
|
92
|
+
unregisterExtension(name, arg) {
|
|
42
93
|
context.unregisterExtension(name, arg);
|
|
43
94
|
},
|
|
44
|
-
renderHtmlExtension
|
|
45
|
-
|
|
46
|
-
return
|
|
95
|
+
renderHtmlExtension(element, props) {
|
|
96
|
+
const [dispose] = render(context, element, props);
|
|
97
|
+
return dispose;
|
|
47
98
|
},
|
|
48
99
|
Extension: components_1.ExtensionSlot,
|
|
49
100
|
};
|
|
@@ -51,24 +102,24 @@ function createCoreApi(context) {
|
|
|
51
102
|
}
|
|
52
103
|
exports.createCoreApi = createCoreApi;
|
|
53
104
|
function createExtenders(context, apis) {
|
|
54
|
-
|
|
55
|
-
return creators.map(
|
|
56
|
-
|
|
57
|
-
if (piral_base_1.isfunc(ctx)) {
|
|
105
|
+
const creators = [createCoreApi, ...apis.filter(piral_base_1.isfunc)];
|
|
106
|
+
return creators.map((c) => {
|
|
107
|
+
const ctx = c(context);
|
|
108
|
+
if ((0, piral_base_1.isfunc)(ctx)) {
|
|
58
109
|
return ctx;
|
|
59
110
|
}
|
|
60
111
|
else {
|
|
61
|
-
return
|
|
112
|
+
return () => (Object.assign({}, ctx));
|
|
62
113
|
}
|
|
63
114
|
});
|
|
64
115
|
}
|
|
65
116
|
exports.createExtenders = createExtenders;
|
|
66
117
|
function defaultApiFactory(context, apis) {
|
|
67
|
-
|
|
68
|
-
return
|
|
69
|
-
|
|
118
|
+
const extenders = createExtenders(context, apis);
|
|
119
|
+
return (target) => {
|
|
120
|
+
const api = (0, piral_base_1.initializeApi)(target, context);
|
|
70
121
|
context.apis[target.name] = api;
|
|
71
|
-
return piral_base_1.mergeApis(api, extenders, target);
|
|
122
|
+
return (0, piral_base_1.mergeApis)(api, extenders, target);
|
|
72
123
|
};
|
|
73
124
|
}
|
|
74
125
|
exports.defaultApiFactory = defaultApiFactory;
|
package/lib/modules/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/modules/api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/modules/api.ts"],"names":[],"mappings":";;;AAAA,2CAAiG;AAEjG,oCAAmC;AACnC,8CAA8C;AAC9C,oCAAkH;AAOlH,IAAI,gBAAgB,IAAI,MAAM,EAAE;IAC9B,MAAM,cAAe,SAAQ,WAAW;QAAxC;;YACE,YAAO,GAAe,YAAI,CAAC;YAC3B,WAAM,GAAc,YAAI,CAAC;QAmC3B,CAAC;QAjCC,QAAQ;YACN,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YACvC,MAAM,MAAM,GAAG,IAAA,oBAAY,EAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAA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OAAO,GAAG,CAAC;SACZ;aAAM;YACL,OAAO,GAAG,EAAE,CAAC,mBACR,GAAG,EACN,CAAC;SACJ;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAbD,0CAaC;AAED,SAAgB,iBAAiB,CAAC,OAA2B,EAAE,IAAwB;IACrF,MAAM,SAAS,GAAG,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACjD,OAAO,CAAC,MAAM,EAAE,EAAE;QAChB,MAAM,GAAG,GAAG,IAAA,0BAAa,EAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,GAAG,CAAC;QAChC,OAAO,IAAA,sBAAS,EAAC,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC,CAAC;AACJ,CAAC;AAPD,8CAOC"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { PiletMetadata, AvailableDependencies } from 'piral-base';
|
|
2
2
|
/**
|
|
3
3
|
* The global dependencies, which represent the dependencies
|
|
4
|
-
*
|
|
4
|
+
* shared from the app shell itself.
|
|
5
5
|
*/
|
|
6
6
|
export declare const globalDependencies: AvailableDependencies;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* are the global dependencies and the implicitly shared
|
|
8
|
+
* The default dependency selector, which just returns the provided
|
|
10
9
|
* dependencies.
|
|
11
10
|
*/
|
|
12
|
-
export declare function
|
|
11
|
+
export declare function defaultDependencySelector(dependencies: AvailableDependencies): AvailableDependencies;
|
|
13
12
|
/**
|
|
14
13
|
* The default pilet requester, which just returns an empty array.
|
|
15
14
|
* Use your own code to connect to the feed service.
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultModuleRequester = exports.
|
|
4
|
-
|
|
5
|
-
var piral_base_1 = require("piral-base");
|
|
6
|
-
var sharedDependencies = {};
|
|
7
|
-
if (process.env.SHARED_DEPENDENCIES) {
|
|
8
|
-
var fillDependencies = require('../../dependencies.codegen');
|
|
9
|
-
if (piral_base_1.isfunc(fillDependencies)) {
|
|
10
|
-
fillDependencies(sharedDependencies);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
3
|
+
exports.defaultModuleRequester = exports.defaultDependencySelector = exports.globalDependencies = void 0;
|
|
4
|
+
const piral_base_1 = require("piral-base");
|
|
13
5
|
/**
|
|
14
6
|
* The global dependencies, which represent the dependencies
|
|
15
|
-
*
|
|
7
|
+
* shared from the app shell itself.
|
|
16
8
|
*/
|
|
17
9
|
exports.globalDependencies = {
|
|
18
10
|
react: require('react'),
|
|
@@ -25,15 +17,20 @@ exports.globalDependencies = {
|
|
|
25
17
|
'@libre/atom': require('@libre/atom'),
|
|
26
18
|
'@dbeining/react-atom': require('@dbeining/react-atom'),
|
|
27
19
|
};
|
|
20
|
+
if (process.env.SHARED_DEPENDENCIES) {
|
|
21
|
+
const fillDependencies = require('../../dependencies.codegen');
|
|
22
|
+
if ((0, piral_base_1.isfunc)(fillDependencies)) {
|
|
23
|
+
fillDependencies(exports.globalDependencies);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
28
26
|
/**
|
|
29
|
-
*
|
|
30
|
-
* are the global dependencies and the implicitly shared
|
|
27
|
+
* The default dependency selector, which just returns the provided
|
|
31
28
|
* dependencies.
|
|
32
29
|
*/
|
|
33
|
-
function
|
|
34
|
-
return
|
|
30
|
+
function defaultDependencySelector(dependencies) {
|
|
31
|
+
return dependencies;
|
|
35
32
|
}
|
|
36
|
-
exports.
|
|
33
|
+
exports.defaultDependencySelector = defaultDependencySelector;
|
|
37
34
|
/**
|
|
38
35
|
* The default pilet requester, which just returns an empty array.
|
|
39
36
|
* Use your own code to connect to the feed service.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":";;;AAAA,2CAA0E;AAE1E;;;GAGG;AACU,QAAA,kBAAkB,GAA0B;IACvD,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC;IACjC,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC;IACvC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,CAAC;IAC/C,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;IAC3B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAC3C,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;IACrC,sBAAsB,EAAE,OAAO,CAAC,sBAAsB,CAAC;CACxD,CAAC;AAEF,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE;IACnC,MAAM,gBAAgB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAE/D,IAAI,IAAA,mBAAM,EAAC,gBAAgB,CAAC,EAAE;QAC5B,gBAAgB,CAAC,0BAAkB,CAAC,CAAC;KACtC;CACF;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/modules/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
tslib_1.__exportStar(require("./api"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./dependencies"), exports);
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./api"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./dependencies"), exports);
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/lib/modules/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/modules/index.ts"],"names":[],"mappings":";;;AAAA,qDAAsB;AACtB,8DAA+B"}
|
|
@@ -1,28 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createActions = exports.includeActions = void 0;
|
|
4
|
-
|
|
5
|
-
var actions = require("../actions");
|
|
4
|
+
const actions = require("../actions");
|
|
6
5
|
function createContext(state, events) {
|
|
7
|
-
|
|
8
|
-
html:
|
|
9
|
-
|
|
10
|
-
return component;
|
|
11
|
-
},
|
|
12
|
-
}, state: state });
|
|
6
|
+
const ctx = Object.assign(Object.assign({}, events), { apis: {}, converters: {
|
|
7
|
+
html: ({ component }) => component,
|
|
8
|
+
}, state });
|
|
13
9
|
return ctx;
|
|
14
10
|
}
|
|
15
11
|
function includeActions(ctx, actions) {
|
|
16
|
-
|
|
17
|
-
for (
|
|
18
|
-
|
|
19
|
-
var action = actions[actionName];
|
|
12
|
+
const actionNames = Object.keys(actions);
|
|
13
|
+
for (const actionName of actionNames) {
|
|
14
|
+
const action = actions[actionName];
|
|
20
15
|
ctx[actionName] = action.bind(ctx, ctx);
|
|
21
16
|
}
|
|
22
17
|
}
|
|
23
18
|
exports.includeActions = includeActions;
|
|
24
19
|
function createActions(state, events) {
|
|
25
|
-
|
|
20
|
+
const context = createContext(state, events);
|
|
26
21
|
includeActions(context, actions);
|
|
27
22
|
return context;
|
|
28
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createActions.js","sourceRoot":"","sources":["../../src/state/createActions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createActions.js","sourceRoot":"","sources":["../../src/state/createActions.ts"],"names":[],"mappings":";;;AAAA,sCAAsC;AAItC,SAAS,aAAa,CAAC,KAAwB,EAAE,MAAoB;IACnE,MAAM,GAAG,GAAG,gCACP,MAAM,KACT,IAAI,EAAE,EAAE,EACR,UAAU,EAAE;YACV,IAAI,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS;SACnC,EACD,KAAK,GACgB,CAAC;IACxB,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAgB,cAAc,CAAC,GAAuB,EAAE,OAA2B;IACjF,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAEzC,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QACpC,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QACnC,GAAG,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;KACzC;AACH,CAAC;AAPD,wCAOC;AAED,SAAgB,aAAa,CAAC,KAAwB,EAAE,MAAoB;IAC1E,MAAM,OAAO,GAAG,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC7C,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,OAAO,CAAC;AACjB,CAAC;AAJD,sCAIC"}
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createGlobalState = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const react_atom_1 = require("@dbeining/react-atom");
|
|
5
|
+
const react_router_dom_1 = require("react-router-dom");
|
|
6
|
+
const components_1 = require("../components");
|
|
7
7
|
function extend(defaultState, customState) {
|
|
8
|
-
for (
|
|
9
|
-
var key = _a[_i];
|
|
8
|
+
for (const key of Object.keys(customState)) {
|
|
10
9
|
if (key === '__proto__' || key === 'constructor') {
|
|
11
10
|
continue;
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
const value = customState[key];
|
|
13
|
+
const original = defaultState[key];
|
|
14
|
+
const nested = typeof original === 'object' && typeof value === 'object';
|
|
16
15
|
defaultState[key] = nested ? extend(original, value) : value;
|
|
17
16
|
}
|
|
18
17
|
return defaultState;
|
|
19
18
|
}
|
|
20
|
-
function createGlobalState(customState) {
|
|
21
|
-
|
|
22
|
-
var defaultState = {
|
|
19
|
+
function createGlobalState(customState = {}) {
|
|
20
|
+
const defaultState = {
|
|
23
21
|
app: {
|
|
24
22
|
error: undefined,
|
|
25
23
|
loading: typeof window !== 'undefined',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createGlobalState.js","sourceRoot":"","sources":["../../src/state/createGlobalState.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"createGlobalState.js","sourceRoot":"","sources":["../../src/state/createGlobalState.ts"],"names":[],"mappings":";;;AAAA,qDAA4C;AAC5C,uDAAiD;AACjD,8CAAyF;AAGzF,SAAS,MAAM,CAAI,YAAe,EAAE,WAA6B;IAC/D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE;QAC1C,IAAI,GAAG,KAAK,WAAW,IAAI,GAAG,KAAK,aAAa,EAAE;YAChD,SAAS;SACV;QAED,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QACnC,MAAM,MAAM,GAAG,OAAO,QAAQ,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;QACzE,YAAY,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;KAC9D;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAgB,iBAAiB,CAAC,cAA0C,EAAE;IAC5E,MAAM,YAAY,GAAgB;QAChC,GAAG,EAAE;YACH,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,OAAO,MAAM,KAAK,WAAW;YACtC,MAAM,EAAE,SAAS;SAClB;QACD,UAAU,EAAE;YACV,SAAS,EAAE,6BAAgB;YAC3B,gBAAgB,EAAE,oCAAuB;YACzC,MAAM,EAAE,gCAAa;YACrB,MAAM,EAAE,0BAAa;SACtB;QACD,eAAe,EAAE,EAAE;QACnB,QAAQ,EAAE;YACR,UAAU,EAAE,EAAE;YACd,KAAK,EAAE,EAAE;YACT,QAAQ,EAAE,EAAE;SACb;QACD,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,EAAE;QACR,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,EAAE;KACZ,CAAC;IAEF,OAAO,iBAAI,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;AACpD,CAAC;AA1BD,8CA0BC"}
|
package/lib/state/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
tslib_1.__exportStar(require("./createActions"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./createGlobalState"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./stateContext"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./withApi"), exports);
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
(0, tslib_1.__exportStar)(require("./createActions"), exports);
|
|
5
|
+
(0, tslib_1.__exportStar)(require("./createGlobalState"), exports);
|
|
6
|
+
(0, tslib_1.__exportStar)(require("./stateContext"), exports);
|
|
7
|
+
(0, tslib_1.__exportStar)(require("./withApi"), exports);
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
package/lib/state/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":";;;AAAA,+DAAgC;AAChC,mEAAoC;AACpC,8DAA+B;AAC/B,yDAA0B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.StateContext = void 0;
|
|
4
|
-
|
|
4
|
+
const React = require("react");
|
|
5
5
|
exports.StateContext = React.createContext(undefined);
|
|
6
6
|
exports.default = exports.StateContext;
|
|
7
7
|
//# sourceMappingURL=stateContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stateContext.js","sourceRoot":"","sources":["../../src/state/stateContext.tsx"],"names":[],"mappings":";;;AAAA
|
|
1
|
+
{"version":3,"file":"stateContext.js","sourceRoot":"","sources":["../../src/state/stateContext.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAGlB,QAAA,YAAY,GAAG,KAAK,CAAC,aAAa,CAAqB,SAAS,CAAC,CAAC;AAE/E,kBAAe,oBAAY,CAAC"}
|
package/lib/state/withApi.js
CHANGED
|
@@ -1,84 +1,82 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.withApi = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
_this.setNode = function (node) {
|
|
25
|
-
_this.current = node;
|
|
4
|
+
const React = require("react");
|
|
5
|
+
const piral_base_1 = require("piral-base");
|
|
6
|
+
const react_router_1 = require("react-router");
|
|
7
|
+
const stateContext_1 = require("./stateContext");
|
|
8
|
+
const components_1 = require("../components");
|
|
9
|
+
const hooks_1 = require("../hooks");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
11
|
+
// this is an arbitrary start number to have 6 digits
|
|
12
|
+
let portalIdBase = 123456;
|
|
13
|
+
const DefaultWrapper = (props) => (0, utils_1.defaultRender)(props.children);
|
|
14
|
+
class ForeignComponentContainer extends React.Component {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.handler = (ev) => {
|
|
18
|
+
const { innerProps } = this.props;
|
|
19
|
+
ev.stopPropagation();
|
|
20
|
+
innerProps.piral.renderHtmlExtension(ev.detail.target, ev.detail.props);
|
|
21
|
+
};
|
|
22
|
+
this.setNode = (node) => {
|
|
23
|
+
this.current = node;
|
|
26
24
|
};
|
|
27
|
-
return _this;
|
|
28
25
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (node && piral_base_1.isfunc(mount)) {
|
|
26
|
+
componentDidMount() {
|
|
27
|
+
const node = this.current;
|
|
28
|
+
const { $component, $context, innerProps } = this.props;
|
|
29
|
+
const { mount } = $component;
|
|
30
|
+
if (node && (0, piral_base_1.isfunc)(mount)) {
|
|
34
31
|
mount(node, innerProps, $context);
|
|
32
|
+
node.addEventListener('render-html', this.handler, false);
|
|
35
33
|
}
|
|
36
34
|
this.previous = node;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
}
|
|
36
|
+
componentDidUpdate() {
|
|
37
|
+
const { current, previous } = this;
|
|
38
|
+
const { $component, $context, innerProps } = this.props;
|
|
39
|
+
const { update } = $component;
|
|
42
40
|
if (current !== previous) {
|
|
43
41
|
previous && this.componentWillUnmount();
|
|
44
42
|
current && this.componentDidMount();
|
|
45
43
|
}
|
|
46
|
-
else if (piral_base_1.isfunc(update)) {
|
|
44
|
+
else if ((0, piral_base_1.isfunc)(update)) {
|
|
47
45
|
update(current, innerProps, $context);
|
|
48
46
|
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (node && piral_base_1.isfunc(unmount)) {
|
|
47
|
+
}
|
|
48
|
+
componentWillUnmount() {
|
|
49
|
+
const node = this.previous;
|
|
50
|
+
const { $component } = this.props;
|
|
51
|
+
const { unmount } = $component;
|
|
52
|
+
if (node && (0, piral_base_1.isfunc)(unmount)) {
|
|
55
53
|
unmount(node);
|
|
54
|
+
node.removeEventListener('render-html', this.handler, false);
|
|
56
55
|
}
|
|
57
56
|
this.previous = undefined;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
}
|
|
58
|
+
render() {
|
|
59
|
+
const { $portalId } = this.props;
|
|
61
60
|
return React.createElement("div", { "data-portal-id": $portalId, ref: this.setNode });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
}(React.Component));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
65
63
|
function wrapReactComponent(Component, stasisOptions, piral, Wrapper) {
|
|
66
|
-
return
|
|
67
|
-
React.createElement(components_1.ErrorBoundary,
|
|
68
|
-
React.createElement(Component,
|
|
64
|
+
return (props) => (React.createElement(Wrapper, Object.assign({}, props, { piral: piral }),
|
|
65
|
+
React.createElement(components_1.ErrorBoundary, Object.assign({}, stasisOptions, { renderProps: props }),
|
|
66
|
+
React.createElement(Component, Object.assign({}, props, { piral: piral })))));
|
|
69
67
|
}
|
|
70
68
|
function wrapForeignComponent(component, stasisOptions, piral, Wrapper) {
|
|
71
|
-
return React.memo(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
React.useEffect(
|
|
79
|
-
return (React.createElement(Wrapper,
|
|
80
|
-
React.createElement(components_1.ErrorBoundary,
|
|
81
|
-
React.createElement(PortalRenderer, { id: id }),
|
|
69
|
+
return React.memo((props) => {
|
|
70
|
+
const { destroyPortal } = (0, hooks_1.useActions)();
|
|
71
|
+
const { state } = React.useContext(stateContext_1.StateContext);
|
|
72
|
+
const router = React.useContext(react_router_1.__RouterContext);
|
|
73
|
+
const id = React.useMemo(() => (portalIdBase++).toString(26), utils_1.none);
|
|
74
|
+
const context = React.useMemo(() => ({ router, state }), [router, state]);
|
|
75
|
+
const innerProps = React.useMemo(() => (Object.assign(Object.assign({}, props), { piral })), [props]);
|
|
76
|
+
React.useEffect(() => () => destroyPortal(id), utils_1.none);
|
|
77
|
+
return (React.createElement(Wrapper, Object.assign({}, innerProps),
|
|
78
|
+
React.createElement(components_1.ErrorBoundary, Object.assign({}, stasisOptions, { renderProps: props }),
|
|
79
|
+
React.createElement(components_1.PortalRenderer, { id: id }),
|
|
82
80
|
React.createElement(ForeignComponentContainer, { innerProps: innerProps, "$portalId": id, "$component": component, "$context": context }))));
|
|
83
81
|
});
|
|
84
82
|
}
|
|
@@ -89,10 +87,10 @@ function wrapComponent(converters, component, piral, Wrapper, stasisOptions) {
|
|
|
89
87
|
if (!component) {
|
|
90
88
|
console.error('The given value is not a valid component.');
|
|
91
89
|
// tslint:disable-next-line:no-null-keyword
|
|
92
|
-
component =
|
|
90
|
+
component = () => null;
|
|
93
91
|
}
|
|
94
92
|
if (typeof component === 'object' && isNotExotic(component)) {
|
|
95
|
-
|
|
93
|
+
const result = (0, utils_1.convertComponent)(converters[component.type], component);
|
|
96
94
|
return wrapForeignComponent(result, stasisOptions, piral, Wrapper);
|
|
97
95
|
}
|
|
98
96
|
return wrapReactComponent(component, stasisOptions, piral, Wrapper);
|
|
@@ -100,19 +98,18 @@ function wrapComponent(converters, component, piral, Wrapper, stasisOptions) {
|
|
|
100
98
|
function getWrapper(wrappers, wrapperType) {
|
|
101
99
|
return wrappers[wrapperType] || wrappers['*'] || DefaultWrapper;
|
|
102
100
|
}
|
|
103
|
-
function withApi(context, component, piral, errorType, wrapperType) {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
var Wrapper = context.readState(function (m) { return getWrapper(m.registry.wrappers, wrapperType); });
|
|
101
|
+
function withApi(context, component, piral, errorType, wrapperType = errorType) {
|
|
102
|
+
const converters = context.converters;
|
|
103
|
+
const Wrapper = context.readState((m) => getWrapper(m.registry.wrappers, wrapperType));
|
|
107
104
|
return wrapComponent(converters, component, piral, Wrapper, {
|
|
108
|
-
onError
|
|
105
|
+
onError(error) {
|
|
109
106
|
console.error(piral, error);
|
|
110
107
|
},
|
|
111
|
-
renderChild
|
|
108
|
+
renderChild(child) {
|
|
112
109
|
return React.createElement(React.Suspense, { fallback: React.createElement(components_1.PiralLoadingIndicator, null) }, child);
|
|
113
110
|
},
|
|
114
|
-
renderError
|
|
115
|
-
return React.createElement(components_1.PiralError,
|
|
111
|
+
renderError(error, props) {
|
|
112
|
+
return React.createElement(components_1.PiralError, Object.assign({ type: errorType, error: error }, props));
|
|
116
113
|
},
|
|
117
114
|
});
|
|
118
115
|
}
|
package/lib/state/withApi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withApi.js","sourceRoot":"","sources":["../../src/state/withApi.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"withApi.js","sourceRoot":"","sources":["../../src/state/withApi.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,2CAAoC;AACpC,+CAA+C;AAC/C,iDAA8C;AAC9C,8CAAuH;AACvH,oCAAsC;AACtC,oCAAiE;AAYjE,qDAAqD;AACrD,IAAI,YAAY,GAAG,MAAM,CAAC;AAE1B,MAAM,cAAc,GAAa,CAAC,KAAK,EAAE,EAAE,CAAC,IAAA,qBAAa,EAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAS1E,MAAM,yBAA6B,S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