@micro-zoe/micro-app 1.0.0-alpha.1 → 1.0.0-alpha.4
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 +13 -6
- package/lib/index.esm.js +784 -370
- 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 +3 -1
- package/typings/global.d.ts +78 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micro-zoe/micro-app",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.4",
|
|
4
4
|
"description": "A lightweight, efficient and powerful micro front-end framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "lib/index.min.js",
|
|
@@ -44,6 +44,8 @@
|
|
|
44
44
|
"test": "jest",
|
|
45
45
|
"test:watch": "jest --watch",
|
|
46
46
|
"test:coverage": "jest --coverage",
|
|
47
|
+
"test:unit": "jest src/__tests__/unit",
|
|
48
|
+
"test:unit:coverage": "npm run test:unit -- --coverage",
|
|
47
49
|
"prepublishOnly": "yarn build"
|
|
48
50
|
},
|
|
49
51
|
"repository": {
|
package/typings/global.d.ts
CHANGED
|
@@ -7,15 +7,23 @@ declare module '@micro-app/types' {
|
|
|
7
7
|
|
|
8
8
|
type microAppWindowType = Window & any
|
|
9
9
|
|
|
10
|
+
type appName = string
|
|
11
|
+
|
|
10
12
|
interface SandBoxInterface {
|
|
11
13
|
proxyWindow: WindowProxy
|
|
12
14
|
microAppWindow: Window // Proxy target
|
|
13
15
|
start (
|
|
16
|
+
umdMode: boolean,
|
|
14
17
|
baseRoute: string,
|
|
15
18
|
useMemoryRouter: boolean,
|
|
16
19
|
defaultPage: string,
|
|
20
|
+
disablePatchRequest: boolean,
|
|
21
|
+
): void
|
|
22
|
+
stop (
|
|
23
|
+
umdMode: boolean,
|
|
24
|
+
keepRouteState: boolean,
|
|
25
|
+
clearEventSource: boolean,
|
|
17
26
|
): void
|
|
18
|
-
stop (keepRouteState: boolean, clearEventSource: boolean): void
|
|
19
27
|
// record umd snapshot before the first execution of umdHookMount
|
|
20
28
|
recordUmdSnapshot (): void
|
|
21
29
|
// rebuild umd snapshot before remount umd app
|
|
@@ -75,6 +83,7 @@ declare module '@micro-app/types' {
|
|
|
75
83
|
useMemoryRouter: boolean // whether use memoryRouter, default is true
|
|
76
84
|
baseroute: string // route prefix, default is ''
|
|
77
85
|
keepRouteState: boolean // keep route state when unmount, default is false
|
|
86
|
+
hiddenRouter: boolean // hide router info of child from browser url
|
|
78
87
|
source: sourceType // sources of css, js, html
|
|
79
88
|
sandBox: SandBoxInterface | null // sandbox
|
|
80
89
|
umdMode: boolean // is umd mode
|
|
@@ -96,6 +105,8 @@ declare module '@micro-app/types' {
|
|
|
96
105
|
baseroute?: string,
|
|
97
106
|
keepRouteState?: boolean,
|
|
98
107
|
defaultPage?: string,
|
|
108
|
+
hiddenRouter?: boolean,
|
|
109
|
+
disablePatchRequest?: boolean,
|
|
99
110
|
): void
|
|
100
111
|
|
|
101
112
|
// unmount app
|
|
@@ -136,10 +147,13 @@ declare module '@micro-app/types' {
|
|
|
136
147
|
type prefetchParam = {
|
|
137
148
|
name: string,
|
|
138
149
|
url: string,
|
|
150
|
+
// old config 👇
|
|
139
151
|
disableScopecss?: boolean
|
|
140
152
|
disableSandbox?: boolean
|
|
141
|
-
|
|
142
|
-
|
|
153
|
+
// old config 👆
|
|
154
|
+
'disable-scopecss'?: boolean
|
|
155
|
+
'disable-sandbox'?: boolean
|
|
156
|
+
'disable-memory-router'?: boolean
|
|
143
157
|
}
|
|
144
158
|
|
|
145
159
|
// prefetch params
|
|
@@ -154,6 +168,8 @@ declare module '@micro-app/types' {
|
|
|
154
168
|
error?(e?: CustomEvent): void
|
|
155
169
|
}
|
|
156
170
|
|
|
171
|
+
type AssetsChecker = (url: string) => boolean;
|
|
172
|
+
|
|
157
173
|
type plugins = {
|
|
158
174
|
// global plugin
|
|
159
175
|
global?: Array<{
|
|
@@ -161,10 +177,16 @@ declare module '@micro-app/types' {
|
|
|
161
177
|
scopeProperties?: Array<PropertyKey>
|
|
162
178
|
// Properties that can be escape to rawWindow
|
|
163
179
|
escapeProperties?: Array<PropertyKey>
|
|
180
|
+
// Exclude JS or CSS
|
|
181
|
+
excludeChecker?: AssetsChecker
|
|
182
|
+
// Ignore JS or CSS
|
|
183
|
+
ignoreChecker?: AssetsChecker
|
|
164
184
|
// options for plugin as the third parameter of loader
|
|
165
185
|
options?: unknown
|
|
166
186
|
// handle function
|
|
167
187
|
loader?: (code: string, url: string, options: unknown, info: sourceScriptInfo) => string
|
|
188
|
+
// html processor
|
|
189
|
+
processHtml?: (code: string, url: string, options: unknown) => string
|
|
168
190
|
}>
|
|
169
191
|
|
|
170
192
|
// plugin for special app
|
|
@@ -174,10 +196,16 @@ declare module '@micro-app/types' {
|
|
|
174
196
|
scopeProperties?: Array<PropertyKey>
|
|
175
197
|
// Properties that can be escape to rawWindow
|
|
176
198
|
escapeProperties?: Array<PropertyKey>
|
|
199
|
+
// Exclude JS or CSS
|
|
200
|
+
excludeChecker?: AssetsChecker
|
|
201
|
+
// Ignore JS or CSS
|
|
202
|
+
ignoreChecker?: AssetsChecker
|
|
177
203
|
// options for plugin as the third parameter of loader
|
|
178
204
|
options?: unknown
|
|
179
205
|
// handle function
|
|
180
206
|
loader?: (code: string, url: string, options: unknown, info: sourceScriptInfo) => string
|
|
207
|
+
// html processor
|
|
208
|
+
processHtml?: (code: string, url: string, options: unknown) => string
|
|
181
209
|
}>
|
|
182
210
|
}
|
|
183
211
|
}
|
|
@@ -191,13 +219,21 @@ declare module '@micro-app/types' {
|
|
|
191
219
|
|
|
192
220
|
type OptionsType = {
|
|
193
221
|
tagName?: string
|
|
194
|
-
shadowDOM?: boolean
|
|
195
|
-
destroy?: boolean
|
|
196
|
-
inline?: boolean
|
|
222
|
+
'shadowDOM'?: boolean
|
|
223
|
+
'destroy'?: boolean
|
|
224
|
+
'inline'?: boolean
|
|
225
|
+
// old config 👇
|
|
197
226
|
disableScopecss?: boolean
|
|
198
227
|
disableSandbox?: boolean
|
|
199
|
-
|
|
200
|
-
|
|
228
|
+
// old config 👆
|
|
229
|
+
'disable-scopecss'?: boolean
|
|
230
|
+
'disable-sandbox'?: boolean
|
|
231
|
+
'disable-memory-router'?: boolean
|
|
232
|
+
'disable-patch-request'?: boolean
|
|
233
|
+
'keep-router-state'?: boolean
|
|
234
|
+
'hidden-router'?: boolean
|
|
235
|
+
'esmodule'?: boolean
|
|
236
|
+
'ssr'?: boolean
|
|
201
237
|
lifeCycles?: lifeCyclesType
|
|
202
238
|
preFetchApps?: prefetchParamList
|
|
203
239
|
plugins?: plugins
|
|
@@ -287,6 +323,11 @@ declare module '@micro-app/types' {
|
|
|
287
323
|
|
|
288
324
|
type RouterGuard = AccurateGuard | GlobalNormalGuard
|
|
289
325
|
|
|
326
|
+
type SetDefaultPageOptions = {
|
|
327
|
+
name: string,
|
|
328
|
+
path: string,
|
|
329
|
+
}
|
|
330
|
+
|
|
290
331
|
// Router API for developer
|
|
291
332
|
interface Router {
|
|
292
333
|
// current route of all apps
|
|
@@ -339,10 +380,37 @@ declare module '@micro-app/types' {
|
|
|
339
380
|
* @param guard global hook for
|
|
340
381
|
*/
|
|
341
382
|
afterEach(guard: RouterGuard): () => boolean
|
|
342
|
-
|
|
343
|
-
|
|
383
|
+
/**
|
|
384
|
+
* Add defaultPage to control the first rendered page
|
|
385
|
+
* @param options SetDefaultPageOptions
|
|
386
|
+
*/
|
|
387
|
+
setDefaultPage(options: SetDefaultPageOptions): () => boolean
|
|
388
|
+
/**
|
|
389
|
+
* Clear data of defaultPage that set by setDefaultPage
|
|
390
|
+
*/
|
|
344
391
|
removeDefaultPage(appName: string): boolean
|
|
392
|
+
/**
|
|
393
|
+
* Get defaultPage that set by setDefaultPage
|
|
394
|
+
*/
|
|
345
395
|
getDefaultPage(key: PropertyKey): string | undefined
|
|
396
|
+
/**
|
|
397
|
+
* Attach specified active app router info to browser url
|
|
398
|
+
*/
|
|
399
|
+
attachToURL(appName: string): void
|
|
400
|
+
/**
|
|
401
|
+
* Attach all active app router info to browser url
|
|
402
|
+
*/
|
|
403
|
+
attachAllToURL(): void
|
|
404
|
+
/**
|
|
405
|
+
* Record base app router, let child app control base app navigation
|
|
406
|
+
* It is global data
|
|
407
|
+
* @param baseRouter router instance of base app
|
|
408
|
+
*/
|
|
409
|
+
setBaseAppRouter(baseRouter: unknown): void
|
|
410
|
+
/**
|
|
411
|
+
* get baseRouter from cache
|
|
412
|
+
*/
|
|
413
|
+
getBaseAppRouter(): unknown
|
|
346
414
|
}
|
|
347
415
|
|
|
348
416
|
// result of add/remove microApp path on browser url
|