@micro-zoe/micro-app 0.5.1 → 0.6.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 CHANGED
@@ -57,11 +57,8 @@ microApp.start()
57
57
  ```html
58
58
  <!-- my-page.vue -->
59
59
  <template>
60
- <div>
61
- <h1>micro application</h1>
62
- <!-- 👇 name is the application name, url is the html address -->
63
- <micro-app name='app1' url='http://localhost:3000/'></micro-app>
64
- </div>
60
+ <!-- 👇 name is the app name, url is the app address -->
61
+ <micro-app name='my-app' url='http://localhost:3000/'></micro-app>
65
62
  </template>
66
63
  ```
67
64
 
@@ -145,7 +142,13 @@ For more commands, see [DEVELP](https://github.com/micro-zoe/micro-app/blob/mast
145
142
  <details>
146
143
  <summary>Does it support vite?</summary>
147
144
 
148
- Yes, please see [adapt vite](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/advanced?id=_2%e3%80%81%e9%80%82%e9%85%8dvite) for details.
145
+ Yes, please see [adapt vite](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/framework/vite) for details.
146
+ </details>
147
+
148
+ <details>
149
+ <summary>Does it support ssr?</summary>
150
+
151
+ Yes, please see [nextjs](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/framework/nextjs), [nuxtjs](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/framework/nuxtjs) for details.
149
152
  </details>
150
153
 
151
154
  # Contributors
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'
@@ -56,11 +56,8 @@ microApp.start()
56
56
  ```html
57
57
  <!-- my-page.vue -->
58
58
  <template>
59
- <div>
60
- <h1>子应用</h1>
61
- <!-- 👇 name为应用名称,url为html地址 -->
62
- <micro-app name='app1' url='http://localhost:3000/'></micro-app>
63
- </div>
59
+ <!-- 👇 name为应用名称,url为应用地址 -->
60
+ <micro-app name='my-app' url='http://localhost:3000/'></micro-app>
64
61
  </template>
65
62
  ```
66
63
 
@@ -146,7 +143,13 @@ yarn start # 访问 http://localhost:3000
146
143
  <details>
147
144
  <summary>支持vite吗?</summary>
148
145
 
149
- 支持,详情请查看[适配vite](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/advanced?id=_2%e3%80%81%e9%80%82%e9%85%8dvite)
146
+ 支持,详情请查看[适配vite](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/framework/vite)
147
+ </details>
148
+
149
+ <details>
150
+ <summary>支持ssr吗?</summary>
151
+
152
+ 支持,详情请查看[nextjs](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/framework/nextjs)、[nuxtjs](https://micro-zoe.github.io/micro-app/docs.html#/zh-cn/framework/nuxtjs)
150
153
  </details>
151
154
 
152
155
  # 贡献者们
package/lib/index.d.ts CHANGED
@@ -8,8 +8,7 @@ declare module '@micro-zoe/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, // version >= 0.5.1
12
- getAllApps, } from './create_app';
11
+ export { getActiveApps, getAllApps, unmountApp, unmountAllApps, } from '@micro-zoe/micro-app/create_app';
13
12
  }
14
13
 
15
14
  declare module '@micro-zoe/micro-app/micro_app' {
@@ -24,6 +23,7 @@ declare module '@micro-zoe/micro-app/micro_app' {
24
23
  disableScopecss?: boolean;
25
24
  disableSandbox?: boolean;
26
25
  macro?: boolean;
26
+ ssr?: boolean;
27
27
  lifeCycles?: lifeCyclesType;
28
28
  plugins?: plugins;
29
29
  fetch?: fetchType;
@@ -275,3 +275,82 @@ declare module '@micro-zoe/micro-app/interact' {
275
275
  export {};
276
276
  }
277
277
 
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
+