@micro-zoe/micro-app 1.0.0-rc.5 → 1.0.0-rc.6

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
@@ -1,6 +1,6 @@
1
1
  <p align="center">
2
2
  <a href="https://micro-zoe.github.io/micro-app/">
3
- <img src="https://zeroing.jd.com/micro-app/media/logo.png" alt="logo" width="200"/>
3
+ <img src="https://micro-zoe.github.io/micro-app/home/assets/logo.png" alt="logo" width="200"/>
4
4
  </a>
5
5
  </p>
6
6
 
package/lib/index.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  // ../../@micro-app/types
5
5
 
6
6
  declare module '@micro-zoe/micro-app' {
7
- export { default, MicroApp, getActiveApps, getAllApps, unmountApp, unmountAllApps, reload, renderApp, getAppStatus } from '@micro-zoe/micro-app/micro_app';
7
+ export { default, MicroApp, getActiveApps, getAllApps, unmountApp, unmountAllApps, reload, renderApp, } 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';
@@ -60,12 +60,6 @@ declare module '@micro-zoe/micro-app/micro_app' {
60
60
  * @returns Promise<boolean>
61
61
  */
62
62
  export function renderApp(options: RenderAppOptions): Promise<boolean>;
63
- /**
64
- * get app state
65
- * @param appName app.name
66
- * @returns app.state
67
- */
68
- export function getAppStatus(appName: string): string | void;
69
63
  export class MicroApp extends EventCenterForBaseApp implements MicroAppBaseType {
70
64
  tagName: string;
71
65
  hasInit: boolean;
@@ -78,7 +72,6 @@ declare module '@micro-zoe/micro-app/micro_app' {
78
72
  getAllApps: typeof getAllApps;
79
73
  reload: typeof reload;
80
74
  renderApp: typeof renderApp;
81
- getAppStatus: typeof getAppStatus;
82
75
  start(options?: OptionsType): void;
83
76
  }
84
77
  const microApp: MicroApp;
@@ -117,7 +110,7 @@ declare module '@micro-zoe/micro-app/prefetch' {
117
110
  }
118
111
 
119
112
  declare module '@micro-zoe/micro-app/libs/utils' {
120
- import { Func, LocationQueryObject, MicroLocation, AttrsType, fiberTasks, MicroAppElementTagNameMap } from '@micro-app/types';
113
+ import { Func, LocationQueryObject, MicroLocation, AttrsType, fiberTasks, MicroAppElementTagNameMap, MicroAppElementInterface } from '@micro-app/types';
121
114
  export const version = "__MICRO_APP_VERSION__";
122
115
  export const isBrowser: boolean;
123
116
  export const globalThis: any;
@@ -157,7 +150,9 @@ declare module '@micro-zoe/micro-app/libs/utils' {
157
150
  export function isDivElement(target: unknown): target is HTMLDivElement;
158
151
  export function isImageElement(target: unknown): target is HTMLImageElement;
159
152
  export function isBaseElement(target: unknown): target is HTMLBaseElement;
153
+ export function isDocumentFragment(target: unknown): target is DocumentFragment;
160
154
  export function isMicroAppBody(target: unknown): target is HTMLElement;
155
+ export function isMicroAppHead(target: unknown): target is HTMLElement;
161
156
  export function isProxyDocument(target: unknown): target is Document;
162
157
  export function isTargetExtension(path: string, suffix: string): boolean;
163
158
  export function includes(target: unknown[], searchElement: unknown, fromIndex?: number): boolean;
@@ -179,6 +174,12 @@ declare module '@micro-zoe/micro-app/libs/utils' {
179
174
  * @param args params
180
175
  */
181
176
  export function defer(fn: Func, ...args: unknown[]): void;
177
+ /**
178
+ * async execution with macro task
179
+ * @param fn callback
180
+ * @param args params
181
+ */
182
+ export function macro(fn: Func, delay?: number, ...args: unknown[]): void;
182
183
  /**
183
184
  * create URL as MicroLocation
184
185
  */
@@ -244,8 +245,19 @@ declare module '@micro-zoe/micro-app/libs/utils' {
244
245
  export function promiseRequestIdle(callback: CallableFunction): Promise<void>;
245
246
  export function setCurrentAppName(appName: string | null): void;
246
247
  export function getCurrentAppName(): string | null;
247
- export function removeDomScope(force?: boolean): void;
248
248
  export function throttleDeferForSetAppName(appName: string): void;
249
+ export function setIframeCurrentAppName(appName: string | null): void;
250
+ export function getIframeCurrentAppName(): string | null;
251
+ export function throttleDeferForIframeAppName(appName: string): void;
252
+ export function getPreventSetState(): boolean;
253
+ /**
254
+ * prevent set appName
255
+ * usage:
256
+ * removeDomScope(true)
257
+ * -----> element scope point to base app <-----
258
+ * removeDomScope(false)
259
+ */
260
+ export function removeDomScope(force?: boolean): void;
249
261
  export function isSafari(): boolean;
250
262
  /**
251
263
  * Create pure elements
@@ -253,11 +265,12 @@ declare module '@micro-zoe/micro-app/libs/utils' {
253
265
  export function pureCreateElement<K extends keyof MicroAppElementTagNameMap>(tagName: K, options?: ElementCreationOptions): MicroAppElementTagNameMap[K];
254
266
  export function isInvalidQuerySelectorKey(key: string): boolean;
255
267
  export function isUniqueElement(key: string): boolean;
268
+ export type RootContainer = HTMLElement & MicroAppElementInterface;
256
269
  /**
257
270
  * get micro-app element
258
271
  * @param target app container
259
272
  */
260
- export function getRootContainer(target: HTMLElement | ShadowRoot): HTMLElement;
273
+ export function getRootContainer(target: HTMLElement | ShadowRoot): RootContainer;
261
274
  /**
262
275
  * trim start & end
263
276
  */
@@ -320,17 +333,13 @@ declare module '@micro-zoe/micro-app/libs/utils' {
320
333
  * @param $dom target node
321
334
  */
322
335
  export function clearDOM($dom: HTMLElement | ShadowRoot | Document): void;
323
- type BaseHTMLElementType = HTMLElement & {
324
- new (): HTMLElement;
325
- prototype: HTMLElement;
326
- };
336
+ export function instanceOf<T extends new (...args: unknown[]) => unknown>(instance: unknown, constructor: T): instance is T extends new (...args: unknown[]) => infer R ? R : boolean;
337
+ export function formatEventType(type: string, appName: string): string;
327
338
  /**
328
- * get HTMLElement from base app
329
- * @returns HTMLElement
339
+ * Is the object empty
340
+ * target maybe number, string, array ...
330
341
  */
331
- export function getBaseHTMLElement(): BaseHTMLElementType;
332
- export function formatEventType(type: string, appName: string): string;
333
- export {};
342
+ export function isEmptyObject(target: unknown): boolean;
334
343
  }
335
344
 
336
345
  declare module '@micro-zoe/micro-app/interact' {