@micro-zoe/micro-app 1.0.0-alpha.3 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micro-zoe/micro-app",
3
- "version": "1.0.0-alpha.3",
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": {
@@ -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
@@ -99,7 +105,8 @@ declare module '@micro-app/types' {
99
105
  baseroute?: string,
100
106
  keepRouteState?: boolean,
101
107
  defaultPage?: string,
102
- hiddenRouter?: boolean
108
+ hiddenRouter?: boolean,
109
+ disablePatchRequest?: boolean,
103
110
  ): void
104
111
 
105
112
  // unmount app
@@ -161,6 +168,8 @@ declare module '@micro-app/types' {
161
168
  error?(e?: CustomEvent): void
162
169
  }
163
170
 
171
+ type AssetsChecker = (url: string) => boolean;
172
+
164
173
  type plugins = {
165
174
  // global plugin
166
175
  global?: Array<{
@@ -168,10 +177,16 @@ declare module '@micro-app/types' {
168
177
  scopeProperties?: Array<PropertyKey>
169
178
  // Properties that can be escape to rawWindow
170
179
  escapeProperties?: Array<PropertyKey>
180
+ // Exclude JS or CSS
181
+ excludeChecker?: AssetsChecker
182
+ // Ignore JS or CSS
183
+ ignoreChecker?: AssetsChecker
171
184
  // options for plugin as the third parameter of loader
172
185
  options?: unknown
173
186
  // handle function
174
187
  loader?: (code: string, url: string, options: unknown, info: sourceScriptInfo) => string
188
+ // html processor
189
+ processHtml?: (code: string, url: string, options: unknown) => string
175
190
  }>
176
191
 
177
192
  // plugin for special app
@@ -181,10 +196,16 @@ declare module '@micro-app/types' {
181
196
  scopeProperties?: Array<PropertyKey>
182
197
  // Properties that can be escape to rawWindow
183
198
  escapeProperties?: Array<PropertyKey>
199
+ // Exclude JS or CSS
200
+ excludeChecker?: AssetsChecker
201
+ // Ignore JS or CSS
202
+ ignoreChecker?: AssetsChecker
184
203
  // options for plugin as the third parameter of loader
185
204
  options?: unknown
186
205
  // handle function
187
206
  loader?: (code: string, url: string, options: unknown, info: sourceScriptInfo) => string
207
+ // html processor
208
+ processHtml?: (code: string, url: string, options: unknown) => string
188
209
  }>
189
210
  }
190
211
  }
@@ -208,6 +229,7 @@ declare module '@micro-app/types' {
208
229
  'disable-scopecss'?: boolean
209
230
  'disable-sandbox'?: boolean
210
231
  'disable-memory-router'?: boolean
232
+ 'disable-patch-request'?: boolean
211
233
  'keep-router-state'?: boolean
212
234
  'hidden-router'?: boolean
213
235
  'esmodule'?: boolean
@@ -301,6 +323,11 @@ declare module '@micro-app/types' {
301
323
 
302
324
  type RouterGuard = AccurateGuard | GlobalNormalGuard
303
325
 
326
+ type SetDefaultPageOptions = {
327
+ name: string,
328
+ path: string,
329
+ }
330
+
304
331
  // Router API for developer
305
332
  interface Router {
306
333
  // current route of all apps
@@ -355,10 +382,9 @@ declare module '@micro-app/types' {
355
382
  afterEach(guard: RouterGuard): () => boolean
356
383
  /**
357
384
  * Add defaultPage to control the first rendered page
358
- * @param appName app name
359
- * @param path default page path
385
+ * @param options SetDefaultPageOptions
360
386
  */
361
- setDefaultPage(appName: string, path: string): () => boolean
387
+ setDefaultPage(options: SetDefaultPageOptions): () => boolean
362
388
  /**
363
389
  * Clear data of defaultPage that set by setDefaultPage
364
390
  */