@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.
Files changed (223) hide show
  1. package/dist/index.js +1237 -0
  2. package/dist/runtime/apis/apis.ts +20 -0
  3. package/dist/runtime/apis/base/crypto.ts +4 -0
  4. package/dist/runtime/apis/base/debug.ts +5 -0
  5. package/dist/runtime/apis/base/index.ts +13 -0
  6. package/dist/runtime/apis/base/performance.ts +8 -0
  7. package/dist/runtime/apis/base/system.ts +181 -0
  8. package/dist/runtime/apis/base/update.ts +5 -0
  9. package/dist/runtime/apis/base/weapp/app-event.ts +75 -0
  10. package/dist/runtime/apis/base/weapp/life-cycle.ts +21 -0
  11. package/dist/runtime/apis/canvas/index.ts +27 -0
  12. package/dist/runtime/apis/data-analysis/index.ts +6 -0
  13. package/dist/runtime/apis/device/accelerometer.ts +79 -0
  14. package/dist/runtime/apis/device/accessibility.ts +4 -0
  15. package/dist/runtime/apis/device/battery.ts +24 -0
  16. package/dist/runtime/apis/device/bluetooth-ble.ts +19 -0
  17. package/dist/runtime/apis/device/bluetooth-peripheral.ts +6 -0
  18. package/dist/runtime/apis/device/bluetooth.ts +16 -0
  19. package/dist/runtime/apis/device/calendar.ts +5 -0
  20. package/dist/runtime/apis/device/clipboard.ts +85 -0
  21. package/dist/runtime/apis/device/compass.ts +21 -0
  22. package/dist/runtime/apis/device/contact.ts +5 -0
  23. package/dist/runtime/apis/device/crypto.ts +4 -0
  24. package/dist/runtime/apis/device/gyroscope.ts +77 -0
  25. package/dist/runtime/apis/device/iBeacon.ts +10 -0
  26. package/dist/runtime/apis/device/index.ts +24 -0
  27. package/dist/runtime/apis/device/keyboard.ts +63 -0
  28. package/dist/runtime/apis/device/memory.ts +11 -0
  29. package/dist/runtime/apis/device/motion.ts +6 -0
  30. package/dist/runtime/apis/device/network.ts +123 -0
  31. package/dist/runtime/apis/device/nfc.ts +10 -0
  32. package/dist/runtime/apis/device/phone.ts +44 -0
  33. package/dist/runtime/apis/device/scan.ts +4 -0
  34. package/dist/runtime/apis/device/screen.ts +80 -0
  35. package/dist/runtime/apis/device/sms.ts +4 -0
  36. package/dist/runtime/apis/device/vibrate.ts +32 -0
  37. package/dist/runtime/apis/device/wifi.ts +15 -0
  38. package/dist/runtime/apis/ext/index.ts +5 -0
  39. package/dist/runtime/apis/files/index.ts +136 -0
  40. package/dist/runtime/apis/files/manager.ts +942 -0
  41. package/dist/runtime/apis/framework/index.ts +48 -0
  42. package/dist/runtime/apis/harmony/task-pool.ts +39 -0
  43. package/dist/runtime/apis/index.ts +61 -0
  44. package/dist/runtime/apis/location/index.ts +133 -0
  45. package/dist/runtime/apis/media/EditorContext.ts +32 -0
  46. package/dist/runtime/apis/media/audio/index.ts +36 -0
  47. package/dist/runtime/apis/media/background-audio/index.ts +16 -0
  48. package/dist/runtime/apis/media/camera.ts +16 -0
  49. package/dist/runtime/apis/media/common.ts +58 -0
  50. package/dist/runtime/apis/media/image/index.ts +291 -0
  51. package/dist/runtime/apis/media/index.ts +13 -0
  52. package/dist/runtime/apis/media/live.ts +5 -0
  53. package/dist/runtime/apis/media/map.ts +4 -0
  54. package/dist/runtime/apis/media/media-recorder.ts +4 -0
  55. package/dist/runtime/apis/media/recorder.ts +6 -0
  56. package/dist/runtime/apis/media/video/VideoContext.ts +67 -0
  57. package/dist/runtime/apis/media/video/index.ts +45 -0
  58. package/dist/runtime/apis/media/video-decoder.ts +4 -0
  59. package/dist/runtime/apis/media/video-processing.ts +4 -0
  60. package/dist/runtime/apis/media/voip.ts +19 -0
  61. package/dist/runtime/apis/navigate/index.ts +8 -0
  62. package/dist/runtime/apis/network/downloadFile.ts +85 -0
  63. package/dist/runtime/apis/network/index.ts +7 -0
  64. package/dist/runtime/apis/network/mdns.ts +13 -0
  65. package/dist/runtime/apis/network/request.ts +140 -0
  66. package/dist/runtime/apis/network/tcp.ts +4 -0
  67. package/dist/runtime/apis/network/udp.ts +4 -0
  68. package/dist/runtime/apis/network/uploadFile.ts +105 -0
  69. package/dist/runtime/apis/network/webSocket.ts +126 -0
  70. package/dist/runtime/apis/open-api/account.ts +4 -0
  71. package/dist/runtime/apis/open-api/address.ts +4 -0
  72. package/dist/runtime/apis/open-api/authorize.ts +5 -0
  73. package/dist/runtime/apis/open-api/card.ts +5 -0
  74. package/dist/runtime/apis/open-api/channels-live.ts +11 -0
  75. package/dist/runtime/apis/open-api/customer-service.ts +4 -0
  76. package/dist/runtime/apis/open-api/device-voip.ts +5 -0
  77. package/dist/runtime/apis/open-api/facial.ts +7 -0
  78. package/dist/runtime/apis/open-api/favorites.ts +5 -0
  79. package/dist/runtime/apis/open-api/group.ts +4 -0
  80. package/dist/runtime/apis/open-api/index.ts +21 -0
  81. package/dist/runtime/apis/open-api/invoice.ts +5 -0
  82. package/dist/runtime/apis/open-api/license-plate.ts +4 -0
  83. package/dist/runtime/apis/open-api/login.ts +6 -0
  84. package/dist/runtime/apis/open-api/my-miniprogram.ts +4 -0
  85. package/dist/runtime/apis/open-api/privacy.ts +7 -0
  86. package/dist/runtime/apis/open-api/red-package.ts +4 -0
  87. package/dist/runtime/apis/open-api/settings.ts +5 -0
  88. package/dist/runtime/apis/open-api/soter.ts +6 -0
  89. package/dist/runtime/apis/open-api/subscribe-message.ts +6 -0
  90. package/dist/runtime/apis/open-api/user-info.ts +70 -0
  91. package/dist/runtime/apis/open-api/werun.ts +5 -0
  92. package/dist/runtime/apis/payment/index.ts +6 -0
  93. package/dist/runtime/apis/route/index.ts +88 -0
  94. package/dist/runtime/apis/share/index.ts +33 -0
  95. package/dist/runtime/apis/storage/background-fetch.ts +7 -0
  96. package/dist/runtime/apis/storage/cache-manager.ts +4 -0
  97. package/dist/runtime/apis/storage/index.ts +203 -0
  98. package/dist/runtime/apis/ui/animation/animation.ts +264 -0
  99. package/dist/runtime/apis/ui/animation/index.ts +7 -0
  100. package/dist/runtime/apis/ui/background.ts +20 -0
  101. package/dist/runtime/apis/ui/custom-component.ts +1 -0
  102. package/dist/runtime/apis/ui/fonts.ts +4 -0
  103. package/dist/runtime/apis/ui/index.ts +12 -0
  104. package/dist/runtime/apis/ui/interaction/index.ts +198 -0
  105. package/dist/runtime/apis/ui/menu.ts +4 -0
  106. package/dist/runtime/apis/ui/navigation-bar/index.ts +72 -0
  107. package/dist/runtime/apis/ui/pull-down-refresh.ts +47 -0
  108. package/dist/runtime/apis/ui/scroll/index.ts +82 -0
  109. package/dist/runtime/apis/ui/sticky.ts +4 -0
  110. package/dist/runtime/apis/ui/tab-bar.ts +144 -0
  111. package/dist/runtime/apis/ui/window.ts +20 -0
  112. package/dist/runtime/apis/utils/constant.ts +1 -0
  113. package/dist/runtime/apis/utils/handler.ts +117 -0
  114. package/dist/runtime/apis/utils/index.ts +105 -0
  115. package/dist/runtime/apis/utils/permissions.ts +6 -0
  116. package/dist/runtime/apis/utils/types.ts +12 -0
  117. package/dist/runtime/apis/utils/unit.ts +104 -0
  118. package/dist/runtime/apis/utils/validate.ts +87 -0
  119. package/dist/runtime/apis/worker/index.ts +4 -0
  120. package/dist/runtime/apis/wxml/index.ts +17 -0
  121. package/dist/runtime/apis/wxml/intersectionObserver.ts +100 -0
  122. package/dist/runtime/apis/wxml/nodesRef.ts +58 -0
  123. package/dist/runtime/apis/wxml/selectorQuery.ts +221 -0
  124. package/dist/runtime/apischunk/index.d.ts +802 -0
  125. package/dist/runtime/apischunk/index.js +5054 -0
  126. package/dist/runtime/components/deprecated.ets +43 -0
  127. package/dist/runtime/components/index.ets +49 -0
  128. package/dist/runtime/components/innerHtml.ets +16 -0
  129. package/dist/runtime/components/navigationBar.ets +65 -0
  130. package/dist/runtime/components/pageMeta.ets +94 -0
  131. package/dist/runtime/components/richText.ets +24 -0
  132. package/dist/runtime/components/slider.ets +119 -0
  133. package/dist/runtime/components/style.ets +286 -0
  134. package/dist/runtime/components/switch.ets +73 -0
  135. package/dist/runtime/components/tag.ts +58 -0
  136. package/dist/runtime/components/utils/AttributeManager.ets +252 -0
  137. package/dist/runtime/components/utils/DynamicCenter.ts +41 -0
  138. package/dist/runtime/components/utils/constant/event.ets +25 -0
  139. package/dist/runtime/components/utils/constant/style.ets +91 -0
  140. package/dist/runtime/components/utils/events.ts +26 -0
  141. package/dist/runtime/components/utils/flexManager.ets +49 -0
  142. package/dist/runtime/components/utils/helper.ets +51 -0
  143. package/dist/runtime/components/utils/htmlParser/HarmonyHTMLParser.ts +100 -0
  144. package/dist/runtime/components/utils/htmlParser/index.ts +58 -0
  145. package/dist/runtime/components/utils/index.ts +77 -0
  146. package/dist/runtime/components/utils/styles.ets +41 -0
  147. package/dist/runtime/components/video.ets +119 -0
  148. package/dist/runtime/components/webView.ets +55 -0
  149. package/dist/runtime/components/xComponent.ets +89 -0
  150. package/dist/runtime/framework/app.ts +248 -0
  151. package/dist/runtime/framework/connect.ts +24 -0
  152. package/dist/runtime/framework/constant.ts +3 -0
  153. package/dist/runtime/framework/hooks.ts +99 -0
  154. package/dist/runtime/framework/index.ts +15 -0
  155. package/dist/runtime/framework/native-page.ts +511 -0
  156. package/dist/runtime/framework/page.ts +256 -0
  157. package/dist/runtime/framework/utils/index.ts +17 -0
  158. package/dist/runtime/framework/utils/is.ts +26 -0
  159. package/dist/runtime/framework-reconciler/componentTree.ts +81 -0
  160. package/dist/runtime/framework-reconciler/constant.ts +86 -0
  161. package/dist/runtime/framework-reconciler/domInput.ts +90 -0
  162. package/dist/runtime/framework-reconciler/event.ts +108 -0
  163. package/dist/runtime/framework-reconciler/index.ts +99 -0
  164. package/dist/runtime/framework-reconciler/inputValueTracking.ts +106 -0
  165. package/dist/runtime/framework-reconciler/props.ts +132 -0
  166. package/dist/runtime/framework-reconciler/reconciler.ts +202 -0
  167. package/dist/runtime/framework-reconciler/render.ts +139 -0
  168. package/dist/runtime/framework-reconciler/workTags.ts +53 -0
  169. package/dist/runtime/runtime-cpp/bom/URL.ts +2 -0
  170. package/dist/runtime/runtime-cpp/bom/document.ts +45 -0
  171. package/dist/runtime/runtime-cpp/bom/history.ts +1 -0
  172. package/dist/runtime/runtime-cpp/bom/location.ts +1 -0
  173. package/dist/runtime/runtime-cpp/bom/navigator.ts +1 -0
  174. package/dist/runtime/runtime-cpp/bom/raf.ts +1 -0
  175. package/dist/runtime/runtime-cpp/bom/window.ts +57 -0
  176. package/dist/runtime/runtime-cpp/constant.ts +29 -0
  177. package/dist/runtime/runtime-cpp/current.ts +48 -0
  178. package/dist/runtime/runtime-cpp/dom/class-list.ts +41 -0
  179. package/dist/runtime/runtime-cpp/dom/comment.ts +9 -0
  180. package/dist/runtime/runtime-cpp/dom/dataSource.ts +87 -0
  181. package/dist/runtime/runtime-cpp/dom/document.ts +113 -0
  182. package/dist/runtime/runtime-cpp/dom/element/canvas.ts +285 -0
  183. package/dist/runtime/runtime-cpp/dom/element/element.ts +262 -0
  184. package/dist/runtime/runtime-cpp/dom/element/form.ts +371 -0
  185. package/dist/runtime/runtime-cpp/dom/element/index.ts +129 -0
  186. package/dist/runtime/runtime-cpp/dom/element/movable.ts +250 -0
  187. package/dist/runtime/runtime-cpp/dom/element/normal.ts +123 -0
  188. package/dist/runtime/runtime-cpp/dom/element/scroll_view.ts +32 -0
  189. package/dist/runtime/runtime-cpp/dom/element/text.ts +9 -0
  190. package/dist/runtime/runtime-cpp/dom/element/video.ts +66 -0
  191. package/dist/runtime/runtime-cpp/dom/element/web_view.ts +72 -0
  192. package/dist/runtime/runtime-cpp/dom/event-source.ts +1 -0
  193. package/dist/runtime/runtime-cpp/dom/event.ts +187 -0
  194. package/dist/runtime/runtime-cpp/dom/eventTarget.ts +81 -0
  195. package/dist/runtime/runtime-cpp/dom/node.ts +307 -0
  196. package/dist/runtime/runtime-cpp/dom/style.ts +44 -0
  197. package/dist/runtime/runtime-cpp/dom/stylesheet/index.ts +379 -0
  198. package/dist/runtime/runtime-cpp/dom/stylesheet/type.ts +212 -0
  199. package/dist/runtime/runtime-cpp/dom/stylesheet/util.ts +186 -0
  200. package/dist/runtime/runtime-cpp/emitter/emitter.ts +29 -0
  201. package/dist/runtime/runtime-cpp/env.ts +1 -0
  202. package/dist/runtime/runtime-cpp/harmony-library.ts +1 -0
  203. package/dist/runtime/runtime-cpp/index.ts +79 -0
  204. package/dist/runtime/runtime-cpp/interface/event.ts +10 -0
  205. package/dist/runtime/runtime-cpp/interface/index.ts +7 -0
  206. package/dist/runtime/runtime-cpp/next-tick.ts +14 -0
  207. package/dist/runtime/runtime-cpp/system.ts +213 -0
  208. package/dist/runtime/runtime-cpp/utils/index.ts +63 -0
  209. package/dist/runtime/runtime-cpp/utils/info.ts +123 -0
  210. package/dist/runtime/runtime-cpp/utils/page.ts +12 -0
  211. package/dist/runtime/runtime-cpp/utils/router.ts +1 -0
  212. package/dist/runtime/runtime-harmony/apis/helper.ets +33 -0
  213. package/dist/runtime/runtime-harmony/apis/network/common.ets +41 -0
  214. package/dist/runtime/runtime-harmony/apis/network/downloadFile.ets +327 -0
  215. package/dist/runtime/runtime-harmony/apis/network/index.ets +58 -0
  216. package/dist/runtime/runtime-harmony/apis/network/request.ets +206 -0
  217. package/dist/runtime/runtime-harmony/apis/network/uploadFile.ets +190 -0
  218. package/dist/runtime/runtime-harmony/apis/route.ets +110 -0
  219. package/dist/runtime/runtime-harmony/apis/taskpool.ets +149 -0
  220. package/dist/runtime/runtime-harmony/index.ets +41 -0
  221. package/dist/runtime/runtime-harmony/utils.ts +53 -0
  222. package/package.json +24 -23
  223. package/LICENSE +0 -174
@@ -0,0 +1,221 @@
1
+ import { Current, getPageScrollerOrNode } from '@tarojs/runtime'
2
+
3
+ import { NodesRef } from './nodesRef'
4
+
5
+ import type { TaroAny } from '@tarojs/runtime'
6
+ import type Taro from '@tarojs/taro/types'
7
+
8
+ interface ISelectorQueryQueue {
9
+ component: any
10
+ selector: string
11
+ single: boolean
12
+ fields
13
+ }
14
+
15
+ type TSelectorQueryQueueCallback = (res: ISelectorQueryQueue) => void
16
+
17
+ // 从 TaroNode 里找到对应的 fields 内容
18
+ function filter (fields, dom) {
19
+ if (!dom) return null
20
+ const {
21
+ id,
22
+ dataset,
23
+ rect,
24
+ size,
25
+ scrollOffset,
26
+ properties = [],
27
+ computedStyle = [],
28
+ nodeCanvasType,
29
+ node,
30
+ context
31
+ } = fields
32
+ const res: any = {}
33
+ if (node) {
34
+ if (nodeCanvasType) { // Node节点获取处理
35
+ const typeName = dom.nodeName
36
+ res.node = {
37
+ id: dom.id,
38
+ $taroElement: dom
39
+ }
40
+ if (/^canvas/i.test(typeName)) {
41
+ // harmony todo canvas attr type
42
+ const canvasType = dom._attrs.type || ''
43
+ res.nodeCanvasType = canvasType
44
+ if (/^(2d|webgl)/i.test(canvasType) && dom) {
45
+ res.node = dom
46
+ } else {
47
+ res.node = null
48
+ }
49
+ } else {
50
+ // TODO https://developers.weixin.qq.com/miniprogram/dev/component/scroll-view.html
51
+ // if (/^taro-scroll-view-core/i.test(tagName))
52
+ res.nodeCanvasType = ''
53
+ res.node = dom
54
+ }
55
+ return res
56
+ } else {
57
+ res.node = dom
58
+ }
59
+ }
60
+ if (context) {
61
+ // TODO: 暂未实现获取 context
62
+ // const typeName = dom.type
63
+ // if (/^video/i.test(typeName)) {
64
+ // return { context: dom }
65
+ // } else if (/^canvas/i.test(typeName)) {
66
+ // const type = dom.type || '2d'
67
+ // // harmony todo canvas context
68
+ // const ctx = dom?.getContext(type)
69
+ // return { context: ctx }
70
+ // } else if (/^taro-live-player-core/i.test(typeName)) {
71
+ // console.error('暂时不支持通过 NodesRef.context 获取 LivePlayerContext')
72
+ // } else if (/^taro-editor-core/i.test(typeName)) {
73
+ // console.error('暂时不支持通过 NodesRef.context 获取 EditorContext')
74
+ // } else if (/^taro-map-core/i.test(typeName)) {
75
+ // console.error('暂时不支持通过 NodesRef.context 获取 MapContext')
76
+ // }
77
+ }
78
+ if (id) res.id = dom.id
79
+
80
+ if (dataset) res.dataset = Object.assign({}, dom.dataset)
81
+
82
+ if (rect || size) {
83
+ const computedStyle = dom.getComputedStyle()
84
+ if (rect) {
85
+ res.top = computedStyle.globalY
86
+ res.left = computedStyle.globalX
87
+ res.right = res.left + computedStyle.width
88
+ res.bottom = res.top + computedStyle.height
89
+ }
90
+
91
+ if (size) {
92
+ res.width = computedStyle.width
93
+ res.height = computedStyle.height
94
+ }
95
+ }
96
+ if (scrollOffset) {
97
+ // FIXME 更新为新的获取方式获取组件参数
98
+ const result = Current.nativeModule.getCurrentOffset(dom)
99
+
100
+ if (result) {
101
+ const { xOffset, yOffset } = result
102
+
103
+ res.scrollLeft = xOffset
104
+ res.scrollTop = yOffset
105
+ }
106
+ }
107
+ if (properties.length) {
108
+ properties.forEach(prop => {
109
+ const attrs = dom._attrs
110
+ if (attrs[prop]) res[prop] = attrs[prop]
111
+ })
112
+ }
113
+ if (computedStyle.length) {
114
+ const styles = dom._st
115
+ computedStyle.forEach(key => {
116
+ const value = styles[key]
117
+ if (value) res[key] = value
118
+ })
119
+ }
120
+ return res
121
+ }
122
+
123
+ function queryBat(queue, cb) {
124
+ const result: TaroAny = []
125
+ const taro = Current.taro
126
+ const page = taro.getCurrentInstance().page
127
+ const element = getPageScrollerOrNode(page?.node, page)
128
+
129
+ if (!element) return null
130
+
131
+ const actions = queue.map((item) => {
132
+ const { component, selector, single, fields } = item
133
+ return new Promise<void>(resolve => {
134
+ Current.nativeModule.querySelectDOM(component || page.node, selector, !single, (res) => {
135
+ if (res && res.length > 0) {
136
+ if (single) {
137
+ const dom = res[0]
138
+ result.push(filter(fields, dom))
139
+ } else {
140
+ result.push(res.map(dom => {
141
+ return filter(fields, dom)
142
+ }))
143
+ }
144
+ }
145
+ resolve()
146
+ })
147
+ })
148
+ })
149
+
150
+ Promise.all(actions).then(() => {
151
+ cb(result)
152
+ })
153
+ }
154
+
155
+ export class SelectorQuery implements Taro.SelectorQuery {
156
+ _queue: ISelectorQueryQueue[]
157
+ _queueCb: (TSelectorQueryQueueCallback | null)[]
158
+ _component?: any
159
+
160
+ constructor () {
161
+ this._queue = []
162
+ this._queueCb = []
163
+ // this._component
164
+ }
165
+
166
+ /**
167
+ * 设置选择器的选取范围
168
+ * @param component 指定组件
169
+ * @return selectQuery 返回查询对象
170
+ */
171
+ in = (component: any) => {
172
+ this._component = component
173
+ return this
174
+ }
175
+
176
+ /**
177
+ * 在当前页面下选择第一个匹配选择器selector的节点
178
+ * @param selector
179
+ * @return nodesRef 返回一个NodesRef 对象实例,可以用于获取节点信息
180
+ */
181
+ select (selector: string) {
182
+ return new NodesRef(selector, this, true)
183
+ }
184
+
185
+ /**
186
+ * 在当前页面下选择匹配选择器selector的所有节点
187
+ * @param selector
188
+ */
189
+ selectAll (selector: string) {
190
+ return new NodesRef(selector, this, false)
191
+ }
192
+
193
+ /**
194
+ * 选择显示区域。可用于获取显示区域的尺寸、滚动位置等信息
195
+ */
196
+ selectViewport () {
197
+ return new NodesRef('.taro_page', this, true)
198
+ }
199
+
200
+ exec (cb?: (...args: any[]) => any) {
201
+ queryBat(this._queue, res => {
202
+ const _queueCb = this._queueCb
203
+ res.forEach((item, index) => {
204
+ const cb = _queueCb[index]
205
+ typeof cb === 'function' && cb.call(this, item)
206
+ })
207
+ typeof cb === 'function' && cb.call(this, res)
208
+ })
209
+ return this as any
210
+ }
211
+
212
+ _push (selector, component, single, fields, callback: Taro.NodesRef.FieldsCallback | null = null) {
213
+ this._queue.push({
214
+ component,
215
+ selector,
216
+ single,
217
+ fields
218
+ })
219
+ this._queueCb.push(callback)
220
+ }
221
+ }