@micro-zoe/micro-app 1.0.0-rc.3 → 1.0.0-rc.31
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 +17 -17
- package/README.zh-cn.md +18 -18
- package/lib/index.d.ts +44 -29
- package/lib/index.esm.js +2081 -1112
- 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 +4 -4
- package/typings/global.d.ts +68 -50
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micro-zoe/micro-app",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.31",
|
|
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/
|
|
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/
|
|
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",
|
package/typings/global.d.ts
CHANGED
|
@@ -65,30 +65,28 @@ declare module '@micro-app/types' {
|
|
|
65
65
|
destroy?: boolean,
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
interface
|
|
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
|
-
|
|
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>
|
|
90
|
-
// sandbox ready state
|
|
91
|
-
sandboxReady: Promise<void>
|
|
89
|
+
interface WithSandBoxInterface extends BaseSandboxType {
|
|
92
90
|
// proxy(microWindow)
|
|
93
91
|
proxyWindow: WindowProxy
|
|
94
92
|
// child window
|
|
@@ -108,7 +106,7 @@ declare module '@micro-app/types' {
|
|
|
108
106
|
setPreRenderState (state: boolean): void
|
|
109
107
|
markUmdMode(state: boolean): void
|
|
110
108
|
patchStaticElement (container: Element | ShadowRoot): void
|
|
111
|
-
|
|
109
|
+
actionsBeforeExecScripts (container: Element | ShadowRoot, handleUmdHooks: Func): void
|
|
112
110
|
deleteIframeElement? (): void
|
|
113
111
|
setStaticAppState (state: string): void
|
|
114
112
|
}
|
|
@@ -156,6 +154,15 @@ declare module '@micro-app/types' {
|
|
|
156
154
|
// hiddenRouter: boolean
|
|
157
155
|
}
|
|
158
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
|
+
|
|
159
166
|
interface UnmountParam {
|
|
160
167
|
destroy: boolean, // completely destroy, delete cache resources
|
|
161
168
|
clearData: boolean // clear data of dateCenter
|
|
@@ -164,7 +171,7 @@ declare module '@micro-app/types' {
|
|
|
164
171
|
}
|
|
165
172
|
|
|
166
173
|
// app instance
|
|
167
|
-
interface AppInterface extends Pick<
|
|
174
|
+
interface AppInterface extends Pick<Element, 'querySelector' | 'querySelectorAll'> {
|
|
168
175
|
source: sourceType // source list
|
|
169
176
|
// TODO: 去掉any
|
|
170
177
|
sandBox: WithSandBoxInterface | null | any // sandbox
|
|
@@ -181,6 +188,7 @@ declare module '@micro-app/types' {
|
|
|
181
188
|
routerMode: string // virtual router mode
|
|
182
189
|
isPrefetch: boolean // whether prefetch app, default is false
|
|
183
190
|
isPrerender: boolean
|
|
191
|
+
isReloading?: boolean
|
|
184
192
|
prefetchLevel?: number
|
|
185
193
|
// defaultPage: string // default page when mount
|
|
186
194
|
// baseroute: string // route prefix, default is ''
|
|
@@ -190,7 +198,7 @@ declare module '@micro-app/types' {
|
|
|
190
198
|
loadSourceCode (): void
|
|
191
199
|
|
|
192
200
|
// resource is loaded
|
|
193
|
-
onLoad (
|
|
201
|
+
onLoad (onLoadParam: OnLoadParam): void
|
|
194
202
|
|
|
195
203
|
// Error loading HTML
|
|
196
204
|
onLoadError (e: Error): void
|
|
@@ -213,6 +221,8 @@ declare module '@micro-app/types' {
|
|
|
213
221
|
// get keep-alive state
|
|
214
222
|
getKeepAliveState(): string | null
|
|
215
223
|
|
|
224
|
+
parseHtmlString(htmlString: string): HTMLElement
|
|
225
|
+
|
|
216
226
|
// is app unmounted
|
|
217
227
|
isUnmounted (): boolean
|
|
218
228
|
|
|
@@ -227,9 +237,6 @@ declare module '@micro-app/types' {
|
|
|
227
237
|
|
|
228
238
|
// show app when connectedCallback with keep-alive
|
|
229
239
|
showKeepAliveApp (container: HTMLElement | ShadowRoot): void
|
|
230
|
-
|
|
231
|
-
// get app lifecycle state
|
|
232
|
-
getLifeCycleState (): string
|
|
233
240
|
}
|
|
234
241
|
|
|
235
242
|
interface prefetchParam {
|
|
@@ -244,9 +251,9 @@ declare module '@micro-app/types' {
|
|
|
244
251
|
inline?: boolean
|
|
245
252
|
iframe?: boolean
|
|
246
253
|
level?: number
|
|
254
|
+
// prerender only 👇
|
|
247
255
|
'default-page'?: string
|
|
248
256
|
'disable-patch-request'?: boolean
|
|
249
|
-
// prerender only 👇
|
|
250
257
|
'router-mode'?: string
|
|
251
258
|
baseroute?: string
|
|
252
259
|
// prerender only 👆
|
|
@@ -257,14 +264,14 @@ declare module '@micro-app/types' {
|
|
|
257
264
|
|
|
258
265
|
// lifeCycles
|
|
259
266
|
interface lifeCyclesType {
|
|
260
|
-
created?(e: CustomEvent): void
|
|
261
|
-
beforemount?(e: CustomEvent): void
|
|
262
|
-
mounted?(e: CustomEvent): void
|
|
263
|
-
unmount?(e: CustomEvent): void
|
|
264
|
-
error?(e: CustomEvent): void
|
|
265
|
-
beforeshow?(e: CustomEvent): void
|
|
266
|
-
aftershow?(e: CustomEvent): void
|
|
267
|
-
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
|
|
268
275
|
}
|
|
269
276
|
|
|
270
277
|
type AssetsChecker = (url: string) => boolean;
|
|
@@ -305,6 +312,7 @@ declare module '@micro-app/types' {
|
|
|
305
312
|
loader?: (code: string, url: string) => string
|
|
306
313
|
// html processor
|
|
307
314
|
processHtml?: (code: string, url: string) => string
|
|
315
|
+
aHrefResolver?: (hrefValue: string, appName: string, appUrl: string) => string
|
|
308
316
|
}>
|
|
309
317
|
}
|
|
310
318
|
}
|
|
@@ -335,15 +343,16 @@ declare module '@micro-app/types' {
|
|
|
335
343
|
'disable-memory-router'?: boolean
|
|
336
344
|
'disable-patch-request'?: boolean
|
|
337
345
|
'keep-router-state'?: boolean
|
|
338
|
-
'hidden-router'?: boolean
|
|
339
346
|
'keep-alive'?: boolean
|
|
340
347
|
'clear-data'?: boolean
|
|
341
348
|
'router-mode'?: string
|
|
349
|
+
'router-event-delay'?: number | ((appName: string) => number),
|
|
342
350
|
iframe?: boolean
|
|
343
351
|
ssr?: boolean
|
|
344
352
|
fiber?: boolean
|
|
345
353
|
prefetchLevel?: number
|
|
346
354
|
prefetchDelay?: number
|
|
355
|
+
iframeSrc?: string
|
|
347
356
|
}
|
|
348
357
|
|
|
349
358
|
interface OptionsType extends MicroAppConfig {
|
|
@@ -354,8 +363,17 @@ declare module '@micro-app/types' {
|
|
|
354
363
|
fetch?: fetchType
|
|
355
364
|
globalAssets?: globalAssetsType,
|
|
356
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
|
|
357
369
|
getRootElementParentNode?: (node: Node, appName: AppName) => void
|
|
358
370
|
customProxyDocumentProps?: Map<string | number | symbol, (value: unknown) => void>
|
|
371
|
+
aHrefResolver?: (hrefValue: string, appName: string, appUrl: string) => string
|
|
372
|
+
inheritBaseBody?:boolean,
|
|
373
|
+
escapeIframeWindowEvents? : Array<string>,
|
|
374
|
+
disableIframeRootDocument?: boolean,
|
|
375
|
+
excludeRewriteIframeConstructor?: string[]
|
|
376
|
+
optionCss?: string[] // some configurations of CSS
|
|
359
377
|
}
|
|
360
378
|
|
|
361
379
|
// MicroApp config
|
|
@@ -368,25 +386,25 @@ declare module '@micro-app/types' {
|
|
|
368
386
|
start(options?: OptionsType): void
|
|
369
387
|
}
|
|
370
388
|
|
|
371
|
-
interface
|
|
389
|
+
interface MicroAppElementInterface {
|
|
372
390
|
appName: AttrType // app name
|
|
373
391
|
appUrl: AttrType // app url
|
|
374
|
-
|
|
375
392
|
// Hooks for element append to documents
|
|
376
393
|
connectedCallback (): void
|
|
377
|
-
|
|
378
394
|
// Hooks for element delete from documents
|
|
379
395
|
disconnectedCallback (): void
|
|
380
|
-
|
|
381
396
|
// Hooks for element attributes change
|
|
382
397
|
attributeChangedCallback (a: 'name' | 'url', o: string, n: string): void
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
398
|
+
// public mount action for micro_app_element & create_app
|
|
399
|
+
mount (app: AppInterface): void
|
|
400
|
+
// unmount app
|
|
401
|
+
unmount (destroy?: boolean, unmountcb?: CallableFunction): void
|
|
402
|
+
// Re render app from the command line
|
|
403
|
+
reload (destroy?: boolean): Promise<boolean>
|
|
404
|
+
// get delay time of router event
|
|
405
|
+
getRouterEventDelay (): number
|
|
406
|
+
// rewrite micro-app.setAttribute, process attr data
|
|
407
|
+
setAttribute (key: string, value: any): void
|
|
390
408
|
}
|
|
391
409
|
|
|
392
410
|
// special CallableFunction for interact
|
|
@@ -397,11 +415,17 @@ declare module '@micro-app/types' {
|
|
|
397
415
|
|
|
398
416
|
interface MicroLocation extends Location, URL {
|
|
399
417
|
fullPath: string
|
|
418
|
+
self: URL | Location
|
|
400
419
|
[key: string]: any
|
|
401
420
|
}
|
|
402
421
|
|
|
403
422
|
type MicroHistory = ProxyHandler<History>
|
|
404
423
|
type MicroState = any
|
|
424
|
+
interface MicroRouterInfoState {
|
|
425
|
+
fullPath: string | null,
|
|
426
|
+
state: MicroState,
|
|
427
|
+
mode: string,
|
|
428
|
+
}
|
|
405
429
|
type HistoryProxyValue =
|
|
406
430
|
Pick<
|
|
407
431
|
History,
|
|
@@ -552,12 +576,6 @@ declare module '@micro-app/types' {
|
|
|
552
576
|
}
|
|
553
577
|
}
|
|
554
578
|
|
|
555
|
-
declare namespace JSX {
|
|
556
|
-
interface IntrinsicElements {
|
|
557
|
-
'micro-app': any
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
579
|
declare module '@micro-zoe/micro-app/polyfill/jsx-custom-event'
|
|
562
580
|
|
|
563
581
|
declare const __DEV__: boolean
|