@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.
- package/dist/apis/apis.ts +6 -2
- package/dist/apis/base/crypto.ts +4 -0
- package/dist/apis/base/debug.ts +5 -0
- package/dist/apis/base/index.ts +9 -1
- package/dist/apis/base/performance.ts +8 -0
- package/dist/apis/base/system.ts +1 -1
- package/dist/apis/base/update.ts +5 -0
- package/dist/apis/base/weapp/app-event.ts +75 -0
- package/dist/apis/base/weapp/life-cycle.ts +21 -0
- package/dist/apis/canvas/index.ts +18 -0
- package/dist/apis/data-analysis/index.ts +6 -0
- package/dist/apis/device/accelerometer.ts +2 -1
- package/dist/apis/device/accessibility.ts +4 -0
- package/dist/apis/device/battery.ts +2 -2
- package/dist/apis/device/bluetooth-ble.ts +19 -0
- package/dist/apis/device/bluetooth-peripheral.ts +6 -0
- package/dist/apis/device/bluetooth.ts +16 -0
- package/dist/apis/device/calendar.ts +5 -0
- package/dist/apis/device/clipboard.ts +1 -1
- package/dist/apis/device/compass.ts +21 -0
- package/dist/apis/device/contact.ts +5 -0
- package/dist/apis/device/crypto.ts +4 -0
- package/dist/apis/device/gyroscope.ts +7 -0
- package/dist/apis/device/iBeacon.ts +10 -0
- package/dist/apis/device/index.ts +15 -0
- package/dist/apis/device/keyboard.ts +2 -1
- package/dist/apis/device/motion.ts +6 -0
- package/dist/apis/device/network.ts +26 -9
- package/dist/apis/device/nfc.ts +10 -0
- package/dist/apis/device/phone.ts +2 -1
- package/dist/apis/device/scan.ts +4 -0
- package/dist/apis/device/screen.ts +2 -1
- package/dist/apis/device/sms.ts +4 -0
- package/dist/apis/device/vibrate.ts +19 -11
- package/dist/apis/device/wifi.ts +15 -0
- package/dist/apis/ext/index.ts +5 -0
- package/dist/apis/files/index.ts +2 -1
- package/dist/apis/files/manager.ts +2 -1
- package/dist/apis/framework/index.ts +5 -6
- package/dist/apis/location/index.ts +61 -68
- package/dist/apis/media/EditorContext.ts +32 -0
- package/dist/apis/media/audio/index.ts +18 -0
- package/dist/apis/media/background-audio/index.ts +16 -0
- package/dist/apis/media/camera.ts +16 -0
- package/dist/apis/media/common.ts +2 -1
- package/dist/apis/media/{image.ts → image/index.ts} +3 -2
- package/dist/apis/media/index.ts +10 -0
- package/dist/apis/media/live.ts +5 -0
- package/dist/apis/media/map.ts +4 -0
- package/dist/apis/media/media-recorder.ts +4 -0
- package/dist/apis/media/recorder.ts +6 -0
- package/dist/apis/media/video/VideoContext.ts +19 -0
- package/dist/apis/media/{video.ts → video/index.ts} +12 -2
- package/dist/apis/media/video-decoder.ts +4 -0
- package/dist/apis/media/video-processing.ts +4 -0
- package/dist/apis/media/voip.ts +19 -0
- package/dist/apis/network/index.ts +3 -0
- package/dist/apis/network/mdns.ts +13 -0
- package/dist/apis/network/request.ts +2 -1
- package/dist/apis/network/tcp.ts +4 -0
- package/dist/apis/network/udp.ts +4 -0
- package/dist/apis/network/webSocket.ts +2 -6
- package/dist/apis/open-api/account.ts +4 -0
- package/dist/apis/open-api/address.ts +4 -0
- package/dist/apis/open-api/authorize.ts +5 -0
- package/dist/apis/open-api/card.ts +5 -0
- package/dist/apis/open-api/channels-live.ts +11 -0
- package/dist/apis/open-api/customer-service.ts +4 -0
- package/dist/apis/open-api/device-voip.ts +5 -0
- package/dist/apis/open-api/facial.ts +7 -0
- package/dist/apis/open-api/favorites.ts +5 -0
- package/dist/apis/open-api/group.ts +4 -0
- package/dist/apis/open-api/index.ts +20 -6
- package/dist/apis/open-api/invoice.ts +5 -0
- package/dist/apis/open-api/license-plate.ts +4 -0
- package/dist/apis/open-api/login.ts +6 -0
- package/dist/apis/open-api/my-miniprogram.ts +4 -0
- package/dist/apis/open-api/privacy.ts +7 -0
- package/dist/apis/open-api/red-package.ts +4 -0
- package/dist/apis/open-api/settings.ts +5 -0
- package/dist/apis/open-api/soter.ts +6 -0
- package/dist/apis/open-api/subscribe-message.ts +6 -0
- package/dist/apis/open-api/{user-info/index.ts → user-info.ts} +1 -16
- package/dist/apis/open-api/werun.ts +5 -0
- package/dist/apis/payment/index.ts +6 -0
- package/dist/apis/route/index.ts +4 -28
- package/dist/apis/share/index.ts +33 -0
- package/dist/apis/storage/background-fetch.ts +7 -0
- package/dist/apis/storage/cache-manager.ts +4 -0
- package/dist/apis/storage/index.ts +20 -18
- package/dist/apis/ui/{animation.ts → animation/animation.ts} +2 -2
- package/dist/apis/ui/animation/index.ts +7 -0
- package/dist/apis/ui/background.ts +2 -18
- package/dist/apis/ui/custom-component.ts +8 -0
- package/dist/apis/ui/fonts.ts +4 -0
- package/dist/apis/ui/index.ts +8 -10
- package/dist/apis/ui/interaction/index.ts +3 -0
- package/dist/apis/ui/menu.ts +4 -0
- package/dist/apis/ui/navigation-bar/index.ts +60 -21
- package/dist/apis/ui/pull-down-refresh.ts +1 -1
- package/dist/apis/{page → ui/scroll}/index.ts +27 -22
- package/dist/apis/ui/sticky.ts +4 -0
- package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +3 -5
- package/dist/apis/ui/window.ts +20 -0
- package/dist/apis/utils/handler.ts +4 -4
- package/dist/apis/worker/index.ts +4 -0
- package/dist/apis/wxml/IntersectionObserver.ts +12 -21
- package/dist/apis/wxml/index.ts +5 -2
- package/dist/apis/wxml/nodesRef.ts +2 -2
- package/dist/apis/wxml/selectorQuery.ts +3 -4
- package/dist/components-harmony-ets/button.ets +90 -64
- package/dist/components-harmony-ets/checkbox.ets +53 -98
- package/dist/components-harmony-ets/form.ets +16 -112
- package/dist/components-harmony-ets/icon.ets +59 -46
- package/dist/components-harmony-ets/image.ets +15 -40
- package/dist/components-harmony-ets/innerHtml.ets +6 -74
- package/dist/components-harmony-ets/input.ets +58 -128
- package/dist/components-harmony-ets/label.ets +43 -69
- package/dist/components-harmony-ets/picker.ets +114 -137
- package/dist/components-harmony-ets/radio.ets +55 -103
- package/dist/components-harmony-ets/richText.ets +17 -41
- package/dist/components-harmony-ets/scrollView.ets +69 -101
- package/dist/components-harmony-ets/slider.ets +35 -58
- package/dist/components-harmony-ets/swiper.ets +24 -135
- package/dist/components-harmony-ets/switch.ets +25 -55
- package/dist/components-harmony-ets/text.ets +42 -46
- package/dist/components-harmony-ets/textArea.ets +39 -107
- package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
- package/dist/components-harmony-ets/utils/flexManager.ets +3 -88
- package/dist/components-harmony-ets/utils/helper.ets +2 -62
- package/dist/components-harmony-ets/utils/index.ts +1 -1
- package/dist/components-harmony-ets/utils/styles.ets +6 -9
- package/dist/components-harmony-ets/video.ets +63 -92
- package/dist/components-harmony-ets/view.ets +65 -40
- package/dist/index.js +33 -4
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/getComputedStyle.ts +1 -1
- package/dist/runtime-ets/dom/bind.ts +80 -0
- package/dist/runtime-ets/dom/class-list.ts +2 -4
- package/dist/runtime-ets/dom/comment.ts +1 -2
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +1 -1
- package/dist/runtime-ets/dom/dataSource.ts +64 -0
- package/dist/runtime-ets/dom/document.ts +14 -43
- package/dist/runtime-ets/dom/element/element.ts +162 -0
- package/dist/runtime-ets/dom/element/form.ts +397 -0
- package/dist/runtime-ets/dom/element/index.ts +89 -0
- package/dist/runtime-ets/dom/element/normal.ts +75 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +14 -0
- package/dist/runtime-ets/dom/element/text.ts +17 -0
- package/dist/runtime-ets/dom/element/video.ts +49 -0
- package/dist/runtime-ets/dom/event.ts +24 -1
- package/dist/runtime-ets/dom/eventTarget.ts +2 -1
- package/dist/runtime-ets/dom/node.ts +74 -44
- package/dist/runtime-ets/dom/stylesheet/index.ts +136 -23
- package/dist/runtime-ets/dom/stylesheet/type.ts +4 -3
- package/dist/runtime-ets/dom/stylesheet/util.ts +71 -1
- package/dist/runtime-ets/index.ts +0 -1
- package/dist/runtime-ets/utils/bind.ts +3 -14
- package/dist/runtime-ets/utils/index.ts +12 -7
- package/dist/runtime-ets/utils/info.ts +22 -50
- package/dist/runtime-framework/react/app.ts +3 -6
- package/dist/runtime-framework/react/page.ts +2 -9
- package/dist/runtime-framework/solid/page.ts +0 -6
- package/dist/runtime-utils.js +1150 -339
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.js +1150 -339
- package/dist/runtime.js.map +1 -1
- package/package.json +8 -8
- package/types/runtime.d.ts +4 -0
- package/LICENSE +0 -160
- package/dist/components-harmony-ets/base.ets +0 -63
- package/dist/components-harmony-ets/element.ets +0 -223
- package/dist/components-harmony-ets/utils/constant/icon.ts +0 -19
- package/dist/runtime-ets/dom/element.ts +0 -457
- package/dist/runtime-ets/dom/text.ts +0 -19
- 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
|
-
|
|
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(
|
|
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
|
-
|
|
79
|
-
|
|
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 {
|
|
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 {
|
|
7
|
-
import { getNormalAttributes, shouldBindEvent, getNodeThresholds, bindAnimation } from './utils/helper'
|
|
4
|
+
import { getNormalAttributes, shouldBindEvent, getNodeThresholds } from './utils/helper'
|
|
8
5
|
|
|
9
|
-
import type { TaroVideoElement } from '
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
nodeInfoMap: TaroAny = {}
|
|
64
|
+
function emitEvent (node: TaroVideoElement, type: string, detail?: TaroAny) {
|
|
65
|
+
const event: TaroEvent = createTaroEvent(type, { detail }, node)
|
|
70
66
|
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
return
|
|
108
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
124
|
-
|
|
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
|
-
|
|
139
|
-
|
|
140
|
-
this.emitEvent('timeUpdate', { currentTime: e.time})
|
|
141
|
-
}
|
|
108
|
+
emitEvent(node, 'timeUpdate', { currentTime: e.time})
|
|
109
|
+
}
|
|
142
110
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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 {
|
|
1
|
+
import { eventHandler, getComponentEventCallback, AREA_CHANGE_EVENT_NAME, VISIBLE_CHANGE_EVENT_NAME } from '@tarojs/runtime'
|
|
2
2
|
|
|
3
|
-
import {
|
|
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
|
|
6
|
+
import { getNodeThresholds, getNormalAttributes, shouldBindEvent } from './utils/helper'
|
|
8
7
|
|
|
9
|
-
import type { TaroViewElement,
|
|
10
|
-
import type { TaroStyleType } from '@tarojs/runtime'
|
|
8
|
+
import type { TaroViewElement, TaroAny, TaroStyleType } from '@tarojs/runtime'
|
|
11
9
|
|
|
12
10
|
@Extend(Flex)
|
|
13
|
-
function
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
.
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|