@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,186 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
export class FlexManager {
|
|
3
|
+
static flexAlign (value: string | number | undefined): FlexAlign {
|
|
4
|
+
switch (value) {
|
|
5
|
+
case 'flex-end':
|
|
6
|
+
return FlexAlign.End
|
|
7
|
+
case 'center':
|
|
8
|
+
return FlexAlign.Center
|
|
9
|
+
case 'space-between':
|
|
10
|
+
return FlexAlign.SpaceBetween
|
|
11
|
+
case 'space-around':
|
|
12
|
+
return FlexAlign.SpaceAround
|
|
13
|
+
case 'space-evenly':
|
|
14
|
+
return FlexAlign.SpaceEvenly
|
|
15
|
+
default:
|
|
16
|
+
return FlexAlign.Start
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static reverseFlexAlign (value: FlexAlign): string {
|
|
21
|
+
switch (value) {
|
|
22
|
+
case FlexAlign.Start:
|
|
23
|
+
return 'flex-start'
|
|
24
|
+
case FlexAlign.End:
|
|
25
|
+
return 'flex-end'
|
|
26
|
+
case FlexAlign.Center:
|
|
27
|
+
return 'center'
|
|
28
|
+
case FlexAlign.SpaceBetween:
|
|
29
|
+
return 'space-between'
|
|
30
|
+
case FlexAlign.SpaceAround:
|
|
31
|
+
return 'space-around'
|
|
32
|
+
case FlexAlign.SpaceEvenly:
|
|
33
|
+
return 'space-evenly'
|
|
34
|
+
default:
|
|
35
|
+
return ''
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
static direction (value: string): FlexDirection {
|
|
40
|
+
switch (value) {
|
|
41
|
+
case 'row': return FlexDirection.Row
|
|
42
|
+
case 'row-reverse': return FlexDirection.RowReverse
|
|
43
|
+
case 'column-reverse': return FlexDirection.ColumnReverse
|
|
44
|
+
default: return FlexDirection.Column
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static reverseDirection (value: FlexDirection): string {
|
|
49
|
+
switch (value) {
|
|
50
|
+
case FlexDirection.Row: return 'row'
|
|
51
|
+
case FlexDirection.RowReverse: return 'row-reverse'
|
|
52
|
+
case FlexDirection.Column: return 'column'
|
|
53
|
+
case FlexDirection.ColumnReverse: return 'column-reverse'
|
|
54
|
+
default: return ''
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static itemAlign (value: string | number | undefined): ItemAlign {
|
|
59
|
+
switch (value) {
|
|
60
|
+
case 'flex-start':
|
|
61
|
+
return ItemAlign.Start
|
|
62
|
+
case 'flex-end':
|
|
63
|
+
return ItemAlign.End
|
|
64
|
+
case 'center':
|
|
65
|
+
return ItemAlign.Center
|
|
66
|
+
case 'stretch':
|
|
67
|
+
return ItemAlign.Stretch
|
|
68
|
+
case 'baseline':
|
|
69
|
+
return ItemAlign.Baseline
|
|
70
|
+
default:
|
|
71
|
+
return ItemAlign.Auto
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
static reverseItemAlign (value: ItemAlign): string {
|
|
76
|
+
switch (value) {
|
|
77
|
+
case ItemAlign.Start:
|
|
78
|
+
return 'flex-start'
|
|
79
|
+
case ItemAlign.End:
|
|
80
|
+
return 'flex-end'
|
|
81
|
+
case ItemAlign.Center:
|
|
82
|
+
return 'center'
|
|
83
|
+
case ItemAlign.Stretch:
|
|
84
|
+
return 'stretch'
|
|
85
|
+
case ItemAlign.Baseline:
|
|
86
|
+
return 'baseline'
|
|
87
|
+
case ItemAlign.Auto:
|
|
88
|
+
return 'auto'
|
|
89
|
+
default:
|
|
90
|
+
return ''
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static justifyContent (value: string): FlexAlign {
|
|
95
|
+
return FlexManager.flexAlign(value)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
static alignItems (value: string): ItemAlign {
|
|
99
|
+
return FlexManager.itemAlign(value)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
static alignSelf (value: string): ItemAlign {
|
|
103
|
+
return FlexManager.itemAlign(value)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static flexWrap (value: string): FlexWrap {
|
|
107
|
+
switch (value) {
|
|
108
|
+
case 'nowrap':
|
|
109
|
+
return FlexWrap.NoWrap
|
|
110
|
+
case 'wrap':
|
|
111
|
+
return FlexWrap.Wrap
|
|
112
|
+
case 'wrap-reverse':
|
|
113
|
+
return FlexWrap.WrapReverse
|
|
114
|
+
default:
|
|
115
|
+
return FlexWrap.NoWrap
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
static reverseFlexWrap (value: FlexWrap): string {
|
|
120
|
+
switch (value) {
|
|
121
|
+
case FlexWrap.NoWrap:
|
|
122
|
+
return 'nowrap'
|
|
123
|
+
case FlexWrap.Wrap:
|
|
124
|
+
return 'wrap'
|
|
125
|
+
case FlexWrap.WrapReverse:
|
|
126
|
+
return 'wrap-reverse'
|
|
127
|
+
default:
|
|
128
|
+
return 'nowrap'
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
static alignContent (style: Record<string, string | number> = {}): FlexAlign | undefined {
|
|
133
|
+
if (style.flexWrap !== 'wrap') return undefined
|
|
134
|
+
const value = style.alignContent
|
|
135
|
+
return FlexManager.flexAlign(value)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
static flexSize (style: Record<string, string | number> = {}): [number, number, number | string] {
|
|
139
|
+
const flex = style.flex
|
|
140
|
+
const flexGrow = style.flexGrow || 0
|
|
141
|
+
const flexShrink = style.flexShrink || 0
|
|
142
|
+
const flexBasis = style.flexBasis || 'auto'
|
|
143
|
+
let res: [number, number, number | string] = [Number(flexGrow), Number(flexShrink), flexBasis]
|
|
144
|
+
|
|
145
|
+
if (typeof flex === 'number') {
|
|
146
|
+
res = [flex, 1, 0]
|
|
147
|
+
} else if (flex === 'auto') {
|
|
148
|
+
res = [1, 1, 'auto']
|
|
149
|
+
} else if (flex === 'none') {
|
|
150
|
+
res = [0, 0, 'auto']
|
|
151
|
+
} else if (typeof flex === 'string') {
|
|
152
|
+
const FlexList = flex.replace(new RegExp('\\s+'), ' ').split(' ')
|
|
153
|
+
FlexList.forEach((item, index) => {
|
|
154
|
+
res[index] = index < 2 ? Number(item) : item
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
return res
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export class BORDER_STYLE_MAP {
|
|
162
|
+
static solid = BorderStyle.Solid
|
|
163
|
+
static dotted = BorderStyle.Dotted
|
|
164
|
+
static dashed = BorderStyle.Dashed
|
|
165
|
+
|
|
166
|
+
static get(type: string): BorderStyle {
|
|
167
|
+
switch (type) {
|
|
168
|
+
case 'dotted': return BorderStyle.Dotted
|
|
169
|
+
case 'dashed': return BorderStyle.Dashed
|
|
170
|
+
default: return BorderStyle.Solid
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
static reverse(type: BorderStyle): string {
|
|
175
|
+
switch (type) {
|
|
176
|
+
case BorderStyle.Dotted: return 'dotted'
|
|
177
|
+
case BorderStyle.Dashed: return 'dashed'
|
|
178
|
+
case BorderStyle.Solid: return 'solid'
|
|
179
|
+
default: return ''
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function capitalizeFirstLetter (str: string) {
|
|
185
|
+
return str.charAt(0).toUpperCase() + str.slice(1)
|
|
186
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { hooks } from '@tarojs/runtime/dist/runtime.esm'
|
|
2
|
+
|
|
3
|
+
import { TaroNativeModule } from '../harmony-library'
|
|
4
|
+
|
|
5
|
+
class Events {
|
|
6
|
+
on = (...args) => {
|
|
7
|
+
TaroNativeModule.onEventCenter(...args)
|
|
8
|
+
return this
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
once = (...args) => {
|
|
12
|
+
TaroNativeModule.onEventCenterOnce(...args)
|
|
13
|
+
return this
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
off = (...args) => {
|
|
17
|
+
TaroNativeModule.offEventCenter(...args)
|
|
18
|
+
return this
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
trigger = (type, ...args) => {
|
|
22
|
+
TaroNativeModule.triggerEventCenter(type, args)
|
|
23
|
+
return this
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const eventCenter = hooks.call('getEventCenter', Events as any) as Events
|
|
28
|
+
|
|
29
|
+
export { Events, EventsType } from '@tarojs/runtime/dist/runtime.esm'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { env } from '@tarojs/runtime/dist/runtime.esm'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as TaroNativeModule } from 'libTaroHarmonyLibrary.so'
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* eslint-disable simple-import-sort/exports */
|
|
2
|
+
import _display from '@ohos.display'
|
|
3
|
+
|
|
4
|
+
import { FOLD_SPLIT_MAX_WIDTH } from './constant'
|
|
5
|
+
import { Current } from './current'
|
|
6
|
+
import { systemContext, systemPromise, TaroWindowUtil } from './system'
|
|
7
|
+
|
|
8
|
+
export function initStyleSheetConfig (layout: { width: number, height: number} = { width: 0, height: 0 }, navHeight = 0) {
|
|
9
|
+
const display = _display.getDefaultDisplaySync()
|
|
10
|
+
|
|
11
|
+
let logicWidth = layout.width ? layout.width : display.width / display.densityPixels
|
|
12
|
+
const logicHeight = layout.height ? layout.height : display.height / display.densityPixels
|
|
13
|
+
// 断点区间
|
|
14
|
+
if (logicWidth >= FOLD_SPLIT_MAX_WIDTH && logicHeight <= (FOLD_SPLIT_MAX_WIDTH * 10.8)) {
|
|
15
|
+
logicWidth = logicWidth / 2
|
|
16
|
+
}
|
|
17
|
+
const designWidth = typeof Current.taro.config.designWidth === 'function' ? Current.taro.config.designWidth(0) : Current.taro.config.designWidth
|
|
18
|
+
const deviceRatio = Current.taro.config.deviceRatio ? Current.taro.config.deviceRatio[designWidth] || 1 : 1
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
// 设计稿比例基准
|
|
22
|
+
designRatio: logicWidth / (designWidth * deviceRatio),
|
|
23
|
+
// vp -> px比例,逻辑像素和物理像素的比值
|
|
24
|
+
densityPixels: display.densityPixels,
|
|
25
|
+
// 屏幕宽度:单位vp
|
|
26
|
+
deviceWidth: display.width / display.densityPixels,
|
|
27
|
+
// 屏幕高度:单位vp
|
|
28
|
+
deviceHeight: display.height / display.densityPixels,
|
|
29
|
+
// 窗口宽度:单位vp
|
|
30
|
+
viewportWidth: layout.width || (display.width / display.densityPixels),
|
|
31
|
+
// 窗口高度:单位vp
|
|
32
|
+
viewportHeight: (layout.height || (display.height / display.densityPixels)) - navHeight,
|
|
33
|
+
// 安全区域:单位vp
|
|
34
|
+
safeArea: systemContext.safeArea,
|
|
35
|
+
// 显示设备的显示字体的缩放因子。该参数为浮点数,通常与densityPixels相同
|
|
36
|
+
scaledDensity: display.scaledDensity,
|
|
37
|
+
// 表示屏幕当前显示的方向
|
|
38
|
+
orientation: display.orientation,
|
|
39
|
+
// 显示设备屏幕的物理像素密度,表示每英寸上的像素点数。该参数为浮点数,单位为px,支持的范围为[80.0,640.0]。一般取值160.0、480.0等,实际能取到的值取决于不同设备设置里提供的可选值
|
|
40
|
+
densityDPI: display.densityDPI
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { systemContext, systemPromise, TaroWindowUtil }
|
|
45
|
+
|
|
46
|
+
// Current必须放在前面初始化
|
|
47
|
+
export * from './current'
|
|
48
|
+
export { hooks } from '@tarojs/shared'
|
|
49
|
+
// bom
|
|
50
|
+
export * from './bom/document'
|
|
51
|
+
export * from './bom/history'
|
|
52
|
+
export * from './bom/location'
|
|
53
|
+
export * from './bom/navigator'
|
|
54
|
+
export * from './bom/raf'
|
|
55
|
+
export * from './bom/URL'
|
|
56
|
+
export * from './bom/window'
|
|
57
|
+
// dom
|
|
58
|
+
export * from './dom/element'
|
|
59
|
+
export * from './dom/event'
|
|
60
|
+
export * from './dom/event-source'
|
|
61
|
+
export * from './dom/node'
|
|
62
|
+
export * from './dom/stylesheet'
|
|
63
|
+
// others
|
|
64
|
+
export * from './env'
|
|
65
|
+
export * from './constant'
|
|
66
|
+
export * from './emitter/emitter'
|
|
67
|
+
export { nextTick } from './next-tick'
|
|
68
|
+
export * from './utils'
|
|
69
|
+
export * from './utils/page'
|
|
70
|
+
export * from './harmony-library'
|
|
71
|
+
export * from './system'
|
|
72
|
+
// typings
|
|
73
|
+
export * from './interface'
|
|
74
|
+
export {
|
|
75
|
+
Instance, PageProps,
|
|
76
|
+
ReactPageComponent, ReactPageInstance, ReactAppInstance,
|
|
77
|
+
PageLifeCycle, PageInstance,
|
|
78
|
+
AppInstance,
|
|
79
|
+
} from '@tarojs/runtime/dist/runtime.esm'
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './event'
|
|
2
|
+
export { PageConfig, TFunc } from '@tarojs/runtime/dist/runtime.esm'
|
|
3
|
+
|
|
4
|
+
export type TaroAny = any
|
|
5
|
+
export type TaroFunc = (...args: TaroAny[]) => TaroAny
|
|
6
|
+
export type TaroIndent = string | number | boolean | undefined | null
|
|
7
|
+
export type TaroObject = Record<string | number | symbol, TaroAny>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TaroNativeModule } from './harmony-library'
|
|
2
|
+
|
|
3
|
+
import type { TFunc } from './interface'
|
|
4
|
+
|
|
5
|
+
// 自定义组件
|
|
6
|
+
export const nextTick = (cb: TFunc, ctx?: Record<string, any>) => {
|
|
7
|
+
TaroNativeModule.registryNextTick(function() {
|
|
8
|
+
try {
|
|
9
|
+
ctx ? cb.call(ctx) : cb()
|
|
10
|
+
} catch (err) {
|
|
11
|
+
console.error('Error(nextTick): callback error - ' + err + '\n' + err.stack)
|
|
12
|
+
}
|
|
13
|
+
})
|
|
14
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// 设备信息,从 API Version 6 开始支持
|
|
2
|
+
import _display from '@ohos.display'
|
|
3
|
+
import _window from '@ohos.window'
|
|
4
|
+
|
|
5
|
+
import { printInfo, runInDebug } from './utils'
|
|
6
|
+
|
|
7
|
+
let __windowWidth = 0
|
|
8
|
+
let __windowHeight = 0
|
|
9
|
+
let __safeArea: TaroGeneral.SafeAreaResult | null = null
|
|
10
|
+
|
|
11
|
+
export const WINDOW_STATE = 'taro-window-stage-yy-key'
|
|
12
|
+
export class TaroWindowUtil {
|
|
13
|
+
static avoidAreaTopHeight = -1
|
|
14
|
+
static resolve: (...args: any[]) => any = () => {}
|
|
15
|
+
static reject: (...args: any[]) => any = () => {}
|
|
16
|
+
static resolver = new Promise((resolve, reject) => {
|
|
17
|
+
TaroWindowUtil.resolve = resolve
|
|
18
|
+
TaroWindowUtil.reject = reject
|
|
19
|
+
|
|
20
|
+
return resolve
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
static updateTopHeight = (t48) => {
|
|
24
|
+
if (t48.type === _window.AvoidAreaType.TYPE_SYSTEM) {
|
|
25
|
+
typeof TaroWindowUtil.resolve === 'function' && TaroWindowUtil.resolve()
|
|
26
|
+
TaroWindowUtil.avoidAreaTopHeight = t48.area.topRect.height
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 需要在 entryAbility 绑定 onWindowStageCreate 生命周期
|
|
31
|
+
static setWindowStage(b49) {
|
|
32
|
+
try {
|
|
33
|
+
TaroWindowUtil.resolver = new Promise((resolve, reject) => {
|
|
34
|
+
TaroWindowUtil.resolve = resolve
|
|
35
|
+
TaroWindowUtil.reject = reject
|
|
36
|
+
|
|
37
|
+
return resolve
|
|
38
|
+
})
|
|
39
|
+
AppStorage.setOrCreate(WINDOW_STATE, b49)
|
|
40
|
+
const topHeight = b49.getMainWindowSync()?.getWindowAvoidArea(_window.AvoidAreaType.TYPE_SYSTEM)?.topRect?.height
|
|
41
|
+
if (typeof topHeight !== 'undefined') {
|
|
42
|
+
TaroWindowUtil.avoidAreaTopHeight = topHeight
|
|
43
|
+
TaroWindowUtil.resolve()
|
|
44
|
+
}
|
|
45
|
+
b49?.getMainWindow().then((d49) => {
|
|
46
|
+
d49?.on('avoidAreaChange', TaroWindowUtil.updateTopHeight)
|
|
47
|
+
}).catch((error) => {
|
|
48
|
+
console.error('Taro Failed to set window stage', error)
|
|
49
|
+
})
|
|
50
|
+
b49.getMainWindowSync().on('avoidAreaChange', (res) => {
|
|
51
|
+
if (res.type !== _window.AvoidAreaType.TYPE_SYSTEM) return
|
|
52
|
+
updateSystemInfo()
|
|
53
|
+
})
|
|
54
|
+
} catch (error) {
|
|
55
|
+
console.error('Taro Failed to set window stage', error)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static getNavigationBarHeight() {
|
|
60
|
+
const a49 = AppStorage.get(WINDOW_STATE)?.getMainWindowSync()?.getWindowAvoidArea(_window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR)
|
|
61
|
+
return a49?.bottomRect?.height ?? 0
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
static getStatusBarHeight() {
|
|
65
|
+
if (TaroWindowUtil.avoidAreaTopHeight === -1) {
|
|
66
|
+
const z48 = AppStorage.get(WINDOW_STATE)?.getMainWindowSync()?.getWindowAvoidArea(_window.AvoidAreaType.TYPE_SYSTEM)
|
|
67
|
+
return z48?.topRect?.height ?? 0
|
|
68
|
+
} else {
|
|
69
|
+
return TaroWindowUtil.avoidAreaTopHeight
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static setStatusBarColor(x48, y48) {
|
|
74
|
+
AppStorage.get(WINDOW_STATE)?.getMainWindowSync()?.setWindowSystemBarProperties({
|
|
75
|
+
statusBarColor: x48,
|
|
76
|
+
statusBarContentColor: y48
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
static onWindowEventListener(u48) {
|
|
81
|
+
AppStorage.get(WINDOW_STATE)?.getMainWindowSync()?.on('windowEvent', (w48) => {
|
|
82
|
+
if (w48 === _window.WindowEventType.WINDOW_SHOWN) {
|
|
83
|
+
u48?.onBackToForeground()
|
|
84
|
+
} else if (w48 === _window.WindowEventType.WINDOW_HIDDEN) {
|
|
85
|
+
u48?.onForeToBackground()
|
|
86
|
+
}
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static offWindowEventListener() {
|
|
91
|
+
AppStorage.get(WINDOW_STATE)?.getMainWindowSync()?.off('windowEvent')
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
_display.on('change', (status: number) => {
|
|
96
|
+
runInDebug(() => {
|
|
97
|
+
printInfo('foldStatusChange:', status)
|
|
98
|
+
|
|
99
|
+
updateSystemInfo()
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
|
|
103
|
+
export const systemContext: any = {
|
|
104
|
+
resolve: null,
|
|
105
|
+
reject: null,
|
|
106
|
+
get windowHeight () {
|
|
107
|
+
return __windowHeight
|
|
108
|
+
},
|
|
109
|
+
set windowHeight (value: number) {
|
|
110
|
+
__windowHeight = value
|
|
111
|
+
},
|
|
112
|
+
get windowWidth () {
|
|
113
|
+
return __windowWidth
|
|
114
|
+
},
|
|
115
|
+
set windowWidth (value: number) {
|
|
116
|
+
__windowWidth = value
|
|
117
|
+
},
|
|
118
|
+
get safeArea (): TaroGeneral.SafeAreaResult | null {
|
|
119
|
+
// left 和 right 通过监听 display 的变化获取,top 和 bottom 通过 TaroWindowUtil 来获取
|
|
120
|
+
const left = __safeArea?.left || 0
|
|
121
|
+
const right = __safeArea?.right || 0
|
|
122
|
+
const top = px2vp(TaroWindowUtil.getStatusBarHeight())
|
|
123
|
+
const bottom = __windowHeight - px2vp(TaroWindowUtil.getNavigationBarHeight())
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
top,
|
|
127
|
+
bottom,
|
|
128
|
+
left,
|
|
129
|
+
right,
|
|
130
|
+
height: bottom - top,
|
|
131
|
+
width: right - left,
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
set safeArea ({ top, left, right, bottom }: TaroGeneral.SafeAreaResult) {
|
|
135
|
+
__safeArea = {
|
|
136
|
+
bottom: px2vp(bottom),
|
|
137
|
+
top: px2vp(top),
|
|
138
|
+
left: px2vp(left),
|
|
139
|
+
right: px2vp(right),
|
|
140
|
+
height: px2vp(bottom - top),
|
|
141
|
+
width: px2vp(right - left),
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
get statusBarHeight () {
|
|
145
|
+
return px2vp(TaroWindowUtil.getStatusBarHeight())
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export const systemPromise = {
|
|
150
|
+
resolver: new Promise((resolve, reject) => {
|
|
151
|
+
systemContext.resolve = resolve
|
|
152
|
+
systemContext.reject = reject
|
|
153
|
+
|
|
154
|
+
return resolve
|
|
155
|
+
}),
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
let lastUpdate = 0
|
|
159
|
+
async function updateSystemInfo () {
|
|
160
|
+
if (Date.now() - lastUpdate < 1000) {
|
|
161
|
+
// Note: 防抖, 切换折叠屏状态时 change 事件会多次触发
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
lastUpdate = Date.now()
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
const display = _display.getDefaultDisplaySync()
|
|
168
|
+
|
|
169
|
+
// top 和 bottom 通过 TaroWindowUtil 来获取
|
|
170
|
+
// Note: display.width 与 getWindowProperties().windowRect.width 一致,通过 getLastWindow 获取此时是上一个窗口的信息
|
|
171
|
+
systemContext.safeArea ||= {
|
|
172
|
+
top: 0,
|
|
173
|
+
bottom: 0,
|
|
174
|
+
left: 0,
|
|
175
|
+
right: display.width,
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// @ts-ignore
|
|
179
|
+
display.getCutoutInfo((err, { waterfallDisplayAreaRects = {} }: _display.CutoutInfo = {}) => {
|
|
180
|
+
if (err?.code) {
|
|
181
|
+
console.error('Failed to get cutout info', JSON.stringify(err))
|
|
182
|
+
systemContext.reject()
|
|
183
|
+
return
|
|
184
|
+
}
|
|
185
|
+
// top 和 bottom 通过 TaroWindowUtil 来获取
|
|
186
|
+
const top = 0
|
|
187
|
+
const bottom = 0
|
|
188
|
+
const left = waterfallDisplayAreaRects.left?.left + waterfallDisplayAreaRects.left?.width
|
|
189
|
+
const right = display.width - waterfallDisplayAreaRects.right?.left
|
|
190
|
+
|
|
191
|
+
systemContext.safeArea = {
|
|
192
|
+
top,
|
|
193
|
+
left,
|
|
194
|
+
right,
|
|
195
|
+
bottom
|
|
196
|
+
}
|
|
197
|
+
})
|
|
198
|
+
systemContext.resolve()
|
|
199
|
+
} catch (error) {
|
|
200
|
+
systemContext.reject()
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
try {
|
|
205
|
+
const display = _display.getDefaultDisplaySync()
|
|
206
|
+
systemContext.densityPixels ||= display.densityPixels
|
|
207
|
+
systemContext.windowWidth ||= px2vp(display.width)
|
|
208
|
+
systemContext.windowHeight ||= px2vp(display.height)
|
|
209
|
+
} catch (error) {
|
|
210
|
+
console.error('Failed to get system info from window', error)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
updateSystemInfo()
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import _display from '@ohos.display'
|
|
2
|
+
|
|
3
|
+
import { NodeType } from '../dom/node'
|
|
4
|
+
|
|
5
|
+
import type { TaroElement } from '../dom/element/element'
|
|
6
|
+
import type { TaroNode } from '../dom/node'
|
|
7
|
+
|
|
8
|
+
const display = _display.getDefaultDisplaySync()
|
|
9
|
+
|
|
10
|
+
export function isElement (node: TaroNode): node is TaroElement {
|
|
11
|
+
return node.nodeType === NodeType.ELEMENT_NODE
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** @deprecated */
|
|
15
|
+
export function convertNumber2PX(value: number): string {
|
|
16
|
+
return `${value}px`
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** @deprecated */
|
|
20
|
+
export function convertNumber2VP(value: number, unit = 'px'): string {
|
|
21
|
+
if (unit === 'vw' || unit === 'vh') {
|
|
22
|
+
return (value / 100 * (unit === 'vw' ? display.width : display.height)) + 'px'
|
|
23
|
+
}
|
|
24
|
+
return `${value}${unit}`
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function getPageScrollerOrNode (scrollerOrNode: any, page: any) {
|
|
28
|
+
if (!page) return scrollerOrNode
|
|
29
|
+
if (page.cacheData) return page.cacheData
|
|
30
|
+
|
|
31
|
+
const isArrayData = scrollerOrNode instanceof Array
|
|
32
|
+
|
|
33
|
+
if (isArrayData) {
|
|
34
|
+
const index = page.tabBarCurrentIndex || 0
|
|
35
|
+
|
|
36
|
+
return scrollerOrNode[index]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return scrollerOrNode
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function ObjectKeys(obj: object): string[] {
|
|
43
|
+
return Object.keys(obj)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function ObjectAssign(...objects) {
|
|
47
|
+
return Object.assign.apply(this, [].concat(...objects))
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function callFn (fn: any, ctx: any, ...args: any) {
|
|
51
|
+
if (typeof fn === 'function') {
|
|
52
|
+
return fn.apply(ctx, args)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export function bindFn (fn: any, ctx: any, ...args: any) {
|
|
56
|
+
if (typeof fn === 'function') {
|
|
57
|
+
return fn.bind(ctx, ...args)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export * from './info'
|
|
62
|
+
export * from './router'
|
|
63
|
+
export * from '@tarojs/runtime/dist/utils/cache'
|