@micro-zoe/micro-app 0.4.3 → 0.5.3

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": "0.4.3",
3
+ "version": "0.5.3",
4
4
  "description": "A lightweight, efficient and powerful micro front-end framework",
5
5
  "private": false,
6
6
  "main": "lib/index.min.js",
@@ -17,24 +17,24 @@
17
17
  "start:main-vue3-vite": "npm-run-all --parallel build:watch start-child:* main-vue3-vite",
18
18
  "build:watch": "cross-env NODE_ENV='development' rollup -c -w",
19
19
  "build": "cross-env NODE_ENV='production' rollup -c && npm run createtype && npm run afterbuild",
20
- "install:main-react16": "cd examples/main-react16 && yarn",
21
- "install:main-vue2": "cd examples/main-vue2 && yarn",
22
- "install:main-vue3-vite": "cd examples/main-vue3-vite && yarn",
23
- "install:child-react16": "cd examples/children/react16 && yarn",
24
- "install:child-react17": "cd examples/children/react17 && yarn",
25
- "install:child-vue2": "cd examples/children/vue2 && yarn",
26
- "install:child-vue3": "cd examples/children/vue3 && yarn",
27
- "install:child-vite": "cd examples/children/vite && yarn",
28
- "install:child-angular11": "cd examples/children/angular11 && yarn",
29
- "main-react16": "cd examples/main-react16 && yarn start",
30
- "main-vue2": "cd examples/main-vue2 && yarn start",
31
- "main-vue3-vite": "cd examples/main-vue3-vite && yarn start",
32
- "start-child:react16": "cd examples/children/react16 && yarn start",
33
- "start-child:react17": "cd examples/children/react17 && yarn start",
34
- "start-child:vue2": "cd examples/children/vue2 && yarn start",
35
- "start-child:vue3": "cd examples/children/vue3 && yarn start",
36
- "start-child:vite": "cd examples/children/vite && yarn start",
37
- "start-child:angular11": "cd examples/children/angular11 && yarn start",
20
+ "install:main-react16": "cd dev/main-react16 && yarn",
21
+ "install:main-vue2": "cd dev/main-vue2 && yarn",
22
+ "install:main-vue3-vite": "cd dev/main-vue3-vite && yarn",
23
+ "install:child-react16": "cd dev/children/react16 && yarn",
24
+ "install:child-react17": "cd dev/children/react17 && yarn",
25
+ "install:child-vue2": "cd dev/children/vue2 && yarn",
26
+ "install:child-vue3": "cd dev/children/vue3 && yarn",
27
+ "install:child-vite": "cd dev/children/vite && yarn",
28
+ "install:child-angular11": "cd dev/children/angular11 && yarn",
29
+ "main-react16": "cd dev/main-react16 && yarn start",
30
+ "main-vue2": "cd dev/main-vue2 && yarn start",
31
+ "main-vue3-vite": "cd dev/main-vue3-vite && yarn start",
32
+ "start-child:react16": "cd dev/children/react16 && yarn start",
33
+ "start-child:react17": "cd dev/children/react17 && yarn start",
34
+ "start-child:vue2": "cd dev/children/vue2 && yarn start",
35
+ "start-child:vue3": "cd dev/children/vue3 && yarn start",
36
+ "start-child:vite": "cd dev/children/vite && yarn start",
37
+ "start-child:angular11": "cd dev/children/angular11 && yarn start",
38
38
  "docs": "docsify serve docs --port 2000",
39
39
  "lint": "eslint --cache '**/*.{js,ts}'",
40
40
  "lint:fix": "yarn lint --fix",
@@ -1,6 +1,4 @@
1
- import React from 'react';
2
-
3
- // @ts-ignore
1
+ const React = require('react');
4
2
  // lifecycles
5
3
  const eventLifeCycles = ['oncreated', 'onbeforemount', 'onmounted', 'onunmount', 'onerror', 'ondatachange'];
6
4
  function jsxCustomEvent(type, props, ...children) {
@@ -41,6 +39,6 @@ function jsxCustomEvent(type, props, ...children) {
41
39
  };
42
40
  return React.createElement.apply(null, [type, newProps, ...children]);
43
41
  }
44
-
45
- export default jsxCustomEvent;
42
+ module.exports = jsxCustomEvent;
43
+ module.exports.default = jsxCustomEvent;
46
44
  //# sourceMappingURL=jsx-custom-event.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-custom-event.js","sources":["../src/polyfill/jsx-custom-event.ts"],"sourcesContent":["// @ts-ignore\nimport React from 'react'\n\ntype MicroElementType = HTMLElement & Record<string, unknown>\n\n// lifecycles\nconst eventLifeCycles = ['oncreated', 'onbeforemount', 'onmounted', 'onunmount', 'onerror', 'ondatachange']\n\nexport default function jsxCustomEvent (\n type: string | CallableFunction,\n props: Record<string, unknown> | null,\n ...children: any[]\n): void {\n if (typeof type !== 'string' || !/^micro-app(-\\S+)?/.test(type as string) || !props) {\n return React.createElement.apply(null, [type, props, ...children])\n }\n\n const newProps = Object.assign({}, props)\n\n // ref will call when create, update, unmount\n newProps.ref = (element: MicroElementType | null) => {\n if (typeof props.ref === 'function') {\n props.ref(element)\n } else if (typeof props.ref === 'object') {\n (props.ref as any).current = element\n }\n\n // when unmount and update the element is null\n if (element) {\n // Update data when the prev and next data are different\n if (toString.call(props.data) === '[object Object]' && element.data !== props.data) {\n element.data = props.data\n }\n\n for (const key in props) {\n if (\n Object.prototype.hasOwnProperty.call(props, key) &&\n eventLifeCycles.includes(key.toLowerCase()) &&\n typeof props[key] === 'function' &&\n (!element[key] || element[key] !== props[key])\n ) {\n const eventName = key.toLowerCase().replace('on', '')\n if (element[key]) {\n // @ts-ignore\n element.removeEventListener(eventName, element[key], false)\n }\n // @ts-ignore\n element.addEventListener(eventName, props[key], false)\n element[key] = props[key]\n }\n }\n }\n }\n\n return React.createElement.apply(null, [type, newProps, ...children])\n}\n"],"names":[],"mappings":";;AAAA;AAKA;AACA,MAAM,eAAe,GAAG,CAAC,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,CAAC,CAAA;SAEnF,cAAc,CACpC,IAA+B,EAC/B,KAAqC,EACrC,GAAG,QAAe;IAElB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,IAAc,CAAC,IAAI,CAAC,KAAK,EAAE;QACnF,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAA;KACnE;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,KAAK,CAA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AAC,GAAG,CAAC,CAAA;iBAC1B;aACF;SACF;KACF,CAAA;IAED,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAA;AACvE;;;;"}
1
+ {"version":3,"file":"jsx-custom-event.js","sources":["../src/polyfill/jsx-custom-event.ts"],"sourcesContent":["const React = require('react')\n\ntype MicroElementType = HTMLElement & Record<string, unknown>\n\n// lifecycles\nconst eventLifeCycles = ['oncreated', 'onbeforemount', 'onmounted', 'onunmount', 'onerror', 'ondatachange']\n\nfunction jsxCustomEvent (\n type: string | CallableFunction,\n props: Record<string, unknown> | null,\n ...children: any[]\n): void {\n if (typeof type !== 'string' || !/^micro-app(-\\S+)?/.test(type as string) || !props) {\n return React.createElement.apply(null, [type, props, ...children])\n }\n\n const newProps = Object.assign({}, props)\n\n // ref will call when create, update, unmount\n newProps.ref = (element: MicroElementType | null) => {\n if (typeof props.ref === 'function') {\n props.ref(element)\n } else if (typeof props.ref === 'object') {\n (props.ref as any).current = element\n }\n\n // when unmount and update the element is null\n if (element) {\n // Update data when the prev and next data are different\n if (toString.call(props.data) === '[object Object]' && element.data !== props.data) {\n element.data = props.data\n }\n\n for (const key in props) {\n if (\n Object.prototype.hasOwnProperty.call(props, key) &&\n eventLifeCycles.includes(key.toLowerCase()) &&\n typeof props[key] === 'function' &&\n (!element[key] || element[key] !== props[key])\n ) {\n const eventName = key.toLowerCase().replace('on', '')\n if (element[key]) {\n // @ts-ignore\n element.removeEventListener(eventName, element[key], false)\n }\n // @ts-ignore\n element.addEventListener(eventName, props[key], false)\n element[key] = props[key]\n }\n }\n }\n }\n\n return React.createElement.apply(null, [type, newProps, ...children])\n}\n\nmodule.exports = jsxCustomEvent\nmodule.exports.default = jsxCustomEvent\n"],"names":[],"mappings":"AAAA,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAI9B;AACA,MAAM,eAAe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AG,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC,EAC9C;oBACA,MAAM,SAAS,GAAG,GAAG,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;oBACrD,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE;;wBAEhB,OAAO,CAAC,mBAAmB,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAA;qBAC5D;;oBAED,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAA;oBACtD,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;iBAC1B;aACF;SACF;KACF,CAAA;IAED,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAA;AACvE,CAAC;AAED,MAAM,CAAC,OAAO,GAAG,cAAc,CAAA;AAC/B,MAAM,CAAC,OAAO,CAAC,OAAO,GAAG,cAAc"}
@@ -30,6 +30,7 @@ declare module '@micro-app/types' {
30
30
  defer: boolean // defer script
31
31
  module: boolean // module type script
32
32
  isGlobal?: boolean // share js to global
33
+ code2Function?: Function // code to Function
33
34
  }
34
35
 
35
36
  interface sourceType {
@@ -43,6 +44,7 @@ declare module '@micro-app/types' {
43
44
  isPrefetch: boolean // whether prefetch app, default is false
44
45
  name: string // app name
45
46
  url: string // app url
47
+ ssrUrl: string // html path in ssr mode
46
48
  container: HTMLElement | ShadowRoot | null // app container
47
49
  inline: boolean // whether js runs in inline script mode, default is false
48
50
  scopecss: boolean // whether use css scoped, default is true
@@ -77,6 +79,9 @@ declare module '@micro-app/types' {
77
79
 
78
80
  // get app status
79
81
  getAppStatus (): string
82
+
83
+ // actions for completely destroy
84
+ actionsForCompletelyDestory (): void
80
85
  }
81
86
 
82
87
  interface MicroAppElementType {
@@ -157,6 +162,7 @@ declare module '@micro-app/types' {
157
162
  disableScopecss?: boolean
158
163
  disableSandbox?: boolean
159
164
  macro?: boolean
165
+ ssr?: boolean
160
166
  lifeCycles?: lifeCyclesType
161
167
  preFetchApps?: prefetchParamList
162
168
  plugins?: plugins
@@ -173,6 +179,7 @@ declare module '@micro-app/types' {
173
179
  disableScopecss?: boolean
174
180
  disableSandbox?: boolean
175
181
  macro?: boolean
182
+ ssr?: boolean
176
183
  lifeCycles?: lifeCyclesType
177
184
  plugins?: plugins
178
185
  fetch?: fetchType