@frontegg/js 6.2.5 → 6.5.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.
- package/AdminPortalRenderer/index.js +7 -0
- package/FronteggApp/FronteggApp.d.ts +3 -0
- package/FronteggApp/FronteggApp.js +10 -1
- package/LoginBoxRenderer/index.js +13 -2
- package/index.js +1 -1
- package/node/AdminPortalRenderer/index.js +8 -0
- package/node/FronteggApp/FronteggApp.js +10 -1
- package/node/LoginBoxRenderer/index.js +14 -2
- package/node/index.js +1 -1
- package/node/utils/index.js +23 -2
- package/node/version.js +1 -1
- package/package.json +3 -3
- package/utils/index.d.ts +4 -0
- package/utils/index.js +19 -1
- package/version.js +1 -1
|
@@ -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
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { EnhancedStore } from '@frontegg/redux-store';
|
|
2
2
|
import { FronteggAppOptions, FronteggCheckoutDialogOptions, LocalizationsOverrides } from '@frontegg/types';
|
|
3
|
+
import * as FronteggRestApi from '@frontegg/rest-api';
|
|
3
4
|
declare type FronteggAppContainers = {
|
|
4
5
|
adminPortalEl: HTMLElement;
|
|
5
6
|
loginBoxEl: HTMLElement;
|
|
@@ -25,11 +26,13 @@ export declare class FronteggApp {
|
|
|
25
26
|
checkoutDialogContainer?: HTMLElement;
|
|
26
27
|
loginBoxRenderer?: any;
|
|
27
28
|
store: EnhancedStore;
|
|
29
|
+
flags: FronteggRestApi.IFeatureFlagsAttributes;
|
|
28
30
|
loadingListeners: (() => void)[];
|
|
29
31
|
updateLocalizations?: (localizations: LocalizationsOverrides) => void;
|
|
30
32
|
constructor(_options: FronteggAppOptions, name: string, iframeRendering?: boolean);
|
|
31
33
|
loadAdminBoxMetadata: () => Promise<void>;
|
|
32
34
|
requestAuthorize: () => Promise<void>;
|
|
35
|
+
loadFeatureFlags: () => Promise<void>;
|
|
33
36
|
initContainers(elements: FronteggAppContainers): Promise<void>;
|
|
34
37
|
updateLocalizationsSetter: (localizationUpdateFn: (localizations: LocalizationsOverrides) => void) => void;
|
|
35
38
|
updateMetadata(metadata: FronteggAppOptions['metadata']): void;
|
|
@@ -27,6 +27,7 @@ export class FronteggApp {
|
|
|
27
27
|
this.checkoutDialogContainer = void 0;
|
|
28
28
|
this.loginBoxRenderer = void 0;
|
|
29
29
|
this.store = void 0;
|
|
30
|
+
this.flags = {};
|
|
30
31
|
this.loadingListeners = [];
|
|
31
32
|
this.updateLocalizations = void 0;
|
|
32
33
|
|
|
@@ -60,6 +61,14 @@ export class FronteggApp {
|
|
|
60
61
|
}
|
|
61
62
|
};
|
|
62
63
|
|
|
64
|
+
this.loadFeatureFlags = async () => {
|
|
65
|
+
try {
|
|
66
|
+
this.flags = await FronteggRestApi.loadFeatureFlags();
|
|
67
|
+
} catch (e) {
|
|
68
|
+
console.error('failed to get admin portal feature flags', e);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
|
|
63
72
|
this.updateLocalizationsSetter = localizationUpdateFn => {
|
|
64
73
|
this.updateLocalizations = localizationUpdateFn;
|
|
65
74
|
};
|
|
@@ -105,7 +114,7 @@ export class FronteggApp {
|
|
|
105
114
|
document.body.classList.add('frontegg-loading');
|
|
106
115
|
} catch (e) {}
|
|
107
116
|
|
|
108
|
-
await Promise.all([this.loadAdminBoxMetadata(), this.requestAuthorize()]);
|
|
117
|
+
await Promise.all([this.loadAdminBoxMetadata(), this.requestAuthorize(), this.loadFeatureFlags()]);
|
|
109
118
|
|
|
110
119
|
if (!this.options.previewMode && !this.options.customLoginBox) {
|
|
111
120
|
this.loadLoginBox();
|
|
@@ -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
|
|
67
|
-
this.app.loginBoxRenderer =
|
|
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
|
@@ -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
|
|
|
@@ -45,6 +45,7 @@ class FronteggApp {
|
|
|
45
45
|
this.checkoutDialogContainer = void 0;
|
|
46
46
|
this.loginBoxRenderer = void 0;
|
|
47
47
|
this.store = void 0;
|
|
48
|
+
this.flags = {};
|
|
48
49
|
this.loadingListeners = [];
|
|
49
50
|
this.updateLocalizations = void 0;
|
|
50
51
|
|
|
@@ -78,6 +79,14 @@ class FronteggApp {
|
|
|
78
79
|
}
|
|
79
80
|
};
|
|
80
81
|
|
|
82
|
+
this.loadFeatureFlags = async () => {
|
|
83
|
+
try {
|
|
84
|
+
this.flags = await FronteggRestApi.loadFeatureFlags();
|
|
85
|
+
} catch (e) {
|
|
86
|
+
console.error('failed to get admin portal feature flags', e);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
81
90
|
this.updateLocalizationsSetter = localizationUpdateFn => {
|
|
82
91
|
this.updateLocalizations = localizationUpdateFn;
|
|
83
92
|
};
|
|
@@ -124,7 +133,7 @@ class FronteggApp {
|
|
|
124
133
|
document.body.classList.add('frontegg-loading');
|
|
125
134
|
} catch (e) {}
|
|
126
135
|
|
|
127
|
-
await Promise.all([this.loadAdminBoxMetadata(), this.requestAuthorize()]);
|
|
136
|
+
await Promise.all([this.loadAdminBoxMetadata(), this.requestAuthorize(), this.loadFeatureFlags()]);
|
|
128
137
|
|
|
129
138
|
if (!this.options.previewMode && !this.options.customLoginBox) {
|
|
130
139
|
this.loadLoginBox();
|
|
@@ -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
|
|
85
|
-
this.app.loginBoxRenderer =
|
|
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
package/node/utils/index.js
CHANGED
|
@@ -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(true);
|
|
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
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/js",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.5.0",
|
|
4
4
|
"main": "./node/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@babel/runtime": "^7.
|
|
8
|
-
"@frontegg/types": "6.
|
|
7
|
+
"@babel/runtime": "^7.18.6",
|
|
8
|
+
"@frontegg/types": "6.5.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(true);
|
|
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