@micro-zoe/micro-app 0.6.2 → 0.8.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/lib/index.d.ts CHANGED
@@ -4,31 +4,48 @@
4
4
  // ../../@micro-app/types
5
5
 
6
6
  declare module '@micro-zoe/micro-app' {
7
- export { default } from '@micro-zoe/micro-app/micro_app';
7
+ export { default, MicroApp, getActiveApps, getAllApps, unmountApp, unmountAllApps, } from '@micro-zoe/micro-app/micro_app';
8
8
  export { default as preFetch, } from '@micro-zoe/micro-app/prefetch';
9
9
  export { removeDomScope, pureCreateElement, version, } from '@micro-zoe/micro-app/libs/utils';
10
10
  export { EventCenterForMicroApp, } from '@micro-zoe/micro-app/interact';
11
- export { getActiveApps, getAllApps, unmountApp, unmountAllApps, } from '@micro-zoe/micro-app/create_app';
12
11
  }
13
12
 
14
13
  declare module '@micro-zoe/micro-app/micro_app' {
15
14
  import type { OptionsType, MicroAppConfigType, lifeCyclesType, plugins, fetchType } from '@micro-app/types';
16
15
  import preFetch from '@micro-zoe/micro-app/prefetch';
17
16
  import { EventCenterForBaseApp } from '@micro-zoe/micro-app/interact';
18
- class MicroApp extends EventCenterForBaseApp implements MicroAppConfigType {
19
- tagName: string;
20
- shadowDOM?: boolean;
21
- destroy?: boolean;
22
- inline?: boolean;
23
- disableScopecss?: boolean;
24
- disableSandbox?: boolean;
25
- macro?: boolean;
26
- ssr?: boolean;
27
- lifeCycles?: lifeCyclesType;
28
- plugins?: plugins;
29
- fetch?: fetchType;
30
- preFetch: typeof preFetch;
31
- start(options?: OptionsType): void;
17
+ /**
18
+ * if app not prefetch & not unmount, then app is active
19
+ * @param excludeHiddenApp exclude hidden keep-alive app, default is false
20
+ * @returns active apps
21
+ */
22
+ export function getActiveApps(excludeHiddenApp?: boolean): string[];
23
+ export function getAllApps(): string[];
24
+ export interface unmountAppParams {
25
+ destroy?: boolean;
26
+ clearAliveState?: boolean;
27
+ }
28
+ /**
29
+ * unmount app by appName
30
+ * @param appName
31
+ * @param options unmountAppParams
32
+ * @returns Promise<void>
33
+ */
34
+ export function unmountApp(appName: string, options?: unmountAppParams): Promise<void>;
35
+ export function unmountAllApps(options?: unmountAppParams): Promise<void>;
36
+ export class MicroApp extends EventCenterForBaseApp implements MicroAppConfigType {
37
+ tagName: string;
38
+ shadowDOM?: boolean;
39
+ destroy?: boolean;
40
+ inline?: boolean;
41
+ disableScopecss?: boolean;
42
+ disableSandbox?: boolean;
43
+ ssr?: boolean;
44
+ lifeCycles?: lifeCyclesType;
45
+ plugins?: plugins;
46
+ fetch?: fetchType;
47
+ preFetch: typeof preFetch;
48
+ start(options?: OptionsType): void;
32
49
  }
33
50
  const _default: MicroApp;
34
51
  export default _default;
@@ -43,13 +60,12 @@ declare module '@micro-zoe/micro-app/prefetch' {
43
60
  * url: string,
44
61
  * disableScopecss?: boolean,
45
62
  * disableSandbox?: boolean,
46
- * macro?: boolean,
47
63
  * },
48
64
  * ...
49
65
  * ])
50
66
  * Note:
51
67
  * 1: preFetch is asynchronous and is performed only when the browser is idle
52
- * 2: disableScopecss, disableSandbox, macro must be same with micro-app element, if conflict, the one who executes first shall prevail
68
+ * 2: disableScopecss, disableSandbox must be same with micro-app element, if conflict, the one who executes first shall prevail
53
69
  * @param apps micro apps
54
70
  */
55
71
  export default function preFetch(apps: prefetchParamList): void;
@@ -62,7 +78,7 @@ declare module '@micro-zoe/micro-app/prefetch' {
62
78
 
63
79
  declare module '@micro-zoe/micro-app/libs/utils' {
64
80
  import type { Func } from '@micro-app/types';
65
- export const version = "__VERSION__";
81
+ export const version = "__MICRO_APP_VERSION__";
66
82
  export const isBrowser: boolean;
67
83
  export const globalThis: any;
68
84
  export function isUndefined(target: unknown): target is undefined;
@@ -75,6 +91,9 @@ declare module '@micro-zoe/micro-app/libs/utils' {
75
91
  export function isPromise(target: unknown): boolean;
76
92
  export function isBoundFunction(target: any): boolean;
77
93
  export function isShadowRoot(target: unknown): boolean;
94
+ export const rawDefineProperty: (o: any, p: string | number | symbol, attributes: PropertyDescriptor & ThisType<any>) => any;
95
+ export const rawDefineProperties: (o: any, properties: PropertyDescriptorMap & ThisType<any>) => any;
96
+ export const rawHasOwnProperty: (v: string | number | symbol) => boolean;
78
97
  /**
79
98
  * format error log
80
99
  * @param msg message
@@ -129,9 +148,9 @@ declare module '@micro-zoe/micro-app/libs/utils' {
129
148
  /**
130
149
  * Get the folder where the link resource is located,
131
150
  * which is used to complete the relative address in the css
132
- * @param linkpath full link address
151
+ * @param linkPath full link address
133
152
  */
134
- export function getLinkFileDir(linkpath: string): string;
153
+ export function getLinkFileDir(linkPath: string): string;
135
154
  /**
136
155
  * promise stream
137
156
  * @param promiseList promise list
@@ -145,6 +164,7 @@ declare module '@micro-zoe/micro-app/libs/utils' {
145
164
  export function unique(array: any[]): any[];
146
165
  export const requestIdleCallback: any;
147
166
  export function setCurrentAppName(appName: string | null): void;
167
+ export function throttleDeferForSetAppName(appName: string): void;
148
168
  export function getCurrentAppName(): string | null;
149
169
  export function removeDomScope(): void;
150
170
  export function isSafari(): boolean;
@@ -166,6 +186,10 @@ declare module '@micro-zoe/micro-app/libs/utils' {
166
186
  * @param target app container
167
187
  */
168
188
  export function getRootContainer(target: HTMLElement | ShadowRoot): HTMLElement;
189
+ /**
190
+ * trim start & end
191
+ */
192
+ export function trim(str: string): string;
169
193
  }
170
194
 
171
195
  declare module '@micro-zoe/micro-app/interact' {
@@ -264,93 +288,14 @@ declare module '@micro-zoe/micro-app/interact' {
264
288
  }
265
289
  /**
266
290
  * Record UMD function before exec umdHookMount
267
- * @param microAppEventCneter
291
+ * @param microAppEventCenter
268
292
  */
269
- export function recordDataCenterSnapshot(microAppEventCneter: EventCenterForMicroApp): void;
293
+ export function recordDataCenterSnapshot(microAppEventCenter: EventCenterForMicroApp): void;
270
294
  /**
271
295
  * Rebind the UMD function of the record before remount
272
- * @param microAppEventCneter instance of EventCenterForMicroApp
296
+ * @param microAppEventCenter instance of EventCenterForMicroApp
273
297
  */
274
- export function rebuildDataCenterSnapshot(microAppEventCneter: EventCenterForMicroApp): void;
298
+ export function rebuildDataCenterSnapshot(microAppEventCenter: EventCenterForMicroApp): void;
275
299
  export {};
276
300
  }
277
301
 
278
- declare module '@micro-zoe/micro-app/create_app' {
279
- import type { AppInterface, sourceType, SandBoxInterface } from '@micro-app/types';
280
- export const appInstanceMap: Map<string, AppInterface>;
281
- export interface CreateAppParam {
282
- name: string;
283
- url: string;
284
- ssrUrl?: string;
285
- scopecss: boolean;
286
- useSandbox: boolean;
287
- macro?: boolean;
288
- inline?: boolean;
289
- baseroute?: string;
290
- container?: HTMLElement | ShadowRoot;
291
- }
292
- export default class CreateApp implements AppInterface {
293
- umdMode: boolean;
294
- isPrefetch: boolean;
295
- name: string;
296
- url: string;
297
- ssrUrl: string;
298
- container: HTMLElement | ShadowRoot | null;
299
- inline: boolean;
300
- scopecss: boolean;
301
- useSandbox: boolean;
302
- macro: boolean;
303
- baseroute: string;
304
- source: sourceType;
305
- sandBox: SandBoxInterface | null;
306
- constructor({ name, url, ssrUrl, container, inline, scopecss, useSandbox, macro, baseroute, }: CreateAppParam);
307
- loadSourceCode(): void;
308
- /**
309
- * When resource is loaded, mount app if it is not prefetch or unmount
310
- */
311
- onLoad(html: HTMLElement): void;
312
- /**
313
- * Error loading HTML
314
- * @param e Error
315
- */
316
- onLoadError(e: Error): void;
317
- /**
318
- * mount app
319
- * @param container app container
320
- * @param inline js runs in inline mode
321
- * @param baseroute route prefix, default is ''
322
- */
323
- mount(container?: HTMLElement | ShadowRoot, inline?: boolean, baseroute?: string): void;
324
- /**
325
- * unmount app
326
- * @param destroy completely destroy, delete cache resources
327
- * @param unmountcb callback of unmount
328
- */
329
- unmount(destroy: boolean, unmountcb?: CallableFunction): void;
330
- actionsForCompletelyDestory(): void;
331
- hiddenKeepAliveApp(): void;
332
- showKeepAliveApp(container: HTMLElement | ShadowRoot): void;
333
- /**
334
- * app rendering error
335
- * @param e Error
336
- */
337
- onerror(e: Error): void;
338
- getAppState(): string;
339
- getKeepAliveState(): string | null;
340
- }
341
- export function getActiveApps(): string[];
342
- export function getAllApps(): string[];
343
- export interface unmountAppParams {
344
- destroy?: boolean;
345
- clearAliveState?: boolean;
346
- }
347
- /**
348
- * unmount app by appname
349
- * @param appName
350
- * @param options unmountAppParams
351
- * @returns Promise<void>
352
- */
353
- export function unmountApp(appName: string, options?: unmountAppParams): Promise<void>;
354
- export function unmountAllApps(options?: unmountAppParams): Promise<void>;
355
- }
356
-