chayns-api 1.0.20 → 1.0.22

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.
@@ -28,7 +28,7 @@ const System = ({
28
28
  if (!system || !ready || failed) {
29
29
  return null;
30
30
  }
31
- return /*#__PURE__*/_react.default.lazy((0, _loadComponent.default)(system.scope, system.module, system.url));
31
+ return /*#__PURE__*/_react.default.lazy((0, _loadComponent.default)(system.scope, system.module, system.url, undefined, system.preventSingleton));
32
32
 
33
33
  /* eslint-disable react-hooks/exhaustive-deps */
34
34
  }, [system === null || system === void 0 ? void 0 : system.scope, ready, system === null || system === void 0 ? void 0 : system.url]);
@@ -80,7 +80,8 @@ const ModuleHost = ({
80
80
  system: {
81
81
  scope: system.scope,
82
82
  url: (0, _url.replaceStagingUrl)(preventStagingReplacement, system.url, environment.buildEnvironment),
83
- module: system.module
83
+ module: system.module,
84
+ preventSingleton: system.preventSingleton
84
85
  },
85
86
  data: initialData,
86
87
  functions: functions,
@@ -12,7 +12,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
12
12
  // @ts-nocheck
13
13
 
14
14
  let instances = {};
15
- function loadComponent(scope, module, url, skipCompatMode = false) {
15
+ function loadComponent(scope, module, url, skipCompatMode = false, preventSingleton = false) {
16
16
  return async () => {
17
17
  // Initializes the shared scope. Fills it with known provided modules from this build and all remotes
18
18
  // eslint-disable-next-line no-undef
@@ -42,6 +42,10 @@ function loadComponent(scope, module, url, skipCompatMode = false) {
42
42
  Module = factory();
43
43
  ModuleMap[`${Module.default.buildEnv}__${Module.default.appVersion}`] = Module;
44
44
  }
45
+ if (preventSingleton) {
46
+ // Intercom :)
47
+ window[scope + "_list"] = null;
48
+ }
45
49
  if (skipCompatMode) return Module;
46
50
  const hostVersion = _semver.default.minVersion(_react.default.version);
47
51
  const {
@@ -23,12 +23,14 @@ class AppWrapper {
23
23
  values = null;
24
24
  accessToken = '';
25
25
  mapOldApiToNew(retVal) {
26
- var _window, _window2, _AppInfo$TappSelected;
26
+ var _window, _urlParamsLowerCase$g, _window2, _AppInfo$TappSelected;
27
27
  const {
28
28
  AppInfo,
29
29
  AppUser
30
30
  } = retVal;
31
31
  this.accessToken = AppUser.TobitAccessToken;
32
+ const urlParams = new URLSearchParams(location.search);
33
+ const urlParamsLowerCase = new URLSearchParams(location.search.toLowerCase());
32
34
  return {
33
35
  device: (0, _deviceHelper.default)(navigator.userAgent, 'image/webp'),
34
36
  environment: {
@@ -56,7 +58,7 @@ class AppWrapper {
56
58
  docked: false
57
59
  },
58
60
  title: AppInfo.Title,
59
- colorMode: AppInfo.colorMode,
61
+ colorMode: (_urlParamsLowerCase$g = urlParamsLowerCase.get('colormode')) !== null && _urlParamsLowerCase$g !== void 0 ? _urlParamsLowerCase$g : AppInfo.colorMode,
60
62
  color: AppInfo.color,
61
63
  domain: AppInfo.domain,
62
64
  font: {
@@ -68,7 +70,7 @@ class AppWrapper {
68
70
  locationPersonId: AppInfo.LocationPersonId,
69
71
  urlHash: (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.location.hash.replace('#', '')
70
72
  },
71
- parameters: Object.fromEntries(new URLSearchParams(location.search)),
73
+ parameters: Object.fromEntries(urlParams),
72
74
  user: {
73
75
  firstName: AppUser.FirstName,
74
76
  lastName: AppUser.LastName,
@@ -20,7 +20,7 @@ const System = _ref => {
20
20
  if (!system || !ready || failed) {
21
21
  return null;
22
22
  }
23
- return /*#__PURE__*/React.lazy(loadComponent(system.scope, system.module, system.url));
23
+ return /*#__PURE__*/React.lazy(loadComponent(system.scope, system.module, system.url, undefined, system.preventSingleton));
24
24
 
25
25
  /* eslint-disable react-hooks/exhaustive-deps */
26
26
  }, [system === null || system === void 0 ? void 0 : system.scope, ready, system === null || system === void 0 ? void 0 : system.url]);
@@ -73,7 +73,8 @@ const ModuleHost = _ref2 => {
73
73
  system: {
74
74
  scope: system.scope,
75
75
  url: replaceStagingUrl(preventStagingReplacement, system.url, environment.buildEnvironment),
76
- module: system.module
76
+ module: system.module,
77
+ preventSingleton: system.preventSingleton
77
78
  },
78
79
  data: initialData,
79
80
  functions: functions,
@@ -7,6 +7,7 @@ import { semaphore } from './useDynamicScript';
7
7
  let instances = {};
8
8
  export default function loadComponent(scope, module, url) {
9
9
  let skipCompatMode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
10
+ let preventSingleton = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
10
11
  return async () => {
11
12
  // Initializes the shared scope. Fills it with known provided modules from this build and all remotes
12
13
  // eslint-disable-next-line no-undef
@@ -36,6 +37,10 @@ export default function loadComponent(scope, module, url) {
36
37
  Module = factory();
37
38
  ModuleMap[`${Module.default.buildEnv}__${Module.default.appVersion}`] = Module;
38
39
  }
40
+ if (preventSingleton) {
41
+ // Intercom :)
42
+ window[scope + "_list"] = null;
43
+ }
39
44
  if (skipCompatMode) return Module;
40
45
  const hostVersion = semver.minVersion(React.version);
41
46
  const {
@@ -15,12 +15,14 @@ import { addApiListener, dispatchApiEvent, removeApiListener } from '../helper/a
15
15
  let appWrapperDialogId = 0;
16
16
  export class AppWrapper {
17
17
  mapOldApiToNew(retVal) {
18
- var _window, _window2, _AppInfo$TappSelected;
18
+ var _window, _urlParamsLowerCase$g, _window2, _AppInfo$TappSelected;
19
19
  const {
20
20
  AppInfo,
21
21
  AppUser
22
22
  } = retVal;
23
23
  this.accessToken = AppUser.TobitAccessToken;
24
+ const urlParams = new URLSearchParams(location.search);
25
+ const urlParamsLowerCase = new URLSearchParams(location.search.toLowerCase());
24
26
  return {
25
27
  device: getDeviceInfo(navigator.userAgent, 'image/webp'),
26
28
  environment: {
@@ -48,7 +50,7 @@ export class AppWrapper {
48
50
  docked: false
49
51
  },
50
52
  title: AppInfo.Title,
51
- colorMode: AppInfo.colorMode,
53
+ colorMode: (_urlParamsLowerCase$g = urlParamsLowerCase.get('colormode')) !== null && _urlParamsLowerCase$g !== void 0 ? _urlParamsLowerCase$g : AppInfo.colorMode,
52
54
  color: AppInfo.color,
53
55
  domain: AppInfo.domain,
54
56
  font: {
@@ -60,7 +62,7 @@ export class AppWrapper {
60
62
  locationPersonId: AppInfo.LocationPersonId,
61
63
  urlHash: (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.location.hash.replace('#', '')
62
64
  },
63
- parameters: Object.fromEntries(new URLSearchParams(location.search)),
65
+ parameters: Object.fromEntries(urlParams),
64
66
  user: {
65
67
  firstName: AppUser.FirstName,
66
68
  lastName: AppUser.LastName,
@@ -209,8 +209,8 @@ export declare const getLanguage: () => {
209
209
  active: import("../types/IChaynsReact").Language;
210
210
  };
211
211
  export declare const getParameters: () => {
212
- [key: string]: string;
213
- [key: symbol]: string;
212
+ [key: string]: string | string[];
213
+ [key: symbol]: string | string[];
214
214
  };
215
215
  export declare const getPages: () => import("../types/IChaynsReact").Page[];
216
216
  export declare const getEnvironment: () => {
@@ -227,8 +227,8 @@ export declare const language: {
227
227
  active: import("../types/IChaynsReact").Language;
228
228
  };
229
229
  export declare const parameters: {
230
- [key: string]: string;
231
- [key: symbol]: string;
230
+ [key: string]: string | string[];
231
+ [key: symbol]: string | string[];
232
232
  };
233
233
  export declare const pages: import("../types/IChaynsReact").Page[];
234
234
  export declare const environment: {
@@ -4,6 +4,7 @@ export type TypeSystem = {
4
4
  scope: string;
5
5
  url: string;
6
6
  module: string;
7
+ preventSingleton?: boolean;
7
8
  };
8
9
  type ModulePropTypes = {
9
10
  system: TypeSystem;
@@ -1 +1 @@
1
- export default function loadComponent(scope: any, module: any, url: any, skipCompatMode?: boolean): () => Promise<any>;
1
+ export default function loadComponent(scope: any, module: any, url: any, skipCompatMode?: boolean, preventSingleton?: boolean): () => Promise<any>;
@@ -131,7 +131,7 @@ export interface ChaynsReactValues {
131
131
  * keys are in lower case
132
132
  */
133
133
  parameters: {
134
- [key: string | symbol]: string;
134
+ [key: string | symbol]: string | string[];
135
135
  };
136
136
  environment: {
137
137
  buildEnvironment: Environment;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chayns-api",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "new chayns api",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",