From 15528a010a4e48015ec61a13c66caa24bfee0f2d Mon Sep 17 00:00:00 2001 From: yaoyuchi Date: Tue, 29 Mar 2022 10:33:44 +0800 Subject: [PATCH 1/5] event support bubble Signed-off-by: yaoyuchi --- .../plugin/templater/component_validator.js | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/ace-loader/plugin/templater/component_validator.js b/ace-loader/plugin/templater/component_validator.js index 93ca88b..94ed709 100644 --- a/ace-loader/plugin/templater/component_validator.js +++ b/ace-loader/plugin/templater/component_validator.js @@ -1054,6 +1054,9 @@ const START_CATCH_REGEXP = /^(grab:)/; const END_CAPTURE_REGEXP = /(\.capture)$/; const TOUCH_EVENT_REGEXP = /^(touch)/; const CLICK_EVENT_REGEXP = /^(click)$/; +const LONG_PRESS_EVENT_REGEXP = /^(longpress)$/; +const DOUBLE_CLICK_EVENT_REGEXP = /^(doubleclick)$/; +const SWIPE_EVENT_REGEXP = /^(swipe)$/; const TOUCH_CAPTURE_EVENT_REGEXP = /^(?!touch).*?(\.capture)$/; /** @@ -1127,9 +1130,36 @@ function distributeEvent(out, eventName, name, val) { out.jsonTemplate.onBubbleEvents = out.jsonTemplate.onBubbleEvents || {} out.jsonTemplate.onBubbleEvents[name] = val } -} else { - out.jsonTemplate.events = out.jsonTemplate.events || {} - out.jsonTemplate.events[name] = val + } else if(process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH && LONG_PRESS_EVENT_REGEXP.test(name) && + !eventName.match(END_CAPTURE_REGEXP) && process.env.PLATFORM_VERSION === PLATFORM.VERSION6){ + if (eventName.match(START_CATCH_REGEXP)) { + out.jsonTemplate.catchBubbleEvents = out.jsonTemplate.catchBubbleEvents || {} + out.jsonTemplate.catchBubbleEvents[name] = val + } else { + out.jsonTemplate.onBubbleEvents = out.jsonTemplate.onBubbleEvents || {} + out.jsonTemplate.onBubbleEvents[name] = val + } + } else if(process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH && DOUBLE_CLICK_EVENT_REGEXP.test(name) && + !eventName.match(END_CAPTURE_REGEXP) && process.env.PLATFORM_VERSION === PLATFORM.VERSION6) { + if (eventName.match(START_CATCH_REGEXP)) { + out.jsonTemplate.catchBubbleEvents = out.jsonTemplate.catchBubbleEvents || {} + out.jsonTemplate.catchBubbleEvents[name] = val + } else { + out.jsonTemplate.onBubbleEvents = out.jsonTemplate.onBubbleEvents || {} + out.jsonTemplate.onBubbleEvents[name] = val + } + } else if(process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH && SWIPE_EVENT_REGEXP.test(name) && + !eventName.match(END_CAPTURE_REGEXP) && process.env.PLATFORM_VERSION === PLATFORM.VERSION6) { + if (eventName.match(START_CATCH_REGEXP)) { + out.jsonTemplate.catchBubbleEvents = out.jsonTemplate.catchBubbleEvents || {} + out.jsonTemplate.catchBubbleEvents[name] = val + } else { + out.jsonTemplate.onBubbleEvents = out.jsonTemplate.onBubbleEvents || {} + out.jsonTemplate.onBubbleEvents[name] = val + } + } else { + out.jsonTemplate.events = out.jsonTemplate.events || {} + out.jsonTemplate.events[name] = val } } -- Gitee From a107cfcb7bf187a2a71c218fe4c609e6ad5517fa Mon Sep 17 00:00:00 2001 From: yaoyuchi Date: Thu, 31 Mar 2022 09:35:10 +0800 Subject: [PATCH 2/5] event support bubble Signed-off-by: yaoyuchi --- .../plugin/templater/component_validator.js | 36 ++++++------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/ace-loader/plugin/templater/component_validator.js b/ace-loader/plugin/templater/component_validator.js index 94ed709..5eb6a14 100644 --- a/ace-loader/plugin/templater/component_validator.js +++ b/ace-loader/plugin/templater/component_validator.js @@ -1123,33 +1123,23 @@ function distributeEvent(out, eventName, name, val) { } } else if (process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH && CLICK_EVENT_REGEXP.test(name) && !eventName.match(END_CAPTURE_REGEXP) && process.env.PLATFORM_VERSION === PLATFORM.VERSION6) { - if (eventName.match(START_CATCH_REGEXP)) { - out.jsonTemplate.catchBubbleEvents = out.jsonTemplate.catchBubbleEvents || {} - out.jsonTemplate.catchBubbleEvents[name] = val - } else { - out.jsonTemplate.onBubbleEvents = out.jsonTemplate.onBubbleEvents || {} - out.jsonTemplate.onBubbleEvents[name] = val - } + dealJson(out, eventName, name, val) } else if(process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH && LONG_PRESS_EVENT_REGEXP.test(name) && !eventName.match(END_CAPTURE_REGEXP) && process.env.PLATFORM_VERSION === PLATFORM.VERSION6){ - if (eventName.match(START_CATCH_REGEXP)) { - out.jsonTemplate.catchBubbleEvents = out.jsonTemplate.catchBubbleEvents || {} - out.jsonTemplate.catchBubbleEvents[name] = val - } else { - out.jsonTemplate.onBubbleEvents = out.jsonTemplate.onBubbleEvents || {} - out.jsonTemplate.onBubbleEvents[name] = val - } + dealJson(out, eventName, name, val) } else if(process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH && DOUBLE_CLICK_EVENT_REGEXP.test(name) && !eventName.match(END_CAPTURE_REGEXP) && process.env.PLATFORM_VERSION === PLATFORM.VERSION6) { - if (eventName.match(START_CATCH_REGEXP)) { - out.jsonTemplate.catchBubbleEvents = out.jsonTemplate.catchBubbleEvents || {} - out.jsonTemplate.catchBubbleEvents[name] = val - } else { - out.jsonTemplate.onBubbleEvents = out.jsonTemplate.onBubbleEvents || {} - out.jsonTemplate.onBubbleEvents[name] = val - } + dealJson(out, eventName, name, val) } else if(process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH && SWIPE_EVENT_REGEXP.test(name) && !eventName.match(END_CAPTURE_REGEXP) && process.env.PLATFORM_VERSION === PLATFORM.VERSION6) { + dealJson(out, eventName, name, val) + } else { + out.jsonTemplate.events = out.jsonTemplate.events || {} + out.jsonTemplate.events[name] = val + } +} + +function dealJson(out, eventName, name, val) { if (eventName.match(START_CATCH_REGEXP)) { out.jsonTemplate.catchBubbleEvents = out.jsonTemplate.catchBubbleEvents || {} out.jsonTemplate.catchBubbleEvents[name] = val @@ -1157,10 +1147,6 @@ function distributeEvent(out, eventName, name, val) { out.jsonTemplate.onBubbleEvents = out.jsonTemplate.onBubbleEvents || {} out.jsonTemplate.onBubbleEvents[name] = val } - } else { - out.jsonTemplate.events = out.jsonTemplate.events || {} - out.jsonTemplate.events[name] = val - } } const transArray = [/\\a/g, /\\b/g, /\\f/g, /\\n/g, /\\r/g, /\\t/g, -- Gitee From a5059d525e2442f92f91eaf9fd2affb74324b68e Mon Sep 17 00:00:00 2001 From: yaoyuchi Date: Thu, 31 Mar 2022 15:23:39 +0800 Subject: [PATCH 3/5] event support bubble Signed-off-by: yaoyuchi --- .../plugin/templater/component_validator.js | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/ace-loader/plugin/templater/component_validator.js b/ace-loader/plugin/templater/component_validator.js index 5eb6a14..d63e853 100644 --- a/ace-loader/plugin/templater/component_validator.js +++ b/ace-loader/plugin/templater/component_validator.js @@ -1106,21 +1106,7 @@ function validateEvent(eventName, val, out, pos, relativePath) { function distributeEvent(out, eventName, name, val) { if ((process.env.DEVICE_LEVEL === DEVICE_LEVEL.LITE || TOUCH_EVENT_REGEXP.test(name)) && process.env.PLATFORM_VERSION !== PLATFORM.VERSION3) { - if (eventName.match(START_CATCH_REGEXP)) { - if (eventName.match(END_CAPTURE_REGEXP)) { - out.jsonTemplate.catchCaptureEvents = out.jsonTemplate.catchCaptureEvents || {} - out.jsonTemplate.catchCaptureEvents[name] = val - } else { - out.jsonTemplate.catchBubbleEvents = out.jsonTemplate.catchBubbleEvents || {} - out.jsonTemplate.catchBubbleEvents[name] = val - } - } else if (eventName.match(END_CAPTURE_REGEXP)) { - out.jsonTemplate.onCaptureEvents = out.jsonTemplate.onCaptureEvents || {} - out.jsonTemplate.onCaptureEvents[name] = val - } else { - out.jsonTemplate.onBubbleEvents = out.jsonTemplate.onBubbleEvents || {} - out.jsonTemplate.onBubbleEvents[name] = val - } + dealTouchJson(out, eventName, name, val) } else if (process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH && CLICK_EVENT_REGEXP.test(name) && !eventName.match(END_CAPTURE_REGEXP) && process.env.PLATFORM_VERSION === PLATFORM.VERSION6) { dealJson(out, eventName, name, val) @@ -1139,6 +1125,24 @@ function distributeEvent(out, eventName, name, val) { } } +function dealTouchJson(out, eventName, name, val) { + if (eventName.match(START_CATCH_REGEXP)) { + if (eventName.match(END_CAPTURE_REGEXP)) { + out.jsonTemplate.catchCaptureEvents = out.jsonTemplate.catchCaptureEvents || {} + out.jsonTemplate.catchCaptureEvents[name] = val + } else { + out.jsonTemplate.catchBubbleEvents = out.jsonTemplate.catchBubbleEvents || {} + out.jsonTemplate.catchBubbleEvents[name] = val + } + } else if (eventName.match(END_CAPTURE_REGEXP)) { + out.jsonTemplate.onCaptureEvents = out.jsonTemplate.onCaptureEvents || {} + out.jsonTemplate.onCaptureEvents[name] = val + } else { + out.jsonTemplate.onBubbleEvents = out.jsonTemplate.onBubbleEvents || {} + out.jsonTemplate.onBubbleEvents[name] = val + } +} + function dealJson(out, eventName, name, val) { if (eventName.match(START_CATCH_REGEXP)) { out.jsonTemplate.catchBubbleEvents = out.jsonTemplate.catchBubbleEvents || {} -- Gitee From 918f34cf647984bdacd51d6585738135727aea09 Mon Sep 17 00:00:00 2001 From: yaoyuchi Date: Thu, 31 Mar 2022 15:53:12 +0800 Subject: [PATCH 4/5] event support bubble Signed-off-by: yaoyuchi --- .../plugin/templater/component_validator.js | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/ace-loader/plugin/templater/component_validator.js b/ace-loader/plugin/templater/component_validator.js index d63e853..f0f069f 100644 --- a/ace-loader/plugin/templater/component_validator.js +++ b/ace-loader/plugin/templater/component_validator.js @@ -1107,18 +1107,16 @@ function distributeEvent(out, eventName, name, val) { if ((process.env.DEVICE_LEVEL === DEVICE_LEVEL.LITE || TOUCH_EVENT_REGEXP.test(name)) && process.env.PLATFORM_VERSION !== PLATFORM.VERSION3) { dealTouchJson(out, eventName, name, val) - } else if (process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH && CLICK_EVENT_REGEXP.test(name) && - !eventName.match(END_CAPTURE_REGEXP) && process.env.PLATFORM_VERSION === PLATFORM.VERSION6) { - dealJson(out, eventName, name, val) - } else if(process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH && LONG_PRESS_EVENT_REGEXP.test(name) && - !eventName.match(END_CAPTURE_REGEXP) && process.env.PLATFORM_VERSION === PLATFORM.VERSION6){ - dealJson(out, eventName, name, val) - } else if(process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH && DOUBLE_CLICK_EVENT_REGEXP.test(name) && - !eventName.match(END_CAPTURE_REGEXP) && process.env.PLATFORM_VERSION === PLATFORM.VERSION6) { - dealJson(out, eventName, name, val) - } else if(process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH && SWIPE_EVENT_REGEXP.test(name) && - !eventName.match(END_CAPTURE_REGEXP) && process.env.PLATFORM_VERSION === PLATFORM.VERSION6) { - dealJson(out, eventName, name, val) + } + if (process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH && !eventName.match(END_CAPTURE_REGEXP) + && process.env.PLATFORM_VERSION === PLATFORM.VERSION6) { + if (CLICK_EVENT_REGEXP.test(name) || LONG_PRESS_EVENT_REGEXP.test(name) + || DOUBLE_CLICK_EVENT_REGEXP.test(name) || SWIPE_EVENT_REGEXP.test(name)) { + dealJson(out, eventName, name, val) + } else { + out.jsonTemplate.events = out.jsonTemplate.events || {} + out.jsonTemplate.events[name] = val + } } else { out.jsonTemplate.events = out.jsonTemplate.events || {} out.jsonTemplate.events[name] = val -- Gitee From 22b3866f8c0976a0dd6d59c463c549ba54631059 Mon Sep 17 00:00:00 2001 From: yaoyuchi Date: Thu, 31 Mar 2022 17:52:46 +0800 Subject: [PATCH 5/5] event support bubble Signed-off-by: yaoyuchi --- .../plugin/templater/component_validator.js | 61 ++++++++----------- 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/ace-loader/plugin/templater/component_validator.js b/ace-loader/plugin/templater/component_validator.js index f0f069f..35f00e2 100644 --- a/ace-loader/plugin/templater/component_validator.js +++ b/ace-loader/plugin/templater/component_validator.js @@ -1106,49 +1106,36 @@ function validateEvent(eventName, val, out, pos, relativePath) { function distributeEvent(out, eventName, name, val) { if ((process.env.DEVICE_LEVEL === DEVICE_LEVEL.LITE || TOUCH_EVENT_REGEXP.test(name)) && process.env.PLATFORM_VERSION !== PLATFORM.VERSION3) { - dealTouchJson(out, eventName, name, val) - } - if (process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH && !eventName.match(END_CAPTURE_REGEXP) - && process.env.PLATFORM_VERSION === PLATFORM.VERSION6) { - if (CLICK_EVENT_REGEXP.test(name) || LONG_PRESS_EVENT_REGEXP.test(name) - || DOUBLE_CLICK_EVENT_REGEXP.test(name) || SWIPE_EVENT_REGEXP.test(name)) { - dealJson(out, eventName, name, val) - } else { - out.jsonTemplate.events = out.jsonTemplate.events || {} - out.jsonTemplate.events[name] = val - } - } else { - out.jsonTemplate.events = out.jsonTemplate.events || {} - out.jsonTemplate.events[name] = val - } -} - -function dealTouchJson(out, eventName, name, val) { if (eventName.match(START_CATCH_REGEXP)) { - if (eventName.match(END_CAPTURE_REGEXP)) { - out.jsonTemplate.catchCaptureEvents = out.jsonTemplate.catchCaptureEvents || {} - out.jsonTemplate.catchCaptureEvents[name] = val - } else { - out.jsonTemplate.catchBubbleEvents = out.jsonTemplate.catchBubbleEvents || {} - out.jsonTemplate.catchBubbleEvents[name] = val - } + if (eventName.match(END_CAPTURE_REGEXP)) { + out.jsonTemplate.catchCaptureEvents = out.jsonTemplate.catchCaptureEvents || {} + out.jsonTemplate.catchCaptureEvents[name] = val + } else { + out.jsonTemplate.catchBubbleEvents = out.jsonTemplate.catchBubbleEvents || {} + out.jsonTemplate.catchBubbleEvents[name] = val + } } else if (eventName.match(END_CAPTURE_REGEXP)) { - out.jsonTemplate.onCaptureEvents = out.jsonTemplate.onCaptureEvents || {} - out.jsonTemplate.onCaptureEvents[name] = val - } else { - out.jsonTemplate.onBubbleEvents = out.jsonTemplate.onBubbleEvents || {} - out.jsonTemplate.onBubbleEvents[name] = val - } -} - -function dealJson(out, eventName, name, val) { - if (eventName.match(START_CATCH_REGEXP)) { - out.jsonTemplate.catchBubbleEvents = out.jsonTemplate.catchBubbleEvents || {} - out.jsonTemplate.catchBubbleEvents[name] = val + out.jsonTemplate.onCaptureEvents = out.jsonTemplate.onCaptureEvents || {} + out.jsonTemplate.onCaptureEvents[name] = val } else { out.jsonTemplate.onBubbleEvents = out.jsonTemplate.onBubbleEvents || {} out.jsonTemplate.onBubbleEvents[name] = val } + } else if (process.env.DEVICE_LEVEL === DEVICE_LEVEL.RICH && + (CLICK_EVENT_REGEXP.test(name) || LONG_PRESS_EVENT_REGEXP.test(name) || + DOUBLE_CLICK_EVENT_REGEXP.test(name) || SWIPE_EVENT_REGEXP.test(name)) && + !eventName.match(END_CAPTURE_REGEXP) && process.env.PLATFORM_VERSION === PLATFORM.VERSION6) { + if (eventName.match(START_CATCH_REGEXP)) { + out.jsonTemplate.catchBubbleEvents = out.jsonTemplate.catchBubbleEvents || {} + out.jsonTemplate.catchBubbleEvents[name] = val + } else { + out.jsonTemplate.onBubbleEvents = out.jsonTemplate.onBubbleEvents || {} + out.jsonTemplate.onBubbleEvents[name] = val + } +} else { + out.jsonTemplate.events = out.jsonTemplate.events || {} + out.jsonTemplate.events[name] = val + } } const transArray = [/\\a/g, /\\b/g, /\\f/g, /\\n/g, /\\r/g, /\\t/g, -- Gitee