xmlui 0.9.71 → 0.9.72
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/{apiInterceptorWorker-C09ZXC2d.mjs → apiInterceptorWorker-B9Uw4ogq.mjs} +1 -1
- package/dist/lib/{index-CkBslrCL.mjs → index-DHZSwtDq.mjs} +9673 -9747
- package/dist/lib/index.css +1 -1
- package/dist/lib/xmlui.d.ts +4 -9
- package/dist/lib/xmlui.mjs +1 -1
- package/dist/metadata/{apiInterceptorWorker-NVGmSE8_.mjs → apiInterceptorWorker-DwXA1Dk9.mjs} +1 -1
- package/dist/metadata/{collectedComponentMetadata-BcVpKIic.mjs → collectedComponentMetadata-B6Gwz_zi.mjs} +8921 -8994
- package/dist/metadata/style.css +1 -1
- package/dist/metadata/xmlui-metadata.mjs +1 -1
- package/dist/metadata/xmlui-metadata.umd.js +87 -87
- package/dist/scripts/package.json +1 -1
- package/dist/scripts/src/components/Checkbox/Checkbox.js +3 -8
- package/dist/scripts/src/components/CodeBlock/CodeBlockNative.js +4 -2
- package/dist/scripts/src/components/List/ListNative.js +1 -1
- package/dist/scripts/src/components/Markdown/MarkdownNative.js +2 -2
- package/dist/scripts/src/components/NestedApp/AppWithCodeViewNative.js +13 -15
- package/dist/scripts/src/components/NestedApp/NestedApp.js +5 -15
- package/dist/scripts/src/components/NestedApp/NestedAppNative.js +56 -87
- package/dist/scripts/src/components/NestedApp/utils.js +7 -0
- package/dist/scripts/src/components/Switch/Switch.js +2 -2
- package/dist/scripts/src/components/TableOfContents/TableOfContents.js +8 -2
- package/dist/scripts/src/components/TableOfContents/TableOfContentsNative.js +4 -3
- package/dist/scripts/src/components/Toggle/Toggle.js +8 -11
- package/dist/scripts/src/components-core/interception/ApiInterceptorProvider.js +48 -26
- package/dist/standalone/xmlui-standalone.es.d.ts +4 -9
- package/dist/standalone/xmlui-standalone.umd.js +234 -234
- package/package.json +1 -1
|
@@ -48,50 +48,71 @@ const react_1 = require("react");
|
|
|
48
48
|
const misc_1 = require("../utils/misc");
|
|
49
49
|
const useApiInterceptorContext_1 = require("./useApiInterceptorContext");
|
|
50
50
|
// This React component injects the API interceptor into the application's context
|
|
51
|
-
function ApiInterceptorProvider({ interceptor, children,
|
|
52
|
-
const
|
|
51
|
+
function ApiInterceptorProvider({ interceptor, children, useHashBasedRouting, parentInterceptorContext = null, waitForApiInterceptor = false, }) {
|
|
52
|
+
const hasParentInterceptorContext = parentInterceptorContext !== null;
|
|
53
53
|
const [initialized, setInitialized] = (0, react_1.useState)(!interceptor);
|
|
54
|
+
const [forceInitialize, setForceInitialize] = (0, react_1.useState)(false);
|
|
54
55
|
const [interceptorWorker, setInterceptorWorker] = (0, react_1.useState)(null);
|
|
55
56
|
// --- Whenever the interceptor changes, update the provider accordingly
|
|
56
57
|
(0, react_1.useEffect)(() => {
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (!apiWorker) {
|
|
58
|
+
if (!hasParentInterceptorContext) {
|
|
59
|
+
if (interceptor || forceInitialize) {
|
|
60
|
+
// setInitialized(false);
|
|
61
|
+
// --- We use "msw" to manage the API interception
|
|
62
|
+
let interceptorWorker;
|
|
63
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
// --- Create the worker on the fly
|
|
65
|
+
if (process.env.VITE_MOCK_ENABLED) {
|
|
66
|
+
const { createApiInterceptorWorker } = yield Promise.resolve().then(() => __importStar(require("./apiInterceptorWorker")));
|
|
67
|
+
if (interceptor || forceInitialize) {
|
|
68
|
+
interceptorWorker = yield createApiInterceptorWorker(interceptor || {}, null);
|
|
69
|
+
// if the apiWorker comes from the outside, we don't handle the lifecycle here
|
|
70
70
|
const workerFileLocation = (0, misc_1.normalizePath)(process.env.VITE_MOCK_WORKER_LOCATION || "mockServiceWorker.js");
|
|
71
71
|
yield interceptorWorker.start({
|
|
72
72
|
onUnhandledRequest: "bypass",
|
|
73
73
|
quiet: true,
|
|
74
74
|
serviceWorker: {
|
|
75
|
-
url: workerFileLocation
|
|
76
|
-
}
|
|
75
|
+
url: workerFileLocation
|
|
76
|
+
}
|
|
77
77
|
});
|
|
78
|
+
setInterceptorWorker(interceptorWorker);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
+
setInitialized(true);
|
|
82
|
+
}))();
|
|
83
|
+
return () => {
|
|
84
|
+
// if the apiWorker comes from the outside, we don't handle the lifecycle here
|
|
85
|
+
if (!(parentInterceptorContext === null || parentInterceptorContext === void 0 ? void 0 : parentInterceptorContext.interceptorWorker)) {
|
|
86
|
+
interceptorWorker === null || interceptorWorker === void 0 ? void 0 : interceptorWorker.stop();
|
|
87
|
+
}
|
|
88
|
+
setInitialized(false);
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
81
92
|
setInitialized(true);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
if (interceptor) {
|
|
97
|
+
if (parentInterceptorContext === null || parentInterceptorContext === void 0 ? void 0 : parentInterceptorContext.interceptorWorker) {
|
|
98
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
const { createApiInterceptorWorker } = yield Promise.resolve().then(() => __importStar(require("./apiInterceptorWorker")));
|
|
100
|
+
yield createApiInterceptorWorker(interceptor, parentInterceptorContext === null || parentInterceptorContext === void 0 ? void 0 : parentInterceptorContext.interceptorWorker);
|
|
101
|
+
setTimeout(() => {
|
|
102
|
+
setInitialized(true);
|
|
103
|
+
}, 0);
|
|
104
|
+
}))();
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
parentInterceptorContext === null || parentInterceptorContext === void 0 ? void 0 : parentInterceptorContext.forceInitialize();
|
|
87
108
|
}
|
|
88
|
-
}
|
|
109
|
+
}
|
|
89
110
|
}
|
|
90
|
-
}, [
|
|
111
|
+
}, [forceInitialize, hasParentInterceptorContext, interceptor, parentInterceptorContext === null || parentInterceptorContext === void 0 ? void 0 : parentInterceptorContext.forceInitialize, parentInterceptorContext === null || parentInterceptorContext === void 0 ? void 0 : parentInterceptorContext.interceptorWorker]);
|
|
112
|
+
const isMocked = (0, react_1.useCallback)((url) => interceptor !== undefined && !!process.env.VITE_MOCK_ENABLED, [interceptor]);
|
|
91
113
|
const doForceInitialize = (0, react_1.useCallback)(() => {
|
|
92
114
|
setForceInitialize(true);
|
|
93
115
|
}, []);
|
|
94
|
-
const isMocked = (0, react_1.useCallback)((url) => interceptor !== undefined && !!process.env.VITE_MOCK_ENABLED, [interceptor]);
|
|
95
116
|
const contextValue = (0, react_1.useMemo)(() => {
|
|
96
117
|
return {
|
|
97
118
|
interceptorWorker,
|
|
@@ -100,5 +121,6 @@ function ApiInterceptorProvider({ interceptor, children, apiWorker, useHashBased
|
|
|
100
121
|
isMocked: isMocked,
|
|
101
122
|
};
|
|
102
123
|
}, [interceptorWorker, initialized, doForceInitialize, isMocked]);
|
|
124
|
+
// console.log("[ApiInterceptorProvider] Initialized:", initialized, "Interceptor:", interceptor, "Has parent", hasParentInterceptorContext, "waitForApiInterceptor", waitForApiInterceptor);
|
|
103
125
|
return ((0, jsx_runtime_1.jsx)(useApiInterceptorContext_1.ApiInterceptorContext.Provider, { value: contextValue, children: waitForApiInterceptor && !initialized ? null : children }));
|
|
104
126
|
}
|
|
@@ -47,11 +47,12 @@ declare type ApiInterceptorDefinition = {
|
|
|
47
47
|
auth?: AuthDefinition;
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
declare function ApiInterceptorProvider({ interceptor, children,
|
|
50
|
+
declare function ApiInterceptorProvider({ interceptor, children, useHashBasedRouting, parentInterceptorContext, waitForApiInterceptor, }: {
|
|
51
51
|
interceptor?: ApiInterceptorDefinition;
|
|
52
52
|
children: ReactNode;
|
|
53
53
|
apiWorker?: SetupWorker;
|
|
54
54
|
useHashBasedRouting?: boolean;
|
|
55
|
+
parentInterceptorContext?: IApiInterceptorContext;
|
|
55
56
|
waitForApiInterceptor?: boolean;
|
|
56
57
|
}): JSX_2.Element;
|
|
57
58
|
|
|
@@ -916,7 +917,7 @@ declare type Message = ValueOrFunction<Renderable, Toast>;
|
|
|
916
917
|
*/
|
|
917
918
|
declare type ModuleErrors = Record<string, ScriptParserErrorMessage[]>;
|
|
918
919
|
|
|
919
|
-
declare function NestedApp({ api, app, components, config, activeTheme, activeTone,
|
|
920
|
+
declare function NestedApp({ api, app, components, config, activeTheme, activeTone, height, style, refreshVersion }: NestedAppProps): JSX_2.Element;
|
|
920
921
|
|
|
921
922
|
declare type NestedAppProps = {
|
|
922
923
|
api?: any;
|
|
@@ -925,15 +926,9 @@ declare type NestedAppProps = {
|
|
|
925
926
|
config?: any;
|
|
926
927
|
activeTone?: ThemeTone;
|
|
927
928
|
activeTheme?: string;
|
|
928
|
-
title?: string;
|
|
929
929
|
height?: string | number;
|
|
930
|
-
allowPlaygroundPopup?: boolean;
|
|
931
|
-
popOutUrl?: string;
|
|
932
|
-
withFrame?: boolean;
|
|
933
|
-
noHeader?: boolean;
|
|
934
930
|
style?: CSSProperties;
|
|
935
|
-
|
|
936
|
-
refVersion?: number;
|
|
931
|
+
refreshVersion?: number;
|
|
937
932
|
};
|
|
938
933
|
|
|
939
934
|
declare type NO_ARG_EXPRESSION = typeof T_NO_ARG_EXPRESSION;
|