Skip to content

Commit

Permalink
Merge branch 'main' into fix/pagemeta
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam authored Mar 22, 2024
2 parents be1585b + 2413691 commit 84b4c4f
Show file tree
Hide file tree
Showing 131 changed files with 2,842 additions and 2,668 deletions.
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": "3.6.24",
"version": "3.6.25",
"description": "Node binding for taro",
"main": "binding.js",
"typings": "binding.d.ts",
Expand Down
9 changes: 9 additions & 0 deletions crates/swc_plugin_compile_mode/src/tests/condition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ test!(
{condition1 && "condition2" && condition3 && <View hoverClass={myClass}>{content}</View>}
{condition1 && 'Hello'}
{condition1 && <View onClick={() => condition2 && doSth()} />}
{condition1 && condition2 && (
<View>
{condition3 && condition4 && (
<View>
<Text>{myText}</Text>
</View>
)}
</View>
)}
<View hoverClass={myClass}></View>
<View>{condition1 && ident}</View>
<View>{condition1 && obj.property}</View>
Expand Down
21 changes: 3 additions & 18 deletions crates/swc_plugin_compile_mode/src/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ use std::collections::HashMap;
use crate::{PluginConfig, utils::as_xscript_expr_string};
use crate::utils::{self, constants::*};

struct PreVisitor {
is_in_and_expr: bool,
}
struct PreVisitor;
impl PreVisitor {
fn new () -> Self {
Self {
is_in_and_expr: false
}
Self {}
}
}
impl VisitMut for PreVisitor {
Expand Down Expand Up @@ -98,17 +94,14 @@ impl VisitMut for PreVisitor {
}
fn visit_mut_jsx_element_child (&mut self, child: &mut JSXElementChild) {
if let JSXElementChild::JSXExprContainer(JSXExprContainer { expr: JSXExpr::Expr(expr), .. }) = child {
let mut is_first_and_expr = false;

if let Expr::Paren(ParenExpr { expr: e, .. }) = &mut **expr {
*expr = e.take();
}

match &mut **expr {
Expr::Bin(BinExpr { op, left, right, ..}) => {
// C&&A 替换为 C?A:A',原因是为了无论显示还是隐藏都保留一个元素,从而不影响兄弟节点的变量路径
if *op == op!("&&") && !self.is_in_and_expr {
is_first_and_expr = true;
if *op == op!("&&") {
fn inject_compile_if (el: &mut Box<JSXElement>, condition: &mut Box<Expr>) -> () {
el.opening.attrs.push(utils::create_jsx_expr_attr(COMPILE_IF, condition.clone()));
}
Expand Down Expand Up @@ -185,15 +178,7 @@ impl VisitMut for PreVisitor {
_ => (),
}

if is_first_and_expr {
self.is_in_and_expr = true;
}

expr.visit_mut_children_with(self);

if is_first_and_expr {
self.is_in_and_expr = false;
}
} else {
child.visit_mut_children_with(self);
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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": "3.6.24",
"version": "3.6.25",
"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": "3.6.24",
"version": "3.6.25",
"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": "3.6.24",
"version": "3.6.25",
"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": "3.6.24",
"version": "3.6.25",
"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": "3.6.24",
"version": "3.6.25",
"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": "3.6.24",
"version": "3.6.25",
"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": "3.6.24",
"version": "3.6.25",
"description": "Transform stylesheet selector to style in JSX Elements.",
"license": "MIT",
"main": "dist/index.js",
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": "3.6.24",
"version": "3.6.25",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
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": "3.6.24",
"version": "3.6.25",
"description": "Taro babel preset",
"author": "yuche <i@yuche.me>",
"homepage": "https://github.com/nervjs/taro/tree/master/packages/babel-preset-taro#readme",
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": "3.6.24",
"version": "3.6.25",
"description": "create taro app with one command",
"author": "VincentW <Vincent.Mr.W@gmail.com>",
"homepage": "https://github.com/nervjs/taro/tree/master/packages/create-app#readme",
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": "3.6.24",
"version": "3.6.25",
"main": "dist/index.js",
"license": "MIT",
"files": [
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": "3.6.24",
"version": "3.6.25",
"description": "Taro specific linting rules for ESLint",
"main": "index.js",
"files": [
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": "3.6.24",
"version": "3.6.25",
"description": "transform html tag name selector",
"main": "index.js",
"author": "drchan",
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": "3.6.24",
"version": "3.6.25",
"description": "parse constants defined in config",
"main": "index.js",
"author": "Simba",
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": "3.6.24",
"version": "3.6.25",
"description": "PostCSS plugin px 转小程序 rpx及h5 rem 单位",
"main": "index.js",
"keywords": [
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": "3.6.24",
"version": "3.6.25",
"description": "小程序单位转换",
"main": "index.js",
"scripts": {
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": "3.6.24",
"version": "3.6.25",
"description": "Taro utils internal use.",
"author": "yuche <i@yuche.me>",
"homepage": "https://github.com/nervjs/taro/tree/master/packages/shared#readme",
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 @@ -537,5 +537,5 @@ export const nestElements = new Map([
['form', 4],
['scroll-view', 4],
['swiper', 4],
['swiper-item', 4]
['swiper-item', 4],
])
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": "3.6.24",
"version": "3.6.25",
"description": "Shareable stylelint config for React Native CSS modules",
"main": "index.js",
"files": [
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,7 +1,7 @@
{
"name": "stylelint-taro-rn",
"description": "A collection of React Native specific rules for stylelint",
"version": "3.6.24",
"version": "3.6.25",
"main": "dist/index.js",
"files": [
"dist",
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-alipay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/plugin-platform-alipay",
"version": "3.6.24",
"version": "3.6.25",
"description": "支付宝小程序平台插件",
"author": "Chen-jj",
"homepage": "https://github.com/nervjs/taro/tree/master/packages/taro-alipay#readme",
Expand Down
5 changes: 5 additions & 0 deletions packages/taro-alipay/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ export class Template extends RecursiveTemplate {

transferComponents: Record<string, Record<string, string>> = {}

constructor () {
super()
this.nestElements.set('root-portal', 3)
}

buildXsTemplate (filePath = './utils') {
return `<import-sjs name="xs" from="${filePath}.sjs" />`
}
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": "3.6.24",
"version": "3.6.25",
"description": "Taro common API",
"author": "yuche <i@yuche.me>",
"homepage": "https://github.com/nervjs/taro/tree/master/packages/api#readme",
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-cli-convertor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/cli-convertor",
"version": "3.6.24",
"version": "3.6.25",
"description": "cli tool for taro-convert",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/cli",
"version": "3.6.24",
"version": "3.6.25",
"description": "cli tool for taro",
"main": "index.js",
"types": "dist/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components-advanced/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tarojs/components-advanced",
"version": "3.6.24",
"version": "3.6.25",
"description": "",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ interface VirtualListProps<T = any> extends Omit<StandardProps, 'children'> {
/** 触底事件 */
onScrollToLower?: () => void
style?: CSSProperties
/** 这是一个 fix 类型的参数,针对于各端小程序,在层级太深的情况下会生成 Taro 的自定义组件,导致一般的选择器字符会查询不到对应的元素,需要加上类似 #container >>> 的查询前缀
* @default ''
*/
queryPrefix?: string
}

declare namespace VirtualListProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const VirtualList = React.forwardRef(function VirtualList (props: VirtualListPro
itemElementType = View,
initialScrollOffset = 0,
overscanCount = 1,
queryPrefix = '',
...rest
} = props as IProps

Expand All @@ -35,6 +36,7 @@ const VirtualList = React.forwardRef(function VirtualList (props: VirtualListPro
direction,
initialScrollOffset,
overscanCount,
queryPrefix,
outerWrapper,
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export default class List extends React.PureComponent<IProps, IState> {
return new Promise((resolve) => {
if (index >= 0 && index < this.props.itemCount) {
const times = this.itemList.compareSize(index) ? 3 : 0
getRectSizeSync(`#${this.preset.id}-${index}`, 100, times).then(({ width, height }) => {
getRectSizeSync(`${this.props.queryPrefix}#${this.preset.id}-${index}`, 100, times).then(({ width, height }) => {
const size = isHorizontal ? width : height
if (typeof size === 'number' && size > 0 && !this.itemList.compareSize(index, size)) {
this.itemList.setSize(index, size)
Expand Down Expand Up @@ -295,7 +295,7 @@ export default class List extends React.PureComponent<IProps, IState> {
} else {
option.top = scrollOffset
}
return getScrollViewContextNode(`#${this.preset.id}`).then((node: any) => node.scrollTo(option))
return getScrollViewContextNode(`${this.props.queryPrefix}#${this.preset.id}`).then((node: any) => node.scrollTo(option))
}

this.setState((prevState: IState) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ export default defineComponent({
type: [Number, Function],
required: true
},
queryPrefix: {
type: String,
default: ''
},
unlimitedSize: {
type: Boolean,
default: false
Expand Down Expand Up @@ -133,7 +137,7 @@ export default defineComponent({
} else {
option.top = scrollOffset
}
return getScrollViewContextNode(`#${this.preset.id}`).then((node: any) => node.scrollTo(option))
return getScrollViewContextNode(`${this.$props.queryPrefix}#${this.preset.id}`).then((node: any) => node.scrollTo(option))
}

this.scrollDirection = this.scrollOffset < scrollOffset ? 'forward' : 'backward'
Expand Down Expand Up @@ -209,7 +213,7 @@ export default defineComponent({
return new Promise((resolve) => {
if (index >= 0 && index < this.$props.itemCount) {
const times = this.itemList.compareSize(index) ? 0 : 2
getRectSizeSync(`#${this.preset.id}-${index}`, 100, times).then(({ width, height }) => {
getRectSizeSync(`${this.$props.queryPrefix}#${this.preset.id}-${index}`, 100, times).then(({ width, height }) => {
const size = isHorizontal ? width : height
if (typeof size === 'number' && size > 0 && !this.itemList.compareSize(index, size)) {
this.itemList.setSize(index, size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ interface VirtualWaterfallProps<T = any> extends Omit<StandardProps, 'children'>
/** 触底事件 */
onScrollToLower?: () => void
style?: CSSProperties
/** 这是一个 fix 类型的参数,针对于各端小程序,在层级太深的情况下会生成 Taro 的自定义组件,导致一般的选择器字符会查询不到对应的元素,需要加上类似 #container >>> 的查询前缀
* @default ''
*/
queryPrefix?: string
}

declare namespace VirtualWaterfallProps {
Expand Down
Loading

0 comments on commit 84b4c4f

Please sign in to comment.