zudoku 0.3.0-dev.74 → 0.3.0-dev.75
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/dist/lib/authentication/Callback.d.ts +1 -1
- package/dist/lib/authentication/Callback.js +0 -1
- package/dist/lib/authentication/Callback.js.map +1 -1
- package/dist/lib/components/DevPortal.js +16 -1
- package/dist/lib/components/DevPortal.js.map +1 -1
- package/dist/lib/core/DevPortalContext.js +3 -6
- package/dist/lib/core/DevPortalContext.js.map +1 -1
- package/lib/zudoku.auth-openid.js +32 -31
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/lib/zudoku.components.js +367 -361
- package/lib/zudoku.components.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/authentication/Callback.tsx +0 -2
- package/src/lib/components/DevPortal.tsx +17 -0
- package/src/lib/core/DevPortalContext.ts +2 -4
package/package.json
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
useContext,
|
|
9
9
|
useEffect,
|
|
10
10
|
useMemo,
|
|
11
|
+
useRef,
|
|
11
12
|
useState,
|
|
12
13
|
} from "react";
|
|
13
14
|
import { ErrorBoundary } from "react-error-boundary";
|
|
@@ -52,8 +53,10 @@ const DevPortalInner = ({
|
|
|
52
53
|
() => ({ ...MdxComponents, ...props.mdx?.components }),
|
|
53
54
|
[props.mdx?.components],
|
|
54
55
|
);
|
|
56
|
+
const [isInitialized, setIsInitialized] = useState(false);
|
|
55
57
|
const { stagger } = useContext(StaggeredRenderContext);
|
|
56
58
|
const [didNavigate, setDidNavigate] = useState(false);
|
|
59
|
+
const initRef = useRef<"idle" | "pending" | "done">("idle");
|
|
57
60
|
const staggeredValue = useMemo(
|
|
58
61
|
() => (didNavigate ? { stagger: true } : { stagger }),
|
|
59
62
|
[stagger, didNavigate],
|
|
@@ -69,11 +72,25 @@ const DevPortalInner = ({
|
|
|
69
72
|
|
|
70
73
|
const [devPortalContext] = useState(() => new DevPortalContext(props));
|
|
71
74
|
|
|
75
|
+
// TODO could be handled more elegantly
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
if (initRef.current === "pending") return;
|
|
78
|
+
initRef.current = "pending";
|
|
79
|
+
void devPortalContext.initialize().then(() => {
|
|
80
|
+
initRef.current = "done";
|
|
81
|
+
setIsInitialized(true);
|
|
82
|
+
});
|
|
83
|
+
}, [devPortalContext]);
|
|
84
|
+
|
|
72
85
|
const heads = props.plugins
|
|
73
86
|
?.filter(hasHead)
|
|
74
87
|
// eslint-disable-next-line react/no-array-index-key
|
|
75
88
|
.map((plugin, i) => <Fragment key={i}>{plugin.getHead?.()}</Fragment>);
|
|
76
89
|
|
|
90
|
+
if (!isInitialized) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
77
94
|
return (
|
|
78
95
|
<QueryClientProvider client={queryClient}>
|
|
79
96
|
<Helmet>{heads}</Helmet>
|
|
@@ -113,16 +113,14 @@ export class DevPortalContext {
|
|
|
113
113
|
this.authentication = config.authentication;
|
|
114
114
|
this.meta = config.metadata;
|
|
115
115
|
this.page = config.page;
|
|
116
|
-
|
|
117
|
-
void this.initialize();
|
|
118
116
|
}
|
|
119
117
|
|
|
120
118
|
initialize = async () => {
|
|
121
|
-
await Promise.all(
|
|
119
|
+
await Promise.all(
|
|
122
120
|
this.plugins
|
|
123
121
|
.filter(needsInitialization)
|
|
124
122
|
.map((plugin) => plugin.initialize?.(this)),
|
|
125
|
-
|
|
123
|
+
);
|
|
126
124
|
};
|
|
127
125
|
|
|
128
126
|
invalidateCache = async (key: DevPortalCacheKey[]) => {
|