@frontegg/js 6.10.1 → 6.12.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.
@@ -1,42 +1,48 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
1
2
  import _extends from "@babel/runtime/helpers/esm/extends";
3
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
5
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
2
6
  import { createFronteggStore } from '@frontegg/redux-store';
3
7
  import { Metadata } from '@frontegg/types';
4
8
  import { FronteggApp } from '../FronteggApp';
5
9
  import { waitThemeSetter } from '../utils';
6
- const defaultTheme = 'modern';
10
+ var defaultTheme = 'modern';
7
11
  export { defaultTheme };
8
- export const getThemeByName = name => {
12
+ export var getThemeByName = function getThemeByName(name) {
9
13
  var _name;
10
14
 
11
15
  // Load themes from window chunk to support cdn getThemeByName
12
- const themes = window['FronteggAdminPortal'].themes;
16
+ var themes = window['FronteggAdminPortal'].themes;
13
17
  return (_name = themes[name]) != null ? _name : themes[defaultTheme];
14
18
  };
15
- export class LoginBoxRenderer {
16
- constructor(name, themeOptions, store, appOptions) {
19
+ export var LoginBoxRenderer = /*#__PURE__*/function () {
20
+ function LoginBoxRenderer(name, themeOptions, store, appOptions) {
21
+ _classCallCheck(this, LoginBoxRenderer);
22
+
17
23
  this.app = void 0;
18
24
  this.options = void 0;
19
25
  this.store = void 0;
20
26
  this.themeSetter = void 0;
21
27
 
22
- this.setRoute = () => {};
28
+ this.setRoute = function () {};
23
29
 
24
30
  this.themeOptions = {};
25
- const contextOptions = {
31
+ var contextOptions = {
26
32
  baseUrl: 'preview'
27
33
  };
28
34
  this.store = store != null ? store : createFronteggStore({
29
35
  context: contextOptions
30
36
  }, this, true, undefined, undefined, true);
31
37
  this.options = _extends({
32
- themeOptions,
38
+ themeOptions: themeOptions,
33
39
  iframeRendering: true,
34
40
  metadata: {},
35
41
  previewMode: true,
36
42
  builderMode: true,
37
43
  store: this.store,
38
- contextOptions,
39
- onRedirectTo: () => {
44
+ contextOptions: contextOptions,
45
+ onRedirectTo: function onRedirectTo() {
40
46
  console.debug('path');
41
47
  }
42
48
  }, appOptions);
@@ -44,75 +50,110 @@ export class LoginBoxRenderer {
44
50
  Metadata.set({}, name);
45
51
  }
46
52
 
47
- async render(loginBoxContainer) {
48
- let loginBoxEl = loginBoxContainer.querySelector('#root');
53
+ _createClass(LoginBoxRenderer, [{
54
+ key: "render",
55
+ value: function () {
56
+ var _render = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(loginBoxContainer) {
57
+ var _this = this;
58
+
59
+ var loginBoxEl, setThemeSetter, setStaticRouteSetter, FronteggLoginBox;
60
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
61
+ while (1) {
62
+ switch (_context.prev = _context.next) {
63
+ case 0:
64
+ loginBoxEl = loginBoxContainer.querySelector('#root');
65
+
66
+ if (!loginBoxEl) {
67
+ loginBoxEl = loginBoxContainer.ownerDocument.createElement('div');
68
+ loginBoxEl.setAttribute('id', 'root');
69
+ loginBoxContainer.appendChild(loginBoxEl);
70
+ }
71
+
72
+ this.app.loginBoxContainer = loginBoxContainer;
73
+ this.app.loginBoxEl = loginBoxEl;
74
+
75
+ setThemeSetter = function setThemeSetter(themeSetter) {
76
+ _this.themeSetter = themeSetter;
77
+ };
78
+
79
+ setStaticRouteSetter = function setStaticRouteSetter(setStaticRoute) {
80
+ _this.setRoute = setStaticRoute;
81
+ };
82
+
83
+ _context.next = 8;
84
+ return this.app.loadScript('FronteggLoginBox');
85
+
86
+ case 8:
87
+ FronteggLoginBox = _context.sent;
88
+ this.app.loginBoxRenderer = FronteggLoginBox.renderPage(loginBoxEl, {
89
+ options: this.options,
90
+ injector: this.app,
91
+ setThemeSetter: setThemeSetter,
92
+ setStaticRouteSetter: setStaticRouteSetter,
93
+ staticRoute: '/account/login'
94
+ });
95
+ _context.next = 12;
96
+ return waitThemeSetter(this);
97
+
98
+ case 12:
99
+ case "end":
100
+ return _context.stop();
101
+ }
102
+ }
103
+ }, _callee, this);
104
+ }));
105
+
106
+ function render(_x) {
107
+ return _render.apply(this, arguments);
108
+ }
49
109
 
50
- if (!loginBoxEl) {
51
- loginBoxEl = loginBoxContainer.ownerDocument.createElement('div');
52
- loginBoxEl.setAttribute('id', 'root');
53
- loginBoxContainer.appendChild(loginBoxEl);
110
+ return render;
111
+ }()
112
+ }, {
113
+ key: "unmount",
114
+ value: function unmount() {
115
+ try {
116
+ var _this$app$loginBoxRen;
117
+
118
+ (_this$app$loginBoxRen = this.app.loginBoxRenderer) == null ? void 0 : _this$app$loginBoxRen.unmount();
119
+ } catch (e) {
120
+ console.error('Failed to unmount login box renderer', e);
121
+ }
54
122
  }
123
+ }, {
124
+ key: "setTheme",
125
+ value: function setTheme(themeOptions) {
126
+ var _this$themeSetter;
55
127
 
56
- this.app.loginBoxContainer = loginBoxContainer;
57
- this.app.loginBoxEl = loginBoxEl;
128
+ this.themeOptions = themeOptions;
58
129
 
59
- const setThemeSetter = themeSetter => {
60
- this.themeSetter = themeSetter;
61
- };
62
-
63
- const setStaticRouteSetter = setStaticRoute => {
64
- this.setRoute = setStaticRoute;
65
- };
66
-
67
- const FronteggLoginBox = await this.app.loadScript('FronteggLoginBox');
68
- this.app.loginBoxRenderer = FronteggLoginBox.renderPage(loginBoxEl, {
69
- options: this.options,
70
- injector: this.app,
71
- setThemeSetter,
72
- setStaticRouteSetter,
73
- staticRoute: '/account/login'
74
- });
75
- await waitThemeSetter(this);
76
- }
77
-
78
- unmount() {
79
- try {
80
- var _this$app$loginBoxRen;
130
+ if (!this.themeSetter) {
131
+ console.warn("this.themeSetter is not defined yet");
132
+ }
81
133
 
82
- (_this$app$loginBoxRen = this.app.loginBoxRenderer) == null ? void 0 : _this$app$loginBoxRen.unmount();
83
- } catch (e) {
84
- console.error('Failed to unmount login box renderer', e);
134
+ (_this$themeSetter = this.themeSetter) == null ? void 0 : _this$themeSetter.call(this, this.themeOptions);
85
135
  }
86
- }
136
+ }, {
137
+ key: "setStaticRoute",
138
+ value: function setStaticRoute(staticRoute) {
139
+ var _this$setRoute;
87
140
 
88
- setTheme(themeOptions) {
89
- var _this$themeSetter;
90
-
91
- this.themeOptions = themeOptions;
141
+ if (!this.setRoute) {
142
+ console.warn("this.setRoute is not defined yet");
143
+ }
92
144
 
93
- if (!this.themeSetter) {
94
- console.warn("this.themeSetter is not defined yet");
145
+ (_this$setRoute = this.setRoute) == null ? void 0 : _this$setRoute.call(this, staticRoute);
95
146
  }
96
-
97
- (_this$themeSetter = this.themeSetter) == null ? void 0 : _this$themeSetter.call(this, this.themeOptions);
98
- }
99
-
100
- setStaticRoute(staticRoute) {
101
- var _this$setRoute;
102
-
103
- if (!this.setRoute) {
104
- console.warn("this.setRoute is not defined yet");
147
+ }, {
148
+ key: "setStore",
149
+ value: function setStore(state) {
150
+ this.store.dispatch({
151
+ type: 'auth/setState',
152
+ payload: state
153
+ });
105
154
  }
155
+ }]);
106
156
 
107
- (_this$setRoute = this.setRoute) == null ? void 0 : _this$setRoute.call(this, staticRoute);
108
- }
109
-
110
- setStore(state) {
111
- this.store.dispatch({
112
- type: 'auth/setState',
113
- payload: state
114
- });
115
- }
116
-
117
- }
157
+ return LoginBoxRenderer;
158
+ }();
118
159
  export default LoginBoxRenderer;
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license Frontegg v6.10.1
1
+ /** @license Frontegg v6.12.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.
package/initialize.js CHANGED
@@ -1,114 +1,146 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
+ import _wrapNativeSuper from "@babel/runtime/helpers/esm/wrapNativeSuper";
7
+
8
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
+
10
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
+
1
12
  import { FronteggApp } from './FronteggApp';
2
13
  import { AppHolder } from './AppHolder';
3
14
  import { createElement } from './utils';
4
- export const initialize = (options, name = 'default') => {
5
- const createdApp = new FronteggApp(options, name);
15
+ export var initialize = function initialize(options) {
16
+ var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'default';
17
+ var createdApp = new FronteggApp(options, name);
6
18
 
7
19
  if (typeof document !== 'undefined') {
8
20
  var _document$querySelect;
9
21
 
10
22
  if (!options.contextOptions.baseUrl) {
11
- const error = new Error('Edit <FronteggProvider/> options { ContextOptions: { baseUrl: "" } } in order to connect your application');
12
- document.body.innerHTML = ``;
23
+ var error = new Error('Edit <FronteggProvider/> options { ContextOptions: { baseUrl: "" } } in order to connect your application');
24
+ document.body.innerHTML = "";
13
25
  alert(error.message);
14
26
  throw error;
15
27
  }
16
28
 
17
29
  if (!customElements.get('frontegg-app')) {
18
- class FronteggAppContainer extends HTMLElement {
19
- constructor(...args) {
20
- super(...args);
21
- this.app = null;
22
- }
30
+ var FronteggAppContainer = /*#__PURE__*/function (_HTMLElement) {
31
+ _inherits(FronteggAppContainer, _HTMLElement);
23
32
 
24
- static get observedAttributes() {
25
- return ['app-name'];
26
- }
33
+ var _super = _createSuper(FronteggAppContainer);
27
34
 
28
- connectedCallback() {
29
- this.updateContent();
30
- }
35
+ function FronteggAppContainer() {
36
+ var _this;
31
37
 
32
- attributeChangedCallback(name, oldValue, newValue) {
33
- if (name === 'app-name') {
34
- if (oldValue === null) {
35
- return;
36
- }
38
+ _classCallCheck(this, FronteggAppContainer);
37
39
 
38
- if (oldValue === newValue) {
39
- return;
40
- }
40
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
41
+ args[_key] = arguments[_key];
42
+ }
41
43
 
42
- this.innerHTML = '';
44
+ _this = _super.call.apply(_super, [this].concat(args));
45
+ _this.app = null;
46
+ return _this;
47
+ }
43
48
 
44
- if (newValue === null) {
45
- this.remove();
46
- } else {
47
- this.updateContent();
48
- }
49
+ _createClass(FronteggAppContainer, [{
50
+ key: "connectedCallback",
51
+ value: function connectedCallback() {
52
+ this.updateContent();
49
53
  }
54
+ }, {
55
+ key: "attributeChangedCallback",
56
+ value: function attributeChangedCallback(name, oldValue, newValue) {
57
+ if (name === 'app-name') {
58
+ if (oldValue === null) {
59
+ return;
60
+ }
61
+
62
+ if (oldValue === newValue) {
63
+ return;
64
+ }
65
+
66
+ this.innerHTML = '';
67
+
68
+ if (newValue === null) {
69
+ this.remove();
70
+ } else {
71
+ this.updateContent();
72
+ }
73
+ }
50
74
 
51
- console.debug('attributeChangedCallback', name, oldValue, newValue);
52
- }
75
+ console.debug('attributeChangedCallback', name, oldValue, newValue);
76
+ }
77
+ }, {
78
+ key: "updateContent",
79
+ value: function updateContent() {
80
+ var _this$getAttribute;
53
81
 
54
- updateContent() {
55
- var _this$getAttribute;
82
+ var appName = (_this$getAttribute = this.getAttribute('app-name')) != null ? _this$getAttribute : 'default';
83
+ var app = AppHolder.getInstance(appName);
56
84
 
57
- const appName = (_this$getAttribute = this.getAttribute('app-name')) != null ? _this$getAttribute : 'default';
58
- const app = AppHolder.getInstance(appName);
85
+ if (app === null) {
86
+ throw Error("FronteggApp not found for appName: '".concat(appName, "'"));
87
+ }
59
88
 
60
- if (app === null) {
61
- throw Error(`FronteggApp not found for appName: '${appName}'`);
89
+ this.setAttribute('id', "frontegg-app-".concat(app.name));
90
+ var adminPortalContainer = createElement(this, 'div', {
91
+ id: "frontegg-admin-portal-container-".concat(app.name)
92
+ });
93
+ var loginBoxContainer = createElement(this, 'div', {
94
+ id: "frontegg-login-box-container-".concat(app.name)
95
+ });
96
+ var checkoutDialogContainer = createElement(this, 'div', {
97
+ id: "frontegg-checkout-dialog-container-".concat(app.name)
98
+ });
99
+ var adminBoxShadowEl = adminPortalContainer.attachShadow({
100
+ mode: 'open'
101
+ });
102
+ var loginBoxShadowEl = loginBoxContainer.attachShadow({
103
+ mode: 'open'
104
+ });
105
+ var checkoutDialogShadowEl = checkoutDialogContainer.attachShadow({
106
+ mode: 'open'
107
+ });
108
+ var adminPortalEl = createElement(adminBoxShadowEl, 'div', {
109
+ id: "frontegg-admin-portal-".concat(app.name),
110
+ "class": 'frontegg-root-content'
111
+ });
112
+ var loginBoxEl = createElement(loginBoxShadowEl, 'div', {
113
+ id: "frontegg-login-box-".concat(app.name),
114
+ "class": 'frontegg-root-content'
115
+ });
116
+ var checkoutDialogEl = createElement(checkoutDialogShadowEl, 'div', {
117
+ id: "frontegg-checkout-dialog-".concat(app.name),
118
+ "class": 'frontegg-root-content'
119
+ });
120
+ app.initContainers({
121
+ adminPortalEl: adminPortalEl,
122
+ loginBoxEl: loginBoxEl,
123
+ adminPortalContainer: adminPortalContainer,
124
+ loginBoxContainer: loginBoxContainer,
125
+ checkoutDialogContainer: checkoutDialogContainer,
126
+ checkoutDialogEl: checkoutDialogEl
127
+ });
62
128
  }
129
+ }], [{
130
+ key: "observedAttributes",
131
+ get: function get() {
132
+ return ['app-name'];
133
+ }
134
+ }]);
63
135
 
64
- this.setAttribute('id', `frontegg-app-${app.name}`);
65
- const adminPortalContainer = createElement(this, 'div', {
66
- id: `frontegg-admin-portal-container-${app.name}`
67
- });
68
- const loginBoxContainer = createElement(this, 'div', {
69
- id: `frontegg-login-box-container-${app.name}`
70
- });
71
- const checkoutDialogContainer = createElement(this, 'div', {
72
- id: `frontegg-checkout-dialog-container-${app.name}`
73
- });
74
- const adminBoxShadowEl = adminPortalContainer.attachShadow({
75
- mode: 'open'
76
- });
77
- const loginBoxShadowEl = loginBoxContainer.attachShadow({
78
- mode: 'open'
79
- });
80
- const checkoutDialogShadowEl = checkoutDialogContainer.attachShadow({
81
- mode: 'open'
82
- });
83
- const adminPortalEl = createElement(adminBoxShadowEl, 'div', {
84
- id: `frontegg-admin-portal-${app.name}`,
85
- class: 'frontegg-root-content'
86
- });
87
- const loginBoxEl = createElement(loginBoxShadowEl, 'div', {
88
- id: `frontegg-login-box-${app.name}`,
89
- class: 'frontegg-root-content'
90
- });
91
- const checkoutDialogEl = createElement(checkoutDialogShadowEl, 'div', {
92
- id: `frontegg-checkout-dialog-${app.name}`,
93
- class: 'frontegg-root-content'
94
- });
95
- app.initContainers({
96
- adminPortalEl,
97
- loginBoxEl,
98
- adminPortalContainer,
99
- loginBoxContainer,
100
- checkoutDialogContainer,
101
- checkoutDialogEl
102
- });
103
- }
104
-
105
- }
136
+ return FronteggAppContainer;
137
+ }( /*#__PURE__*/_wrapNativeSuper(HTMLElement));
106
138
 
107
139
  customElements.define('frontegg-app', FronteggAppContainer);
108
140
  }
109
141
 
110
- (_document$querySelect = document.querySelector(`frontegg-app[app-name="${createdApp.name}"]`)) == null ? void 0 : _document$querySelect.remove();
111
- const element = document.createElement('frontegg-app');
142
+ (_document$querySelect = document.querySelector("frontegg-app[app-name=\"".concat(createdApp.name, "\"]"))) == null ? void 0 : _document$querySelect.remove();
143
+ var element = document.createElement('frontegg-app');
112
144
  element.setAttribute('app-name', createdApp.name);
113
145
  document.body.appendChild(element);
114
146
  }
@@ -1,21 +1,39 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.AdminPortal = void 0;
7
9
 
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+
12
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
+
8
14
  var _AppHolder = require("../AppHolder");
9
15
 
10
- class AdminPortal {
11
- static show(name = 'default') {
12
- _AppHolder.AppHolder.getInstance(name).showAdminPortal();
16
+ var AdminPortal = /*#__PURE__*/function () {
17
+ function AdminPortal() {
18
+ (0, _classCallCheck2["default"])(this, AdminPortal);
13
19
  }
14
20
 
15
- static hide(name = 'default') {
16
- _AppHolder.AppHolder.getInstance(name).hideAdminPortal();
17
- }
21
+ (0, _createClass2["default"])(AdminPortal, null, [{
22
+ key: "show",
23
+ value: function show() {
24
+ var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
25
+
26
+ _AppHolder.AppHolder.getInstance(name).showAdminPortal();
27
+ }
28
+ }, {
29
+ key: "hide",
30
+ value: function hide() {
31
+ var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'default';
18
32
 
19
- }
33
+ _AppHolder.AppHolder.getInstance(name).hideAdminPortal();
34
+ }
35
+ }]);
36
+ return AdminPortal;
37
+ }();
20
38
 
21
39
  exports.AdminPortal = AdminPortal;