chayns-api 3.1.0-beta.2 → 3.1.1

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.
@@ -2,6 +2,8 @@ name: Deploy Docs to GitHub Pages
2
2
 
3
3
  on:
4
4
  push:
5
+ branches:
6
+ - main
5
7
  paths:
6
8
  - "website/**"
7
9
  workflow_dispatch:
@@ -75,9 +75,9 @@ const ChaynsProvider = ({
75
75
  isHistoryDisabled,
76
76
  segmentCount
77
77
  }) => {
78
- var _ref, _crypto, _customWrapper$curren, _customWrapper$curren3, _customWrapper$curren4;
78
+ var _ref, _crypto, _crypto$randomUUID, _customWrapper$curren, _customWrapper$curren3, _customWrapper$curren4;
79
79
  const customWrapper = (0, _react.useRef)(null);
80
- const idRef = (0, _react.useRef)((_ref = chaynsApiId !== null && chaynsApiId !== void 0 ? chaynsApiId : (_crypto = crypto) === null || _crypto === void 0 ? void 0 : _crypto.randomUUID()) !== null && _ref !== void 0 ? _ref : Math.random().toString());
80
+ const idRef = (0, _react.useRef)((_ref = chaynsApiId !== null && chaynsApiId !== void 0 ? chaynsApiId : (_crypto = crypto) === null || _crypto === void 0 || (_crypto$randomUUID = _crypto.randomUUID) === null || _crypto$randomUUID === void 0 ? void 0 : _crypto$randomUUID.call(_crypto)) !== null && _ref !== void 0 ? _ref : Math.random().toString());
81
81
  const contextLayer = (0, _HistoryLayerContext.useChaynsHistoryLayerContext)();
82
82
  const parentLayerRef = (0, _react.useRef)(contextLayer);
83
83
  const rootLayerRef = (0, _react.useRef)(null);
@@ -101,7 +101,7 @@ const HostIframe = ({
101
101
  if (eventTarget.current) eventTarget.current.addEventListener('data_update', e => e.detail && cb(e.detail));
102
102
  },
103
103
  getInitialData: () => currentDataRef.current,
104
- history: historyLayerRef.current ? {
104
+ history: {
105
105
  getInitialState: () => {
106
106
  const l = historyLayerRef.current;
107
107
  if (!l) return null;
@@ -118,48 +118,57 @@ const HostIframe = ({
118
118
  },
119
119
  setRoute: (route, opts) => {
120
120
  var _historyLayerRef$curr;
121
- return (_historyLayerRef$curr = historyLayerRef.current) === null || _historyLayerRef$curr === void 0 ? void 0 : _historyLayerRef$curr.setRoute(route, opts);
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);
122
122
  },
123
123
  setParams: (params, opts) => {
124
124
  var _historyLayerRef$curr2;
125
- return (_historyLayerRef$curr2 = historyLayerRef.current) === null || _historyLayerRef$curr2 === void 0 ? void 0 : _historyLayerRef$curr2.setParams(params, opts);
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);
126
126
  },
127
127
  setHash: (hash, opts) => {
128
128
  var _historyLayerRef$curr3;
129
- return (_historyLayerRef$curr3 = historyLayerRef.current) === null || _historyLayerRef$curr3 === void 0 ? void 0 : _historyLayerRef$curr3.setHash(hash, opts);
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);
130
130
  },
131
131
  setState: (state, opts) => {
132
132
  var _historyLayerRef$curr4;
133
- return (_historyLayerRef$curr4 = historyLayerRef.current) === null || _historyLayerRef$curr4 === void 0 ? void 0 : _historyLayerRef$curr4.setState(state, opts);
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);
134
134
  },
135
135
  navigate: opts => {
136
136
  var _historyLayerRef$curr5;
137
- return (_historyLayerRef$curr5 = historyLayerRef.current) === null || _historyLayerRef$curr5 === void 0 ? void 0 : _historyLayerRef$curr5.navigate(opts);
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);
138
138
  },
139
139
  setActiveChild: (id, init) => {
140
140
  var _historyLayerRef$curr6;
141
- return (_historyLayerRef$curr6 = historyLayerRef.current) === null || _historyLayerRef$curr6 === void 0 ? void 0 : _historyLayerRef$curr6.setActiveChild(id, init);
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);
142
142
  },
143
143
  setSegmentCount: n => {
144
144
  var _historyLayerRef$curr7;
145
- return (_historyLayerRef$curr7 = historyLayerRef.current) === null || _historyLayerRef$curr7 === void 0 ? void 0 : _historyLayerRef$curr7.setSegmentCount(n);
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);
146
146
  },
147
147
  addChangeListener: callback => {
148
148
  var _historyLayerRef$curr8, _historyLayerRef$curr9;
149
+ if (!historyLayerRef.current) {
150
+ new Error('[chayns-api] addChangeListener is not allowed on this page');
151
+ }
149
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 : () => {};
150
153
  return comlink.proxy(unsub);
151
154
  },
152
155
  addPopstateListener: callback => {
153
156
  var _historyLayerRef$curr0, _historyLayerRef$curr1;
157
+ if (!historyLayerRef.current) {
158
+ new Error('[chayns-api] addPopstateListener is not allowed on this page');
159
+ }
154
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 : () => {};
155
161
  return comlink.proxy(unsub);
156
162
  },
157
163
  addBlock: (callback, opts) => {
158
164
  var _historyLayerRef$curr10, _historyLayerRef$curr11;
165
+ if (!historyLayerRef.current) {
166
+ new Error('[chayns-api] addBlock is not allowed on this page');
167
+ }
159
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 : () => {};
160
169
  return comlink.proxy(unsub);
161
170
  }
162
- } : undefined
171
+ }
163
172
  }
164
173
  };
165
174
  comlink.expose(obj, comlink.windowEndpoint(ref.current.contentWindow));
@@ -93,7 +93,7 @@ class AppWrapper {
93
93
  runtimeEnvironment: _IChaynsReact.RuntimeEnviroment.App
94
94
  },
95
95
  language: {
96
- site: language,
96
+ site: AppInfo.Language || 'de',
97
97
  translation: null,
98
98
  device: language,
99
99
  active: language
@@ -623,8 +623,8 @@ class AppWrapper {
623
623
  return new _DialogHandler.default(config, this.functions.openDialog, this.functions.closeDialog, this.functions.dispatchEventToDialogClient, this.functions.addDialogClientEventListener);
624
624
  },
625
625
  openDialog: async (config, callback) => {
626
- var _this$values$device;
627
- const currentDialogId = crypto.randomUUID();
626
+ var _crypto$randomUUID, _crypto, _crypto$randomUUID2, _this$values$device;
627
+ const currentDialogId = (_crypto$randomUUID = (_crypto = crypto) === null || _crypto === void 0 || (_crypto$randomUUID2 = _crypto.randomUUID) === null || _crypto$randomUUID2 === void 0 ? void 0 : _crypto$randomUUID2.call(_crypto)) !== null && _crypto$randomUUID !== void 0 ? _crypto$randomUUID : `${Date.now()}-${Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)}`;
628
628
  this.nextDialogEventId = 0;
629
629
  let isSupported = (0, _is.isAppCallSupported)({
630
630
  minAndroidVersion: 7137,
@@ -67,9 +67,9 @@ const ChaynsProvider = ({
67
67
  isHistoryDisabled,
68
68
  segmentCount
69
69
  }) => {
70
- var _ref, _crypto, _customWrapper$curren, _customWrapper$curren3, _customWrapper$curren4;
70
+ var _ref, _crypto, _crypto$randomUUID, _customWrapper$curren, _customWrapper$curren3, _customWrapper$curren4;
71
71
  const customWrapper = useRef(null);
72
- const idRef = useRef((_ref = chaynsApiId !== null && chaynsApiId !== void 0 ? chaynsApiId : (_crypto = crypto) === null || _crypto === void 0 ? void 0 : _crypto.randomUUID()) !== null && _ref !== void 0 ? _ref : Math.random().toString());
72
+ const idRef = useRef((_ref = chaynsApiId !== null && chaynsApiId !== void 0 ? chaynsApiId : (_crypto = crypto) === null || _crypto === void 0 || (_crypto$randomUUID = _crypto.randomUUID) === null || _crypto$randomUUID === void 0 ? void 0 : _crypto$randomUUID.call(_crypto)) !== null && _ref !== void 0 ? _ref : Math.random().toString());
73
73
  const contextLayer = useChaynsHistoryLayerContext();
74
74
  const parentLayerRef = useRef(contextLayer);
75
75
  const rootLayerRef = useRef(null);
@@ -93,7 +93,7 @@ const HostIframe = ({
93
93
  if (eventTarget.current) eventTarget.current.addEventListener('data_update', e => e.detail && cb(e.detail));
94
94
  },
95
95
  getInitialData: () => currentDataRef.current,
96
- history: historyLayerRef.current ? {
96
+ history: {
97
97
  getInitialState: () => {
98
98
  const l = historyLayerRef.current;
99
99
  if (!l) return null;
@@ -110,48 +110,57 @@ const HostIframe = ({
110
110
  },
111
111
  setRoute: (route, opts) => {
112
112
  var _historyLayerRef$curr;
113
- return (_historyLayerRef$curr = historyLayerRef.current) === null || _historyLayerRef$curr === void 0 ? void 0 : _historyLayerRef$curr.setRoute(route, opts);
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);
114
114
  },
115
115
  setParams: (params, opts) => {
116
116
  var _historyLayerRef$curr2;
117
- return (_historyLayerRef$curr2 = historyLayerRef.current) === null || _historyLayerRef$curr2 === void 0 ? void 0 : _historyLayerRef$curr2.setParams(params, opts);
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);
118
118
  },
119
119
  setHash: (hash, opts) => {
120
120
  var _historyLayerRef$curr3;
121
- return (_historyLayerRef$curr3 = historyLayerRef.current) === null || _historyLayerRef$curr3 === void 0 ? void 0 : _historyLayerRef$curr3.setHash(hash, opts);
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);
122
122
  },
123
123
  setState: (state, opts) => {
124
124
  var _historyLayerRef$curr4;
125
- return (_historyLayerRef$curr4 = historyLayerRef.current) === null || _historyLayerRef$curr4 === void 0 ? void 0 : _historyLayerRef$curr4.setState(state, opts);
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);
126
126
  },
127
127
  navigate: opts => {
128
128
  var _historyLayerRef$curr5;
129
- return (_historyLayerRef$curr5 = historyLayerRef.current) === null || _historyLayerRef$curr5 === void 0 ? void 0 : _historyLayerRef$curr5.navigate(opts);
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);
130
130
  },
131
131
  setActiveChild: (id, init) => {
132
132
  var _historyLayerRef$curr6;
133
- return (_historyLayerRef$curr6 = historyLayerRef.current) === null || _historyLayerRef$curr6 === void 0 ? void 0 : _historyLayerRef$curr6.setActiveChild(id, init);
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);
134
134
  },
135
135
  setSegmentCount: n => {
136
136
  var _historyLayerRef$curr7;
137
- return (_historyLayerRef$curr7 = historyLayerRef.current) === null || _historyLayerRef$curr7 === void 0 ? void 0 : _historyLayerRef$curr7.setSegmentCount(n);
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);
138
138
  },
139
139
  addChangeListener: callback => {
140
140
  var _historyLayerRef$curr8, _historyLayerRef$curr9;
141
+ if (!historyLayerRef.current) {
142
+ new Error('[chayns-api] addChangeListener is not allowed on this page');
143
+ }
141
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 : () => {};
142
145
  return comlink.proxy(unsub);
143
146
  },
144
147
  addPopstateListener: callback => {
145
148
  var _historyLayerRef$curr0, _historyLayerRef$curr1;
149
+ if (!historyLayerRef.current) {
150
+ new Error('[chayns-api] addPopstateListener is not allowed on this page');
151
+ }
146
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 : () => {};
147
153
  return comlink.proxy(unsub);
148
154
  },
149
155
  addBlock: (callback, opts) => {
150
156
  var _historyLayerRef$curr10, _historyLayerRef$curr11;
157
+ if (!historyLayerRef.current) {
158
+ new Error('[chayns-api] addBlock is not allowed on this page');
159
+ }
151
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 : () => {};
152
161
  return comlink.proxy(unsub);
153
162
  }
154
- } : undefined
163
+ }
155
164
  }
156
165
  };
157
166
  comlink.expose(obj, comlink.windowEndpoint(ref.current.contentWindow));
@@ -83,7 +83,7 @@ export class AppWrapper {
83
83
  runtimeEnvironment: RuntimeEnviroment.App
84
84
  },
85
85
  language: {
86
- site: language,
86
+ site: AppInfo.Language || 'de',
87
87
  translation: null,
88
88
  device: language,
89
89
  active: language
@@ -586,8 +586,8 @@ export class AppWrapper {
586
586
  return new DialogHandler(config, this.functions.openDialog, this.functions.closeDialog, this.functions.dispatchEventToDialogClient, this.functions.addDialogClientEventListener);
587
587
  },
588
588
  openDialog: async (config, callback) => {
589
- var _this$values$device;
590
- const currentDialogId = crypto.randomUUID();
589
+ var _crypto$randomUUID, _crypto, _crypto$randomUUID2, _this$values$device;
590
+ const currentDialogId = (_crypto$randomUUID = (_crypto = crypto) === null || _crypto === void 0 || (_crypto$randomUUID2 = _crypto.randomUUID) === null || _crypto$randomUUID2 === void 0 ? void 0 : _crypto$randomUUID2.call(_crypto)) !== null && _crypto$randomUUID !== void 0 ? _crypto$randomUUID : `${Date.now()}-${Math.floor(Math.random() * Number.MAX_SAFE_INTEGER)}`;
591
591
  this.nextDialogEventId = 0;
592
592
  let isSupported = isAppCallSupported({
593
593
  minAndroidVersion: 7137,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "3.1.0-beta.2",
3
+ "version": "3.1.1",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -71,7 +71,7 @@
71
71
  "@types/react-dom": "^18.3.7",
72
72
  "@types/ua-parser-js": "^0.7.39",
73
73
  "babel-plugin-react-compiler": "^1.0.0",
74
- "chayns-toolkit": "^4.0.0-beta.0",
74
+ "chayns-toolkit": "^4.0.7",
75
75
  "concurrently": "^9.2.1",
76
76
  "cross-env": "^10.1.0",
77
77
  "jsdom": "^29.1.1",