@micro-zoe/micro-app 1.0.0-alpha.5 → 1.0.0-alpha.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 +0 -4
- package/README.zh-cn.md +1 -1
- package/lib/index.d.ts +26 -16
- package/lib/index.esm.js +887 -433
- package/lib/index.esm.js.map +1 -1
- package/lib/index.min.js +1 -1
- package/lib/index.min.js.map +1 -1
- package/lib/index.umd.js +1 -1
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/typings/global.d.ts +97 -73
package/package.json
CHANGED
package/typings/global.d.ts
CHANGED
|
@@ -9,21 +9,31 @@ declare module '@micro-app/types' {
|
|
|
9
9
|
|
|
10
10
|
type appName = string
|
|
11
11
|
|
|
12
|
+
type SourceAddress = string
|
|
13
|
+
|
|
14
|
+
type AttrsType = Map<string, string>
|
|
15
|
+
|
|
16
|
+
type fiberTasks = Array<() => Promise<void>> | null
|
|
17
|
+
|
|
18
|
+
interface SandBoxStartParams {
|
|
19
|
+
umdMode: boolean
|
|
20
|
+
baseroute: string
|
|
21
|
+
useMemoryRouter: boolean
|
|
22
|
+
defaultPage: string
|
|
23
|
+
disablePatchRequest: boolean
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
interface SandBoxStopParams {
|
|
27
|
+
umdMode: boolean
|
|
28
|
+
keepRouteState: boolean
|
|
29
|
+
clearEventSource: boolean
|
|
30
|
+
}
|
|
31
|
+
|
|
12
32
|
interface SandBoxInterface {
|
|
13
33
|
proxyWindow: WindowProxy
|
|
14
34
|
microAppWindow: Window // Proxy target
|
|
15
|
-
start (
|
|
16
|
-
|
|
17
|
-
baseRoute: string,
|
|
18
|
-
useMemoryRouter: boolean,
|
|
19
|
-
defaultPage: string,
|
|
20
|
-
disablePatchRequest: boolean,
|
|
21
|
-
): void
|
|
22
|
-
stop (
|
|
23
|
-
umdMode: boolean,
|
|
24
|
-
keepRouteState: boolean,
|
|
25
|
-
clearEventSource: boolean,
|
|
26
|
-
): void
|
|
35
|
+
start (startParams: SandBoxStartParams): void
|
|
36
|
+
stop (stopParams: SandBoxStopParams): void
|
|
27
37
|
// record umd snapshot before the first execution of umdHookMount
|
|
28
38
|
recordUmdSnapshot (): void
|
|
29
39
|
// rebuild umd snapshot before remount umd app
|
|
@@ -46,48 +56,71 @@ declare module '@micro-app/types' {
|
|
|
46
56
|
// injectReactHRMProperty (): void
|
|
47
57
|
}
|
|
48
58
|
|
|
49
|
-
type
|
|
50
|
-
code: string // code
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
type LinkSourceInfo = {
|
|
60
|
+
code: string, // source code
|
|
61
|
+
appSpace: Record<string, {
|
|
62
|
+
attrs: Map<string, string>, // active element.attributes
|
|
63
|
+
placeholder?: Comment | null, // placeholder comment
|
|
64
|
+
parsedCode?: string, // parsed code
|
|
65
|
+
prefix?: string, // micro-app[name=appName]
|
|
66
|
+
}>
|
|
53
67
|
}
|
|
54
68
|
|
|
55
|
-
type
|
|
56
|
-
code: string // code
|
|
57
|
-
isExternal: boolean // external script
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
69
|
+
type ScriptSourceInfo = {
|
|
70
|
+
code: string, // source code
|
|
71
|
+
isExternal: boolean, // external script
|
|
72
|
+
appSpace: Record<string, {
|
|
73
|
+
async: boolean, // async script
|
|
74
|
+
defer: boolean, // defer script
|
|
75
|
+
module: boolean, // module type script
|
|
76
|
+
inline: boolean, // run js with inline script
|
|
77
|
+
pure: boolean, // pure script
|
|
78
|
+
attrs: Map<string, string>, // element attributes
|
|
79
|
+
parsedCode?: string, // bind code
|
|
80
|
+
parsedFunction?: Function | null, // code to function
|
|
81
|
+
wrapInSandBox?: boolean // use sandbox
|
|
82
|
+
}>
|
|
64
83
|
}
|
|
65
84
|
|
|
66
|
-
|
|
67
|
-
html
|
|
68
|
-
links:
|
|
69
|
-
scripts:
|
|
85
|
+
type sourceType = {
|
|
86
|
+
html: HTMLElement | null, // html address
|
|
87
|
+
links: Set<string>, // style/link address list
|
|
88
|
+
scripts: Set<string>, // script address list
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface MountParam {
|
|
92
|
+
container: HTMLElement | ShadowRoot
|
|
93
|
+
inline: boolean
|
|
94
|
+
useMemoryRouter: boolean
|
|
95
|
+
baseroute: string
|
|
96
|
+
keepRouteState: boolean
|
|
97
|
+
defaultPage: string
|
|
98
|
+
hiddenRouter: boolean
|
|
99
|
+
disablePatchRequest: boolean
|
|
100
|
+
fiber: boolean
|
|
101
|
+
esmodule: boolean
|
|
70
102
|
}
|
|
71
103
|
|
|
72
104
|
// app instance
|
|
73
105
|
interface AppInterface {
|
|
74
|
-
|
|
75
|
-
|
|
106
|
+
source: sourceType // source list
|
|
107
|
+
sandBox: SandBoxInterface | null // sandbox
|
|
76
108
|
name: string // app name
|
|
77
109
|
url: string // app url
|
|
78
|
-
ssrUrl: string // html path in ssr mode
|
|
79
|
-
container: HTMLElement | ShadowRoot | null // container maybe null, micro-app, shadowRoot, DIV(keep-alive)
|
|
80
|
-
inline: boolean // whether js runs in inline script mode, default is false
|
|
81
110
|
scopecss: boolean // whether use css scoped, default is true
|
|
82
111
|
useSandbox: boolean // whether use js sandbox, default is true
|
|
83
|
-
|
|
84
|
-
|
|
112
|
+
inline: boolean // whether js runs in inline script mode, default is false
|
|
113
|
+
esmodule: boolean // support esmodule in script
|
|
114
|
+
ssrUrl: string // html path in ssr mode
|
|
115
|
+
isPrefetch: boolean // whether prefetch app, default is false
|
|
116
|
+
container: HTMLElement | ShadowRoot | null // container maybe null, micro-app, shadowRoot, div(keep-alive)
|
|
85
117
|
keepRouteState: boolean // keep route state when unmount, default is false
|
|
86
|
-
hiddenRouter: boolean // hide router info of child from browser url
|
|
87
|
-
source: sourceType // sources of css, js, html
|
|
88
|
-
sandBox: SandBoxInterface | null // sandbox
|
|
89
118
|
umdMode: boolean // is umd mode
|
|
90
|
-
|
|
119
|
+
fiber: boolean // fiber mode
|
|
120
|
+
useMemoryRouter: boolean // use virtual router
|
|
121
|
+
// defaultPage: string // default page when mount
|
|
122
|
+
// baseroute: string // route prefix, default is ''
|
|
123
|
+
// hiddenRouter: boolean // hide router info of child from browser url
|
|
91
124
|
|
|
92
125
|
// Load resources
|
|
93
126
|
loadSourceCode (): void
|
|
@@ -99,15 +132,7 @@ declare module '@micro-app/types' {
|
|
|
99
132
|
onLoadError (e: Error): void
|
|
100
133
|
|
|
101
134
|
// mount app
|
|
102
|
-
mount (
|
|
103
|
-
container?: HTMLElement | ShadowRoot,
|
|
104
|
-
inline?: boolean,
|
|
105
|
-
baseroute?: string,
|
|
106
|
-
keepRouteState?: boolean,
|
|
107
|
-
defaultPage?: string,
|
|
108
|
-
hiddenRouter?: boolean,
|
|
109
|
-
disablePatchRequest?: boolean,
|
|
110
|
-
): void
|
|
135
|
+
mount (mountParams: MountParam): void
|
|
111
136
|
|
|
112
137
|
// unmount app
|
|
113
138
|
unmount (destroy: boolean, unmountcb?: CallableFunction): void
|
|
@@ -153,7 +178,8 @@ declare module '@micro-app/types' {
|
|
|
153
178
|
// old config 👆
|
|
154
179
|
'disable-scopecss'?: boolean
|
|
155
180
|
'disable-sandbox'?: boolean
|
|
156
|
-
|
|
181
|
+
inline?: boolean
|
|
182
|
+
esmodule?: boolean
|
|
157
183
|
}
|
|
158
184
|
|
|
159
185
|
// prefetch params
|
|
@@ -166,6 +192,9 @@ declare module '@micro-app/types' {
|
|
|
166
192
|
mounted?(e?: CustomEvent): void
|
|
167
193
|
unmount?(e?: CustomEvent): void
|
|
168
194
|
error?(e?: CustomEvent): void
|
|
195
|
+
beforeshow?(e?: CustomEvent): void
|
|
196
|
+
aftershow?(e?: CustomEvent): void
|
|
197
|
+
afterhidden?(e?: CustomEvent): void
|
|
169
198
|
}
|
|
170
199
|
|
|
171
200
|
type AssetsChecker = (url: string) => boolean;
|
|
@@ -182,11 +211,11 @@ declare module '@micro-app/types' {
|
|
|
182
211
|
// Ignore JS or CSS
|
|
183
212
|
ignoreChecker?: AssetsChecker
|
|
184
213
|
// options for plugin as the third parameter of loader
|
|
185
|
-
options?: unknown
|
|
214
|
+
options?: Record<string, unknown>
|
|
186
215
|
// handle function
|
|
187
|
-
loader?: (code: string, url: string
|
|
216
|
+
loader?: (code: string, url: string) => string
|
|
188
217
|
// html processor
|
|
189
|
-
processHtml?: (code: string, url: string
|
|
218
|
+
processHtml?: (code: string, url: string) => string
|
|
190
219
|
}>
|
|
191
220
|
|
|
192
221
|
// plugin for special app
|
|
@@ -201,11 +230,11 @@ declare module '@micro-app/types' {
|
|
|
201
230
|
// Ignore JS or CSS
|
|
202
231
|
ignoreChecker?: AssetsChecker
|
|
203
232
|
// options for plugin as the third parameter of loader
|
|
204
|
-
options?: unknown
|
|
233
|
+
options?: Record<string, unknown>
|
|
205
234
|
// handle function
|
|
206
|
-
loader?: (code: string, url: string
|
|
235
|
+
loader?: (code: string, url: string) => string
|
|
207
236
|
// html processor
|
|
208
|
-
processHtml?: (code: string, url: string
|
|
237
|
+
processHtml?: (code: string, url: string) => string
|
|
209
238
|
}>
|
|
210
239
|
}
|
|
211
240
|
}
|
|
@@ -219,9 +248,10 @@ declare module '@micro-app/types' {
|
|
|
219
248
|
|
|
220
249
|
type OptionsType = {
|
|
221
250
|
tagName?: string
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
251
|
+
shadowDOM?: boolean
|
|
252
|
+
destroy?: boolean
|
|
253
|
+
destory?: boolean
|
|
254
|
+
inline?: boolean
|
|
225
255
|
// old config 👇
|
|
226
256
|
disableScopecss?: boolean
|
|
227
257
|
disableSandbox?: boolean
|
|
@@ -232,28 +262,22 @@ declare module '@micro-app/types' {
|
|
|
232
262
|
'disable-patch-request'?: boolean
|
|
233
263
|
'keep-router-state'?: boolean
|
|
234
264
|
'hidden-router'?: boolean
|
|
235
|
-
'
|
|
236
|
-
|
|
265
|
+
'keep-alive'?: boolean
|
|
266
|
+
esmodule?: boolean
|
|
267
|
+
ssr?: boolean
|
|
268
|
+
fiber?: boolean
|
|
237
269
|
lifeCycles?: lifeCyclesType
|
|
238
270
|
preFetchApps?: prefetchParamList
|
|
239
271
|
plugins?: plugins
|
|
240
272
|
fetch?: fetchType
|
|
241
273
|
globalAssets?: globalAssetsType,
|
|
274
|
+
excludeAssetFilter?: (assetUrl: string) => boolean
|
|
242
275
|
}
|
|
243
276
|
|
|
244
277
|
// MicroApp config
|
|
245
278
|
interface MicroAppConfigType {
|
|
246
279
|
tagName: string
|
|
247
|
-
|
|
248
|
-
destroy?: boolean
|
|
249
|
-
inline?: boolean
|
|
250
|
-
disableScopecss?: boolean
|
|
251
|
-
disableSandbox?: boolean
|
|
252
|
-
disableMemoryRouter?: boolean
|
|
253
|
-
ssr?: boolean
|
|
254
|
-
lifeCycles?: lifeCyclesType
|
|
255
|
-
plugins?: plugins
|
|
256
|
-
fetch?: fetchType
|
|
280
|
+
options: OptionsType
|
|
257
281
|
preFetch(apps: prefetchParamList): void
|
|
258
282
|
router: Router // eslint-disable-line
|
|
259
283
|
start(options?: OptionsType): void
|
|
@@ -319,7 +343,7 @@ declare module '@micro-app/types' {
|
|
|
319
343
|
[appName: string]: (to: GuardLocation, from: GuardLocation) => void
|
|
320
344
|
}
|
|
321
345
|
|
|
322
|
-
type GlobalNormalGuard = ((
|
|
346
|
+
type GlobalNormalGuard = ((to: GuardLocation, from: GuardLocation, appName: string) => void)
|
|
323
347
|
|
|
324
348
|
type RouterGuard = AccurateGuard | GlobalNormalGuard
|
|
325
349
|
|
|
@@ -392,7 +416,7 @@ declare module '@micro-app/types' {
|
|
|
392
416
|
/**
|
|
393
417
|
* Get defaultPage that set by setDefaultPage
|
|
394
418
|
*/
|
|
395
|
-
getDefaultPage(key: PropertyKey): string |
|
|
419
|
+
getDefaultPage(key: PropertyKey): string | void
|
|
396
420
|
/**
|
|
397
421
|
* Attach specified active app router info to browser url
|
|
398
422
|
*/
|