@hai3/react 0.2.0-alpha.4 → 0.4.0-alpha.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/CLAUDE.md +255 -43
- package/commands/hai3-new-mfe.md +167 -0
- package/dist/index.cjs +539 -280
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +342 -90
- package/dist/index.d.ts +342 -90
- package/dist/index.js +422 -149
- package/dist/index.js.map +1 -1
- package/dist/types-CcLYaLwF.d.cts +136 -0
- package/dist/types-CcLYaLwF.d.ts +136 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +3 -238
- package/dist/types.d.ts +3 -238
- package/llms.txt +72 -9
- package/package.json +13 -6
package/dist/index.js
CHANGED
|
@@ -16,25 +16,39 @@ function useHAI3() {
|
|
|
16
16
|
return context;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
// src/
|
|
19
|
+
// src/mfe/MfeContext.tsx
|
|
20
|
+
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
21
|
+
var MfeContext = createContext2(null);
|
|
22
|
+
function useMfeContext() {
|
|
23
|
+
const context = useContext2(MfeContext);
|
|
24
|
+
if (!context) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
"useMfeContext must be used within a MfeProvider. This hook can only be used inside MFE components."
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return context;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// src/mfe/MfeProvider.tsx
|
|
20
33
|
import { jsx } from "react/jsx-runtime";
|
|
34
|
+
var MfeProvider = ({ value, children }) => {
|
|
35
|
+
return /* @__PURE__ */ jsx(MfeContext.Provider, { value, children });
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// src/HAI3Provider.tsx
|
|
39
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
21
40
|
var HAI3Provider = ({
|
|
22
41
|
children,
|
|
23
42
|
config,
|
|
24
43
|
app: providedApp,
|
|
25
|
-
|
|
44
|
+
mfeBridge
|
|
26
45
|
}) => {
|
|
27
46
|
const app = useMemo(() => {
|
|
28
47
|
if (providedApp) {
|
|
29
48
|
return providedApp;
|
|
30
49
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
routerMode: router?.type,
|
|
34
|
-
autoNavigate: router?.autoNavigate ?? config?.autoNavigate
|
|
35
|
-
};
|
|
36
|
-
return createHAI3App(mergedConfig);
|
|
37
|
-
}, [providedApp, config, router]);
|
|
50
|
+
return createHAI3App(config);
|
|
51
|
+
}, [providedApp, config]);
|
|
38
52
|
useEffect(() => {
|
|
39
53
|
return () => {
|
|
40
54
|
if (!providedApp) {
|
|
@@ -42,7 +56,11 @@ var HAI3Provider = ({
|
|
|
42
56
|
}
|
|
43
57
|
};
|
|
44
58
|
}, [app, providedApp]);
|
|
45
|
-
|
|
59
|
+
const content = /* @__PURE__ */ jsx2(HAI3Context.Provider, { value: app, children: /* @__PURE__ */ jsx2(ReduxProvider, { store: app.store, children }) });
|
|
60
|
+
if (mfeBridge) {
|
|
61
|
+
return /* @__PURE__ */ jsx2(MfeProvider, { value: mfeBridge, children: content });
|
|
62
|
+
}
|
|
63
|
+
return content;
|
|
46
64
|
};
|
|
47
65
|
|
|
48
66
|
// src/hooks/useAppDispatch.ts
|
|
@@ -81,10 +99,12 @@ function useTranslation() {
|
|
|
81
99
|
[i18nRegistry2]
|
|
82
100
|
);
|
|
83
101
|
const setLanguage = useCallback(
|
|
84
|
-
|
|
85
|
-
|
|
102
|
+
(lang) => {
|
|
103
|
+
if (app.actions.setLanguage) {
|
|
104
|
+
app.actions.setLanguage({ language: lang });
|
|
105
|
+
}
|
|
86
106
|
},
|
|
87
|
-
[
|
|
107
|
+
[app.actions]
|
|
88
108
|
);
|
|
89
109
|
const isRTL = useMemo2(() => {
|
|
90
110
|
void language;
|
|
@@ -167,68 +187,49 @@ function useScreenTranslations(screensetId, screenId, translations) {
|
|
|
167
187
|
return { isLoaded, error };
|
|
168
188
|
}
|
|
169
189
|
|
|
170
|
-
// src/hooks/
|
|
171
|
-
import {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
190
|
+
// src/hooks/useFormatters.ts
|
|
191
|
+
import { useMemo as useMemo4 } from "react";
|
|
192
|
+
import {
|
|
193
|
+
formatDate as formatDateFn,
|
|
194
|
+
formatTime as formatTimeFn,
|
|
195
|
+
formatDateTime as formatDateTimeFn,
|
|
196
|
+
formatRelative as formatRelativeFn,
|
|
197
|
+
formatNumber as formatNumberFn,
|
|
198
|
+
formatPercent as formatPercentFn,
|
|
199
|
+
formatCompact as formatCompactFn,
|
|
200
|
+
formatCurrency as formatCurrencyFn,
|
|
201
|
+
compareStrings as compareStringsFn,
|
|
202
|
+
createCollator as createCollatorFn
|
|
203
|
+
} from "@hai3/framework";
|
|
204
|
+
function useFormatters() {
|
|
205
|
+
const { language } = useTranslation();
|
|
206
|
+
return useMemo4(
|
|
207
|
+
() => {
|
|
208
|
+
void language;
|
|
209
|
+
return {
|
|
210
|
+
formatDate: formatDateFn,
|
|
211
|
+
formatTime: formatTimeFn,
|
|
212
|
+
formatDateTime: formatDateTimeFn,
|
|
213
|
+
formatRelative: formatRelativeFn,
|
|
214
|
+
formatNumber: formatNumberFn,
|
|
215
|
+
formatPercent: formatPercentFn,
|
|
216
|
+
formatCompact: formatCompactFn,
|
|
217
|
+
formatCurrency: formatCurrencyFn,
|
|
218
|
+
compareStrings: compareStringsFn,
|
|
219
|
+
createCollator: createCollatorFn
|
|
220
|
+
};
|
|
197
221
|
},
|
|
198
|
-
[
|
|
222
|
+
[language]
|
|
199
223
|
);
|
|
200
|
-
const currentScreenset = currentScreen ? app.routeRegistry?.getScreensetForScreen(currentScreen) ?? null : null;
|
|
201
|
-
return {
|
|
202
|
-
navigateToScreen,
|
|
203
|
-
navigateToScreenset,
|
|
204
|
-
currentScreenset,
|
|
205
|
-
currentScreen
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// src/contexts/RouteParamsContext.tsx
|
|
210
|
-
import { createContext as createContext2, useContext as useContext2 } from "react";
|
|
211
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
212
|
-
var RouteParamsContext = createContext2({});
|
|
213
|
-
function RouteParamsProvider({ params, children }) {
|
|
214
|
-
return /* @__PURE__ */ jsx2(RouteParamsContext.Provider, { value: params, children });
|
|
215
|
-
}
|
|
216
|
-
function useRouteParamsContext() {
|
|
217
|
-
return useContext2(RouteParamsContext);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
// src/hooks/useRouteParams.ts
|
|
221
|
-
function useRouteParams() {
|
|
222
|
-
return useRouteParamsContext();
|
|
223
224
|
}
|
|
224
225
|
|
|
225
226
|
// src/hooks/useTheme.ts
|
|
226
|
-
import { useCallback as
|
|
227
|
+
import { useCallback as useCallback3, useMemo as useMemo5, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
227
228
|
function useTheme() {
|
|
228
229
|
const app = useHAI3();
|
|
229
230
|
const { themeRegistry } = app;
|
|
230
231
|
const version = useSyncExternalStore3(
|
|
231
|
-
|
|
232
|
+
useCallback3(
|
|
232
233
|
(callback) => {
|
|
233
234
|
return themeRegistry.subscribe(callback);
|
|
234
235
|
},
|
|
@@ -237,18 +238,18 @@ function useTheme() {
|
|
|
237
238
|
() => themeRegistry.getVersion(),
|
|
238
239
|
() => themeRegistry.getVersion()
|
|
239
240
|
);
|
|
240
|
-
const currentTheme =
|
|
241
|
+
const currentTheme = useMemo5(() => {
|
|
241
242
|
void version;
|
|
242
243
|
const theme = themeRegistry.getCurrent();
|
|
243
244
|
return theme?.id;
|
|
244
245
|
}, [themeRegistry, version]);
|
|
245
|
-
const themes2 =
|
|
246
|
+
const themes2 = useMemo5(() => {
|
|
246
247
|
return themeRegistry.getAll().map((theme) => ({
|
|
247
248
|
id: theme.id,
|
|
248
249
|
name: theme.name
|
|
249
250
|
}));
|
|
250
251
|
}, [themeRegistry]);
|
|
251
|
-
const setTheme =
|
|
252
|
+
const setTheme = useCallback3(
|
|
252
253
|
(themeId) => {
|
|
253
254
|
if (app.actions.changeTheme) {
|
|
254
255
|
app.actions.changeTheme({ themeId });
|
|
@@ -263,111 +264,295 @@ function useTheme() {
|
|
|
263
264
|
};
|
|
264
265
|
}
|
|
265
266
|
|
|
266
|
-
// src/
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
267
|
+
// src/mfe/hooks/useMfeBridge.ts
|
|
268
|
+
function useMfeBridge() {
|
|
269
|
+
const { bridge } = useMfeContext();
|
|
270
|
+
return bridge;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// src/mfe/hooks/useSharedProperty.ts
|
|
274
|
+
import { useSyncExternalStore as useSyncExternalStore4, useCallback as useCallback4 } from "react";
|
|
275
|
+
function useSharedProperty(propertyTypeId) {
|
|
276
|
+
const { bridge } = useMfeContext();
|
|
277
|
+
const subscribe = useCallback4((callback) => {
|
|
278
|
+
return bridge.subscribeToProperty(propertyTypeId, () => {
|
|
279
|
+
callback();
|
|
280
|
+
});
|
|
281
|
+
}, [bridge, propertyTypeId]);
|
|
282
|
+
const getSnapshot = useCallback4(() => {
|
|
283
|
+
const property = bridge.getProperty(propertyTypeId);
|
|
284
|
+
return property?.value;
|
|
285
|
+
}, [bridge, propertyTypeId]);
|
|
286
|
+
const value = useSyncExternalStore4(subscribe, getSnapshot, getSnapshot);
|
|
287
|
+
return value;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// src/mfe/hooks/useHostAction.ts
|
|
291
|
+
import { useCallback as useCallback5 } from "react";
|
|
292
|
+
function useHostAction(actionTypeId) {
|
|
293
|
+
const { bridge } = useMfeContext();
|
|
294
|
+
return useCallback5((payload) => {
|
|
295
|
+
const chain = {
|
|
296
|
+
action: {
|
|
297
|
+
type: actionTypeId,
|
|
298
|
+
target: bridge.domainId,
|
|
299
|
+
payload
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
bridge.executeActionsChain(chain).catch((error) => {
|
|
303
|
+
console.error(
|
|
304
|
+
`[useHostAction] Failed to send action '${actionTypeId}':`,
|
|
305
|
+
error
|
|
306
|
+
);
|
|
307
|
+
});
|
|
308
|
+
}, [actionTypeId, bridge]);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// src/mfe/hooks/useDomainExtensions.ts
|
|
312
|
+
import { useSyncExternalStore as useSyncExternalStore5, useCallback as useCallback6, useRef } from "react";
|
|
313
|
+
function useDomainExtensions(domainId) {
|
|
273
314
|
const app = useHAI3();
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
315
|
+
const registry = app.screensetsRegistry;
|
|
316
|
+
if (!registry) {
|
|
317
|
+
throw new Error(
|
|
318
|
+
"useDomainExtensions requires the microfrontends plugin. Add microfrontends() to your HAI3 app configuration."
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
const subscribe = useCallback6(
|
|
322
|
+
(onStoreChange) => {
|
|
323
|
+
return app.store.subscribe(onStoreChange);
|
|
324
|
+
},
|
|
325
|
+
[app.store]
|
|
326
|
+
);
|
|
327
|
+
const cacheRef = useRef({ ids: "", extensions: [] });
|
|
328
|
+
const getSnapshot = useCallback6(() => {
|
|
329
|
+
const extensions = registry.getExtensionsForDomain(domainId);
|
|
330
|
+
const ids = extensions.map((e) => e.id).join(",");
|
|
331
|
+
if (ids !== cacheRef.current.ids) {
|
|
332
|
+
cacheRef.current = { ids, extensions };
|
|
280
333
|
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
334
|
+
return cacheRef.current.extensions;
|
|
335
|
+
}, [registry, domainId]);
|
|
336
|
+
return useSyncExternalStore5(subscribe, getSnapshot, getSnapshot);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// src/mfe/hooks/useRegisteredPackages.ts
|
|
340
|
+
import { useSyncExternalStore as useSyncExternalStore6, useCallback as useCallback7, useRef as useRef2 } from "react";
|
|
341
|
+
function useRegisteredPackages() {
|
|
342
|
+
const app = useHAI3();
|
|
343
|
+
const registry = app.screensetsRegistry;
|
|
344
|
+
if (!registry) {
|
|
345
|
+
throw new Error(
|
|
346
|
+
"useRegisteredPackages requires the microfrontends plugin. Add microfrontends() to your HAI3 app configuration."
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
const subscribe = useCallback7(
|
|
350
|
+
(onStoreChange) => {
|
|
351
|
+
return app.store.subscribe(onStoreChange);
|
|
352
|
+
},
|
|
353
|
+
[app.store]
|
|
354
|
+
);
|
|
355
|
+
const cacheRef = useRef2({ packages: "", list: [] });
|
|
356
|
+
const getSnapshot = useCallback7(() => {
|
|
357
|
+
const list = registry.getRegisteredPackages();
|
|
358
|
+
const packages = list.join(",");
|
|
359
|
+
if (packages !== cacheRef.current.packages) {
|
|
360
|
+
cacheRef.current = { packages, list };
|
|
361
|
+
}
|
|
362
|
+
return cacheRef.current.list;
|
|
363
|
+
}, [registry]);
|
|
364
|
+
return useSyncExternalStore6(subscribe, getSnapshot, getSnapshot);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// src/mfe/hooks/useActivePackage.ts
|
|
368
|
+
import { useSyncExternalStore as useSyncExternalStore7, useCallback as useCallback8, useRef as useRef3 } from "react";
|
|
369
|
+
import { extractGtsPackage, HAI3_SCREEN_DOMAIN } from "@hai3/framework";
|
|
370
|
+
function useActivePackage() {
|
|
371
|
+
const app = useHAI3();
|
|
372
|
+
const registry = app.screensetsRegistry;
|
|
373
|
+
if (!registry) {
|
|
374
|
+
throw new Error(
|
|
375
|
+
"useActivePackage requires the microfrontends plugin. Add microfrontends() to your HAI3 app configuration."
|
|
376
|
+
);
|
|
377
|
+
}
|
|
378
|
+
const subscribe = useCallback8(
|
|
379
|
+
(onStoreChange) => {
|
|
380
|
+
return app.store.subscribe(onStoreChange);
|
|
381
|
+
},
|
|
382
|
+
[app.store]
|
|
383
|
+
);
|
|
384
|
+
const cacheRef = useRef3({ activePackage: void 0 });
|
|
385
|
+
const getSnapshot = useCallback8(() => {
|
|
386
|
+
const mountedExtensionId = registry.getMountedExtension(HAI3_SCREEN_DOMAIN);
|
|
387
|
+
if (!mountedExtensionId) {
|
|
388
|
+
const result = void 0;
|
|
389
|
+
if (result !== cacheRef.current.activePackage) {
|
|
390
|
+
cacheRef.current = { activePackage: result };
|
|
391
|
+
}
|
|
392
|
+
return cacheRef.current.activePackage;
|
|
290
393
|
}
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
}, [
|
|
394
|
+
const activePackage = extractGtsPackage(mountedExtensionId);
|
|
395
|
+
if (activePackage !== cacheRef.current.activePackage) {
|
|
396
|
+
cacheRef.current = { activePackage };
|
|
397
|
+
}
|
|
398
|
+
return cacheRef.current.activePackage;
|
|
399
|
+
}, [registry]);
|
|
400
|
+
return useSyncExternalStore7(subscribe, getSnapshot, getSnapshot);
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
// src/mfe/components/RefContainerProvider.ts
|
|
404
|
+
import { ContainerProvider } from "@hai3/framework";
|
|
405
|
+
var RefContainerProvider = class extends ContainerProvider {
|
|
406
|
+
constructor(containerRef) {
|
|
407
|
+
super();
|
|
408
|
+
this.containerRef = containerRef;
|
|
409
|
+
}
|
|
410
|
+
getContainer(_extensionId) {
|
|
411
|
+
if (!this.containerRef.current) {
|
|
412
|
+
throw new Error("Container ref is not attached -- component may not be mounted yet");
|
|
413
|
+
}
|
|
414
|
+
return this.containerRef.current;
|
|
415
|
+
}
|
|
416
|
+
releaseContainer(_extensionId) {
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
|
|
420
|
+
// src/mfe/components/ExtensionDomainSlot.tsx
|
|
421
|
+
import { useEffect as useEffect3, useRef as useRef4, useState as useState2 } from "react";
|
|
422
|
+
import {
|
|
423
|
+
HAI3_ACTION_MOUNT_EXT,
|
|
424
|
+
HAI3_ACTION_UNMOUNT_EXT
|
|
425
|
+
} from "@hai3/framework";
|
|
426
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
427
|
+
function ExtensionDomainSlot(props) {
|
|
428
|
+
const {
|
|
429
|
+
registry,
|
|
430
|
+
domainId,
|
|
431
|
+
extensionId,
|
|
432
|
+
className,
|
|
433
|
+
onMounted,
|
|
434
|
+
onUnmounted,
|
|
435
|
+
onError,
|
|
436
|
+
loadingComponent,
|
|
437
|
+
errorComponent
|
|
438
|
+
} = props;
|
|
439
|
+
const containerRef = useRef4(null);
|
|
440
|
+
const [isLoading, setIsLoading] = useState2(true);
|
|
441
|
+
const [error, setError] = useState2(null);
|
|
442
|
+
const [bridge, setBridge] = useState2(null);
|
|
297
443
|
useEffect3(() => {
|
|
298
|
-
let
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
444
|
+
let mounted = true;
|
|
445
|
+
let currentBridge = null;
|
|
446
|
+
async function mountExtension2() {
|
|
447
|
+
if (!containerRef.current) {
|
|
302
448
|
return;
|
|
303
449
|
}
|
|
304
450
|
try {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
451
|
+
setIsLoading(true);
|
|
452
|
+
setError(null);
|
|
453
|
+
await registry.executeActionsChain({
|
|
454
|
+
action: {
|
|
455
|
+
type: HAI3_ACTION_MOUNT_EXT,
|
|
456
|
+
target: domainId,
|
|
457
|
+
payload: {
|
|
458
|
+
extensionId
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
if (!mounted) {
|
|
463
|
+
await registry.executeActionsChain({
|
|
464
|
+
action: {
|
|
465
|
+
type: HAI3_ACTION_UNMOUNT_EXT,
|
|
466
|
+
target: domainId,
|
|
467
|
+
payload: {
|
|
468
|
+
extensionId
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
return;
|
|
310
473
|
}
|
|
311
|
-
const
|
|
312
|
-
if (!
|
|
313
|
-
|
|
314
|
-
|
|
474
|
+
const newBridge = registry.getParentBridge(extensionId);
|
|
475
|
+
if (!newBridge) {
|
|
476
|
+
throw new Error(`Failed to obtain bridge for extension ${extensionId} after mount`);
|
|
477
|
+
}
|
|
478
|
+
currentBridge = newBridge;
|
|
479
|
+
setBridge(newBridge);
|
|
480
|
+
setIsLoading(false);
|
|
481
|
+
if (onMounted) {
|
|
482
|
+
onMounted(newBridge);
|
|
315
483
|
}
|
|
316
484
|
} catch (err) {
|
|
317
|
-
if (!
|
|
318
|
-
|
|
319
|
-
|
|
485
|
+
if (!mounted) {
|
|
486
|
+
return;
|
|
487
|
+
}
|
|
488
|
+
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
489
|
+
setError(errorObj);
|
|
490
|
+
setIsLoading(false);
|
|
491
|
+
if (onError) {
|
|
492
|
+
onError(errorObj);
|
|
320
493
|
}
|
|
321
494
|
}
|
|
322
|
-
}
|
|
323
|
-
|
|
495
|
+
}
|
|
496
|
+
void mountExtension2();
|
|
324
497
|
return () => {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
498
|
+
mounted = false;
|
|
499
|
+
if (currentBridge) {
|
|
500
|
+
void registry.executeActionsChain({
|
|
501
|
+
action: {
|
|
502
|
+
type: HAI3_ACTION_UNMOUNT_EXT,
|
|
503
|
+
target: domainId,
|
|
504
|
+
payload: {
|
|
505
|
+
extensionId
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}).then(() => {
|
|
509
|
+
if (onUnmounted) {
|
|
510
|
+
onUnmounted();
|
|
511
|
+
}
|
|
512
|
+
});
|
|
332
513
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
/* @__PURE__ */ jsx3("p", { children: error.message })
|
|
338
|
-
] });
|
|
514
|
+
};
|
|
515
|
+
}, [registry, domainId, extensionId, onMounted, onUnmounted, onError]);
|
|
516
|
+
if (isLoading) {
|
|
517
|
+
return /* @__PURE__ */ jsx3("div", { className, "data-domain-id": domainId, "data-extension-id": extensionId, children: loadingComponent ?? /* @__PURE__ */ jsx3("div", { children: "Loading extension..." }) });
|
|
339
518
|
}
|
|
340
|
-
if (
|
|
341
|
-
return /* @__PURE__ */ jsx3(
|
|
519
|
+
if (error) {
|
|
520
|
+
return /* @__PURE__ */ jsx3("div", { className, "data-domain-id": domainId, "data-extension-id": extensionId, children: errorComponent ? errorComponent(error) : /* @__PURE__ */ jsxs("div", { children: [
|
|
521
|
+
/* @__PURE__ */ jsx3("strong", { children: "Error loading extension:" }),
|
|
522
|
+
/* @__PURE__ */ jsx3("pre", { children: error.message })
|
|
523
|
+
] }) });
|
|
342
524
|
}
|
|
343
|
-
return /* @__PURE__ */ jsx3(
|
|
344
|
-
|
|
525
|
+
return /* @__PURE__ */ jsx3(
|
|
526
|
+
"div",
|
|
527
|
+
{
|
|
528
|
+
ref: containerRef,
|
|
529
|
+
className,
|
|
530
|
+
"data-domain-id": domainId,
|
|
531
|
+
"data-extension-id": extensionId,
|
|
532
|
+
"data-bridge-active": bridge !== null
|
|
533
|
+
}
|
|
534
|
+
);
|
|
535
|
+
}
|
|
345
536
|
|
|
346
537
|
// src/index.ts
|
|
347
538
|
import {
|
|
348
539
|
createHAI3,
|
|
349
540
|
createHAI3App as createHAI3App2,
|
|
350
541
|
presets,
|
|
351
|
-
screensetRegistry,
|
|
352
542
|
ACCOUNTS_DOMAIN,
|
|
353
543
|
I18nRegistry,
|
|
354
544
|
screensets,
|
|
355
545
|
themes,
|
|
356
546
|
layout,
|
|
357
|
-
navigation,
|
|
358
|
-
routing,
|
|
359
547
|
i18n,
|
|
360
548
|
effects,
|
|
361
|
-
createScreensetRegistry,
|
|
362
549
|
createThemeRegistry,
|
|
363
|
-
createRouteRegistry,
|
|
364
550
|
createStore,
|
|
365
551
|
getStore,
|
|
366
552
|
registerSlice,
|
|
367
553
|
hasSlice,
|
|
368
554
|
createSlice,
|
|
369
555
|
LayoutDomain,
|
|
370
|
-
ScreensetCategory,
|
|
371
556
|
layoutReducer,
|
|
372
557
|
layoutDomainReducers,
|
|
373
558
|
LAYOUT_SLICE_NAME,
|
|
@@ -458,6 +643,58 @@ import {
|
|
|
458
643
|
getLanguageMetadata
|
|
459
644
|
} from "@hai3/framework";
|
|
460
645
|
import { Language, TextDirection, LanguageDisplayMode } from "@hai3/framework";
|
|
646
|
+
import {
|
|
647
|
+
microfrontends,
|
|
648
|
+
mock
|
|
649
|
+
} from "@hai3/framework";
|
|
650
|
+
import {
|
|
651
|
+
loadExtension,
|
|
652
|
+
mountExtension,
|
|
653
|
+
unmountExtension,
|
|
654
|
+
registerExtension,
|
|
655
|
+
unregisterExtension
|
|
656
|
+
} from "@hai3/framework";
|
|
657
|
+
import {
|
|
658
|
+
selectExtensionState,
|
|
659
|
+
selectRegisteredExtensions,
|
|
660
|
+
selectExtensionError
|
|
661
|
+
} from "@hai3/framework";
|
|
662
|
+
import {
|
|
663
|
+
HAI3_POPUP_DOMAIN,
|
|
664
|
+
HAI3_SIDEBAR_DOMAIN,
|
|
665
|
+
HAI3_SCREEN_DOMAIN as HAI3_SCREEN_DOMAIN2,
|
|
666
|
+
HAI3_OVERLAY_DOMAIN,
|
|
667
|
+
screenDomain,
|
|
668
|
+
sidebarDomain,
|
|
669
|
+
popupDomain,
|
|
670
|
+
overlayDomain
|
|
671
|
+
} from "@hai3/framework";
|
|
672
|
+
import {
|
|
673
|
+
HAI3_SCREEN_EXTENSION_TYPE
|
|
674
|
+
} from "@hai3/framework";
|
|
675
|
+
import {
|
|
676
|
+
HAI3_ACTION_LOAD_EXT,
|
|
677
|
+
HAI3_ACTION_MOUNT_EXT as HAI3_ACTION_MOUNT_EXT2,
|
|
678
|
+
HAI3_ACTION_UNMOUNT_EXT as HAI3_ACTION_UNMOUNT_EXT2
|
|
679
|
+
} from "@hai3/framework";
|
|
680
|
+
import {
|
|
681
|
+
HAI3_SHARED_PROPERTY_THEME,
|
|
682
|
+
HAI3_SHARED_PROPERTY_LANGUAGE
|
|
683
|
+
} from "@hai3/framework";
|
|
684
|
+
import {
|
|
685
|
+
MfeHandler,
|
|
686
|
+
MfeBridgeFactory,
|
|
687
|
+
ScreensetsRegistry,
|
|
688
|
+
ScreensetsRegistryFactory,
|
|
689
|
+
screensetsRegistryFactory,
|
|
690
|
+
ContainerProvider as ContainerProvider2
|
|
691
|
+
} from "@hai3/framework";
|
|
692
|
+
import { MfeHandlerMF, gtsPlugin } from "@hai3/framework";
|
|
693
|
+
import {
|
|
694
|
+
createShadowRoot,
|
|
695
|
+
injectCssVariables,
|
|
696
|
+
extractGtsPackage as extractGtsPackage2
|
|
697
|
+
} from "@hai3/framework";
|
|
461
698
|
import { eventBus as frameworkEventBus } from "@hai3/framework";
|
|
462
699
|
var eventBus = frameworkEventBus;
|
|
463
700
|
export {
|
|
@@ -465,10 +702,21 @@ export {
|
|
|
465
702
|
ApiPlugin,
|
|
466
703
|
ApiPluginBase,
|
|
467
704
|
ApiProtocol,
|
|
468
|
-
AppRouter,
|
|
469
705
|
BaseApiService,
|
|
706
|
+
ContainerProvider2 as ContainerProvider,
|
|
707
|
+
ExtensionDomainSlot,
|
|
470
708
|
HAI3Context,
|
|
471
709
|
HAI3Provider,
|
|
710
|
+
HAI3_ACTION_LOAD_EXT,
|
|
711
|
+
HAI3_ACTION_MOUNT_EXT2 as HAI3_ACTION_MOUNT_EXT,
|
|
712
|
+
HAI3_ACTION_UNMOUNT_EXT2 as HAI3_ACTION_UNMOUNT_EXT,
|
|
713
|
+
HAI3_OVERLAY_DOMAIN,
|
|
714
|
+
HAI3_POPUP_DOMAIN,
|
|
715
|
+
HAI3_SCREEN_DOMAIN2 as HAI3_SCREEN_DOMAIN,
|
|
716
|
+
HAI3_SCREEN_EXTENSION_TYPE,
|
|
717
|
+
HAI3_SHARED_PROPERTY_LANGUAGE,
|
|
718
|
+
HAI3_SHARED_PROPERTY_THEME,
|
|
719
|
+
HAI3_SIDEBAR_DOMAIN,
|
|
472
720
|
I18nRegistry,
|
|
473
721
|
I18nRegistryImpl,
|
|
474
722
|
LAYOUT_SLICE_NAME,
|
|
@@ -476,16 +724,21 @@ export {
|
|
|
476
724
|
LanguageDisplayMode,
|
|
477
725
|
LayoutDomain,
|
|
478
726
|
MOCK_PLUGIN,
|
|
727
|
+
MfeBridgeFactory,
|
|
728
|
+
MfeContext,
|
|
729
|
+
MfeHandler,
|
|
730
|
+
MfeHandlerMF,
|
|
731
|
+
MfeProvider,
|
|
479
732
|
MockEventSource,
|
|
480
733
|
MockEvents,
|
|
734
|
+
RefContainerProvider,
|
|
481
735
|
RestMockPlugin,
|
|
482
736
|
RestPlugin,
|
|
483
737
|
RestPluginWithConfig,
|
|
484
738
|
RestProtocol,
|
|
485
|
-
RouteParamsContext,
|
|
486
|
-
RouteParamsProvider,
|
|
487
739
|
SUPPORTED_LANGUAGES,
|
|
488
|
-
|
|
740
|
+
ScreensetsRegistry,
|
|
741
|
+
ScreensetsRegistryFactory,
|
|
489
742
|
SseMockPlugin,
|
|
490
743
|
SsePlugin,
|
|
491
744
|
SsePluginWithConfig,
|
|
@@ -505,17 +758,18 @@ export {
|
|
|
505
758
|
createHAI3,
|
|
506
759
|
createHAI3App2 as createHAI3App,
|
|
507
760
|
createI18nRegistry,
|
|
508
|
-
|
|
509
|
-
createScreensetRegistry,
|
|
761
|
+
createShadowRoot,
|
|
510
762
|
createSlice,
|
|
511
763
|
createStore,
|
|
512
764
|
createThemeRegistry,
|
|
513
765
|
effects,
|
|
514
766
|
eventBus,
|
|
767
|
+
extractGtsPackage2 as extractGtsPackage,
|
|
515
768
|
footerActions,
|
|
516
769
|
footerSlice,
|
|
517
770
|
getLanguageMetadata,
|
|
518
771
|
getStore,
|
|
772
|
+
gtsPlugin,
|
|
519
773
|
hasSlice,
|
|
520
774
|
headerActions,
|
|
521
775
|
headerSlice,
|
|
@@ -524,6 +778,7 @@ export {
|
|
|
524
778
|
i18nRegistry,
|
|
525
779
|
initMockEffects,
|
|
526
780
|
initTenantEffects,
|
|
781
|
+
injectCssVariables,
|
|
527
782
|
isMockPlugin,
|
|
528
783
|
isRestShortCircuit,
|
|
529
784
|
isShortCircuit,
|
|
@@ -531,24 +786,33 @@ export {
|
|
|
531
786
|
layout,
|
|
532
787
|
layoutDomainReducers,
|
|
533
788
|
layoutReducer,
|
|
789
|
+
loadExtension,
|
|
534
790
|
menuActions,
|
|
535
791
|
menuSlice,
|
|
792
|
+
microfrontends,
|
|
793
|
+
mock,
|
|
536
794
|
mockActions,
|
|
537
795
|
mockSlice,
|
|
796
|
+
mountExtension,
|
|
538
797
|
navigateTo,
|
|
539
|
-
navigation,
|
|
540
798
|
openPopup,
|
|
541
799
|
overlayActions,
|
|
800
|
+
overlayDomain,
|
|
542
801
|
overlaySlice,
|
|
543
802
|
popupActions,
|
|
803
|
+
popupDomain,
|
|
544
804
|
popupSlice,
|
|
545
805
|
presets,
|
|
806
|
+
registerExtension,
|
|
546
807
|
registerSlice,
|
|
547
|
-
routing,
|
|
548
808
|
screenActions,
|
|
809
|
+
screenDomain,
|
|
549
810
|
screenSlice,
|
|
550
|
-
screensetRegistry,
|
|
551
811
|
screensets,
|
|
812
|
+
screensetsRegistryFactory,
|
|
813
|
+
selectExtensionError,
|
|
814
|
+
selectExtensionState,
|
|
815
|
+
selectRegisteredExtensions,
|
|
552
816
|
setActiveScreen,
|
|
553
817
|
setFooterConfig,
|
|
554
818
|
setFooterVisible,
|
|
@@ -573,6 +837,7 @@ export {
|
|
|
573
837
|
setUser,
|
|
574
838
|
showOverlay,
|
|
575
839
|
sidebarActions,
|
|
840
|
+
sidebarDomain,
|
|
576
841
|
sidebarSlice,
|
|
577
842
|
tenantActions,
|
|
578
843
|
tenantReducer,
|
|
@@ -581,12 +846,20 @@ export {
|
|
|
581
846
|
toggleMenu,
|
|
582
847
|
toggleMockMode,
|
|
583
848
|
toggleSidebar,
|
|
849
|
+
unmountExtension,
|
|
850
|
+
unregisterExtension,
|
|
851
|
+
useActivePackage,
|
|
584
852
|
useAppDispatch,
|
|
585
853
|
useAppSelector,
|
|
854
|
+
useDomainExtensions,
|
|
855
|
+
useFormatters,
|
|
586
856
|
useHAI3,
|
|
587
|
-
|
|
588
|
-
|
|
857
|
+
useHostAction,
|
|
858
|
+
useMfeBridge,
|
|
859
|
+
useMfeContext,
|
|
860
|
+
useRegisteredPackages,
|
|
589
861
|
useScreenTranslations,
|
|
862
|
+
useSharedProperty,
|
|
590
863
|
useTheme,
|
|
591
864
|
useTranslation
|
|
592
865
|
};
|