@frontegg/js 6.2.3 → 6.3.0

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,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { createFronteggStore } from '@frontegg/redux-store';
3
3
  import { Metadata } from '@frontegg/types';
4
4
  import { FronteggApp } from '../FronteggApp';
5
+ import { waitThemeSetter } from '../utils';
5
6
  export class AdminPortalRenderer {
6
7
  constructor(name, themeOptions, store, appOptions) {
7
8
  this.app = void 0;
@@ -59,6 +60,7 @@ export class AdminPortalRenderer {
59
60
  setStaticRouteSetter
60
61
  });
61
62
  this.app.loading = false;
63
+ await waitThemeSetter(this);
62
64
  }
63
65
 
64
66
  setStaticRoute(staticRoute) {
@@ -81,6 +83,11 @@ export class AdminPortalRenderer {
81
83
  var _this$themeSetter;
82
84
 
83
85
  this.themeOptions = themeOptions;
86
+
87
+ if (!this.themeSetter) {
88
+ console.warn('this.themeSetter is not defined yet');
89
+ }
90
+
84
91
  (_this$themeSetter = this.themeSetter) == null ? void 0 : _this$themeSetter.call(this, this.themeOptions);
85
92
  }
86
93
 
@@ -2,6 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { createFronteggStore } from '@frontegg/redux-store';
3
3
  import { Metadata } from '@frontegg/types';
4
4
  import { FronteggApp } from '../FronteggApp';
5
+ import { waitThemeSetter } from '../utils';
5
6
  const defaultTheme = 'modern';
6
7
  export { defaultTheme };
7
8
  export const getThemeByName = name => {
@@ -63,14 +64,15 @@ export class LoginBoxRenderer {
63
64
  this.setRoute = setStaticRoute;
64
65
  };
65
66
 
66
- const FronteggAdminPortal = await this.app.loadScript('FronteggLoginBox');
67
- this.app.loginBoxRenderer = FronteggAdminPortal.renderPage(loginBoxEl, {
67
+ const FronteggLoginBox = await this.app.loadScript('FronteggLoginBox');
68
+ this.app.loginBoxRenderer = FronteggLoginBox.renderPage(loginBoxEl, {
68
69
  options: this.options,
69
70
  injector: this.app,
70
71
  setThemeSetter,
71
72
  setStaticRouteSetter,
72
73
  staticRoute: '/account/login'
73
74
  });
75
+ await waitThemeSetter(this);
74
76
  }
75
77
 
76
78
  unmount() {
@@ -87,12 +89,21 @@ export class LoginBoxRenderer {
87
89
  var _this$themeSetter;
88
90
 
89
91
  this.themeOptions = themeOptions;
92
+
93
+ if (!this.themeSetter) {
94
+ console.warn("this.themeSetter is not defined yet");
95
+ }
96
+
90
97
  (_this$themeSetter = this.themeSetter) == null ? void 0 : _this$themeSetter.call(this, this.themeOptions);
91
98
  }
92
99
 
93
100
  setStaticRoute(staticRoute) {
94
101
  var _this$setRoute;
95
102
 
103
+ if (!this.setRoute) {
104
+ console.warn("this.setRoute is not defined yet");
105
+ }
106
+
96
107
  (_this$setRoute = this.setRoute) == null ? void 0 : _this$setRoute.call(this, staticRoute);
97
108
  }
98
109
 
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.2.3
1
+ /** @license Frontegg v6.3.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -15,6 +15,8 @@ var _types = require("@frontegg/types");
15
15
 
16
16
  var _FronteggApp = require("../FronteggApp");
17
17
 
18
+ var _utils = require("../utils");
19
+
18
20
  class AdminPortalRenderer {
19
21
  constructor(name, themeOptions, store, appOptions) {
20
22
  this.app = void 0;
@@ -73,6 +75,7 @@ class AdminPortalRenderer {
73
75
  setStaticRouteSetter
74
76
  });
75
77
  this.app.loading = false;
78
+ await (0, _utils.waitThemeSetter)(this);
76
79
  }
77
80
 
78
81
  setStaticRoute(staticRoute) {
@@ -95,6 +98,11 @@ class AdminPortalRenderer {
95
98
  var _this$themeSetter;
96
99
 
97
100
  this.themeOptions = themeOptions;
101
+
102
+ if (!this.themeSetter) {
103
+ console.warn('this.themeSetter is not defined yet');
104
+ }
105
+
98
106
  (_this$themeSetter = this.themeSetter) == null ? void 0 : _this$themeSetter.call(this, this.themeOptions);
99
107
  }
100
108
 
@@ -15,6 +15,8 @@ var _types = require("@frontegg/types");
15
15
 
16
16
  var _FronteggApp = require("../FronteggApp");
17
17
 
18
+ var _utils = require("../utils");
19
+
18
20
  const defaultTheme = 'modern';
19
21
  exports.defaultTheme = defaultTheme;
20
22
 
@@ -81,14 +83,15 @@ class LoginBoxRenderer {
81
83
  this.setRoute = setStaticRoute;
82
84
  };
83
85
 
84
- const FronteggAdminPortal = await this.app.loadScript('FronteggLoginBox');
85
- this.app.loginBoxRenderer = FronteggAdminPortal.renderPage(loginBoxEl, {
86
+ const FronteggLoginBox = await this.app.loadScript('FronteggLoginBox');
87
+ this.app.loginBoxRenderer = FronteggLoginBox.renderPage(loginBoxEl, {
86
88
  options: this.options,
87
89
  injector: this.app,
88
90
  setThemeSetter,
89
91
  setStaticRouteSetter,
90
92
  staticRoute: '/account/login'
91
93
  });
94
+ await (0, _utils.waitThemeSetter)(this);
92
95
  }
93
96
 
94
97
  unmount() {
@@ -105,12 +108,21 @@ class LoginBoxRenderer {
105
108
  var _this$themeSetter;
106
109
 
107
110
  this.themeOptions = themeOptions;
111
+
112
+ if (!this.themeSetter) {
113
+ console.warn("this.themeSetter is not defined yet");
114
+ }
115
+
108
116
  (_this$themeSetter = this.themeSetter) == null ? void 0 : _this$themeSetter.call(this, this.themeOptions);
109
117
  }
110
118
 
111
119
  setStaticRoute(staticRoute) {
112
120
  var _this$setRoute;
113
121
 
122
+ if (!this.setRoute) {
123
+ console.warn("this.setRoute is not defined yet");
124
+ }
125
+
114
126
  (_this$setRoute = this.setRoute) == null ? void 0 : _this$setRoute.call(this, staticRoute);
115
127
  }
116
128
 
package/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.2.3
1
+ /** @license Frontegg v6.3.0
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.formatName = exports.createElement = void 0;
6
+ exports.waitThemeSetter = exports.formatName = exports.createElement = void 0;
7
7
 
8
8
  const formatName = name => name.replace(/\W+/g, ' ').split(/ |\B(?=[A-Z])/).map(word => word.toLowerCase()).join('');
9
9
 
@@ -16,4 +16,25 @@ const createElement = (container, type, attrs = {}) => {
16
16
  return el;
17
17
  };
18
18
 
19
- exports.createElement = createElement;
19
+ exports.createElement = createElement;
20
+
21
+ const waitThemeSetter = instance => new Promise((resolve, reject) => {
22
+ let timeout = 4000;
23
+ const interval = setInterval(() => {
24
+ if (instance.themeSetter != null) {
25
+ clearInterval(interval);
26
+ resolve();
27
+ return;
28
+ }
29
+
30
+ if (timeout < 0) {
31
+ reject('Failed to load Renderer with themeSetter');
32
+ clearInterval(interval);
33
+ return;
34
+ }
35
+
36
+ timeout -= 50;
37
+ }, 50);
38
+ });
39
+
40
+ exports.waitThemeSetter = waitThemeSetter;
package/node/version.js CHANGED
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _default = {
8
- "cdnVersion": "6.2.3"
8
+ "cdnVersion": "6.3.0"
9
9
  };
10
10
  exports.default = _default;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@frontegg/js",
3
- "version": "6.2.3",
3
+ "version": "6.3.0",
4
4
  "main": "./node/index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
7
7
  "@babel/runtime": "^7.17.2",
8
- "@frontegg/types": "6.2.3"
8
+ "@frontegg/types": "6.3.0"
9
9
  },
10
10
  "sideEffects": false,
11
11
  "private": false,
package/utils/index.d.ts CHANGED
@@ -1,4 +1,8 @@
1
+ import { FronteggThemeOptions } from '@frontegg/types';
1
2
  export declare const formatName: (name: string) => string;
2
3
  export declare const createElement: (container: HTMLElement | ShadowRoot, type: string, attrs?: {
3
4
  [x: string]: string;
4
5
  }) => HTMLElement;
6
+ export declare const waitThemeSetter: (instance: {
7
+ themeSetter: ((themeOptions: FronteggThemeOptions) => {}) | undefined;
8
+ }) => Promise<unknown>;
package/utils/index.js CHANGED
@@ -4,4 +4,22 @@ export const createElement = (container, type, attrs = {}) => {
4
4
  Object.keys(attrs).forEach(key => el.setAttribute(key, attrs[key]));
5
5
  container.appendChild(el);
6
6
  return el;
7
- };
7
+ };
8
+ export const waitThemeSetter = instance => new Promise((resolve, reject) => {
9
+ let timeout = 4000;
10
+ const interval = setInterval(() => {
11
+ if (instance.themeSetter != null) {
12
+ clearInterval(interval);
13
+ resolve();
14
+ return;
15
+ }
16
+
17
+ if (timeout < 0) {
18
+ reject('Failed to load Renderer with themeSetter');
19
+ clearInterval(interval);
20
+ return;
21
+ }
22
+
23
+ timeout -= 50;
24
+ }, 50);
25
+ });
package/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export default {
2
- "cdnVersion": "6.2.3"
2
+ "cdnVersion": "6.3.0"
3
3
  };