@micro-zoe/micro-app 1.0.0-alpha.6 → 1.0.0-alpha.9
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/lib/index.d.ts +87 -21
- package/lib/index.esm.js +894 -277
- 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 +75 -31
package/package.json
CHANGED
package/typings/global.d.ts
CHANGED
|
@@ -7,14 +7,29 @@ declare module '@micro-app/types' {
|
|
|
7
7
|
|
|
8
8
|
type microAppWindowType = Window & any
|
|
9
9
|
|
|
10
|
-
type
|
|
10
|
+
type AppName = string
|
|
11
11
|
|
|
12
12
|
type SourceAddress = string
|
|
13
13
|
|
|
14
14
|
type AttrsType = Map<string, string>
|
|
15
15
|
|
|
16
|
+
type RequestIdleCallbackOptions = {
|
|
17
|
+
timeout: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
type RequestIdleCallbackInfo = {
|
|
21
|
+
readonly didTimeout: boolean
|
|
22
|
+
timeRemaining: () => number
|
|
23
|
+
}
|
|
24
|
+
|
|
16
25
|
type fiberTasks = Array<() => Promise<void>> | null
|
|
17
26
|
|
|
27
|
+
interface EffectController {
|
|
28
|
+
recordEffect(): void
|
|
29
|
+
rebuildEffect(): void
|
|
30
|
+
releaseEffect(): void
|
|
31
|
+
}
|
|
32
|
+
|
|
18
33
|
interface SandBoxStartParams {
|
|
19
34
|
umdMode: boolean
|
|
20
35
|
baseroute: string
|
|
@@ -27,6 +42,7 @@ declare module '@micro-app/types' {
|
|
|
27
42
|
umdMode: boolean
|
|
28
43
|
keepRouteState: boolean
|
|
29
44
|
clearEventSource: boolean
|
|
45
|
+
clearData: boolean
|
|
30
46
|
}
|
|
31
47
|
|
|
32
48
|
interface SandBoxInterface {
|
|
@@ -34,12 +50,14 @@ declare module '@micro-app/types' {
|
|
|
34
50
|
microAppWindow: Window // Proxy target
|
|
35
51
|
start (startParams: SandBoxStartParams): void
|
|
36
52
|
stop (stopParams: SandBoxStopParams): void
|
|
53
|
+
releaseGlobalEffect (clearData?: boolean): void
|
|
37
54
|
// record umd snapshot before the first execution of umdHookMount
|
|
38
|
-
|
|
55
|
+
recordEffectSnapshot (): void
|
|
39
56
|
// rebuild umd snapshot before remount umd app
|
|
40
|
-
|
|
57
|
+
rebuildEffectSnapshot (): void
|
|
41
58
|
setRouteInfoForKeepAliveApp (): void
|
|
42
59
|
removeRouteInfoForKeepAliveApp (): void
|
|
60
|
+
setPreRenderState (state: boolean): void
|
|
43
61
|
}
|
|
44
62
|
|
|
45
63
|
interface SandBoxAdapter {
|
|
@@ -89,16 +107,22 @@ declare module '@micro-app/types' {
|
|
|
89
107
|
}
|
|
90
108
|
|
|
91
109
|
interface MountParam {
|
|
92
|
-
container: HTMLElement | ShadowRoot
|
|
93
|
-
inline: boolean
|
|
94
|
-
useMemoryRouter: boolean
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
container: HTMLElement | ShadowRoot // app container
|
|
111
|
+
inline: boolean // run js in inline mode
|
|
112
|
+
useMemoryRouter: boolean // use virtual router
|
|
113
|
+
defaultPage: string // default page of virtual router
|
|
114
|
+
baseroute: string // route prefix, default is ''
|
|
115
|
+
disablePatchRequest: boolean // prevent rewrite request method of child app
|
|
116
|
+
fiber: boolean // run js in fiber mode
|
|
117
|
+
esmodule: boolean // support type='module' script
|
|
118
|
+
// hiddenRouter: boolean
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
interface UnmountParam {
|
|
122
|
+
destroy: boolean, // completely destroy, delete cache resources
|
|
123
|
+
clearData: boolean // clear data of dateCenter
|
|
124
|
+
keepRouteState: boolean // keep route state when unmount, default is false
|
|
125
|
+
unmountcb?: CallableFunction // callback of unmount
|
|
102
126
|
}
|
|
103
127
|
|
|
104
128
|
// app instance
|
|
@@ -112,12 +136,13 @@ declare module '@micro-app/types' {
|
|
|
112
136
|
inline: boolean // whether js runs in inline script mode, default is false
|
|
113
137
|
esmodule: boolean // support esmodule in script
|
|
114
138
|
ssrUrl: string // html path in ssr mode
|
|
115
|
-
isPrefetch: boolean // whether prefetch app, default is false
|
|
116
139
|
container: HTMLElement | ShadowRoot | null // container maybe null, micro-app, shadowRoot, div(keep-alive)
|
|
117
|
-
keepRouteState: boolean // keep route state when unmount, default is false
|
|
118
140
|
umdMode: boolean // is umd mode
|
|
119
141
|
fiber: boolean // fiber mode
|
|
120
142
|
useMemoryRouter: boolean // use virtual router
|
|
143
|
+
isPrefetch: boolean // whether prefetch app, default is false
|
|
144
|
+
isPrerender: boolean
|
|
145
|
+
prefetchLevel?: number
|
|
121
146
|
// defaultPage: string // default page when mount
|
|
122
147
|
// baseroute: string // route prefix, default is ''
|
|
123
148
|
// hiddenRouter: boolean // hide router info of child from browser url
|
|
@@ -126,7 +151,7 @@ declare module '@micro-app/types' {
|
|
|
126
151
|
loadSourceCode (): void
|
|
127
152
|
|
|
128
153
|
// resource is loaded
|
|
129
|
-
onLoad (html: HTMLElement): void
|
|
154
|
+
onLoad (html: HTMLElement, defaultPage?: string, disablePatchRequest?: boolean): void
|
|
130
155
|
|
|
131
156
|
// Error loading HTML
|
|
132
157
|
onLoadError (e: Error): void
|
|
@@ -135,7 +160,7 @@ declare module '@micro-app/types' {
|
|
|
135
160
|
mount (mountParams: MountParam): void
|
|
136
161
|
|
|
137
162
|
// unmount app
|
|
138
|
-
unmount (
|
|
163
|
+
unmount (unmountParam: UnmountParam): void
|
|
139
164
|
|
|
140
165
|
// app rendering error
|
|
141
166
|
onerror (e: Error): void
|
|
@@ -149,7 +174,7 @@ declare module '@micro-app/types' {
|
|
|
149
174
|
actionsForCompletelyDestroy (): void
|
|
150
175
|
|
|
151
176
|
// hidden app when disconnectedCallback with keep-alive
|
|
152
|
-
hiddenKeepAliveApp (): void
|
|
177
|
+
hiddenKeepAliveApp (callback?: CallableFunction): void
|
|
153
178
|
|
|
154
179
|
// show app when connectedCallback with keep-alive
|
|
155
180
|
showKeepAliveApp (container: HTMLElement | ShadowRoot): void
|
|
@@ -169,7 +194,7 @@ declare module '@micro-app/types' {
|
|
|
169
194
|
attributeChangedCallback (a: 'name' | 'url', o: string, n: string): void
|
|
170
195
|
}
|
|
171
196
|
|
|
172
|
-
|
|
197
|
+
interface prefetchParam {
|
|
173
198
|
name: string,
|
|
174
199
|
url: string,
|
|
175
200
|
// old config 👇
|
|
@@ -180,6 +205,9 @@ declare module '@micro-app/types' {
|
|
|
180
205
|
'disable-sandbox'?: boolean
|
|
181
206
|
inline?: boolean
|
|
182
207
|
esmodule?: boolean
|
|
208
|
+
level?: number
|
|
209
|
+
'default-page'?: string
|
|
210
|
+
'disable-patch-request'?: boolean
|
|
183
211
|
}
|
|
184
212
|
|
|
185
213
|
// prefetch params
|
|
@@ -187,14 +215,14 @@ declare module '@micro-app/types' {
|
|
|
187
215
|
|
|
188
216
|
// lifeCycles
|
|
189
217
|
interface lifeCyclesType {
|
|
190
|
-
created
|
|
191
|
-
beforemount
|
|
192
|
-
mounted
|
|
193
|
-
unmount
|
|
194
|
-
error
|
|
195
|
-
beforeshow
|
|
196
|
-
aftershow
|
|
197
|
-
afterhidden
|
|
218
|
+
created(e: CustomEvent): void
|
|
219
|
+
beforemount(e: CustomEvent): void
|
|
220
|
+
mounted(e: CustomEvent): void
|
|
221
|
+
unmount(e: CustomEvent): void
|
|
222
|
+
error(e: CustomEvent): void
|
|
223
|
+
beforeshow(e: CustomEvent): void
|
|
224
|
+
aftershow(e: CustomEvent): void
|
|
225
|
+
afterhidden(e: CustomEvent): void
|
|
198
226
|
}
|
|
199
227
|
|
|
200
228
|
type AssetsChecker = (url: string) => boolean;
|
|
@@ -239,6 +267,11 @@ declare module '@micro-app/types' {
|
|
|
239
267
|
}
|
|
240
268
|
}
|
|
241
269
|
|
|
270
|
+
type GetActiveAppsParam = {
|
|
271
|
+
excludeHiddenApp?: boolean,
|
|
272
|
+
excludePreRender?: boolean,
|
|
273
|
+
}
|
|
274
|
+
|
|
242
275
|
type fetchType = (url: string, options: Record<string, unknown>, appName: string | null) => Promise<string>
|
|
243
276
|
|
|
244
277
|
type globalAssetsType = {
|
|
@@ -246,8 +279,7 @@ declare module '@micro-app/types' {
|
|
|
246
279
|
css?: string[],
|
|
247
280
|
}
|
|
248
281
|
|
|
249
|
-
|
|
250
|
-
tagName?: string
|
|
282
|
+
interface MicroAppConfig {
|
|
251
283
|
shadowDOM?: boolean
|
|
252
284
|
destroy?: boolean
|
|
253
285
|
destory?: boolean
|
|
@@ -263,9 +295,16 @@ declare module '@micro-app/types' {
|
|
|
263
295
|
'keep-router-state'?: boolean
|
|
264
296
|
'hidden-router'?: boolean
|
|
265
297
|
'keep-alive'?: boolean
|
|
298
|
+
'clear-data'?: boolean
|
|
266
299
|
esmodule?: boolean
|
|
267
300
|
ssr?: boolean
|
|
268
301
|
fiber?: boolean
|
|
302
|
+
prefetchLevel?: number
|
|
303
|
+
prefetchDelay?: number
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
interface OptionsType extends MicroAppConfig {
|
|
307
|
+
tagName?: string
|
|
269
308
|
lifeCycles?: lifeCyclesType
|
|
270
309
|
preFetchApps?: prefetchParamList
|
|
271
310
|
plugins?: plugins
|
|
@@ -275,7 +314,7 @@ declare module '@micro-app/types' {
|
|
|
275
314
|
}
|
|
276
315
|
|
|
277
316
|
// MicroApp config
|
|
278
|
-
interface
|
|
317
|
+
interface MicroAppBaseType {
|
|
279
318
|
tagName: string
|
|
280
319
|
options: OptionsType
|
|
281
320
|
preFetch(apps: prefetchParamList): void
|
|
@@ -352,6 +391,11 @@ declare module '@micro-app/types' {
|
|
|
352
391
|
path: string,
|
|
353
392
|
}
|
|
354
393
|
|
|
394
|
+
type AttachAllToURLParam = {
|
|
395
|
+
includeHiddenApp?: boolean,
|
|
396
|
+
includePreRender?: boolean,
|
|
397
|
+
}
|
|
398
|
+
|
|
355
399
|
// Router API for developer
|
|
356
400
|
interface Router {
|
|
357
401
|
// current route of all apps
|
|
@@ -424,7 +468,7 @@ declare module '@micro-app/types' {
|
|
|
424
468
|
/**
|
|
425
469
|
* Attach all active app router info to browser url
|
|
426
470
|
*/
|
|
427
|
-
attachAllToURL(): void
|
|
471
|
+
attachAllToURL(options: AttachAllToURLParam): void
|
|
428
472
|
/**
|
|
429
473
|
* Record base app router, let child app control base app navigation
|
|
430
474
|
* It is global data
|