@vnb/mfe-events 0.0.1-rc.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/README.md +850 -0
- package/dist/bus.d.ts +29 -0
- package/dist/bus.d.ts.map +1 -0
- package/dist/constants.d.ts +48 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +852 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +837 -0
- package/dist/index.mjs.map +1 -0
- package/dist/index.umd.js +858 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/plugin.d.ts +141 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/transport.d.ts +56 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/types.d.ts +157 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +62 -0
package/dist/bus.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @xxxx/mfe-events — Type-safe Event Bus
|
|
3
|
+
*
|
|
4
|
+
* Provides compile-time type checking for event names and payloads.
|
|
5
|
+
* Wraps Transport with generic type constraints.
|
|
6
|
+
*/
|
|
7
|
+
import type { Transport } from './transport';
|
|
8
|
+
export declare class Bus<T extends Record<string, any>> {
|
|
9
|
+
private transport;
|
|
10
|
+
constructor(transport: Transport);
|
|
11
|
+
/**
|
|
12
|
+
* Emit an event with type-safe payload
|
|
13
|
+
*/
|
|
14
|
+
emit<K extends keyof T>(event: K, data: T[K]): void;
|
|
15
|
+
/**
|
|
16
|
+
* Subscribe to an event with type-safe handler
|
|
17
|
+
* Returns unsubscribe function
|
|
18
|
+
*/
|
|
19
|
+
on<K extends keyof T>(event: K, handler: (data: T[K]) => void, options?: {
|
|
20
|
+
priority?: number;
|
|
21
|
+
once?: boolean;
|
|
22
|
+
}): () => void;
|
|
23
|
+
/**
|
|
24
|
+
* Subscribe to an event once
|
|
25
|
+
* Returns unsubscribe function
|
|
26
|
+
*/
|
|
27
|
+
once<K extends keyof T>(event: K, handler: (data: T[K]) => void): () => void;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=bus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bus.d.ts","sourceRoot":"","sources":["../src/bus.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,qBAAa,GAAG,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAChC,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAExC;;OAEG;IACH,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAInD;;;OAGG;IACH,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,EAClB,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,EAC7B,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAA;KAAE,GAC9C,MAAM,IAAI;IAOb;;;OAGG;IACH,IAAI,CAAC,CAAC,SAAS,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI;CAO7E"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @xxxx/mfe-events — Event Constants
|
|
3
|
+
*
|
|
4
|
+
* Three scopes:
|
|
5
|
+
* - EvtShl: Shell internal (no window, memory only)
|
|
6
|
+
* - EvtMfe: Cross-app (Shell + Remote Apps)
|
|
7
|
+
* - EvtApp: Remote App internal (framework-specific)
|
|
8
|
+
*
|
|
9
|
+
* Naming convention: {scope}:{domain}-{action}
|
|
10
|
+
* - State/notification events: must have -{action} suffix
|
|
11
|
+
* - Event markers (error, shell-ready, raw): no suffix
|
|
12
|
+
*/
|
|
13
|
+
export declare const EvtShl: {
|
|
14
|
+
readonly TabOverflow: "shl:tab-overflow";
|
|
15
|
+
readonly TabClose: "shl:tab-close";
|
|
16
|
+
readonly RouteReuse: "shl:route-reuse";
|
|
17
|
+
readonly AuthSync: "shl:auth-sync";
|
|
18
|
+
readonly StateSync: "shl:state-sync";
|
|
19
|
+
readonly AppMounted: "shl:app-mounted";
|
|
20
|
+
readonly AppUnmounted: "shl:app-unmounted";
|
|
21
|
+
};
|
|
22
|
+
export declare const EvtMfe: {
|
|
23
|
+
readonly ThemeUpdate: "mfe:theme-update";
|
|
24
|
+
readonly LocaleUpdate: "mfe:locale-update";
|
|
25
|
+
readonly BreakpointUpdate: "mfe:breakpoint-update";
|
|
26
|
+
readonly StateUpdate: "mfe:state-update";
|
|
27
|
+
readonly ShellReady: "mfe:shell-ready";
|
|
28
|
+
readonly Error: "mfe:error";
|
|
29
|
+
readonly Raw: "mfe:raw";
|
|
30
|
+
readonly Custom: "mfe:raw";
|
|
31
|
+
readonly AuthLogin: "mfe:auth-login";
|
|
32
|
+
readonly AuthLogout: "mfe:auth-logout";
|
|
33
|
+
readonly AuthTokenUpdate: "mfe:auth-token-update";
|
|
34
|
+
readonly AuthTokenClear: "mfe:auth-token-clear";
|
|
35
|
+
readonly AuthPermissionUpdate: "mfe:auth-permission-update";
|
|
36
|
+
readonly AuthExpired: "mfe:auth-expired";
|
|
37
|
+
readonly RouteNavigate: "mfe:route-navigate";
|
|
38
|
+
readonly RouteRefresh: "mfe:route-refresh";
|
|
39
|
+
readonly RouteChange: "mfe:route-change";
|
|
40
|
+
readonly LifecycleAppClose: "mfe:lifecycle-app-close";
|
|
41
|
+
readonly LifecycleAppReady: "mfe:lifecycle-app-ready";
|
|
42
|
+
readonly LifecycleAppUnmount: "mfe:lifecycle-app-unmount";
|
|
43
|
+
readonly NotifyShow: "mfe:notify-show";
|
|
44
|
+
readonly NotifyClose: "mfe:notify-close";
|
|
45
|
+
readonly NotifyCloseAll: "mfe:notify-close-all";
|
|
46
|
+
};
|
|
47
|
+
export declare function EvtApp(appId: string, name: string): `app:${string}-${string}`;
|
|
48
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,eAAO,MAAM,MAAM;;;;;;;;CAQT,CAAC;AAKX,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;CAiCT,CAAC;AAKX,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,MAAM,IAAI,MAAM,EAAE,CAE7E"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @xxxx/mfe-events — Micro Frontend Event Plugin
|
|
3
|
+
*
|
|
4
|
+
* Unified event communication for Module Federation / Native Federation / iframe architectures.
|
|
5
|
+
*
|
|
6
|
+
* Features:
|
|
7
|
+
* - Three scopes: EvtShl (Shell internal), EvtMfe (cross-app), EvtApp (Remote App internal)
|
|
8
|
+
* - Type-safe event bus with compile-time checking
|
|
9
|
+
* - Automatic Transport adaptation (CustomEvent for MF, postMessage for iframe)
|
|
10
|
+
* - Plugin API for Remote App registration and communication
|
|
11
|
+
* - Notification API with fallback support
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import mfeEventPlugin, { mfeBus, shlBus } from '@xxxx/mfe-events'
|
|
16
|
+
* import { EvtMfe, EvtShl, EvtApp } from '@xxxx/mfe-events'
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export { MemoryTransport, WindowTransport, PostMessageTransport, IframeProxyTransport } from './transport';
|
|
20
|
+
export type { Transport } from './transport';
|
|
21
|
+
export { Bus } from './bus';
|
|
22
|
+
export { EvtShl, EvtMfe, EvtApp } from './constants';
|
|
23
|
+
export type { PayloadShl, PayloadMfe, PayloadApp, NotificationType, NotificationConfig, AppType, AppMeta, PluginOptions, } from './types';
|
|
24
|
+
export { mfeEventPlugin } from './plugin';
|
|
25
|
+
export type { default as MfeEventPlugin } from './plugin';
|
|
26
|
+
export { mfeEventPlugin as default } from './plugin';
|
|
27
|
+
import { Bus } from './bus';
|
|
28
|
+
import type { PayloadShl, PayloadMfe } from './types';
|
|
29
|
+
/**
|
|
30
|
+
* Shell internal bus — isolated, does not touch window
|
|
31
|
+
* Use for Shell-internal state synchronization
|
|
32
|
+
*/
|
|
33
|
+
export declare const shlBus: Bus<PayloadShl>;
|
|
34
|
+
export declare const mfeBus: Bus<PayloadMfe>;
|
|
35
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC3G,YAAY,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAG7C,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAGrD,YAAY,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,kBAAkB,EAClB,OAAO,EACP,OAAO,EACP,aAAa,GACd,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,YAAY,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,EAAE,cAAc,IAAI,OAAO,EAAE,MAAM,UAAU,CAAC;AAOrD,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAE5B,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,MAAM,iBAA6C,CAAC;AAwBjE,eAAO,MAAM,MAAM,iBAAiB,CAAC"}
|