@micro-zoe/micro-app 1.0.0-rc.2 → 1.0.0-rc.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micro-zoe/micro-app",
3
- "version": "1.0.0-rc.2",
3
+ "version": "1.0.0-rc.21",
4
4
  "description": "A lightweight, efficient and powerful micro front-end framework",
5
5
  "private": false,
6
6
  "main": "lib/index.min.js",
@@ -52,7 +52,7 @@
52
52
  },
53
53
  "repository": {
54
54
  "type": "git",
55
- "url": "https://github.com/micro-zoe/micro-app.git"
55
+ "url": "https://github.com/jd-opensource/micro-app.git"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"
@@ -72,7 +72,7 @@
72
72
  "author": "cangdu",
73
73
  "license": "MIT",
74
74
  "bugs": {
75
- "url": "https://github.com/micro-zoe/micro-app/issues"
75
+ "url": "https://github.com/jd-opensource/micro-app/issues"
76
76
  },
77
77
  "husky": {
78
78
  "hooks": {
@@ -96,6 +96,7 @@
96
96
  "@rollup/plugin-babel": "~5.2.2",
97
97
  "@rollup/plugin-node-resolve": "~11.0.1",
98
98
  "@rollup/plugin-replace": "~2.4.1",
99
+ "@rollup/plugin-terser": "^0.4.4",
99
100
  "@rollup/plugin-typescript": "~8.1.0",
100
101
  "@types/jest": "~26.0.24",
101
102
  "@types/node": "~14.14.19",
@@ -125,7 +126,6 @@
125
126
  "node-fetch": "~2.6.1",
126
127
  "npm-run-all": "~4.1.5",
127
128
  "pretty-bytes": "~5.5.0",
128
- "react": "~17.0.2",
129
129
  "rollup": "~2.35.1",
130
130
  "rollup-plugin-terser": "~7.0.2",
131
131
  "ts-jest": "~26.5.6",
@@ -65,28 +65,28 @@ declare module '@micro-app/types' {
65
65
  destroy?: boolean,
66
66
  }
67
67
 
68
- interface SandBoxAdapter {
68
+ interface BaseSandboxType {
69
+ // Properties that can only get and set in microAppWindow, will not escape to rawWindow
70
+ scopeProperties: PropertyKey[]
71
+ // Properties that can be escape to rawWindow
72
+ escapeProperties: PropertyKey[]
73
+ // Properties newly added to microAppWindow
74
+ injectedKeys: Set<PropertyKey>
75
+ // Properties escape to rawWindow, cleared when unmount
76
+ escapeKeys: Set<PropertyKey>
77
+ // Sandbox ready state
78
+ sandboxReady: Promise<void>
69
79
  // Variables that can only assigned to rawWindow
70
- escapeSetterKeyList: PropertyKey[]
71
-
80
+ rawWindowScopeKeyList: PropertyKey[]
72
81
  // Variables that can escape to rawWindow
73
82
  staticEscapeProperties: PropertyKey[]
74
-
75
83
  // Variables that scoped in child app
76
84
  staticScopeProperties: PropertyKey[]
85
+ // clear mount, unmount when stop in default mode
86
+ clearHijackUmdHooks: () => void
77
87
  }
78
88
 
79
- interface WithSandBoxInterface {
80
- // adapter for sandbox
81
- adapter: SandBoxAdapter
82
- // Scoped global Properties(Properties that can only get and set in microAppWindow, will not escape to rawWindow)
83
- scopeProperties: PropertyKey[]
84
- // Properties that can be escape to rawWindow
85
- escapeProperties: PropertyKey[]
86
- // Properties escape to rawWindow, cleared when unmount
87
- escapeKeys: Set<PropertyKey>
88
- // Properties newly added to microAppWindow
89
- injectedKeys: Set<PropertyKey>
89
+ interface WithSandBoxInterface extends BaseSandboxType {
90
90
  // proxy(microWindow)
91
91
  proxyWindow: WindowProxy
92
92
  // child window
@@ -106,8 +106,9 @@ declare module '@micro-app/types' {
106
106
  setPreRenderState (state: boolean): void
107
107
  markUmdMode(state: boolean): void
108
108
  patchStaticElement (container: Element | ShadowRoot): void
109
- actionBeforeExecScripts (container: Element | ShadowRoot): void
109
+ actionsBeforeExecScripts (container: Element | ShadowRoot, handleUmdHooks: Func): void
110
110
  deleteIframeElement? (): void
111
+ setStaticAppState (state: string): void
111
112
  }
112
113
 
113
114
  type LinkSourceInfo = {
@@ -153,6 +154,15 @@ declare module '@micro-app/types' {
153
154
  // hiddenRouter: boolean
154
155
  }
155
156
 
157
+ interface OnLoadParam {
158
+ html: HTMLElement,
159
+ // below params is only for prerender app
160
+ defaultPage?: string // default page of virtual router
161
+ routerMode?: string // virtual router mode
162
+ baseroute?: string // route prefix, default is ''
163
+ disablePatchRequest?: boolean // prevent rewrite request method of child app
164
+ }
165
+
156
166
  interface UnmountParam {
157
167
  destroy: boolean, // completely destroy, delete cache resources
158
168
  clearData: boolean // clear data of dateCenter
@@ -161,7 +171,7 @@ declare module '@micro-app/types' {
161
171
  }
162
172
 
163
173
  // app instance
164
- interface AppInterface extends Pick<ParentNode, 'querySelector' | 'querySelectorAll'> {
174
+ interface AppInterface extends Pick<Element, 'querySelector' | 'querySelectorAll'> {
165
175
  source: sourceType // source list
166
176
  // TODO: 去掉any
167
177
  sandBox: WithSandBoxInterface | null | any // sandbox
@@ -178,6 +188,7 @@ declare module '@micro-app/types' {
178
188
  routerMode: string // virtual router mode
179
189
  isPrefetch: boolean // whether prefetch app, default is false
180
190
  isPrerender: boolean
191
+ isReloading?: boolean
181
192
  prefetchLevel?: number
182
193
  // defaultPage: string // default page when mount
183
194
  // baseroute: string // route prefix, default is ''
@@ -187,7 +198,7 @@ declare module '@micro-app/types' {
187
198
  loadSourceCode (): void
188
199
 
189
200
  // resource is loaded
190
- onLoad (html: HTMLElement, defaultPage?: string, disablePatchRequest?: boolean): void
201
+ onLoad (onLoadParam: OnLoadParam): void
191
202
 
192
203
  // Error loading HTML
193
204
  onLoadError (e: Error): void
@@ -210,6 +221,8 @@ declare module '@micro-app/types' {
210
221
  // get keep-alive state
211
222
  getKeepAliveState(): string | null
212
223
 
224
+ parseHtmlString(htmlString: string): HTMLElement
225
+
213
226
  // is app unmounted
214
227
  isUnmounted (): boolean
215
228
 
@@ -238,9 +251,9 @@ declare module '@micro-app/types' {
238
251
  inline?: boolean
239
252
  iframe?: boolean
240
253
  level?: number
254
+ // prerender only 👇
241
255
  'default-page'?: string
242
256
  'disable-patch-request'?: boolean
243
- // prerender only 👇
244
257
  'router-mode'?: string
245
258
  baseroute?: string
246
259
  // prerender only 👆
@@ -251,14 +264,14 @@ declare module '@micro-app/types' {
251
264
 
252
265
  // lifeCycles
253
266
  interface lifeCyclesType {
254
- created?(e: CustomEvent): void
255
- beforemount?(e: CustomEvent): void
256
- mounted?(e: CustomEvent): void
257
- unmount?(e: CustomEvent): void
258
- error?(e: CustomEvent): void
259
- beforeshow?(e: CustomEvent): void
260
- aftershow?(e: CustomEvent): void
261
- afterhidden?(e: CustomEvent): void
267
+ created?(e: CustomEvent, appName: string): void
268
+ beforemount?(e: CustomEvent, appName: string): void
269
+ mounted?(e: CustomEvent, appName: string): void
270
+ unmount?(e: CustomEvent, appName: string): void
271
+ error?(e: CustomEvent, appName: string): void
272
+ beforeshow?(e: CustomEvent, appName: string): void
273
+ aftershow?(e: CustomEvent, appName: string): void
274
+ afterhidden?(e: CustomEvent, appName: string): void
262
275
  }
263
276
 
264
277
  type AssetsChecker = (url: string) => boolean;
@@ -299,6 +312,7 @@ declare module '@micro-app/types' {
299
312
  loader?: (code: string, url: string) => string
300
313
  // html processor
301
314
  processHtml?: (code: string, url: string) => string
315
+ aHrefResolver?: (hrefValue: string, appName: string, appUrl: string) => string
302
316
  }>
303
317
  }
304
318
  }
@@ -329,15 +343,16 @@ declare module '@micro-app/types' {
329
343
  'disable-memory-router'?: boolean
330
344
  'disable-patch-request'?: boolean
331
345
  'keep-router-state'?: boolean
332
- 'hidden-router'?: boolean
333
346
  'keep-alive'?: boolean
334
347
  'clear-data'?: boolean
335
348
  'router-mode'?: string
349
+ 'router-event-delay'?: number | ((appName: string) => number),
336
350
  iframe?: boolean
337
351
  ssr?: boolean
338
352
  fiber?: boolean
339
353
  prefetchLevel?: number
340
354
  prefetchDelay?: number
355
+ iframeSrc?: string
341
356
  }
342
357
 
343
358
  interface OptionsType extends MicroAppConfig {
@@ -348,6 +363,9 @@ declare module '@micro-app/types' {
348
363
  fetch?: fetchType
349
364
  globalAssets?: globalAssetsType,
350
365
  excludeAssetFilter?: (assetUrl: string) => boolean
366
+ excludeRunScriptFilter?: (scriptUrl: string, error: Error, appName: string, appUrl: string) => boolean
367
+ /* image video audio 是否设置 crossOrigin = 'anonymous' */
368
+ includeCrossOrigin?: (assetUrl: string) => boolean
351
369
  getRootElementParentNode?: (node: Node, appName: AppName) => void
352
370
  customProxyDocumentProps?: Map<string | number | symbol, (value: unknown) => void>
353
371
  }
@@ -362,25 +380,25 @@ declare module '@micro-app/types' {
362
380
  start(options?: OptionsType): void
363
381
  }
364
382
 
365
- interface MicroAppElementType {
383
+ interface MicroAppElementInterface {
366
384
  appName: AttrType // app name
367
385
  appUrl: AttrType // app url
368
-
369
386
  // Hooks for element append to documents
370
387
  connectedCallback (): void
371
-
372
388
  // Hooks for element delete from documents
373
389
  disconnectedCallback (): void
374
-
375
390
  // Hooks for element attributes change
376
391
  attributeChangedCallback (a: 'name' | 'url', o: string, n: string): void
377
-
378
- /**
379
- * Get configuration
380
- * Global setting is lowest priority
381
- * @param name Configuration item name
382
- */
383
- getDisposeResult <T extends keyof OptionsType> (name: T): boolean
392
+ // public mount action for micro_app_element & create_app
393
+ mount (app: AppInterface): void
394
+ // unmount app
395
+ unmount (destroy?: boolean, unmountcb?: CallableFunction): void
396
+ // Re render app from the command line
397
+ reload (destroy?: boolean): Promise<boolean>
398
+ // get delay time of router event
399
+ getRouterEventDelay (): number
400
+ // rewrite micro-app.setAttribute, process attr data
401
+ setAttribute (key: string, value: any): void
384
402
  }
385
403
 
386
404
  // special CallableFunction for interact
@@ -391,11 +409,17 @@ declare module '@micro-app/types' {
391
409
 
392
410
  interface MicroLocation extends Location, URL {
393
411
  fullPath: string
412
+ self: URL | Location
394
413
  [key: string]: any
395
414
  }
396
415
 
397
416
  type MicroHistory = ProxyHandler<History>
398
417
  type MicroState = any
418
+ interface MicroRouterInfoState {
419
+ fullPath: string | null,
420
+ state: MicroState,
421
+ mode: string,
422
+ }
399
423
  type HistoryProxyValue =
400
424
  Pick<
401
425
  History,
@@ -434,7 +458,7 @@ declare module '@micro-app/types' {
434
458
  replace?: boolean
435
459
  }
436
460
 
437
- type navigationMethod = (to: RouterTarget) => void
461
+ type navigationMethod = (to: RouterTarget) => Promise<void>
438
462
 
439
463
  interface AccurateGuard {
440
464
  [appName: string]: (to: GuardLocation, from: GuardLocation) => void
@@ -546,12 +570,6 @@ declare module '@micro-app/types' {
546
570
  }
547
571
  }
548
572
 
549
- declare namespace JSX {
550
- interface IntrinsicElements {
551
- 'micro-app': any
552
- }
553
- }
554
-
555
573
  declare module '@micro-zoe/micro-app/polyfill/jsx-custom-event'
556
574
 
557
575
  declare const __DEV__: boolean