@micro-zoe/micro-app 1.0.0-rc.1 → 1.0.0-rc.10
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 +46 -12
- package/lib/index.esm.js +1860 -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 +60 -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.10",
|
|
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 {
|
|
@@ -349,6 +362,7 @@ declare module '@micro-app/types' {
|
|
|
349
362
|
globalAssets?: globalAssetsType,
|
|
350
363
|
excludeAssetFilter?: (assetUrl: string) => boolean
|
|
351
364
|
getRootElementParentNode?: (node: Node, appName: AppName) => void
|
|
365
|
+
customProxyDocumentProps?: Map<string | number | symbol, (value: unknown) => void>
|
|
352
366
|
}
|
|
353
367
|
|
|
354
368
|
// MicroApp config
|
|
@@ -361,25 +375,25 @@ declare module '@micro-app/types' {
|
|
|
361
375
|
start(options?: OptionsType): void
|
|
362
376
|
}
|
|
363
377
|
|
|
364
|
-
interface
|
|
378
|
+
interface MicroAppElementInterface {
|
|
365
379
|
appName: AttrType // app name
|
|
366
380
|
appUrl: AttrType // app url
|
|
367
|
-
|
|
368
381
|
// Hooks for element append to documents
|
|
369
382
|
connectedCallback (): void
|
|
370
|
-
|
|
371
383
|
// Hooks for element delete from documents
|
|
372
384
|
disconnectedCallback (): void
|
|
373
|
-
|
|
374
385
|
// Hooks for element attributes change
|
|
375
386
|
attributeChangedCallback (a: 'name' | 'url', o: string, n: string): void
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
387
|
+
// public mount action for micro_app_element & create_app
|
|
388
|
+
mount (app: AppInterface): void
|
|
389
|
+
// unmount app
|
|
390
|
+
unmount (destroy?: boolean, unmountcb?: CallableFunction): void
|
|
391
|
+
// Re render app from the command line
|
|
392
|
+
reload (destroy?: boolean): Promise<boolean>
|
|
393
|
+
// get delay time of router event
|
|
394
|
+
getRouterEventDelay (): number
|
|
395
|
+
// rewrite micro-app.setAttribute, process attr data
|
|
396
|
+
setAttribute (key: string, value: any): void
|
|
383
397
|
}
|
|
384
398
|
|
|
385
399
|
// special CallableFunction for interact
|
|
@@ -390,11 +404,17 @@ declare module '@micro-app/types' {
|
|
|
390
404
|
|
|
391
405
|
interface MicroLocation extends Location, URL {
|
|
392
406
|
fullPath: string
|
|
407
|
+
self: URL | Location
|
|
393
408
|
[key: string]: any
|
|
394
409
|
}
|
|
395
410
|
|
|
396
411
|
type MicroHistory = ProxyHandler<History>
|
|
397
412
|
type MicroState = any
|
|
413
|
+
interface MicroRouterInfoState {
|
|
414
|
+
fullPath: string | null,
|
|
415
|
+
state: MicroState,
|
|
416
|
+
mode: string,
|
|
417
|
+
}
|
|
398
418
|
type HistoryProxyValue =
|
|
399
419
|
Pick<
|
|
400
420
|
History,
|
|
@@ -433,7 +453,7 @@ declare module '@micro-app/types' {
|
|
|
433
453
|
replace?: boolean
|
|
434
454
|
}
|
|
435
455
|
|
|
436
|
-
type navigationMethod = (to: RouterTarget) => void
|
|
456
|
+
type navigationMethod = (to: RouterTarget) => Promise<void>
|
|
437
457
|
|
|
438
458
|
interface AccurateGuard {
|
|
439
459
|
[appName: string]: (to: GuardLocation, from: GuardLocation) => void
|
|
@@ -545,12 +565,6 @@ declare module '@micro-app/types' {
|
|
|
545
565
|
}
|
|
546
566
|
}
|
|
547
567
|
|
|
548
|
-
declare namespace JSX {
|
|
549
|
-
interface IntrinsicElements {
|
|
550
|
-
'micro-app': any
|
|
551
|
-
}
|
|
552
|
-
}
|
|
553
|
-
|
|
554
568
|
declare module '@micro-zoe/micro-app/polyfill/jsx-custom-event'
|
|
555
569
|
|
|
556
570
|
declare const __DEV__: boolean
|