From 3cec16b7b1b5d277bed325ec416ee139770c179c Mon Sep 17 00:00:00 2001 From: hwaphon Date: Tue, 7 May 2024 11:10:24 +0800 Subject: [PATCH 1/9] chore(release): publish packages --- CHANGELOG.md | 16 ++++++++++++++++ lerna.json | 2 +- packages/cli/CHANGELOG.md | 8 ++++++++ packages/cli/package.json | 4 ++-- packages/create-mor/CHANGELOG.md | 8 ++++++++ packages/create-mor/package.json | 4 ++-- packages/plugin-compiler-web/CHANGELOG.md | 17 +++++++++++++++++ packages/plugin-compiler-web/package.json | 4 ++-- packages/plugin-compiler/CHANGELOG.md | 13 +++++++++++++ packages/plugin-compiler/package.json | 4 ++-- packages/runtime-web/CHANGELOG.md | 12 ++++++++++++ packages/runtime-web/package.json | 2 +- 12 files changed, 84 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 25245132..fe3199d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.110](https://github.com/eleme/morjs/compare/v1.0.109...v1.0.110) (2024-04-26) + +### Bug Fixes + +- **plugin-compiler-web:** 取用户配置空值兜底 ([bf97608](https://github.com/eleme/morjs/commit/bf976083bade3cf78821cfb339e09ec6c841cdac)) + +### Features + +- **plugin-compiler-web:** 样式文件中[@import](https://github.com/import)内容可写入样式文件 ([935871a](https://github.com/eleme/morjs/commit/935871af633322410a734537d7af90b0e37caffa)) +- **plugin-compiler-web:** 转 web 时 tabbar 兼容微信使用场景 ([33acea7](https://github.com/eleme/morjs/commit/33acea789975d66c076fd5752ec067ac95d61b49)) +- **plugin-compiler:** css 压缩获取短类名时的执行顺序调整,让业务判断获取更高的优先级 ([e3d9c3f](https://github.com/eleme/morjs/commit/e3d9c3fa8e016475bd7b10a843d94bb854a37065)) +- **plugin-compiler:** runtime 方法替换兼容 return 语句 ([caa684e](https://github.com/eleme/morjs/commit/caa684e5ccb6cea6297f33b011344d1bca5521d5)) +- **plugin-compiler:** runtime 方法替换兼容 return 语句(增强判断) ([10b4090](https://github.com/eleme/morjs/commit/10b4090cc3361fd0d06f70b69b7b5c7a5bc9b198)) +- **runtime-web:** loading 组件样式调整,对齐支付宝最新样式 ([859d075](https://github.com/eleme/morjs/commit/859d07586532350ca859169429f86600d93c7689)) +- **runtime-web:** tabbar 兼容不配置 icon 场景 ([fa15499](https://github.com/eleme/morjs/commit/fa15499f6e21b3bcf1574c60e879d93a96ee0e96)) + ## [1.0.109](https://github.com/eleme/morjs/compare/v1.0.108...v1.0.109) (2024-04-18) ### Bug Fixes diff --git a/lerna.json b/lerna.json index 59e06020..66848889 100644 --- a/lerna.json +++ b/lerna.json @@ -25,5 +25,5 @@ "message": "chore(release): publish packages" } }, - "version": "1.0.109" + "version": "1.0.110" } diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index f6f4daed..dc99e219 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.110](https://github.com/eleme/morjs/compare/v1.0.109...v1.0.110) (2024-04-26) + +**Note:** Version bump only for package @morjs/cli + + + + + ## [1.0.109](https://github.com/eleme/morjs/compare/v1.0.108...v1.0.109) (2024-04-18) **Note:** Version bump only for package @morjs/cli diff --git a/packages/cli/package.json b/packages/cli/package.json index f7211cbf..cc74f54b 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@morjs/cli", - "version": "1.0.109", + "version": "1.0.110", "description": "mor cli", "keywords": [ "mor", @@ -34,7 +34,7 @@ }, "dependencies": { "@morjs/plugin-analyzer": "1.0.71", - "@morjs/plugin-compiler": "1.0.109", + "@morjs/plugin-compiler": "1.0.110", "@morjs/plugin-composer": "1.0.72", "@morjs/plugin-generator": "1.0.71", "@morjs/plugin-mocker": "1.0.71", diff --git a/packages/create-mor/CHANGELOG.md b/packages/create-mor/CHANGELOG.md index 0a3cda70..27e8217e 100644 --- a/packages/create-mor/CHANGELOG.md +++ b/packages/create-mor/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.110](https://github.com/eleme/morjs/compare/v1.0.109...v1.0.110) (2024-04-26) + +**Note:** Version bump only for package create-mor + + + + + ## [1.0.109](https://github.com/eleme/morjs/compare/v1.0.108...v1.0.109) (2024-04-18) **Note:** Version bump only for package create-mor diff --git a/packages/create-mor/package.json b/packages/create-mor/package.json index e88f0aa1..8f244277 100644 --- a/packages/create-mor/package.json +++ b/packages/create-mor/package.json @@ -1,6 +1,6 @@ { "name": "create-mor", - "version": "1.0.109", + "version": "1.0.110", "license": "MIT", "authors": [ "Felix Liu (https://github.com/lyfeyaj)" @@ -26,6 +26,6 @@ }, "homepage": "https://github.com/eleme/morjs/tree/main/packages/create-mor#readme", "dependencies": { - "@morjs/cli": "1.0.109" + "@morjs/cli": "1.0.110" } } diff --git a/packages/plugin-compiler-web/CHANGELOG.md b/packages/plugin-compiler-web/CHANGELOG.md index 14196b55..afb29193 100644 --- a/packages/plugin-compiler-web/CHANGELOG.md +++ b/packages/plugin-compiler-web/CHANGELOG.md @@ -3,6 +3,23 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.110](https://github.com/eleme/morjs/compare/v1.0.109...v1.0.110) (2024-04-26) + + +### Bug Fixes + +* **plugin-compiler-web:** 取用户配置空值兜底 ([bf97608](https://github.com/eleme/morjs/commit/bf976083bade3cf78821cfb339e09ec6c841cdac)) + + +### Features + +* **plugin-compiler-web:** 样式文件中[@import](https://github.com/import)内容可写入样式文件 ([935871a](https://github.com/eleme/morjs/commit/935871af633322410a734537d7af90b0e37caffa)) +* **plugin-compiler-web:** 转 web 时 tabbar 兼容微信使用场景 ([33acea7](https://github.com/eleme/morjs/commit/33acea789975d66c076fd5752ec067ac95d61b49)) + + + + + ## [1.0.108](https://github.com/eleme/morjs/compare/v1.0.107...v1.0.108) (2024-04-15) diff --git a/packages/plugin-compiler-web/package.json b/packages/plugin-compiler-web/package.json index c4d5b742..f04a9e59 100644 --- a/packages/plugin-compiler-web/package.json +++ b/packages/plugin-compiler-web/package.json @@ -1,6 +1,6 @@ { "name": "@morjs/plugin-compiler-web", - "version": "1.0.108", + "version": "1.0.110", "description": "mor complier plugin for web", "keywords": [ "mor", @@ -32,7 +32,7 @@ "dependencies": { "@babel/runtime": "7.21.0", "@morjs/plugin-compiler-alipay": "1.0.106", - "@morjs/runtime-web": "1.0.108", + "@morjs/runtime-web": "1.0.110", "@morjs/utils": "1.0.71", "postcss": "7.0.39", "postcss-import-sync": "7.1.4" diff --git a/packages/plugin-compiler/CHANGELOG.md b/packages/plugin-compiler/CHANGELOG.md index f55160b7..116078a9 100644 --- a/packages/plugin-compiler/CHANGELOG.md +++ b/packages/plugin-compiler/CHANGELOG.md @@ -3,6 +3,19 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.110](https://github.com/eleme/morjs/compare/v1.0.109...v1.0.110) (2024-04-26) + + +### Features + +* **plugin-compiler:** css 压缩获取短类名时的执行顺序调整,让业务判断获取更高的优先级 ([e3d9c3f](https://github.com/eleme/morjs/commit/e3d9c3fa8e016475bd7b10a843d94bb854a37065)) +* **plugin-compiler:** runtime 方法替换兼容 return 语句 ([caa684e](https://github.com/eleme/morjs/commit/caa684e5ccb6cea6297f33b011344d1bca5521d5)) +* **plugin-compiler:** runtime 方法替换兼容 return 语句(增强判断) ([10b4090](https://github.com/eleme/morjs/commit/10b4090cc3361fd0d06f70b69b7b5c7a5bc9b198)) + + + + + ## [1.0.109](https://github.com/eleme/morjs/compare/v1.0.108...v1.0.109) (2024-04-18) diff --git a/packages/plugin-compiler/package.json b/packages/plugin-compiler/package.json index fb5ab4e9..9a504b80 100644 --- a/packages/plugin-compiler/package.json +++ b/packages/plugin-compiler/package.json @@ -1,6 +1,6 @@ { "name": "@morjs/plugin-compiler", - "version": "1.0.109", + "version": "1.0.110", "description": "mor compiler plugin", "keywords": [ "mor", @@ -37,7 +37,7 @@ "@morjs/plugin-compiler-kuaishou": "1.0.106", "@morjs/plugin-compiler-qq": "1.0.106", "@morjs/plugin-compiler-taobao": "1.0.106", - "@morjs/plugin-compiler-web": "1.0.108", + "@morjs/plugin-compiler-web": "1.0.110", "@morjs/plugin-compiler-wechat": "1.0.106", "@morjs/runtime-mini": "1.0.106", "@morjs/utils": "1.0.71", diff --git a/packages/runtime-web/CHANGELOG.md b/packages/runtime-web/CHANGELOG.md index 5ea8a19c..d2775493 100644 --- a/packages/runtime-web/CHANGELOG.md +++ b/packages/runtime-web/CHANGELOG.md @@ -3,6 +3,18 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [1.0.110](https://github.com/eleme/morjs/compare/v1.0.109...v1.0.110) (2024-04-26) + + +### Features + +* **runtime-web:** loading 组件样式调整,对齐支付宝最新样式 ([859d075](https://github.com/eleme/morjs/commit/859d07586532350ca859169429f86600d93c7689)) +* **runtime-web:** tabbar 兼容不配置 icon 场景 ([fa15499](https://github.com/eleme/morjs/commit/fa15499f6e21b3bcf1574c60e879d93a96ee0e96)) + + + + + ## [1.0.108](https://github.com/eleme/morjs/compare/v1.0.107...v1.0.108) (2024-04-15) diff --git a/packages/runtime-web/package.json b/packages/runtime-web/package.json index 1c88ee1f..c00886aa 100644 --- a/packages/runtime-web/package.json +++ b/packages/runtime-web/package.json @@ -1,6 +1,6 @@ { "name": "@morjs/runtime-web", - "version": "1.0.108", + "version": "1.0.110", "description": "mor runtime for web", "keywords": [ "mor", From 13f1da08e47d8db5d7a3d7aabcbea6451ef09e90 Mon Sep 17 00:00:00 2001 From: hwaphon Date: Sun, 28 Apr 2024 10:59:24 +0800 Subject: [PATCH 2/9] =?UTF-8?q?feat(plugin-compiler-alipay):=20=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E4=BF=9D=E5=AD=98=E6=96=B9=E6=B3=95=E6=9C=BA=E5=88=B6?= =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/templateProcessorToOther.ts | 25 ++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/plugin-compiler-alipay/src/templateProcessorToOther.ts b/packages/plugin-compiler-alipay/src/templateProcessorToOther.ts index aca321bb..d10baa06 100644 --- a/packages/plugin-compiler-alipay/src/templateProcessorToOther.ts +++ b/packages/plugin-compiler-alipay/src/templateProcessorToOther.ts @@ -17,6 +17,22 @@ import { isNativeTag } from './templateTags' type NodeAttributes = Record +/** + * 构建键值对字符串 + * @param {Object} param - 包含键值对的对象 + * @returns {string} - 键值对组合成的字符串,键和值之间以下划线连接,各对之间以破折号分隔 + */ +function buildPairs(param) { + const keys = Object.keys(param) + + return keys.reduce((pre, key, index) => { + const value = param[key] + const suffix = index === keys.length - 1 ? '' : '-' + + return (pre += `${key}_${value}${suffix}`) + }, '') +} + /** * 自定义 template 处理 * 处理 支付宝转 其他小程序的兼容性 @@ -100,8 +116,8 @@ export const templateProcessorToOther = { } // 事件代理名称 -const PROXY_EVENT_NAME = '$morEventHandlerProxy' -const EVENT_HANDLER_NAME = 'data-mor-event-handlers' +const PROXY_EVENT_NAME = '$morEHP' // $morEventHandlerProxy +const EVENT_HANDLER_NAME = 'data-meh' // data-mor-event-handlers const PROXY_DISABLE_EVENT_NAME = '$morDisableScrollProxy' /** @@ -117,10 +133,7 @@ function processEventProxy( Object.keys(context.morHandlersMap).length && !options.userConfig?.processComponentsPropsFunction ) { - node.attrs[EVENT_HANDLER_NAME] = Buffer.from( - JSON.stringify(context.morHandlersMap) - ).toString('base64') - + node.attrs[EVENT_HANDLER_NAME] = buildPairs(context.morHandlersMap) delete context.morHandlersMap } } From 4162bd18b5d06a6fd36853a726588255394600b6 Mon Sep 17 00:00:00 2001 From: hwaphon Date: Sun, 28 Apr 2024 11:03:17 +0800 Subject: [PATCH 3/9] =?UTF-8?q?feat(runtime-mini):=20=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=A7=A3=E6=9E=90=E9=85=8D=E5=90=88=E6=94=B9?= =?UTF-8?q?=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/alipay/componentToOther.ts | 24 +++++++++++++++---- .../runtime-mini/src/alipay/utilsToOther.ts | 2 +- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/packages/runtime-mini/src/alipay/componentToOther.ts b/packages/runtime-mini/src/alipay/componentToOther.ts index c99b412c..53cf4bd5 100644 --- a/packages/runtime-mini/src/alipay/componentToOther.ts +++ b/packages/runtime-mini/src/alipay/componentToOther.ts @@ -1,5 +1,4 @@ import { - Base64, compose, generateId, getSharedProperty, @@ -13,7 +12,7 @@ const MOR_PREFIX = 'mor' as const /** * 保存在 dataset 的事件代理相关方法名称映射 */ -const MOR_EVENT_HANDLERS_DATASET = `${MOR_PREFIX}EventHandlers` as const +const MOR_EVENT_HANDLERS_DATASET = `meh` as const /** * 用于保存事件代理相关方法名称映射 */ @@ -112,6 +111,24 @@ function cloneDeep>( } } +/** + * 根据键值对字符串创建对象 + * @param {string} param - 以短横线分隔的键值对字符串,形如 "key1_value1-key2_value2" + * @returns {Object} - 创建的对象,键为原始字符串中的 key,值为对应的 value + */ +function getObjectFromPairs(param) { + const result = {} + if (typeof param !== 'string') return result + + const paramsArr = param.split('-') + paramsArr.forEach((pair) => { + const [key, value] = pair.split('_') + result[key] = value + }) + + return result +} + /** * 生成随机不重复事件 ID * @returns 事件 ID @@ -517,10 +534,9 @@ function hookComponentLifeCycle( const injectEventHandlers = function (): void { const morEventHandlers = this.dataset?.[MOR_EVENT_HANDLERS_DATASET] - if (morEventHandlers) { try { - this[MOR_EVENT_HANDLERS] = JSON.parse(Base64.decode(morEventHandlers)) + this[MOR_EVENT_HANDLERS] = getObjectFromPairs(morEventHandlers) // ref 支持 if (this[MOR_EVENT_HANDLERS].ref) { diff --git a/packages/runtime-mini/src/alipay/utilsToOther.ts b/packages/runtime-mini/src/alipay/utilsToOther.ts index c853708f..abd27e8d 100644 --- a/packages/runtime-mini/src/alipay/utilsToOther.ts +++ b/packages/runtime-mini/src/alipay/utilsToOther.ts @@ -30,7 +30,7 @@ export function addEventProxy(options: Record): void { * 支付宝小程序转其他小程序的事件代理函数 * @param event 事件 */ - options.$morEventHandlerProxy = function (event: IEvent): void { + options.$morEHP = function (event: IEvent): void { const { name, args, id } = event.detail let value: any From 3b9f59b882d8c8edb7d0d19cbe456ba4f2949729 Mon Sep 17 00:00:00 2001 From: hwaphon Date: Sun, 28 Apr 2024 11:28:37 +0800 Subject: [PATCH 4/9] =?UTF-8?q?feat(utils=20&=20runtime-base):=20=E4=B8=BA?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E6=97=B6&=E8=BF=90=E8=A1=8C=E6=97=B6?= =?UTF-8?q?=E6=8F=90=E4=BE=9B=E7=BB=9F=E4=B8=80=E7=9A=84=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/runtime-base/src/utils/pairs.ts | 35 ++++++++++++++++++++++++ packages/utils/src/pairs.ts | 35 ++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 packages/runtime-base/src/utils/pairs.ts create mode 100644 packages/utils/src/pairs.ts diff --git a/packages/runtime-base/src/utils/pairs.ts b/packages/runtime-base/src/utils/pairs.ts new file mode 100644 index 00000000..d3beddde --- /dev/null +++ b/packages/runtime-base/src/utils/pairs.ts @@ -0,0 +1,35 @@ +export const Pairs = { + /** + * 构建键值对字符串 + * @param {Object} param - 包含键值对的对象 + * @returns {string} - 键值对组合成的字符串,键和值之间以下划线连接,各对之间以破折号分隔 + */ + toString(param: Record): string { + const keys = Object.keys(param) + + return keys.reduce((pre, key, index) => { + const value = param[key] + const suffix = index === keys.length - 1 ? '' : '-' + + return (pre += `${key}_${value}${suffix}`) + }, '') + }, + + /** + * 根据键值对字符串创建对象 + * @param {string} param - 以短横线分隔的键值对字符串,形如 "key1_value1-key2_value2" + * @returns {Object} - 创建的对象,键为原始字符串中的 key,值为对应的 value + */ + toObject(param: string): Record { + const result = {} + if (typeof param !== 'string') return result + + const paramsArr = param.split('-') + paramsArr.forEach((pair) => { + const [key, value] = pair.split('_') + result[key] = value + }) + + return result + } +} diff --git a/packages/utils/src/pairs.ts b/packages/utils/src/pairs.ts new file mode 100644 index 00000000..d3beddde --- /dev/null +++ b/packages/utils/src/pairs.ts @@ -0,0 +1,35 @@ +export const Pairs = { + /** + * 构建键值对字符串 + * @param {Object} param - 包含键值对的对象 + * @returns {string} - 键值对组合成的字符串,键和值之间以下划线连接,各对之间以破折号分隔 + */ + toString(param: Record): string { + const keys = Object.keys(param) + + return keys.reduce((pre, key, index) => { + const value = param[key] + const suffix = index === keys.length - 1 ? '' : '-' + + return (pre += `${key}_${value}${suffix}`) + }, '') + }, + + /** + * 根据键值对字符串创建对象 + * @param {string} param - 以短横线分隔的键值对字符串,形如 "key1_value1-key2_value2" + * @returns {Object} - 创建的对象,键为原始字符串中的 key,值为对应的 value + */ + toObject(param: string): Record { + const result = {} + if (typeof param !== 'string') return result + + const paramsArr = param.split('-') + paramsArr.forEach((pair) => { + const [key, value] = pair.split('_') + result[key] = value + }) + + return result + } +} From 08ba15d6ee8e6138650833539c47477d14084382 Mon Sep 17 00:00:00 2001 From: hwaphon Date: Sun, 28 Apr 2024 11:29:07 +0800 Subject: [PATCH 5/9] =?UTF-8?q?feat(plugin-compiler-alipay):=20=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E4=BF=9D=E5=AD=98=E6=96=B9=E6=B3=95=E6=9C=BA=E5=88=B6?= =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/templateProcessorToOther.ts | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/packages/plugin-compiler-alipay/src/templateProcessorToOther.ts b/packages/plugin-compiler-alipay/src/templateProcessorToOther.ts index d10baa06..2cb474f4 100644 --- a/packages/plugin-compiler-alipay/src/templateProcessorToOther.ts +++ b/packages/plugin-compiler-alipay/src/templateProcessorToOther.ts @@ -1,6 +1,7 @@ import { FileParserOptions, logger, + Pairs, posthtml, tsTransformerFactory, typescript as ts @@ -17,22 +18,6 @@ import { isNativeTag } from './templateTags' type NodeAttributes = Record -/** - * 构建键值对字符串 - * @param {Object} param - 包含键值对的对象 - * @returns {string} - 键值对组合成的字符串,键和值之间以下划线连接,各对之间以破折号分隔 - */ -function buildPairs(param) { - const keys = Object.keys(param) - - return keys.reduce((pre, key, index) => { - const value = param[key] - const suffix = index === keys.length - 1 ? '' : '-' - - return (pre += `${key}_${value}${suffix}`) - }, '') -} - /** * 自定义 template 处理 * 处理 支付宝转 其他小程序的兼容性 @@ -133,7 +118,7 @@ function processEventProxy( Object.keys(context.morHandlersMap).length && !options.userConfig?.processComponentsPropsFunction ) { - node.attrs[EVENT_HANDLER_NAME] = buildPairs(context.morHandlersMap) + node.attrs[EVENT_HANDLER_NAME] = Pairs.toString(context.morHandlersMap) delete context.morHandlersMap } } From 0cc9c629600f91ede99897e72c14bdd7412ff7fc Mon Sep 17 00:00:00 2001 From: hwaphon Date: Sun, 28 Apr 2024 11:29:32 +0800 Subject: [PATCH 6/9] =?UTF-8?q?feat(plugin-compiler-alipay):=20=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E4=BF=9D=E5=AD=98=E6=96=B9=E6=B3=95=E6=9C=BA=E5=88=B6?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=EF=BC=88=E7=BB=84=E4=BB=B6=E7=BB=B4=E6=8A=A4?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E6=94=AF=E6=8C=81=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugins/processComponentsPropsFunctionPlugin.ts | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/plugin-compiler/src/plugins/processComponentsPropsFunctionPlugin.ts b/packages/plugin-compiler/src/plugins/processComponentsPropsFunctionPlugin.ts index bd81b7bd..7eaa5229 100644 --- a/packages/plugin-compiler/src/plugins/processComponentsPropsFunctionPlugin.ts +++ b/packages/plugin-compiler/src/plugins/processComponentsPropsFunctionPlugin.ts @@ -3,6 +3,7 @@ import { EntryType, fsExtra as fs, lodash as _, + Pairs, Plugin, Runner, SourceTypes, @@ -142,15 +143,11 @@ export class ProcessComponentsPropsFunctionPlugin implements Plugin { // props 中的函数传参 const propsFunction = propsFunctionList .map((item) => { - return `bind:${this.getEventName( - item - )}="$morEventHandlerProxy" ` + return `bind:${this.getEventName(item)}="$morEHP" ` }) .join('') - const eventHandlerName = Buffer.from( - JSON.stringify(propsMorHandlers) - ).toString('base64') - return `` + const eventHandlerName = Pairs.toString(propsMorHandlers) + return `` } else if ( options?.fileInfo?.entryFileType === EntryFileType.style ) { @@ -188,7 +185,7 @@ export class ProcessComponentsPropsFunctionPlugin implements Plugin { ${properties} }, methods: { - $morEventHandlerProxy(event) { + $morEHP(event) { const { detail } = event; if (detail.name) { this.triggerEvent(event.type, { ...detail.args[0] }) From 91199511e89b40a10767f52ac0ffdb617e2959de Mon Sep 17 00:00:00 2001 From: hwaphon Date: Sun, 28 Apr 2024 11:30:07 +0800 Subject: [PATCH 7/9] =?UTF-8?q?feat(runtime-mini):=20=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E8=A7=A3=E6=9E=90=E9=85=8D=E5=90=88=E6=94=B9?= =?UTF-8?q?=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/alipay/componentToOther.ts | 25 +++---------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/packages/runtime-mini/src/alipay/componentToOther.ts b/packages/runtime-mini/src/alipay/componentToOther.ts index 53cf4bd5..d692372c 100644 --- a/packages/runtime-mini/src/alipay/componentToOther.ts +++ b/packages/runtime-mini/src/alipay/componentToOther.ts @@ -2,7 +2,8 @@ import { compose, generateId, getSharedProperty, - logger + logger, + Pairs } from '@morjs/runtime-base' import clone from 'clone-deep' import { injectHasMixinSupport } from '../common/behaviorOrMixin' @@ -111,24 +112,6 @@ function cloneDeep>( } } -/** - * 根据键值对字符串创建对象 - * @param {string} param - 以短横线分隔的键值对字符串,形如 "key1_value1-key2_value2" - * @returns {Object} - 创建的对象,键为原始字符串中的 key,值为对应的 value - */ -function getObjectFromPairs(param) { - const result = {} - if (typeof param !== 'string') return result - - const paramsArr = param.split('-') - paramsArr.forEach((pair) => { - const [key, value] = pair.split('_') - result[key] = value - }) - - return result -} - /** * 生成随机不重复事件 ID * @returns 事件 ID @@ -516,7 +499,7 @@ function hookComponentLifeCycle( } // 触发小程序原生事件 - // 事件会被 $morEventHandlerProxy 事件代理方法捕获 + // 事件会被 $morEHP 事件代理方法捕获 // 并触发 event 事件, 基于 eventId this.triggerEvent(triggerEventName, { name: this[MOR_EVENT_HANDLERS][triggerEventName], @@ -536,7 +519,7 @@ function hookComponentLifeCycle( const morEventHandlers = this.dataset?.[MOR_EVENT_HANDLERS_DATASET] if (morEventHandlers) { try { - this[MOR_EVENT_HANDLERS] = getObjectFromPairs(morEventHandlers) + this[MOR_EVENT_HANDLERS] = Pairs.toObject(morEventHandlers) // ref 支持 if (this[MOR_EVENT_HANDLERS].ref) { From 8a036cfa8f6f66acf2b15a15ff16350756585030 Mon Sep 17 00:00:00 2001 From: hwaphon Date: Sun, 28 Apr 2024 11:30:26 +0800 Subject: [PATCH 8/9] =?UTF-8?q?feat(utils=20&=20runtime-base):=20=E4=B8=BA?= =?UTF-8?q?=E7=BC=96=E8=AF=91=E6=97=B6&=E8=BF=90=E8=A1=8C=E6=97=B6?= =?UTF-8?q?=E6=8F=90=E4=BE=9B=E7=BB=9F=E4=B8=80=E7=9A=84=E5=B7=A5=E5=85=B7?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/runtime-base/src/utils/index.ts | 1 + packages/utils/src/index.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/runtime-base/src/utils/index.ts b/packages/runtime-base/src/utils/index.ts index d1b33678..34291e92 100644 --- a/packages/runtime-base/src/utils/index.ts +++ b/packages/runtime-base/src/utils/index.ts @@ -3,4 +3,5 @@ export * from './compose' export * from './generateId' export * from './getSharedProperty' export * from './hasOwnProperty' +export * from './pairs' export * from './transformApis' diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts index 091b46e2..d80014ff 100644 --- a/packages/utils/src/index.ts +++ b/packages/utils/src/index.ts @@ -38,6 +38,7 @@ export * from './babelDeps' export * from './constants' export * from './hooks' export * from './moduleGraph' +export * from './pairs' export * from './queue' export * from './types' export * from './utils' From e32f6470846c52fbdeddc911a2ad5ba7cd98113e Mon Sep 17 00:00:00 2001 From: hwaphon Date: Tue, 7 May 2024 11:14:55 +0800 Subject: [PATCH 9/9] =?UTF-8?q?feat(runtime-base):=20=E7=A7=BB=E9=99=A4=20?= =?UTF-8?q?pairs=20=E4=B8=AD=E7=9A=84=20toString=EF=BC=8C=E9=99=8D?= =?UTF-8?q?=E4=BD=8E=E8=BF=90=E8=A1=8C=E6=97=B6=E5=8C=85=E5=A4=A7=E5=B0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/runtime-base/src/utils/pairs.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/packages/runtime-base/src/utils/pairs.ts b/packages/runtime-base/src/utils/pairs.ts index d3beddde..ef5a9a47 100644 --- a/packages/runtime-base/src/utils/pairs.ts +++ b/packages/runtime-base/src/utils/pairs.ts @@ -1,20 +1,4 @@ export const Pairs = { - /** - * 构建键值对字符串 - * @param {Object} param - 包含键值对的对象 - * @returns {string} - 键值对组合成的字符串,键和值之间以下划线连接,各对之间以破折号分隔 - */ - toString(param: Record): string { - const keys = Object.keys(param) - - return keys.reduce((pre, key, index) => { - const value = param[key] - const suffix = index === keys.length - 1 ? '' : '-' - - return (pre += `${key}_${value}${suffix}`) - }, '') - }, - /** * 根据键值对字符串创建对象 * @param {string} param - 以短横线分隔的键值对字符串,形如 "key1_value1-key2_value2"