@micro-zoe/micro-app 1.0.0-rc.1 → 1.0.0-rc.11
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 +1 -1
- package/lib/index.d.ts +47 -12
- package/lib/index.esm.js +1882 -952
- 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 +2 -1
- package/typings/global.d.ts +62 -46
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.11",
|
|
4
4
|
"description": "A lightweight, efficient and powerful micro front-end framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "lib/index.min.js",
|
|
@@ -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",
|
package/typings/global.d.ts
CHANGED
|
@@ -65,28 +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>
|
|
89
|
+
interface WithSandBoxInterface extends BaseSandboxType {
|
|
90
90
|
// proxy(microWindow)
|
|
91
91
|
proxyWindow: WindowProxy
|
|
92
92
|
// child window
|
|
@@ -106,8 +106,9 @@ declare module '@micro-app/types' {
|
|
|
106
106
|
setPreRenderState (state: boolean): void
|
|
107
107
|
markUmdMode(state: boolean): void
|
|
108
108
|
patchStaticElement (container: Element | ShadowRoot): void
|
|
109
|
-
|
|
109
|
+
actionsBeforeExecScripts (container: Element | ShadowRoot, handleUmdHooks: Func): void
|
|
110
110
|
deleteIframeElement? (): void
|
|
111
|
+
setStaticAppState (state: string): void
|
|
111
112
|
}
|
|
112
113
|
|
|
113
114
|
type LinkSourceInfo = {
|
|
@@ -153,6 +154,15 @@ declare module '@micro-app/types' {
|
|
|
153
154
|
// hiddenRouter: boolean
|
|
154
155
|
}
|
|
155
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
|
+
|
|
156
166
|
interface UnmountParam {
|
|
157
167
|
destroy: boolean, // completely destroy, delete cache resources
|
|
158
168
|
clearData: boolean // clear data of dateCenter
|
|
@@ -161,7 +171,7 @@ declare module '@micro-app/types' {
|
|
|
161
171
|
}
|
|
162
172
|
|
|
163
173
|
// app instance
|
|
164
|
-
interface AppInterface extends Pick<
|
|
174
|
+
interface AppInterface extends Pick<Element, 'querySelector' | 'querySelectorAll'> {
|
|
165
175
|
source: sourceType // source list
|
|
166
176
|
// TODO: 去掉any
|
|
167
177
|
sandBox: WithSandBoxInterface | null | any // sandbox
|
|
@@ -187,7 +197,7 @@ declare module '@micro-app/types' {
|
|
|
187
197
|
loadSourceCode (): void
|
|
188
198
|
|
|
189
199
|
// resource is loaded
|
|
190
|
-
onLoad (
|
|
200
|
+
onLoad (onLoadParam: OnLoadParam): void
|
|
191
201
|
|
|
192
202
|
// Error loading HTML
|
|
193
203
|
onLoadError (e: Error): void
|
|
@@ -210,6 +220,8 @@ declare module '@micro-app/types' {
|
|
|
210
220
|
// get keep-alive state
|
|
211
221
|
getKeepAliveState(): string | null
|
|
212
222
|
|
|
223
|
+
parseHtmlString(htmlString: string): HTMLElement
|
|
224
|
+
|
|
213
225
|
// is app unmounted
|
|
214
226
|
isUnmounted (): boolean
|
|
215
227
|
|
|
@@ -238,9 +250,9 @@ declare module '@micro-app/types' {
|
|
|
238
250
|
inline?: boolean
|
|
239
251
|
iframe?: boolean
|
|
240
252
|
level?: number
|
|
253
|
+
// prerender only 👇
|
|
241
254
|
'default-page'?: string
|
|
242
255
|
'disable-patch-request'?: boolean
|
|
243
|
-
// prerender only 👇
|
|
244
256
|
'router-mode'?: string
|
|
245
257
|
baseroute?: string
|
|
246
258
|
// prerender only 👆
|
|
@@ -251,14 +263,14 @@ declare module '@micro-app/types' {
|
|
|
251
263
|
|
|
252
264
|
// lifeCycles
|
|
253
265
|
interface lifeCyclesType {
|
|
254
|
-
created?(e: CustomEvent): void
|
|
255
|
-
beforemount?(e: CustomEvent): void
|
|
256
|
-
mounted?(e: CustomEvent): void
|
|
257
|
-
unmount?(e: CustomEvent): void
|
|
258
|
-
error?(e: CustomEvent): void
|
|
259
|
-
beforeshow?(e: CustomEvent): void
|
|
260
|
-
aftershow?(e: CustomEvent): void
|
|
261
|
-
afterhidden?(e: CustomEvent): void
|
|
266
|
+
created?(e: CustomEvent, appName: string): void
|
|
267
|
+
beforemount?(e: CustomEvent, appName: string): void
|
|
268
|
+
mounted?(e: CustomEvent, appName: string): void
|
|
269
|
+
unmount?(e: CustomEvent, appName: string): void
|
|
270
|
+
error?(e: CustomEvent, appName: string): void
|
|
271
|
+
beforeshow?(e: CustomEvent, appName: string): void
|
|
272
|
+
aftershow?(e: CustomEvent, appName: string): void
|
|
273
|
+
afterhidden?(e: CustomEvent, appName: string): void
|
|
262
274
|
}
|
|
263
275
|
|
|
264
276
|
type AssetsChecker = (url: string) => boolean;
|
|
@@ -329,15 +341,16 @@ declare module '@micro-app/types' {
|
|
|
329
341
|
'disable-memory-router'?: boolean
|
|
330
342
|
'disable-patch-request'?: boolean
|
|
331
343
|
'keep-router-state'?: boolean
|
|
332
|
-
'hidden-router'?: boolean
|
|
333
344
|
'keep-alive'?: boolean
|
|
334
345
|
'clear-data'?: boolean
|
|
335
346
|
'router-mode'?: string
|
|
347
|
+
'router-event-delay'?: number | ((appName: string) => number),
|
|
336
348
|
iframe?: boolean
|
|
337
349
|
ssr?: boolean
|
|
338
350
|
fiber?: boolean
|
|
339
351
|
prefetchLevel?: number
|
|
340
352
|
prefetchDelay?: number
|
|
353
|
+
iframeSrc?: string
|
|
341
354
|
}
|
|
342
355
|
|
|
343
356
|
interface OptionsType extends MicroAppConfig {
|
|
@@ -348,7 +361,10 @@ declare module '@micro-app/types' {
|
|
|
348
361
|
fetch?: fetchType
|
|
349
362
|
globalAssets?: globalAssetsType,
|
|
350
363
|
excludeAssetFilter?: (assetUrl: string) => boolean
|
|
364
|
+
/* image video audio 是否设置 crossOrigin = 'anonymous' */
|
|
365
|
+
includeCrossOrigin?: (assetUrl: string) => boolean
|
|
351
366
|
getRootElementParentNode?: (node: Node, appName: AppName) => void
|
|
367
|
+
customProxyDocumentProps?: Map<string | number | symbol, (value: unknown) => void>
|
|
352
368
|
}
|
|
353
369
|
|
|
354
370
|
// MicroApp config
|
|
@@ -361,25 +377,25 @@ declare module '@micro-app/types' {
|
|
|
361
377
|
start(options?: OptionsType): void
|
|
362
378
|
}
|
|
363
379
|
|
|
364
|
-
interface
|
|
380
|
+
interface MicroAppElementInterface {
|
|
365
381
|
appName: AttrType // app name
|
|
366
382
|
appUrl: AttrType // app url
|
|
367
|
-
|
|
368
383
|
// Hooks for element append to documents
|
|
369
384
|
connectedCallback (): void
|
|
370
|
-
|
|
371
385
|
// Hooks for element delete from documents
|
|
372
386
|
disconnectedCallback (): void
|
|
373
|
-
|
|
374
387
|
// Hooks for element attributes change
|
|
375
388
|
attributeChangedCallback (a: 'name' | 'url', o: string, n: string): void
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
389
|
+
// public mount action for micro_app_element & create_app
|
|
390
|
+
mount (app: AppInterface): void
|
|
391
|
+
// unmount app
|
|
392
|
+
unmount (destroy?: boolean, unmountcb?: CallableFunction): void
|
|
393
|
+
// Re render app from the command line
|
|
394
|
+
reload (destroy?: boolean): Promise<boolean>
|
|
395
|
+
// get delay time of router event
|
|
396
|
+
getRouterEventDelay (): number
|
|
397
|
+
// rewrite micro-app.setAttribute, process attr data
|
|
398
|
+
setAttribute (key: string, value: any): void
|
|
383
399
|
}
|
|
384
400
|
|
|
385
401
|
// special CallableFunction for interact
|
|
@@ -390,11 +406,17 @@ declare module '@micro-app/types' {
|
|
|
390
406
|
|
|
391
407
|
interface MicroLocation extends Location, URL {
|
|
392
408
|
fullPath: string
|
|
409
|
+
self: URL | Location
|
|
393
410
|
[key: string]: any
|
|
394
411
|
}
|
|
395
412
|
|
|
396
413
|
type MicroHistory = ProxyHandler<History>
|
|
397
414
|
type MicroState = any
|
|
415
|
+
interface MicroRouterInfoState {
|
|
416
|
+
fullPath: string | null,
|
|
417
|
+
state: MicroState,
|
|
418
|
+
mode: string,
|
|
419
|
+
}
|
|
398
420
|
type HistoryProxyValue =
|
|
399
421
|
Pick<
|
|
400
422
|
History,
|
|
@@ -433,7 +455,7 @@ declare module '@micro-app/types' {
|
|
|
433
455
|
replace?: boolean
|
|
434
456
|
}
|
|
435
457
|
|
|
436
|
-
type navigationMethod = (to: RouterTarget) => void
|
|
458
|
+
type navigationMethod = (to: RouterTarget) => Promise<void>
|
|
437
459
|
|
|
438
460
|
interface AccurateGuard {
|
|
439
461
|
[appName: string]: (to: GuardLocation, from: GuardLocation) => void
|
|
@@ -545,12 +567,6 @@ declare module '@micro-app/types' {
|
|
|
545
567
|
}
|
|
546
568
|
}
|
|
547
569
|
|
|
548
|
-
declare namespace JSX {
|
|
549
|
-
interface IntrinsicElements {
|
|
550
|
-
'micro-app': any
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
|
|
554
570
|
declare module '@micro-zoe/micro-app/polyfill/jsx-custom-event'
|
|
555
571
|
|
|
556
572
|
declare const __DEV__: boolean
|