chayns-api 3.0.0 → 3.1.0-beta.0
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/dist/cjs/calls/index.js +4 -1
- package/dist/cjs/calls/visibilityChangeListener.js +4 -4
- package/dist/cjs/components/ChaynsProvider.js +34 -6
- package/dist/cjs/components/withHydrationBoundary.js +2 -2
- package/dist/cjs/constants/index.js +0 -22
- package/dist/cjs/contexts/HistoryLayerContext.js +89 -0
- package/dist/cjs/contexts/index.js +38 -0
- package/dist/cjs/handler/history/FrameHistoryLayer.js +100 -0
- package/dist/cjs/handler/history/HistoryLayer.js +321 -0
- package/dist/cjs/handler/history/index.js +19 -0
- package/dist/cjs/hooks/history.js +454 -0
- package/dist/cjs/hooks/index.js +62 -1
- package/dist/cjs/host/ChaynsHost.js +113 -54
- package/dist/cjs/host/iframe/HostIframe.js +70 -5
- package/dist/cjs/host/module/ModuleHost.js +50 -44
- package/dist/cjs/index.js +139 -6
- package/dist/cjs/types/history.js +1 -0
- package/dist/cjs/umd.index.js +2 -2
- package/dist/cjs/utils/EventBus.js +33 -0
- package/dist/cjs/{util → utils}/appStorage.js +2 -2
- package/dist/cjs/utils/equality.js +19 -0
- package/dist/cjs/utils/history/BlockRegistry.js +110 -0
- package/dist/cjs/utils/history/NavigationQueue.js +388 -0
- package/dist/cjs/utils/history/layerTree.js +32 -0
- package/dist/cjs/utils/history/navigationIndex.js +42 -0
- package/dist/cjs/utils/history/rootLayer.js +175 -0
- package/dist/cjs/utils/history/segments.js +15 -0
- package/dist/cjs/utils/history/stateProjector.js +156 -0
- package/dist/cjs/utils/history/url.js +47 -0
- package/dist/cjs/utils/history/window.js +9 -0
- package/dist/cjs/wrapper/AppWrapper.js +23 -23
- package/dist/cjs/wrapper/FrameWrapper.js +35 -2
- package/dist/cjs/wrapper/ModuleFederationWrapper.js +2 -0
- package/dist/cjs/wrapper/StaticChaynsApi.js +1 -1
- package/dist/esm/calls/index.js +2 -0
- package/dist/esm/calls/visibilityChangeListener.js +1 -1
- package/dist/esm/components/ChaynsProvider.js +34 -6
- package/dist/esm/components/withHydrationBoundary.js +1 -1
- package/dist/esm/constants/index.js +1 -3
- package/dist/esm/contexts/HistoryLayerContext.js +76 -0
- package/dist/esm/contexts/index.js +3 -0
- package/dist/esm/handler/history/FrameHistoryLayer.js +105 -0
- package/dist/esm/handler/history/HistoryLayer.js +321 -0
- package/dist/esm/handler/history/index.js +2 -0
- package/dist/esm/hooks/history.js +428 -0
- package/dist/esm/hooks/index.js +2 -1
- package/dist/esm/host/ChaynsHost.js +113 -54
- package/dist/esm/host/iframe/HostIframe.js +70 -5
- package/dist/esm/host/module/ModuleHost.js +50 -44
- package/dist/esm/index.js +15 -6
- package/dist/esm/types/history.js +1 -0
- package/dist/esm/umd.index.js +2 -2
- package/dist/esm/utils/EventBus.js +31 -0
- package/dist/esm/{util → utils}/appStorage.js +1 -1
- package/dist/esm/utils/equality.js +12 -0
- package/dist/esm/utils/history/BlockRegistry.js +108 -0
- package/dist/esm/utils/history/NavigationQueue.js +385 -0
- package/dist/esm/utils/history/layerTree.js +24 -0
- package/dist/esm/utils/history/navigationIndex.js +33 -0
- package/dist/esm/utils/history/rootLayer.js +167 -0
- package/dist/esm/utils/history/segments.js +7 -0
- package/dist/esm/utils/history/stateProjector.js +147 -0
- package/dist/esm/utils/history/url.js +40 -0
- package/dist/esm/utils/history/window.js +3 -0
- package/dist/esm/wrapper/AppWrapper.js +5 -5
- package/dist/esm/wrapper/FrameWrapper.js +35 -2
- package/dist/esm/wrapper/ModuleFederationWrapper.js +2 -0
- package/dist/esm/wrapper/StaticChaynsApi.js +2 -1
- package/dist/types/calls/index.d.ts +5 -0
- package/dist/types/components/ChaynsProvider.d.ts +21 -0
- package/dist/types/constants/index.d.ts +0 -2
- package/dist/types/contexts/HistoryLayerContext.d.ts +33 -0
- package/dist/types/contexts/index.d.ts +3 -0
- package/dist/types/handler/history/FrameHistoryLayer.d.ts +99 -0
- package/dist/types/handler/history/HistoryLayer.d.ts +117 -0
- package/dist/types/handler/history/index.d.ts +2 -0
- package/dist/types/hooks/history.d.ts +89 -0
- package/dist/types/hooks/index.d.ts +1 -0
- package/dist/types/host/ChaynsHost.d.ts +12 -0
- package/dist/types/host/iframe/HostIframe.d.ts +4 -0
- package/dist/types/host/module/ModuleHost.d.ts +4 -0
- package/dist/types/index.d.ts +15 -6
- package/dist/types/types/IChaynsReact.d.ts +3 -0
- package/dist/types/types/history.d.ts +74 -0
- package/dist/types/umd.index.d.ts +2 -2
- package/dist/types/utils/EventBus.d.ts +10 -0
- package/dist/types/{util → utils}/collectCssChunks.d.ts +1 -1
- package/dist/types/utils/equality.d.ts +2 -0
- package/dist/types/utils/history/BlockRegistry.d.ts +38 -0
- package/dist/types/utils/history/NavigationQueue.d.ts +109 -0
- package/dist/types/utils/history/layerTree.d.ts +10 -0
- package/dist/types/utils/history/navigationIndex.d.ts +14 -0
- package/dist/types/utils/history/rootLayer.d.ts +42 -0
- package/dist/types/utils/history/segments.d.ts +2 -0
- package/dist/types/utils/history/stateProjector.d.ts +24 -0
- package/dist/types/utils/history/url.d.ts +17 -0
- package/dist/types/utils/history/window.d.ts +1 -0
- package/dist/types/wrapper/FrameWrapper.d.ts +1 -0
- package/dist/types/wrapper/StaticChaynsApi.d.ts +1 -0
- package/package.json +2 -1
- /package/dist/cjs/{constants → contexts}/hydrationContext.js +0 -0
- /package/dist/cjs/{constants → contexts}/moduleContext.js +0 -0
- /package/dist/cjs/{helper/apiListenerHelper.js → utils/apiListener.js} +0 -0
- /package/dist/cjs/{util → utils}/appCall.js +0 -0
- /package/dist/cjs/{util → utils}/bindChaynsApi.js +0 -0
- /package/dist/cjs/{util → utils}/collectCssChunks.js +0 -0
- /package/dist/cjs/{util → utils}/deviceHelper.js +0 -0
- /package/dist/cjs/{util → utils}/heightHelper.js +0 -0
- /package/dist/cjs/{util → utils}/initModuleFederationSharing.js +0 -0
- /package/dist/cjs/{util → utils}/is.js +0 -0
- /package/dist/cjs/{util → utils}/postIframeForm.js +0 -0
- /package/dist/cjs/{util → utils}/transferNestedFunctions.js +0 -0
- /package/dist/cjs/{util → utils}/url.js +0 -0
- /package/dist/esm/{constants → contexts}/hydrationContext.js +0 -0
- /package/dist/esm/{constants → contexts}/moduleContext.js +0 -0
- /package/dist/esm/{helper/apiListenerHelper.js → utils/apiListener.js} +0 -0
- /package/dist/esm/{util → utils}/appCall.js +0 -0
- /package/dist/esm/{util → utils}/bindChaynsApi.js +0 -0
- /package/dist/esm/{util → utils}/collectCssChunks.js +0 -0
- /package/dist/esm/{util → utils}/deviceHelper.js +0 -0
- /package/dist/esm/{util → utils}/heightHelper.js +0 -0
- /package/dist/esm/{util → utils}/initModuleFederationSharing.js +0 -0
- /package/dist/esm/{util → utils}/is.js +0 -0
- /package/dist/esm/{util → utils}/postIframeForm.js +0 -0
- /package/dist/esm/{util → utils}/transferNestedFunctions.js +0 -0
- /package/dist/esm/{util → utils}/url.js +0 -0
- /package/dist/types/{constants → contexts}/hydrationContext.d.ts +0 -0
- /package/dist/types/{constants → contexts}/moduleContext.d.ts +0 -0
- /package/dist/types/{helper/apiListenerHelper.d.ts → utils/apiListener.d.ts} +0 -0
- /package/dist/types/{util → utils}/appCall.d.ts +0 -0
- /package/dist/types/{util → utils}/appStorage.d.ts +0 -0
- /package/dist/types/{util → utils}/bindChaynsApi.d.ts +0 -0
- /package/dist/types/{util → utils}/deviceHelper.d.ts +0 -0
- /package/dist/types/{util → utils}/heightHelper.d.ts +0 -0
- /package/dist/types/{util → utils}/initModuleFederationSharing.d.ts +0 -0
- /package/dist/types/{util → utils}/is.d.ts +0 -0
- /package/dist/types/{util → utils}/postIframeForm.d.ts +0 -0
- /package/dist/types/{util → utils}/transferNestedFunctions.d.ts +0 -0
- /package/dist/types/{util → utils}/url.d.ts +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
2
2
|
import React, { useEffect, useRef } from 'react';
|
|
3
3
|
import * as comlink from 'comlink';
|
|
4
|
-
import postIframeForm from '../../
|
|
4
|
+
import postIframeForm from '../../utils/postIframeForm';
|
|
5
5
|
import useUpdateData from './utils/useUpdateData';
|
|
6
|
-
import { replaceStagingUrl } from "../../
|
|
7
|
-
import { initTransferNestedFunctions } from '../../
|
|
6
|
+
import { replaceStagingUrl } from "../../utils/url";
|
|
7
|
+
import { initTransferNestedFunctions } from '../../utils/transferNestedFunctions';
|
|
8
8
|
const HostIframe = ({
|
|
9
9
|
iFrameProps,
|
|
10
10
|
src,
|
|
@@ -24,13 +24,17 @@ const HostIframe = ({
|
|
|
24
24
|
customData,
|
|
25
25
|
preventStagingReplacement,
|
|
26
26
|
dialog,
|
|
27
|
-
styleSettings
|
|
27
|
+
styleSettings,
|
|
28
|
+
historyLayer,
|
|
29
|
+
isHistoryDisabled
|
|
28
30
|
}) => {
|
|
29
31
|
const eventTarget = useRef();
|
|
30
32
|
const ref = useRef();
|
|
31
33
|
const currentDataRef = useRef();
|
|
32
34
|
const customFunctionsRef = useRef();
|
|
33
35
|
customFunctionsRef.current = customFunctions;
|
|
36
|
+
const historyLayerRef = useRef(undefined);
|
|
37
|
+
historyLayerRef.current = historyLayer;
|
|
34
38
|
if (!eventTarget.current) {
|
|
35
39
|
eventTarget.current = global.document ? document.createElement('div') : undefined;
|
|
36
40
|
}
|
|
@@ -42,6 +46,7 @@ const HostIframe = ({
|
|
|
42
46
|
const initialData = {
|
|
43
47
|
site,
|
|
44
48
|
isAdminModeActive,
|
|
49
|
+
isHistoryDisabled,
|
|
45
50
|
pages,
|
|
46
51
|
currentPage,
|
|
47
52
|
device,
|
|
@@ -87,7 +92,66 @@ const HostIframe = ({
|
|
|
87
92
|
addDataListener: cb => {
|
|
88
93
|
if (eventTarget.current) eventTarget.current.addEventListener('data_update', e => e.detail && cb(e.detail));
|
|
89
94
|
},
|
|
90
|
-
getInitialData: () => currentDataRef.current
|
|
95
|
+
getInitialData: () => currentDataRef.current,
|
|
96
|
+
history: historyLayerRef.current ? {
|
|
97
|
+
getInitialState: () => {
|
|
98
|
+
const l = historyLayerRef.current;
|
|
99
|
+
if (!l) return null;
|
|
100
|
+
return {
|
|
101
|
+
id: l.id,
|
|
102
|
+
depth: l.depth,
|
|
103
|
+
segments: l.getRoute(),
|
|
104
|
+
params: l.getParams(),
|
|
105
|
+
hash: l.getHash(),
|
|
106
|
+
state: l.getState(),
|
|
107
|
+
activeChildId: l.getActiveChildId(),
|
|
108
|
+
segmentCount: l.getSegmentCount()
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
setRoute: (route, opts) => {
|
|
112
|
+
var _historyLayerRef$curr;
|
|
113
|
+
return (_historyLayerRef$curr = historyLayerRef.current) === null || _historyLayerRef$curr === void 0 ? void 0 : _historyLayerRef$curr.setRoute(route, opts);
|
|
114
|
+
},
|
|
115
|
+
setParams: (params, opts) => {
|
|
116
|
+
var _historyLayerRef$curr2;
|
|
117
|
+
return (_historyLayerRef$curr2 = historyLayerRef.current) === null || _historyLayerRef$curr2 === void 0 ? void 0 : _historyLayerRef$curr2.setParams(params, opts);
|
|
118
|
+
},
|
|
119
|
+
setHash: (hash, opts) => {
|
|
120
|
+
var _historyLayerRef$curr3;
|
|
121
|
+
return (_historyLayerRef$curr3 = historyLayerRef.current) === null || _historyLayerRef$curr3 === void 0 ? void 0 : _historyLayerRef$curr3.setHash(hash, opts);
|
|
122
|
+
},
|
|
123
|
+
setState: (state, opts) => {
|
|
124
|
+
var _historyLayerRef$curr4;
|
|
125
|
+
return (_historyLayerRef$curr4 = historyLayerRef.current) === null || _historyLayerRef$curr4 === void 0 ? void 0 : _historyLayerRef$curr4.setState(state, opts);
|
|
126
|
+
},
|
|
127
|
+
navigate: opts => {
|
|
128
|
+
var _historyLayerRef$curr5;
|
|
129
|
+
return (_historyLayerRef$curr5 = historyLayerRef.current) === null || _historyLayerRef$curr5 === void 0 ? void 0 : _historyLayerRef$curr5.navigate(opts);
|
|
130
|
+
},
|
|
131
|
+
setActiveChild: (id, init) => {
|
|
132
|
+
var _historyLayerRef$curr6;
|
|
133
|
+
return (_historyLayerRef$curr6 = historyLayerRef.current) === null || _historyLayerRef$curr6 === void 0 ? void 0 : _historyLayerRef$curr6.setActiveChild(id, init);
|
|
134
|
+
},
|
|
135
|
+
setSegmentCount: n => {
|
|
136
|
+
var _historyLayerRef$curr7;
|
|
137
|
+
return (_historyLayerRef$curr7 = historyLayerRef.current) === null || _historyLayerRef$curr7 === void 0 ? void 0 : _historyLayerRef$curr7.setSegmentCount(n);
|
|
138
|
+
},
|
|
139
|
+
addChangeListener: callback => {
|
|
140
|
+
var _historyLayerRef$curr8, _historyLayerRef$curr9;
|
|
141
|
+
const unsub = (_historyLayerRef$curr8 = (_historyLayerRef$curr9 = historyLayerRef.current) === null || _historyLayerRef$curr9 === void 0 ? void 0 : _historyLayerRef$curr9.addEventListener('change', callback)) !== null && _historyLayerRef$curr8 !== void 0 ? _historyLayerRef$curr8 : () => {};
|
|
142
|
+
return comlink.proxy(unsub);
|
|
143
|
+
},
|
|
144
|
+
addPopstateListener: callback => {
|
|
145
|
+
var _historyLayerRef$curr0, _historyLayerRef$curr1;
|
|
146
|
+
const unsub = (_historyLayerRef$curr0 = (_historyLayerRef$curr1 = historyLayerRef.current) === null || _historyLayerRef$curr1 === void 0 ? void 0 : _historyLayerRef$curr1.addEventListener('popstate', callback)) !== null && _historyLayerRef$curr0 !== void 0 ? _historyLayerRef$curr0 : () => {};
|
|
147
|
+
return comlink.proxy(unsub);
|
|
148
|
+
},
|
|
149
|
+
addBlock: (callback, opts) => {
|
|
150
|
+
var _historyLayerRef$curr10, _historyLayerRef$curr11;
|
|
151
|
+
const unsub = (_historyLayerRef$curr10 = (_historyLayerRef$curr11 = historyLayerRef.current) === null || _historyLayerRef$curr11 === void 0 ? void 0 : _historyLayerRef$curr11.addBlock(callback, opts)) !== null && _historyLayerRef$curr10 !== void 0 ? _historyLayerRef$curr10 : () => {};
|
|
152
|
+
return comlink.proxy(unsub);
|
|
153
|
+
}
|
|
154
|
+
} : undefined
|
|
91
155
|
}
|
|
92
156
|
};
|
|
93
157
|
comlink.expose(obj, comlink.windowEndpoint(ref.current.contentWindow));
|
|
@@ -98,6 +162,7 @@ const HostIframe = ({
|
|
|
98
162
|
}
|
|
99
163
|
return undefined;
|
|
100
164
|
}, []);
|
|
165
|
+
useUpdateData(eventTarget.current, 'isHistoryDisabled', isHistoryDisabled);
|
|
101
166
|
useUpdateData(eventTarget.current, 'isAdminModeActive', isAdminModeActive);
|
|
102
167
|
useUpdateData(eventTarget.current, 'user', user);
|
|
103
168
|
useUpdateData(eventTarget.current, 'site', site);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { c as _c } from "react-compiler-runtime";
|
|
2
2
|
import React, { useContext, useMemo } from 'react';
|
|
3
|
-
import { ModuleContext } from '../../
|
|
3
|
+
import { ModuleContext } from '../../contexts/moduleContext';
|
|
4
4
|
import loadComponent from './utils/loadComponent';
|
|
5
|
-
import { replaceStagingUrl } from "../../
|
|
5
|
+
import { replaceStagingUrl } from "../../utils/url";
|
|
6
6
|
const System = ({
|
|
7
7
|
system,
|
|
8
8
|
fallback,
|
|
@@ -24,7 +24,7 @@ const System = ({
|
|
|
24
24
|
}, React.createElement(Component, props));
|
|
25
25
|
};
|
|
26
26
|
const ModuleHost = t0 => {
|
|
27
|
-
const $ = _c(
|
|
27
|
+
const $ = _c(36);
|
|
28
28
|
const {
|
|
29
29
|
system,
|
|
30
30
|
children: t1,
|
|
@@ -42,14 +42,17 @@ const ModuleHost = t0 => {
|
|
|
42
42
|
dialog,
|
|
43
43
|
environment,
|
|
44
44
|
preventStagingReplacement,
|
|
45
|
-
styleSettings
|
|
45
|
+
styleSettings,
|
|
46
|
+
historyLayer,
|
|
47
|
+
isHistoryDisabled
|
|
46
48
|
} = t0;
|
|
47
49
|
const children = t1 === undefined ? null : t1;
|
|
48
50
|
let result;
|
|
49
|
-
if ($[0] !== currentPage || $[1] !== customData || $[2] !== device || $[3] !== dialog || $[4] !== environment || $[5] !== isAdminModeActive || $[6] !==
|
|
51
|
+
if ($[0] !== currentPage || $[1] !== customData || $[2] !== device || $[3] !== dialog || $[4] !== environment || $[5] !== isAdminModeActive || $[6] !== isHistoryDisabled || $[7] !== language || $[8] !== pages || $[9] !== parameters || $[10] !== site || $[11] !== styleSettings || $[12] !== user) {
|
|
50
52
|
result = {
|
|
51
53
|
site,
|
|
52
54
|
isAdminModeActive,
|
|
55
|
+
isHistoryDisabled,
|
|
53
56
|
pages,
|
|
54
57
|
currentPage,
|
|
55
58
|
device,
|
|
@@ -71,49 +74,50 @@ const ModuleHost = t0 => {
|
|
|
71
74
|
$[3] = dialog;
|
|
72
75
|
$[4] = environment;
|
|
73
76
|
$[5] = isAdminModeActive;
|
|
74
|
-
$[6] =
|
|
75
|
-
$[7] =
|
|
76
|
-
$[8] =
|
|
77
|
-
$[9] =
|
|
78
|
-
$[10] =
|
|
79
|
-
$[11] =
|
|
80
|
-
$[12] =
|
|
77
|
+
$[6] = isHistoryDisabled;
|
|
78
|
+
$[7] = language;
|
|
79
|
+
$[8] = pages;
|
|
80
|
+
$[9] = parameters;
|
|
81
|
+
$[10] = site;
|
|
82
|
+
$[11] = styleSettings;
|
|
83
|
+
$[12] = user;
|
|
84
|
+
$[13] = result;
|
|
81
85
|
} else {
|
|
82
|
-
result = $[
|
|
86
|
+
result = $[13];
|
|
83
87
|
}
|
|
84
88
|
const data = result;
|
|
85
89
|
let t2;
|
|
86
|
-
if ($[
|
|
90
|
+
if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
|
|
87
91
|
t2 = React.createElement("div", {
|
|
88
92
|
className: "module-css"
|
|
89
93
|
});
|
|
90
|
-
$[
|
|
94
|
+
$[14] = t2;
|
|
91
95
|
} else {
|
|
92
|
-
t2 = $[
|
|
96
|
+
t2 = $[14];
|
|
93
97
|
}
|
|
94
98
|
const t3 = system.scope;
|
|
95
99
|
let t4;
|
|
96
|
-
if ($[
|
|
100
|
+
if ($[15] !== environment.buildEnvironment || $[16] !== preventStagingReplacement || $[17] !== system.url) {
|
|
97
101
|
t4 = replaceStagingUrl(preventStagingReplacement, system.url, environment.buildEnvironment);
|
|
98
|
-
$[
|
|
99
|
-
$[
|
|
100
|
-
$[
|
|
101
|
-
$[
|
|
102
|
+
$[15] = environment.buildEnvironment;
|
|
103
|
+
$[16] = preventStagingReplacement;
|
|
104
|
+
$[17] = system.url;
|
|
105
|
+
$[18] = t4;
|
|
102
106
|
} else {
|
|
103
|
-
t4 = $[
|
|
107
|
+
t4 = $[18];
|
|
104
108
|
}
|
|
105
109
|
let t5;
|
|
106
|
-
if ($[
|
|
110
|
+
if ($[19] !== environment.buildEnvironment || $[20] !== preventStagingReplacement || $[21] !== system.serverUrl) {
|
|
107
111
|
t5 = replaceStagingUrl(preventStagingReplacement, system.serverUrl, environment.buildEnvironment);
|
|
108
|
-
$[
|
|
109
|
-
$[
|
|
110
|
-
$[
|
|
111
|
-
$[
|
|
112
|
+
$[19] = environment.buildEnvironment;
|
|
113
|
+
$[20] = preventStagingReplacement;
|
|
114
|
+
$[21] = system.serverUrl;
|
|
115
|
+
$[22] = t5;
|
|
112
116
|
} else {
|
|
113
|
-
t5 = $[
|
|
117
|
+
t5 = $[22];
|
|
114
118
|
}
|
|
115
119
|
let t6;
|
|
116
|
-
if ($[
|
|
120
|
+
if ($[23] !== system.module || $[24] !== system.preventSingleton || $[25] !== system.scope || $[26] !== t4 || $[27] !== t5) {
|
|
117
121
|
t6 = {
|
|
118
122
|
scope: t3,
|
|
119
123
|
url: t4,
|
|
@@ -121,33 +125,35 @@ const ModuleHost = t0 => {
|
|
|
121
125
|
module: system.module,
|
|
122
126
|
preventSingleton: system.preventSingleton
|
|
123
127
|
};
|
|
124
|
-
$[
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
127
|
-
$[
|
|
128
|
-
$[
|
|
129
|
-
$[
|
|
128
|
+
$[23] = system.module;
|
|
129
|
+
$[24] = system.preventSingleton;
|
|
130
|
+
$[25] = system.scope;
|
|
131
|
+
$[26] = t4;
|
|
132
|
+
$[27] = t5;
|
|
133
|
+
$[28] = t6;
|
|
130
134
|
} else {
|
|
131
|
-
t6 = $[
|
|
135
|
+
t6 = $[28];
|
|
132
136
|
}
|
|
133
137
|
let t7;
|
|
134
|
-
if ($[
|
|
138
|
+
if ($[29] !== children || $[30] !== customFunctions || $[31] !== data || $[32] !== functions || $[33] !== historyLayer || $[34] !== t6) {
|
|
135
139
|
t7 = React.createElement(React.Fragment, null, t2, React.createElement(System, {
|
|
136
140
|
system: t6,
|
|
137
141
|
data: data,
|
|
138
142
|
functions: functions,
|
|
139
143
|
customFunctions: customFunctions,
|
|
140
144
|
fallback: children,
|
|
145
|
+
historyLayer: historyLayer,
|
|
141
146
|
isModule: true
|
|
142
147
|
}));
|
|
143
|
-
$[
|
|
144
|
-
$[
|
|
145
|
-
$[
|
|
146
|
-
$[
|
|
147
|
-
$[
|
|
148
|
-
$[
|
|
148
|
+
$[29] = children;
|
|
149
|
+
$[30] = customFunctions;
|
|
150
|
+
$[31] = data;
|
|
151
|
+
$[32] = functions;
|
|
152
|
+
$[33] = historyLayer;
|
|
153
|
+
$[34] = t6;
|
|
154
|
+
$[35] = t7;
|
|
149
155
|
} else {
|
|
150
|
-
t7 = $[
|
|
156
|
+
t7 = $[35];
|
|
151
157
|
}
|
|
152
158
|
return t7;
|
|
153
159
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -1,22 +1,31 @@
|
|
|
1
1
|
export { default as ChaynsProvider } from './components/ChaynsProvider';
|
|
2
|
-
export { default as getDeviceInfo, getScreenSize, getClientDeviceInfo } from './
|
|
2
|
+
export { default as getDeviceInfo, getScreenSize, getClientDeviceInfo } from './utils/deviceHelper';
|
|
3
3
|
export { default as ChaynsHost } from './host/ChaynsHost';
|
|
4
4
|
export { withCompatMode } from './components/withCompatMode';
|
|
5
5
|
export * from './calls';
|
|
6
6
|
export * from './hooks';
|
|
7
7
|
export * from './components/WaitUntil';
|
|
8
8
|
export * from './types/IChaynsReact';
|
|
9
|
-
export * from './
|
|
9
|
+
export * from './types/history';
|
|
10
|
+
export * from './utils/is';
|
|
10
11
|
export * from './constants';
|
|
11
12
|
export { default as withHydrationBoundary } from './components/withHydrationBoundary';
|
|
12
13
|
export { default as StaticChaynsApi } from './wrapper/StaticChaynsApi';
|
|
13
14
|
export { default as loadComponent, loadModule } from './host/module/utils/loadComponent';
|
|
14
15
|
export { default as DialogHandler } from './handler/DialogHandler';
|
|
16
|
+
export * from './handler/history';
|
|
17
|
+
export { initRootChaynsHistoryLayer, getOrInitRootChaynsHistoryLayer } from './utils/history/rootLayer';
|
|
18
|
+
export { NavigationQueue } from './utils/history/NavigationQueue';
|
|
19
|
+
export { BlockRegistry } from './utils/history/BlockRegistry';
|
|
20
|
+
export { projectToUrl, parseFromUrl } from './utils/history/url';
|
|
21
|
+
export { projectToState, applyStateToTree, diffIncomingState, hasChaynsHistoryState } from './utils/history/stateProjector';
|
|
22
|
+
export { getChaynsHistoryActiveChain, findChaynsHistoryLayerById, isInChaynsHistoryActiveChain } from './utils/history/layerTree';
|
|
15
23
|
import * as _dialog from './calls/dialogs/index';
|
|
16
24
|
export { _dialog as dialog };
|
|
17
25
|
export * from './plugins';
|
|
18
|
-
export * from './
|
|
19
|
-
export * from './
|
|
20
|
-
export * from './
|
|
21
|
-
export * from './
|
|
26
|
+
export * from './utils/initModuleFederationSharing';
|
|
27
|
+
export * from './utils/bindChaynsApi';
|
|
28
|
+
export * from './utils/appStorage';
|
|
29
|
+
export * from './utils/collectCssChunks';
|
|
30
|
+
export * from './contexts';
|
|
22
31
|
export { getChaynsApi } from './components/moduleWrapper';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/umd.index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { default as getDeviceInfo, getScreenSize, getClientDeviceInfo } from './
|
|
1
|
+
export { default as getDeviceInfo, getScreenSize, getClientDeviceInfo } from './utils/deviceHelper';
|
|
2
2
|
export * from './calls';
|
|
3
3
|
export * from './types/IChaynsReact';
|
|
4
|
-
export * from './
|
|
4
|
+
export * from './utils/is';
|
|
5
5
|
export { default as StaticChaynsApi } from './wrapper/StaticChaynsApi';
|
|
6
6
|
export { default as DialogHandler } from './handler/DialogHandler';
|
|
7
7
|
import * as _dialog from './calls/dialogs/index';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
+
export class EventBus {
|
|
5
|
+
constructor() {
|
|
6
|
+
_defineProperty(this, "listeners", new Map());
|
|
7
|
+
}
|
|
8
|
+
on(type, handler) {
|
|
9
|
+
let set = this.listeners.get(type);
|
|
10
|
+
if (!set) {
|
|
11
|
+
set = new Set();
|
|
12
|
+
this.listeners.set(type, set);
|
|
13
|
+
}
|
|
14
|
+
set.add(handler);
|
|
15
|
+
return () => set.delete(handler);
|
|
16
|
+
}
|
|
17
|
+
emit(type, event) {
|
|
18
|
+
const set = this.listeners.get(type);
|
|
19
|
+
if (!set) return;
|
|
20
|
+
for (const fn of [...set]) {
|
|
21
|
+
try {
|
|
22
|
+
fn(event);
|
|
23
|
+
} catch (err) {
|
|
24
|
+
console.error('[chaynsHistory] listener threw', err);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
clear() {
|
|
29
|
+
this.listeners.clear();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function shallowEqualArr(a, b) {
|
|
2
|
+
if (a.length !== b.length) return false;
|
|
3
|
+
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
export function shallowEqualObj(a, b) {
|
|
7
|
+
const ak = Object.keys(a);
|
|
8
|
+
const bk = Object.keys(b);
|
|
9
|
+
if (ak.length !== bk.length) return false;
|
|
10
|
+
for (const k of ak) if (a[k] !== b[k]) return false;
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
2
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
4
|
+
const BLOCK_TIMEOUT_MS = 30000;
|
|
5
|
+
let _nextId = 1;
|
|
6
|
+
export class BlockRegistry {
|
|
7
|
+
constructor() {
|
|
8
|
+
_defineProperty(this, "layerBlocks", new Map());
|
|
9
|
+
_defineProperty(this, "beforeUnloadCount", 0);
|
|
10
|
+
_defineProperty(this, "beforeUnloadHandler", e => {
|
|
11
|
+
e.preventDefault();
|
|
12
|
+
e.returnValue = '';
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
add(layer, callback, opts = {}) {
|
|
16
|
+
var _opts$scope, _opts$isBeforeUnload;
|
|
17
|
+
const entry = {
|
|
18
|
+
id: String(_nextId++),
|
|
19
|
+
callback,
|
|
20
|
+
opts: {
|
|
21
|
+
scope: (_opts$scope = opts.scope) !== null && _opts$scope !== void 0 ? _opts$scope : 'local',
|
|
22
|
+
isBeforeUnload: (_opts$isBeforeUnload = opts.isBeforeUnload) !== null && _opts$isBeforeUnload !== void 0 ? _opts$isBeforeUnload : false
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
let set = this.layerBlocks.get(layer.id);
|
|
26
|
+
if (!set) {
|
|
27
|
+
set = new Set();
|
|
28
|
+
this.layerBlocks.set(layer.id, set);
|
|
29
|
+
}
|
|
30
|
+
set.add(entry);
|
|
31
|
+
if (entry.opts.isBeforeUnload) {
|
|
32
|
+
this.incrementBeforeUnload();
|
|
33
|
+
}
|
|
34
|
+
return () => this.remove(layer.id, entry);
|
|
35
|
+
}
|
|
36
|
+
remove(layerId, entry) {
|
|
37
|
+
const set = this.layerBlocks.get(layerId);
|
|
38
|
+
if (!set) return;
|
|
39
|
+
set.delete(entry);
|
|
40
|
+
if (set.size === 0) this.layerBlocks.delete(layerId);
|
|
41
|
+
if (entry.opts.isBeforeUnload) {
|
|
42
|
+
this.decrementBeforeUnload();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
removeAllForLayer(layerId) {
|
|
46
|
+
const set = this.layerBlocks.get(layerId);
|
|
47
|
+
if (!set) return;
|
|
48
|
+
for (const entry of set) {
|
|
49
|
+
if (entry.opts.isBeforeUnload) this.decrementBeforeUnload();
|
|
50
|
+
}
|
|
51
|
+
this.layerBlocks.delete(layerId);
|
|
52
|
+
}
|
|
53
|
+
collectApplicableBlocks(targetLayer) {
|
|
54
|
+
const result = [];
|
|
55
|
+
const localSet = this.layerBlocks.get(targetLayer.id);
|
|
56
|
+
if (localSet) {
|
|
57
|
+
for (const entry of localSet) {
|
|
58
|
+
result.push(entry);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
this.collectGlobalFromActiveDescendants(targetLayer, result);
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
collectGlobalFromActiveDescendants(layer, out) {
|
|
65
|
+
const activeChildId = layer.getActiveChildId();
|
|
66
|
+
if (!activeChildId) return;
|
|
67
|
+
const child = layer.getChildLayer(activeChildId);
|
|
68
|
+
if (!child) return;
|
|
69
|
+
const childSet = this.layerBlocks.get(child.id);
|
|
70
|
+
if (childSet) {
|
|
71
|
+
for (const entry of childSet) {
|
|
72
|
+
if (entry.opts.scope === 'global') {
|
|
73
|
+
out.push(entry);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
this.collectGlobalFromActiveDescendants(child, out);
|
|
78
|
+
}
|
|
79
|
+
async checkBlocks(targetLayer) {
|
|
80
|
+
const blocks = this.collectApplicableBlocks(targetLayer);
|
|
81
|
+
if (blocks.length === 0) return true;
|
|
82
|
+
const results = await Promise.all(blocks.map(b => this.runBlock(b)));
|
|
83
|
+
return results.every(Boolean);
|
|
84
|
+
}
|
|
85
|
+
async runBlock(entry) {
|
|
86
|
+
try {
|
|
87
|
+
const result = await Promise.race([entry.callback(), new Promise(resolve => setTimeout(() => {
|
|
88
|
+
resolve(false);
|
|
89
|
+
}, BLOCK_TIMEOUT_MS))]);
|
|
90
|
+
return result;
|
|
91
|
+
} catch (err) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
incrementBeforeUnload() {
|
|
96
|
+
this.beforeUnloadCount++;
|
|
97
|
+
if (this.beforeUnloadCount === 1 && typeof window !== 'undefined') {
|
|
98
|
+
window.addEventListener('beforeunload', this.beforeUnloadHandler);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
decrementBeforeUnload() {
|
|
102
|
+
if (this.beforeUnloadCount === 0) return;
|
|
103
|
+
this.beforeUnloadCount--;
|
|
104
|
+
if (this.beforeUnloadCount === 0 && typeof window !== 'undefined') {
|
|
105
|
+
window.removeEventListener('beforeunload', this.beforeUnloadHandler);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|