@frontegg/react-hooks 6.49.0-alpha.0 → 6.49.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/FronteggProvider/index.js +14 -13
- package/index.js +1 -1
- package/node/FronteggProvider/index.js +14 -13
- package/node/index.js +1 -1
- package/package.json +3 -3
|
@@ -9,7 +9,7 @@ import { Provider, FronteggStoreContext } from '../FronteggStoreContext';
|
|
|
9
9
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const defaultSetLoading = loading => {
|
|
13
13
|
const isSSR = typeof document === 'undefined' || typeof window === 'undefined';
|
|
14
14
|
|
|
15
15
|
if (!isSSR) {
|
|
@@ -73,7 +73,7 @@ const FronteggContent = ({
|
|
|
73
73
|
app,
|
|
74
74
|
setLoading
|
|
75
75
|
}) => {
|
|
76
|
-
var _app$options, _app$options2
|
|
76
|
+
var _app$options, _app$options2;
|
|
77
77
|
|
|
78
78
|
const {
|
|
79
79
|
isLoading
|
|
@@ -83,7 +83,8 @@ const FronteggContent = ({
|
|
|
83
83
|
isLoading
|
|
84
84
|
}));
|
|
85
85
|
const customLoginBox = !app || (app == null ? void 0 : (_app$options = app.options) == null ? void 0 : _app$options.customLoginBox) === true;
|
|
86
|
-
const
|
|
86
|
+
const isNextJS = (app == null ? void 0 : (_app$options2 = app.options) == null ? void 0 : _app$options2.framework) === 'nextjs';
|
|
87
|
+
const alwaysShowChildren = customLoginBox || isNextJS;
|
|
87
88
|
const loadingRef = useRef(undefined);
|
|
88
89
|
|
|
89
90
|
if (isLoading !== loadingRef.current) {
|
|
@@ -91,7 +92,7 @@ const FronteggContent = ({
|
|
|
91
92
|
setLoading(isLoading);
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
if (isLoading) {
|
|
95
|
+
if (isLoading && !isNextJS) {
|
|
95
96
|
return null;
|
|
96
97
|
}
|
|
97
98
|
|
|
@@ -108,40 +109,40 @@ const FronteggContent = ({
|
|
|
108
109
|
};
|
|
109
110
|
|
|
110
111
|
export const FronteggStoreProvider = props => {
|
|
111
|
-
var _app$options$contextO, _app$
|
|
112
|
+
var _app$options$contextO, _app$options3, _app$options$previewM, _app$options4, _app$options5, _app$options6;
|
|
112
113
|
|
|
113
114
|
const {
|
|
114
115
|
children,
|
|
115
116
|
app,
|
|
116
117
|
contextOptions,
|
|
117
|
-
setLoading
|
|
118
|
+
setLoading = defaultSetLoading
|
|
118
119
|
} = props; // TODO: make this optionals more readable
|
|
119
120
|
|
|
120
|
-
const context = (_app$options$contextO = app == null ? void 0 : (_app$
|
|
121
|
+
const context = (_app$options$contextO = app == null ? void 0 : (_app$options3 = app.options) == null ? void 0 : _app$options3.contextOptions) != null ? _app$options$contextO : contextOptions;
|
|
121
122
|
|
|
122
123
|
if (!context) {
|
|
123
124
|
throw Error("contextOptions must not be null or undefined");
|
|
124
125
|
}
|
|
125
126
|
|
|
126
|
-
const previewMode = (_app$options$previewM = app == null ? void 0 : (_app$
|
|
127
|
-
const authOptions = app != null && (_app$
|
|
127
|
+
const previewMode = (_app$options$previewM = app == null ? void 0 : (_app$options4 = app.options) == null ? void 0 : _app$options4.previewMode) != null ? _app$options$previewM : false;
|
|
128
|
+
const authOptions = app != null && (_app$options5 = app.options) != null && _app$options5.authOptions ? _extends({}, app.options.authOptions, {
|
|
128
129
|
hostedLoginBox: app.options.hostedLoginBox
|
|
129
130
|
}) : {
|
|
130
|
-
hostedLoginBox: app == null ? void 0 : (_app$
|
|
131
|
+
hostedLoginBox: app == null ? void 0 : (_app$options6 = app.options) == null ? void 0 : _app$options6.hostedLoginBox
|
|
131
132
|
};
|
|
132
133
|
ContextHolder.setContext(context);
|
|
133
134
|
const store = useMemo(() => {
|
|
134
|
-
var _app$
|
|
135
|
+
var _app$options7;
|
|
135
136
|
|
|
136
137
|
return createFronteggStore({
|
|
137
138
|
context
|
|
138
|
-
}, app, previewMode, authOptions, undefined, false, app == null ? void 0 : (_app$
|
|
139
|
+
}, app, previewMode, authOptions, undefined, false, app == null ? void 0 : (_app$options7 = app.options) == null ? void 0 : _app$options7.urlStrategy);
|
|
139
140
|
}, [app, previewMode]);
|
|
140
141
|
return /*#__PURE__*/_jsx(Provider, {
|
|
141
142
|
context: FronteggStoreContext,
|
|
142
143
|
store: store,
|
|
143
144
|
children: /*#__PURE__*/_jsx(FronteggContent, {
|
|
144
|
-
setLoading:
|
|
145
|
+
setLoading: setLoading,
|
|
145
146
|
app: app,
|
|
146
147
|
children: children
|
|
147
148
|
})
|
package/index.js
CHANGED
|
@@ -29,7 +29,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
29
29
|
|
|
30
30
|
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; }
|
|
31
31
|
|
|
32
|
-
const
|
|
32
|
+
const defaultSetLoading = loading => {
|
|
33
33
|
const isSSR = typeof document === 'undefined' || typeof window === 'undefined';
|
|
34
34
|
|
|
35
35
|
if (!isSSR) {
|
|
@@ -92,7 +92,7 @@ const FronteggContent = ({
|
|
|
92
92
|
app,
|
|
93
93
|
setLoading
|
|
94
94
|
}) => {
|
|
95
|
-
var _app$options, _app$options2
|
|
95
|
+
var _app$options, _app$options2;
|
|
96
96
|
|
|
97
97
|
const {
|
|
98
98
|
isLoading
|
|
@@ -102,7 +102,8 @@ const FronteggContent = ({
|
|
|
102
102
|
isLoading
|
|
103
103
|
}));
|
|
104
104
|
const customLoginBox = !app || (app == null ? void 0 : (_app$options = app.options) == null ? void 0 : _app$options.customLoginBox) === true;
|
|
105
|
-
const
|
|
105
|
+
const isNextJS = (app == null ? void 0 : (_app$options2 = app.options) == null ? void 0 : _app$options2.framework) === 'nextjs';
|
|
106
|
+
const alwaysShowChildren = customLoginBox || isNextJS;
|
|
106
107
|
const loadingRef = (0, _react.useRef)(undefined);
|
|
107
108
|
|
|
108
109
|
if (isLoading !== loadingRef.current) {
|
|
@@ -110,7 +111,7 @@ const FronteggContent = ({
|
|
|
110
111
|
setLoading(isLoading);
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
if (isLoading) {
|
|
114
|
+
if (isLoading && !isNextJS) {
|
|
114
115
|
return null;
|
|
115
116
|
}
|
|
116
117
|
|
|
@@ -127,42 +128,42 @@ const FronteggContent = ({
|
|
|
127
128
|
};
|
|
128
129
|
|
|
129
130
|
const FronteggStoreProvider = props => {
|
|
130
|
-
var _app$options$contextO, _app$
|
|
131
|
+
var _app$options$contextO, _app$options3, _app$options$previewM, _app$options4, _app$options5, _app$options6;
|
|
131
132
|
|
|
132
133
|
const {
|
|
133
134
|
children,
|
|
134
135
|
app,
|
|
135
136
|
contextOptions,
|
|
136
|
-
setLoading
|
|
137
|
+
setLoading = defaultSetLoading
|
|
137
138
|
} = props; // TODO: make this optionals more readable
|
|
138
139
|
|
|
139
|
-
const context = (_app$options$contextO = app == null ? void 0 : (_app$
|
|
140
|
+
const context = (_app$options$contextO = app == null ? void 0 : (_app$options3 = app.options) == null ? void 0 : _app$options3.contextOptions) != null ? _app$options$contextO : contextOptions;
|
|
140
141
|
|
|
141
142
|
if (!context) {
|
|
142
143
|
throw Error("contextOptions must not be null or undefined");
|
|
143
144
|
}
|
|
144
145
|
|
|
145
|
-
const previewMode = (_app$options$previewM = app == null ? void 0 : (_app$
|
|
146
|
-
const authOptions = app != null && (_app$
|
|
146
|
+
const previewMode = (_app$options$previewM = app == null ? void 0 : (_app$options4 = app.options) == null ? void 0 : _app$options4.previewMode) != null ? _app$options$previewM : false;
|
|
147
|
+
const authOptions = app != null && (_app$options5 = app.options) != null && _app$options5.authOptions ? (0, _extends2.default)({}, app.options.authOptions, {
|
|
147
148
|
hostedLoginBox: app.options.hostedLoginBox
|
|
148
149
|
}) : {
|
|
149
|
-
hostedLoginBox: app == null ? void 0 : (_app$
|
|
150
|
+
hostedLoginBox: app == null ? void 0 : (_app$options6 = app.options) == null ? void 0 : _app$options6.hostedLoginBox
|
|
150
151
|
};
|
|
151
152
|
|
|
152
153
|
_restApi.ContextHolder.setContext(context);
|
|
153
154
|
|
|
154
155
|
const store = (0, _react.useMemo)(() => {
|
|
155
|
-
var _app$
|
|
156
|
+
var _app$options7;
|
|
156
157
|
|
|
157
158
|
return (0, _reduxStore.createFronteggStore)({
|
|
158
159
|
context
|
|
159
|
-
}, app, previewMode, authOptions, undefined, false, app == null ? void 0 : (_app$
|
|
160
|
+
}, app, previewMode, authOptions, undefined, false, app == null ? void 0 : (_app$options7 = app.options) == null ? void 0 : _app$options7.urlStrategy);
|
|
160
161
|
}, [app, previewMode]);
|
|
161
162
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_FronteggStoreContext.Provider, {
|
|
162
163
|
context: _FronteggStoreContext.FronteggStoreContext,
|
|
163
164
|
store: store,
|
|
164
165
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(FronteggContent, {
|
|
165
|
-
setLoading:
|
|
166
|
+
setLoading: setLoading,
|
|
166
167
|
app: app,
|
|
167
168
|
children: children
|
|
168
169
|
})
|
package/node/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/react-hooks",
|
|
3
|
-
"version": "6.49.0
|
|
3
|
+
"version": "6.49.0",
|
|
4
4
|
"main": "./node/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Frontegg LTD",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@babel/runtime": "^7.18.6",
|
|
9
|
-
"@frontegg/redux-store": "6.49.0
|
|
10
|
-
"@frontegg/types": "6.49.0
|
|
9
|
+
"@frontegg/redux-store": "6.49.0",
|
|
10
|
+
"@frontegg/types": "6.49.0",
|
|
11
11
|
"@types/react": "*",
|
|
12
12
|
"react-redux": "^7.x"
|
|
13
13
|
},
|