@tarojs/plugin-platform-harmony-cpp 4.1.0 → 4.1.1-alpha.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/index.js +1237 -0
- package/dist/runtime/apis/apis.ts +20 -0
- package/dist/runtime/apis/base/crypto.ts +4 -0
- package/dist/runtime/apis/base/debug.ts +5 -0
- package/dist/runtime/apis/base/index.ts +13 -0
- package/dist/runtime/apis/base/performance.ts +8 -0
- package/dist/runtime/apis/base/system.ts +181 -0
- package/dist/runtime/apis/base/update.ts +5 -0
- package/dist/runtime/apis/base/weapp/app-event.ts +75 -0
- package/dist/runtime/apis/base/weapp/life-cycle.ts +21 -0
- package/dist/runtime/apis/canvas/index.ts +27 -0
- package/dist/runtime/apis/data-analysis/index.ts +6 -0
- package/dist/runtime/apis/device/accelerometer.ts +79 -0
- package/dist/runtime/apis/device/accessibility.ts +4 -0
- package/dist/runtime/apis/device/battery.ts +24 -0
- package/dist/runtime/apis/device/bluetooth-ble.ts +19 -0
- package/dist/runtime/apis/device/bluetooth-peripheral.ts +6 -0
- package/dist/runtime/apis/device/bluetooth.ts +16 -0
- package/dist/runtime/apis/device/calendar.ts +5 -0
- package/dist/runtime/apis/device/clipboard.ts +85 -0
- package/dist/runtime/apis/device/compass.ts +21 -0
- package/dist/runtime/apis/device/contact.ts +5 -0
- package/dist/runtime/apis/device/crypto.ts +4 -0
- package/dist/runtime/apis/device/gyroscope.ts +77 -0
- package/dist/runtime/apis/device/iBeacon.ts +10 -0
- package/dist/runtime/apis/device/index.ts +24 -0
- package/dist/runtime/apis/device/keyboard.ts +63 -0
- package/dist/runtime/apis/device/memory.ts +11 -0
- package/dist/runtime/apis/device/motion.ts +6 -0
- package/dist/runtime/apis/device/network.ts +123 -0
- package/dist/runtime/apis/device/nfc.ts +10 -0
- package/dist/runtime/apis/device/phone.ts +44 -0
- package/dist/runtime/apis/device/scan.ts +4 -0
- package/dist/runtime/apis/device/screen.ts +80 -0
- package/dist/runtime/apis/device/sms.ts +4 -0
- package/dist/runtime/apis/device/vibrate.ts +32 -0
- package/dist/runtime/apis/device/wifi.ts +15 -0
- package/dist/runtime/apis/ext/index.ts +5 -0
- package/dist/runtime/apis/files/index.ts +136 -0
- package/dist/runtime/apis/files/manager.ts +942 -0
- package/dist/runtime/apis/framework/index.ts +48 -0
- package/dist/runtime/apis/harmony/task-pool.ts +39 -0
- package/dist/runtime/apis/index.ts +61 -0
- package/dist/runtime/apis/location/index.ts +133 -0
- package/dist/runtime/apis/media/EditorContext.ts +32 -0
- package/dist/runtime/apis/media/audio/index.ts +36 -0
- package/dist/runtime/apis/media/background-audio/index.ts +16 -0
- package/dist/runtime/apis/media/camera.ts +16 -0
- package/dist/runtime/apis/media/common.ts +58 -0
- package/dist/runtime/apis/media/image/index.ts +291 -0
- package/dist/runtime/apis/media/index.ts +13 -0
- package/dist/runtime/apis/media/live.ts +5 -0
- package/dist/runtime/apis/media/map.ts +4 -0
- package/dist/runtime/apis/media/media-recorder.ts +4 -0
- package/dist/runtime/apis/media/recorder.ts +6 -0
- package/dist/runtime/apis/media/video/VideoContext.ts +67 -0
- package/dist/runtime/apis/media/video/index.ts +45 -0
- package/dist/runtime/apis/media/video-decoder.ts +4 -0
- package/dist/runtime/apis/media/video-processing.ts +4 -0
- package/dist/runtime/apis/media/voip.ts +19 -0
- package/dist/runtime/apis/navigate/index.ts +8 -0
- package/dist/runtime/apis/network/downloadFile.ts +85 -0
- package/dist/runtime/apis/network/index.ts +7 -0
- package/dist/runtime/apis/network/mdns.ts +13 -0
- package/dist/runtime/apis/network/request.ts +140 -0
- package/dist/runtime/apis/network/tcp.ts +4 -0
- package/dist/runtime/apis/network/udp.ts +4 -0
- package/dist/runtime/apis/network/uploadFile.ts +105 -0
- package/dist/runtime/apis/network/webSocket.ts +126 -0
- package/dist/runtime/apis/open-api/account.ts +4 -0
- package/dist/runtime/apis/open-api/address.ts +4 -0
- package/dist/runtime/apis/open-api/authorize.ts +5 -0
- package/dist/runtime/apis/open-api/card.ts +5 -0
- package/dist/runtime/apis/open-api/channels-live.ts +11 -0
- package/dist/runtime/apis/open-api/customer-service.ts +4 -0
- package/dist/runtime/apis/open-api/device-voip.ts +5 -0
- package/dist/runtime/apis/open-api/facial.ts +7 -0
- package/dist/runtime/apis/open-api/favorites.ts +5 -0
- package/dist/runtime/apis/open-api/group.ts +4 -0
- package/dist/runtime/apis/open-api/index.ts +21 -0
- package/dist/runtime/apis/open-api/invoice.ts +5 -0
- package/dist/runtime/apis/open-api/license-plate.ts +4 -0
- package/dist/runtime/apis/open-api/login.ts +6 -0
- package/dist/runtime/apis/open-api/my-miniprogram.ts +4 -0
- package/dist/runtime/apis/open-api/privacy.ts +7 -0
- package/dist/runtime/apis/open-api/red-package.ts +4 -0
- package/dist/runtime/apis/open-api/settings.ts +5 -0
- package/dist/runtime/apis/open-api/soter.ts +6 -0
- package/dist/runtime/apis/open-api/subscribe-message.ts +6 -0
- package/dist/runtime/apis/open-api/user-info.ts +70 -0
- package/dist/runtime/apis/open-api/werun.ts +5 -0
- package/dist/runtime/apis/payment/index.ts +6 -0
- package/dist/runtime/apis/route/index.ts +88 -0
- package/dist/runtime/apis/share/index.ts +33 -0
- package/dist/runtime/apis/storage/background-fetch.ts +7 -0
- package/dist/runtime/apis/storage/cache-manager.ts +4 -0
- package/dist/runtime/apis/storage/index.ts +203 -0
- package/dist/runtime/apis/ui/animation/animation.ts +264 -0
- package/dist/runtime/apis/ui/animation/index.ts +7 -0
- package/dist/runtime/apis/ui/background.ts +20 -0
- package/dist/runtime/apis/ui/custom-component.ts +1 -0
- package/dist/runtime/apis/ui/fonts.ts +4 -0
- package/dist/runtime/apis/ui/index.ts +12 -0
- package/dist/runtime/apis/ui/interaction/index.ts +198 -0
- package/dist/runtime/apis/ui/menu.ts +4 -0
- package/dist/runtime/apis/ui/navigation-bar/index.ts +72 -0
- package/dist/runtime/apis/ui/pull-down-refresh.ts +47 -0
- package/dist/runtime/apis/ui/scroll/index.ts +82 -0
- package/dist/runtime/apis/ui/sticky.ts +4 -0
- package/dist/runtime/apis/ui/tab-bar.ts +144 -0
- package/dist/runtime/apis/ui/window.ts +20 -0
- package/dist/runtime/apis/utils/constant.ts +1 -0
- package/dist/runtime/apis/utils/handler.ts +117 -0
- package/dist/runtime/apis/utils/index.ts +105 -0
- package/dist/runtime/apis/utils/permissions.ts +6 -0
- package/dist/runtime/apis/utils/types.ts +12 -0
- package/dist/runtime/apis/utils/unit.ts +104 -0
- package/dist/runtime/apis/utils/validate.ts +87 -0
- package/dist/runtime/apis/worker/index.ts +4 -0
- package/dist/runtime/apis/wxml/index.ts +17 -0
- package/dist/runtime/apis/wxml/intersectionObserver.ts +100 -0
- package/dist/runtime/apis/wxml/nodesRef.ts +58 -0
- package/dist/runtime/apis/wxml/selectorQuery.ts +221 -0
- package/dist/runtime/apischunk/index.d.ts +802 -0
- package/dist/runtime/apischunk/index.js +5054 -0
- package/dist/runtime/components/deprecated.ets +43 -0
- package/dist/runtime/components/index.ets +49 -0
- package/dist/runtime/components/innerHtml.ets +16 -0
- package/dist/runtime/components/navigationBar.ets +65 -0
- package/dist/runtime/components/pageMeta.ets +94 -0
- package/dist/runtime/components/richText.ets +24 -0
- package/dist/runtime/components/slider.ets +119 -0
- package/dist/runtime/components/style.ets +286 -0
- package/dist/runtime/components/switch.ets +73 -0
- package/dist/runtime/components/tag.ts +58 -0
- package/dist/runtime/components/utils/AttributeManager.ets +252 -0
- package/dist/runtime/components/utils/DynamicCenter.ts +41 -0
- package/dist/runtime/components/utils/constant/event.ets +25 -0
- package/dist/runtime/components/utils/constant/style.ets +91 -0
- package/dist/runtime/components/utils/events.ts +26 -0
- package/dist/runtime/components/utils/flexManager.ets +49 -0
- package/dist/runtime/components/utils/helper.ets +51 -0
- package/dist/runtime/components/utils/htmlParser/HarmonyHTMLParser.ts +100 -0
- package/dist/runtime/components/utils/htmlParser/index.ts +58 -0
- package/dist/runtime/components/utils/index.ts +77 -0
- package/dist/runtime/components/utils/styles.ets +41 -0
- package/dist/runtime/components/video.ets +119 -0
- package/dist/runtime/components/webView.ets +55 -0
- package/dist/runtime/components/xComponent.ets +89 -0
- package/dist/runtime/framework/app.ts +248 -0
- package/dist/runtime/framework/connect.ts +24 -0
- package/dist/runtime/framework/constant.ts +3 -0
- package/dist/runtime/framework/hooks.ts +99 -0
- package/dist/runtime/framework/index.ts +15 -0
- package/dist/runtime/framework/native-page.ts +511 -0
- package/dist/runtime/framework/page.ts +256 -0
- package/dist/runtime/framework/utils/index.ts +17 -0
- package/dist/runtime/framework/utils/is.ts +26 -0
- package/dist/runtime/framework-reconciler/componentTree.ts +81 -0
- package/dist/runtime/framework-reconciler/constant.ts +86 -0
- package/dist/runtime/framework-reconciler/domInput.ts +90 -0
- package/dist/runtime/framework-reconciler/event.ts +108 -0
- package/dist/runtime/framework-reconciler/index.ts +99 -0
- package/dist/runtime/framework-reconciler/inputValueTracking.ts +106 -0
- package/dist/runtime/framework-reconciler/props.ts +132 -0
- package/dist/runtime/framework-reconciler/reconciler.ts +202 -0
- package/dist/runtime/framework-reconciler/render.ts +139 -0
- package/dist/runtime/framework-reconciler/workTags.ts +53 -0
- package/dist/runtime/runtime-cpp/bom/URL.ts +2 -0
- package/dist/runtime/runtime-cpp/bom/document.ts +45 -0
- package/dist/runtime/runtime-cpp/bom/history.ts +1 -0
- package/dist/runtime/runtime-cpp/bom/location.ts +1 -0
- package/dist/runtime/runtime-cpp/bom/navigator.ts +1 -0
- package/dist/runtime/runtime-cpp/bom/raf.ts +1 -0
- package/dist/runtime/runtime-cpp/bom/window.ts +57 -0
- package/dist/runtime/runtime-cpp/constant.ts +29 -0
- package/dist/runtime/runtime-cpp/current.ts +48 -0
- package/dist/runtime/runtime-cpp/dom/class-list.ts +41 -0
- package/dist/runtime/runtime-cpp/dom/comment.ts +9 -0
- package/dist/runtime/runtime-cpp/dom/dataSource.ts +87 -0
- package/dist/runtime/runtime-cpp/dom/document.ts +113 -0
- package/dist/runtime/runtime-cpp/dom/element/canvas.ts +285 -0
- package/dist/runtime/runtime-cpp/dom/element/element.ts +262 -0
- package/dist/runtime/runtime-cpp/dom/element/form.ts +371 -0
- package/dist/runtime/runtime-cpp/dom/element/index.ts +129 -0
- package/dist/runtime/runtime-cpp/dom/element/movable.ts +250 -0
- package/dist/runtime/runtime-cpp/dom/element/normal.ts +123 -0
- package/dist/runtime/runtime-cpp/dom/element/scroll_view.ts +32 -0
- package/dist/runtime/runtime-cpp/dom/element/text.ts +9 -0
- package/dist/runtime/runtime-cpp/dom/element/video.ts +66 -0
- package/dist/runtime/runtime-cpp/dom/element/web_view.ts +72 -0
- package/dist/runtime/runtime-cpp/dom/event-source.ts +1 -0
- package/dist/runtime/runtime-cpp/dom/event.ts +187 -0
- package/dist/runtime/runtime-cpp/dom/eventTarget.ts +81 -0
- package/dist/runtime/runtime-cpp/dom/node.ts +307 -0
- package/dist/runtime/runtime-cpp/dom/style.ts +44 -0
- package/dist/runtime/runtime-cpp/dom/stylesheet/index.ts +379 -0
- package/dist/runtime/runtime-cpp/dom/stylesheet/type.ts +212 -0
- package/dist/runtime/runtime-cpp/dom/stylesheet/util.ts +186 -0
- package/dist/runtime/runtime-cpp/emitter/emitter.ts +29 -0
- package/dist/runtime/runtime-cpp/env.ts +1 -0
- package/dist/runtime/runtime-cpp/harmony-library.ts +1 -0
- package/dist/runtime/runtime-cpp/index.ts +79 -0
- package/dist/runtime/runtime-cpp/interface/event.ts +10 -0
- package/dist/runtime/runtime-cpp/interface/index.ts +7 -0
- package/dist/runtime/runtime-cpp/next-tick.ts +14 -0
- package/dist/runtime/runtime-cpp/system.ts +213 -0
- package/dist/runtime/runtime-cpp/utils/index.ts +63 -0
- package/dist/runtime/runtime-cpp/utils/info.ts +123 -0
- package/dist/runtime/runtime-cpp/utils/page.ts +12 -0
- package/dist/runtime/runtime-cpp/utils/router.ts +1 -0
- package/dist/runtime/runtime-harmony/apis/helper.ets +33 -0
- package/dist/runtime/runtime-harmony/apis/network/common.ets +41 -0
- package/dist/runtime/runtime-harmony/apis/network/downloadFile.ets +327 -0
- package/dist/runtime/runtime-harmony/apis/network/index.ets +58 -0
- package/dist/runtime/runtime-harmony/apis/network/request.ets +206 -0
- package/dist/runtime/runtime-harmony/apis/network/uploadFile.ets +190 -0
- package/dist/runtime/runtime-harmony/apis/route.ets +110 -0
- package/dist/runtime/runtime-harmony/apis/taskpool.ets +149 -0
- package/dist/runtime/runtime-harmony/index.ets +41 -0
- package/dist/runtime/runtime-harmony/utils.ts +53 -0
- package/package.json +24 -23
- package/LICENSE +0 -174
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
import { TaroElement } from './element'
|
|
2
|
+
|
|
3
|
+
import type { MovableAreaProps, MovableViewProps } from '@tarojs/components/types'
|
|
4
|
+
import type { TaroAny, TFunc } from '../../interface'
|
|
5
|
+
|
|
6
|
+
type Tsize = {
|
|
7
|
+
w: number
|
|
8
|
+
h: number
|
|
9
|
+
}
|
|
10
|
+
type Tpoint = {
|
|
11
|
+
x: number
|
|
12
|
+
y: number
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function calcPosition(postion: number, start: number, end: number) {
|
|
16
|
+
if (postion <= end && postion >= start) {
|
|
17
|
+
return postion
|
|
18
|
+
} else if (postion < start) {
|
|
19
|
+
return start
|
|
20
|
+
} else {
|
|
21
|
+
return end
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function isTaroMovableViewElement (item: TaroAny): item is TaroMovableViewElement {
|
|
26
|
+
return item instanceof TaroMovableViewElement
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class TaroMovableViewElement extends TaroElement<MovableViewProps & { animation: undefined }> {
|
|
30
|
+
_scaleValue = 1
|
|
31
|
+
_scalevalueTemp = 1
|
|
32
|
+
|
|
33
|
+
// 父级区别的大小
|
|
34
|
+
_area?: Tsize
|
|
35
|
+
// 自己元素的大小
|
|
36
|
+
_selfSize?: Tsize
|
|
37
|
+
_areaInited: boolean
|
|
38
|
+
_selfSizeInited: boolean
|
|
39
|
+
|
|
40
|
+
// 元素的位置
|
|
41
|
+
_position: Tpoint = {
|
|
42
|
+
x: 0,
|
|
43
|
+
y: 0,
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
_positionTemp: Tpoint = {
|
|
47
|
+
x: 0,
|
|
48
|
+
y: 0,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
constructor() {
|
|
52
|
+
super('MovableView')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
get _outOfBounds() {
|
|
56
|
+
if (this.getAttribute('outOfBounds')) {
|
|
57
|
+
return this.selfSize ? this.selfSize.w / 3 : 0
|
|
58
|
+
}
|
|
59
|
+
return 0
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
startScale() {
|
|
63
|
+
this._scalevalueTemp = this._scaleValue
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
doScale(val: number) {
|
|
67
|
+
const scale = this.getAttribute('scale')
|
|
68
|
+
|
|
69
|
+
// 禁止缩放的时候不生效
|
|
70
|
+
if (scale) {
|
|
71
|
+
this.scaleValue = val * this._scalevalueTemp
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
set scaleValue(val: number) {
|
|
76
|
+
if (this.checkScaleValueInBounds(val)) {
|
|
77
|
+
this._scaleValue = val
|
|
78
|
+
|
|
79
|
+
this.checkPositionBoundary(this.position, val)
|
|
80
|
+
|
|
81
|
+
const scaleFns = this?.__listeners?.scale || []
|
|
82
|
+
scaleFns.forEach((fn) => {
|
|
83
|
+
fn({ ...this.position, scale: this.scaleValue })
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
get scaleValue () {
|
|
89
|
+
return this._scaleValue
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
get visibility () {
|
|
93
|
+
return this._areaInited && this._selfSizeInited ? Visibility.Visible : Visibility.Hidden
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
startMove() {
|
|
97
|
+
this._positionTemp = this._position
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
doMove(val: Tpoint) {
|
|
101
|
+
if (!this.area || !this.selfSize) {
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
if (this.getAttribute('disabled')) {
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
const direction = this.getAttribute('direction')
|
|
108
|
+
|
|
109
|
+
// 容器的宽高终点
|
|
110
|
+
const areaWidthEnd = this.area.w - this.selfSize.w * this.scaleValue
|
|
111
|
+
const areaHeightEnd = this.area.h - this.selfSize.h * this.scaleValue
|
|
112
|
+
|
|
113
|
+
const incrementWidth = (this.scaleValue - 1) * this.selfSize.w
|
|
114
|
+
const incrementHeight = (this.scaleValue - 1) * this.selfSize.h
|
|
115
|
+
|
|
116
|
+
let x = this._positionTemp.x
|
|
117
|
+
let y = this._positionTemp.y
|
|
118
|
+
if (['all', 'horizontal'].includes(direction)) {
|
|
119
|
+
const nextX = this._positionTemp.x + val.x * this.scaleValue
|
|
120
|
+
x = calcPosition(
|
|
121
|
+
nextX,
|
|
122
|
+
incrementWidth * 0.5 - this._outOfBounds,
|
|
123
|
+
areaWidthEnd + incrementWidth * 0.5 + this._outOfBounds
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (['all', 'vertical'].includes(direction)) {
|
|
128
|
+
const nextY = this._positionTemp.y + val.y * this.scaleValue
|
|
129
|
+
y = calcPosition(
|
|
130
|
+
nextY,
|
|
131
|
+
incrementHeight * 0.5 - this._outOfBounds,
|
|
132
|
+
areaHeightEnd + incrementHeight * 0.5 + this._outOfBounds
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const changeFns = this?.__listeners?.change || []
|
|
137
|
+
changeFns.forEach((fn) => {
|
|
138
|
+
fn({ x, y, source: 'touch' })
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
this.position = {
|
|
142
|
+
x: x,
|
|
143
|
+
y: y,
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
get position() {
|
|
148
|
+
return this._position
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
set position(val: Tpoint) {
|
|
152
|
+
this._position = val
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
set area(val: Tsize) {
|
|
156
|
+
if (val.w === this._area?.w && val.h === this._area?.h) return
|
|
157
|
+
this._area = val
|
|
158
|
+
if (!this._areaInited) {
|
|
159
|
+
this._areaInited = true
|
|
160
|
+
this.initPositionFromAttribute()
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
get area(): Tsize | undefined {
|
|
165
|
+
return this._area
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
set selfSize(val: Tsize) {
|
|
169
|
+
if (val.w === this._selfSize?.w && val.h === this._selfSize?.h) return
|
|
170
|
+
this._selfSize = val
|
|
171
|
+
if (!this._selfSizeInited) {
|
|
172
|
+
this._selfSizeInited = true
|
|
173
|
+
this.initPositionFromAttribute()
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
get selfSize(): Tsize | undefined {
|
|
178
|
+
return this._selfSize
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
initPositionFromAttribute () {
|
|
182
|
+
if (!this.area || !this.selfSize) {
|
|
183
|
+
return
|
|
184
|
+
}
|
|
185
|
+
const x = this.getAttribute('x') ? Number(this.getAttribute('x')) : 0
|
|
186
|
+
const y = this.getAttribute('y') ? Number(this.getAttribute('y')) : 0
|
|
187
|
+
this.checkPositionBoundary({ x, y }, this.scaleValue)
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
checkPositionBoundary(position: Tpoint, scale: number) {
|
|
191
|
+
if (!this.area || !this.selfSize) {
|
|
192
|
+
return { x: 0, y: 0 }
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const areaWidthEnd = this.area.w - this.selfSize.w * scale
|
|
196
|
+
const areaHeightEnd = this.area.h - this.selfSize.h * scale
|
|
197
|
+
|
|
198
|
+
const incrementWidth = (scale - 1) * this.selfSize.w
|
|
199
|
+
const incrementHeight = (scale - 1) * this.selfSize.h
|
|
200
|
+
|
|
201
|
+
this.position = {
|
|
202
|
+
x: calcPosition(position.x, incrementWidth * 0.5, areaWidthEnd + incrementWidth * 0.5),
|
|
203
|
+
y: calcPosition(position.y, incrementHeight * 0.5, areaHeightEnd + incrementHeight * 0.5),
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
checkScaleValueInBounds(currentScale: number) {
|
|
208
|
+
const scaleMin = this.getAttribute('scaleMin')
|
|
209
|
+
const scaleMax = this.getAttribute('scaleMax')
|
|
210
|
+
|
|
211
|
+
if (scaleMin && Number(scaleMin) >= 0.1 && currentScale < Number(scaleMin)) {
|
|
212
|
+
return false
|
|
213
|
+
} else if (scaleMax && Number(scaleMax) >= 0.1 && currentScale > Number(scaleMax)) {
|
|
214
|
+
return false
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
return true
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
public setAttribute(name: string, value: any): void {
|
|
221
|
+
if (name === 'x') {
|
|
222
|
+
this.checkPositionBoundary({ x: value, y: this.position.y }, this.scaleValue)
|
|
223
|
+
}
|
|
224
|
+
if (name === 'y') {
|
|
225
|
+
this.checkPositionBoundary({ x: this.position.x, y: value }, this.scaleValue)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
super.setAttribute(name, value)
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
public callTouchEventFnFromGesture(eventName: string, gestureEvent: GestureEvent) {
|
|
232
|
+
const touchFns = (this?.__listeners?.[eventName] || []) as TFunc[]
|
|
233
|
+
touchFns.forEach(fn => {
|
|
234
|
+
fn({
|
|
235
|
+
_hmEvent: gestureEvent,
|
|
236
|
+
target: this,
|
|
237
|
+
changedTouches: gestureEvent.fingerList.map(finger => ({
|
|
238
|
+
clientX: finger.globalX,
|
|
239
|
+
clientY: finger.globalY
|
|
240
|
+
}))
|
|
241
|
+
})
|
|
242
|
+
})
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export class TaroMovableAreaElement extends TaroElement<MovableAreaProps> {
|
|
247
|
+
constructor() {
|
|
248
|
+
super('MovableArea')
|
|
249
|
+
}
|
|
250
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { TaroElement } from './element'
|
|
2
|
+
import { TaroScrollViewElement } from './scroll_view'
|
|
3
|
+
|
|
4
|
+
import type {
|
|
5
|
+
ButtonProps,
|
|
6
|
+
IconProps,
|
|
7
|
+
ImageProps,
|
|
8
|
+
NavigationBarProps,
|
|
9
|
+
PageMetaProps,
|
|
10
|
+
ProgressProps,
|
|
11
|
+
StandardProps,
|
|
12
|
+
SwiperItemProps,
|
|
13
|
+
SwiperProps,
|
|
14
|
+
ViewProps,
|
|
15
|
+
} from '@tarojs/components/types'
|
|
16
|
+
import type { TaroAny } from '../../interface'
|
|
17
|
+
|
|
18
|
+
interface FlowSectionProps extends StandardProps {
|
|
19
|
+
column?: number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Observed
|
|
23
|
+
export class TaroOtherElement extends TaroElement<ViewProps> {
|
|
24
|
+
isETS = true
|
|
25
|
+
|
|
26
|
+
public setAttribute(name: string, value: TaroAny): void {
|
|
27
|
+
super.setAttribute(name, value)
|
|
28
|
+
|
|
29
|
+
// Note: 使用 @ComponentV2 时,需要在 struct 将参数声明为 @Local 并在此更新
|
|
30
|
+
if (this._instance) {
|
|
31
|
+
const attrName = `attr${name.charAt(0).toUpperCase()}${name.slice(1)}`
|
|
32
|
+
this._instance[attrName] = value
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export class TaroViewElement extends TaroElement<ViewProps> {
|
|
38
|
+
constructor() {
|
|
39
|
+
super('View')
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class TaroImageElement extends TaroElement<ImageProps> {
|
|
44
|
+
constructor() {
|
|
45
|
+
super('Image')
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export class TaroButtonElement extends TaroElement<ButtonProps> {
|
|
50
|
+
constructor() {
|
|
51
|
+
super('Button')
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export class TaroIconElement extends TaroElement<IconProps> {
|
|
56
|
+
constructor() {
|
|
57
|
+
super('Icon')
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export class TaroSwiperElement extends TaroElement<SwiperProps> {
|
|
62
|
+
controller: typeof SwiperController = new SwiperController()
|
|
63
|
+
|
|
64
|
+
constructor() {
|
|
65
|
+
super('Swiper')
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export class TaroSwiperItemElement extends TaroElement<SwiperItemProps> {
|
|
70
|
+
constructor() {
|
|
71
|
+
super('SwiperItem')
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export class TaroProgressElement extends TaroElement<ProgressProps> {
|
|
76
|
+
isETS = true
|
|
77
|
+
|
|
78
|
+
constructor() {
|
|
79
|
+
super('Progress')
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
@Observed
|
|
84
|
+
export class TaroPageMetaElement extends TaroElement<PageMetaProps> {
|
|
85
|
+
isETS = true
|
|
86
|
+
|
|
87
|
+
constructor() {
|
|
88
|
+
super('PageMeta')
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@Observed
|
|
93
|
+
export class TaroNavigationBarElement extends TaroElement<NavigationBarProps> {
|
|
94
|
+
isETS = true
|
|
95
|
+
|
|
96
|
+
constructor() {
|
|
97
|
+
super('NavigationBar')
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export class TaroWaterFlowElement extends TaroScrollViewElement {
|
|
102
|
+
constructor() {
|
|
103
|
+
super('WaterFlow')
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export class TaroListElement extends TaroScrollViewElement {
|
|
108
|
+
constructor() {
|
|
109
|
+
super('List')
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export class TaroFlowSectionElement extends TaroElement<FlowSectionProps> {
|
|
114
|
+
constructor() {
|
|
115
|
+
super('FlowSection')
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export class TaroFlowItemElement extends TaroElement {
|
|
120
|
+
constructor() {
|
|
121
|
+
super('FlowItem')
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { TaroNativeModule } from '../../harmony-library'
|
|
2
|
+
import { TaroElement } from './element'
|
|
3
|
+
|
|
4
|
+
import type { ScrollViewProps } from '@tarojs/components/types'
|
|
5
|
+
|
|
6
|
+
export class TaroScrollViewElement extends TaroElement<ScrollViewProps> {
|
|
7
|
+
constructor(tagName = 'ScrollView') {
|
|
8
|
+
super(tagName)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
get scrollTop() {
|
|
12
|
+
return TaroNativeModule.getCurrentOffset(this)?.yOffset
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
set scrollTop(value: number) {
|
|
16
|
+
TaroNativeModule.scrollTo(this, {
|
|
17
|
+
yOffset: value,
|
|
18
|
+
duration: 0
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get scrollLeft() {
|
|
23
|
+
return TaroNativeModule.getCurrentOffset(this)?.xOffset
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
set scrollLeft(value: number) {
|
|
27
|
+
TaroNativeModule.scrollTo(this, {
|
|
28
|
+
xOffset: value,
|
|
29
|
+
duration: 0
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { TaroElement } from './element'
|
|
2
|
+
|
|
3
|
+
import type { VideoProps } from '@tarojs/components/types'
|
|
4
|
+
import type { TaroAny } from '../../interface'
|
|
5
|
+
|
|
6
|
+
export class TaroVideoElement extends TaroElement<VideoProps> {
|
|
7
|
+
controller: VideoController
|
|
8
|
+
|
|
9
|
+
isETS = true
|
|
10
|
+
|
|
11
|
+
constructor() {
|
|
12
|
+
super('Video')
|
|
13
|
+
|
|
14
|
+
this._nodeInfo._currentTime = 0
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public setAttribute(name: string, value: TaroAny): void {
|
|
18
|
+
super.setAttribute(name, value)
|
|
19
|
+
|
|
20
|
+
// Note: 使用 @ComponentV2 时,需要在 struct 将参数声明为 @Local 并在此更新
|
|
21
|
+
if (this._instance) {
|
|
22
|
+
const attrName = `attr${name.charAt(0).toUpperCase()}${name.slice(1)}`
|
|
23
|
+
this._instance[attrName] = value
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async play() {
|
|
28
|
+
try {
|
|
29
|
+
this.controller.start()
|
|
30
|
+
return Promise.resolve()
|
|
31
|
+
} catch (e) {
|
|
32
|
+
return Promise.reject(e)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
pause() {
|
|
37
|
+
try {
|
|
38
|
+
this.controller.pause()
|
|
39
|
+
return Promise.resolve()
|
|
40
|
+
} catch (e) {
|
|
41
|
+
return Promise.reject(e)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
stop() {
|
|
46
|
+
try {
|
|
47
|
+
this.controller.stop()
|
|
48
|
+
return Promise.resolve()
|
|
49
|
+
} catch (e) {
|
|
50
|
+
return Promise.reject(e)
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get currentTime() {
|
|
55
|
+
return this._nodeInfo._currentTime
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
set currentTime(val: number) {
|
|
59
|
+
this._nodeInfo._currentTime = val
|
|
60
|
+
this.controller.setCurrentTime(val)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
dispose () {
|
|
64
|
+
this.controller = null
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import business_error from '@ohos.base'
|
|
2
|
+
import web_webview from '@ohos.web.webview'
|
|
3
|
+
|
|
4
|
+
import { TaroElement } from './element'
|
|
5
|
+
|
|
6
|
+
import type { WebViewProps } from '@tarojs/components/types'
|
|
7
|
+
|
|
8
|
+
@Observed
|
|
9
|
+
export class TaroInnerHtmlElement extends TaroElement {
|
|
10
|
+
isETS = true
|
|
11
|
+
|
|
12
|
+
constructor() {
|
|
13
|
+
super('InnerHtml')
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@Observed
|
|
18
|
+
export class TaroWebViewElement extends TaroElement<WebViewProps> {
|
|
19
|
+
ports: web_webview.WebMessagePort[] = []
|
|
20
|
+
|
|
21
|
+
nativePort: web_webview.WebMessagePort | null = null
|
|
22
|
+
|
|
23
|
+
message: web_webview.WebMessageExt = new web_webview.WebMessageExt()
|
|
24
|
+
|
|
25
|
+
controller: web_webview.WebviewController = new web_webview.WebviewController()
|
|
26
|
+
|
|
27
|
+
isETS = true
|
|
28
|
+
|
|
29
|
+
constructor() {
|
|
30
|
+
super('WebView')
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
postMessage (value: string) {
|
|
34
|
+
if (!this.nativePort) return
|
|
35
|
+
|
|
36
|
+
this.message.setString(value)
|
|
37
|
+
this.nativePort.postMessageEventExt(this.message)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
handleMessageFromWeb (result: web_webview.WebMessageExt) {
|
|
41
|
+
try {
|
|
42
|
+
const type = result.getType()
|
|
43
|
+
switch (type) {
|
|
44
|
+
case web_webview.WebMessageType.STRING: {
|
|
45
|
+
return result.getString()
|
|
46
|
+
}
|
|
47
|
+
case web_webview.WebMessageType.NUMBER: {
|
|
48
|
+
return result.getNumber()
|
|
49
|
+
}
|
|
50
|
+
case web_webview.WebMessageType.BOOLEAN: {
|
|
51
|
+
return result.getBoolean()
|
|
52
|
+
}
|
|
53
|
+
case web_webview.WebMessageType.ARRAY_BUFFER: {
|
|
54
|
+
return result.getArrayBuffer()
|
|
55
|
+
}
|
|
56
|
+
case web_webview.WebMessageType.ARRAY: {
|
|
57
|
+
return result.getArray()
|
|
58
|
+
}
|
|
59
|
+
case web_webview.WebMessageType.ERROR: {
|
|
60
|
+
return result.getError()
|
|
61
|
+
}
|
|
62
|
+
default: {
|
|
63
|
+
return null
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} catch (error) {
|
|
67
|
+
const e: business_error.BusinessError = error as business_error.BusinessError
|
|
68
|
+
|
|
69
|
+
console.error(`ErrorCode: ${e.code}, Message: ${e.message}`)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { eventSource } from '@tarojs/runtime/dist/runtime.esm'
|