@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-alpha.10
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 +74 -21
- 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 +27 -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 +17 -9
- 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/memory.ts +10 -3
- 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 +3 -8
- package/dist/apis/index.ts +27 -17
- 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} +4 -3
- 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 +68 -0
- package/dist/apis/media/{video.ts → video/index.ts} +13 -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 +7 -6
- 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 +19 -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 +158 -88
- package/dist/apis/ui/{animation.ts → animation/animation.ts} +73 -31
- package/dist/apis/ui/animation/index.ts +7 -0
- package/dist/apis/ui/background.ts +4 -19
- 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 +45 -59
- 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 +10 -4
- package/dist/apis/{page → ui/scroll}/index.ts +32 -27
- package/dist/apis/ui/sticky.ts +4 -0
- package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +6 -8
- package/dist/apis/ui/window.ts +20 -0
- package/dist/apis/utils/handler.ts +4 -4
- package/dist/apis/utils/index.ts +1 -1
- package/dist/apis/worker/index.ts +4 -0
- package/dist/apis/wxml/IntersectionObserver.ts +24 -25
- package/dist/apis/wxml/index.ts +7 -2
- package/dist/apis/wxml/nodesRef.ts +2 -2
- package/dist/apis/wxml/selectorQuery.ts +29 -17
- package/dist/components-harmony-ets/button.ets +106 -80
- package/dist/components-harmony-ets/canvas.ets +51 -0
- package/dist/components-harmony-ets/checkbox.ets +82 -148
- package/dist/components-harmony-ets/form.ets +45 -132
- package/dist/components-harmony-ets/icon.ets +66 -69
- package/dist/components-harmony-ets/image.ets +26 -61
- package/dist/components-harmony-ets/index.ets +92 -0
- package/dist/components-harmony-ets/innerHtml.ets +7 -70
- package/dist/components-harmony-ets/input.ets +60 -146
- package/dist/components-harmony-ets/label.ets +86 -92
- package/dist/components-harmony-ets/listView.ets +26 -0
- package/dist/components-harmony-ets/movableArea.ets +124 -0
- package/dist/components-harmony-ets/movableView.ets +93 -0
- package/dist/components-harmony-ets/navigationBar.ets +65 -0
- package/dist/components-harmony-ets/pageMeta.ets +94 -0
- package/dist/components-harmony-ets/picker.ets +172 -198
- package/dist/components-harmony-ets/progress.ets +52 -0
- package/dist/components-harmony-ets/pseudo.ets +80 -0
- package/dist/components-harmony-ets/radio.ets +85 -155
- package/dist/components-harmony-ets/richText.ets +15 -87
- package/dist/components-harmony-ets/scrollList.ets +94 -0
- package/dist/components-harmony-ets/scrollView.ets +81 -149
- package/dist/components-harmony-ets/slider.ets +47 -94
- package/dist/components-harmony-ets/stickySection.ets +42 -0
- package/dist/components-harmony-ets/style.ets +396 -0
- package/dist/components-harmony-ets/swiper.ets +51 -151
- package/dist/components-harmony-ets/switch.ets +35 -76
- package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
- package/dist/components-harmony-ets/text.ets +131 -76
- package/dist/components-harmony-ets/textArea.ets +64 -140
- package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
- package/dist/components-harmony-ets/utils/DynamicCenter.ts +4 -13
- package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
- package/dist/components-harmony-ets/utils/flexManager.ets +68 -85
- package/dist/components-harmony-ets/utils/helper.ets +18 -65
- package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
- package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
- package/dist/components-harmony-ets/utils/index.ts +55 -51
- package/dist/components-harmony-ets/utils/styles.ets +177 -65
- package/dist/components-harmony-ets/video.ets +70 -116
- package/dist/components-harmony-ets/view.ets +58 -64
- package/dist/components-harmony-ets/webView.ets +56 -0
- package/dist/index.d.ts +152 -0
- package/dist/index.js +230 -60
- package/dist/index.js.map +1 -1
- package/dist/runtime-ets/bom/document.ts +6 -4
- package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
- package/dist/runtime-ets/bom/window.ts +9 -2
- package/dist/runtime-ets/current.ts +3 -0
- package/dist/runtime-ets/dom/bind.ts +96 -0
- package/dist/runtime-ets/dom/class-list.ts +4 -6
- package/dist/runtime-ets/dom/comment.ts +1 -2
- package/dist/runtime-ets/dom/cssNesting.ts +409 -0
- package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -20
- package/dist/runtime-ets/dom/dataSource.ts +64 -0
- package/dist/runtime-ets/dom/document.ts +36 -51
- package/dist/runtime-ets/dom/element/canvas.ts +136 -0
- package/dist/runtime-ets/dom/element/element.ts +439 -0
- package/dist/runtime-ets/dom/element/form.ts +403 -0
- package/dist/runtime-ets/dom/element/index.ts +120 -0
- package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
- package/dist/runtime-ets/dom/element/movableView.ts +242 -0
- package/dist/runtime-ets/dom/element/normal.ts +103 -0
- package/dist/runtime-ets/dom/element/progress.ts +11 -0
- package/dist/runtime-ets/dom/element/scrollView.ts +15 -0
- package/dist/runtime-ets/dom/element/text.ts +10 -0
- package/dist/runtime-ets/dom/element/video.ts +50 -0
- package/dist/runtime-ets/dom/element/webView.ts +68 -0
- package/dist/runtime-ets/dom/event.ts +26 -5
- package/dist/runtime-ets/dom/eventTarget.ts +3 -3
- package/dist/runtime-ets/dom/node.ts +114 -49
- package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +805 -0
- package/dist/runtime-ets/dom/stylesheet/index.ts +122 -429
- package/dist/runtime-ets/dom/stylesheet/type.ts +93 -17
- package/dist/runtime-ets/dom/stylesheet/util.ts +145 -17
- package/dist/runtime-ets/index.ts +2 -3
- package/dist/runtime-ets/interface/event.ts +3 -2
- package/dist/runtime-ets/utils/index.ts +87 -17
- package/dist/runtime-ets/utils/info.ts +21 -47
- package/dist/runtime-framework/react/app.ts +20 -28
- package/dist/runtime-framework/react/hooks.ts +3 -4
- package/dist/runtime-framework/react/index.ts +1 -2
- package/dist/runtime-framework/react/native-page.ts +421 -0
- package/dist/runtime-framework/react/page.ts +5 -17
- package/dist/runtime-framework/solid/app.ts +25 -45
- package/dist/runtime-framework/solid/connect.ts +21 -3
- package/dist/runtime-framework/solid/hooks.ts +17 -12
- package/dist/runtime-framework/solid/index.ts +6 -2
- package/dist/runtime-framework/solid/page.ts +84 -36
- package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
- package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
- package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
- package/dist/runtime-framework/solid/utils/index.ts +0 -2
- package/dist/runtime-utils.d.ts +827 -0
- package/dist/runtime-utils.js +1633 -549
- package/dist/runtime-utils.js.map +1 -1
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +1633 -549
- package/dist/runtime.js.map +1 -1
- package/index.js +3 -1
- package/package.json +14 -15
- package/static/media/cancel.svg +1 -0
- package/static/media/circle.svg +1 -0
- package/static/media/clear.svg +1 -0
- package/static/media/download.svg +1 -0
- package/static/media/info.svg +1 -0
- package/static/media/info_circle.svg +1 -0
- package/static/media/search.svg +1 -0
- package/static/media/success.svg +1 -0
- package/static/media/success_no_circle.svg +1 -0
- package/static/media/taro_arrow_left.svg +1 -0
- package/static/media/taro_home.svg +1 -0
- package/static/media/waiting.svg +1 -0
- package/static/media/warn.svg +1 -0
- package/types/harmony.d.ts +4 -0
- package/types/index.d.ts +4 -0
- package/types/runtime.d.ts +7 -1
- 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/dist/runtime-ets/utils/bind.ts +0 -35
- package/types/api.d.ts +0 -4
- /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
|
@@ -2,11 +2,10 @@ import { eventSource } from '@tarojs/runtime/dist/runtime.esm'
|
|
|
2
2
|
import { isUndefined } from '@tarojs/shared'
|
|
3
3
|
|
|
4
4
|
import { Current } from '../current'
|
|
5
|
+
import { findChildNodeWithDFS, getPageScrollerOrNode } from '../utils'
|
|
5
6
|
import { TaroComment } from './comment'
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { NodeType, TaroNode } from './node'
|
|
9
|
-
import { TaroTextNode } from './text'
|
|
7
|
+
import { TaroElement } from './element/element'
|
|
8
|
+
import { NodeType, TaroNode, TaroTextNode } from './node'
|
|
10
9
|
|
|
11
10
|
import type { Window } from '../bom/window'
|
|
12
11
|
|
|
@@ -29,61 +28,31 @@ class TaroDocument extends TaroNode {
|
|
|
29
28
|
|
|
30
29
|
public createElement (tagName: string): TaroElement {
|
|
31
30
|
let node: TaroElement
|
|
32
|
-
|
|
31
|
+
// TODO: 仍需补充更多节点解析和它默认样式行为的转换,比如h1\h2
|
|
32
|
+
switch (tagName) {
|
|
33
|
+
case 'root': tagName = 'view'; break
|
|
34
|
+
case 'img': tagName = 'image'; break
|
|
35
|
+
case 'div': tagName = 'view'; break
|
|
36
|
+
case 'p': tagName = 'text'; break
|
|
37
|
+
case 'span': tagName = 'text'; break
|
|
38
|
+
case 'a': tagName = 'text'; break
|
|
39
|
+
}
|
|
33
40
|
// @ts-ignore
|
|
34
41
|
if (Current?.createHarmonyElement) {
|
|
35
42
|
// @ts-ignore
|
|
36
43
|
node = Current.createHarmonyElement(tagName)
|
|
37
44
|
} else {
|
|
38
|
-
|
|
39
|
-
case 'view':
|
|
40
|
-
node = new TaroViewElement()
|
|
41
|
-
break
|
|
42
|
-
case 'text':
|
|
43
|
-
node = new TaroTextElement()
|
|
44
|
-
break
|
|
45
|
-
case 'image':
|
|
46
|
-
node = new TaroImageElement()
|
|
47
|
-
break
|
|
48
|
-
case 'button':
|
|
49
|
-
node = new TaroButtonElement()
|
|
50
|
-
break
|
|
51
|
-
case 'video':
|
|
52
|
-
node = new TaroVideoElement()
|
|
53
|
-
break
|
|
54
|
-
case 'input':
|
|
55
|
-
node = new TaroInputElement()
|
|
56
|
-
break
|
|
57
|
-
case 'switch':
|
|
58
|
-
node = new TaroSwitchElement()
|
|
59
|
-
break
|
|
60
|
-
case 'slider':
|
|
61
|
-
node = new TaroSliderElement()
|
|
62
|
-
break
|
|
63
|
-
case 'checkbox-group':
|
|
64
|
-
node = new TaroCheckboxGroupElement()
|
|
65
|
-
break
|
|
66
|
-
case 'radio-group':
|
|
67
|
-
node = new TaroRadioGroupElement()
|
|
68
|
-
break
|
|
69
|
-
case 'picker':
|
|
70
|
-
node = new TaroPickerElement()
|
|
71
|
-
break
|
|
72
|
-
case 'ignore':
|
|
73
|
-
node = new TaroIgnoreElement()
|
|
74
|
-
break
|
|
75
|
-
default:
|
|
76
|
-
node = new TaroElement(tagName)
|
|
77
|
-
}
|
|
45
|
+
node = new TaroElement(tagName)
|
|
78
46
|
}
|
|
79
47
|
node._doc = this
|
|
80
|
-
// Hack: 此 Proxy 不能放在 Element 类内定义,否则响应式更新会失效
|
|
81
|
-
node._style = createCSSStyleDeclaration(node)
|
|
82
48
|
return node
|
|
83
49
|
}
|
|
84
50
|
|
|
85
51
|
public createTextNode (value: string): TaroTextNode {
|
|
86
|
-
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
if (!Current?.createTextNode) return
|
|
54
|
+
|
|
55
|
+
const node = Current.createTextNode(value)
|
|
87
56
|
node._doc = this
|
|
88
57
|
return node
|
|
89
58
|
}
|
|
@@ -92,16 +61,32 @@ class TaroDocument extends TaroNode {
|
|
|
92
61
|
return new TaroComment(data)
|
|
93
62
|
}
|
|
94
63
|
|
|
95
|
-
|
|
96
64
|
public getElementById<T extends TaroElement> (id: string | undefined | null): T | null {
|
|
97
65
|
const el = eventSource.get(id)
|
|
98
66
|
return isUndefined(el) ? null : el as unknown as T
|
|
99
67
|
}
|
|
100
68
|
|
|
69
|
+
public querySelector (selectors: string): TaroElement | null {
|
|
70
|
+
const taro = (Current as any).taro
|
|
71
|
+
const page = taro.getCurrentInstance().page
|
|
72
|
+
const element = getPageScrollerOrNode(page?.node, page)
|
|
73
|
+
|
|
74
|
+
if (!element) return null
|
|
75
|
+
|
|
76
|
+
return findChildNodeWithDFS(element, selectors)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public querySelectorAll (selectors: string): TaroElement[] {
|
|
80
|
+
const taro = (Current as any).taro
|
|
81
|
+
const page = taro.getCurrentInstance().page
|
|
82
|
+
const element = getPageScrollerOrNode(page?.node, page)
|
|
83
|
+
|
|
84
|
+
if (element == null) return []
|
|
85
|
+
|
|
86
|
+
return findChildNodeWithDFS(element, selectors, true) || []
|
|
87
|
+
}
|
|
101
88
|
// @Todo
|
|
102
89
|
// public getElementsByClassName (names: string): TaroElement[]
|
|
103
|
-
// public querySelector (selectors: string): TaroElement | null
|
|
104
|
-
// public querySelectorAll (selectors: string): TaroElement[]
|
|
105
90
|
// public createElementNS
|
|
106
91
|
}
|
|
107
92
|
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { eventSource, TaroAny, TaroNode } from '@tarojs/runtime'
|
|
2
|
+
|
|
3
|
+
import { TaroElement } from './element'
|
|
4
|
+
|
|
5
|
+
import type { CanvasProps, CanvasTouchEvent } from '@tarojs/components/types'
|
|
6
|
+
|
|
7
|
+
export class CanvasRenderingContext2DWXAdapter extends CanvasRenderingContext2D {
|
|
8
|
+
// constructor(settings?: RenderingContextSetting) {
|
|
9
|
+
// super(settings)
|
|
10
|
+
// }
|
|
11
|
+
|
|
12
|
+
createCircularGradient() {
|
|
13
|
+
// Not supported now
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
draw(cb?: (...args: any[]) => any) {
|
|
17
|
+
typeof cb === 'function' && cb()
|
|
18
|
+
// Not supported now
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
setFillStyle(fillStyle: typeof this.fillStyle) {
|
|
22
|
+
this.fillStyle = fillStyle
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
setFontSize(fontSize: number) {
|
|
26
|
+
const font = this.font.split(' ')
|
|
27
|
+
font[2] = `${fontSize}`
|
|
28
|
+
this.font = font.join(' ')
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
setGlobalAlpha(globalAlpha: typeof this.globalAlpha) {
|
|
32
|
+
this.globalAlpha = globalAlpha
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
setLineCap(lineCap: typeof this.lineCap) {
|
|
36
|
+
this.lineCap = lineCap
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
setLineJoin(lineJoin: typeof this.lineJoin) {
|
|
40
|
+
this.lineJoin = lineJoin
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
setLineWidth(lineWidth: typeof this.lineWidth) {
|
|
44
|
+
this.lineWidth = lineWidth
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
setMiterLimit(miterLimit: typeof this.miterLimit) {
|
|
48
|
+
this.miterLimit = miterLimit
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
setShadow(offsetX: number, offsetY: number, blur: number, color: string) {
|
|
52
|
+
this.shadowOffsetX = offsetX
|
|
53
|
+
this.shadowOffsetY = offsetY
|
|
54
|
+
this.shadowBlur = blur
|
|
55
|
+
this.shadowColor = color
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
setStrokeStyle(strokeStyle: typeof this.strokeStyle) {
|
|
59
|
+
this.strokeStyle = strokeStyle
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
setTextAlign(textAlign: typeof this.textAlign) {
|
|
63
|
+
this.textAlign = textAlign
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
setTextBaseline(textBaseline: typeof this.textBaseline) {
|
|
67
|
+
this.textBaseline = textBaseline
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function getContextKey(obj) {
|
|
71
|
+
let currentObj = obj
|
|
72
|
+
let res = []
|
|
73
|
+
while (currentObj) {
|
|
74
|
+
if (currentObj instanceof CanvasRenderingContext2D) {
|
|
75
|
+
res = [...res, ...Object.getOwnPropertyNames(currentObj)]
|
|
76
|
+
}
|
|
77
|
+
currentObj = Object.getPrototypeOf(currentObj)
|
|
78
|
+
}
|
|
79
|
+
return res
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@Observed
|
|
83
|
+
export class TaroCanvasElement extends TaroElement<CanvasProps, CanvasTouchEvent> {
|
|
84
|
+
_drawList: {
|
|
85
|
+
key: string
|
|
86
|
+
value: TaroAny
|
|
87
|
+
}[] = []
|
|
88
|
+
|
|
89
|
+
settings: RenderingContextSettings
|
|
90
|
+
_context: CanvasRenderingContext2D
|
|
91
|
+
_contextProxy: CanvasRenderingContext2D
|
|
92
|
+
|
|
93
|
+
constructor() {
|
|
94
|
+
super('Canvas')
|
|
95
|
+
this.settings = new RenderingContextSettings(true)
|
|
96
|
+
const context = new CanvasRenderingContext2DWXAdapter(this.settings) as CanvasRenderingContext2D
|
|
97
|
+
this._context = context
|
|
98
|
+
|
|
99
|
+
const proxyObj = getContextKey(context).reduce((obj, key) => {
|
|
100
|
+
if (typeof context[key] === 'function') {
|
|
101
|
+
obj[key] = new Proxy(context[key], {
|
|
102
|
+
apply: (target, thisArg, argumentsList) => {
|
|
103
|
+
this._drawList.push({
|
|
104
|
+
key,
|
|
105
|
+
value: argumentsList,
|
|
106
|
+
})
|
|
107
|
+
},
|
|
108
|
+
})
|
|
109
|
+
} else {
|
|
110
|
+
obj[key] = context[key]
|
|
111
|
+
}
|
|
112
|
+
return obj
|
|
113
|
+
}, {})
|
|
114
|
+
|
|
115
|
+
this._contextProxy = new Proxy(proxyObj, {
|
|
116
|
+
set: (_, property, value) => {
|
|
117
|
+
this._drawList.push({
|
|
118
|
+
key: property,
|
|
119
|
+
value,
|
|
120
|
+
})
|
|
121
|
+
return true
|
|
122
|
+
},
|
|
123
|
+
})
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
get context() {
|
|
127
|
+
return this._contextProxy
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
public setAttribute(name: string, value: TaroAny): void {
|
|
131
|
+
if (name === 'canvasId') {
|
|
132
|
+
eventSource.set(`canvasId-${value}`, this as TaroNode)
|
|
133
|
+
}
|
|
134
|
+
super.setAttribute(name, value)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { eventCenter, eventSource } from '@tarojs/runtime/dist/runtime.esm'
|
|
2
|
+
import { EMPTY_OBJ, toCamelCase } from '@tarojs/shared'
|
|
3
|
+
|
|
4
|
+
import { ATTRIBUTES_CALLBACK_TRIGGER_MAP, ID } from '../../constant'
|
|
5
|
+
import { Current } from '../../current'
|
|
6
|
+
import { findChildNodeWithDFS } from '../../utils'
|
|
7
|
+
import { initComponentNodeInfo, triggerAttributesCallback } from '../../utils/info'
|
|
8
|
+
import { bindAnimation } from '../bind'
|
|
9
|
+
import { ClassList } from '../class-list'
|
|
10
|
+
import { type ICSSStyleDeclaration, createCSSStyleDeclaration } from '../cssStyleDeclaration'
|
|
11
|
+
import { NodeType, TaroNode } from '../node'
|
|
12
|
+
import StyleSheet, { HarmonyStyle, TaroStyleType } from '../stylesheet'
|
|
13
|
+
|
|
14
|
+
import type { BaseTouchEvent, ITouchEvent, StandardProps } from '@tarojs/components/types'
|
|
15
|
+
import type { TaroAny } from '../../utils'
|
|
16
|
+
|
|
17
|
+
type NamedNodeMap = { name: string, value: string }[]
|
|
18
|
+
|
|
19
|
+
export interface TaroExtraProps {
|
|
20
|
+
compileMode?: string | boolean
|
|
21
|
+
compileIf?: boolean
|
|
22
|
+
disabled?: boolean
|
|
23
|
+
__hmStyle?: TaroStyleType
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export class TaroElement<
|
|
27
|
+
T extends StandardProps<any, U> = StandardProps,
|
|
28
|
+
U extends BaseTouchEvent<any> = ITouchEvent
|
|
29
|
+
> extends TaroNode {
|
|
30
|
+
public _innerHTML = ''
|
|
31
|
+
public _nodeInfo: TaroAny = {
|
|
32
|
+
layer: 0 // 渲染层级
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public hm_instance: TaroAny
|
|
36
|
+
|
|
37
|
+
public get _instance () {
|
|
38
|
+
return this.hm_instance
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public set _instance (value) {
|
|
42
|
+
this.hm_instance = value
|
|
43
|
+
if (this._nodeInfo.aboutToAppear) {
|
|
44
|
+
let task
|
|
45
|
+
// eslint-disable-next-line no-cond-assign
|
|
46
|
+
while (task = this._nodeInfo.aboutToAppear.shift()) {
|
|
47
|
+
task()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public readonly tagName: string
|
|
53
|
+
public dataset: Record<string, unknown> = EMPTY_OBJ
|
|
54
|
+
public _attrs: T & TaroExtraProps = {} as T & TaroExtraProps
|
|
55
|
+
|
|
56
|
+
constructor(tagName: string) {
|
|
57
|
+
super(tagName.replace(new RegExp('(?<=.)([A-Z])', 'g'), '-$1').toUpperCase(), NodeType.ELEMENT_NODE)
|
|
58
|
+
this.tagName = this.nodeName
|
|
59
|
+
this._style = createCSSStyleDeclaration(this)
|
|
60
|
+
initComponentNodeInfo(this)
|
|
61
|
+
bindAnimation(this)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public set id(value: string) {
|
|
65
|
+
this.setAttribute('id', value)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public get id(): string {
|
|
69
|
+
return this.getAttribute('id') || this._nid
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
public set className(value: string) {
|
|
73
|
+
this.setAttribute('class', value)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public get className(): string {
|
|
77
|
+
return this.getAttribute('class') || ''
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
public get classList(): ClassList {
|
|
81
|
+
return new ClassList(this.className, this)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
public get attributes(): NamedNodeMap {
|
|
85
|
+
const list: NamedNodeMap = []
|
|
86
|
+
|
|
87
|
+
Object.keys(this._attrs).forEach((name) => {
|
|
88
|
+
const value: TaroAny = this._attrs[name]
|
|
89
|
+
|
|
90
|
+
list.push({ name, value })
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
return list
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public get children(): TaroElement[] {
|
|
97
|
+
return this.childNodes.filter((node) => node.nodeType === NodeType.ELEMENT_NODE) as TaroElement[]
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public setAttribute(name: string, value: TaroAny): void {
|
|
101
|
+
switch (name) {
|
|
102
|
+
case ID:
|
|
103
|
+
eventSource.delete(this._attrs.id)
|
|
104
|
+
eventSource.set(value, this as TaroAny)
|
|
105
|
+
break
|
|
106
|
+
default:
|
|
107
|
+
if (name.startsWith('data-')) {
|
|
108
|
+
if (this.dataset === EMPTY_OBJ) {
|
|
109
|
+
this.dataset = Object.create(null)
|
|
110
|
+
}
|
|
111
|
+
this.dataset[toCamelCase(name.replace(/^data-/, ''))] = value
|
|
112
|
+
}
|
|
113
|
+
break
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
this._attrs[name] = value
|
|
117
|
+
|
|
118
|
+
if (['PAGE-META', 'NAVIGATION-BAR'].includes(this.tagName)) {
|
|
119
|
+
// FIXME 等 Harmony 支持更细粒度的 @Watch 方法后移出
|
|
120
|
+
eventCenter.trigger('__taroComponentAttributeUpdate', {
|
|
121
|
+
id: this._nid,
|
|
122
|
+
tagName: this.tagName,
|
|
123
|
+
attribute: name,
|
|
124
|
+
value
|
|
125
|
+
})
|
|
126
|
+
} else {
|
|
127
|
+
const attributeTriggerValue: TaroAny = ATTRIBUTES_CALLBACK_TRIGGER_MAP[name]
|
|
128
|
+
if (attributeTriggerValue) {
|
|
129
|
+
const triggerName: TaroAny = attributeTriggerValue.triggerName
|
|
130
|
+
const valueInspect: TaroAny = attributeTriggerValue.valueInspect
|
|
131
|
+
|
|
132
|
+
if (valueInspect && !valueInspect(value)) return
|
|
133
|
+
|
|
134
|
+
triggerAttributesCallback(this, triggerName)
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
public getAttribute(name: string): string {
|
|
140
|
+
return this._attrs[name]
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public removeAttribute(name: string): void {
|
|
144
|
+
this._attrs[name] = null
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
public hasAttribute(name: string): boolean {
|
|
148
|
+
return !!this._attrs[name]
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
public hasAttributes(): boolean {
|
|
152
|
+
return Object.keys(this._attrs).length > 0
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public getElementById<T extends TaroElement = TaroElement>(id: string | undefined | null) {
|
|
156
|
+
return findChildNodeWithDFS<T>(
|
|
157
|
+
this as TaroAny,
|
|
158
|
+
(el) => {
|
|
159
|
+
return el.id === id
|
|
160
|
+
},
|
|
161
|
+
false
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
public getElementsByTagName<T extends TaroElement = TaroElement>(tagName: string) {
|
|
166
|
+
return (
|
|
167
|
+
findChildNodeWithDFS<T>(
|
|
168
|
+
this as TaroAny,
|
|
169
|
+
(el) => {
|
|
170
|
+
return el.nodeName === tagName || (tagName === '*' && (this as TaroAny) !== el)
|
|
171
|
+
},
|
|
172
|
+
true
|
|
173
|
+
) || []
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
public getElementsByClassName<T extends TaroElement = TaroElement>(className: string) {
|
|
178
|
+
const classNames = className.trim().split(new RegExp('\\s+'))
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
findChildNodeWithDFS<T>(
|
|
182
|
+
this as TaroAny,
|
|
183
|
+
(el) => {
|
|
184
|
+
const classList = el.classList
|
|
185
|
+
return classNames.every((c) => {
|
|
186
|
+
const bool = classList.contains(c)
|
|
187
|
+
|
|
188
|
+
return bool
|
|
189
|
+
})
|
|
190
|
+
},
|
|
191
|
+
true
|
|
192
|
+
) || []
|
|
193
|
+
)
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
public set innerHTML(value: string) {
|
|
197
|
+
if (this.nodeType === NodeType.ELEMENT_NODE && this.ownerDocument) {
|
|
198
|
+
const ele = this.ownerDocument.createElement('inner-html')
|
|
199
|
+
ele._innerHTML = value
|
|
200
|
+
this.appendChild(ele as TaroAny)
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
public get innerHTML(): string {
|
|
205
|
+
return this._innerHTML
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// 存放的样式,获取其实跟获取style是一样的,只不过这里取的更快捷,不需要走style的get方法进到cssStyleDeclaration
|
|
209
|
+
public _st = new StyleSheet()
|
|
210
|
+
|
|
211
|
+
// 经转换后的鸿蒙样式
|
|
212
|
+
public get hmStyle() {
|
|
213
|
+
return this._st.hmStyle
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
public _style: ICSSStyleDeclaration | null = null
|
|
217
|
+
|
|
218
|
+
public get style(): ICSSStyleDeclaration | null {
|
|
219
|
+
return this._style
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// 伪元素,不存在style动态设置,均已被转换为鸿蒙样式
|
|
223
|
+
// 可根据实际情况,迁移到具体的组件中,如View、ScrollView中,Text\Image其实是不需要的
|
|
224
|
+
public _pseudo_before: StyleSheet | null = null
|
|
225
|
+
|
|
226
|
+
public set_pseudo_before(value: HarmonyStyle | null) {
|
|
227
|
+
if (value) {
|
|
228
|
+
if (!this._pseudo_before) {
|
|
229
|
+
this._pseudo_before = new StyleSheet()
|
|
230
|
+
}
|
|
231
|
+
Object.keys(value).forEach(key => {
|
|
232
|
+
this._pseudo_before!.hmStyle[key] = value[key]
|
|
233
|
+
})
|
|
234
|
+
} else {
|
|
235
|
+
this._pseudo_before = null
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
public _pseudo_after: StyleSheet | null = null
|
|
240
|
+
|
|
241
|
+
public set_pseudo_after(value: HarmonyStyle | null) {
|
|
242
|
+
if (value) {
|
|
243
|
+
if (!this._pseudo_after) {
|
|
244
|
+
this._pseudo_after = new StyleSheet()
|
|
245
|
+
}
|
|
246
|
+
Object.keys(value).forEach(key => {
|
|
247
|
+
this._pseudo_after!.hmStyle[key] = value[key]
|
|
248
|
+
})
|
|
249
|
+
} else {
|
|
250
|
+
this._pseudo_after = null
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
// 伪类,在获取的时候根据dom和parent的关系,动态设置
|
|
255
|
+
public _pseudo_class: Record<string, StyleSheet | null> = {
|
|
256
|
+
// ["::first-child"]: new StyleSheet(),
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
public set_pseudo_class(name: string, value: HarmonyStyle | null) {
|
|
260
|
+
if (value) {
|
|
261
|
+
if (!this._pseudo_class[name]) {
|
|
262
|
+
this._pseudo_class[name] = new StyleSheet()
|
|
263
|
+
}
|
|
264
|
+
Object.keys(value).forEach(key => {
|
|
265
|
+
this._pseudo_class[name]!.hmStyle[key] = value[key]
|
|
266
|
+
})
|
|
267
|
+
} else {
|
|
268
|
+
this._pseudo_class[name] = null
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
get currentLayerNode () {
|
|
273
|
+
if (!Current.page) return null
|
|
274
|
+
if (typeof Current.page.tabBarCurrentIndex !== 'undefined') {
|
|
275
|
+
Current.page.layerNode ||= []
|
|
276
|
+
Current.page.layerNode[Current.page.tabBarCurrentIndex] ||= Current.createHarmonyElement('VIEW')
|
|
277
|
+
// Tabbar
|
|
278
|
+
return Current.page.layerNode[Current.page.tabBarCurrentIndex]
|
|
279
|
+
} else {
|
|
280
|
+
Current.page.layerNode ||= Current.createHarmonyElement('VIEW')
|
|
281
|
+
return Current.page.layerNode
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
get currentLayerParents () {
|
|
286
|
+
if (!Current.page) return null
|
|
287
|
+
if (typeof Current.page.tabBarCurrentIndex !== 'undefined') {
|
|
288
|
+
Current.page.layerParents ||= []
|
|
289
|
+
Current.page.layerParents[Current.page.tabBarCurrentIndex] ||= []
|
|
290
|
+
// Tabbar
|
|
291
|
+
return Current.page.layerParents[Current.page.tabBarCurrentIndex]
|
|
292
|
+
} else {
|
|
293
|
+
Current.page.layerParents ||= []
|
|
294
|
+
return Current.page.layerParents
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// 设置渲染层级,0为正常层级,大于0为固定层级
|
|
299
|
+
// 1、appendChild的时候会判断是否需要设置层级
|
|
300
|
+
// 2、taro-react的setProperty,在处理属性变化的时候,会判断是否需要设置层级
|
|
301
|
+
// 3、removeChild的时候,会判断是否需要移除层级
|
|
302
|
+
public setLayer (value: number) {
|
|
303
|
+
if (!this.parentNode) return // 没有父节点,不需要设置层级关系
|
|
304
|
+
this._nodeInfo.layer = value
|
|
305
|
+
|
|
306
|
+
const currentLayerNode = this.currentLayerNode
|
|
307
|
+
const currentLayerParents = this.currentLayerParents
|
|
308
|
+
if (!currentLayerNode || !currentLayerParents) return
|
|
309
|
+
if (value > 0) {
|
|
310
|
+
// 插入到固定浮层
|
|
311
|
+
currentLayerNode.childNodes.push(this)
|
|
312
|
+
currentLayerNode.notifyDataAdd(currentLayerNode.childNodes.length - 1)
|
|
313
|
+
// 绑定祖先的节点id,建立关系,方便在祖先卸载(removeChild)的时候,能够找到该节点使其卸载
|
|
314
|
+
const _parentRecord = {}
|
|
315
|
+
generateLayerParentIds(_parentRecord, this)
|
|
316
|
+
currentLayerParents[this._nid] = _parentRecord
|
|
317
|
+
} else {
|
|
318
|
+
const idx = currentLayerNode.childNodes.findIndex(n => n._nid === this._nid)
|
|
319
|
+
currentLayerNode.childNodes.splice(idx, 1)
|
|
320
|
+
currentLayerNode.notifyDataDelete(idx)
|
|
321
|
+
|
|
322
|
+
delete currentLayerParents[this._nid]
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
if (this.parentNode) {
|
|
326
|
+
this.parentNode.notifyDataChange(this.parentNode.findIndex(this))
|
|
327
|
+
this.updateComponent()
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
protected toggleLayer(add: boolean) {
|
|
332
|
+
if (add) {
|
|
333
|
+
if (this._st?.hmStyle.position === 'fixed') {
|
|
334
|
+
this.setLayer(1)
|
|
335
|
+
}
|
|
336
|
+
} else {
|
|
337
|
+
const currentLayerParents = this.currentLayerParents
|
|
338
|
+
if (!currentLayerParents) return
|
|
339
|
+
// 识别Current.page.layerParents里面是否有需要移除的固定元素
|
|
340
|
+
if (this._nodeInfo?.layer > 0) {
|
|
341
|
+
delete currentLayerParents[this._nid]
|
|
342
|
+
this.setLayer(0)
|
|
343
|
+
} else {
|
|
344
|
+
Object.keys(currentLayerParents).forEach(fixedId => {
|
|
345
|
+
const parentIds = currentLayerParents[fixedId]
|
|
346
|
+
if (parentIds[this._nid]) {
|
|
347
|
+
// 需要移除fixedId
|
|
348
|
+
delete currentLayerParents[fixedId]
|
|
349
|
+
const fixedNode = eventSource.get(fixedId) as unknown as TaroElement
|
|
350
|
+
if (fixedNode) {
|
|
351
|
+
fixedNode.setLayer(0)
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
})
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// 设置动画
|
|
360
|
+
public setAnimation (playing) {
|
|
361
|
+
if (!this._instance) {
|
|
362
|
+
if (!this._nodeInfo.aboutToAppear) {
|
|
363
|
+
this._nodeInfo.aboutToAppear = []
|
|
364
|
+
}
|
|
365
|
+
this._nodeInfo.aboutToAppear.push(() => {
|
|
366
|
+
this.setAnimation(playing)
|
|
367
|
+
})
|
|
368
|
+
return
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const keyframes = this._st.hmStyle.animationName
|
|
372
|
+
|
|
373
|
+
// 防止动画闪烁,需要把第一帧的内容先设置上去设置初始样式
|
|
374
|
+
if (playing && keyframes && keyframes[0] && keyframes[0].percentage === 0) {
|
|
375
|
+
this._instance.overwriteStyle = keyframes[0].event
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
// 首次设置,不用实例替换
|
|
379
|
+
if (!this._nodeInfo.hasAnimation) {
|
|
380
|
+
this._nodeInfo.hasAnimation = true
|
|
381
|
+
// 下一帧播放,等节点样式首次设置上去在进行覆盖
|
|
382
|
+
setTimeout(() => {
|
|
383
|
+
if (playing) {
|
|
384
|
+
this.playAnimation()
|
|
385
|
+
}
|
|
386
|
+
}, 0)
|
|
387
|
+
} else if (this.parentNode) {
|
|
388
|
+
const idx = this.parentNode.findIndex(this)
|
|
389
|
+
// Note: 因为keyframeAnimateTo无法暂停,华为没有支持,只能临时先换掉实例,重新创建ark节点,使得原本的keyframeAnimateTo失效
|
|
390
|
+
// remove
|
|
391
|
+
this.parentNode.childNodes.splice(idx, 1)
|
|
392
|
+
this.parentNode.notifyDataDelete(idx)
|
|
393
|
+
|
|
394
|
+
// 下一帧播放,等实例被移除掉,再重新插入
|
|
395
|
+
setTimeout(() => {
|
|
396
|
+
// insert
|
|
397
|
+
this.parentNode?.childNodes.splice(idx, 0, this)
|
|
398
|
+
this.parentNode?.notifyDataAdd(idx)
|
|
399
|
+
|
|
400
|
+
// 执行动画
|
|
401
|
+
if (playing) {
|
|
402
|
+
this.playAnimation()
|
|
403
|
+
}
|
|
404
|
+
}, 0)
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
private playAnimation () {
|
|
409
|
+
const {
|
|
410
|
+
animationDuration = 0, animationDelay = 0, animationIterationCount = 1, animationName: keyframes,
|
|
411
|
+
animationTimingFunction
|
|
412
|
+
} = this._st.hmStyle
|
|
413
|
+
|
|
414
|
+
if (keyframes) {
|
|
415
|
+
let cur_percentage = 0
|
|
416
|
+
this._instance.getUIContext()?.keyframeAnimateTo({
|
|
417
|
+
delay: animationDelay,
|
|
418
|
+
iterations: animationIterationCount,
|
|
419
|
+
}, keyframes.map(item => {
|
|
420
|
+
const duration = (item.percentage - cur_percentage) * animationDuration
|
|
421
|
+
cur_percentage = item.percentage
|
|
422
|
+
return {
|
|
423
|
+
duration: duration,
|
|
424
|
+
curve: item.event.animationTimingFunction || animationTimingFunction,
|
|
425
|
+
event: () => {
|
|
426
|
+
this._instance.overwriteStyle = item.event
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
}))
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
function generateLayerParentIds(ids: Record<string, true>, node?: TaroElement) {
|
|
435
|
+
if (node?.parentElement) {
|
|
436
|
+
ids[node.parentElement._nid] = true
|
|
437
|
+
generateLayerParentIds(ids, node.parentElement)
|
|
438
|
+
}
|
|
439
|
+
}
|