Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/4.0.8 skyline完善&新增ES5模式 #16945

Merged
merged 15 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/native_binding/binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface CreateOptions {
version?: string
date?: string
typescript?: boolean
buildEs5?: boolean
template: string
pageName?: string
compiler?: CompilerType
Expand Down Expand Up @@ -105,6 +106,7 @@ export interface Project {
npm: NpmType
description?: string
typescript?: boolean
buildEs5?: boolean
template: string
css: CSSType
autoInstall?: boolean
Expand Down
2 changes: 1 addition & 1 deletion crates/native_binding/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/binding",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"description": "Node binding for taro",
"main": "binding.js",
"typings": "binding.d.ts",
Expand Down
1 change: 1 addition & 0 deletions crates/native_binding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub async fn create_project(
conf.npm,
conf.description,
conf.typescript,
conf.build_es5,
conf.template,
conf.css,
conf.framework,
Expand Down
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>;
}
1 change: 1 addition & 0 deletions crates/taro_init/src/creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct CreateOptions {
pub version: Option<String>,
pub date: Option<String>,
pub typescript: Option<bool>,
pub build_es5: Option<bool>,
pub template: String,
pub page_name: Option<String>,
pub compiler: Option<CompilerType>,
Expand Down
1 change: 1 addition & 0 deletions crates/taro_init/src/page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ impl Page {
set_page_name: None,
set_sub_pkg_page_name: None,
change_ext: None,
build_es5: None,
is_custom_template: self.is_custom_template.clone(),
plugin_type: None,
};
Expand Down
1 change: 1 addition & 0 deletions crates/taro_init/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ impl Plugin {
version: Some(self.version.clone()),
date: None,
typescript: None,
build_es5: None,
template: self.template.clone(),
page_name: None,
compiler: None,
Expand Down
4 changes: 4 additions & 0 deletions crates/taro_init/src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub struct Project {
pub npm: NpmType,
pub description: Option<String>,
pub typescript: Option<bool>,
pub build_es5: Option<bool>,
pub template: String,
pub css: CSSType,
pub auto_install: Option<bool>,
Expand All @@ -37,6 +38,7 @@ impl Project {
npm: NpmType,
description: Option<String>,
typescript: Option<bool>,
build_es5: Option<bool>,
template: String,
css: CSSType,
framework: FrameworkType,
Expand All @@ -53,6 +55,7 @@ impl Project {
npm,
description,
typescript,
build_es5,
template,
css,
auto_install,
Expand Down Expand Up @@ -103,6 +106,7 @@ impl Project {
version: Some(self.version.clone()),
date: self.date.clone(),
typescript: self.typescript.clone(),
build_es5: self.build_es5.clone(),
template: self.template.clone(),
page_name: Some("index".to_string()),
compiler: self.compiler.clone(),
Expand Down
2 changes: 1 addition & 1 deletion npm/darwin-arm64/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tarojs/binding-darwin-arm64",
"description": "Native binding for taro",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/darwin-x64/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tarojs/binding-darwin-x64",
"description": "Native binding for taro",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"os": [
"darwin"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/linux-x64-gnu/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tarojs/binding-linux-x64-gnu",
"description": "Native binding for taro",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/linux-x64-musl/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/binding-linux-x64-musl",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"os": [
"linux"
],
Expand Down
2 changes: 1 addition & 1 deletion npm/win32-x64-msvc/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@tarojs/binding-win32-x64-msvc",
"description": "Native binding for taro",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"os": [
"win32"
],
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "taro",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"description": "开放式跨端跨框架开发解决方案",
"homepage": "https://github.com/NervJS/taro#readme",
"author": "O2Team",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-transform-react-jsx-to-rn-stylesheet",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"description": "Transform stylesheet selector to style in JSX Elements.",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-transform-solid-jsx/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "babel-plugin-transform-solid-jsx",
"description": "A JSX to DOM plugin that wraps expressions for fine grained change detection",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"license": "MIT",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-transform-taroapi/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-plugin-transform-taroapi",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"author": "O2Team",
"license": "MIT",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-preset-taro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "babel-preset-taro",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"description": "Taro babel preset",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/create-app",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"description": "create taro app with one command",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/css-to-react-native/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "taro-css-to-react-native",
"description": "Convert CSS text to a React Native stylesheet object",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"author": "O2Team",
"license": "MIT",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-taro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-taro",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"description": "Taro specific linting rules for ESLint",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-helper/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jest-taro-helper",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"description": "jest helper for taro",
"private": true,
"author": "O2Team",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-html-transform/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-html-transform",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"description": "transform html tag name selector",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-plugin-constparse/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-plugin-constparse",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"description": "parse constants defined in config",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-pxtransform/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-pxtransform",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"description": "PostCSS plugin px 转小程序 rpx及h5 rem 单位",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/postcss-unit-transform/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-taro-unit-transform",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"description": "小程序单位转换",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/rollup-plugin-copy/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rollup-plugin-copy",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"description": "rollup-plugin-copy for taro",
"private": true,
"author": "O2Team",
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/shared",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"description": "Taro utils internal use.",
"author": "O2Team",
"license": "MIT",
Expand Down
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
2 changes: 1 addition & 1 deletion packages/stylelint-config-taro-rn/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stylelint-config-taro-rn",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"description": "Shareable stylelint config for React Native CSS modules",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/stylelint-taro-rn/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stylelint-taro-rn",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"description": "A collection of React Native specific rules for stylelint",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/stylelint-taro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stylelint-taro",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"description": "Taro stylelint 规则集合",
"author": "O2Team",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/api",
"version": "4.0.8-beta.0",
"version": "4.0.8-beta.1",
"description": "Taro common API",
"author": "O2Team",
"license": "MIT",
Expand Down
Loading
Loading