@micro-zoe/micro-app 1.0.0-alpha.2 → 1.0.0-alpha.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micro-zoe/micro-app",
3
- "version": "1.0.0-alpha.2",
3
+ "version": "1.0.0-alpha.5",
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": {
@@ -13,11 +13,17 @@ declare module '@micro-app/types' {
13
13
  proxyWindow: WindowProxy
14
14
  microAppWindow: Window // Proxy target
15
15
  start (
16
+ umdMode: boolean,
16
17
  baseRoute: string,
17
18
  useMemoryRouter: boolean,
18
19
  defaultPage: string,
20
+ disablePatchRequest: boolean,
21
+ ): void
22
+ stop (
23
+ umdMode: boolean,
24
+ keepRouteState: boolean,
25
+ clearEventSource: boolean,
19
26
  ): void
20
- stop (keepRouteState: boolean, clearEventSource: boolean): void
21
27
  // record umd snapshot before the first execution of umdHookMount
22
28
  recordUmdSnapshot (): void
23
29
  // rebuild umd snapshot before remount umd app
@@ -77,6 +83,7 @@ declare module '@micro-app/types' {
77
83
  useMemoryRouter: boolean // whether use memoryRouter, default is true
78
84
  baseroute: string // route prefix, default is ''
79
85
  keepRouteState: boolean // keep route state when unmount, default is false
86
+ hiddenRouter: boolean // hide router info of child from browser url
80
87
  source: sourceType // sources of css, js, html
81
88
  sandBox: SandBoxInterface | null // sandbox
82
89
  umdMode: boolean // is umd mode
@@ -98,6 +105,8 @@ declare module '@micro-app/types' {
98
105
  baseroute?: string,
99
106
  keepRouteState?: boolean,
100
107
  defaultPage?: string,
108
+ hiddenRouter?: boolean,
109
+ disablePatchRequest?: boolean,
101
110
  ): void
102
111
 
103
112
  // unmount app
@@ -138,10 +147,13 @@ declare module '@micro-app/types' {
138
147
  type prefetchParam = {
139
148
  name: string,
140
149
  url: string,
150
+ // old config 👇
141
151
  disableScopecss?: boolean
142
152
  disableSandbox?: boolean
143
- disableMemoryRouter?: boolean
144
- shadowDOM?: boolean
153
+ // old config 👆
154
+ 'disable-scopecss'?: boolean
155
+ 'disable-sandbox'?: boolean
156
+ 'disable-memory-router'?: boolean
145
157
  }
146
158
 
147
159
  // prefetch params
@@ -156,6 +168,8 @@ declare module '@micro-app/types' {
156
168
  error?(e?: CustomEvent): void
157
169
  }
158
170
 
171
+ type AssetsChecker = (url: string) => boolean;
172
+
159
173
  type plugins = {
160
174
  // global plugin
161
175
  global?: Array<{
@@ -163,10 +177,16 @@ declare module '@micro-app/types' {
163
177
  scopeProperties?: Array<PropertyKey>
164
178
  // Properties that can be escape to rawWindow
165
179
  escapeProperties?: Array<PropertyKey>
180
+ // Exclude JS or CSS
181
+ excludeChecker?: AssetsChecker
182
+ // Ignore JS or CSS
183
+ ignoreChecker?: AssetsChecker
166
184
  // options for plugin as the third parameter of loader
167
185
  options?: unknown
168
186
  // handle function
169
187
  loader?: (code: string, url: string, options: unknown, info: sourceScriptInfo) => string
188
+ // html processor
189
+ processHtml?: (code: string, url: string, options: unknown) => string
170
190
  }>
171
191
 
172
192
  // plugin for special app
@@ -176,10 +196,16 @@ declare module '@micro-app/types' {
176
196
  scopeProperties?: Array<PropertyKey>
177
197
  // Properties that can be escape to rawWindow
178
198
  escapeProperties?: Array<PropertyKey>
199
+ // Exclude JS or CSS
200
+ excludeChecker?: AssetsChecker
201
+ // Ignore JS or CSS
202
+ ignoreChecker?: AssetsChecker
179
203
  // options for plugin as the third parameter of loader
180
204
  options?: unknown
181
205
  // handle function
182
206
  loader?: (code: string, url: string, options: unknown, info: sourceScriptInfo) => string
207
+ // html processor
208
+ processHtml?: (code: string, url: string, options: unknown) => string
183
209
  }>
184
210
  }
185
211
  }
@@ -193,13 +219,21 @@ declare module '@micro-app/types' {
193
219
 
194
220
  type OptionsType = {
195
221
  tagName?: string
196
- shadowDOM?: boolean
197
- destroy?: boolean
198
- inline?: boolean
222
+ 'shadowDOM'?: boolean
223
+ 'destroy'?: boolean
224
+ 'inline'?: boolean
225
+ // old config 👇
199
226
  disableScopecss?: boolean
200
227
  disableSandbox?: boolean
201
- disableMemoryRouter?: boolean
202
- ssr?: boolean
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
203
237
  lifeCycles?: lifeCyclesType
204
238
  preFetchApps?: prefetchParamList
205
239
  plugins?: plugins
@@ -289,6 +323,11 @@ declare module '@micro-app/types' {
289
323
 
290
324
  type RouterGuard = AccurateGuard | GlobalNormalGuard
291
325
 
326
+ type SetDefaultPageOptions = {
327
+ name: string,
328
+ path: string,
329
+ }
330
+
292
331
  // Router API for developer
293
332
  interface Router {
294
333
  // current route of all apps
@@ -343,10 +382,9 @@ declare module '@micro-app/types' {
343
382
  afterEach(guard: RouterGuard): () => boolean
344
383
  /**
345
384
  * Add defaultPage to control the first rendered page
346
- * @param appName app name
347
- * @param path default page path
385
+ * @param options SetDefaultPageOptions
348
386
  */
349
- setDefaultPage(appName: string, path: string): () => boolean
387
+ setDefaultPage(options: SetDefaultPageOptions): () => boolean
350
388
  /**
351
389
  * Clear data of defaultPage that set by setDefaultPage
352
390
  */