kj-micro-app 1.0.2
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/LICENSE +21 -0
- package/README.md +156 -0
- package/README.zh-cn.md +156 -0
- package/lib/index.d.ts +483 -0
- package/lib/index.esm.js +9419 -0
- package/lib/index.esm.js.map +1 -0
- package/lib/index.min.js +2 -0
- package/lib/index.min.js.map +1 -0
- package/lib/index.umd.js +2 -0
- package/lib/index.umd.js.map +1 -0
- package/package.json +134 -0
- package/polyfill/jsx-custom-event.js +54 -0
- package/polyfill/jsx-custom-event.js.map +1 -0
- package/typings/global.d.ts +582 -0
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
/// <reference path="../typings/global.d.ts" />
|
|
2
|
+
// Generated by dts-bundle v0.7.3
|
|
3
|
+
// Dependencies for this module:
|
|
4
|
+
// ../../@micro-app/types
|
|
5
|
+
|
|
6
|
+
declare module 'bl-micro-app' {
|
|
7
|
+
export { default, MicroApp, getActiveApps, getAllApps, unmountApp, unmountAllApps, reload, renderApp, } from 'bl-micro-app/micro_app';
|
|
8
|
+
export { default as preFetch, } from 'bl-micro-app/prefetch';
|
|
9
|
+
export { removeDomScope, pureCreateElement, version, } from 'bl-micro-app/libs/utils';
|
|
10
|
+
export { EventCenterForMicroApp, } from 'bl-micro-app/interact';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
declare module 'bl-micro-app/micro_app' {
|
|
14
|
+
import { OptionsType, MicroAppBaseType, Router, AppName, Func, lifeCyclesType, MicroAppConfig, GetActiveAppsParam } from '@micro-app/types';
|
|
15
|
+
import preFetch from 'bl-micro-app/prefetch';
|
|
16
|
+
import { EventCenterForBaseApp } from 'bl-micro-app/interact';
|
|
17
|
+
/**
|
|
18
|
+
* if app not prefetch & not unmount, then app is active
|
|
19
|
+
* @param excludeHiddenApp exclude hidden keep-alive app, default is false
|
|
20
|
+
* @param excludePreRender exclude pre render app
|
|
21
|
+
* @returns active apps
|
|
22
|
+
*/
|
|
23
|
+
export function getActiveApps({ excludeHiddenApp, excludePreRender, }?: GetActiveAppsParam): AppName[];
|
|
24
|
+
export function getAllApps(): string[];
|
|
25
|
+
type unmountAppOptions = {
|
|
26
|
+
destroy?: boolean;
|
|
27
|
+
clearAliveState?: boolean;
|
|
28
|
+
clearData?: boolean;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* unmount app by appName
|
|
32
|
+
* @param appName
|
|
33
|
+
* @param options unmountAppOptions
|
|
34
|
+
* @returns Promise<void>
|
|
35
|
+
*/
|
|
36
|
+
export function unmountApp(appName: string, options?: unmountAppOptions): Promise<boolean>;
|
|
37
|
+
export function unmountAllApps(options?: unmountAppOptions): Promise<boolean>;
|
|
38
|
+
/**
|
|
39
|
+
* Re render app from the command line
|
|
40
|
+
* microApp.reload(destroy)
|
|
41
|
+
* @param appName app.name
|
|
42
|
+
* @param destroy unmount app with destroy mode
|
|
43
|
+
* @returns Promise<boolean>
|
|
44
|
+
*/
|
|
45
|
+
export function reload(appName: string, destroy?: boolean): Promise<boolean>;
|
|
46
|
+
interface RenderAppOptions extends MicroAppConfig {
|
|
47
|
+
name: string;
|
|
48
|
+
url: string;
|
|
49
|
+
container: string | Element;
|
|
50
|
+
baseroute?: string;
|
|
51
|
+
'default-page'?: string;
|
|
52
|
+
data?: Record<PropertyKey, unknown>;
|
|
53
|
+
onDataChange?: Func;
|
|
54
|
+
lifeCycles?: lifeCyclesType;
|
|
55
|
+
[key: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Manually render app
|
|
59
|
+
* @param options RenderAppOptions
|
|
60
|
+
* @returns Promise<boolean>
|
|
61
|
+
*/
|
|
62
|
+
export function renderApp(options: RenderAppOptions): Promise<boolean>;
|
|
63
|
+
export class MicroApp extends EventCenterForBaseApp implements MicroAppBaseType {
|
|
64
|
+
tagName: string;
|
|
65
|
+
hasInit: boolean;
|
|
66
|
+
options: OptionsType;
|
|
67
|
+
router: Router;
|
|
68
|
+
preFetch: typeof preFetch;
|
|
69
|
+
unmountApp: typeof unmountApp;
|
|
70
|
+
unmountAllApps: typeof unmountAllApps;
|
|
71
|
+
getActiveApps: typeof getActiveApps;
|
|
72
|
+
getAllApps: typeof getAllApps;
|
|
73
|
+
reload: typeof reload;
|
|
74
|
+
renderApp: typeof renderApp;
|
|
75
|
+
start(options?: OptionsType): void;
|
|
76
|
+
}
|
|
77
|
+
const microApp: MicroApp;
|
|
78
|
+
export default microApp;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
declare module 'bl-micro-app/prefetch' {
|
|
82
|
+
import { prefetchParamList, globalAssetsType } from '@micro-app/types';
|
|
83
|
+
/**
|
|
84
|
+
* preFetch([
|
|
85
|
+
* {
|
|
86
|
+
* name: string,
|
|
87
|
+
* url: string,
|
|
88
|
+
* iframe: boolean,
|
|
89
|
+
* inline: boolean,
|
|
90
|
+
* 'disable-scopecss': boolean,
|
|
91
|
+
* 'disable-sandbox': boolean,
|
|
92
|
+
* level: number,
|
|
93
|
+
* 'default-page': string,
|
|
94
|
+
* 'disable-patch-request': boolean,
|
|
95
|
+
* },
|
|
96
|
+
* ...
|
|
97
|
+
* ])
|
|
98
|
+
* Note:
|
|
99
|
+
* 1: preFetch is async and is performed only when the browser is idle
|
|
100
|
+
* 2: options of prefetch preferably match the config of the micro-app element, although this is not required
|
|
101
|
+
* @param apps micro app options
|
|
102
|
+
* @param delay delay time
|
|
103
|
+
*/
|
|
104
|
+
export default function preFetch(apps: prefetchParamList, delay?: number): void;
|
|
105
|
+
/**
|
|
106
|
+
* load global assets into cache
|
|
107
|
+
* @param assets global assets of js, css
|
|
108
|
+
*/
|
|
109
|
+
export function getGlobalAssets(assets: globalAssetsType): void;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
declare module 'bl-micro-app/libs/utils' {
|
|
113
|
+
import { Func, LocationQueryObject, MicroLocation, AttrsType, fiberTasks, MicroAppElementTagNameMap, MicroAppElementInterface } from '@micro-app/types';
|
|
114
|
+
export const version = "__MICRO_APP_VERSION__";
|
|
115
|
+
export const isBrowser: boolean;
|
|
116
|
+
export const globalThis: any;
|
|
117
|
+
export const noop: () => void;
|
|
118
|
+
export const noopFalse: () => boolean;
|
|
119
|
+
export const isArray: (arg: any) => arg is any[];
|
|
120
|
+
export const assign: {
|
|
121
|
+
<T, U>(target: T, source: U): T & U;
|
|
122
|
+
<T_1, U_1, V>(target: T_1, source1: U_1, source2: V): T_1 & U_1 & V;
|
|
123
|
+
<T_2, U_2, V_1, W>(target: T_2, source1: U_2, source2: V_1, source3: W): T_2 & U_2 & V_1 & W;
|
|
124
|
+
(target: object, ...sources: any[]): any;
|
|
125
|
+
};
|
|
126
|
+
export const rawDefineProperty: (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any;
|
|
127
|
+
export const rawDefineProperties: (o: any, properties: PropertyDescriptorMap & ThisType<any>) => any;
|
|
128
|
+
export const rawToString: () => string;
|
|
129
|
+
export const rawHasOwnProperty: (v: string | number | symbol) => boolean;
|
|
130
|
+
export const toTypeString: (value: unknown) => string;
|
|
131
|
+
export function isUndefined(target: unknown): target is undefined;
|
|
132
|
+
export function isNull(target: unknown): target is null;
|
|
133
|
+
export function isString(target: unknown): target is string;
|
|
134
|
+
export function isBoolean(target: unknown): target is boolean;
|
|
135
|
+
export function isNumber(target: unknown): target is Number;
|
|
136
|
+
export function isFunction(target: unknown): target is Function;
|
|
137
|
+
export function isPlainObject<T = Record<PropertyKey, unknown>>(target: unknown): target is T;
|
|
138
|
+
export function isObject(target: unknown): target is Object;
|
|
139
|
+
export function isPromise(target: unknown): target is Promise<unknown>;
|
|
140
|
+
export function isBoundFunction(target: unknown): boolean;
|
|
141
|
+
export function isConstructor(target: unknown): boolean;
|
|
142
|
+
export function isShadowRoot(target: unknown): target is ShadowRoot;
|
|
143
|
+
export function isURL(target: unknown): target is URL;
|
|
144
|
+
export function isElement(target: unknown): target is Element;
|
|
145
|
+
export function isNode(target: unknown): target is Node;
|
|
146
|
+
export function isCanvasElement(target: unknown): target is HTMLCanvasElement;
|
|
147
|
+
export function isAnchorElement(target: unknown): target is HTMLAnchorElement;
|
|
148
|
+
export function isAudioElement(target: unknown): target is HTMLAudioElement;
|
|
149
|
+
export function isVideoElement(target: unknown): target is HTMLVideoElement;
|
|
150
|
+
export function isLinkElement(target: unknown): target is HTMLLinkElement;
|
|
151
|
+
export function isBodyElement(target: unknown): target is HTMLBodyElement;
|
|
152
|
+
export function isStyleElement(target: unknown): target is HTMLStyleElement;
|
|
153
|
+
export function isScriptElement(target: unknown): target is HTMLScriptElement;
|
|
154
|
+
export function isIFrameElement(target: unknown): target is HTMLIFrameElement;
|
|
155
|
+
export function isDivElement(target: unknown): target is HTMLDivElement;
|
|
156
|
+
export function isImageElement(target: unknown): target is HTMLImageElement;
|
|
157
|
+
export function isBaseElement(target: unknown): target is HTMLBaseElement;
|
|
158
|
+
export function isDocumentFragment(target: unknown): target is DocumentFragment;
|
|
159
|
+
export function isDocumentShadowRoot(target: unknown): target is DocumentFragment;
|
|
160
|
+
export function isMicroAppBody(target: unknown): target is HTMLElement;
|
|
161
|
+
export function isMicroAppHead(target: unknown): target is HTMLElement;
|
|
162
|
+
export function isWebComponentElement(target: unknown): boolean;
|
|
163
|
+
export function isProxyDocument(target: unknown): target is Document;
|
|
164
|
+
export function isTargetExtension(path: string, suffix: string): boolean;
|
|
165
|
+
export function includes(target: unknown[], searchElement: unknown, fromIndex?: number): boolean;
|
|
166
|
+
/**
|
|
167
|
+
* format error log
|
|
168
|
+
* @param msg message
|
|
169
|
+
* @param appName app name, default is null
|
|
170
|
+
*/
|
|
171
|
+
export function logError(msg: unknown, appName?: string | null, ...rest: unknown[]): void;
|
|
172
|
+
/**
|
|
173
|
+
* format warn log
|
|
174
|
+
* @param msg message
|
|
175
|
+
* @param appName app name, default is null
|
|
176
|
+
*/
|
|
177
|
+
export function logWarn(msg: unknown, appName?: string | null, ...rest: unknown[]): void;
|
|
178
|
+
/**
|
|
179
|
+
* async execution
|
|
180
|
+
* @param fn callback
|
|
181
|
+
* @param args params
|
|
182
|
+
*/
|
|
183
|
+
export function defer(fn: Func, ...args: unknown[]): void;
|
|
184
|
+
/**
|
|
185
|
+
* async execution with macro task
|
|
186
|
+
* @param fn callback
|
|
187
|
+
* @param args params
|
|
188
|
+
*/
|
|
189
|
+
export function macro(fn: Func, delay?: number, ...args: unknown[]): void;
|
|
190
|
+
/**
|
|
191
|
+
* create URL as MicroLocation
|
|
192
|
+
*/
|
|
193
|
+
export const createURL: (path: string | URL, base?: string | undefined) => MicroLocation;
|
|
194
|
+
/**
|
|
195
|
+
* Add address protocol
|
|
196
|
+
* @param url address
|
|
197
|
+
*/
|
|
198
|
+
export function addProtocol(url: string): string;
|
|
199
|
+
/**
|
|
200
|
+
* format URL address
|
|
201
|
+
* note the scenes:
|
|
202
|
+
* 1. micro-app -> attributeChangedCallback
|
|
203
|
+
* 2. preFetch
|
|
204
|
+
*/
|
|
205
|
+
export function formatAppURL(url: string | null, appName?: string | null): string;
|
|
206
|
+
/**
|
|
207
|
+
* format name
|
|
208
|
+
* note the scenes:
|
|
209
|
+
* 1. micro-app -> attributeChangedCallback
|
|
210
|
+
* 2. event_center -> EventCenterForMicroApp -> constructor
|
|
211
|
+
* 3. event_center -> EventCenterForBaseApp -> all methods
|
|
212
|
+
* 4. preFetch
|
|
213
|
+
* 5. plugins
|
|
214
|
+
* 6. router api (push, replace)
|
|
215
|
+
*/
|
|
216
|
+
export function formatAppName(name: string | null): string;
|
|
217
|
+
/**
|
|
218
|
+
* Get valid address, such as
|
|
219
|
+
* 1. https://domain/xx/xx.html to https://domain/xx/
|
|
220
|
+
* 2. https://domain/xx to https://domain/xx/
|
|
221
|
+
* @param url app.url
|
|
222
|
+
*/
|
|
223
|
+
export function getEffectivePath(url: string): string;
|
|
224
|
+
/**
|
|
225
|
+
* Complete address
|
|
226
|
+
* @param path address
|
|
227
|
+
* @param baseURI base url(app.url)
|
|
228
|
+
*/
|
|
229
|
+
export function CompletionPath(path: string, baseURI: string): string;
|
|
230
|
+
/**
|
|
231
|
+
* Get the folder where the link resource is located,
|
|
232
|
+
* which is used to complete the relative address in the css
|
|
233
|
+
* @param linkPath full link address
|
|
234
|
+
*/
|
|
235
|
+
export function getLinkFileDir(linkPath: string): string;
|
|
236
|
+
/**
|
|
237
|
+
* promise stream
|
|
238
|
+
* @param promiseList promise list
|
|
239
|
+
* @param successCb success callback
|
|
240
|
+
* @param errorCb failed callback
|
|
241
|
+
* @param finallyCb finally callback
|
|
242
|
+
*/
|
|
243
|
+
export function promiseStream<T>(promiseList: Array<Promise<T> | T>, successCb: CallableFunction, errorCb: CallableFunction, finallyCb?: CallableFunction): void;
|
|
244
|
+
export function isSupportModuleScript(): boolean;
|
|
245
|
+
export function createNonceSrc(): string;
|
|
246
|
+
export function unique(array: any[]): any[];
|
|
247
|
+
export const requestIdleCallback: any;
|
|
248
|
+
/**
|
|
249
|
+
* Wrap requestIdleCallback with promise
|
|
250
|
+
* Exec callback when browser idle
|
|
251
|
+
*/
|
|
252
|
+
export function promiseRequestIdle(callback: CallableFunction): Promise<void>;
|
|
253
|
+
export function setCurrentAppName(appName: string | null): void;
|
|
254
|
+
export function getCurrentAppName(): string | null;
|
|
255
|
+
export function throttleDeferForSetAppName(appName: string): void;
|
|
256
|
+
export function setIframeCurrentAppName(appName: string | null): void;
|
|
257
|
+
export function getIframeCurrentAppName(): string | null;
|
|
258
|
+
export function throttleDeferForIframeAppName(appName: string): void;
|
|
259
|
+
export function getPreventSetState(): boolean;
|
|
260
|
+
/**
|
|
261
|
+
* prevent set appName
|
|
262
|
+
* usage:
|
|
263
|
+
* removeDomScope(true)
|
|
264
|
+
* -----> element scope point to base app <-----
|
|
265
|
+
* removeDomScope(false)
|
|
266
|
+
*/
|
|
267
|
+
export function removeDomScope(force?: boolean): void;
|
|
268
|
+
export function isSafari(): boolean;
|
|
269
|
+
/**
|
|
270
|
+
* Create pure elements
|
|
271
|
+
*/
|
|
272
|
+
export function pureCreateElement<K extends keyof MicroAppElementTagNameMap>(tagName: K, options?: ElementCreationOptions): MicroAppElementTagNameMap[K];
|
|
273
|
+
export function isInvalidQuerySelectorKey(key: string): boolean;
|
|
274
|
+
export function isUniqueElement(key: string): boolean;
|
|
275
|
+
export type RootContainer = HTMLElement & MicroAppElementInterface;
|
|
276
|
+
/**
|
|
277
|
+
* get micro-app element
|
|
278
|
+
* @param target app container
|
|
279
|
+
*/
|
|
280
|
+
export function getRootContainer(target: HTMLElement | ShadowRoot): RootContainer;
|
|
281
|
+
/**
|
|
282
|
+
* trim start & end
|
|
283
|
+
*/
|
|
284
|
+
export function trim(str: string): string;
|
|
285
|
+
export function isFireFox(): boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Transforms a queryString into object.
|
|
288
|
+
* @param search - search string to parse
|
|
289
|
+
* @returns a query object
|
|
290
|
+
*/
|
|
291
|
+
export function parseQuery(search: string): LocationQueryObject;
|
|
292
|
+
/**
|
|
293
|
+
* Transforms an object to query string
|
|
294
|
+
* @param queryObject - query object to stringify
|
|
295
|
+
* @returns query string without the leading `?`
|
|
296
|
+
*/
|
|
297
|
+
export function stringifyQuery(queryObject: LocationQueryObject): string;
|
|
298
|
+
/**
|
|
299
|
+
* Register or unregister callback/guard with Set
|
|
300
|
+
*/
|
|
301
|
+
export function useSetRecord<T>(): {
|
|
302
|
+
add: (handler: T) => () => boolean;
|
|
303
|
+
list: () => Set<T>;
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* record data with Map
|
|
307
|
+
*/
|
|
308
|
+
export function useMapRecord<T>(): {
|
|
309
|
+
add: (key: PropertyKey, value: T) => () => boolean;
|
|
310
|
+
get: (key: PropertyKey) => T | undefined;
|
|
311
|
+
delete: (key: PropertyKey) => boolean;
|
|
312
|
+
};
|
|
313
|
+
export function getAttributes(element: Element): AttrsType;
|
|
314
|
+
/**
|
|
315
|
+
* if fiberTasks exist, wrap callback with promiseRequestIdle
|
|
316
|
+
* if not, execute callback
|
|
317
|
+
* @param fiberTasks fiber task list
|
|
318
|
+
* @param callback action callback
|
|
319
|
+
*/
|
|
320
|
+
export function injectFiberTask(fiberTasks: fiberTasks, callback: CallableFunction): void;
|
|
321
|
+
/**
|
|
322
|
+
* serial exec fiber task of link, style, script
|
|
323
|
+
* @param tasks task array or null
|
|
324
|
+
*/
|
|
325
|
+
export function serialExecFiberTasks(tasks: fiberTasks): Promise<void> | null;
|
|
326
|
+
/**
|
|
327
|
+
* inline script start with inline-xxx
|
|
328
|
+
* @param address source address
|
|
329
|
+
*/
|
|
330
|
+
export function isInlineScript(address: string): boolean;
|
|
331
|
+
/**
|
|
332
|
+
* call function with try catch
|
|
333
|
+
* @param fn target function
|
|
334
|
+
* @param appName app.name
|
|
335
|
+
* @param args arguments
|
|
336
|
+
*/
|
|
337
|
+
export function execMicroAppGlobalHook(fn: Func | null, appName: string, hookName: string, ...args: unknown[]): void;
|
|
338
|
+
/**
|
|
339
|
+
* remove all childNode from target node
|
|
340
|
+
* @param $dom target node
|
|
341
|
+
*/
|
|
342
|
+
export function clearDOM($dom: HTMLElement | ShadowRoot | Document): void;
|
|
343
|
+
export function instanceOf<T extends new (...args: unknown[]) => unknown>(instance: unknown, constructor: T): instance is T extends new (...args: unknown[]) => infer R ? R : boolean;
|
|
344
|
+
export function formatEventType(type: string, appName: string): string;
|
|
345
|
+
/**
|
|
346
|
+
* Is the object empty
|
|
347
|
+
* target maybe number, string, array ...
|
|
348
|
+
*/
|
|
349
|
+
export function isEmptyObject(target: unknown): boolean;
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
declare module 'bl-micro-app/interact' {
|
|
353
|
+
import { CallableFunctionForInteract } from '@micro-app/types';
|
|
354
|
+
class EventCenterForGlobal {
|
|
355
|
+
/**
|
|
356
|
+
* add listener of global data
|
|
357
|
+
* @param cb listener
|
|
358
|
+
* @param autoTrigger If there is cached data when first bind listener, whether it needs to trigger, default is false
|
|
359
|
+
*/
|
|
360
|
+
addGlobalDataListener(cb: CallableFunctionForInteract, autoTrigger?: boolean): void;
|
|
361
|
+
/**
|
|
362
|
+
* remove listener of global data
|
|
363
|
+
* @param cb listener
|
|
364
|
+
*/
|
|
365
|
+
removeGlobalDataListener(cb: CallableFunctionForInteract): void;
|
|
366
|
+
/**
|
|
367
|
+
* dispatch global data
|
|
368
|
+
* @param data data
|
|
369
|
+
*/
|
|
370
|
+
setGlobalData(data: Record<PropertyKey, unknown>, nextStep?: CallableFunction, force?: boolean): void;
|
|
371
|
+
forceSetGlobalData(data: Record<PropertyKey, unknown>, nextStep?: CallableFunction): void;
|
|
372
|
+
/**
|
|
373
|
+
* get global data
|
|
374
|
+
*/
|
|
375
|
+
getGlobalData(): Record<PropertyKey, unknown> | null;
|
|
376
|
+
/**
|
|
377
|
+
* clear global data
|
|
378
|
+
*/
|
|
379
|
+
clearGlobalData(): void;
|
|
380
|
+
/**
|
|
381
|
+
* clear all listener of global data
|
|
382
|
+
* if appName exists, only the specified functions is cleared
|
|
383
|
+
* if appName not exists, only clear the base app functions
|
|
384
|
+
*/
|
|
385
|
+
clearGlobalDataListener(): void;
|
|
386
|
+
}
|
|
387
|
+
export class EventCenterForBaseApp extends EventCenterForGlobal {
|
|
388
|
+
/**
|
|
389
|
+
* add listener
|
|
390
|
+
* @param appName app.name
|
|
391
|
+
* @param cb listener
|
|
392
|
+
* @param autoTrigger If there is cached data when first bind listener, whether it needs to trigger, default is false
|
|
393
|
+
*/
|
|
394
|
+
addDataListener(appName: string, cb: CallableFunction, autoTrigger?: boolean): void;
|
|
395
|
+
/**
|
|
396
|
+
* remove listener
|
|
397
|
+
* @param appName app.name
|
|
398
|
+
* @param cb listener
|
|
399
|
+
*/
|
|
400
|
+
removeDataListener(appName: string, cb: CallableFunction): void;
|
|
401
|
+
/**
|
|
402
|
+
* get data from micro app or base app
|
|
403
|
+
* @param appName app.name
|
|
404
|
+
* @param fromBaseApp whether get data from base app, default is false
|
|
405
|
+
*/
|
|
406
|
+
getData(appName: string, fromBaseApp?: boolean): Record<PropertyKey, unknown> | null;
|
|
407
|
+
/**
|
|
408
|
+
* Dispatch data to the specified micro app
|
|
409
|
+
* @param appName app.name
|
|
410
|
+
* @param data data
|
|
411
|
+
*/
|
|
412
|
+
setData(appName: string, data: Record<PropertyKey, unknown>, nextStep?: CallableFunction, force?: boolean): void;
|
|
413
|
+
forceSetData(appName: string, data: Record<PropertyKey, unknown>, nextStep?: CallableFunction): void;
|
|
414
|
+
/**
|
|
415
|
+
* clear data from base app
|
|
416
|
+
* @param appName app.name
|
|
417
|
+
* @param fromBaseApp whether clear data from child app, default is true
|
|
418
|
+
*/
|
|
419
|
+
clearData(appName: string, fromBaseApp?: boolean): void;
|
|
420
|
+
/**
|
|
421
|
+
* clear all listener for specified micro app
|
|
422
|
+
* @param appName app.name
|
|
423
|
+
*/
|
|
424
|
+
clearDataListener(appName: string): void;
|
|
425
|
+
changeEventAppName(newAppName: string, oldAppName: string): void;
|
|
426
|
+
}
|
|
427
|
+
export class EventCenterForMicroApp extends EventCenterForGlobal {
|
|
428
|
+
appName: string;
|
|
429
|
+
umdDataListeners?: {
|
|
430
|
+
global: Set<CallableFunctionForInteract>;
|
|
431
|
+
normal: Set<CallableFunctionForInteract>;
|
|
432
|
+
};
|
|
433
|
+
constructor(appName: string);
|
|
434
|
+
/**
|
|
435
|
+
* add listener, monitor the data sent by the base app
|
|
436
|
+
* @param cb listener
|
|
437
|
+
* @param autoTrigger If there is cached data when first bind listener, whether it needs to trigger, default is false
|
|
438
|
+
*/
|
|
439
|
+
addDataListener(cb: CallableFunctionForInteract, autoTrigger?: boolean): void;
|
|
440
|
+
/**
|
|
441
|
+
* remove listener
|
|
442
|
+
* @param cb listener
|
|
443
|
+
*/
|
|
444
|
+
removeDataListener(cb: CallableFunctionForInteract): void;
|
|
445
|
+
/**
|
|
446
|
+
* get data from base app
|
|
447
|
+
*/
|
|
448
|
+
getData(fromBaseApp?: boolean): Record<PropertyKey, unknown> | null;
|
|
449
|
+
/**
|
|
450
|
+
* dispatch data to base app
|
|
451
|
+
* @param data data
|
|
452
|
+
*/
|
|
453
|
+
dispatch(data: Record<PropertyKey, unknown>, nextStep?: CallableFunction, force?: boolean): void;
|
|
454
|
+
forceDispatch(data: Record<PropertyKey, unknown>, nextStep?: CallableFunction): void;
|
|
455
|
+
/**
|
|
456
|
+
* clear data from child app
|
|
457
|
+
* @param fromBaseApp whether clear data from base app, default is false
|
|
458
|
+
*/
|
|
459
|
+
clearData(fromBaseApp?: boolean): void;
|
|
460
|
+
/**
|
|
461
|
+
* clear all listeners
|
|
462
|
+
*/
|
|
463
|
+
clearDataListener(): void;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Record UMD function before exec umdHookMount
|
|
467
|
+
* NOTE: record maybe call twice when unmount prerender, keep-alive app manually with umd mode
|
|
468
|
+
* @param microAppEventCenter instance of EventCenterForMicroApp
|
|
469
|
+
*/
|
|
470
|
+
export function recordDataCenterSnapshot(microAppEventCenter: EventCenterForMicroApp): void;
|
|
471
|
+
/**
|
|
472
|
+
* Rebind the UMD function of the record before remount
|
|
473
|
+
* @param microAppEventCenter instance of EventCenterForMicroApp
|
|
474
|
+
*/
|
|
475
|
+
export function rebuildDataCenterSnapshot(microAppEventCenter: EventCenterForMicroApp): void;
|
|
476
|
+
/**
|
|
477
|
+
* delete umdDataListeners from microAppEventCenter
|
|
478
|
+
* @param microAppEventCenter instance of EventCenterForMicroApp
|
|
479
|
+
*/
|
|
480
|
+
export function resetDataCenterSnapshot(microAppEventCenter: EventCenterForMicroApp): void;
|
|
481
|
+
export {};
|
|
482
|
+
}
|
|
483
|
+
|