@micro-zoe/micro-app 0.5.2 → 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/README.md +9 -6
- package/README.zh-cn.md +10 -7
- package/lib/index.d.ts +1 -0
- package/lib/index.esm.js +8 -1
- 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 +3 -2
- package/polyfill/jsx-custom-event.js +3 -5
- package/polyfill/jsx-custom-event.js.map +1 -1
- package/typings/global.d.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micro-zoe/micro-app",
|
|
3
|
-
"version": "0.5.
|
|
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",
|
|
@@ -43,7 +43,8 @@
|
|
|
43
43
|
"test:server": "node scripts/test_server.js --start",
|
|
44
44
|
"test": "jest",
|
|
45
45
|
"test:watch": "jest --watch",
|
|
46
|
-
"test:coverage": "jest --coverage"
|
|
46
|
+
"test:coverage": "jest --coverage",
|
|
47
|
+
"prepublishOnly": "yarn lint && yarn test && yarn build"
|
|
47
48
|
},
|
|
48
49
|
"repository": {
|
|
49
50
|
"type": "git",
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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":["
|
|
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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oBAC3C,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,UAAU;qBAC/B,CAAC,OAAO,CAAC,GAAG,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"}
|
package/typings/global.d.ts
CHANGED
|
@@ -162,6 +162,7 @@ declare module '@micro-app/types' {
|
|
|
162
162
|
disableScopecss?: boolean
|
|
163
163
|
disableSandbox?: boolean
|
|
164
164
|
macro?: boolean
|
|
165
|
+
ssr?: boolean
|
|
165
166
|
lifeCycles?: lifeCyclesType
|
|
166
167
|
preFetchApps?: prefetchParamList
|
|
167
168
|
plugins?: plugins
|
|
@@ -178,6 +179,7 @@ declare module '@micro-app/types' {
|
|
|
178
179
|
disableScopecss?: boolean
|
|
179
180
|
disableSandbox?: boolean
|
|
180
181
|
macro?: boolean
|
|
182
|
+
ssr?: boolean
|
|
181
183
|
lifeCycles?: lifeCyclesType
|
|
182
184
|
plugins?: plugins
|
|
183
185
|
fetch?: fetchType
|