@hai3/react 0.3.0-alpha.0 → 0.4.0-alpha.1
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-component.md +5 -31
- package/commands/hai3-new-mfe.md +167 -0
- package/commands/hai3-new-screen.md +12 -53
- package/commands/hai3-new-screenset.md +14 -51
- package/dist/index.cjs +541 -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 +424 -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 +10 -3
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,59 @@ 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
|
+
HAI3_MFE_ENTRY_MF
|
|
675
|
+
} from "@hai3/framework";
|
|
676
|
+
import {
|
|
677
|
+
HAI3_ACTION_LOAD_EXT,
|
|
678
|
+
HAI3_ACTION_MOUNT_EXT as HAI3_ACTION_MOUNT_EXT2,
|
|
679
|
+
HAI3_ACTION_UNMOUNT_EXT as HAI3_ACTION_UNMOUNT_EXT2
|
|
680
|
+
} from "@hai3/framework";
|
|
681
|
+
import {
|
|
682
|
+
HAI3_SHARED_PROPERTY_THEME,
|
|
683
|
+
HAI3_SHARED_PROPERTY_LANGUAGE
|
|
684
|
+
} from "@hai3/framework";
|
|
685
|
+
import {
|
|
686
|
+
MfeHandler,
|
|
687
|
+
MfeBridgeFactory,
|
|
688
|
+
ScreensetsRegistry,
|
|
689
|
+
ScreensetsRegistryFactory,
|
|
690
|
+
screensetsRegistryFactory,
|
|
691
|
+
ContainerProvider as ContainerProvider2
|
|
692
|
+
} from "@hai3/framework";
|
|
693
|
+
import { MfeHandlerMF, gtsPlugin } from "@hai3/framework";
|
|
694
|
+
import {
|
|
695
|
+
createShadowRoot,
|
|
696
|
+
injectCssVariables,
|
|
697
|
+
extractGtsPackage as extractGtsPackage2
|
|
698
|
+
} from "@hai3/framework";
|
|
461
699
|
import { eventBus as frameworkEventBus } from "@hai3/framework";
|
|
462
700
|
var eventBus = frameworkEventBus;
|
|
463
701
|
export {
|
|
@@ -465,10 +703,22 @@ export {
|
|
|
465
703
|
ApiPlugin,
|
|
466
704
|
ApiPluginBase,
|
|
467
705
|
ApiProtocol,
|
|
468
|
-
AppRouter,
|
|
469
706
|
BaseApiService,
|
|
707
|
+
ContainerProvider2 as ContainerProvider,
|
|
708
|
+
ExtensionDomainSlot,
|
|
470
709
|
HAI3Context,
|
|
471
710
|
HAI3Provider,
|
|
711
|
+
HAI3_ACTION_LOAD_EXT,
|
|
712
|
+
HAI3_ACTION_MOUNT_EXT2 as HAI3_ACTION_MOUNT_EXT,
|
|
713
|
+
HAI3_ACTION_UNMOUNT_EXT2 as HAI3_ACTION_UNMOUNT_EXT,
|
|
714
|
+
HAI3_MFE_ENTRY_MF,
|
|
715
|
+
HAI3_OVERLAY_DOMAIN,
|
|
716
|
+
HAI3_POPUP_DOMAIN,
|
|
717
|
+
HAI3_SCREEN_DOMAIN2 as HAI3_SCREEN_DOMAIN,
|
|
718
|
+
HAI3_SCREEN_EXTENSION_TYPE,
|
|
719
|
+
HAI3_SHARED_PROPERTY_LANGUAGE,
|
|
720
|
+
HAI3_SHARED_PROPERTY_THEME,
|
|
721
|
+
HAI3_SIDEBAR_DOMAIN,
|
|
472
722
|
I18nRegistry,
|
|
473
723
|
I18nRegistryImpl,
|
|
474
724
|
LAYOUT_SLICE_NAME,
|
|
@@ -476,16 +726,21 @@ export {
|
|
|
476
726
|
LanguageDisplayMode,
|
|
477
727
|
LayoutDomain,
|
|
478
728
|
MOCK_PLUGIN,
|
|
729
|
+
MfeBridgeFactory,
|
|
730
|
+
MfeContext,
|
|
731
|
+
MfeHandler,
|
|
732
|
+
MfeHandlerMF,
|
|
733
|
+
MfeProvider,
|
|
479
734
|
MockEventSource,
|
|
480
735
|
MockEvents,
|
|
736
|
+
RefContainerProvider,
|
|
481
737
|
RestMockPlugin,
|
|
482
738
|
RestPlugin,
|
|
483
739
|
RestPluginWithConfig,
|
|
484
740
|
RestProtocol,
|
|
485
|
-
RouteParamsContext,
|
|
486
|
-
RouteParamsProvider,
|
|
487
741
|
SUPPORTED_LANGUAGES,
|
|
488
|
-
|
|
742
|
+
ScreensetsRegistry,
|
|
743
|
+
ScreensetsRegistryFactory,
|
|
489
744
|
SseMockPlugin,
|
|
490
745
|
SsePlugin,
|
|
491
746
|
SsePluginWithConfig,
|
|
@@ -505,17 +760,18 @@ export {
|
|
|
505
760
|
createHAI3,
|
|
506
761
|
createHAI3App2 as createHAI3App,
|
|
507
762
|
createI18nRegistry,
|
|
508
|
-
|
|
509
|
-
createScreensetRegistry,
|
|
763
|
+
createShadowRoot,
|
|
510
764
|
createSlice,
|
|
511
765
|
createStore,
|
|
512
766
|
createThemeRegistry,
|
|
513
767
|
effects,
|
|
514
768
|
eventBus,
|
|
769
|
+
extractGtsPackage2 as extractGtsPackage,
|
|
515
770
|
footerActions,
|
|
516
771
|
footerSlice,
|
|
517
772
|
getLanguageMetadata,
|
|
518
773
|
getStore,
|
|
774
|
+
gtsPlugin,
|
|
519
775
|
hasSlice,
|
|
520
776
|
headerActions,
|
|
521
777
|
headerSlice,
|
|
@@ -524,6 +780,7 @@ export {
|
|
|
524
780
|
i18nRegistry,
|
|
525
781
|
initMockEffects,
|
|
526
782
|
initTenantEffects,
|
|
783
|
+
injectCssVariables,
|
|
527
784
|
isMockPlugin,
|
|
528
785
|
isRestShortCircuit,
|
|
529
786
|
isShortCircuit,
|
|
@@ -531,24 +788,33 @@ export {
|
|
|
531
788
|
layout,
|
|
532
789
|
layoutDomainReducers,
|
|
533
790
|
layoutReducer,
|
|
791
|
+
loadExtension,
|
|
534
792
|
menuActions,
|
|
535
793
|
menuSlice,
|
|
794
|
+
microfrontends,
|
|
795
|
+
mock,
|
|
536
796
|
mockActions,
|
|
537
797
|
mockSlice,
|
|
798
|
+
mountExtension,
|
|
538
799
|
navigateTo,
|
|
539
|
-
navigation,
|
|
540
800
|
openPopup,
|
|
541
801
|
overlayActions,
|
|
802
|
+
overlayDomain,
|
|
542
803
|
overlaySlice,
|
|
543
804
|
popupActions,
|
|
805
|
+
popupDomain,
|
|
544
806
|
popupSlice,
|
|
545
807
|
presets,
|
|
808
|
+
registerExtension,
|
|
546
809
|
registerSlice,
|
|
547
|
-
routing,
|
|
548
810
|
screenActions,
|
|
811
|
+
screenDomain,
|
|
549
812
|
screenSlice,
|
|
550
|
-
screensetRegistry,
|
|
551
813
|
screensets,
|
|
814
|
+
screensetsRegistryFactory,
|
|
815
|
+
selectExtensionError,
|
|
816
|
+
selectExtensionState,
|
|
817
|
+
selectRegisteredExtensions,
|
|
552
818
|
setActiveScreen,
|
|
553
819
|
setFooterConfig,
|
|
554
820
|
setFooterVisible,
|
|
@@ -573,6 +839,7 @@ export {
|
|
|
573
839
|
setUser,
|
|
574
840
|
showOverlay,
|
|
575
841
|
sidebarActions,
|
|
842
|
+
sidebarDomain,
|
|
576
843
|
sidebarSlice,
|
|
577
844
|
tenantActions,
|
|
578
845
|
tenantReducer,
|
|
@@ -581,12 +848,20 @@ export {
|
|
|
581
848
|
toggleMenu,
|
|
582
849
|
toggleMockMode,
|
|
583
850
|
toggleSidebar,
|
|
851
|
+
unmountExtension,
|
|
852
|
+
unregisterExtension,
|
|
853
|
+
useActivePackage,
|
|
584
854
|
useAppDispatch,
|
|
585
855
|
useAppSelector,
|
|
856
|
+
useDomainExtensions,
|
|
857
|
+
useFormatters,
|
|
586
858
|
useHAI3,
|
|
587
|
-
|
|
588
|
-
|
|
859
|
+
useHostAction,
|
|
860
|
+
useMfeBridge,
|
|
861
|
+
useMfeContext,
|
|
862
|
+
useRegisteredPackages,
|
|
589
863
|
useScreenTranslations,
|
|
864
|
+
useSharedProperty,
|
|
590
865
|
useTheme,
|
|
591
866
|
useTranslation
|
|
592
867
|
};
|