chayns-api 3.1.2 → 3.1.3
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/components/ChaynsProvider.js +3 -6
- package/dist/cjs/handler/history/FrameHistoryLayer.js +7 -7
- package/dist/cjs/handler/history/HistoryLayer.js +10 -10
- package/dist/cjs/host/iframe/HostIframe.js +42 -28
- package/dist/cjs/utils/history/BlockRegistry.js +5 -0
- package/dist/cjs/wrapper/AppWrapper.js +1 -0
- package/dist/cjs/wrapper/FrameWrapper.js +4 -11
- package/dist/cjs/wrapper/ModuleFederationWrapper.js +1 -1
- package/dist/cjs/wrapper/SsrWrapper.js +1 -0
- package/dist/esm/components/ChaynsProvider.js +3 -6
- package/dist/esm/handler/history/FrameHistoryLayer.js +7 -7
- package/dist/esm/handler/history/HistoryLayer.js +10 -10
- package/dist/esm/host/iframe/HostIframe.js +42 -28
- package/dist/esm/utils/history/BlockRegistry.js +3 -0
- package/dist/esm/wrapper/AppWrapper.js +1 -0
- package/dist/esm/wrapper/FrameWrapper.js +4 -11
- package/dist/esm/wrapper/ModuleFederationWrapper.js +1 -1
- package/dist/esm/wrapper/SsrWrapper.js +1 -0
- package/dist/esm/wrapper/StaticChaynsApi.js +0 -1
- package/dist/types/handler/history/FrameHistoryLayer.d.ts +5 -5
- package/dist/types/handler/history/HistoryLayer.d.ts +5 -5
- package/dist/types/hooks/history.d.ts +6 -6
- package/dist/types/types/IChaynsReact.d.ts +1 -1
- package/dist/types/types/history.d.ts +5 -5
- package/dist/types/utils/history/BlockRegistry.d.ts +1 -0
- package/dist/types/wrapper/AppWrapper.d.ts +1 -0
- package/dist/types/wrapper/FrameWrapper.d.ts +2 -2
- package/dist/types/wrapper/ModuleFederationWrapper.d.ts +1 -0
- package/dist/types/wrapper/SsrWrapper.d.ts +1 -0
- package/dist/types/wrapper/StaticChaynsApi.d.ts +0 -1
- package/package.json +1 -1
|
@@ -113,19 +113,16 @@ const ChaynsProvider = ({
|
|
|
113
113
|
(0, _react.useEffect)(() => {
|
|
114
114
|
void (async (_customWrapper$curren2, _ref2) => {
|
|
115
115
|
await customWrapper.current.init();
|
|
116
|
-
customWrapper.current.addDataListener(({
|
|
117
|
-
type,
|
|
118
|
-
value
|
|
119
|
-
}) => {
|
|
116
|
+
customWrapper.current.addDataListener(() => {
|
|
120
117
|
customWrapper.current.emitChange();
|
|
121
118
|
});
|
|
122
|
-
parentLayerRef.current = (_customWrapper$curren2 = customWrapper.current.
|
|
119
|
+
parentLayerRef.current = (_customWrapper$curren2 = customWrapper.current.history) !== null && _customWrapper$curren2 !== void 0 ? _customWrapper$curren2 : contextLayer;
|
|
123
120
|
if (!rootLayerRef.current && !historyLayer && !parentLayerRef.current) {
|
|
124
121
|
rootLayerRef.current = (0, _rootLayer.getOrInitRootChaynsHistoryLayer)(history === null || history === void 0 ? void 0 : history.url, history === null || history === void 0 ? void 0 : history.segmentCount).rootLayer;
|
|
125
122
|
}
|
|
126
123
|
const layer = (_ref2 = historyLayer !== null && historyLayer !== void 0 ? historyLayer : parentLayerRef.current) !== null && _ref2 !== void 0 ? _ref2 : rootLayerRef.current;
|
|
127
124
|
if (layer && typeof segmentCount === 'number' && layer.getSegmentCount() !== segmentCount) {
|
|
128
|
-
layer.setSegmentCount(segmentCount);
|
|
125
|
+
await layer.setSegmentCount(segmentCount);
|
|
129
126
|
}
|
|
130
127
|
setEffectiveLayer(layer);
|
|
131
128
|
if (!isInitialized) {
|
|
@@ -23,12 +23,12 @@ class FrameHistoryLayer {
|
|
|
23
23
|
getSegmentCount() {
|
|
24
24
|
return this._segmentCount;
|
|
25
25
|
}
|
|
26
|
-
setSegmentCount(n) {
|
|
26
|
+
async setSegmentCount(n) {
|
|
27
27
|
if (n === this._segmentCount) {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
this._segmentCount = n;
|
|
31
|
-
|
|
31
|
+
await this.bridge.setSegmentCount(n);
|
|
32
32
|
}
|
|
33
33
|
createChildLayer(_id) {
|
|
34
34
|
throw new Error('[chaynsHistory] FrameHistoryLayer does not support createChildLayer. ' + 'Manage sub-routing within the iframe with a local initRootChaynsHistoryLayer.');
|
|
@@ -46,12 +46,12 @@ class FrameHistoryLayer {
|
|
|
46
46
|
getRoute() {
|
|
47
47
|
return [...this._segments];
|
|
48
48
|
}
|
|
49
|
-
setRoute(route, opts) {
|
|
49
|
+
async setRoute(route, opts) {
|
|
50
50
|
const normalizedRoute = (0, _segments.normalizeHistoryRouteInput)(route);
|
|
51
51
|
if ((0, _equality.shallowEqualArr)(this._segments, normalizedRoute)) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
|
|
54
|
+
await this.bridge.setRoute(normalizedRoute, opts);
|
|
55
55
|
}
|
|
56
56
|
getParams() {
|
|
57
57
|
return {
|
|
@@ -59,19 +59,19 @@ class FrameHistoryLayer {
|
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
setParams(params, opts) {
|
|
62
|
-
|
|
62
|
+
return this.bridge.setParams(params, opts);
|
|
63
63
|
}
|
|
64
64
|
getHash() {
|
|
65
65
|
return this._hash;
|
|
66
66
|
}
|
|
67
67
|
setHash(hash, opts) {
|
|
68
|
-
|
|
68
|
+
return this.bridge.setHash(hash, opts);
|
|
69
69
|
}
|
|
70
70
|
getState() {
|
|
71
71
|
return this._state;
|
|
72
72
|
}
|
|
73
73
|
setState(state, opts) {
|
|
74
|
-
|
|
74
|
+
return this.bridge.setState(state, opts);
|
|
75
75
|
}
|
|
76
76
|
navigate(opts) {
|
|
77
77
|
return this.bridge.navigate(opts);
|
|
@@ -32,7 +32,7 @@ class ChaynsHistoryLayer {
|
|
|
32
32
|
getSegmentCount() {
|
|
33
33
|
return this.segmentCount;
|
|
34
34
|
}
|
|
35
|
-
setSegmentCount(n) {
|
|
35
|
+
async setSegmentCount(n) {
|
|
36
36
|
if (n < 0 || !Number.isInteger(n)) {
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
@@ -57,7 +57,7 @@ class ChaynsHistoryLayer {
|
|
|
57
57
|
this.segments = (0, _segments.normalizeHistorySegments)(bootstrapSegs);
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
await this.deps.getQueue().enqueue({
|
|
61
61
|
kind: 'setRoute',
|
|
62
62
|
layerId: this.id,
|
|
63
63
|
segments: [...this.segments],
|
|
@@ -119,9 +119,9 @@ class ChaynsHistoryLayer {
|
|
|
119
119
|
getRoute() {
|
|
120
120
|
return [...this.segments];
|
|
121
121
|
}
|
|
122
|
-
setRoute(route, opts) {
|
|
122
|
+
async setRoute(route, opts) {
|
|
123
123
|
if (this.isDestroyed) return;
|
|
124
|
-
|
|
124
|
+
await this.deps.getQueue().enqueue({
|
|
125
125
|
kind: 'setRoute',
|
|
126
126
|
layerId: this.id,
|
|
127
127
|
segments: ChaynsHistoryLayer.normalizeRoute(route),
|
|
@@ -133,9 +133,9 @@ class ChaynsHistoryLayer {
|
|
|
133
133
|
...this._params
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
|
-
setParams(params, opts) {
|
|
136
|
+
async setParams(params, opts) {
|
|
137
137
|
if (this.isDestroyed) return;
|
|
138
|
-
|
|
138
|
+
await this.deps.getQueue().enqueue({
|
|
139
139
|
kind: 'setParams',
|
|
140
140
|
layerId: this.id,
|
|
141
141
|
params: {
|
|
@@ -148,10 +148,10 @@ class ChaynsHistoryLayer {
|
|
|
148
148
|
var _this$_hash;
|
|
149
149
|
return (_this$_hash = this._hash) !== null && _this$_hash !== void 0 ? _this$_hash : '';
|
|
150
150
|
}
|
|
151
|
-
setHash(hash, opts) {
|
|
151
|
+
async setHash(hash, opts) {
|
|
152
152
|
if (this.isDestroyed) return;
|
|
153
153
|
const normalized = hash.startsWith('#') ? hash.slice(1) : hash;
|
|
154
|
-
|
|
154
|
+
await this.deps.getQueue().enqueue({
|
|
155
155
|
kind: 'setHash',
|
|
156
156
|
layerId: this.id,
|
|
157
157
|
hash: normalized,
|
|
@@ -163,10 +163,10 @@ class ChaynsHistoryLayer {
|
|
|
163
163
|
...this.ownState
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
|
-
setState(state, opts) {
|
|
166
|
+
async setState(state, opts) {
|
|
167
167
|
if (this.isDestroyed) return;
|
|
168
168
|
const filtered = ChaynsHistoryLayer.filterReservedKeys(state);
|
|
169
|
-
|
|
169
|
+
await this.deps.getQueue().enqueue({
|
|
170
170
|
kind: 'setState',
|
|
171
171
|
layerId: this.id,
|
|
172
172
|
state: filtered,
|
|
@@ -116,56 +116,70 @@ const HostIframe = ({
|
|
|
116
116
|
segmentCount: l.getSegmentCount()
|
|
117
117
|
};
|
|
118
118
|
},
|
|
119
|
-
setRoute: (route, opts) => {
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
setRoute: async (route, opts) => {
|
|
120
|
+
if (!historyLayerRef.current) {
|
|
121
|
+
throw new Error('[chayns-api] setRoute is not allowed on this page');
|
|
122
|
+
}
|
|
123
|
+
await historyLayerRef.current.setRoute(route, opts);
|
|
122
124
|
},
|
|
123
|
-
setParams: (params, opts) => {
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
setParams: async (params, opts) => {
|
|
126
|
+
if (!historyLayerRef.current) {
|
|
127
|
+
throw new Error('[chayns-api] setParams is not allowed on this page');
|
|
128
|
+
}
|
|
129
|
+
await historyLayerRef.current.setParams(params, opts);
|
|
126
130
|
},
|
|
127
|
-
setHash: (hash, opts) => {
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
setHash: async (hash, opts) => {
|
|
132
|
+
if (!historyLayerRef.current) {
|
|
133
|
+
throw new Error('[chayns-api] setHash is not allowed on this page');
|
|
134
|
+
}
|
|
135
|
+
await historyLayerRef.current.setHash(hash, opts);
|
|
130
136
|
},
|
|
131
|
-
setState: (state, opts) => {
|
|
132
|
-
|
|
133
|
-
|
|
137
|
+
setState: async (state, opts) => {
|
|
138
|
+
if (!historyLayerRef.current) {
|
|
139
|
+
throw new Error('[chayns-api] setState is not allowed on this page');
|
|
140
|
+
}
|
|
141
|
+
await historyLayerRef.current.setState(state, opts);
|
|
134
142
|
},
|
|
135
143
|
navigate: opts => {
|
|
136
|
-
|
|
137
|
-
|
|
144
|
+
if (!historyLayerRef.current) {
|
|
145
|
+
throw new Error('[chayns-api] navigate is not allowed on this page');
|
|
146
|
+
}
|
|
147
|
+
return historyLayerRef.current.navigate(opts);
|
|
138
148
|
},
|
|
139
149
|
setActiveChild: (id, init) => {
|
|
140
|
-
|
|
141
|
-
|
|
150
|
+
if (!historyLayerRef.current) {
|
|
151
|
+
throw new Error('[chayns-api] setActiveChild is not allowed on this page');
|
|
152
|
+
}
|
|
153
|
+
return historyLayerRef.current.setActiveChild(id, init);
|
|
142
154
|
},
|
|
143
|
-
setSegmentCount: n => {
|
|
144
|
-
|
|
145
|
-
|
|
155
|
+
setSegmentCount: async n => {
|
|
156
|
+
if (!historyLayerRef.current) {
|
|
157
|
+
throw new Error('[chayns-api] setSegmentCount is not allowed on this page');
|
|
158
|
+
}
|
|
159
|
+
await historyLayerRef.current.setSegmentCount(n);
|
|
146
160
|
},
|
|
147
161
|
addChangeListener: callback => {
|
|
148
|
-
var _historyLayerRef$
|
|
162
|
+
var _historyLayerRef$curr, _historyLayerRef$curr2;
|
|
149
163
|
if (!historyLayerRef.current) {
|
|
150
|
-
new Error('[chayns-api] addChangeListener is not allowed on this page');
|
|
164
|
+
throw new Error('[chayns-api] addChangeListener is not allowed on this page');
|
|
151
165
|
}
|
|
152
|
-
const unsub = (_historyLayerRef$
|
|
166
|
+
const unsub = (_historyLayerRef$curr = (_historyLayerRef$curr2 = historyLayerRef.current) === null || _historyLayerRef$curr2 === void 0 ? void 0 : _historyLayerRef$curr2.addEventListener('change', callback)) !== null && _historyLayerRef$curr !== void 0 ? _historyLayerRef$curr : () => {};
|
|
153
167
|
return comlink.proxy(unsub);
|
|
154
168
|
},
|
|
155
169
|
addPopstateListener: callback => {
|
|
156
|
-
var _historyLayerRef$
|
|
170
|
+
var _historyLayerRef$curr3, _historyLayerRef$curr4;
|
|
157
171
|
if (!historyLayerRef.current) {
|
|
158
|
-
new Error('[chayns-api] addPopstateListener is not allowed on this page');
|
|
172
|
+
throw new Error('[chayns-api] addPopstateListener is not allowed on this page');
|
|
159
173
|
}
|
|
160
|
-
const unsub = (_historyLayerRef$
|
|
174
|
+
const unsub = (_historyLayerRef$curr3 = (_historyLayerRef$curr4 = historyLayerRef.current) === null || _historyLayerRef$curr4 === void 0 ? void 0 : _historyLayerRef$curr4.addEventListener('popstate', callback)) !== null && _historyLayerRef$curr3 !== void 0 ? _historyLayerRef$curr3 : () => {};
|
|
161
175
|
return comlink.proxy(unsub);
|
|
162
176
|
},
|
|
163
177
|
addBlock: (callback, opts) => {
|
|
164
|
-
var _historyLayerRef$
|
|
178
|
+
var _historyLayerRef$curr5, _historyLayerRef$curr6;
|
|
165
179
|
if (!historyLayerRef.current) {
|
|
166
|
-
new Error('[chayns-api] addBlock is not allowed on this page');
|
|
180
|
+
throw new Error('[chayns-api] addBlock is not allowed on this page');
|
|
167
181
|
}
|
|
168
|
-
const unsub = (_historyLayerRef$
|
|
182
|
+
const unsub = (_historyLayerRef$curr5 = (_historyLayerRef$curr6 = historyLayerRef.current) === null || _historyLayerRef$curr6 === void 0 ? void 0 : _historyLayerRef$curr6.addBlock(callback, opts)) !== null && _historyLayerRef$curr5 !== void 0 ? _historyLayerRef$curr5 : () => {};
|
|
169
183
|
return comlink.proxy(unsub);
|
|
170
184
|
}
|
|
171
185
|
}
|
|
@@ -15,6 +15,11 @@ class BlockRegistry {
|
|
|
15
15
|
e.returnValue = '';
|
|
16
16
|
};
|
|
17
17
|
totalBlockCount = 0;
|
|
18
|
+
constructor() {
|
|
19
|
+
if (this.totalBlockCount === 0) {
|
|
20
|
+
this.setNativeNavigationEnabled(false);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
18
23
|
add(layer, callback, opts = {}) {
|
|
19
24
|
var _opts$scope, _opts$isBeforeUnload;
|
|
20
25
|
const entry = {
|
|
@@ -20,6 +20,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
20
20
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
21
21
|
class AppWrapper {
|
|
22
22
|
values = null;
|
|
23
|
+
history = null;
|
|
23
24
|
accessToken = '';
|
|
24
25
|
listeners = [];
|
|
25
26
|
customFunctions = {};
|
|
@@ -19,12 +19,11 @@ class FrameWrapper {
|
|
|
19
19
|
exposedFunctions = null;
|
|
20
20
|
exposedCustomFunctions = {};
|
|
21
21
|
exposedCustomFunctionNames = [];
|
|
22
|
-
resizeListener = null;
|
|
23
|
-
_historyLayer = null;
|
|
24
22
|
ready = new Promise(res => {
|
|
25
23
|
this.resolve = res;
|
|
26
24
|
});
|
|
27
25
|
values = null;
|
|
26
|
+
history = null;
|
|
28
27
|
chaynsApiId = null;
|
|
29
28
|
listeners = [];
|
|
30
29
|
functions = {
|
|
@@ -303,12 +302,6 @@ class FrameWrapper {
|
|
|
303
302
|
redirect: async options => {
|
|
304
303
|
if (!this.initialized) await this.ready;
|
|
305
304
|
return this.exposedFunctions.redirect(options);
|
|
306
|
-
},
|
|
307
|
-
getHistoryLayer: () => {
|
|
308
|
-
if (!this._historyLayer) {
|
|
309
|
-
return null;
|
|
310
|
-
}
|
|
311
|
-
return this._historyLayer;
|
|
312
305
|
}
|
|
313
306
|
};
|
|
314
307
|
customFunctions = new Proxy({}, {
|
|
@@ -376,7 +369,7 @@ class FrameWrapper {
|
|
|
376
369
|
initialState = await exposedHistory.getInitialState();
|
|
377
370
|
} catch (ex) {}
|
|
378
371
|
if (initialState) {
|
|
379
|
-
this.
|
|
372
|
+
this.history = new _FrameHistoryLayer.FrameHistoryLayer({
|
|
380
373
|
setRoute: (route, opts) => exposedHistory.setRoute(route, opts),
|
|
381
374
|
setParams: (params, opts) => exposedHistory.setParams(params, opts),
|
|
382
375
|
setHash: (hash, opts) => exposedHistory.setHash(hash, opts),
|
|
@@ -390,10 +383,10 @@ class FrameWrapper {
|
|
|
390
383
|
}
|
|
391
384
|
}, initialState);
|
|
392
385
|
await exposedHistory.addChangeListener(comlink.proxy(e => {
|
|
393
|
-
this.
|
|
386
|
+
this.history._applyAndEmit(e);
|
|
394
387
|
}));
|
|
395
388
|
await exposedHistory.addPopstateListener(comlink.proxy(e => {
|
|
396
|
-
this.
|
|
389
|
+
this.history._applyAndEmit(e);
|
|
397
390
|
}));
|
|
398
391
|
}
|
|
399
392
|
}
|
|
@@ -11,6 +11,7 @@ var _getUserInfo = _interopRequireDefault(require("../calls/getUserInfo"));
|
|
|
11
11
|
var _sendMessage = require("../calls/sendMessage");
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
class ModuleFederationWrapper {
|
|
14
|
+
history = (0, _rootLayer.getOrInitRootChaynsHistoryLayer)().rootLayer;
|
|
14
15
|
customFunctions = {};
|
|
15
16
|
listeners = [];
|
|
16
17
|
chaynsApiId = null;
|
|
@@ -32,7 +33,6 @@ class ModuleFederationWrapper {
|
|
|
32
33
|
this.functions.createDialog = config => {
|
|
33
34
|
return new _DialogHandler.default(config, functions.openDialog, functions.closeDialog, functions.dispatchEventToDialogClient, functions.addDialogClientEventListener);
|
|
34
35
|
};
|
|
35
|
-
this.functions.getHistoryLayer = () => (0, _rootLayer.getOrInitRootChaynsHistoryLayer)().rootLayer;
|
|
36
36
|
}
|
|
37
37
|
async init() {
|
|
38
38
|
return undefined;
|
|
@@ -105,19 +105,16 @@ const ChaynsProvider = ({
|
|
|
105
105
|
useEffect(() => {
|
|
106
106
|
void (async (_customWrapper$curren2, _ref2) => {
|
|
107
107
|
await customWrapper.current.init();
|
|
108
|
-
customWrapper.current.addDataListener(({
|
|
109
|
-
type,
|
|
110
|
-
value
|
|
111
|
-
}) => {
|
|
108
|
+
customWrapper.current.addDataListener(() => {
|
|
112
109
|
customWrapper.current.emitChange();
|
|
113
110
|
});
|
|
114
|
-
parentLayerRef.current = (_customWrapper$curren2 = customWrapper.current.
|
|
111
|
+
parentLayerRef.current = (_customWrapper$curren2 = customWrapper.current.history) !== null && _customWrapper$curren2 !== void 0 ? _customWrapper$curren2 : contextLayer;
|
|
115
112
|
if (!rootLayerRef.current && !historyLayer && !parentLayerRef.current) {
|
|
116
113
|
rootLayerRef.current = getOrInitRootChaynsHistoryLayer(history === null || history === void 0 ? void 0 : history.url, history === null || history === void 0 ? void 0 : history.segmentCount).rootLayer;
|
|
117
114
|
}
|
|
118
115
|
const layer = (_ref2 = historyLayer !== null && historyLayer !== void 0 ? historyLayer : parentLayerRef.current) !== null && _ref2 !== void 0 ? _ref2 : rootLayerRef.current;
|
|
119
116
|
if (layer && typeof segmentCount === 'number' && layer.getSegmentCount() !== segmentCount) {
|
|
120
|
-
layer.setSegmentCount(segmentCount);
|
|
117
|
+
await layer.setSegmentCount(segmentCount);
|
|
121
118
|
}
|
|
122
119
|
setEffectiveLayer(layer);
|
|
123
120
|
if (!isInitialized) {
|
|
@@ -29,12 +29,12 @@ export class FrameHistoryLayer {
|
|
|
29
29
|
getSegmentCount() {
|
|
30
30
|
return this._segmentCount;
|
|
31
31
|
}
|
|
32
|
-
setSegmentCount(n) {
|
|
32
|
+
async setSegmentCount(n) {
|
|
33
33
|
if (n === this._segmentCount) {
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
this._segmentCount = n;
|
|
37
|
-
|
|
37
|
+
await this.bridge.setSegmentCount(n);
|
|
38
38
|
}
|
|
39
39
|
createChildLayer(_id) {
|
|
40
40
|
throw new Error('[chaynsHistory] FrameHistoryLayer does not support createChildLayer. ' + 'Manage sub-routing within the iframe with a local initRootChaynsHistoryLayer.');
|
|
@@ -52,12 +52,12 @@ export class FrameHistoryLayer {
|
|
|
52
52
|
getRoute() {
|
|
53
53
|
return [...this._segments];
|
|
54
54
|
}
|
|
55
|
-
setRoute(route, opts) {
|
|
55
|
+
async setRoute(route, opts) {
|
|
56
56
|
const normalizedRoute = normalizeHistoryRouteInput(route);
|
|
57
57
|
if (shallowEqualArr(this._segments, normalizedRoute)) {
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
await this.bridge.setRoute(normalizedRoute, opts);
|
|
61
61
|
}
|
|
62
62
|
getParams() {
|
|
63
63
|
return {
|
|
@@ -65,19 +65,19 @@ export class FrameHistoryLayer {
|
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
67
|
setParams(params, opts) {
|
|
68
|
-
|
|
68
|
+
return this.bridge.setParams(params, opts);
|
|
69
69
|
}
|
|
70
70
|
getHash() {
|
|
71
71
|
return this._hash;
|
|
72
72
|
}
|
|
73
73
|
setHash(hash, opts) {
|
|
74
|
-
|
|
74
|
+
return this.bridge.setHash(hash, opts);
|
|
75
75
|
}
|
|
76
76
|
getState() {
|
|
77
77
|
return this._state;
|
|
78
78
|
}
|
|
79
79
|
setState(state, opts) {
|
|
80
|
-
|
|
80
|
+
return this.bridge.setState(state, opts);
|
|
81
81
|
}
|
|
82
82
|
navigate(opts) {
|
|
83
83
|
return this.bridge.navigate(opts);
|
|
@@ -33,7 +33,7 @@ export class ChaynsHistoryLayer {
|
|
|
33
33
|
getSegmentCount() {
|
|
34
34
|
return this.segmentCount;
|
|
35
35
|
}
|
|
36
|
-
setSegmentCount(n) {
|
|
36
|
+
async setSegmentCount(n) {
|
|
37
37
|
if (n < 0 || !Number.isInteger(n)) {
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
@@ -58,7 +58,7 @@ export class ChaynsHistoryLayer {
|
|
|
58
58
|
this.segments = normalizeHistorySegments(bootstrapSegs);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
await this.deps.getQueue().enqueue({
|
|
62
62
|
kind: 'setRoute',
|
|
63
63
|
layerId: this.id,
|
|
64
64
|
segments: [...this.segments],
|
|
@@ -120,9 +120,9 @@ export class ChaynsHistoryLayer {
|
|
|
120
120
|
getRoute() {
|
|
121
121
|
return [...this.segments];
|
|
122
122
|
}
|
|
123
|
-
setRoute(route, opts) {
|
|
123
|
+
async setRoute(route, opts) {
|
|
124
124
|
if (this.isDestroyed) return;
|
|
125
|
-
|
|
125
|
+
await this.deps.getQueue().enqueue({
|
|
126
126
|
kind: 'setRoute',
|
|
127
127
|
layerId: this.id,
|
|
128
128
|
segments: ChaynsHistoryLayer.normalizeRoute(route),
|
|
@@ -134,9 +134,9 @@ export class ChaynsHistoryLayer {
|
|
|
134
134
|
...this._params
|
|
135
135
|
};
|
|
136
136
|
}
|
|
137
|
-
setParams(params, opts) {
|
|
137
|
+
async setParams(params, opts) {
|
|
138
138
|
if (this.isDestroyed) return;
|
|
139
|
-
|
|
139
|
+
await this.deps.getQueue().enqueue({
|
|
140
140
|
kind: 'setParams',
|
|
141
141
|
layerId: this.id,
|
|
142
142
|
params: {
|
|
@@ -149,10 +149,10 @@ export class ChaynsHistoryLayer {
|
|
|
149
149
|
var _this$_hash;
|
|
150
150
|
return (_this$_hash = this._hash) !== null && _this$_hash !== void 0 ? _this$_hash : '';
|
|
151
151
|
}
|
|
152
|
-
setHash(hash, opts) {
|
|
152
|
+
async setHash(hash, opts) {
|
|
153
153
|
if (this.isDestroyed) return;
|
|
154
154
|
const normalized = hash.startsWith('#') ? hash.slice(1) : hash;
|
|
155
|
-
|
|
155
|
+
await this.deps.getQueue().enqueue({
|
|
156
156
|
kind: 'setHash',
|
|
157
157
|
layerId: this.id,
|
|
158
158
|
hash: normalized,
|
|
@@ -164,10 +164,10 @@ export class ChaynsHistoryLayer {
|
|
|
164
164
|
...this.ownState
|
|
165
165
|
};
|
|
166
166
|
}
|
|
167
|
-
setState(state, opts) {
|
|
167
|
+
async setState(state, opts) {
|
|
168
168
|
if (this.isDestroyed) return;
|
|
169
169
|
const filtered = ChaynsHistoryLayer.filterReservedKeys(state);
|
|
170
|
-
|
|
170
|
+
await this.deps.getQueue().enqueue({
|
|
171
171
|
kind: 'setState',
|
|
172
172
|
layerId: this.id,
|
|
173
173
|
state: filtered,
|
|
@@ -108,56 +108,70 @@ const HostIframe = ({
|
|
|
108
108
|
segmentCount: l.getSegmentCount()
|
|
109
109
|
};
|
|
110
110
|
},
|
|
111
|
-
setRoute: (route, opts) => {
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
setRoute: async (route, opts) => {
|
|
112
|
+
if (!historyLayerRef.current) {
|
|
113
|
+
throw new Error('[chayns-api] setRoute is not allowed on this page');
|
|
114
|
+
}
|
|
115
|
+
await historyLayerRef.current.setRoute(route, opts);
|
|
114
116
|
},
|
|
115
|
-
setParams: (params, opts) => {
|
|
116
|
-
|
|
117
|
-
|
|
117
|
+
setParams: async (params, opts) => {
|
|
118
|
+
if (!historyLayerRef.current) {
|
|
119
|
+
throw new Error('[chayns-api] setParams is not allowed on this page');
|
|
120
|
+
}
|
|
121
|
+
await historyLayerRef.current.setParams(params, opts);
|
|
118
122
|
},
|
|
119
|
-
setHash: (hash, opts) => {
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
setHash: async (hash, opts) => {
|
|
124
|
+
if (!historyLayerRef.current) {
|
|
125
|
+
throw new Error('[chayns-api] setHash is not allowed on this page');
|
|
126
|
+
}
|
|
127
|
+
await historyLayerRef.current.setHash(hash, opts);
|
|
122
128
|
},
|
|
123
|
-
setState: (state, opts) => {
|
|
124
|
-
|
|
125
|
-
|
|
129
|
+
setState: async (state, opts) => {
|
|
130
|
+
if (!historyLayerRef.current) {
|
|
131
|
+
throw new Error('[chayns-api] setState is not allowed on this page');
|
|
132
|
+
}
|
|
133
|
+
await historyLayerRef.current.setState(state, opts);
|
|
126
134
|
},
|
|
127
135
|
navigate: opts => {
|
|
128
|
-
|
|
129
|
-
|
|
136
|
+
if (!historyLayerRef.current) {
|
|
137
|
+
throw new Error('[chayns-api] navigate is not allowed on this page');
|
|
138
|
+
}
|
|
139
|
+
return historyLayerRef.current.navigate(opts);
|
|
130
140
|
},
|
|
131
141
|
setActiveChild: (id, init) => {
|
|
132
|
-
|
|
133
|
-
|
|
142
|
+
if (!historyLayerRef.current) {
|
|
143
|
+
throw new Error('[chayns-api] setActiveChild is not allowed on this page');
|
|
144
|
+
}
|
|
145
|
+
return historyLayerRef.current.setActiveChild(id, init);
|
|
134
146
|
},
|
|
135
|
-
setSegmentCount: n => {
|
|
136
|
-
|
|
137
|
-
|
|
147
|
+
setSegmentCount: async n => {
|
|
148
|
+
if (!historyLayerRef.current) {
|
|
149
|
+
throw new Error('[chayns-api] setSegmentCount is not allowed on this page');
|
|
150
|
+
}
|
|
151
|
+
await historyLayerRef.current.setSegmentCount(n);
|
|
138
152
|
},
|
|
139
153
|
addChangeListener: callback => {
|
|
140
|
-
var _historyLayerRef$
|
|
154
|
+
var _historyLayerRef$curr, _historyLayerRef$curr2;
|
|
141
155
|
if (!historyLayerRef.current) {
|
|
142
|
-
new Error('[chayns-api] addChangeListener is not allowed on this page');
|
|
156
|
+
throw new Error('[chayns-api] addChangeListener is not allowed on this page');
|
|
143
157
|
}
|
|
144
|
-
const unsub = (_historyLayerRef$
|
|
158
|
+
const unsub = (_historyLayerRef$curr = (_historyLayerRef$curr2 = historyLayerRef.current) === null || _historyLayerRef$curr2 === void 0 ? void 0 : _historyLayerRef$curr2.addEventListener('change', callback)) !== null && _historyLayerRef$curr !== void 0 ? _historyLayerRef$curr : () => {};
|
|
145
159
|
return comlink.proxy(unsub);
|
|
146
160
|
},
|
|
147
161
|
addPopstateListener: callback => {
|
|
148
|
-
var _historyLayerRef$
|
|
162
|
+
var _historyLayerRef$curr3, _historyLayerRef$curr4;
|
|
149
163
|
if (!historyLayerRef.current) {
|
|
150
|
-
new Error('[chayns-api] addPopstateListener is not allowed on this page');
|
|
164
|
+
throw new Error('[chayns-api] addPopstateListener is not allowed on this page');
|
|
151
165
|
}
|
|
152
|
-
const unsub = (_historyLayerRef$
|
|
166
|
+
const unsub = (_historyLayerRef$curr3 = (_historyLayerRef$curr4 = historyLayerRef.current) === null || _historyLayerRef$curr4 === void 0 ? void 0 : _historyLayerRef$curr4.addEventListener('popstate', callback)) !== null && _historyLayerRef$curr3 !== void 0 ? _historyLayerRef$curr3 : () => {};
|
|
153
167
|
return comlink.proxy(unsub);
|
|
154
168
|
},
|
|
155
169
|
addBlock: (callback, opts) => {
|
|
156
|
-
var _historyLayerRef$
|
|
170
|
+
var _historyLayerRef$curr5, _historyLayerRef$curr6;
|
|
157
171
|
if (!historyLayerRef.current) {
|
|
158
|
-
new Error('[chayns-api] addBlock is not allowed on this page');
|
|
172
|
+
throw new Error('[chayns-api] addBlock is not allowed on this page');
|
|
159
173
|
}
|
|
160
|
-
const unsub = (_historyLayerRef$
|
|
174
|
+
const unsub = (_historyLayerRef$curr5 = (_historyLayerRef$curr6 = historyLayerRef.current) === null || _historyLayerRef$curr6 === void 0 ? void 0 : _historyLayerRef$curr6.addBlock(callback, opts)) !== null && _historyLayerRef$curr5 !== void 0 ? _historyLayerRef$curr5 : () => {};
|
|
161
175
|
return comlink.proxy(unsub);
|
|
162
176
|
}
|
|
163
177
|
}
|
|
@@ -14,6 +14,9 @@ export class BlockRegistry {
|
|
|
14
14
|
});
|
|
15
15
|
_defineProperty(this, "totalBlockCount", 0);
|
|
16
16
|
_defineProperty(this, "nativeNavigationCallback", () => {});
|
|
17
|
+
if (this.totalBlockCount === 0) {
|
|
18
|
+
this.setNativeNavigationEnabled(false);
|
|
19
|
+
}
|
|
17
20
|
}
|
|
18
21
|
add(layer, callback, opts = {}) {
|
|
19
22
|
var _opts$scope, _opts$isBeforeUnload;
|
|
@@ -146,6 +146,7 @@ export class AppWrapper {
|
|
|
146
146
|
}
|
|
147
147
|
constructor() {
|
|
148
148
|
_defineProperty(this, "values", null);
|
|
149
|
+
_defineProperty(this, "history", null);
|
|
149
150
|
_defineProperty(this, "accessToken", '');
|
|
150
151
|
_defineProperty(this, "listeners", []);
|
|
151
152
|
_defineProperty(this, "customFunctions", {});
|
|
@@ -15,12 +15,11 @@ export class FrameWrapper {
|
|
|
15
15
|
_defineProperty(this, "exposedFunctions", null);
|
|
16
16
|
_defineProperty(this, "exposedCustomFunctions", {});
|
|
17
17
|
_defineProperty(this, "exposedCustomFunctionNames", []);
|
|
18
|
-
_defineProperty(this, "resizeListener", null);
|
|
19
|
-
_defineProperty(this, "_historyLayer", null);
|
|
20
18
|
_defineProperty(this, "ready", new Promise(res => {
|
|
21
19
|
this.resolve = res;
|
|
22
20
|
}));
|
|
23
21
|
_defineProperty(this, "values", null);
|
|
22
|
+
_defineProperty(this, "history", null);
|
|
24
23
|
_defineProperty(this, "chaynsApiId", null);
|
|
25
24
|
_defineProperty(this, "listeners", []);
|
|
26
25
|
_defineProperty(this, "functions", {
|
|
@@ -299,12 +298,6 @@ export class FrameWrapper {
|
|
|
299
298
|
redirect: async options => {
|
|
300
299
|
if (!this.initialized) await this.ready;
|
|
301
300
|
return this.exposedFunctions.redirect(options);
|
|
302
|
-
},
|
|
303
|
-
getHistoryLayer: () => {
|
|
304
|
-
if (!this._historyLayer) {
|
|
305
|
-
return null;
|
|
306
|
-
}
|
|
307
|
-
return this._historyLayer;
|
|
308
301
|
}
|
|
309
302
|
});
|
|
310
303
|
_defineProperty(this, "customFunctions", new Proxy({}, {
|
|
@@ -380,7 +373,7 @@ export class FrameWrapper {
|
|
|
380
373
|
initialState = await exposedHistory.getInitialState();
|
|
381
374
|
} catch (ex) {}
|
|
382
375
|
if (initialState) {
|
|
383
|
-
this.
|
|
376
|
+
this.history = new FrameHistoryLayer({
|
|
384
377
|
setRoute: (route, opts) => exposedHistory.setRoute(route, opts),
|
|
385
378
|
setParams: (params, opts) => exposedHistory.setParams(params, opts),
|
|
386
379
|
setHash: (hash, opts) => exposedHistory.setHash(hash, opts),
|
|
@@ -394,10 +387,10 @@ export class FrameWrapper {
|
|
|
394
387
|
}
|
|
395
388
|
}, initialState);
|
|
396
389
|
await exposedHistory.addChangeListener(comlink.proxy(e => {
|
|
397
|
-
this.
|
|
390
|
+
this.history._applyAndEmit(e);
|
|
398
391
|
}));
|
|
399
392
|
await exposedHistory.addPopstateListener(comlink.proxy(e => {
|
|
400
|
-
this.
|
|
393
|
+
this.history._applyAndEmit(e);
|
|
401
394
|
}));
|
|
402
395
|
}
|
|
403
396
|
}
|
|
@@ -10,6 +10,7 @@ export class ModuleFederationWrapper {
|
|
|
10
10
|
constructor(values, functions, customFunctions) {
|
|
11
11
|
_defineProperty(this, "values", void 0);
|
|
12
12
|
_defineProperty(this, "functions", void 0);
|
|
13
|
+
_defineProperty(this, "history", getOrInitRootChaynsHistoryLayer().rootLayer);
|
|
13
14
|
_defineProperty(this, "customFunctions", {});
|
|
14
15
|
_defineProperty(this, "listeners", []);
|
|
15
16
|
_defineProperty(this, "chaynsApiId", null);
|
|
@@ -39,7 +40,6 @@ export class ModuleFederationWrapper {
|
|
|
39
40
|
this.functions.createDialog = config => {
|
|
40
41
|
return new DialogHandler(config, functions.openDialog, functions.closeDialog, functions.dispatchEventToDialogClient, functions.addDialogClientEventListener);
|
|
41
42
|
};
|
|
42
|
-
this.functions.getHistoryLayer = () => getOrInitRootChaynsHistoryLayer().rootLayer;
|
|
43
43
|
}
|
|
44
44
|
async init() {
|
|
45
45
|
return undefined;
|
|
@@ -6,6 +6,7 @@ export class SsrWrapper {
|
|
|
6
6
|
_defineProperty(this, "initialData", void 0);
|
|
7
7
|
_defineProperty(this, "values", void 0);
|
|
8
8
|
_defineProperty(this, "functions", void 0);
|
|
9
|
+
_defineProperty(this, "history", null);
|
|
9
10
|
_defineProperty(this, "customFunctions", void 0);
|
|
10
11
|
_defineProperty(this, "listeners", []);
|
|
11
12
|
_defineProperty(this, "chaynsApiId", null);
|
|
@@ -74,7 +74,6 @@ class StaticChaynsApi {
|
|
|
74
74
|
_defineProperty(this, "addAccessTokenChangeListener", void 0);
|
|
75
75
|
_defineProperty(this, "removeAccessTokenChangeListener", void 0);
|
|
76
76
|
_defineProperty(this, "redirect", void 0);
|
|
77
|
-
_defineProperty(this, "getHistoryLayer", void 0);
|
|
78
77
|
_defineProperty(this, "ready", void 0);
|
|
79
78
|
_defineProperty(this, "addDataListener", void 0);
|
|
80
79
|
_defineProperty(this, "_wrapper", void 0);
|
|
@@ -63,7 +63,7 @@ export declare class FrameHistoryLayer implements ChaynsHistoryLayer {
|
|
|
63
63
|
private readonly bridge;
|
|
64
64
|
constructor(bridge: HistoryBridgeFunctions, initial: HistoryInitialState);
|
|
65
65
|
getSegmentCount(): number;
|
|
66
|
-
setSegmentCount(n: number): void
|
|
66
|
+
setSegmentCount(n: number): Promise<void>;
|
|
67
67
|
createChildLayer(_id: string): ChaynsHistoryLayer;
|
|
68
68
|
destroyChildLayer(_id: string): void;
|
|
69
69
|
setActiveChild(id: string | null, init?: {
|
|
@@ -73,13 +73,13 @@ export declare class FrameHistoryLayer implements ChaynsHistoryLayer {
|
|
|
73
73
|
getActiveChildId(): string | null;
|
|
74
74
|
getChildLayer(_id: string): ChaynsHistoryLayer | undefined;
|
|
75
75
|
getRoute(): string[];
|
|
76
|
-
setRoute(route: string | string[], opts?: ChaynsHistoryNavigateOptions): void
|
|
76
|
+
setRoute(route: string | string[], opts?: ChaynsHistoryNavigateOptions): Promise<void>;
|
|
77
77
|
getParams(): Record<string, string>;
|
|
78
|
-
setParams(params: Record<string, string>, opts?: ChaynsHistoryNavigationCommitOptions): void
|
|
78
|
+
setParams(params: Record<string, string>, opts?: ChaynsHistoryNavigationCommitOptions): Promise<void>;
|
|
79
79
|
getHash(): string;
|
|
80
|
-
setHash(hash: string, opts?: ChaynsHistoryNavigationCommitOptions): void
|
|
80
|
+
setHash(hash: string, opts?: ChaynsHistoryNavigationCommitOptions): Promise<void>;
|
|
81
81
|
getState<T extends object = Record<string, unknown>>(): T | undefined;
|
|
82
|
-
setState(state:
|
|
82
|
+
setState<T extends object>(state: T, opts?: ChaynsHistoryNavigateOptions): Promise<void>;
|
|
83
83
|
navigate(opts: {
|
|
84
84
|
route?: string | string[];
|
|
85
85
|
state?: Record<string, unknown>;
|
|
@@ -50,7 +50,7 @@ export declare class ChaynsHistoryLayer implements IChaynsHistoryLayer {
|
|
|
50
50
|
private isDestroyed;
|
|
51
51
|
constructor(init: ChaynsHistoryLayerInit);
|
|
52
52
|
getSegmentCount(): number;
|
|
53
|
-
setSegmentCount(n: number): void
|
|
53
|
+
setSegmentCount(n: number): Promise<void>;
|
|
54
54
|
createChildLayer(id: string): ChaynsHistoryLayer;
|
|
55
55
|
destroyChildLayer(id: string): void;
|
|
56
56
|
getChildLayer(id: string): ChaynsHistoryLayer | undefined;
|
|
@@ -60,13 +60,13 @@ export declare class ChaynsHistoryLayer implements IChaynsHistoryLayer {
|
|
|
60
60
|
state?: Record<string, unknown>;
|
|
61
61
|
}): Promise<ChaynsHistoryActionResult>;
|
|
62
62
|
getRoute(): string[];
|
|
63
|
-
setRoute(route: string | string[], opts?: ChaynsHistoryNavigateOptions): void
|
|
63
|
+
setRoute(route: string | string[], opts?: ChaynsHistoryNavigateOptions): Promise<void>;
|
|
64
64
|
getParams(): Record<string, string>;
|
|
65
|
-
setParams(params: Record<string, string>, opts?: ChaynsHistoryNavigationCommitOptions): void
|
|
65
|
+
setParams(params: Record<string, string>, opts?: ChaynsHistoryNavigationCommitOptions): Promise<void>;
|
|
66
66
|
getHash(): string;
|
|
67
|
-
setHash(hash: string, opts?: ChaynsHistoryNavigationCommitOptions): void
|
|
67
|
+
setHash(hash: string, opts?: ChaynsHistoryNavigationCommitOptions): Promise<void>;
|
|
68
68
|
getState<T extends object = Record<string, unknown>>(): T | undefined;
|
|
69
|
-
setState<T extends object>(state: T, opts?: ChaynsHistoryNavigateOptions): void
|
|
69
|
+
setState<T extends object>(state: T, opts?: ChaynsHistoryNavigateOptions): Promise<void>;
|
|
70
70
|
navigate(opts: {
|
|
71
71
|
route?: string | string[];
|
|
72
72
|
state?: Record<string, unknown>;
|
|
@@ -6,7 +6,7 @@ import type { ChaynsHistoryLayer, ChaynsHistoryNavigateOptions, ChaynsHistoryNav
|
|
|
6
6
|
export declare function useChaynsHistoryLayer(): ChaynsHistoryLayer;
|
|
7
7
|
export interface UseChaynsHistoryRouteResult {
|
|
8
8
|
segments: string[];
|
|
9
|
-
setRoute: (route: string | string[], opts?: ChaynsHistoryNavigateOptions) => void
|
|
9
|
+
setRoute: (route: string | string[], opts?: ChaynsHistoryNavigateOptions) => Promise<void>;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Returns the current route segments and a setter for the nearest ChaynsHistoryLayer.
|
|
@@ -19,7 +19,7 @@ export declare function useChaynsHistoryRoute(): UseChaynsHistoryRouteResult;
|
|
|
19
19
|
*/
|
|
20
20
|
export declare function useChaynsHistoryState<T extends object = Record<string, unknown>>(): [
|
|
21
21
|
T | undefined,
|
|
22
|
-
(state: T, opts?: ChaynsHistoryNavigateOptions) => void
|
|
22
|
+
(state: T, opts?: ChaynsHistoryNavigateOptions) => Promise<void>
|
|
23
23
|
];
|
|
24
24
|
/**
|
|
25
25
|
* Returns a stable `navigate` function for the nearest ChaynsHistoryLayer.
|
|
@@ -43,14 +43,14 @@ export declare function useChaynsHistoryNavigate(): (opts: {
|
|
|
43
43
|
*/
|
|
44
44
|
export declare function useChaynsHistoryParams(): [
|
|
45
45
|
Record<string, string>,
|
|
46
|
-
(params: Record<string, string>, opts?: ChaynsHistoryNavigationCommitOptions) => void
|
|
46
|
+
(params: Record<string, string>, opts?: ChaynsHistoryNavigationCommitOptions) => Promise<void>
|
|
47
47
|
];
|
|
48
48
|
/**
|
|
49
49
|
* Returns the current hash fragment (without `#`) and a setter for the nearest ChaynsHistoryLayer.
|
|
50
50
|
* Pass `''` to explicitly clear the hash.
|
|
51
51
|
* Re-renders only when the hash changes.
|
|
52
52
|
*/
|
|
53
|
-
export declare function useChaynsHistoryHash(): [string, (hash: string, opts?: ChaynsHistoryNavigationCommitOptions) => void];
|
|
53
|
+
export declare function useChaynsHistoryHash(): [string, (hash: string, opts?: ChaynsHistoryNavigationCommitOptions) => Promise<void>];
|
|
54
54
|
export interface UseChaynsHistoryBlockOptions extends ChaynsHistoryBlockOptions {
|
|
55
55
|
/** Only register the block when true. Default: true. */
|
|
56
56
|
isEnabled?: boolean;
|
|
@@ -78,9 +78,9 @@ export declare function useChaynsHistoryChildLayer(id: string): ChaynsHistoryLay
|
|
|
78
78
|
export interface UseChaynsHistoryActiveChildResult {
|
|
79
79
|
activeChildId: string | null;
|
|
80
80
|
setActiveChild: (id: string | null, init?: {
|
|
81
|
-
route?: string[];
|
|
81
|
+
route?: string | string[];
|
|
82
82
|
state?: Record<string, unknown>;
|
|
83
|
-
}) =>
|
|
83
|
+
}) => Promise<ChaynsHistoryActionResult>;
|
|
84
84
|
}
|
|
85
85
|
/**
|
|
86
86
|
* Returns the active child id of the nearest layer and a setter.
|
|
@@ -467,7 +467,6 @@ export interface ChaynsReactFunctions {
|
|
|
467
467
|
destination: string;
|
|
468
468
|
isPermanent?: boolean;
|
|
469
469
|
}) => Promise<void>;
|
|
470
|
-
getHistoryLayer(): ChaynsHistoryLayer | null;
|
|
471
470
|
}
|
|
472
471
|
export type ChaynsReactCustomFunctions = {
|
|
473
472
|
[key: string]: (...args: any[]) => Promise<any>;
|
|
@@ -674,6 +673,7 @@ export interface DesignSettingsUpdateItem {
|
|
|
674
673
|
export interface IChaynsReact {
|
|
675
674
|
values: ChaynsReactValues;
|
|
676
675
|
functions: ChaynsReactFunctions;
|
|
676
|
+
history: ChaynsHistoryLayer | null;
|
|
677
677
|
customFunctions: ChaynsReactCustomFunctions;
|
|
678
678
|
addDataListener: (cb: DataChangeCallback) => CleanupCallback;
|
|
679
679
|
getSSRData: () => ChaynsReactValues | null;
|
|
@@ -41,7 +41,7 @@ export interface ChaynsHistoryLayer {
|
|
|
41
41
|
readonly id: string;
|
|
42
42
|
readonly depth: number;
|
|
43
43
|
getSegmentCount(): number;
|
|
44
|
-
setSegmentCount(n: number): void
|
|
44
|
+
setSegmentCount(n: number): Promise<void>;
|
|
45
45
|
createChildLayer(id: string): ChaynsHistoryLayer;
|
|
46
46
|
destroyChildLayer(id: string): void;
|
|
47
47
|
setActiveChild(id: string | null, init?: {
|
|
@@ -51,13 +51,13 @@ export interface ChaynsHistoryLayer {
|
|
|
51
51
|
getActiveChildId(): string | null;
|
|
52
52
|
getChildLayer(id: string): ChaynsHistoryLayer | undefined;
|
|
53
53
|
getRoute(): string[];
|
|
54
|
-
setRoute(route: string | string[], opts?: ChaynsHistoryNavigateOptions): void
|
|
54
|
+
setRoute(route: string | string[], opts?: ChaynsHistoryNavigateOptions): Promise<void>;
|
|
55
55
|
getParams(): Record<string, string>;
|
|
56
|
-
setParams(params: Record<string, string>, opts?: ChaynsHistoryNavigationCommitOptions): void
|
|
56
|
+
setParams(params: Record<string, string>, opts?: ChaynsHistoryNavigationCommitOptions): Promise<void>;
|
|
57
57
|
getHash(): string;
|
|
58
|
-
setHash(hash: string, opts?: ChaynsHistoryNavigationCommitOptions): void
|
|
58
|
+
setHash(hash: string, opts?: ChaynsHistoryNavigationCommitOptions): Promise<void>;
|
|
59
59
|
getState<T extends object = Record<string, unknown>>(): T | undefined;
|
|
60
|
-
setState<T extends object>(state: T, opts?: ChaynsHistoryNavigateOptions): void
|
|
60
|
+
setState<T extends object>(state: T, opts?: ChaynsHistoryNavigateOptions): Promise<void>;
|
|
61
61
|
navigate(opts: {
|
|
62
62
|
route?: string | string[];
|
|
63
63
|
state?: Record<string, unknown>;
|
|
@@ -14,6 +14,7 @@ export declare class BlockRegistry {
|
|
|
14
14
|
/** Total number of currently registered blocks across all layers.
|
|
15
15
|
* Used to toggle the native navigation handling (chayns app, action 249). */
|
|
16
16
|
private totalBlockCount;
|
|
17
|
+
constructor();
|
|
17
18
|
add(layer: ChaynsHistoryLayer, callback: () => Promise<boolean>, opts?: ChaynsHistoryBlockOptions): () => void;
|
|
18
19
|
remove(layerId: string, entry: BlockEntry): void;
|
|
19
20
|
/** Remove all blocks registered for a layer (called on destroy). */
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChaynsReactFunctions, ChaynsReactValues, ChaynsStyleSettings, CleanupCallback, DataChangeCallback, IChaynsReact } from '../types/IChaynsReact';
|
|
2
2
|
export declare class AppWrapper implements IChaynsReact {
|
|
3
3
|
values: ChaynsReactValues;
|
|
4
|
+
history: IChaynsReact['history'];
|
|
4
5
|
accessToken: string;
|
|
5
6
|
listeners: (() => void)[];
|
|
6
7
|
customFunctions: {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
+
import { FrameHistoryLayer } from '../handler/history/FrameHistoryLayer';
|
|
1
2
|
import { ChaynsReactFunctions, ChaynsReactValues, DataChangeCallback, IChaynsReact } from '../types/IChaynsReact';
|
|
2
3
|
export declare class FrameWrapper implements IChaynsReact {
|
|
3
4
|
private resolve;
|
|
4
5
|
private exposedFunctions;
|
|
5
6
|
private exposedCustomFunctions;
|
|
6
7
|
private exposedCustomFunctionNames;
|
|
7
|
-
private resizeListener;
|
|
8
|
-
private _historyLayer;
|
|
9
8
|
ready: Promise<unknown>;
|
|
10
9
|
values: ChaynsReactValues;
|
|
10
|
+
history: FrameHistoryLayer | null;
|
|
11
11
|
chaynsApiId: string;
|
|
12
12
|
listeners: (() => void)[];
|
|
13
13
|
functions: ChaynsReactFunctions;
|
|
@@ -2,6 +2,7 @@ import { ChaynsReactFunctions, ChaynsReactValues, DataChangeCallback, IChaynsRea
|
|
|
2
2
|
export declare class ModuleFederationWrapper implements IChaynsReact {
|
|
3
3
|
values: ChaynsReactValues;
|
|
4
4
|
functions: ChaynsReactFunctions;
|
|
5
|
+
history: IChaynsReact['history'];
|
|
5
6
|
customFunctions: IChaynsReact["customFunctions"];
|
|
6
7
|
listeners: (() => void)[];
|
|
7
8
|
chaynsApiId: string;
|
|
@@ -3,6 +3,7 @@ export declare class SsrWrapper implements IChaynsReact {
|
|
|
3
3
|
private readonly initialData;
|
|
4
4
|
values: ChaynsReactValues;
|
|
5
5
|
functions: ChaynsReactFunctions;
|
|
6
|
+
history: IChaynsReact['history'];
|
|
6
7
|
customFunctions: IChaynsReact["customFunctions"];
|
|
7
8
|
listeners: (() => void)[];
|
|
8
9
|
chaynsApiId: string;
|
|
@@ -64,7 +64,6 @@ declare class StaticChaynsApi implements ChaynsReactFunctions {
|
|
|
64
64
|
addAccessTokenChangeListener: ChaynsReactFunctions['addAccessTokenChangeListener'];
|
|
65
65
|
removeAccessTokenChangeListener: ChaynsReactFunctions['removeAccessTokenChangeListener'];
|
|
66
66
|
redirect: ChaynsReactFunctions['redirect'];
|
|
67
|
-
getHistoryLayer: ChaynsReactFunctions['getHistoryLayer'];
|
|
68
67
|
ready: Promise<void>;
|
|
69
68
|
addDataListener: (cb: DataChangeCallback) => () => void;
|
|
70
69
|
private _wrapper;
|