chayns-api 1.1.0-0 → 1.1.0-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 (101) hide show
  1. package/dist/cjs/handler/DialogHandler.js +24 -1
  2. package/dist/cjs/hooks/useDialogState.js +6 -2
  3. package/dist/cjs/wrapper/FrameWrapper.js +37 -3
  4. package/dist/cjs/wrapper/ModuleFederationWrapper.js +1 -1
  5. package/dist/esm/handler/DialogHandler.js +24 -1
  6. package/dist/esm/hooks/useDialogState.js +6 -2
  7. package/dist/esm/wrapper/FrameWrapper.js +37 -3
  8. package/dist/esm/wrapper/ModuleFederationWrapper.js +1 -1
  9. package/dist/types/components/WaitUntil.d.ts +1 -2
  10. package/dist/types/handler/DialogHandler.d.ts +8 -1
  11. package/dist/types/hooks/useDialogState.d.ts +1 -1
  12. package/dist/types/types/IChaynsReact.d.ts +9 -3
  13. package/package.json +4 -4
  14. package/dist/cjs/bootstrap.js +0 -11
  15. package/dist/cjs/calls/abstractApiListener.js +0 -40
  16. package/dist/cjs/calls/apiEventListener.js +0 -40
  17. package/dist/cjs/calls/setVisibilityChangeListener.js +0 -1
  18. package/dist/cjs/calls/windowMetricsListener.js +0 -18
  19. package/dist/cjs/client.js +0 -93
  20. package/dist/cjs/components/App.js +0 -32
  21. package/dist/cjs/components/App.spec.js +0 -16
  22. package/dist/cjs/components/Button.js +0 -32
  23. package/dist/cjs/components/ChaynsModuleProvider.js +0 -457
  24. package/dist/cjs/components/ChaynsProviderExposed.js +0 -16
  25. package/dist/cjs/components/Dialog.js +0 -1
  26. package/dist/cjs/components/TestProvider.js +0 -236
  27. package/dist/cjs/components/Title.js +0 -162
  28. package/dist/cjs/functions/addApiListener.js +0 -37
  29. package/dist/cjs/functions/addGeoLocationListener.js +0 -26
  30. package/dist/cjs/functions/addScrollListener.js +0 -26
  31. package/dist/cjs/functions/addWindowMetricsListener.js +0 -37
  32. package/dist/cjs/helper/cssLoader.js +0 -28
  33. package/dist/cjs/hooks/addGeoLocationListener.js +0 -26
  34. package/dist/cjs/hooks/addScrollListener.js +0 -26
  35. package/dist/cjs/hooks/addWindowMetricsListener.js +0 -37
  36. package/dist/cjs/hooks/geoLocation.js +0 -48
  37. package/dist/cjs/hooks/useAddGeoLocationListener.js +0 -26
  38. package/dist/cjs/hooks/useAddScrollListener.js +0 -48
  39. package/dist/cjs/hooks/useAddWindowMetricsListener.js +0 -45
  40. package/dist/cjs/hooks/useAdddScrollListener.js +0 -26
  41. package/dist/cjs/hooks/useFunction.js +0 -13
  42. package/dist/cjs/hooks/windowMetrics.js +0 -45
  43. package/dist/cjs/host/HostIframe.js +0 -157
  44. package/dist/cjs/host/ModuleHost.js +0 -11
  45. package/dist/cjs/host/module/utils.js +0 -25
  46. package/dist/cjs/index.example.js +0 -7
  47. package/dist/cjs/index2.js +0 -64
  48. package/dist/cjs/types/DynamicApiImport.d.js +0 -5
  49. package/dist/cjs/types/DynamicImport.d.js +0 -5
  50. package/dist/cjs/types/chayns-components.d.js +0 -1
  51. package/dist/cjs/types/chayns-logger.d.js +0 -1
  52. package/dist/cjs/types/chayns.d.js +0 -1
  53. package/dist/cjs/types/tobit-websocket-service-client.d.js +0 -1
  54. package/dist/cjs/types/toolkit-types.d.js +0 -1
  55. package/dist/cjs/util/useFunctionsContext.js +0 -16
  56. package/dist/cjs/util/useIsAdminMode.js +0 -18
  57. package/dist/cjs/util/useUser.js +0 -16
  58. package/dist/cjs/wrapper/Dialog.js +0 -35
  59. package/dist/cjs/wrapper/DialogHandler.js +0 -35
  60. package/dist/esm/bootstrap.js +0 -4
  61. package/dist/esm/client.js +0 -8
  62. package/dist/esm/components/App.js +0 -35
  63. package/dist/esm/components/App.spec.js +0 -9
  64. package/dist/esm/components/Button.js +0 -34
  65. package/dist/esm/components/ChaynsModuleProvider.js +0 -517
  66. package/dist/esm/components/ChaynsProviderExposed.js +0 -3
  67. package/dist/esm/components/Dialog.js +0 -0
  68. package/dist/esm/components/TestProvider.js +0 -308
  69. package/dist/esm/components/Title.js +0 -210
  70. package/dist/esm/helper/cssLoader.js +0 -21
  71. package/dist/esm/hooks/useAddGeoLocationListener.js +0 -18
  72. package/dist/esm/hooks/useAddScrollListener.js +0 -18
  73. package/dist/esm/hooks/useAddWindowMetricsListener.js +0 -18
  74. package/dist/esm/hooks/useFunction.js +0 -6
  75. package/dist/esm/host/HostIframe.js +0 -153
  76. package/dist/esm/index.example.js +0 -1
  77. package/dist/esm/index2.js +0 -5
  78. package/dist/esm/types/DynamicApiImport.d.js +0 -1
  79. package/dist/esm/types/DynamicImport.d.js +0 -1
  80. package/dist/esm/types/chayns-components.d.js +0 -0
  81. package/dist/esm/types/chayns-logger.d.js +0 -0
  82. package/dist/esm/types/chayns.d.js +0 -0
  83. package/dist/esm/types/tobit-websocket-service-client.d.js +0 -0
  84. package/dist/esm/types/toolkit-types.d.js +0 -0
  85. package/dist/esm/util/useIsAdminMode.js +0 -9
  86. package/dist/esm/util/useUser.js +0 -7
  87. package/dist/esm/wrapper/Dialog.js +0 -31
  88. package/dist/esm/wrapper/DialogHandler.js +0 -31
  89. package/dist/types/bootstrap.d.ts +0 -1
  90. package/dist/types/client.d.ts +0 -7
  91. package/dist/types/components/App.d.ts +0 -5
  92. package/dist/types/components/Button.d.ts +0 -8
  93. package/dist/types/components/ChaynsModuleProvider.d.ts +0 -170
  94. package/dist/types/components/ChaynsProviderExposed.d.ts +0 -13
  95. package/dist/types/components/Dialog.d.ts +0 -0
  96. package/dist/types/components/Title.d.ts +0 -3
  97. package/dist/types/hooks/useFunction.d.ts +0 -2
  98. package/dist/types/host/HostIframe.d.ts +0 -20
  99. package/dist/types/index.example.d.ts +0 -0
  100. package/dist/types/wrapper/Dialog.d.ts +0 -10
  101. package/dist/types/wrapper/DialogHandler.d.ts +0 -10
@@ -7,10 +7,13 @@ exports.default = void 0;
7
7
  class DialogHandler {
8
8
  isOpen = false;
9
9
  result = undefined;
10
- constructor(config, open, close) {
10
+ listeners = [];
11
+ constructor(config, open, close, dispatchEvent, addDataListener) {
11
12
  this._open = open;
12
13
  this._close = close;
13
14
  this._config = config;
15
+ this._dispatchEvent = dispatchEvent;
16
+ this._addDataListener = addDataListener;
14
17
  }
15
18
  async open() {
16
19
  if (this.isOpen) {
@@ -23,6 +26,11 @@ class DialogHandler {
23
26
  };
24
27
  this.isOpen = true;
25
28
  this.dialogId = await this._open(this._config, callback);
29
+ console.log('dialogId', this.dialogId);
30
+ this._addDataListener(this.dialogId, data => {
31
+ console.log('[DialogHandler]dataListener', this.dialogId, data);
32
+ this.listeners.forEach(cb => cb(data));
33
+ });
26
34
  });
27
35
  return this.result = res;
28
36
  }
@@ -33,6 +41,21 @@ class DialogHandler {
33
41
  this.isOpen = false;
34
42
  this._close(this.dialogId, data);
35
43
  }
44
+ dispatchEvent(data) {
45
+ if (!this.isOpen) {
46
+ return;
47
+ }
48
+ this._dispatchEvent(this.dialogId, data);
49
+ }
50
+ addDataListener(listener) {
51
+ this.listeners.push(listener);
52
+ }
53
+ removeDataListener(listener) {
54
+ const index = this.listeners.findIndex(l => l === listener);
55
+ if (index > -1) {
56
+ this.listeners.splice(index, 1);
57
+ }
58
+ }
36
59
  getResult() {
37
60
  return this.result;
38
61
  }
@@ -10,13 +10,17 @@ var _ChaynsContext = require("../components/ChaynsContext");
10
10
  * @category Hooks
11
11
  */
12
12
  const useDialogState = () => {
13
- const closeDialog = (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsFunctionsContext, v => v === null || v === void 0 ? void 0 : v.closeDialog);
13
+ const setResult = (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsFunctionsContext, v => v === null || v === void 0 ? void 0 : v.setDialogResult);
14
+ const sendData = (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsFunctionsContext, v => v === null || v === void 0 ? void 0 : v.dispatchEventToDialogHost);
15
+ const addDataListener = (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsFunctionsContext, v => v === null || v === void 0 ? void 0 : v.addDialogHostEventListener);
14
16
  const isClosingRequested = (0, _useContextSelector.useContextSelector)(_ChaynsContext.ChaynsContext, v => {
15
17
  var _v$dialog;
16
18
  return v === null || v === void 0 ? void 0 : (_v$dialog = v.dialog) === null || _v$dialog === void 0 ? void 0 : _v$dialog.isClosingRequested;
17
19
  });
18
20
  return {
19
- closeDialog,
21
+ setResult,
22
+ sendData,
23
+ addDataListener,
20
24
  isClosingRequested
21
25
  };
22
26
  };
@@ -236,8 +236,7 @@ class FrameWrapper {
236
236
  return this.exposedFunctions.scrollByY(value, duration);
237
237
  },
238
238
  createDialog: config => {
239
- const openDialog = (config, callback) => this.exposedFunctions.openDialog(config, comlink.proxy(callback));
240
- return new _DialogHandler.default(config, openDialog, this.exposedFunctions.closeDialog);
239
+ return new _DialogHandler.default(config, this.functions.openDialog, this.exposedFunctions.closeDialog, this.functions.dispatchEventToDialogClient, this.functions.addDialogClientEventListener);
241
240
  },
242
241
  closeDialog: async dialogId => {
243
242
  if (!this.initialized) await this.ready;
@@ -250,7 +249,42 @@ class FrameWrapper {
250
249
  setDialogResult: async result => {
251
250
  if (!this.initialized) await this.ready;
252
251
  return this.exposedFunctions.setDialogResult(result);
253
- }
252
+ },
253
+ dispatchEventToDialogClient: async (dialogId, data) => {
254
+ if (!this.initialized) await this.ready;
255
+ return this.exposedFunctions.dispatchEventToDialogClient(dialogId, data);
256
+ },
257
+ addDialogClientEventListener: async (dialogId, callback) => {
258
+ if (!this.initialized) await this.ready;
259
+ return this.exposedFunctions.addDialogClientEventListener(dialogId, comlink.proxy(callback));
260
+ },
261
+ dispatchEventToDialogHost: async data => {
262
+ if (!this.initialized) await this.ready;
263
+ return this.exposedFunctions.dispatchEventToDialogHost(data);
264
+ },
265
+ addDialogHostEventListener: async callback => {
266
+ if (!this.initialized) await this.ready;
267
+ const listenerKey = `dialogHostEventListener`;
268
+ const {
269
+ id,
270
+ shouldInitialize
271
+ } = (0, _apiListenerHelper.addApiListener)(listenerKey, callback);
272
+ if (shouldInitialize) {
273
+ this.exposedFunctions.addDialogHostEventListener(comlink.proxy(data => {
274
+ (0, _apiListenerHelper.dispatchApiEvent)(listenerKey, data);
275
+ }));
276
+ }
277
+ return id;
278
+ },
279
+ removeDialogHostEventListener: async id => {
280
+ if (!this.initialized) await this.ready;
281
+ const listenerKey = `dialogHostEventListener`;
282
+ const shouldRemove = (0, _apiListenerHelper.removeApiListener)(listenerKey, id);
283
+ if (shouldRemove) {
284
+ // this.exposedFunctions.removeDialogHostEventListener(0);
285
+ }
286
+ },
287
+ removeDialogClientEventListener: async () => {}
254
288
  };
255
289
  initialized = false;
256
290
  constructor() {
@@ -26,7 +26,7 @@ class ModuleFederationWrapper {
26
26
  this.functions[k] = async (...args) => fn(...args);
27
27
  });
28
28
  this.functions.createDialog = config => {
29
- return new _DialogHandler.default(config, functions.openDialog, functions.closeDialog);
29
+ return new _DialogHandler.default(config, functions.openDialog, functions.closeDialog, functions.dispatchEventToDialogClient, functions.addDialogClientEventListener);
30
30
  };
31
31
  this.functions.addWindowMetricsListener = async callback => {
32
32
  const {
@@ -2,12 +2,15 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
2
2
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
3
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); }
4
4
  export default class DialogHandler {
5
- constructor(config, open, close) {
5
+ constructor(config, open, close, dispatchEvent, addDataListener) {
6
6
  _defineProperty(this, "isOpen", false);
7
7
  _defineProperty(this, "result", undefined);
8
+ _defineProperty(this, "listeners", []);
8
9
  this._open = open;
9
10
  this._close = close;
10
11
  this._config = config;
12
+ this._dispatchEvent = dispatchEvent;
13
+ this._addDataListener = addDataListener;
11
14
  }
12
15
  async open() {
13
16
  if (this.isOpen) {
@@ -20,6 +23,11 @@ export default class DialogHandler {
20
23
  };
21
24
  this.isOpen = true;
22
25
  this.dialogId = await this._open(this._config, callback);
26
+ console.log('dialogId', this.dialogId);
27
+ this._addDataListener(this.dialogId, data => {
28
+ console.log('[DialogHandler]dataListener', this.dialogId, data);
29
+ this.listeners.forEach(cb => cb(data));
30
+ });
23
31
  });
24
32
  return this.result = res;
25
33
  }
@@ -30,6 +38,21 @@ export default class DialogHandler {
30
38
  this.isOpen = false;
31
39
  this._close(this.dialogId, data);
32
40
  }
41
+ dispatchEvent(data) {
42
+ if (!this.isOpen) {
43
+ return;
44
+ }
45
+ this._dispatchEvent(this.dialogId, data);
46
+ }
47
+ addDataListener(listener) {
48
+ this.listeners.push(listener);
49
+ }
50
+ removeDataListener(listener) {
51
+ const index = this.listeners.findIndex(l => l === listener);
52
+ if (index > -1) {
53
+ this.listeners.splice(index, 1);
54
+ }
55
+ }
33
56
  getResult() {
34
57
  return this.result;
35
58
  }
@@ -5,13 +5,17 @@ import { ChaynsContext, ChaynsFunctionsContext } from '../components/ChaynsConte
5
5
  * @category Hooks
6
6
  */
7
7
  export const useDialogState = () => {
8
- const closeDialog = useContextSelector(ChaynsFunctionsContext, v => v === null || v === void 0 ? void 0 : v.closeDialog);
8
+ const setResult = useContextSelector(ChaynsFunctionsContext, v => v === null || v === void 0 ? void 0 : v.setDialogResult);
9
+ const sendData = useContextSelector(ChaynsFunctionsContext, v => v === null || v === void 0 ? void 0 : v.dispatchEventToDialogHost);
10
+ const addDataListener = useContextSelector(ChaynsFunctionsContext, v => v === null || v === void 0 ? void 0 : v.addDialogHostEventListener);
9
11
  const isClosingRequested = useContextSelector(ChaynsContext, v => {
10
12
  var _v$dialog;
11
13
  return v === null || v === void 0 ? void 0 : (_v$dialog = v.dialog) === null || _v$dialog === void 0 ? void 0 : _v$dialog.isClosingRequested;
12
14
  });
13
15
  return {
14
- closeDialog,
16
+ setResult,
17
+ sendData,
18
+ addDataListener,
15
19
  isClosingRequested
16
20
  };
17
21
  };
@@ -230,8 +230,7 @@ export class FrameWrapper {
230
230
  return this.exposedFunctions.scrollByY(value, duration);
231
231
  },
232
232
  createDialog: config => {
233
- const openDialog = (config, callback) => this.exposedFunctions.openDialog(config, comlink.proxy(callback));
234
- return new DialogHandler(config, openDialog, this.exposedFunctions.closeDialog);
233
+ return new DialogHandler(config, this.functions.openDialog, this.exposedFunctions.closeDialog, this.functions.dispatchEventToDialogClient, this.functions.addDialogClientEventListener);
235
234
  },
236
235
  closeDialog: async dialogId => {
237
236
  if (!this.initialized) await this.ready;
@@ -244,7 +243,42 @@ export class FrameWrapper {
244
243
  setDialogResult: async result => {
245
244
  if (!this.initialized) await this.ready;
246
245
  return this.exposedFunctions.setDialogResult(result);
247
- }
246
+ },
247
+ dispatchEventToDialogClient: async (dialogId, data) => {
248
+ if (!this.initialized) await this.ready;
249
+ return this.exposedFunctions.dispatchEventToDialogClient(dialogId, data);
250
+ },
251
+ addDialogClientEventListener: async (dialogId, callback) => {
252
+ if (!this.initialized) await this.ready;
253
+ return this.exposedFunctions.addDialogClientEventListener(dialogId, comlink.proxy(callback));
254
+ },
255
+ dispatchEventToDialogHost: async data => {
256
+ if (!this.initialized) await this.ready;
257
+ return this.exposedFunctions.dispatchEventToDialogHost(data);
258
+ },
259
+ addDialogHostEventListener: async callback => {
260
+ if (!this.initialized) await this.ready;
261
+ const listenerKey = `dialogHostEventListener`;
262
+ const {
263
+ id,
264
+ shouldInitialize
265
+ } = addApiListener(listenerKey, callback);
266
+ if (shouldInitialize) {
267
+ this.exposedFunctions.addDialogHostEventListener(comlink.proxy(data => {
268
+ dispatchApiEvent(listenerKey, data);
269
+ }));
270
+ }
271
+ return id;
272
+ },
273
+ removeDialogHostEventListener: async id => {
274
+ if (!this.initialized) await this.ready;
275
+ const listenerKey = `dialogHostEventListener`;
276
+ const shouldRemove = removeApiListener(listenerKey, id);
277
+ if (shouldRemove) {
278
+ // this.exposedFunctions.removeDialogHostEventListener(0);
279
+ }
280
+ },
281
+ removeDialogClientEventListener: async () => {}
248
282
  });
249
283
  _defineProperty(this, "initialized", false);
250
284
  const initialDataTag = document.querySelector('#__CHAYNS_DATA__');
@@ -22,7 +22,7 @@ export class ModuleFederationWrapper {
22
22
  };
23
23
  });
24
24
  this.functions.createDialog = config => {
25
- return new DialogHandler(config, functions.openDialog, functions.closeDialog);
25
+ return new DialogHandler(config, functions.openDialog, functions.closeDialog, functions.dispatchEventToDialogClient, functions.addDialogClientEventListener);
26
26
  };
27
27
  this.functions.addWindowMetricsListener = async callback => {
28
28
  const {
@@ -1,8 +1,7 @@
1
1
  import { FC, ReactNode } from "react";
2
- type TaskList = (TaskList | Promise<unknown> | (() => Promise<unknown>))[];
2
+ export type TaskList = (TaskList | Promise<unknown> | (() => Promise<unknown>))[];
3
3
  export declare const WaitUntil: FC<{
4
4
  tasks: TaskList;
5
5
  children?: ReactNode;
6
6
  loadingComponent?: ReactNode;
7
7
  }>;
8
- export {};
@@ -5,8 +5,15 @@ export default class DialogHandler {
5
5
  private readonly _open;
6
6
  private readonly _close;
7
7
  private readonly _config;
8
- constructor(config: any, open: any, close: any);
8
+ private readonly _dispatchEvent;
9
+ private readonly _addDataListener;
10
+ private readonly _removeDataListener;
11
+ private readonly listeners;
12
+ constructor(config: any, open: any, close: any, dispatchEvent: any, addDataListener: any);
9
13
  open(): Promise<unknown>;
10
14
  close(buttonType: any, data: any): void;
15
+ dispatchEvent(data: object): void;
16
+ addDataListener(listener: (data: any) => void): void;
17
+ removeDataListener(listener: (data: any) => void): void;
11
18
  getResult(): any;
12
19
  }
@@ -2,7 +2,7 @@ import { DialogDataHookResult, DialogHookResult } from '../types/IChaynsReact';
2
2
  /**
3
3
  * @category Hooks
4
4
  */
5
- export declare const useDialogState: () => Pick<DialogHookResult, 'closeDialog' | 'isClosingRequested'>;
5
+ export declare const useDialogState: () => DialogHookResult;
6
6
  /**
7
7
  * @category Hooks
8
8
  */
@@ -99,9 +99,9 @@ export type ChaynsApiDevice = {
99
99
  };
100
100
  export type DialogHookResult = {
101
101
  isClosingRequested: boolean;
102
- buttonType: DialogButtonType;
103
- data: any;
104
- closeDialog: (buttonType: any, data: any) => Promise<void>;
102
+ setResult: ChaynsReactFunctions["setDialogResult"];
103
+ sendData: ChaynsReactFunctions["dispatchEventToDialogHost"];
104
+ addDataListener: ChaynsReactFunctions["addDialogHostEventListener"];
105
105
  };
106
106
  export type DialogDataHookResult = {
107
107
  inputData: {
@@ -203,6 +203,12 @@ export interface ChaynsReactFunctions {
203
203
  openDialog: (value: any, callback: (data: any) => any) => Promise<any>;
204
204
  closeDialog: (dialogId: number) => Promise<void>;
205
205
  setDialogResult: (result: any) => Promise<void>;
206
+ dispatchEventToDialogClient: (dialogId: number, data: object) => Promise<void>;
207
+ addDialogClientEventListener: (dialogId: number, callback: (data: object) => void) => Promise<number>;
208
+ removeDialogClientEventListener: (dialogId: number, id: number) => Promise<void>;
209
+ dispatchEventToDialogHost: (data: object) => Promise<void>;
210
+ addDialogHostEventListener: (callback: (data: object) => void) => Promise<number>;
211
+ removeDialogHostEventListener: (id: number) => Promise<void>;
206
212
  }
207
213
  export type DialogResult = {
208
214
  open: () => Promise<any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "1.1.0-0",
3
+ "version": "1.1.0-3",
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.4.1",
38
+ "comlink": "4.3.1",
39
39
  "detect-browser": "^5.2.1",
40
40
  "htmlescape": "^1.1.1",
41
41
  "lodash.throttle": "^4.1.1",
@@ -64,8 +64,8 @@
64
64
  "postcss-prefix-selector": "^1.13.0",
65
65
  "prettier": "^2.5.0",
66
66
  "prettier-plugin-packagejson": "^2.2.15",
67
- "react": "^18.2.0",
68
- "react-dom": "^18.2.0",
67
+ "react": "^17.0.2",
68
+ "react-dom": "^17.0.2",
69
69
  "typescript": "^4.9.5"
70
70
  },
71
71
  "peerDependencies": {
@@ -1,11 +0,0 @@
1
- "use strict";
2
-
3
- var _react = _interopRequireDefault(require("react"));
4
-
5
- var _reactDom = _interopRequireDefault(require("react-dom"));
6
-
7
- var _App = _interopRequireDefault(require("./components/App"));
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
11
- _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_App.default, null), document.querySelector('#root'));
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- 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; }
9
-
10
- class ApiEventListener {
11
- constructor() {
12
- _defineProperty(this, "counter", 0);
13
-
14
- _defineProperty(this, "listenerMapping", {});
15
-
16
- _defineProperty(this, "addEventListener", callback => {
17
- if (Object.keys(this.listenerMapping).length === 0) {
18
- this.initializeListener();
19
- }
20
-
21
- const id = ++this.counter;
22
- this.listenerMapping[id] = callback;
23
- return Promise.resolve(id);
24
- });
25
-
26
- _defineProperty(this, "removeEventListener", id => {
27
- delete this.listenerMapping[id];
28
-
29
- if (Object.keys(this.listenerMapping).length === 0) {
30
- this.cleanupListener();
31
- }
32
-
33
- return Promise.resolve();
34
- });
35
- }
36
-
37
- }
38
-
39
- var _default = ApiEventListener;
40
- exports.default = _default;
@@ -1,40 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- 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; }
9
-
10
- class ApiEventListener {
11
- constructor() {
12
- _defineProperty(this, "counter", 0);
13
-
14
- _defineProperty(this, "listenerMapping", {});
15
-
16
- _defineProperty(this, "addEventListener", callback => {
17
- if (Object.keys(this.listenerMapping).length === 0) {
18
- this.initializeListener();
19
- }
20
-
21
- const id = ++this.counter;
22
- this.listenerMapping[id] = callback;
23
- return Promise.resolve(id);
24
- });
25
-
26
- _defineProperty(this, "removeEventListener", id => {
27
- delete this.listenerMapping[id];
28
-
29
- if (Object.keys(this.listenerMapping).length === 0) {
30
- this.cleanupListener();
31
- }
32
-
33
- return Promise.resolve();
34
- });
35
- }
36
-
37
- }
38
-
39
- var _default = ApiEventListener;
40
- exports.default = _default;
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- var _apiEventListener = _interopRequireDefault(require("./apiEventListener"));
4
-
5
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
-
7
- class WindowMetricsListener extends _apiEventListener.default {
8
- constructor() {
9
- super();
10
- }
11
-
12
- handleEvent(event) {}
13
-
14
- initializeListener() {}
15
-
16
- cleanupListener() {}
17
-
18
- }
@@ -1,93 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- var _exportNames = {
7
- ChaynsProvider: true,
8
- ChaynsHost: true,
9
- getDeviceInfo: true,
10
- getScreenSize: true,
11
- dialog: true
12
- };
13
- Object.defineProperty(exports, "ChaynsHost", {
14
- enumerable: true,
15
- get: function () {
16
- return _ChaynsHost.default;
17
- }
18
- });
19
- Object.defineProperty(exports, "ChaynsProvider", {
20
- enumerable: true,
21
- get: function () {
22
- return _ChaynsModuleProvider.default;
23
- }
24
- });
25
- exports.dialog = void 0;
26
- Object.defineProperty(exports, "getDeviceInfo", {
27
- enumerable: true,
28
- get: function () {
29
- return _deviceHelper.default;
30
- }
31
- });
32
- Object.defineProperty(exports, "getScreenSize", {
33
- enumerable: true,
34
- get: function () {
35
- return _deviceHelper.getScreenSize;
36
- }
37
- });
38
-
39
- var _ChaynsModuleProvider = _interopRequireWildcard(require("./components/ChaynsModuleProvider"));
40
-
41
- Object.keys(_ChaynsModuleProvider).forEach(function (key) {
42
- if (key === "default" || key === "__esModule") return;
43
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
44
- if (key in exports && exports[key] === _ChaynsModuleProvider[key]) return;
45
- Object.defineProperty(exports, key, {
46
- enumerable: true,
47
- get: function () {
48
- return _ChaynsModuleProvider[key];
49
- }
50
- });
51
- });
52
-
53
- var _ChaynsHost = _interopRequireDefault(require("./host/ChaynsHost"));
54
-
55
- var _deviceHelper = _interopRequireWildcard(require("./util/deviceHelper"));
56
-
57
- var _withCompatMode = require("./components/withCompatMode");
58
-
59
- Object.keys(_withCompatMode).forEach(function (key) {
60
- if (key === "default" || key === "__esModule") return;
61
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
62
- if (key in exports && exports[key] === _withCompatMode[key]) return;
63
- Object.defineProperty(exports, key, {
64
- enumerable: true,
65
- get: function () {
66
- return _withCompatMode[key];
67
- }
68
- });
69
- });
70
-
71
- var _dialog = _interopRequireWildcard(require("./calls/dialogs/index"));
72
-
73
- exports.dialog = _dialog;
74
-
75
- var _IChaynsReact = require("./types/IChaynsReact");
76
-
77
- Object.keys(_IChaynsReact).forEach(function (key) {
78
- if (key === "default" || key === "__esModule") return;
79
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
80
- if (key in exports && exports[key] === _IChaynsReact[key]) return;
81
- Object.defineProperty(exports, key, {
82
- enumerable: true,
83
- get: function () {
84
- return _IChaynsReact[key];
85
- }
86
- });
87
- });
88
-
89
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
90
-
91
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
92
-
93
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _react = _interopRequireWildcard(require("react"));
9
-
10
- var _Title = _interopRequireDefault(require("./Title"));
11
-
12
- var _ChaynsProvider = _interopRequireDefault(require("./ChaynsProvider"));
13
-
14
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
-
18
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
-
20
- const propTypes = {};
21
-
22
- const App = () => {
23
- const [isVisible, setIsVisible] = (0, _react.useState)(true);
24
- return /*#__PURE__*/_react.default.createElement(_ChaynsProvider.default, null, /*#__PURE__*/_react.default.createElement("button", {
25
- type: "button",
26
- onClick: () => setIsVisible(s => !s)
27
- }, "Toggle"), isVisible && /*#__PURE__*/_react.default.createElement(_Title.default, null));
28
- };
29
-
30
- App.propTypes = propTypes;
31
- var _default = App;
32
- exports.default = _default;
@@ -1,16 +0,0 @@
1
- "use strict";
2
-
3
- var _react = _interopRequireDefault(require("react"));
4
-
5
- var _react2 = require("@testing-library/react");
6
-
7
- var _App = _interopRequireDefault(require("./App"));
8
-
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
-
11
- test('should have correct text', () => {
12
- const {
13
- getByRole
14
- } = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_App.default, null));
15
- expect(getByRole("heading")).toHaveTextContent("Hi! Welcome to your newly created chayns application!");
16
- });
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- var _react = _interopRequireWildcard(require("react"));
9
-
10
- var _ChaynsProvider = _interopRequireDefault(require("./ChaynsProvider"));
11
-
12
- var _Title = _interopRequireDefault(require("./Title"));
13
-
14
- var _withCompatMode = _interopRequireDefault(require("./withCompatMode"));
15
-
16
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
19
-
20
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
-
22
- const Button = props => {
23
- const [visible, setVisible] = (0, _react.useState)(true);
24
- return /*#__PURE__*/_react.default.createElement(_ChaynsProvider.default, props, /*#__PURE__*/_react.default.createElement("button", {
25
- type: "button",
26
- onClick: () => setVisible(s => !s)
27
- }, "Toggle"), visible && /*#__PURE__*/_react.default.createElement(_Title.default, null));
28
- };
29
-
30
- var _default = (0, _withCompatMode.default)(Button);
31
-
32
- exports.default = _default;