From b4317ecddcbebde990dcc142abce5f7e9d4b254f Mon Sep 17 00:00:00 2001 From: * <8> Date: Tue, 20 Sep 2022 20:11:37 +0800 Subject: [PATCH 1/3] Match-id-04a3b220932d28b652d605dde0f351a22f4db24c --- libs/horizon/src/event/EventBinding.ts | 6 ++++-- libs/horizon/src/event/EventHub.ts | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/horizon/src/event/EventBinding.ts b/libs/horizon/src/event/EventBinding.ts index 0623c9fb..9236eaa6 100644 --- a/libs/horizon/src/event/EventBinding.ts +++ b/libs/horizon/src/event/EventBinding.ts @@ -7,7 +7,7 @@ import { } from './EventHub'; import { isDocument } from '../dom/utils/Common'; import { getNearestVNode, getNonDelegatedListenerMap } from '../dom/DOMInternalKeys'; -import { runDiscreteUpdates } from '../renderer/TreeBuilder'; +import { asyncUpdates, runDiscreteUpdates } from '../renderer/TreeBuilder'; import { handleEventMain } from './HorizonEventMain'; import { decorateNativeEvent } from './EventWrapper'; import { VNode } from '../renderer/vnode/VNode'; @@ -98,7 +98,9 @@ function isCaptureEvent(horizonEventName) { function getWrapperListener(horizonEventName, nativeEvtName, targetElement, listener) { return event => { const customEvent = decorateNativeEvent(horizonEventName, nativeEvtName, event); - listener(customEvent); + asyncUpdates(() => { + listener(customEvent); + }); }; } diff --git a/libs/horizon/src/event/EventHub.ts b/libs/horizon/src/event/EventHub.ts index 944112f2..b357730a 100644 --- a/libs/horizon/src/event/EventHub.ts +++ b/libs/horizon/src/event/EventHub.ts @@ -12,6 +12,7 @@ export const horizonEventToNativeMap = new Map([ ['onFocus', ['focusin']], ['onBlur', ['focusout']], ['onInput', ['input']], + ['onWheel', ['wheel']], ['onMouseOut', ['mouseout']], ['onMouseOver', ['mouseover']], ['onPointerOut', ['pointerout']], @@ -41,6 +42,7 @@ export const horizonEventToNativeMap = new Map([ ]); export const NativeEventToHorizonMap = { click: 'click', + wheel: 'wheel', dblclick: 'doubleClick', contextmenu: 'contextMenu', dragend: 'dragEnd', From 670f453e232b852dc906054dca476d8cab5dc467 Mon Sep 17 00:00:00 2001 From: * <8> Date: Tue, 20 Sep 2022 20:22:04 +0800 Subject: [PATCH 2/3] Match-id-85c86904506cfb0430fae36e0c237772bab23d82 --- CHANGELOG.md | 3 +++ libs/horizon/package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a01913e..23420f42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.0.21 (2022-09-20) +- **core**: #85 所有事件中发生的多次更新都合并执行 +- ## 0.0.20 (2022-09-14) - **core**: #81 fix Memo场景路径错误 diff --git a/libs/horizon/package.json b/libs/horizon/package.json index 83d12372..e7b57197 100644 --- a/libs/horizon/package.json +++ b/libs/horizon/package.json @@ -4,7 +4,7 @@ "keywords": [ "horizon" ], - "version": "0.0.20", + "version": "0.0.21", "homepage": "", "bugs": "", "main": "index.js", From 17a8e1b13efc12d443cf72a6fc68c03e4eb6e56b Mon Sep 17 00:00:00 2001 From: * <8> Date: Wed, 21 Sep 2022 15:55:40 +0800 Subject: [PATCH 3/3] Match-id-12d462d57e45d6a2337ce371637f7c45bec9ff99 --- package.json | 6 +++--- scripts/gen3rdLib.js | 50 +++++++++++++------------------------------- 2 files changed, 18 insertions(+), 38 deletions(-) diff --git a/package.json b/package.json index 500c07f5..c939f970 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,9 @@ "lint": "eslint . --ext .ts", "build": "rollup --config ./scripts/rollup/rollup.config.js", "build:watch": "rollup --watch --config ./scripts/rollup/rollup.config.js", - "build-3rdLib": "node ./scripts/gen3rdLib.js", - "build-3rdLib-dev": "npm run build & node ./scripts/gen3rdLib.js --dev", - "build-horizon3rdLib-dev": "npm run build & node ./scripts/gen3rdLib.js --dev --type horizon", + "build:3rdLib": "node ./scripts/gen3rdLib.js build:3rdLib", + "build:3rdLib-dev": "npm run build & node ./scripts/gen3rdLib.js build:3rdLib-dev", + "build:horizon3rdLib-dev": "npm run build & node ./scripts/gen3rdLib.js build:horizon3rdLib-dev", "build-types": "tsc -p ./libs/horizon/index.ts --emitDeclarationOnly --declaration --declarationDir ./build/horizon/@types --skipLibCheck", "debug-test": "yarn test --debug", "test": "jest --config=jest.config.js", diff --git a/scripts/gen3rdLib.js b/scripts/gen3rdLib.js index 26a55887..b8495dc0 100644 --- a/scripts/gen3rdLib.js +++ b/scripts/gen3rdLib.js @@ -1,44 +1,24 @@ 'use strict'; -const ejs = require('ejs'); -const fs = require('fs'); const path = require('path'); -const chalk = require('chalk'); -const console = require('console'); -const rimRaf = require('rimRaf'); -const argv = require('minimist')(process.argv.slice(2)); +const fs = require('fs'); +const childProcess = require('child_process'); -const libPathPrefix = '../build'; -const suffix = argv.dev ? 'development.js' : 'production.js'; -const template = argv.type === 'horizon' ? 'horizon3rdTemplate.ejs' : 'template.ejs'; -const templatePath = path.resolve(__dirname, `./${template}`); -if (!fs.existsSync(templatePath)) { - console.log(chalk.yellow('Failed: Template file not exist')); - return; +const horizonEcoPath = path.resolve(__dirname, '../../horizon-ecosystem'); +if (!fs.existsSync(horizonEcoPath)) { + throw Error('horizon-ecosystem not found, put horizon-core and horizon-ecosystem in same folder plz!'); } -const readLib = lib => { - const libName = lib.split('.')[0]; - const libPath = path.resolve(__dirname, `${libPathPrefix}/${libName}/umd/${lib}`); - if (fs.existsSync(libPath)) { - return fs.readFileSync(libPath, 'utf-8'); - } else { - console.log(chalk.red(`Error: "${libPath}" 文件不存在\n先运行 npm run build`)); - } -}; -ejs.renderFile( - path.resolve(__dirname, `./${template}`), +const cmd = process.argv[2]; +childProcess.exec( + `npm run ${cmd}`, { - Horizon: readLib(`horizon.${suffix}`), + cwd: horizonEcoPath, }, - null, - function(err, result) { - const common3rdLibPath = path.resolve(__dirname, `${libPathPrefix}/horizonCommon3rdlib.min.js`); - rimRaf(common3rdLibPath, e => { - if (e) { - console.log(e); - } - fs.writeFileSync(common3rdLibPath, result); - console.log(chalk.green(`成功生成: ${common3rdLibPath}`)); - }); + function (error, stdout) { + if (error) { + console.log(`Error: ${error}`); + } else { + console.log(`STDOUT: ${stdout}`); + } } );