@micro-zoe/micro-app 1.0.0-alpha.9 → 1.0.0-beta.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micro-zoe/micro-app",
3
- "version": "1.0.0-alpha.9",
3
+ "version": "1.0.0-beta.1",
4
4
  "description": "A lightweight, efficient and powerful micro front-end framework",
5
5
  "private": false,
6
6
  "main": "lib/index.min.js",
@@ -24,7 +24,7 @@
24
24
  "install:child-react17": "cd dev/children/react17 && yarn",
25
25
  "install:child-vue2": "cd dev/children/vue2 && yarn",
26
26
  "install:child-vue3": "cd dev/children/vue3 && yarn",
27
- "install:child-vite": "cd dev/children/vite && yarn",
27
+ "install:child-vite2": "cd dev/children/vite2 && yarn",
28
28
  "install:child-angular11": "cd dev/children/angular11 && yarn",
29
29
  "main-react16": "cd dev/main-react16 && yarn start",
30
30
  "main-vue2": "cd dev/main-vue2 && yarn start",
@@ -33,7 +33,7 @@
33
33
  "start-child:react17": "cd dev/children/react17 && yarn start",
34
34
  "start-child:vue2": "cd dev/children/vue2 && yarn start",
35
35
  "start-child:vue3": "cd dev/children/vue3 && yarn start",
36
- "start-child:vite": "cd dev/children/vite && yarn start",
36
+ "start-child:vite2": "cd dev/children/vite2 && yarn start",
37
37
  "start-child:angular11": "cd dev/children/angular11 && yarn start",
38
38
  "docs": "docsify serve docs --port 2000",
39
39
  "lint": "eslint --cache '**/*.{js,ts}'",
@@ -24,10 +24,33 @@ declare module '@micro-app/types' {
24
24
 
25
25
  type fiberTasks = Array<() => Promise<void>> | null
26
26
 
27
+ type MicroEventListener = EventListenerOrEventListenerObject & Record<string, any>
28
+
29
+ type timeInfo = {
30
+ handler: TimerHandler,
31
+ timeout?: number,
32
+ args: any[],
33
+ }
34
+
35
+ interface releaseEffectParams {
36
+ umdMode: boolean,
37
+ isPrerender: boolean,
38
+ keepAlive: boolean,
39
+ destroy: boolean,
40
+ }
41
+
27
42
  interface EffectController {
28
- recordEffect(): void
29
- rebuildEffect(): void
30
- releaseEffect(): void
43
+ reset(): void
44
+ record(): void
45
+ rebuild(): void
46
+ release(options: releaseEffectParams): void
47
+ }
48
+
49
+ interface CommonIframeEffect {
50
+ reset(): void
51
+ record(): void
52
+ rebuild(): void
53
+ release(umdMode?: boolean, preRender?: boolean): void
31
54
  }
32
55
 
33
56
  interface SandBoxStartParams {
@@ -41,23 +64,37 @@ declare module '@micro-app/types' {
41
64
  interface SandBoxStopParams {
42
65
  umdMode: boolean
43
66
  keepRouteState: boolean
44
- clearEventSource: boolean
67
+ destroy: boolean
45
68
  clearData: boolean
46
69
  }
47
70
 
48
- interface SandBoxInterface {
71
+ interface releaseGlobalEffectParams {
72
+ clearData?: boolean,
73
+ isPrerender?: boolean,
74
+ keepAlive?: boolean,
75
+ destroy?: boolean,
76
+ }
77
+
78
+ interface WithSandBoxInterface {
49
79
  proxyWindow: WindowProxy
50
80
  microAppWindow: Window // Proxy target
51
81
  start (startParams: SandBoxStartParams): void
52
82
  stop (stopParams: SandBoxStopParams): void
53
- releaseGlobalEffect (clearData?: boolean): void
83
+ recordAndReleaseEffect (options: releaseGlobalEffectParams, preventRecord?: boolean): void
84
+ // reset effect snapshot data
85
+ resetEffectSnapshot(): void
54
86
  // record umd snapshot before the first execution of umdHookMount
55
87
  recordEffectSnapshot (): void
56
88
  // rebuild umd snapshot before remount umd app
57
89
  rebuildEffectSnapshot (): void
90
+ releaseGlobalEffect (options: releaseGlobalEffectParams): void
58
91
  setRouteInfoForKeepAliveApp (): void
59
92
  removeRouteInfoForKeepAliveApp (): void
60
93
  setPreRenderState (state: boolean): void
94
+ markUmdMode(state: boolean): void
95
+ patchStaticElement (container: Element | ShadowRoot): void
96
+ actionBeforeExecScripts (container: Element | ShadowRoot): void
97
+ deleteIframeElement? (): void
61
98
  }
62
99
 
63
100
  interface SandBoxAdapter {
@@ -71,7 +108,7 @@ declare module '@micro-app/types' {
71
108
  staticScopeProperties: PropertyKey[]
72
109
 
73
110
  // adapter for react
74
- // injectReactHRMProperty (): void
111
+ // injectReactHMRProperty (): void
75
112
  }
76
113
 
77
114
  type LinkSourceInfo = {
@@ -96,7 +133,7 @@ declare module '@micro-app/types' {
96
133
  attrs: Map<string, string>, // element attributes
97
134
  parsedCode?: string, // bind code
98
135
  parsedFunction?: Function | null, // code to function
99
- wrapInSandBox?: boolean // use sandbox
136
+ sandboxType?: 'with' | 'iframe' | 'disable' // sandbox type (with, iframe, disable)
100
137
  }>
101
138
  }
102
139
 
@@ -114,7 +151,6 @@ declare module '@micro-app/types' {
114
151
  baseroute: string // route prefix, default is ''
115
152
  disablePatchRequest: boolean // prevent rewrite request method of child app
116
153
  fiber: boolean // run js in fiber mode
117
- esmodule: boolean // support type='module' script
118
154
  // hiddenRouter: boolean
119
155
  }
120
156
 
@@ -126,15 +162,16 @@ declare module '@micro-app/types' {
126
162
  }
127
163
 
128
164
  // app instance
129
- interface AppInterface {
165
+ interface AppInterface extends Pick<ParentNode, 'querySelector' | 'querySelectorAll'> {
130
166
  source: sourceType // source list
131
- sandBox: SandBoxInterface | null // sandbox
167
+ // TODO: 去掉any
168
+ sandBox: WithSandBoxInterface | null | any // sandbox
132
169
  name: string // app name
133
170
  url: string // app url
134
171
  scopecss: boolean // whether use css scoped, default is true
135
172
  useSandbox: boolean // whether use js sandbox, default is true
136
173
  inline: boolean // whether js runs in inline script mode, default is false
137
- esmodule: boolean // support esmodule in script
174
+ iframe: boolean // use iframe sandbox
138
175
  ssrUrl: string // html path in ssr mode
139
176
  container: HTMLElement | ShadowRoot | null // container maybe null, micro-app, shadowRoot, div(keep-alive)
140
177
  umdMode: boolean // is umd mode
@@ -204,7 +241,7 @@ declare module '@micro-app/types' {
204
241
  'disable-scopecss'?: boolean
205
242
  'disable-sandbox'?: boolean
206
243
  inline?: boolean
207
- esmodule?: boolean
244
+ iframe?: boolean
208
245
  level?: number
209
246
  'default-page'?: string
210
247
  'disable-patch-request'?: boolean
@@ -296,7 +333,7 @@ declare module '@micro-app/types' {
296
333
  'hidden-router'?: boolean
297
334
  'keep-alive'?: boolean
298
335
  'clear-data'?: boolean
299
- esmodule?: boolean
336
+ iframe?: boolean
300
337
  ssr?: boolean
301
338
  fiber?: boolean
302
339
  prefetchLevel?: number
@@ -311,6 +348,7 @@ declare module '@micro-app/types' {
311
348
  fetch?: fetchType
312
349
  globalAssets?: globalAssetsType,
313
350
  excludeAssetFilter?: (assetUrl: string) => boolean
351
+ getRootElementParentNode?: (node: Node, appName: AppName) => void
314
352
  }
315
353
 
316
354
  // MicroApp config
@@ -325,13 +363,10 @@ declare module '@micro-app/types' {
325
363
  // special CallableFunction for interact
326
364
  type CallableFunctionForInteract = CallableFunction & { __APP_NAME__?: string, __AUTO_TRIGGER__?: boolean }
327
365
 
328
- interface ShadowLocation {
329
- [k: string]: string
330
- }
366
+ type PopStateListener = (this: Window, e: PopStateEvent) => void
367
+ type MicroPopStateEvent = PopStateEvent & { onlyForBrowser?: boolean }
331
368
 
332
369
  interface MicroLocation extends Location, URL {
333
- // shadowLocation is the current location information (href, pathname, search, hash)
334
- shadowLocation: ShadowLocation
335
370
  fullPath: string
336
371
  [key: string]: any
337
372
  }