chayns-api 1.0.8 → 1.0.10

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.
@@ -32,6 +32,9 @@ const withCompatMode = Component => {
32
32
  ref: innerRef
33
33
  })), this.ref.current);
34
34
  }
35
+ componentWillUnmount() {
36
+ _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null), this.ref.current);
37
+ }
35
38
  render() {
36
39
  return /*#__PURE__*/_react.default.createElement("div", {
37
40
  ref: this.ref
@@ -68,7 +68,7 @@ const HostIframe = ({
68
68
  if (postForm) {
69
69
  var _await$functions$getA;
70
70
  const accessToken = (_await$functions$getA = await functions.getAccessToken()) !== null && _await$functions$getA !== void 0 ? _await$functions$getA : {};
71
- void (0, _postIframeForm.default)((0, _url.replaceStagingUrl)(preventStagingReplacement, src, environment.runtimeEnvironment), JSON.stringify({
71
+ void (0, _postIframeForm.default)((0, _url.replaceStagingUrl)(preventStagingReplacement, src, environment.buildEnvironment), JSON.stringify({
72
72
  ...initialData,
73
73
  pages: undefined,
74
74
  ...accessToken
@@ -128,7 +128,7 @@ const HostIframe = ({
128
128
  },
129
129
  title: " "
130
130
  }, iFrameProps, {
131
- src: postForm ? undefined : (0, _url.replaceStagingUrl)(preventStagingReplacement, src, environment.runtimeEnvironment)
131
+ src: postForm ? undefined : (0, _url.replaceStagingUrl)(preventStagingReplacement, src, environment.buildEnvironment)
132
132
  }));
133
133
  };
134
134
  var _default = HostIframe;
@@ -75,7 +75,7 @@ const ModuleHost = ({
75
75
  }), /*#__PURE__*/_react.default.createElement(System, {
76
76
  system: {
77
77
  scope: system.scope,
78
- url: (0, _url.replaceStagingUrl)(preventStagingReplacement, system.url, environment.runtimeEnvironment),
78
+ url: (0, _url.replaceStagingUrl)(preventStagingReplacement, system.url, environment.buildEnvironment),
79
79
  module: system.module
80
80
  },
81
81
  data: initialData,
@@ -4,10 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.AppWrapper = void 0;
7
+ var _lodash = _interopRequireDefault(require("lodash.throttle"));
7
8
  var _IChaynsReact = require("../types/IChaynsReact");
8
9
  var _appCall = _interopRequireDefault(require("../util/appCall"));
9
10
  var _deviceHelper = _interopRequireWildcard(require("../util/deviceHelper"));
10
- var _visibilityChangeListener = require("../calls/visibilityChangeListener");
11
11
  var _getUserInfo = _interopRequireDefault(require("../calls/getUserInfo"));
12
12
  var _sendMessage = require("../calls/sendMessage");
13
13
  var _apiListenerHelper = require("../helper/apiListenerHelper");
@@ -19,7 +19,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
19
19
 
20
20
  class AppWrapper {
21
21
  values = null;
22
- accessToken = "";
22
+ accessToken = '';
23
23
  mapOldApiToNew(retVal) {
24
24
  var _window, _window2, _AppInfo$TappSelected;
25
25
  const {
@@ -122,7 +122,7 @@ class AppWrapper {
122
122
  }
123
123
  resolve((_v$retVal2 = v === null || v === void 0 ? void 0 : v.retVal) !== null && _v$retVal2 !== void 0 ? _v$retVal2 : v);
124
124
  };
125
- value.callback = "window." + callbackName;
125
+ value.callback = 'window.' + callbackName;
126
126
  (0, _appCall.default)({
127
127
  action,
128
128
  value
@@ -133,50 +133,83 @@ class AppWrapper {
133
133
  getAccessToken: async () => ({
134
134
  accessToken: this.accessToken
135
135
  }),
136
- // addGeoLocationListener: async (value , callback) => {
137
- // return invokeAppCall({
138
- // 'action': 14,
139
- // 'value': {
140
- // 'permanent': false,
141
- // callback: callback
142
- // }
143
- // });
144
- // },
145
- // addScrollListener: async (value, callback) => {
146
- //
147
- // },
136
+ addGeoLocationListener: async (value, callback) => {
137
+ const {
138
+ id,
139
+ shouldInitialize
140
+ } = (0, _apiListenerHelper.addApiListener)('geoLocationListener', callback);
141
+ if (shouldInitialize) {
142
+ this.appCall(14, {
143
+ permanent: true
144
+ }, {
145
+ callback: v => {
146
+ var _v$accuracy, _v$code;
147
+ (0, _apiListenerHelper.dispatchApiEvent)('geoLocationListener', {
148
+ latitude: v.latitude,
149
+ longitude: v.longitude,
150
+ accuracy: (_v$accuracy = v.accuracy) !== null && _v$accuracy !== void 0 ? _v$accuracy : null,
151
+ speed: v.speed,
152
+ code: (_v$code = v.code) !== null && _v$code !== void 0 ? _v$code : null
153
+ });
154
+ }
155
+ });
156
+ }
157
+ return id;
158
+ },
159
+ addScrollListener: async (value, callback) => {
160
+ let throttledCallback = callback;
161
+ if (value.throttle) {
162
+ throttledCallback = (0, _lodash.default)(callback, value.throttle);
163
+ }
164
+ const {
165
+ id,
166
+ shouldInitialize
167
+ } = (0, _apiListenerHelper.addApiListener)('scrollListener', throttledCallback);
168
+ if (shouldInitialize) {
169
+ window.addEventListener('scroll', this.scrollListener = () => {
170
+ void (async () => {
171
+ (0, _apiListenerHelper.dispatchApiEvent)('scrollListener', {
172
+ scrollX: window.scrollX,
173
+ scrollY: window.scrollY
174
+ });
175
+ })();
176
+ });
177
+ }
178
+ return id;
179
+ },
148
180
  addVisibilityChangeListener: async callback => {
181
+ const {
182
+ id,
183
+ shouldInitialize
184
+ } = (0, _apiListenerHelper.addApiListener)('visibilityChangeListener', callback);
185
+ if (shouldInitialize) {
186
+ this.appCall(60, {}, {
187
+ callback: v => {
188
+ (0, _apiListenerHelper.dispatchApiEvent)('visibilityChangeListener', {
189
+ isVisible: v.tappEvent === _IChaynsReact.TappEvent.OnShow,
190
+ tappEvent: v.tappEvent
191
+ });
192
+ }
193
+ });
194
+ }
195
+ return id;
196
+ },
197
+ addWindowMetricsListener: async callback => {
149
198
  const {
150
199
  id,
151
200
  shouldInitialize
152
201
  } = (0, _apiListenerHelper.addApiListener)('windowMetricsListener', callback);
153
- this.appCall(60, {}, {
154
- callback: v => {
155
- console.log("v", v);
156
- (0, _apiListenerHelper.dispatchApiEvent)("windowMetricsListener", {
157
- isVisible: v.tappEvent === _IChaynsReact.TappEvent.OnShow,
158
- tappEvent: v.tappEvent
159
- });
160
- }
161
- });
202
+ if (shouldInitialize) {
203
+ window.addEventListener('resize', this.resizeListener = () => {
204
+ void (async () => {
205
+ (0, _apiListenerHelper.dispatchApiEvent)('windowMetricsListener', await this.functions.getWindowMetrics());
206
+ })();
207
+ });
208
+ }
162
209
  return id;
163
210
  },
164
- // addWindowMetricsListener: async (callback) => {
165
- // const { id, shouldInitialize } = addApiListener('windowMetricsListener', callback);
166
- //
167
- // if (shouldInitialize) {
168
- // window.addEventListener('resize', this.resizeListener = () => {
169
- // void (async() => {
170
- // dispatchApiEvent('windowMetricsListener', {
171
- //
172
- // });
173
- // })();
174
- // })
175
- // }
176
- // return id;
177
- // },
178
211
  customCallbackFunction: async () => {
179
- this.notImplemented("customCallbackFunction");
212
+ this.notImplemented('customCallbackFunction');
180
213
  },
181
214
  getAvailableSharingServices: async () => {
182
215
  const res = await this.appCall(79);
@@ -264,9 +297,9 @@ class AppWrapper {
264
297
  awaitResult: false
265
298
  });
266
299
  },
267
- // openUrl: async (value) => {
268
- //
269
- // },
300
+ openUrl: async value => {
301
+ window.open(value.url);
302
+ },
270
303
  openVideo: async value => {
271
304
  this.appCall(15, {
272
305
  url: value.url
@@ -280,19 +313,41 @@ class AppWrapper {
280
313
  });
281
314
  },
282
315
  refreshData: async value => {
283
- this.notImplemented("refreshData");
284
- },
285
- // removeGeoLocationListener: async (id) => {
286
- // },
287
- // removeScrollListener: async (id) => {
288
- // },
289
- removeVisibilityChangeListener(number) {
290
- (0, _visibilityChangeListener.removeVisibilityChangeListener)(number);
291
- return Promise.resolve();
292
- },
293
- // removeWindowMetricsListener: async (id) => {
294
- //
295
- // },
316
+ this.notImplemented('refreshData');
317
+ },
318
+ removeGeoLocationListener: async id => {
319
+ const {
320
+ shouldRemove
321
+ } = (0, _apiListenerHelper.removeApiListener)('geoLocationListener', id);
322
+ if (shouldRemove) {
323
+ // App does not support removal of request geo location call with permanent true which makes this a no-op
324
+ }
325
+ },
326
+ removeScrollListener: async id => {
327
+ const {
328
+ shouldRemove
329
+ } = (0, _apiListenerHelper.removeApiListener)('scrollListener', id);
330
+ if (shouldRemove && this.scrollListener) {
331
+ window.removeEventListener('scroll', this.scrollListener);
332
+ this.scrollListener = null;
333
+ }
334
+ },
335
+ removeVisibilityChangeListener: async id => {
336
+ const {
337
+ shouldRemove
338
+ } = (0, _apiListenerHelper.removeApiListener)('visibilityChangeListener', id);
339
+ if (shouldRemove) {
340
+ // App does not support removal of onActivate callback which makes this a no-op
341
+ }
342
+ },
343
+ removeWindowMetricsListener: async id => {
344
+ const shouldRemove = (0, _apiListenerHelper.removeApiListener)('windowMetricsListener', id);
345
+ if (shouldRemove) {
346
+ void this.exposedFunctions.removeWindowMetricsListener(id);
347
+ if (this.resizeListener) window.removeEventListener('resize', this.resizeListener);
348
+ this.resizeListener = null;
349
+ }
350
+ },
296
351
  selectPage: async options => {
297
352
  void this.appCall(2, {
298
353
  id: options.id,
@@ -323,7 +378,7 @@ class AppWrapper {
323
378
  return (0, _sendMessage.sendMessageToUser)(this, message, userId);
324
379
  },
325
380
  setAdminMode: async () => {
326
- this.notImplemented("setAdminMode");
381
+ this.notImplemented('setAdminMode');
327
382
  },
328
383
  setDisplayTimeout: async enabled => {
329
384
  this.appCall(94, {
@@ -348,10 +403,10 @@ class AppWrapper {
348
403
  }, callback));
349
404
  },
350
405
  setHeight: async () => {
351
- this.notImplemented("setOverlay");
406
+ this.notImplemented('setOverlay');
352
407
  },
353
408
  setOverlay: async () => {
354
- this.notImplemented("setOverlay");
409
+ this.notImplemented('setOverlay');
355
410
  },
356
411
  setRefreshScrollEnabled: async isEnabled => {
357
412
  this.appCall(0, {
@@ -367,7 +422,7 @@ class AppWrapper {
367
422
  return await this.appCall(34, value);
368
423
  },
369
424
  setTempDesignSettings: async () => {
370
- this.notImplemented("setTempDesignSettings");
425
+ this.notImplemented('setTempDesignSettings');
371
426
  },
372
427
  setWaitCursor: async value => {
373
428
  void this.appCall(1, {
@@ -25,6 +25,9 @@ export const withCompatMode = Component => {
25
25
  ref: innerRef
26
26
  })), this.ref.current);
27
27
  }
28
+ componentWillUnmount() {
29
+ ReactDOM.render( /*#__PURE__*/React.createElement(React.Fragment, null), this.ref.current);
30
+ }
28
31
  render() {
29
32
  return /*#__PURE__*/React.createElement("div", {
30
33
  ref: this.ref
@@ -60,7 +60,7 @@ const HostIframe = _ref => {
60
60
  if (postForm) {
61
61
  var _await$functions$getA;
62
62
  const accessToken = (_await$functions$getA = await functions.getAccessToken()) !== null && _await$functions$getA !== void 0 ? _await$functions$getA : {};
63
- void postIframeForm(replaceStagingUrl(preventStagingReplacement, src, environment.runtimeEnvironment), JSON.stringify({
63
+ void postIframeForm(replaceStagingUrl(preventStagingReplacement, src, environment.buildEnvironment), JSON.stringify({
64
64
  ...initialData,
65
65
  pages: undefined,
66
66
  ...accessToken
@@ -120,7 +120,7 @@ const HostIframe = _ref => {
120
120
  },
121
121
  title: " "
122
122
  }, iFrameProps, {
123
- src: postForm ? undefined : replaceStagingUrl(preventStagingReplacement, src, environment.runtimeEnvironment)
123
+ src: postForm ? undefined : replaceStagingUrl(preventStagingReplacement, src, environment.buildEnvironment)
124
124
  }));
125
125
  };
126
126
  export default HostIframe;
@@ -68,7 +68,7 @@ const ModuleHost = _ref2 => {
68
68
  }), /*#__PURE__*/React.createElement(System, {
69
69
  system: {
70
70
  scope: system.scope,
71
- url: replaceStagingUrl(preventStagingReplacement, system.url, environment.runtimeEnvironment),
71
+ url: replaceStagingUrl(preventStagingReplacement, system.url, environment.buildEnvironment),
72
72
  module: system.module
73
73
  },
74
74
  data: initialData,
@@ -1,14 +1,16 @@
1
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
2
4
  /* eslint-disable */
3
5
  // @ts-nocheck
4
6
 
7
+ import throttle from 'lodash.throttle';
5
8
  import { Environment, Font, Gender, IconType, RuntimeEnviroment, TappEvent } from '../types/IChaynsReact';
6
- import invokeAppCall from "../util/appCall";
7
- import getDeviceInfo, { getScreenSize } from "../util/deviceHelper";
8
- import { removeVisibilityChangeListener } from "../calls/visibilityChangeListener";
9
- import getUserInfo from "../calls/getUserInfo";
10
- import { sendMessageToGroup, sendMessageToPage, sendMessageToUser } from "../calls/sendMessage";
11
- import { addApiListener, dispatchApiEvent } from "../helper/apiListenerHelper";
9
+ import invokeAppCall from '../util/appCall';
10
+ import getDeviceInfo, { getScreenSize } from '../util/deviceHelper';
11
+ import getUserInfo from '../calls/getUserInfo';
12
+ import { sendMessageToGroup, sendMessageToPage, sendMessageToUser } from '../calls/sendMessage';
13
+ import { addApiListener, dispatchApiEvent, removeApiListener } from '../helper/apiListenerHelper';
12
14
  export class AppWrapper {
13
15
  mapOldApiToNew(retVal) {
14
16
  var _window, _window2, _AppInfo$TappSelected;
@@ -86,56 +88,89 @@ export class AppWrapper {
86
88
  }
87
89
  constructor() {
88
90
  _defineProperty(this, "values", null);
89
- _defineProperty(this, "accessToken", "");
91
+ _defineProperty(this, "accessToken", '');
90
92
  _defineProperty(this, "counter", 0);
91
93
  _defineProperty(this, "functions", {
92
94
  getAccessToken: async () => ({
93
95
  accessToken: this.accessToken
94
96
  }),
95
- // addGeoLocationListener: async (value , callback) => {
96
- // return invokeAppCall({
97
- // 'action': 14,
98
- // 'value': {
99
- // 'permanent': false,
100
- // callback: callback
101
- // }
102
- // });
103
- // },
104
- // addScrollListener: async (value, callback) => {
105
- //
106
- // },
97
+ addGeoLocationListener: async (value, callback) => {
98
+ const {
99
+ id,
100
+ shouldInitialize
101
+ } = addApiListener('geoLocationListener', callback);
102
+ if (shouldInitialize) {
103
+ this.appCall(14, {
104
+ permanent: true
105
+ }, {
106
+ callback: v => {
107
+ var _v$accuracy, _v$code;
108
+ dispatchApiEvent('geoLocationListener', {
109
+ latitude: v.latitude,
110
+ longitude: v.longitude,
111
+ accuracy: (_v$accuracy = v.accuracy) !== null && _v$accuracy !== void 0 ? _v$accuracy : null,
112
+ speed: v.speed,
113
+ code: (_v$code = v.code) !== null && _v$code !== void 0 ? _v$code : null
114
+ });
115
+ }
116
+ });
117
+ }
118
+ return id;
119
+ },
120
+ addScrollListener: async (value, callback) => {
121
+ let throttledCallback = callback;
122
+ if (value.throttle) {
123
+ throttledCallback = throttle(callback, value.throttle);
124
+ }
125
+ const {
126
+ id,
127
+ shouldInitialize
128
+ } = addApiListener('scrollListener', throttledCallback);
129
+ if (shouldInitialize) {
130
+ window.addEventListener('scroll', this.scrollListener = () => {
131
+ void (async () => {
132
+ dispatchApiEvent('scrollListener', {
133
+ scrollX: window.scrollX,
134
+ scrollY: window.scrollY
135
+ });
136
+ })();
137
+ });
138
+ }
139
+ return id;
140
+ },
107
141
  addVisibilityChangeListener: async callback => {
142
+ const {
143
+ id,
144
+ shouldInitialize
145
+ } = addApiListener('visibilityChangeListener', callback);
146
+ if (shouldInitialize) {
147
+ this.appCall(60, {}, {
148
+ callback: v => {
149
+ dispatchApiEvent('visibilityChangeListener', {
150
+ isVisible: v.tappEvent === TappEvent.OnShow,
151
+ tappEvent: v.tappEvent
152
+ });
153
+ }
154
+ });
155
+ }
156
+ return id;
157
+ },
158
+ addWindowMetricsListener: async callback => {
108
159
  const {
109
160
  id,
110
161
  shouldInitialize
111
162
  } = addApiListener('windowMetricsListener', callback);
112
- this.appCall(60, {}, {
113
- callback: v => {
114
- console.log("v", v);
115
- dispatchApiEvent("windowMetricsListener", {
116
- isVisible: v.tappEvent === TappEvent.OnShow,
117
- tappEvent: v.tappEvent
118
- });
119
- }
120
- });
163
+ if (shouldInitialize) {
164
+ window.addEventListener('resize', this.resizeListener = () => {
165
+ void (async () => {
166
+ dispatchApiEvent('windowMetricsListener', await this.functions.getWindowMetrics());
167
+ })();
168
+ });
169
+ }
121
170
  return id;
122
171
  },
123
- // addWindowMetricsListener: async (callback) => {
124
- // const { id, shouldInitialize } = addApiListener('windowMetricsListener', callback);
125
- //
126
- // if (shouldInitialize) {
127
- // window.addEventListener('resize', this.resizeListener = () => {
128
- // void (async() => {
129
- // dispatchApiEvent('windowMetricsListener', {
130
- //
131
- // });
132
- // })();
133
- // })
134
- // }
135
- // return id;
136
- // },
137
172
  customCallbackFunction: async () => {
138
- this.notImplemented("customCallbackFunction");
173
+ this.notImplemented('customCallbackFunction');
139
174
  },
140
175
  getAvailableSharingServices: async () => {
141
176
  const res = await this.appCall(79);
@@ -224,9 +259,9 @@ export class AppWrapper {
224
259
  awaitResult: false
225
260
  });
226
261
  },
227
- // openUrl: async (value) => {
228
- //
229
- // },
262
+ openUrl: async value => {
263
+ window.open(value.url);
264
+ },
230
265
  openVideo: async value => {
231
266
  this.appCall(15, {
232
267
  url: value.url
@@ -240,19 +275,41 @@ export class AppWrapper {
240
275
  });
241
276
  },
242
277
  refreshData: async value => {
243
- this.notImplemented("refreshData");
244
- },
245
- // removeGeoLocationListener: async (id) => {
246
- // },
247
- // removeScrollListener: async (id) => {
248
- // },
249
- removeVisibilityChangeListener(number) {
250
- removeVisibilityChangeListener(number);
251
- return Promise.resolve();
252
- },
253
- // removeWindowMetricsListener: async (id) => {
254
- //
255
- // },
278
+ this.notImplemented('refreshData');
279
+ },
280
+ removeGeoLocationListener: async id => {
281
+ const {
282
+ shouldRemove
283
+ } = removeApiListener('geoLocationListener', id);
284
+ if (shouldRemove) {
285
+ // App does not support removal of request geo location call with permanent true which makes this a no-op
286
+ }
287
+ },
288
+ removeScrollListener: async id => {
289
+ const {
290
+ shouldRemove
291
+ } = removeApiListener('scrollListener', id);
292
+ if (shouldRemove && this.scrollListener) {
293
+ window.removeEventListener('scroll', this.scrollListener);
294
+ this.scrollListener = null;
295
+ }
296
+ },
297
+ removeVisibilityChangeListener: async id => {
298
+ const {
299
+ shouldRemove
300
+ } = removeApiListener('visibilityChangeListener', id);
301
+ if (shouldRemove) {
302
+ // App does not support removal of onActivate callback which makes this a no-op
303
+ }
304
+ },
305
+ removeWindowMetricsListener: async id => {
306
+ const shouldRemove = removeApiListener('windowMetricsListener', id);
307
+ if (shouldRemove) {
308
+ void this.exposedFunctions.removeWindowMetricsListener(id);
309
+ if (this.resizeListener) window.removeEventListener('resize', this.resizeListener);
310
+ this.resizeListener = null;
311
+ }
312
+ },
256
313
  selectPage: async options => {
257
314
  void this.appCall(2, {
258
315
  id: options.id,
@@ -283,7 +340,7 @@ export class AppWrapper {
283
340
  return sendMessageToUser(this, message, userId);
284
341
  },
285
342
  setAdminMode: async () => {
286
- this.notImplemented("setAdminMode");
343
+ this.notImplemented('setAdminMode');
287
344
  },
288
345
  setDisplayTimeout: async enabled => {
289
346
  this.appCall(94, {
@@ -308,10 +365,10 @@ export class AppWrapper {
308
365
  }, callback));
309
366
  },
310
367
  setHeight: async () => {
311
- this.notImplemented("setOverlay");
368
+ this.notImplemented('setOverlay');
312
369
  },
313
370
  setOverlay: async () => {
314
- this.notImplemented("setOverlay");
371
+ this.notImplemented('setOverlay');
315
372
  },
316
373
  setRefreshScrollEnabled: async isEnabled => {
317
374
  this.appCall(0, {
@@ -327,7 +384,7 @@ export class AppWrapper {
327
384
  return await this.appCall(34, value);
328
385
  },
329
386
  setTempDesignSettings: async () => {
330
- this.notImplemented("setTempDesignSettings");
387
+ this.notImplemented('setTempDesignSettings');
331
388
  },
332
389
  setWaitCursor: async value => {
333
390
  void this.appCall(1, {
@@ -401,7 +458,7 @@ export class AppWrapper {
401
458
  }
402
459
  resolve((_v$retVal2 = v === null || v === void 0 ? void 0 : v.retVal) !== null && _v$retVal2 !== void 0 ? _v$retVal2 : v);
403
460
  };
404
- value.callback = "window." + callbackName;
461
+ value.callback = 'window.' + callbackName;
405
462
  invokeAppCall({
406
463
  action,
407
464
  value
@@ -1,4 +1,6 @@
1
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
2
4
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
3
5
  import * as comlink from 'comlink';
4
6
  import { addVisibilityChangeListener, removeVisibilityChangeListener } from '../calls/visibilityChangeListener';
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { ReactNode } from 'react';
2
2
  import { ChaynsReactFunctions, ChaynsReactValues, IChaynsReact } from '../types/IChaynsReact';
3
3
  export declare const moduleWrapper: {
4
4
  current: IChaynsReact;
@@ -8,6 +8,7 @@ type ChaynsProviderProps = {
8
8
  functions?: ChaynsReactFunctions;
9
9
  renderedByServer?: boolean;
10
10
  isModule?: boolean;
11
+ children?: ReactNode;
11
12
  };
12
13
  declare const ChaynsProvider: React.FC<ChaynsProviderProps>;
13
14
  export default ChaynsProvider;
@@ -2,6 +2,7 @@ import { FC, ReactNode } from "react";
2
2
  type TaskList = (TaskList | Promise<unknown> | (() => Promise<unknown>))[];
3
3
  export declare const WaitUntil: FC<{
4
4
  tasks: TaskList;
5
+ children?: ReactNode;
5
6
  loadingComponent?: ReactNode;
6
7
  }>;
7
8
  export {};
@@ -1,4 +1,4 @@
1
- import { FC } from 'react';
1
+ import { FC, ReactNode } from 'react';
2
2
  import { ChaynsApiDevice, ChaynsApiSite, ChaynsApiUser, ChaynsReactFunctions, ChaynsReactValues, Page } from '../../types/IChaynsReact';
3
3
  export type TypeSystem = {
4
4
  scope: string;
@@ -19,6 +19,7 @@ type ModulePropTypes = {
19
19
  customData: any;
20
20
  environment: ChaynsReactValues["environment"];
21
21
  preventStagingReplacement?: boolean;
22
+ children?: ReactNode;
22
23
  };
23
24
  declare const ModuleHost: FC<ModulePropTypes>;
24
25
  export default ModuleHost;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -35,7 +35,7 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "@types/semver": "^7.3.9",
38
- "comlink": "^4.3.1",
38
+ "comlink": "^4.4.1",
39
39
  "detect-browser": "^5.2.1",
40
40
  "htmlescape": "^1.1.1",
41
41
  "lodash.throttle": "^4.1.1",
@@ -46,8 +46,8 @@
46
46
  "use-context-selector": "^1.3.9"
47
47
  },
48
48
  "devDependencies": {
49
- "@babel/cli": "^7.16.0",
50
- "@babel/core": "^7.16.0",
49
+ "@babel/cli": "^7.20.7",
50
+ "@babel/core": "^7.20.12",
51
51
  "@babel/preset-env": "^7.16.4",
52
52
  "@babel/preset-react": "^7.16.0",
53
53
  "@babel/preset-typescript": "^7.16.0",
@@ -56,18 +56,17 @@
56
56
  "@types/htmlescape": "^1.1.1",
57
57
  "@types/lodash.throttle": "^4.1.6",
58
58
  "@types/prop-types": "^15.7.3",
59
- "@types/react": "^17.0.37",
59
+ "@types/react": "^17.0.53",
60
60
  "@types/react-dom": "^17.0.11",
61
- "@typescript-eslint/parser": "^5.4.0",
62
- "chayns-toolkit": "^2.0.0-beta.21",
63
- "concurrently": "^6.5.1",
61
+ "@typescript-eslint/parser": "^5.50.0",
62
+ "concurrently": "^7.6.0",
64
63
  "cross-env": "^7.0.3",
65
64
  "postcss-prefix-selector": "^1.13.0",
66
65
  "prettier": "^2.5.0",
67
66
  "prettier-plugin-packagejson": "^2.2.15",
68
67
  "react": "^17.0.2",
69
68
  "react-dom": "^17.0.2",
70
- "typescript": "^4.5.2"
69
+ "typescript": "^4.9.5"
71
70
  },
72
71
  "peerDependencies": {
73
72
  "react": "^16.8 || ^17.0.1",
package/toolkit.config.js DELETED
@@ -1,52 +0,0 @@
1
- /* eslint-disable import/no-extraneous-dependencies */
2
- const packageJson = require('./package.json');
3
- const webpack = require('webpack');
4
- const { ModuleFederationPlugin } = webpack.container;
5
- const path = require('path');
6
-
7
- /**
8
- * Your `chayns-toolkit.json`-file was automatically converted into this
9
- * JavaScript configuration file, which will be the configuration format going
10
- * forward.
11
- */
12
-
13
- module.exports = {
14
- development: {
15
- host: '0.0.0.0',
16
- port: parseInt(process.env.DEV_PORT, 10) || 8083,
17
- cert: '//fs1/ssl/tobitag.crt',
18
- key: '//fs1/ssl/tobitag.key',
19
- },
20
- webpack(config, { dev }) {
21
- config.output.uniqueName = `module-chayns-api`;
22
-
23
- config.plugins.push(
24
- new ModuleFederationPlugin({
25
- name: 'chayns_api_module2',
26
- filename: 'remoteEntry.js',
27
- exposes: {
28
- './index': './src/index',
29
- './ChaynsProvider': './src/components/ChaynsProvider'
30
- },
31
- shared: {
32
- react: {
33
- requiredVersion: packageJson.peerDependencies?.react || packageJson.dependencies?.react
34
- },
35
- 'react-dom': {
36
- requiredVersion: packageJson.peerDependencies?.["react-dom"] || packageJson.dependencies?.["react-dom"]
37
- }
38
- }
39
- })
40
- )
41
- config.output.chunkLoadingGlobal = `webpackChunkchayns_api__${process.env.BUILD_ENV || process.env.NODE_ENV}__${process.env.VERSION}`;
42
-
43
- config.resolve.alias = {
44
- react: path.resolve('./node_modules/react'),
45
- //'react-dom': path.resolve('./node_modules/react-dom')
46
- };
47
-
48
- delete config.optimization.splitChunks;
49
-
50
- return config;
51
- }
52
- };