@micro-zoe/micro-app 0.5.3 → 0.7.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/README.zh-cn.md CHANGED
@@ -25,7 +25,7 @@
25
25
  </a>
26
26
  </p>
27
27
 
28
- [English](https://github.com/micro-zoe/micro-app)|简体中文|[官网文档](https://micro-zoe.github.io/micro-app/)|[讨论组](https://github.com/micro-zoe/micro-app/discussions)|[Gitter群聊](https://gitter.im/microzoe/micro-app)
28
+ [English](https://github.com/micro-zoe/micro-app)|简体中文|[官网文档](https://micro-zoe.github.io/micro-app/)|[讨论组](https://github.com/micro-zoe/micro-app/discussions)|[聊天室](https://gitter.im/microzoe/micro-app)
29
29
 
30
30
  # 📖简介
31
31
  micro-app是京东零售推出的一款微前端框架,它基于类WebComponent进行渲染,从组件化的思维实现微前端,旨在降低上手难度、提升工作效率。它是目前接入微前端成本最低的框架,并且提供了JS沙箱、样式隔离、元素隔离、预加载、资源地址补全、插件系统、数据通信等一系列完善的功能。
@@ -44,7 +44,7 @@ micro-app与技术栈无关,对前端框架没有限制,任何框架都可
44
44
  yarn add @micro-zoe/micro-app
45
45
  ```
46
46
 
47
- **2、在入口处引入**
47
+ **2、在入口文件引入**
48
48
  ```js
49
49
  // main.js
50
50
  import microApp from '@micro-zoe/micro-app'
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, } 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
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
@@ -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;
@@ -275,66 +295,3 @@ declare module '@micro-zoe/micro-app/interact' {
275
295
  export {};
276
296
  }
277
297
 
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
- */
328
- unmount(destroy: boolean): void;
329
- actionsForCompletelyDestory(): void;
330
- /**
331
- * app rendering error
332
- * @param e Error
333
- */
334
- onerror(e: Error): void;
335
- getAppStatus(): string;
336
- }
337
- export function getActiveApps(): string[];
338
- export function getAllApps(): string[];
339
- }
340
-