Skip to content

Commit

Permalink
Merge branch 'fix/skyline' into feat/4.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
yushijie1 committed Nov 21, 2024
2 parents 7029f3e + 4eb92e5 commit f675e3a
Show file tree
Hide file tree
Showing 95 changed files with 3,384 additions and 790 deletions.
1 change: 1 addition & 0 deletions crates/swc_plugin_compile_mode/src/tests/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ test!(
<View onClick={handleViewClick}></View>
<View onAnimationStart={() => {}} id={myId}></View>
<Image onLoad={() => {}} id="myImg" />
<View nativeView="view" onScroll={() => {}} onScrollUpdateWorklet="onScrollUpdate" onGestureWorklet="onGesture" shouldResponseOnMoveWorklet="shouldResponseOnMoveCallBack"></View>
</View>
)
}
Expand Down
9 changes: 9 additions & 0 deletions crates/swc_plugin_compile_mode/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,15 @@ impl TransformVisitor {
Some(jsx_attr_value) => {
match jsx_attr_value {
JSXAttrValue::Lit(Lit::Str(Str { value, .. })) => {
// 处理worklet事件
if is_event {
let event_name_str = event_name.unwrap();
if event_name_str.starts_with("worklet:") {
props.insert(event_name_str, value.to_string());
return false;
}
}

// 静态属性在 xml 中保留即可,jsx 中可以删除
if jsx_attr_name != COMPILE_MODE {
props.insert(miniapp_attr_name, value.to_string());
Expand Down
13 changes: 13 additions & 0 deletions crates/swc_plugin_compile_mode/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ pub fn check_is_event_attr(val: &str) -> bool {
}

pub fn identify_jsx_event_key(val: &str, platform: &str) -> Option<String> {

// 处理worklet事件及callback
// 事件: onScrollUpdateWorklet -> worklet:onscrollupdate
// callback:shouldResponseOnMoveWorklet -> worklet:should-response-on-move
if val.ends_with("Worklet") {
let worklet_name = val.trim_end_matches("Worklet");
if worklet_name.starts_with("on") {
return Some(format!("worklet:{}", worklet_name.to_lowercase()));
} else {
return Some(format!("worklet:{}", to_kebab_case(worklet_name)));
}
}

if check_is_event_attr(val) {
let event_name = val.get(2..).unwrap().to_lowercase();
let event_name = if event_name == "click" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
const TARO_TEMPLATES_f0t0 = '<template name="tmpl_0_f0t0"><view><view bindtap="eh" data-sid="{{i.cn[0].sid}}" id="{{i.cn[0].sid}}"></view><view bindanimationstart="eh" data-sid="{{i.cn[1].sid}}" id="{{i.cn[1].uid}}"></view><image bindload="eh" data-sid="{{i.cn[2].sid}}" id="myImg"></image></view></template>';
const TARO_TEMPLATES_f0t0 = '<template name="tmpl_0_f0t0"><view><view bindtap="eh" data-sid="{{i.cn[0].sid}}" id="{{i.cn[0].sid}}"></view><view bindanimationstart="eh" data-sid="{{i.cn[1].sid}}" id="{{i.cn[1].uid}}"></view><image bindload="eh" data-sid="{{i.cn[2].sid}}" id="myImg"></image><view bindscroll="eh" data-sid="{{i.cn[3].sid}}" id="{{i.cn[3].sid}}" native-view="view" worklet:ongesture="onGesture" worklet:onscrollupdate="onScrollUpdate" worklet:should-response-on-move="shouldResponseOnMoveCallBack"></view></view></template>';
function Index() {
return <View compileMode="f0t0">

<View onClick={handleViewClick}></View>
<View onAnimationStart={() => {}} id={myId}></View>
<Image onLoad={() => {}} />
</View>

<View onAnimationStart={()=>{}} id={myId}></View>

<Image onLoad={()=>{}}/>

<View onScroll={()=>{}}></View>

</View>;
}
2 changes: 1 addition & 1 deletion packages/shared/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,10 +525,10 @@ export const voidElements = new Set([
export const nestElements = new Map([
['view', -1],
['catch-view', -1],
['click-view', -1],
['cover-view', -1],
['static-view', -1],
['pure-view', -1],
['click-view', -1],
['block', -1],
['text', -1],
['static-text', 6],
Expand Down
9 changes: 7 additions & 2 deletions packages/shared/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,11 @@ export class BaseTemplate {
style: comp.style,
class: comp.class
}

result['click-view'] = {
style: comp.style,
class: comp.class,
bindtap: 'eh'
...this.getClickEvent()
}
}
}
Expand Down Expand Up @@ -412,9 +413,9 @@ export class BaseTemplate {
case 'slot':
case 'slot-view':
case 'catch-view':
case 'click-view':
case 'static-view':
case 'pure-view':
case 'click-view':
nodeName = 'view'
break
case 'static-text':
Expand Down Expand Up @@ -515,6 +516,10 @@ export class BaseTemplate {
return events
}

protected getClickEvent (): any {
return { bindtap: 'eh' }
}

protected getAttrValue (value: string, _key: string, _nodeName: string) {
return `{${value}}`
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# taro-double-tap-gesture-handler-core



<!-- Auto Generated Below -->


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Component, ComponentInterface, h, Host } from '@stencil/core'

import { notSupport } from '../../utils'

@Component({
tag: 'taro-double-tap-gesture-handler-core'
})
export class DoubleTapGestureHandler implements ComponentInterface {
componentDidLoad () {
notSupport('DoubleTapGestureHandler', this)
}

render () {
return (
<Host />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# taro-force-press-gesture-handler-core



<!-- Auto Generated Below -->


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Component, ComponentInterface, h, Host } from '@stencil/core'

import { notSupport } from '../../utils'

@Component({
tag: 'taro-force-press-gesture-handler-core'
})
export class ForcePressGestureHandler implements ComponentInterface {
componentDidLoad () {
notSupport('ForcePressGestureHandler', this)
}

render () {
return (
<Host />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# taro-horizontal-drag-gesture-handler-core



<!-- Auto Generated Below -->


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Component, ComponentInterface, h, Host } from '@stencil/core'

import { notSupport } from '../../utils'

@Component({
tag: 'taro-horizontal-drag-gesture-handler-core'
})
export class HorizontalDragGestureHandler implements ComponentInterface {
componentDidLoad () {
notSupport('HorizontalDragGestureHandler', this)
}

render () {
return (
<Host />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# taro-long-press-gesture-handler-core



<!-- Auto Generated Below -->


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Component, ComponentInterface, h, Host } from '@stencil/core'

import { notSupport } from '../../utils'

@Component({
tag: 'taro-long-press-gesture-handler-core'
})
export class LongPressGestureHandler implements ComponentInterface {
componentDidLoad () {
notSupport('LongPressGestureHandler', this)
}

render () {
return (
<Host />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# taro-pan-gesture-handler-core



<!-- Auto Generated Below -->


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Component, ComponentInterface, h, Host } from '@stencil/core'

import { notSupport } from '../../utils'

@Component({
tag: 'taro-pan-gesture-handler-core'
})
export class PanGestureHandler implements ComponentInterface {
componentDidLoad () {
notSupport('PanGestureHandler', this)
}

render () {
return (
<Host />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# taro-scale-gesture-handler-core



<!-- Auto Generated Below -->


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Component, ComponentInterface, h, Host } from '@stencil/core'

import { notSupport } from '../../utils'

@Component({
tag: 'taro-scale-gesture-handler-core'
})
export class ScaleGestureHandler implements ComponentInterface {
componentDidLoad () {
notSupport('ScaleGestureHandler', this)
}

render () {
return (
<Host />
)
}
}
10 changes: 10 additions & 0 deletions packages/taro-components/src/components/script/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# taro-script-core



<!-- Auto Generated Below -->


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
18 changes: 18 additions & 0 deletions packages/taro-components/src/components/script/script.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Component, ComponentInterface, h, Host } from '@stencil/core'

import { notSupport } from '../../utils'

@Component({
tag: 'taro-script-core'
})
export class Script implements ComponentInterface {
componentDidLoad () {
notSupport('Script', this)
}

render () {
return (
<Host />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# taro-tap-gesture-handler-core



<!-- Auto Generated Below -->


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Component, ComponentInterface, h, Host } from '@stencil/core'

import { notSupport } from '../../utils'

@Component({
tag: 'taro-tap-gesture-handler-core'
})
export class TapGestureHandler implements ComponentInterface {
componentDidLoad () {
notSupport('TapGestureHandler', this)
}

render () {
return (
<Host />
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# taro-vertical-drag-gesture-handler-core



<!-- Auto Generated Below -->


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Component, ComponentInterface, h, Host } from '@stencil/core'

import { notSupport } from '../../utils'

@Component({
tag: 'taro-vertical-drag-gesture-handler-core'
})
export class VerticalDragGestureHandler implements ComponentInterface {
componentDidLoad () {
notSupport('VerticalDragGestureHandler', this)
}

render () {
return (
<Host />
)
}
}
5 changes: 5 additions & 0 deletions packages/taro-components/types/DraggableSheet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ interface DraggableSheetProps extends StandardProps {
* @default []
*/
snapSizes?: any[]
/**
* 尺寸发生变化时触发,仅支持 worklet 作为回调。event = {pixels, size}
* @supported weapp
*/
onSizeUpdateWorklet?: string
}

/**
Expand Down
Loading

0 comments on commit f675e3a

Please sign in to comment.