@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-beta.0

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.
Files changed (176) hide show
  1. package/dist/apis/apis.ts +6 -2
  2. package/dist/apis/base/crypto.ts +4 -0
  3. package/dist/apis/base/debug.ts +5 -0
  4. package/dist/apis/base/index.ts +9 -1
  5. package/dist/apis/base/performance.ts +8 -0
  6. package/dist/apis/base/system.ts +1 -1
  7. package/dist/apis/base/update.ts +5 -0
  8. package/dist/apis/base/weapp/app-event.ts +75 -0
  9. package/dist/apis/base/weapp/life-cycle.ts +21 -0
  10. package/dist/apis/canvas/index.ts +18 -0
  11. package/dist/apis/data-analysis/index.ts +6 -0
  12. package/dist/apis/device/accelerometer.ts +2 -1
  13. package/dist/apis/device/accessibility.ts +4 -0
  14. package/dist/apis/device/battery.ts +2 -2
  15. package/dist/apis/device/bluetooth-ble.ts +19 -0
  16. package/dist/apis/device/bluetooth-peripheral.ts +6 -0
  17. package/dist/apis/device/bluetooth.ts +16 -0
  18. package/dist/apis/device/calendar.ts +5 -0
  19. package/dist/apis/device/clipboard.ts +1 -1
  20. package/dist/apis/device/compass.ts +21 -0
  21. package/dist/apis/device/contact.ts +5 -0
  22. package/dist/apis/device/crypto.ts +4 -0
  23. package/dist/apis/device/gyroscope.ts +7 -0
  24. package/dist/apis/device/iBeacon.ts +10 -0
  25. package/dist/apis/device/index.ts +15 -0
  26. package/dist/apis/device/keyboard.ts +2 -1
  27. package/dist/apis/device/motion.ts +6 -0
  28. package/dist/apis/device/network.ts +26 -9
  29. package/dist/apis/device/nfc.ts +10 -0
  30. package/dist/apis/device/phone.ts +2 -1
  31. package/dist/apis/device/scan.ts +4 -0
  32. package/dist/apis/device/screen.ts +2 -1
  33. package/dist/apis/device/sms.ts +4 -0
  34. package/dist/apis/device/vibrate.ts +19 -11
  35. package/dist/apis/device/wifi.ts +15 -0
  36. package/dist/apis/ext/index.ts +5 -0
  37. package/dist/apis/files/index.ts +2 -1
  38. package/dist/apis/files/manager.ts +2 -1
  39. package/dist/apis/framework/index.ts +5 -6
  40. package/dist/apis/location/index.ts +61 -68
  41. package/dist/apis/media/EditorContext.ts +32 -0
  42. package/dist/apis/media/audio/index.ts +18 -0
  43. package/dist/apis/media/background-audio/index.ts +16 -0
  44. package/dist/apis/media/camera.ts +16 -0
  45. package/dist/apis/media/common.ts +2 -1
  46. package/dist/apis/media/{image.ts → image/index.ts} +3 -2
  47. package/dist/apis/media/index.ts +10 -0
  48. package/dist/apis/media/live.ts +5 -0
  49. package/dist/apis/media/map.ts +4 -0
  50. package/dist/apis/media/media-recorder.ts +4 -0
  51. package/dist/apis/media/recorder.ts +6 -0
  52. package/dist/apis/media/video/VideoContext.ts +19 -0
  53. package/dist/apis/media/{video.ts → video/index.ts} +12 -2
  54. package/dist/apis/media/video-decoder.ts +4 -0
  55. package/dist/apis/media/video-processing.ts +4 -0
  56. package/dist/apis/media/voip.ts +19 -0
  57. package/dist/apis/network/index.ts +3 -0
  58. package/dist/apis/network/mdns.ts +13 -0
  59. package/dist/apis/network/request.ts +2 -1
  60. package/dist/apis/network/tcp.ts +4 -0
  61. package/dist/apis/network/udp.ts +4 -0
  62. package/dist/apis/network/webSocket.ts +2 -6
  63. package/dist/apis/open-api/account.ts +4 -0
  64. package/dist/apis/open-api/address.ts +4 -0
  65. package/dist/apis/open-api/authorize.ts +5 -0
  66. package/dist/apis/open-api/card.ts +5 -0
  67. package/dist/apis/open-api/channels-live.ts +11 -0
  68. package/dist/apis/open-api/customer-service.ts +4 -0
  69. package/dist/apis/open-api/device-voip.ts +5 -0
  70. package/dist/apis/open-api/facial.ts +7 -0
  71. package/dist/apis/open-api/favorites.ts +5 -0
  72. package/dist/apis/open-api/group.ts +4 -0
  73. package/dist/apis/open-api/index.ts +20 -6
  74. package/dist/apis/open-api/invoice.ts +5 -0
  75. package/dist/apis/open-api/license-plate.ts +4 -0
  76. package/dist/apis/open-api/login.ts +6 -0
  77. package/dist/apis/open-api/my-miniprogram.ts +4 -0
  78. package/dist/apis/open-api/privacy.ts +7 -0
  79. package/dist/apis/open-api/red-package.ts +4 -0
  80. package/dist/apis/open-api/settings.ts +5 -0
  81. package/dist/apis/open-api/soter.ts +6 -0
  82. package/dist/apis/open-api/subscribe-message.ts +6 -0
  83. package/dist/apis/open-api/{user-info/index.ts → user-info.ts} +1 -16
  84. package/dist/apis/open-api/werun.ts +5 -0
  85. package/dist/apis/payment/index.ts +6 -0
  86. package/dist/apis/route/index.ts +4 -28
  87. package/dist/apis/share/index.ts +33 -0
  88. package/dist/apis/storage/background-fetch.ts +7 -0
  89. package/dist/apis/storage/cache-manager.ts +4 -0
  90. package/dist/apis/storage/index.ts +20 -18
  91. package/dist/apis/ui/{animation.ts → animation/animation.ts} +2 -2
  92. package/dist/apis/ui/animation/index.ts +7 -0
  93. package/dist/apis/ui/background.ts +2 -18
  94. package/dist/apis/ui/custom-component.ts +8 -0
  95. package/dist/apis/ui/fonts.ts +4 -0
  96. package/dist/apis/ui/index.ts +8 -10
  97. package/dist/apis/ui/interaction/index.ts +3 -0
  98. package/dist/apis/ui/menu.ts +4 -0
  99. package/dist/apis/ui/navigation-bar/index.ts +60 -21
  100. package/dist/apis/ui/pull-down-refresh.ts +1 -1
  101. package/dist/apis/{page → ui/scroll}/index.ts +27 -22
  102. package/dist/apis/ui/sticky.ts +4 -0
  103. package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +3 -5
  104. package/dist/apis/ui/window.ts +20 -0
  105. package/dist/apis/utils/handler.ts +4 -4
  106. package/dist/apis/worker/index.ts +4 -0
  107. package/dist/apis/wxml/IntersectionObserver.ts +12 -21
  108. package/dist/apis/wxml/index.ts +5 -2
  109. package/dist/apis/wxml/nodesRef.ts +2 -2
  110. package/dist/apis/wxml/selectorQuery.ts +3 -4
  111. package/dist/components-harmony-ets/button.ets +90 -64
  112. package/dist/components-harmony-ets/checkbox.ets +53 -98
  113. package/dist/components-harmony-ets/form.ets +16 -112
  114. package/dist/components-harmony-ets/icon.ets +59 -46
  115. package/dist/components-harmony-ets/image.ets +15 -40
  116. package/dist/components-harmony-ets/innerHtml.ets +6 -74
  117. package/dist/components-harmony-ets/input.ets +58 -128
  118. package/dist/components-harmony-ets/label.ets +43 -69
  119. package/dist/components-harmony-ets/picker.ets +114 -137
  120. package/dist/components-harmony-ets/radio.ets +55 -103
  121. package/dist/components-harmony-ets/richText.ets +17 -41
  122. package/dist/components-harmony-ets/scrollView.ets +69 -101
  123. package/dist/components-harmony-ets/slider.ets +35 -58
  124. package/dist/components-harmony-ets/swiper.ets +24 -135
  125. package/dist/components-harmony-ets/switch.ets +25 -55
  126. package/dist/components-harmony-ets/text.ets +42 -46
  127. package/dist/components-harmony-ets/textArea.ets +39 -107
  128. package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
  129. package/dist/components-harmony-ets/utils/flexManager.ets +3 -88
  130. package/dist/components-harmony-ets/utils/helper.ets +2 -62
  131. package/dist/components-harmony-ets/utils/index.ts +1 -1
  132. package/dist/components-harmony-ets/utils/styles.ets +6 -9
  133. package/dist/components-harmony-ets/video.ets +63 -92
  134. package/dist/components-harmony-ets/view.ets +65 -40
  135. package/dist/index.js +33 -4
  136. package/dist/index.js.map +1 -1
  137. package/dist/runtime-ets/bom/getComputedStyle.ts +1 -1
  138. package/dist/runtime-ets/dom/bind.ts +80 -0
  139. package/dist/runtime-ets/dom/class-list.ts +2 -4
  140. package/dist/runtime-ets/dom/comment.ts +1 -2
  141. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +1 -1
  142. package/dist/runtime-ets/dom/dataSource.ts +64 -0
  143. package/dist/runtime-ets/dom/document.ts +14 -43
  144. package/dist/runtime-ets/dom/element/element.ts +162 -0
  145. package/dist/runtime-ets/dom/element/form.ts +397 -0
  146. package/dist/runtime-ets/dom/element/index.ts +89 -0
  147. package/dist/runtime-ets/dom/element/normal.ts +75 -0
  148. package/dist/runtime-ets/dom/element/scrollView.ts +14 -0
  149. package/dist/runtime-ets/dom/element/text.ts +17 -0
  150. package/dist/runtime-ets/dom/element/video.ts +49 -0
  151. package/dist/runtime-ets/dom/event.ts +24 -1
  152. package/dist/runtime-ets/dom/eventTarget.ts +2 -1
  153. package/dist/runtime-ets/dom/node.ts +74 -44
  154. package/dist/runtime-ets/dom/stylesheet/index.ts +136 -23
  155. package/dist/runtime-ets/dom/stylesheet/type.ts +4 -3
  156. package/dist/runtime-ets/dom/stylesheet/util.ts +71 -1
  157. package/dist/runtime-ets/index.ts +0 -1
  158. package/dist/runtime-ets/utils/bind.ts +3 -14
  159. package/dist/runtime-ets/utils/index.ts +12 -7
  160. package/dist/runtime-ets/utils/info.ts +22 -50
  161. package/dist/runtime-framework/react/app.ts +3 -6
  162. package/dist/runtime-framework/react/page.ts +2 -9
  163. package/dist/runtime-framework/solid/page.ts +0 -6
  164. package/dist/runtime-utils.js +1150 -339
  165. package/dist/runtime-utils.js.map +1 -1
  166. package/dist/runtime.js +1150 -339
  167. package/dist/runtime.js.map +1 -1
  168. package/package.json +8 -8
  169. package/types/runtime.d.ts +4 -0
  170. package/LICENSE +0 -160
  171. package/dist/components-harmony-ets/base.ets +0 -63
  172. package/dist/components-harmony-ets/element.ets +0 -223
  173. package/dist/components-harmony-ets/utils/constant/icon.ts +0 -19
  174. package/dist/runtime-ets/dom/element.ts +0 -457
  175. package/dist/runtime-ets/dom/text.ts +0 -19
  176. package/types/api.d.ts +0 -4
@@ -12,96 +12,11 @@ class FlexManager {
12
12
  return {
13
13
  direction: flexDirection,
14
14
  justifyContent: hmStyle.justifyContent,
15
- alignItems: hmStyle.alignItems
15
+ alignItems: hmStyle.alignItems,
16
+ wrap: hmStyle.flexWrap,
17
+ alignContent: hmStyle.alignContent,
16
18
  }
17
19
  }
18
-
19
- static flexAlign (value: string | number | undefined): FlexAlign {
20
- switch (value) {
21
- case 'flex-end':
22
- return FlexAlign.End
23
- case 'center':
24
- return FlexAlign.Center
25
- case 'space-between':
26
- return FlexAlign.SpaceBetween
27
- case 'space-around':
28
- return FlexAlign.SpaceAround
29
- case 'space-evenly':
30
- return FlexAlign.SpaceEvenly
31
- default:
32
- return FlexAlign.Start
33
- }
34
- }
35
-
36
- static direction (value: string): FlexDirection {
37
- switch (value) {
38
- case 'row': return FlexDirection.Row;
39
- case 'row-reverse': return FlexDirection.RowReverse;
40
- case 'column-reverse': return FlexDirection.ColumnReverse;
41
- default: return FlexDirection.Column;
42
- }
43
- }
44
-
45
- static itemAlign (value: string | number | undefined): ItemAlign {
46
- switch (value) {
47
- case 'flex-start':
48
- return ItemAlign.Start
49
- case 'flex-end':
50
- return ItemAlign.End
51
- case 'center':
52
- return ItemAlign.Center
53
- case 'stretch':
54
- return ItemAlign.Stretch
55
- case 'baseline':
56
- return ItemAlign.Baseline
57
- default:
58
- return ItemAlign.Auto
59
- }
60
- }
61
-
62
- static justifyContent (value: string): FlexAlign {
63
- return FlexManager.flexAlign(value)
64
- }
65
-
66
- static alignItems (value: string): ItemAlign {
67
- return FlexManager.itemAlign(value)
68
- }
69
-
70
- static alignSelf (value: string): ItemAlign {
71
- return FlexManager.itemAlign(value)
72
- }
73
-
74
- static flexWrap (value: string): FlexWrap {
75
- return value === 'wrap' ? FlexWrap.Wrap : FlexWrap.NoWrap
76
- }
77
-
78
- static alignContent (style: Record<string, string | number> = {}): FlexAlign | undefined {
79
- if (style.flexWrap !== 'wrap') return undefined
80
- const value = style.alignContent
81
- return FlexManager.flexAlign(value)
82
- }
83
-
84
- static flexSize (style: Record<string, string | number> = {}): [number, number, number | string] {
85
- const flex = style.flex
86
- const flexGrow = style.flexGrow || 0
87
- const flexShrink = style.flexShrink || 0
88
- const flexBasis = style.flexBasis || 'auto'
89
- let res: [number, number, number | string] = [Number(flexGrow), Number(flexShrink), flexBasis]
90
-
91
- if (typeof flex === 'number') {
92
- res = [flex, 1, 0]
93
- } else if (flex === 'auto') {
94
- res = [1, 1, 'auto']
95
- } else if (flex === 'none') {
96
- res = [0, 0, 'auto']
97
- } else if (typeof flex === 'string') {
98
- const FlexList = flex.replace(new RegExp("/\s+/g"), ' ').split(' ')
99
- FlexList.forEach((item, index) => {
100
- res[index] = index < 2 ? Number(item) : item
101
- })
102
- }
103
- return res
104
- }
105
20
  }
106
21
 
107
22
  export { FlexManager }
@@ -1,8 +1,7 @@
1
1
  import { getNormalAttributes, getFontAttributes } from './styles'
2
- import { bindAttributesCallback, ObjectAssign } from '@tarojs/runtime'
3
2
 
4
- import type { TaroAny, TaroElement } from '@tarojs/runtime'
5
3
  import type { Func } from '@tarojs/runtime/dist/runtime.esm'
4
+ import type { TaroElement } from '@tarojs/runtime'
6
5
 
7
6
  export const parseStyles = (styles = ''): Record<string, string> => {
8
7
  const styleObj: Record<string, string> = {}
@@ -21,7 +20,6 @@ export const parseStyles = (styles = ''): Record<string, string> => {
21
20
  return styleObj
22
21
  }
23
22
 
24
-
25
23
  export function shouldBindEvent (cb: Func, node: TaroElement, eventNames: string[], disabled = false) {
26
24
  if (!node || node._attrs?.disabled || disabled) return null
27
25
  if (!node.__listeners) {
@@ -35,65 +33,7 @@ export function shouldBindEvent (cb: Func, node: TaroElement, eventNames: string
35
33
  export function getNodeThresholds (node: TaroElement): number[] | null {
36
34
  if (!node) return null
37
35
 
38
- const id = node._nid
39
- const instance: TaroAny = node._instance
40
-
41
- return instance?.nodeInfoMap?.[id]?.thresholds || null
42
- }
43
-
44
- function convertToCamelCase(str: string) {
45
- return str.replace(new RegExp("/-(.)/g"), (_, char: string) => char.toUpperCase()).replace(new RegExp("/^\w/"), firstChar => firstChar.toUpperCase())
46
- }
47
-
48
- // 动画绑定
49
- export function bindAnimation (node: TaroElement) {
50
- bindAttributesCallback(node, 'animation', async (animation: TaroAny) => {
51
- if (animation && animation.actions) {
52
- for (let i = 0; i < animation.actions.length; i++) {
53
- const anim: TaroAny = animation.actions[i]
54
- // 动画队列
55
- await new Promise<TaroAny>((resolve: TaroAny) => {
56
- const timingFunction: TaroAny = anim.timingFunction
57
- const animateParams: AnimateParam = {
58
- duration: anim.duration,
59
- delay: anim.delay,
60
- tempo: 1,
61
- // TODO: ETS转TS
62
- playMode: PlayMode.Normal,
63
- iterations: 1,
64
- onFinish: resolve
65
- }
66
- if (timingFunction === 'step-start') {
67
- animateParams.tempo = 0
68
- } else if (timingFunction === 'step-end') {
69
- animateParams.tempo = 0
70
- animateParams.delay = anim.duration + anim.delay
71
- animateParams.duration = 0
72
- }
73
- animateParams.curve = Curve[convertToCamelCase(timingFunction)] || Curve.EaseInOut
74
- animateTo(animateParams, () => {
75
- const component: TaroAny = node._instance
76
- const transformOrigin: string = anim.transformOrigin
77
-
78
- if (transformOrigin) {
79
- const splitOrigin = transformOrigin.split(' ')
80
- Object.keys(anim.rule).forEach(key => {
81
- if (['scale', 'rotate'].includes(key)) {
82
- anim.rule[key] = ObjectAssign(anim.rule[key], {
83
- centerX: splitOrigin[0],
84
- centerY: splitOrigin[1],
85
- })
86
- }
87
- })
88
- }
89
-
90
- component.nodeInfoMap[node._nid].overwriteStyle = anim.rule
91
- node.updateComponent()
92
- })
93
- })
94
- }
95
- }
96
- })
36
+ return node?._nodeInfo.thresholds || null
97
37
  }
98
38
 
99
39
  export { getNormalAttributes, getFontAttributes }
@@ -1,7 +1,7 @@
1
1
  import { convertNumber2VP } from '@tarojs/runtime'
2
2
  import { isNumber } from '@tarojs/shared'
3
3
 
4
- export function getSingleSelector(ctx, range, rangeKey): any[] {
4
+ export function getSingleSelector(range, rangeKey): any[] {
5
5
  return range.map((data) => data[rangeKey])
6
6
  }
7
7
 
@@ -1,10 +1,9 @@
1
1
  import { ObjectAssign } from '@tarojs/runtime'
2
2
 
3
- import { AttributeManager } from './AttributeManager'
4
3
  import { TEXT_DEFAULT_STYLE } from './constant/style'
5
4
 
6
- import type { TaroAny, TaroElement, TaroStyleType, TaroTextStyleType, HarmonyType, HarmonyStyle } from '@tarojs/runtime'
7
5
  import type { StandardProps } from '@tarojs/components/types'
6
+ import type { TaroAny, TaroElement, TaroStyleType, TaroTextStyleType, HarmonyType, HarmonyStyle } from '@tarojs/runtime'
8
7
 
9
8
  export function getFontAttributes (node: TaroElement): TaroTextStyleType {
10
9
  const hmStyle = node.hmStyle
@@ -54,6 +53,7 @@ export function getNormalAttributes (node: TaroElement): TaroStyleType {
54
53
  backgroundImage: hmStyle.backgroundImage,
55
54
  backgroundImageSize: hmStyle.backgroundImageSize,
56
55
  backgroundRepeat: hmStyle.backgroundRepeat,
56
+ backgroundImagePosition: hmStyle.backgroundImagePosition,
57
57
  linearGradient: hmStyle.linearGradient,
58
58
  // 变换相关
59
59
  rotate: transformRotate,
@@ -71,16 +71,13 @@ export function getNormalAttributes (node: TaroElement): TaroStyleType {
71
71
  // 其他
72
72
  clip: hmStyle.clip,
73
73
  id: _attrs.id || _nid,
74
+ opacity: hmStyle.opacity,
74
75
  // focus: _attrs.focus || false,
75
76
  }
76
77
 
77
-
78
- const id = node._nid
79
- const component: TaroAny = node._instance
80
-
81
- // taro_page 等写死在运行时里的节点,没有 _instance
82
- if (component) {
83
- const overwriteStyle: TaroStyleType = component.nodeInfoMap[id].overwriteStyle
78
+ // taro_page 等写死在运行时里的节点,没有 _nodeInfo
79
+ if (node._nodeInfo) {
80
+ const overwriteStyle: TaroStyleType = node._nodeInfo?.overwriteStyle
84
81
 
85
82
  // 处理覆盖属性:如动画的覆盖
86
83
  if (overwriteStyle) {
@@ -1,13 +1,9 @@
1
- import { bindInstanceToNode, AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, initComponentNodeInfo, getPageScrollerOrNode,
2
- TaroEvent, TaroAny } from '@tarojs/runtime'
1
+ import { AREA_CHANGE_EVENT_NAME, eventHandler, getComponentEventCallback, VISIBLE_CHANGE_EVENT_NAME, createTaroEvent } from '@tarojs/runtime'
3
2
 
4
- import TaroComponentWrapper from './base'
5
3
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
6
- import { createTaroEvent } from './utils/events'
7
- import { getNormalAttributes, shouldBindEvent, getNodeThresholds, bindAnimation } from './utils/helper'
4
+ import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
8
5
 
9
- import type { TaroVideoElement } from './element'
10
- import type { TaroStyleType } from '@tarojs/runtime'
6
+ import type { TaroStyleType, TaroAny, TaroVideoElement, TaroEvent } from '@tarojs/runtime'
11
7
 
12
8
  export interface VideoOptions {
13
9
  src?: string | Resource
@@ -41,6 +37,7 @@ function attrs (style: TaroStyleType) {
41
37
  .backgroundColor(style.backgroundColor)
42
38
  .backgroundImage(style.backgroundImage, style.backgroundRepeat)
43
39
  .backgroundImageSize(style.backgroundImageSize)
40
+ .backgroundImagePosition(style.backgroundImagePosition)
44
41
  .rotate(style.rotate)
45
42
  .scale(style.scale)
46
43
  .translate(style.translate)
@@ -61,101 +58,75 @@ function props(attr: VideoAttrs) {
61
58
  .autoPlay(attr.autoPlay)
62
59
  .controls(attr.controls)
63
60
  .objectFit(attr.objectFit)
64
- .loop(attr.loop)
61
+ .loop(attr.loop || false)
65
62
  }
66
63
 
67
- @Component
68
- export default struct TaroVideo {
69
- nodeInfoMap: TaroAny = {}
64
+ function emitEvent (node: TaroVideoElement, type: string, detail?: TaroAny) {
65
+ const event: TaroEvent = createTaroEvent(type, { detail }, node)
70
66
 
71
- @Styles visibleChangeEvent () {
72
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
73
- }
74
-
75
- @ObjectLink node: TaroVideoElement
76
-
77
- controller: VideoController = new VideoController()
78
-
79
- aboutToAppear () {
80
- initComponentNodeInfo(this, this.node)
81
- bindInstanceToNode(this.node, this)
82
- // 绑定动画
83
- bindAnimation(this.node)
84
- }
85
-
86
- @Styles defaultEvent () {
87
- .onClick((e: ClickEvent) => {
88
- eventHandler(e, 'click', this.node)
89
- })
90
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
91
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
92
- const eventResult: TaroAny = res.eventResult
93
- this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
94
- }))
95
- }
67
+ event.stopPropagation()
68
+ eventHandler(event, type, node)
69
+ }
96
70
 
97
- emitEvent = (type: string, detail?: TaroAny) => {
98
- const event: TaroEvent = createTaroEvent(type, { detail }, this.node)
99
- event.stopPropagation()
100
- eventHandler(event, type, this.node)
71
+ function getVideoData (node: TaroVideoElement): VideoOptions {
72
+ const src = node._attrs.src
73
+ const poster = node._attrs.poster
74
+ return {
75
+ src,
76
+ previewUri: poster,
77
+ controller: node.controller
101
78
  }
79
+ }
102
80
 
103
-
104
- getVideoData (): VideoOptions {
105
- const src = this.node._attrs.src
106
- const poster = this.node._attrs.poster
107
- return {
108
- src,
109
- previewUri: poster,
110
- controller: this.controller
111
- }
81
+ function getObjectFit (node: TaroVideoElement) {
82
+ switch (node._attrs.objectFit) {
83
+ case 'contain': return ImageFit.Contain
84
+ case 'cover': return ImageFit.Cover
85
+ case 'fill': return ImageFit.Fill
86
+ default: return ImageFit.Contain
112
87
  }
88
+ }
113
89
 
114
- getObjectFit () {
115
- switch (this.node._attrs.objectFit) {
116
- case 'contain': return ImageFit.Contain
117
- case 'cover': return ImageFit.Cover
118
- case 'fill': return ImageFit.Fill
119
- default: return ImageFit.Contain
120
- }
90
+ function getVideoProps (node: TaroVideoElement): VideoAttrs {
91
+ const muted: boolean = node._attrs.muted || false
92
+ const autoPlay: boolean = node._attrs.autoplay || false
93
+ const controls: boolean = node._attrs.controls || false
94
+ const objectFit: ImageFit = getObjectFit(node)
95
+ const loop: boolean = node._attrs.loop || false
96
+ return {
97
+ muted,
98
+ controls,
99
+ objectFit,
100
+ loop,
101
+ autoPlay
121
102
  }
103
+ }
122
104
 
123
- getVideoProps (): VideoAttrs {
124
- const muted: boolean = this.node._attrs.muted || false
125
- const autoPlay: boolean = this.node._attrs.autoplay || false
126
- const controls: boolean = this.node._attrs.controls || false
127
- const objectFit: ImageFit = this.getObjectFit()
128
- const loop: boolean = this.node._attrs.loop || false
129
- return {
130
- muted,
131
- controls,
132
- objectFit,
133
- loop,
134
- autoPlay
135
- }
136
- }
105
+ function handleUpdate (node: TaroVideoElement, e: VideoUpdateEvent) {
106
+ node._currentTime = e.time
137
107
 
138
- handleUpdate (e: VideoUpdateEvent) {
139
- this.nodeInfoMap[this.node._nid].currentTime = e.time
140
- this.emitEvent('timeUpdate', { currentTime: e.time})
141
- }
108
+ emitEvent(node, 'timeUpdate', { currentTime: e.time})
109
+ }
142
110
 
143
- build() {
144
- TaroComponentWrapper({ node: this.node }) {
145
- Video(this.getVideoData())
146
- .attrs(getNormalAttributes(this.node))
147
- .props(this.getVideoProps())
148
- .defaultEvent()
149
- .visibleChangeEvent()
150
- .onStart(shouldBindEvent(() => { this.emitEvent('play') }, this.node, ['play']))
151
- .onPause(shouldBindEvent(() => { this.emitEvent('pause') }, this.node, ['pause']))
152
- .onFinish(shouldBindEvent(() => { this.emitEvent('ended') }, this.node, ['ended']))
153
- .onError(shouldBindEvent(() => { this.emitEvent('error') }, this.node, ['error']))
154
- .onUpdate((e) => { this.handleUpdate(e) })
155
- .onPrepared(shouldBindEvent((e: TaroAny) => { this.emitEvent('loadedMetaData', { duration: e.duration }) }, this.node, ['loadedmetadata']))
156
- .onSeeking(shouldBindEvent((e: TaroAny) => { this.emitEvent('seeking', { duration: e.time }) }, this.node, ['seeking']))
157
- .onSeeked(shouldBindEvent(() => { this.emitEvent('seeked') }, this.node, ['seeked']))
158
- .onFullscreenChange(shouldBindEvent((e: TaroAny) => { this.emitEvent('fullScreenChange', { fullScreen: e.fullscreen}) }, this.node, ['fullscreenchange']))
159
- }
160
- }
111
+ @Builder
112
+ export default function TaroVideo (node: TaroVideoElement) {
113
+ Video(getVideoData(node))
114
+ .attrs(getNormalAttributes(node))
115
+ .props(getVideoProps(node))
116
+ .aspectRatio(4 / 3)
117
+ .onStart(shouldBindEvent(() => { emitEvent(node, 'play') }, node, ['play']))
118
+ .onPause(shouldBindEvent(() => { emitEvent(node, 'pause') }, node, ['pause']))
119
+ .onFinish(shouldBindEvent(() => { emitEvent(node, 'ended') }, node, ['ended']))
120
+ .onError(shouldBindEvent(() => { emitEvent(node, 'error') }, node, ['error']))
121
+ .onUpdate((e) => { handleUpdate(node, e) })
122
+ .onPrepared(shouldBindEvent((e: TaroAny) => { emitEvent(node, 'loadedMetaData', { duration: e.duration }) }, node, ['loadedmetadata']))
123
+ .onSeeking(shouldBindEvent((e: TaroAny) => { emitEvent(node, 'seeking', { duration: e.time }) }, node, ['seeking']))
124
+ .onSeeked(shouldBindEvent(() => { emitEvent(node, 'seeked') }, node, ['seeked']))
125
+ .onFullscreenChange(shouldBindEvent((e: TaroAny) => { emitEvent(node, 'fullScreenChange', { fullScreen: e.fullscreen}) }, node, ['fullscreenchange']))
126
+ .onClick((e: ClickEvent) => { eventHandler(e, 'click', node) })
127
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
128
+ .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
129
+ node._nodeInfo.areaInfo = res[1]
130
+ }))
131
+ .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
161
132
  }
@@ -1,30 +1,61 @@
1
- import { bindInstanceToNode, eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME, initComponentNodeInfo, TaroAny } from '@tarojs/runtime'
1
+ import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
2
2
 
3
- import { createNode } from './render'
4
- import TaroComponentWrapper from './base'
3
+ import { createLazyChildren } from './render'
5
4
  import { TOUCH_EVENT_MAP } from './utils/constant/event'
6
5
  import { FlexManager } from './utils/FlexManager'
7
- import { getNodeThresholds, getNormalAttributes, shouldBindEvent, bindAnimation } from './utils/helper'
6
+ import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
8
7
 
9
- import type { TaroViewElement, TaroElement } from './element'
10
- import type { TaroStyleType } from '@tarojs/runtime'
8
+ import type { TaroViewElement, TaroAny, TaroStyleType } from '@tarojs/runtime'
11
9
 
12
10
  @Extend(Flex)
13
- function attrs (style: TaroStyleType) {
11
+ function flexAttrs (style: TaroStyleType) {
14
12
  .id(style.id)
15
13
  .key(style.id)
14
+ .flexGrow(style.flexGrow)
15
+ .flexShrink(style.flexShrink)
16
+ .flexBasis(style.flexBasis)
17
+ .alignSelf(style.alignSelf)
16
18
  .padding(style.padding)
17
19
  .margin(style.margin)
18
20
  .width(style.width)
19
21
  .height(style.height)
20
22
  .constraintSize(style.constraintSize)
23
+ .backgroundColor(style.backgroundColor)
24
+ .backgroundImage(style.backgroundImage, style.backgroundRepeat)
25
+ .backgroundImageSize(style.backgroundImageSize)
26
+ .backgroundImagePosition(style.backgroundImagePosition)
27
+ .rotate(style.rotate)
28
+ .scale(style.scale)
29
+ .translate(style.translate)
30
+ .transform(style.transform)
31
+ .borderStyle(style.borderStyle)
32
+ .borderWidth(style.borderWidth)
33
+ .borderColor(style.borderColor)
34
+ .borderRadius(style.borderRadius)
35
+ .linearGradient(style.linearGradient)
36
+ .zIndex(style.zIndex)
37
+ .opacity(style.opacity)
38
+ .clip(style.clip)
39
+ }
40
+
41
+
42
+ @Extend(Column)
43
+ function columnAttrs (style: TaroStyleType) {
44
+ .id(style.id)
45
+ .key(style.id)
21
46
  .flexGrow(style.flexGrow)
22
47
  .flexShrink(style.flexShrink)
23
48
  .flexBasis(style.flexBasis)
24
49
  .alignSelf(style.alignSelf)
50
+ .padding(style.padding)
51
+ .margin(style.margin)
52
+ .width(style.width)
53
+ .height(style.height)
54
+ .constraintSize(style.constraintSize)
25
55
  .backgroundColor(style.backgroundColor)
26
56
  .backgroundImage(style.backgroundImage, style.backgroundRepeat)
27
57
  .backgroundImageSize(style.backgroundImageSize)
58
+ .backgroundImagePosition(style.backgroundImagePosition)
28
59
  .rotate(style.rotate)
29
60
  .scale(style.scale)
30
61
  .translate(style.translate)
@@ -39,41 +70,35 @@ function attrs (style: TaroStyleType) {
39
70
  .clip(style.clip)
40
71
  }
41
72
 
42
- @Component
43
- export default struct TaroView {
44
- nodeInfoMap: TaroAny = {}
45
-
46
- @Styles visibleChangeEvent () {
47
- .onVisibleAreaChange(getNodeThresholds(this.node) || [0.0, 1.0], getComponentEventCallback(this.node, VISIBLE_CHANGE_EVENT_NAME))
48
- }
49
-
50
- @ObjectLink node: TaroViewElement
51
-
52
- aboutToAppear () {
53
- initComponentNodeInfo(this, this.node)
54
- bindInstanceToNode(this.node, this)
55
- // 绑定动画
56
- bindAnimation(this.node)
57
- }
73
+ function isFlexNode (node: TaroViewElement) {
74
+ return !!node.hmStyle?.display?.includes('flex')
75
+ }
58
76
 
59
- @Styles defaultEvent () {
60
- .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', this.node), this.node, ['click']))
61
- .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), this.node), this.node, TOUCH_EVENT_MAP.values()))
62
- .onAreaChange(getComponentEventCallback(this.node, AREA_CHANGE_EVENT_NAME, res => {
63
- const eventResult: TaroAny = res.eventResult
64
- this.nodeInfoMap[this.node._nid].areaInfo = eventResult[1]
77
+ @Builder
78
+ export default function TaroView (node: TaroViewElement) {
79
+ if (isFlexNode(node)) {
80
+ Flex(FlexManager.flexOptions(node)) {
81
+ createLazyChildren(node)
82
+ }
83
+ .flexAttrs(getNormalAttributes(node))
84
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
85
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
86
+ .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
87
+ node._nodeInfo.areaInfo = res[1]
65
88
  }))
66
- }
67
- build() {
68
- TaroComponentWrapper({ node: this.node }) {
69
- Flex(FlexManager.flexOptions(this.node)) {
70
- ForEach(this.node.childNodes, (item: TaroElement) => {
71
- createNode(item)
72
- }, (item: TaroElement) => item._nid)
73
- }
74
- .attrs(getNormalAttributes(this.node))
75
- .defaultEvent()
76
- .visibleChangeEvent()
89
+ .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
90
+ } else {
91
+ Column() {
92
+ createLazyChildren(node)
77
93
  }
94
+ .columnAttrs(getNormalAttributes(node))
95
+ .onClick(shouldBindEvent((e: ClickEvent) => eventHandler(e, 'click', node), node, ['click']))
96
+ .onTouch(shouldBindEvent((e: TouchEvent) => eventHandler(e, TOUCH_EVENT_MAP.get(e.type), node), node, TOUCH_EVENT_MAP.values()))
97
+ .onAreaChange(getComponentEventCallback(node, AREA_CHANGE_EVENT_NAME, (res: TaroAny) => {
98
+ node._nodeInfo.areaInfo = res[1]
99
+ }))
100
+ .onVisibleAreaChange(getNodeThresholds(node) || [0.0, 1.0], getComponentEventCallback(node, VISIBLE_CHANGE_EVENT_NAME))
101
+ .alignItems(HorizontalAlign.Start)
102
+ .justifyContent(node.hmStyle.justifyContent)
78
103
  }
79
104
  }
package/dist/index.js CHANGED
@@ -71,7 +71,7 @@ function __classPrivateFieldSet(receiver, state, value, kind, f) {
71
71
  }
72
72
 
73
73
  const PLATFORM_NAME = 'harmony';
74
- const PACKAGE_NAME = '@tarojs/plugin-platform-harmony';
74
+ const PACKAGE_NAME = '@tarojs/plugin-platform-harmony-ets';
75
75
  const PLUGIN_NAME = 'TaroHarmony';
76
76
  const HARMONY_SCOPES = [/^@system\./, /^@ohos\./, /^@hmscore\//];
77
77
 
@@ -224,7 +224,7 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
224
224
  ['@tarojs/components/types', /^@tarojs[\\/]components[\\/]types/],
225
225
  ['@tarojs/components', /^@tarojs[\\/]components([\\/].+)?$/, this.componentLibrary],
226
226
  ['@tarojs/react', /^@tarojs[\\/]react$/],
227
- ['@tarojs/runtime', /^@tarojs[\\/]runtime$/, this.runtimeLibrary],
227
+ ['@tarojs/runtime', /^@tarojs[\\/]runtime([\\/]ets[\\/].*)?$/, this.runtimeLibrary],
228
228
  ['@tarojs/taro/types', /^@tarojs[\\/]taro[\\/]types/],
229
229
  ['@tarojs/taro', /^@tarojs[\\/]taro$/, this.apiLibrary],
230
230
  ['@tarojs/plugin-framework-react/dist/runtime', /^@tarojs[\\/]plugin-framework-react[\\/]dist[\\/]runtime$/, this.runtimeFrameworkLibrary],
@@ -236,6 +236,10 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
236
236
  this.modifyViteConfig();
237
237
  },
238
238
  });
239
+ ctx.onBuildFinish(() => {
240
+ const outDir = path__namespace.resolve(process.cwd(), config.outputRoot);
241
+ this.handleResourceEmit(outDir);
242
+ });
239
243
  }
240
244
  get framework() {
241
245
  return this.ctx.initialConfig.framework || 'react';
@@ -312,6 +316,7 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
312
316
  basedir,
313
317
  extensions: this.extensions,
314
318
  mainFields: [...helper.defaultMainFields],
319
+ preserveSymlinks: false,
315
320
  });
316
321
  if (!typePath) {
317
322
  typeName = path__namespace.join(path__namespace.dirname(lib), `${basename}.d.ts`);
@@ -319,6 +324,7 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
319
324
  basedir,
320
325
  extensions: this.extensions,
321
326
  mainFields: [...helper.defaultMainFields],
327
+ preserveSymlinks: false,
322
328
  });
323
329
  }
324
330
  if (typePath) {
@@ -345,7 +351,9 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
345
351
  else {
346
352
  // FIXME 多级目录,可能存在入口不为 index 或者引用一级目录文件的情况,需要额外处理
347
353
  const dir = path__namespace.dirname(pkgPath);
348
- target = path__namespace.join(target, dir);
354
+ if (libDir.includes(helper.NODE_MODULES)) {
355
+ target = path__namespace.join(target, dir);
356
+ }
349
357
  lib = path__namespace.dirname(lib);
350
358
  }
351
359
  }
@@ -378,7 +386,7 @@ let Harmony$1 = class Harmony extends TaroPlatformHarmony {
378
386
  const targetPath = path__namespace.join(outputRoot, helper.NODE_MODULES, p1);
379
387
  const relativePath = parseRelativePath(path__namespace.dirname(target), targetPath);
380
388
  if (HARMONY_SCOPES.every(e => !e.test(p1))) {
381
- if (this.indexOfLibraries(p1) === -1) {
389
+ if (this.indexOfLibraries(p1) === -1 && !/\.(d\.ts|flow\.js)$/.test(lib)) {
382
390
  this.externalDeps.push([p1, new RegExp(`^${p1.replace(/([-\\/$])/g, '\\$1')}$`)]);
383
391
  this.moveLibraries(p1, targetPath, path__namespace.dirname(lib), true);
384
392
  }
@@ -533,6 +541,27 @@ function App(props) {
533
541
  viteConfig.plugins.push(externalPlugin(), injectLoaderMeta());
534
542
  });
535
543
  }
544
+ handleResourceEmit(outDir, basedir = this.ctx.paths.appPath) {
545
+ const resources = path__namespace.resolve(outDir, '..', 'resources');
546
+ const mediaPath = 'static/media';
547
+ const mediaSource = helper.resolveSync(`${PACKAGE_NAME}/${mediaPath}`, {
548
+ basedir,
549
+ extensions: this.extensions,
550
+ mainFields: [...helper.defaultMainFields],
551
+ preserveSymlinks: false,
552
+ isFile: (file) => {
553
+ try {
554
+ const stat = helper.fs.lstatSync(file);
555
+ return stat.isFile() || (file.endsWith(mediaPath) && stat.isDirectory());
556
+ }
557
+ catch (_) { } // eslint-disable-line no-empty
558
+ return false;
559
+ }
560
+ });
561
+ if (mediaSource) {
562
+ this.moveLibraries(mediaSource, path__namespace.join(resources, 'base/media'), basedir);
563
+ }
564
+ }
536
565
  };
537
566
  _Harmony_defineConstants = new WeakMap();
538
567