@tarojs/plugin-platform-harmony-ets 4.0.0-beta.31 → 4.0.0-beta.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -105,19 +105,18 @@ export function pxTransformHelper (size: number, unit?: string, isNumber = false
105
105
  return isNumber ? val : val + targetUnit
106
106
  }
107
107
 
108
- export function pxTransform (size: number): number {
108
+ export function pxTransform (size: number): number | string {
109
109
  const config = (Current as any).taro?.config || {}
110
110
  const targetUnit = config.targetUnit || defaultTargetUnit
111
111
 
112
- let val = size
112
+ const val = size
113
113
  switch (targetUnit) {
114
114
  case 'vp':
115
- val = px2vp(size)
116
- break
115
+ return pxTransformHelper(size, 'px')
117
116
  default:
118
117
  // NOTE: 鸿蒙环境下 style 会自动完成设计稿转换,无需在方法内二次调整
119
118
  }
120
- return val + config.targetUnit
119
+ return val + targetUnit
121
120
  }
122
121
 
123
122
  export function canIUseWebp () {
@@ -65,13 +65,13 @@ function getThemeAttributes (node: TaroButtonElement): TaroStyleType {
65
65
  }
66
66
  }
67
67
 
68
- function getButtonWidth (node: TaroButtonElement) {
68
+ function getButtonWidth (node: TaroButtonElement): string | number {
69
69
  const isMini = node._attrs.size === 'mini'
70
70
 
71
71
  return isMini ? convertNumber2VP(120) : '100%'
72
72
  }
73
73
 
74
- function getButtonHeight (node: TaroButtonElement) {
74
+ function getButtonHeight (node: TaroButtonElement): string | number {
75
75
  const isMini = node._attrs.size === 'mini'
76
76
 
77
77
  return isMini ? convertNumber2VP(60) : convertNumber2VP(92)
@@ -23,6 +23,26 @@ import TaroMovableView from './movableView'
23
23
  import { TaroRadio, TaroRadioGroup } from './radio'
24
24
  import { TaroCheckboxGroup, TaroCheckbox } from './checkbox'
25
25
 
26
+ import commonStyleModify from './style'
27
+ import { getButtonColor } from './button'
28
+ import { FlexManager } from './utils/flexManager'
29
+ import { DynamicCenter } from './utils/DynamicCenter'
30
+ import { TOUCH_EVENT_MAP } from './utils/constant/event'
31
+ import { BUTTON_THEME_COLOR } from './utils/constant/style'
32
+ import { getNodeThresholds, getNormalAttributes, getFontAttributes } from './utils/helper'
33
+
34
+ export {
35
+ FlexManager,
36
+ DynamicCenter,
37
+ getButtonColor,
38
+ TOUCH_EVENT_MAP,
39
+ getFontAttributes,
40
+ commonStyleModify,
41
+ getNodeThresholds,
42
+ BUTTON_THEME_COLOR,
43
+ getNormalAttributes,
44
+ }
45
+
26
46
  export {
27
47
  TaroImage,
28
48
  TaroCanvas,
@@ -36,7 +36,7 @@ class CommonStyleModify implements AttributeModifier<CommonAttribute> {
36
36
  setNormalAttributeIntoInstance(instance, this.style, this.node)
37
37
  }
38
38
 
39
- setAnimationAttributeIntoInstance(instance, this.overwriteStyle)
39
+ setAnimationAttributeIntoInstance(instance, this.overwriteStyle, this.style || {})
40
40
  }
41
41
  }
42
42
 
@@ -69,7 +69,7 @@ class RowStyleModify extends CommonStyleModify {
69
69
  })
70
70
  }
71
71
 
72
- setAnimationAttributeIntoInstance(instance, this.overwriteStyle)
72
+ setAnimationAttributeIntoInstance(instance, this.overwriteStyle, this.style || {})
73
73
  }
74
74
  }
75
75
 
@@ -85,29 +85,31 @@ class ColumnStyleModify extends CommonStyleModify {
85
85
  })
86
86
  }
87
87
 
88
- setAnimationAttributeIntoInstance(instance, this.overwriteStyle)
88
+ setAnimationAttributeIntoInstance(instance, this.overwriteStyle, this.style || {})
89
89
  }
90
90
  }
91
91
 
92
- function setAnimationAttributeIntoInstance(instance: CommonAttribute, overwriteStyle: Record<string, TaroAny>) {
92
+ function setAnimationAttributeIntoInstance(instance: CommonAttribute, overwriteStyle: Record<string, TaroAny>, style: TaroStyleType) {
93
93
  // Animation 需要提前和 @State 变量绑定才能产生动画效果,因此不能做 if else 判断
94
94
  instance.translate({
95
- x: overwriteStyle.translate?.x,
96
- y: overwriteStyle.translate?.y,
97
- z: overwriteStyle.translate?.z,
98
- }).scale({
99
- x: overwriteStyle.scale?.x,
100
- y: overwriteStyle.scale?.y,
101
- z: overwriteStyle.scale?.z,
102
- centerX: overwriteStyle.transformOrigin?.x,
103
- centerY: overwriteStyle.transformOrigin?.y,
104
- }).rotate({
105
- x: overwriteStyle.rotate?.x,
106
- y: overwriteStyle.rotate?.y,
107
- z: overwriteStyle.rotate?.z,
108
- centerX: overwriteStyle.transformOrigin?.x,
109
- centerY: overwriteStyle.transformOrigin?.y,
110
- angle: overwriteStyle.rotate?.angle,
95
+ x: overwriteStyle.translate?.x || style.transform?.Translate?.x,
96
+ y: overwriteStyle.translate?.y || style.transform?.Translate?.y,
97
+ z: overwriteStyle.translate?.z || style.transform?.Translate?.z,
98
+ })
99
+ instance.scale({
100
+ x: overwriteStyle.scale?.x || style.transform?.Scale?.x,
101
+ y: overwriteStyle.scale?.y || style.transform?.Scale?.y,
102
+ z: overwriteStyle.scale?.z || style.transform?.Scale?.z,
103
+ centerX: overwriteStyle.transformOrigin?.x || style.transformOrigin?.x || 0,
104
+ centerY: overwriteStyle.transformOrigin?.y || style.transformOrigin?.y || 0,
105
+ })
106
+ instance.rotate({
107
+ x: overwriteStyle.rotate?.x || style.transform?.Rotate?.x,
108
+ y: overwriteStyle.rotate?.y || style.transform?.Rotate?.y,
109
+ z: overwriteStyle.rotate?.z || style.transform?.Rotate?.z,
110
+ centerX: overwriteStyle.transformOrigin?.x || style.transformOrigin?.x || 0,
111
+ centerY: overwriteStyle.transformOrigin?.y || style.transformOrigin?.y || 0,
112
+ angle: overwriteStyle.rotate?.angle || style.transform?.Rotate?.angle || 0,
111
113
  })
112
114
  }
113
115
 
@@ -166,7 +168,11 @@ function setNormalAttributeIntoInstance(instance: CommonAttribute, style: TaroSt
166
168
  instance.backgroundColor(style.backgroundColor)
167
169
  }
168
170
  if (!isUndefined(style.backgroundImage)) {
169
- if (style.backgroundImage.colors) {
171
+ if (style.backgroundImage.center) {
172
+ // radialGradient
173
+ instance.radialGradient(style.backgroundImage)
174
+ } else if (style.backgroundImage.colors) {
175
+ // linearGradient
170
176
  instance.linearGradient(style.backgroundImage)
171
177
  } else {
172
178
  instance.backgroundImage(style.backgroundImage?.src, style.backgroundRepeat)
@@ -231,34 +237,35 @@ function setNormalAttributeIntoInstance(instance: CommonAttribute, style: TaroSt
231
237
  // instance.rotate({ centerX: style.transformOrigin.x, centerY: style.transformOrigin.y, angle: 0 })
232
238
  // instance.scale({ centerX: style.transformOrigin.x, centerY: style.transformOrigin.y })
233
239
  // }
234
- if (!isUndefined(style.transform)) {
235
- if (style.transform.Translate) {
236
- instance.translate({
237
- x: style.transform.Translate.x || 0,
238
- y: style.transform.Translate.y || 0,
239
- z: style.transform.Translate.z || 0,
240
- })
241
- }
242
- if (style.transform.Scale) {
243
- instance.scale({
244
- x: style.transform.Scale.x || 0,
245
- y: style.transform.Scale.y || 0,
246
- z: style.transform.Scale.z || 0,
247
- centerX: style.transformOrigin?.x || 0,
248
- centerY: style.transformOrigin?.y || 0,
249
- })
250
- }
251
- if (style.transform.Rotate) {
252
- instance.rotate({
253
- x: style.transform.Rotate.x || 0,
254
- y: style.transform.Rotate.y || 0,
255
- z: style.transform.Rotate.z || 0,
256
- centerX: style.transformOrigin?.x || 0,
257
- centerY: style.transformOrigin?.y || 0,
258
- angle: 0
259
- })
260
- }
261
- }
240
+ // // Note: 移植到setAnimationAttributeIntoInstance设置
241
+ // if (!isUndefined(style.transform)) {
242
+ // if (style.transform.Translate) {
243
+ // instance.translate({
244
+ // x: style.transform.Translate.x || 0,
245
+ // y: style.transform.Translate.y || 0,
246
+ // z: style.transform.Translate.z || 0,
247
+ // })
248
+ // }
249
+ // if (style.transform.Scale) {
250
+ // instance.scale({
251
+ // x: style.transform.Scale.x || 0,
252
+ // y: style.transform.Scale.y || 0,
253
+ // z: style.transform.Scale.z || 0,
254
+ // centerX: style.transformOrigin?.x || 0,
255
+ // centerY: style.transformOrigin?.y || 0,
256
+ // })
257
+ // }
258
+ // if (style.transform.Rotate) {
259
+ // instance.rotate({
260
+ // x: style.transform.Rotate.x || 0,
261
+ // y: style.transform.Rotate.y || 0,
262
+ // z: style.transform.Rotate.z || 0,
263
+ // centerX: style.transformOrigin?.x || 0,
264
+ // centerY: style.transformOrigin?.y || 0,
265
+ // angle: 0
266
+ // })
267
+ // }
268
+ // }
262
269
  if (style.position === 'absolute' || style.position === 'fixed') {
263
270
  instance.position({
264
271
  x: style.left || 0,
@@ -34,7 +34,7 @@ function textSpecialFontStyle(attr: TaroTextStyleType) {
34
34
  .lineHeight(attr.lineHeight)
35
35
  }
36
36
 
37
- function getButtonFontSize (node: TaroButtonElement) {
37
+ function getButtonFontSize (node: TaroButtonElement): string | number {
38
38
  const isMini = node._attrs.size === 'mini'
39
39
 
40
40
  return isMini ? convertNumber2VP(26) : convertNumber2VP(36)
@@ -106,14 +106,6 @@ export function getNormalAttributes (node: TaroElement, initStyle?: HarmonyStyle
106
106
  normalAttributes = ObjectAssign({}, normalAttributes, pseudoStylesheet)
107
107
  }
108
108
 
109
- // taro_page 等写死在运行时里的节点,没有 _nodeInfo
110
- if (node._nodeInfo) {
111
- const overwriteStyle: TaroStyleType = node._nodeInfo?.overwriteStyle
112
- // 处理覆盖属性:如动画的覆盖
113
- if (overwriteStyle) {
114
- normalAttributes = ObjectAssign({}, normalAttributes, overwriteStyle)
115
- }
116
- }
117
109
  // 初始化默认的值
118
110
  if (initStyle) {
119
111
  normalAttributes = ObjectAssign({}, initStyle, normalAttributes)
package/dist/index.d.ts CHANGED
@@ -49,6 +49,7 @@ declare class Harmony extends TaroPlatformHarmony {
49
49
  useJSON5: boolean;
50
50
  runtimePath: string[] | string;
51
51
  taroComponentsPath: string;
52
+ apiEntryList: RegExp[];
52
53
  constructor(ctx: IPluginContext, config: TConfig);
53
54
  get framework(): "solid" | "vue3" | "react" | "preact" | "nerv" | "vue";
54
55
  get aliasFramework(): string;
package/dist/index.js CHANGED
@@ -303,6 +303,9 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
303
303
  this.useJSON5 = true;
304
304
  this.runtimePath = [];
305
305
  this.taroComponentsPath = `${PACKAGE_NAME}/dist/components-harmony-ets`;
306
+ this.apiEntryList = [
307
+ /(@tarojs[\\/]plugin-platform-harmony-ets|taro-platform-harmony)[\\/]dist[\\/]apis[\\/]index\.ts/,
308
+ ];
306
309
  _Harmony_defineConstants.set(this, {});
307
310
  this.extensions = ['.js', '.jsx', '.ts', '.tsx', '.cjs', '.mjs', '.mts', '.vue', '.ets', '.d.ts'];
308
311
  this.excludeLibraries = [];
@@ -339,9 +342,7 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
339
342
  return path__namespace.resolve(__dirname, './apis');
340
343
  }
341
344
  get apiEntry() {
342
- return [
343
- /(@tarojs[\\/]plugin-platform-harmony-ets|taro-platform-harmony)[\\/]dist[\\/]apis[\\/]index\.ts/,
344
- ];
345
+ return this.apiEntryList;
345
346
  }
346
347
  get componentLibrary() {
347
348
  return path__namespace.resolve(__dirname, './components-harmony-ets');
@@ -500,7 +501,9 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
500
501
  }
501
502
  return src;
502
503
  });
503
- const define = Object.assign({}, this.defineConstants);
504
+ const define = Object.assign(Object.assign({}, this.defineConstants), {
505
+ // Note: React 开发环境可能调用 stack 可能导致 appWrapper 实例变更
506
+ 'ReactDebugCurrentFrame.getCurrentStack': 'ReactDebugCurrentFrame.getCurrentStack$' });
504
507
  if ([/(@tarojs[\\/]runtime|taro-runtime)[\\/]dist/].some(e => e.test(lib))) {
505
508
  define.global = 'globalThis';
506
509
  }