chayns-api 3.1.1 → 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.
Files changed (31) hide show
  1. package/dist/cjs/components/ChaynsProvider.js +4 -7
  2. package/dist/cjs/handler/history/FrameHistoryLayer.js +7 -7
  3. package/dist/cjs/handler/history/HistoryLayer.js +10 -10
  4. package/dist/cjs/host/iframe/HostIframe.js +42 -28
  5. package/dist/cjs/utils/history/BlockRegistry.js +5 -0
  6. package/dist/cjs/wrapper/AppWrapper.js +1 -0
  7. package/dist/cjs/wrapper/FrameWrapper.js +8 -12
  8. package/dist/cjs/wrapper/ModuleFederationWrapper.js +1 -1
  9. package/dist/cjs/wrapper/SsrWrapper.js +1 -0
  10. package/dist/esm/components/ChaynsProvider.js +4 -7
  11. package/dist/esm/handler/history/FrameHistoryLayer.js +7 -7
  12. package/dist/esm/handler/history/HistoryLayer.js +10 -10
  13. package/dist/esm/host/iframe/HostIframe.js +42 -28
  14. package/dist/esm/utils/history/BlockRegistry.js +3 -0
  15. package/dist/esm/wrapper/AppWrapper.js +1 -0
  16. package/dist/esm/wrapper/FrameWrapper.js +8 -12
  17. package/dist/esm/wrapper/ModuleFederationWrapper.js +1 -1
  18. package/dist/esm/wrapper/SsrWrapper.js +1 -0
  19. package/dist/esm/wrapper/StaticChaynsApi.js +0 -1
  20. package/dist/types/handler/history/FrameHistoryLayer.d.ts +5 -5
  21. package/dist/types/handler/history/HistoryLayer.d.ts +5 -5
  22. package/dist/types/hooks/history.d.ts +6 -6
  23. package/dist/types/types/IChaynsReact.d.ts +1 -1
  24. package/dist/types/types/history.d.ts +5 -5
  25. package/dist/types/utils/history/BlockRegistry.d.ts +1 -0
  26. package/dist/types/wrapper/AppWrapper.d.ts +1 -0
  27. package/dist/types/wrapper/FrameWrapper.d.ts +2 -2
  28. package/dist/types/wrapper/ModuleFederationWrapper.d.ts +1 -0
  29. package/dist/types/wrapper/SsrWrapper.d.ts +1 -0
  30. package/dist/types/wrapper/StaticChaynsApi.d.ts +0 -1
  31. 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.functions.getHistoryLayer()) !== null && _customWrapper$curren2 !== void 0 ? _customWrapper$curren2 : contextLayer;
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
- if (typeof segmentCount === 'number' && layer.getSegmentCount() !== segmentCount) {
128
- layer.setSegmentCount(segmentCount);
124
+ if (layer && typeof segmentCount === 'number' && layer.getSegmentCount() !== 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
- void this.bridge.setSegmentCount(n);
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
- void this.bridge.setRoute(normalizedRoute, opts);
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
- void this.bridge.setParams(params, opts);
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
- void this.bridge.setHash(hash, opts);
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
- void this.bridge.setState(state, opts);
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
- void this.deps.getQueue().enqueue({
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
- void this.deps.getQueue().enqueue({
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
- void this.deps.getQueue().enqueue({
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
- void this.deps.getQueue().enqueue({
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
- void this.deps.getQueue().enqueue({
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
- var _historyLayerRef$curr;
121
- return !historyLayerRef.current ? new Error('[chayns-api] setRoute is not allowed on this page') : (_historyLayerRef$curr = historyLayerRef.current) === null || _historyLayerRef$curr === void 0 ? void 0 : _historyLayerRef$curr.setRoute(route, opts);
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
- var _historyLayerRef$curr2;
125
- return !historyLayerRef.current ? new Error('[chayns-api] setParams is not allowed on this page') : (_historyLayerRef$curr2 = historyLayerRef.current) === null || _historyLayerRef$curr2 === void 0 ? void 0 : _historyLayerRef$curr2.setParams(params, opts);
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
- var _historyLayerRef$curr3;
129
- return !historyLayerRef.current ? new Error('[chayns-api] setHash is not allowed on this page') : (_historyLayerRef$curr3 = historyLayerRef.current) === null || _historyLayerRef$curr3 === void 0 ? void 0 : _historyLayerRef$curr3.setHash(hash, opts);
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
- var _historyLayerRef$curr4;
133
- return !historyLayerRef.current ? new Error('[chayns-api] setState is not allowed on this page') : (_historyLayerRef$curr4 = historyLayerRef.current) === null || _historyLayerRef$curr4 === void 0 ? void 0 : _historyLayerRef$curr4.setState(state, opts);
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
- var _historyLayerRef$curr5;
137
- return !historyLayerRef.current ? new Error('[chayns-api] navigate is not allowed on this page') : (_historyLayerRef$curr5 = historyLayerRef.current) === null || _historyLayerRef$curr5 === void 0 ? void 0 : _historyLayerRef$curr5.navigate(opts);
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
- var _historyLayerRef$curr6;
141
- return !historyLayerRef.current ? new Error('[chayns-api] setActiveChild is not allowed on this page') : (_historyLayerRef$curr6 = historyLayerRef.current) === null || _historyLayerRef$curr6 === void 0 ? void 0 : _historyLayerRef$curr6.setActiveChild(id, init);
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
- var _historyLayerRef$curr7;
145
- return !historyLayerRef.current ? new Error('[chayns-api] setSegmentCount is not allowed on this page') : (_historyLayerRef$curr7 = historyLayerRef.current) === null || _historyLayerRef$curr7 === void 0 ? void 0 : _historyLayerRef$curr7.setSegmentCount(n);
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$curr8, _historyLayerRef$curr9;
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$curr8 = (_historyLayerRef$curr9 = historyLayerRef.current) === null || _historyLayerRef$curr9 === void 0 ? void 0 : _historyLayerRef$curr9.addEventListener('change', callback)) !== null && _historyLayerRef$curr8 !== void 0 ? _historyLayerRef$curr8 : () => {};
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$curr0, _historyLayerRef$curr1;
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$curr0 = (_historyLayerRef$curr1 = historyLayerRef.current) === null || _historyLayerRef$curr1 === void 0 ? void 0 : _historyLayerRef$curr1.addEventListener('popstate', callback)) !== null && _historyLayerRef$curr0 !== void 0 ? _historyLayerRef$curr0 : () => {};
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$curr10, _historyLayerRef$curr11;
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$curr10 = (_historyLayerRef$curr11 = historyLayerRef.current) === null || _historyLayerRef$curr11 === void 0 ? void 0 : _historyLayerRef$curr11.addBlock(callback, opts)) !== null && _historyLayerRef$curr10 !== void 0 ? _historyLayerRef$curr10 : () => {};
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
- throw new Error('[chaynsHistory] No history layer available. Ensure historyLayer prop is set on the parent HostIframe.');
310
- }
311
- return this._historyLayer;
312
305
  }
313
306
  };
314
307
  customFunctions = new Proxy({}, {
@@ -371,9 +364,12 @@ class FrameWrapper {
371
364
  }, {});
372
365
  const exposedHistory = exposed.history;
373
366
  if (exposedHistory) {
374
- const initialState = await exposedHistory.getInitialState();
367
+ let initialState = null;
368
+ try {
369
+ initialState = await exposedHistory.getInitialState();
370
+ } catch (ex) {}
375
371
  if (initialState) {
376
- this._historyLayer = new _FrameHistoryLayer.FrameHistoryLayer({
372
+ this.history = new _FrameHistoryLayer.FrameHistoryLayer({
377
373
  setRoute: (route, opts) => exposedHistory.setRoute(route, opts),
378
374
  setParams: (params, opts) => exposedHistory.setParams(params, opts),
379
375
  setHash: (hash, opts) => exposedHistory.setHash(hash, opts),
@@ -387,10 +383,10 @@ class FrameWrapper {
387
383
  }
388
384
  }, initialState);
389
385
  await exposedHistory.addChangeListener(comlink.proxy(e => {
390
- this._historyLayer._applyAndEmit(e);
386
+ this.history._applyAndEmit(e);
391
387
  }));
392
388
  await exposedHistory.addPopstateListener(comlink.proxy(e => {
393
- this._historyLayer._applyAndEmit(e);
389
+ this.history._applyAndEmit(e);
394
390
  }));
395
391
  }
396
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;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.SsrWrapper = void 0;
7
7
  class SsrWrapper {
8
+ history = null;
8
9
  listeners = [];
9
10
  chaynsApiId = null;
10
11
  constructor(values, functions, customFunctions) {
@@ -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.functions.getHistoryLayer()) !== null && _customWrapper$curren2 !== void 0 ? _customWrapper$curren2 : contextLayer;
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
- if (typeof segmentCount === 'number' && layer.getSegmentCount() !== segmentCount) {
120
- layer.setSegmentCount(segmentCount);
116
+ if (layer && typeof segmentCount === 'number' && layer.getSegmentCount() !== 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
- void this.bridge.setSegmentCount(n);
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
- void this.bridge.setRoute(normalizedRoute, opts);
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
- void this.bridge.setParams(params, opts);
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
- void this.bridge.setHash(hash, opts);
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
- void this.bridge.setState(state, opts);
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
- void this.deps.getQueue().enqueue({
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
- void this.deps.getQueue().enqueue({
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
- void this.deps.getQueue().enqueue({
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
- void this.deps.getQueue().enqueue({
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
- void this.deps.getQueue().enqueue({
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
- var _historyLayerRef$curr;
113
- return !historyLayerRef.current ? new Error('[chayns-api] setRoute is not allowed on this page') : (_historyLayerRef$curr = historyLayerRef.current) === null || _historyLayerRef$curr === void 0 ? void 0 : _historyLayerRef$curr.setRoute(route, opts);
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
- var _historyLayerRef$curr2;
117
- return !historyLayerRef.current ? new Error('[chayns-api] setParams is not allowed on this page') : (_historyLayerRef$curr2 = historyLayerRef.current) === null || _historyLayerRef$curr2 === void 0 ? void 0 : _historyLayerRef$curr2.setParams(params, opts);
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
- var _historyLayerRef$curr3;
121
- return !historyLayerRef.current ? new Error('[chayns-api] setHash is not allowed on this page') : (_historyLayerRef$curr3 = historyLayerRef.current) === null || _historyLayerRef$curr3 === void 0 ? void 0 : _historyLayerRef$curr3.setHash(hash, opts);
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
- var _historyLayerRef$curr4;
125
- return !historyLayerRef.current ? new Error('[chayns-api] setState is not allowed on this page') : (_historyLayerRef$curr4 = historyLayerRef.current) === null || _historyLayerRef$curr4 === void 0 ? void 0 : _historyLayerRef$curr4.setState(state, opts);
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
- var _historyLayerRef$curr5;
129
- return !historyLayerRef.current ? new Error('[chayns-api] navigate is not allowed on this page') : (_historyLayerRef$curr5 = historyLayerRef.current) === null || _historyLayerRef$curr5 === void 0 ? void 0 : _historyLayerRef$curr5.navigate(opts);
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
- var _historyLayerRef$curr6;
133
- return !historyLayerRef.current ? new Error('[chayns-api] setActiveChild is not allowed on this page') : (_historyLayerRef$curr6 = historyLayerRef.current) === null || _historyLayerRef$curr6 === void 0 ? void 0 : _historyLayerRef$curr6.setActiveChild(id, init);
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
- var _historyLayerRef$curr7;
137
- return !historyLayerRef.current ? new Error('[chayns-api] setSegmentCount is not allowed on this page') : (_historyLayerRef$curr7 = historyLayerRef.current) === null || _historyLayerRef$curr7 === void 0 ? void 0 : _historyLayerRef$curr7.setSegmentCount(n);
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$curr8, _historyLayerRef$curr9;
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$curr8 = (_historyLayerRef$curr9 = historyLayerRef.current) === null || _historyLayerRef$curr9 === void 0 ? void 0 : _historyLayerRef$curr9.addEventListener('change', callback)) !== null && _historyLayerRef$curr8 !== void 0 ? _historyLayerRef$curr8 : () => {};
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$curr0, _historyLayerRef$curr1;
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$curr0 = (_historyLayerRef$curr1 = historyLayerRef.current) === null || _historyLayerRef$curr1 === void 0 ? void 0 : _historyLayerRef$curr1.addEventListener('popstate', callback)) !== null && _historyLayerRef$curr0 !== void 0 ? _historyLayerRef$curr0 : () => {};
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$curr10, _historyLayerRef$curr11;
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$curr10 = (_historyLayerRef$curr11 = historyLayerRef.current) === null || _historyLayerRef$curr11 === void 0 ? void 0 : _historyLayerRef$curr11.addBlock(callback, opts)) !== null && _historyLayerRef$curr10 !== void 0 ? _historyLayerRef$curr10 : () => {};
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
- throw new Error('[chaynsHistory] No history layer available. Ensure historyLayer prop is set on the parent HostIframe.');
306
- }
307
- return this._historyLayer;
308
301
  }
309
302
  });
310
303
  _defineProperty(this, "customFunctions", new Proxy({}, {
@@ -375,9 +368,12 @@ export class FrameWrapper {
375
368
  }, {});
376
369
  const exposedHistory = exposed.history;
377
370
  if (exposedHistory) {
378
- const initialState = await exposedHistory.getInitialState();
371
+ let initialState = null;
372
+ try {
373
+ initialState = await exposedHistory.getInitialState();
374
+ } catch (ex) {}
379
375
  if (initialState) {
380
- this._historyLayer = new FrameHistoryLayer({
376
+ this.history = new FrameHistoryLayer({
381
377
  setRoute: (route, opts) => exposedHistory.setRoute(route, opts),
382
378
  setParams: (params, opts) => exposedHistory.setParams(params, opts),
383
379
  setHash: (hash, opts) => exposedHistory.setHash(hash, opts),
@@ -391,10 +387,10 @@ export class FrameWrapper {
391
387
  }
392
388
  }, initialState);
393
389
  await exposedHistory.addChangeListener(comlink.proxy(e => {
394
- this._historyLayer._applyAndEmit(e);
390
+ this.history._applyAndEmit(e);
395
391
  }));
396
392
  await exposedHistory.addPopstateListener(comlink.proxy(e => {
397
- this._historyLayer._applyAndEmit(e);
393
+ this.history._applyAndEmit(e);
398
394
  }));
399
395
  }
400
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: object, opts?: ChaynsHistoryNavigateOptions): void;
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
- }) => void;
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;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",