@micro-zoe/micro-app 1.0.0-rc.4 → 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,8 +150,11 @@ 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;
157
+ export function isTargetExtension(path: string, suffix: string): boolean;
162
158
  export function includes(target: unknown[], searchElement: unknown, fromIndex?: number): boolean;
163
159
  /**
164
160
  * format error log
@@ -178,6 +174,12 @@ declare module '@micro-zoe/micro-app/libs/utils' {
178
174
  * @param args params
179
175
  */
180
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;
181
183
  /**
182
184
  * create URL as MicroLocation
183
185
  */
@@ -206,7 +208,9 @@ declare module '@micro-zoe/micro-app/libs/utils' {
206
208
  */
207
209
  export function formatAppName(name: string | null): string;
208
210
  /**
209
- * Get valid address, such as https://xxx/xx/xx.html to https://xxx/xx/
211
+ * Get valid address, such as
212
+ * 1. https://domain/xx/xx.html to https://domain/xx/
213
+ * 2. https://domain/xx to https://domain/xx/
210
214
  * @param url app.url
211
215
  */
212
216
  export function getEffectivePath(url: string): string;
@@ -241,8 +245,19 @@ declare module '@micro-zoe/micro-app/libs/utils' {
241
245
  export function promiseRequestIdle(callback: CallableFunction): Promise<void>;
242
246
  export function setCurrentAppName(appName: string | null): void;
243
247
  export function getCurrentAppName(): string | null;
244
- export function removeDomScope(force?: boolean): void;
245
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;
246
261
  export function isSafari(): boolean;
247
262
  /**
248
263
  * Create pure elements
@@ -250,11 +265,12 @@ declare module '@micro-zoe/micro-app/libs/utils' {
250
265
  export function pureCreateElement<K extends keyof MicroAppElementTagNameMap>(tagName: K, options?: ElementCreationOptions): MicroAppElementTagNameMap[K];
251
266
  export function isInvalidQuerySelectorKey(key: string): boolean;
252
267
  export function isUniqueElement(key: string): boolean;
268
+ export type RootContainer = HTMLElement & MicroAppElementInterface;
253
269
  /**
254
270
  * get micro-app element
255
271
  * @param target app container
256
272
  */
257
- export function getRootContainer(target: HTMLElement | ShadowRoot): HTMLElement;
273
+ export function getRootContainer(target: HTMLElement | ShadowRoot): RootContainer;
258
274
  /**
259
275
  * trim start & end
260
276
  */
@@ -317,16 +333,13 @@ declare module '@micro-zoe/micro-app/libs/utils' {
317
333
  * @param $dom target node
318
334
  */
319
335
  export function clearDOM($dom: HTMLElement | ShadowRoot | Document): void;
320
- type BaseHTMLElementType = HTMLElement & {
321
- new (): HTMLElement;
322
- prototype: HTMLElement;
323
- };
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;
324
338
  /**
325
- * get HTMLElement from base app
326
- * @returns HTMLElement
339
+ * Is the object empty
340
+ * target maybe number, string, array ...
327
341
  */
328
- export function getBaseHTMLElement(): BaseHTMLElementType;
329
- export {};
342
+ export function isEmptyObject(target: unknown): boolean;
330
343
  }
331
344
 
332
345
  declare module '@micro-zoe/micro-app/interact' {