@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.
Files changed (239) hide show
  1. package/dist/apis/apis.ts +6 -2
  2. package/dist/apis/base/crypto.ts +4 -0
  3. package/dist/apis/base/debug.ts +5 -0
  4. package/dist/apis/base/index.ts +9 -1
  5. package/dist/apis/base/performance.ts +8 -0
  6. package/dist/apis/base/system.ts +74 -21
  7. package/dist/apis/base/update.ts +5 -0
  8. package/dist/apis/base/weapp/app-event.ts +75 -0
  9. package/dist/apis/base/weapp/life-cycle.ts +21 -0
  10. package/dist/apis/canvas/index.ts +27 -0
  11. package/dist/apis/data-analysis/index.ts +6 -0
  12. package/dist/apis/device/accelerometer.ts +2 -1
  13. package/dist/apis/device/accessibility.ts +4 -0
  14. package/dist/apis/device/battery.ts +2 -2
  15. package/dist/apis/device/bluetooth-ble.ts +19 -0
  16. package/dist/apis/device/bluetooth-peripheral.ts +6 -0
  17. package/dist/apis/device/bluetooth.ts +16 -0
  18. package/dist/apis/device/calendar.ts +5 -0
  19. package/dist/apis/device/clipboard.ts +17 -9
  20. package/dist/apis/device/compass.ts +21 -0
  21. package/dist/apis/device/contact.ts +5 -0
  22. package/dist/apis/device/crypto.ts +4 -0
  23. package/dist/apis/device/gyroscope.ts +7 -0
  24. package/dist/apis/device/iBeacon.ts +10 -0
  25. package/dist/apis/device/index.ts +15 -0
  26. package/dist/apis/device/keyboard.ts +2 -1
  27. package/dist/apis/device/memory.ts +10 -3
  28. package/dist/apis/device/motion.ts +6 -0
  29. package/dist/apis/device/network.ts +26 -9
  30. package/dist/apis/device/nfc.ts +10 -0
  31. package/dist/apis/device/phone.ts +2 -1
  32. package/dist/apis/device/scan.ts +4 -0
  33. package/dist/apis/device/screen.ts +2 -1
  34. package/dist/apis/device/sms.ts +4 -0
  35. package/dist/apis/device/vibrate.ts +19 -11
  36. package/dist/apis/device/wifi.ts +15 -0
  37. package/dist/apis/ext/index.ts +5 -0
  38. package/dist/apis/files/index.ts +2 -1
  39. package/dist/apis/files/manager.ts +2 -1
  40. package/dist/apis/framework/index.ts +3 -8
  41. package/dist/apis/index.ts +27 -17
  42. package/dist/apis/location/index.ts +61 -68
  43. package/dist/apis/media/EditorContext.ts +32 -0
  44. package/dist/apis/media/audio/index.ts +18 -0
  45. package/dist/apis/media/background-audio/index.ts +16 -0
  46. package/dist/apis/media/camera.ts +16 -0
  47. package/dist/apis/media/common.ts +2 -1
  48. package/dist/apis/media/{image.ts → image/index.ts} +4 -3
  49. package/dist/apis/media/index.ts +10 -0
  50. package/dist/apis/media/live.ts +5 -0
  51. package/dist/apis/media/map.ts +4 -0
  52. package/dist/apis/media/media-recorder.ts +4 -0
  53. package/dist/apis/media/recorder.ts +6 -0
  54. package/dist/apis/media/video/VideoContext.ts +68 -0
  55. package/dist/apis/media/{video.ts → video/index.ts} +13 -2
  56. package/dist/apis/media/video-decoder.ts +4 -0
  57. package/dist/apis/media/video-processing.ts +4 -0
  58. package/dist/apis/media/voip.ts +19 -0
  59. package/dist/apis/network/index.ts +3 -0
  60. package/dist/apis/network/mdns.ts +13 -0
  61. package/dist/apis/network/request.ts +7 -6
  62. package/dist/apis/network/tcp.ts +4 -0
  63. package/dist/apis/network/udp.ts +4 -0
  64. package/dist/apis/network/webSocket.ts +2 -6
  65. package/dist/apis/open-api/account.ts +4 -0
  66. package/dist/apis/open-api/address.ts +4 -0
  67. package/dist/apis/open-api/authorize.ts +5 -0
  68. package/dist/apis/open-api/card.ts +5 -0
  69. package/dist/apis/open-api/channels-live.ts +11 -0
  70. package/dist/apis/open-api/customer-service.ts +4 -0
  71. package/dist/apis/open-api/device-voip.ts +5 -0
  72. package/dist/apis/open-api/facial.ts +7 -0
  73. package/dist/apis/open-api/favorites.ts +5 -0
  74. package/dist/apis/open-api/group.ts +4 -0
  75. package/dist/apis/open-api/index.ts +20 -6
  76. package/dist/apis/open-api/invoice.ts +5 -0
  77. package/dist/apis/open-api/license-plate.ts +4 -0
  78. package/dist/apis/open-api/login.ts +6 -0
  79. package/dist/apis/open-api/my-miniprogram.ts +4 -0
  80. package/dist/apis/open-api/privacy.ts +7 -0
  81. package/dist/apis/open-api/red-package.ts +4 -0
  82. package/dist/apis/open-api/settings.ts +5 -0
  83. package/dist/apis/open-api/soter.ts +6 -0
  84. package/dist/apis/open-api/subscribe-message.ts +6 -0
  85. package/dist/apis/open-api/{user-info/index.ts → user-info.ts} +1 -16
  86. package/dist/apis/open-api/werun.ts +5 -0
  87. package/dist/apis/payment/index.ts +6 -0
  88. package/dist/apis/route/index.ts +19 -28
  89. package/dist/apis/share/index.ts +33 -0
  90. package/dist/apis/storage/background-fetch.ts +7 -0
  91. package/dist/apis/storage/cache-manager.ts +4 -0
  92. package/dist/apis/storage/index.ts +158 -88
  93. package/dist/apis/ui/{animation.ts → animation/animation.ts} +73 -31
  94. package/dist/apis/ui/animation/index.ts +7 -0
  95. package/dist/apis/ui/background.ts +4 -19
  96. package/dist/apis/ui/custom-component.ts +8 -0
  97. package/dist/apis/ui/fonts.ts +4 -0
  98. package/dist/apis/ui/index.ts +8 -10
  99. package/dist/apis/ui/interaction/index.ts +45 -59
  100. package/dist/apis/ui/menu.ts +4 -0
  101. package/dist/apis/ui/navigation-bar/index.ts +60 -21
  102. package/dist/apis/ui/pull-down-refresh.ts +10 -4
  103. package/dist/apis/{page → ui/scroll}/index.ts +32 -27
  104. package/dist/apis/ui/sticky.ts +4 -0
  105. package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +6 -8
  106. package/dist/apis/ui/window.ts +20 -0
  107. package/dist/apis/utils/handler.ts +4 -4
  108. package/dist/apis/utils/index.ts +1 -1
  109. package/dist/apis/worker/index.ts +4 -0
  110. package/dist/apis/wxml/IntersectionObserver.ts +24 -25
  111. package/dist/apis/wxml/index.ts +7 -2
  112. package/dist/apis/wxml/nodesRef.ts +2 -2
  113. package/dist/apis/wxml/selectorQuery.ts +29 -17
  114. package/dist/components-harmony-ets/button.ets +106 -80
  115. package/dist/components-harmony-ets/canvas.ets +51 -0
  116. package/dist/components-harmony-ets/checkbox.ets +82 -148
  117. package/dist/components-harmony-ets/form.ets +45 -132
  118. package/dist/components-harmony-ets/icon.ets +66 -69
  119. package/dist/components-harmony-ets/image.ets +26 -61
  120. package/dist/components-harmony-ets/index.ets +92 -0
  121. package/dist/components-harmony-ets/innerHtml.ets +7 -70
  122. package/dist/components-harmony-ets/input.ets +60 -146
  123. package/dist/components-harmony-ets/label.ets +86 -92
  124. package/dist/components-harmony-ets/listView.ets +26 -0
  125. package/dist/components-harmony-ets/movableArea.ets +124 -0
  126. package/dist/components-harmony-ets/movableView.ets +93 -0
  127. package/dist/components-harmony-ets/navigationBar.ets +65 -0
  128. package/dist/components-harmony-ets/pageMeta.ets +94 -0
  129. package/dist/components-harmony-ets/picker.ets +172 -198
  130. package/dist/components-harmony-ets/progress.ets +52 -0
  131. package/dist/components-harmony-ets/pseudo.ets +80 -0
  132. package/dist/components-harmony-ets/radio.ets +85 -155
  133. package/dist/components-harmony-ets/richText.ets +15 -87
  134. package/dist/components-harmony-ets/scrollList.ets +94 -0
  135. package/dist/components-harmony-ets/scrollView.ets +81 -149
  136. package/dist/components-harmony-ets/slider.ets +47 -94
  137. package/dist/components-harmony-ets/stickySection.ets +42 -0
  138. package/dist/components-harmony-ets/style.ets +396 -0
  139. package/dist/components-harmony-ets/swiper.ets +51 -151
  140. package/dist/components-harmony-ets/switch.ets +35 -76
  141. package/dist/components-harmony-ets/{index.ts → tag.ts} +6 -0
  142. package/dist/components-harmony-ets/text.ets +131 -76
  143. package/dist/components-harmony-ets/textArea.ets +64 -140
  144. package/dist/components-harmony-ets/utils/AttributeManager.ets +1 -1
  145. package/dist/components-harmony-ets/utils/DynamicCenter.ts +4 -13
  146. package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
  147. package/dist/components-harmony-ets/utils/flexManager.ets +68 -85
  148. package/dist/components-harmony-ets/utils/helper.ets +18 -65
  149. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +1 -2
  150. package/dist/components-harmony-ets/utils/htmlParser/index.ts +1 -1
  151. package/dist/components-harmony-ets/utils/index.ts +55 -51
  152. package/dist/components-harmony-ets/utils/styles.ets +177 -65
  153. package/dist/components-harmony-ets/video.ets +70 -116
  154. package/dist/components-harmony-ets/view.ets +58 -64
  155. package/dist/components-harmony-ets/webView.ets +56 -0
  156. package/dist/index.d.ts +152 -0
  157. package/dist/index.js +230 -60
  158. package/dist/index.js.map +1 -1
  159. package/dist/runtime-ets/bom/document.ts +6 -4
  160. package/dist/runtime-ets/bom/getComputedStyle.ts +2 -2
  161. package/dist/runtime-ets/bom/window.ts +9 -2
  162. package/dist/runtime-ets/current.ts +3 -0
  163. package/dist/runtime-ets/dom/bind.ts +96 -0
  164. package/dist/runtime-ets/dom/class-list.ts +4 -6
  165. package/dist/runtime-ets/dom/comment.ts +1 -2
  166. package/dist/runtime-ets/dom/cssNesting.ts +409 -0
  167. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +30 -20
  168. package/dist/runtime-ets/dom/dataSource.ts +64 -0
  169. package/dist/runtime-ets/dom/document.ts +36 -51
  170. package/dist/runtime-ets/dom/element/canvas.ts +136 -0
  171. package/dist/runtime-ets/dom/element/element.ts +439 -0
  172. package/dist/runtime-ets/dom/element/form.ts +403 -0
  173. package/dist/runtime-ets/dom/element/index.ts +120 -0
  174. package/dist/runtime-ets/dom/element/movableArea.ts +11 -0
  175. package/dist/runtime-ets/dom/element/movableView.ts +242 -0
  176. package/dist/runtime-ets/dom/element/normal.ts +103 -0
  177. package/dist/runtime-ets/dom/element/progress.ts +11 -0
  178. package/dist/runtime-ets/dom/element/scrollView.ts +15 -0
  179. package/dist/runtime-ets/dom/element/text.ts +10 -0
  180. package/dist/runtime-ets/dom/element/video.ts +50 -0
  181. package/dist/runtime-ets/dom/element/webView.ts +68 -0
  182. package/dist/runtime-ets/dom/event.ts +26 -5
  183. package/dist/runtime-ets/dom/eventTarget.ts +3 -3
  184. package/dist/runtime-ets/dom/node.ts +114 -49
  185. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +805 -0
  186. package/dist/runtime-ets/dom/stylesheet/index.ts +122 -429
  187. package/dist/runtime-ets/dom/stylesheet/type.ts +93 -17
  188. package/dist/runtime-ets/dom/stylesheet/util.ts +145 -17
  189. package/dist/runtime-ets/index.ts +2 -3
  190. package/dist/runtime-ets/interface/event.ts +3 -2
  191. package/dist/runtime-ets/utils/index.ts +87 -17
  192. package/dist/runtime-ets/utils/info.ts +21 -47
  193. package/dist/runtime-framework/react/app.ts +20 -28
  194. package/dist/runtime-framework/react/hooks.ts +3 -4
  195. package/dist/runtime-framework/react/index.ts +1 -2
  196. package/dist/runtime-framework/react/native-page.ts +421 -0
  197. package/dist/runtime-framework/react/page.ts +5 -17
  198. package/dist/runtime-framework/solid/app.ts +25 -45
  199. package/dist/runtime-framework/solid/connect.ts +21 -3
  200. package/dist/runtime-framework/solid/hooks.ts +17 -12
  201. package/dist/runtime-framework/solid/index.ts +6 -2
  202. package/dist/runtime-framework/solid/page.ts +84 -36
  203. package/dist/runtime-framework/solid/reconciler/props.ts +70 -25
  204. package/dist/runtime-framework/solid/reconciler/render.ts +16 -6
  205. package/dist/runtime-framework/solid/reconciler/use.ts +0 -1
  206. package/dist/runtime-framework/solid/utils/index.ts +0 -2
  207. package/dist/runtime-utils.d.ts +827 -0
  208. package/dist/runtime-utils.js +1633 -549
  209. package/dist/runtime-utils.js.map +1 -1
  210. package/dist/runtime.d.ts +1 -0
  211. package/dist/runtime.js +1633 -549
  212. package/dist/runtime.js.map +1 -1
  213. package/index.js +3 -1
  214. package/package.json +14 -15
  215. package/static/media/cancel.svg +1 -0
  216. package/static/media/circle.svg +1 -0
  217. package/static/media/clear.svg +1 -0
  218. package/static/media/download.svg +1 -0
  219. package/static/media/info.svg +1 -0
  220. package/static/media/info_circle.svg +1 -0
  221. package/static/media/search.svg +1 -0
  222. package/static/media/success.svg +1 -0
  223. package/static/media/success_no_circle.svg +1 -0
  224. package/static/media/taro_arrow_left.svg +1 -0
  225. package/static/media/taro_home.svg +1 -0
  226. package/static/media/waiting.svg +1 -0
  227. package/static/media/warn.svg +1 -0
  228. package/types/harmony.d.ts +4 -0
  229. package/types/index.d.ts +4 -0
  230. package/types/runtime.d.ts +7 -1
  231. package/LICENSE +0 -160
  232. package/dist/components-harmony-ets/base.ets +0 -63
  233. package/dist/components-harmony-ets/element.ets +0 -223
  234. package/dist/components-harmony-ets/utils/constant/icon.ts +0 -19
  235. package/dist/runtime-ets/dom/element.ts +0 -457
  236. package/dist/runtime-ets/dom/text.ts +0 -19
  237. package/dist/runtime-ets/utils/bind.ts +0 -35
  238. package/types/api.d.ts +0 -4
  239. /package/dist/runtime-framework/solid/{contant.ts → constant.ts} +0 -0
@@ -1,11 +1,12 @@
1
1
  // 网络状态,从API Version 7 开始,该接口不再维护,推荐使用新接口'@ohos.telephony.observer'
2
2
  // 但是新接口 @ohos.telephony.observer 没有network.getType。而且网络状态枚举值不清楚
3
3
  import network from '@system.network'
4
- import Taro from '@tarojs/taro'
5
4
 
6
5
  import { temporarilyNotSupport } from '../utils'
7
6
  import { CallbackManager, MethodHandler } from '../utils/handler'
8
7
 
8
+ import type Taro from '@tarojs/taro/types'
9
+
9
10
  export const getNetworkType: typeof Taro.getNetworkType = (options = {}) => {
10
11
  const { success, fail, complete } = options
11
12
  const handle = new MethodHandler<Taro.getNetworkType.SuccessCallbackResult & { code: unknown, metered: boolean }>({ name: 'getNetworkType', success, fail, complete })
@@ -51,11 +52,19 @@ const networkStatusListener = async (data, code = 0) => {
51
52
  export const onNetworkWeakChange = /* @__PURE__ */ temporarilyNotSupport('onNetworkWeakChange')
52
53
 
53
54
  export const onNetworkStatusChange: typeof Taro.onNetworkStatusChange = callback => {
54
- networkStatusManager.add(callback)
55
- if (networkStatusManager.count() === 1) {
56
- network.subscribe({
57
- success: networkStatusListener,
58
- fail: networkStatusListener,
55
+ const name = 'onNetworkStatusChange'
56
+ const handle = new MethodHandler<Partial<Taro.onNetworkStatusChange.CallbackResult>>({ name, complete: callback })
57
+ try {
58
+ networkStatusManager.add(callback)
59
+ if (networkStatusManager.count() === 1) {
60
+ network.subscribe({
61
+ success: networkStatusListener,
62
+ fail: networkStatusListener,
63
+ })
64
+ }
65
+ } catch (error) {
66
+ handle.fail({
67
+ errMsg: error
59
68
  })
60
69
  }
61
70
  }
@@ -63,9 +72,17 @@ export const onNetworkStatusChange: typeof Taro.onNetworkStatusChange = callback
63
72
  export const offNetworkWeakChange = /* @__PURE__ */ temporarilyNotSupport('offNetworkWeakChange')
64
73
 
65
74
  export const offNetworkStatusChange: typeof Taro.offNetworkStatusChange = callback => {
66
- networkStatusManager.remove(callback)
67
- if (networkStatusManager.count() === 0) {
68
- network.unsubscribe()
75
+ const name = 'offNetworkStatusChange'
76
+ const handle = new MethodHandler<Partial<Taro.onNetworkStatusChange.CallbackResult>>({ name, complete: callback })
77
+ try {
78
+ networkStatusManager.remove(callback)
79
+ if (networkStatusManager.count() === 0) {
80
+ network.unsubscribe()
81
+ }
82
+ } catch (error) {
83
+ handle.fail({
84
+ errMsg: error
85
+ })
69
86
  }
70
87
  }
71
88
 
@@ -0,0 +1,10 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // NFC
4
+ export const stopHCE = /* @__PURE__ */ temporarilyNotSupport('stopHCE')
5
+ export const startHCE = /* @__PURE__ */ temporarilyNotSupport('startHCE')
6
+ export const sendHCEMessage = /* @__PURE__ */ temporarilyNotSupport('sendHCEMessage')
7
+ export const onHCEMessage = /* @__PURE__ */ temporarilyNotSupport('onHCEMessage')
8
+ export const offHCEMessage = /* @__PURE__ */ temporarilyNotSupport('offHCEMessage')
9
+ export const getNFCAdapter = /* @__PURE__ */ temporarilyNotSupport('getNFCAdapter')
10
+ export const getHCEState = /* @__PURE__ */ temporarilyNotSupport('getHCEState')
@@ -1,11 +1,12 @@
1
1
  // 从 API Version 7 开始支持。
2
2
  import call from '@ohos.telephony.call'
3
3
  import { isString } from '@tarojs/shared'
4
- import Taro from '@tarojs/taro'
5
4
 
6
5
  import { getParameterError, object2String, shouldBeObject } from '../utils'
7
6
  import { MethodHandler } from '../utils/handler'
8
7
 
8
+ import type Taro from '@tarojs/taro/types'
9
+
9
10
  export const makePhoneCall: typeof Taro.makePhoneCall = (options) => {
10
11
  // options must be an Object
11
12
  const isObject = shouldBeObject(options)
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 扫码
4
+ export const scanCode = /* @__PURE__ */ temporarilyNotSupport('scanCode')
@@ -2,11 +2,12 @@
2
2
  // 但是 新接口 @ohos.brightness 没有 getValue
3
3
  import brightness from '@system.brightness'
4
4
  import { isNumber } from '@tarojs/shared'
5
- import Taro from '@tarojs/taro'
6
5
 
7
6
  import { getParameterError, shouldBeObject, temporarilyNotSupport } from '../utils'
8
7
  import { MethodHandler } from '../utils/handler'
9
8
 
9
+ import type Taro from '@tarojs/taro/types'
10
+
10
11
  // 屏幕
11
12
  export const setVisualEffectOnCapture = /* @__PURE__ */ temporarilyNotSupport('setVisualEffectOnCapture')
12
13
 
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 短信
4
+ export const sendSms = /* @__PURE__ */ temporarilyNotSupport('sendSms')
@@ -1,24 +1,32 @@
1
1
  import vibrator from '@ohos.vibrator'
2
2
 
3
- import { callAsyncFail, callAsyncSuccess } from '../utils'
4
- import { IAsyncParams } from '../utils/types'
3
+ import { MethodHandler } from '../utils/handler'
4
+
5
+ import type Taro from '@tarojs/taro/types'
5
6
 
6
7
  const VIBRATOR_LONG_TIME = 400
7
8
  const VIBRATOR_SHORT_TIME = 15
8
9
 
9
- function vibrateBaseGenerator (time: number) {
10
- return (options: IAsyncParams) => {
10
+ function vibrateBaseGenerator (duration: number, name = '') {
11
+ return ({ success, fail, complete }: Taro.vibrateLong.Option = {}) => {
12
+ const handle = new MethodHandler({ name, success, fail, complete })
11
13
  return new Promise((resolve, reject) => {
12
- vibrator.vibrate(time).then(() => {
13
- const res = { errMsg: 'vibrateShort:ok' }
14
- callAsyncSuccess(resolve, res, options)
14
+ vibrator.startVibration({
15
+ type: 'time',
16
+ duration,
17
+ }, {
18
+ usage: 'unknown'
15
19
  }, (error) => {
16
- const res = { errMsg: 'vibrateShort:fail' + error }
17
- callAsyncFail(reject, res, options)
20
+ if (error) {
21
+ return handle.fail({
22
+ errMsg: `vibrate fail, error.code: ${error.code}; error.message: ${error.message}`
23
+ }, { resolve, reject })
24
+ }
25
+ return handle.success({}, { resolve, reject })
18
26
  })
19
27
  })
20
28
  }
21
29
  }
22
30
 
23
- export const vibrateLong = vibrateBaseGenerator(VIBRATOR_LONG_TIME)
24
- export const vibrateShort = vibrateBaseGenerator(VIBRATOR_SHORT_TIME)
31
+ export const vibrateLong = vibrateBaseGenerator(VIBRATOR_LONG_TIME, 'vibrateLong')
32
+ export const vibrateShort = vibrateBaseGenerator(VIBRATOR_SHORT_TIME, 'vibrateShort')
@@ -0,0 +1,15 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // Wi-Fi
4
+ export const stopWifi = /* @__PURE__ */ temporarilyNotSupport('stopWifi')
5
+ export const startWifi = /* @__PURE__ */ temporarilyNotSupport('startWifi')
6
+ export const setWifiList = /* @__PURE__ */ temporarilyNotSupport('setWifiList')
7
+ export const onWifiConnectedWithPartialInfo = /* @__PURE__ */ temporarilyNotSupport('onWifiConnectedWithPartialInfo')
8
+ export const onWifiConnected = /* @__PURE__ */ temporarilyNotSupport('onWifiConnected')
9
+ export const onGetWifiList = /* @__PURE__ */ temporarilyNotSupport('onGetWifiList')
10
+ export const offWifiConnectedWithPartialInfo = /* @__PURE__ */ temporarilyNotSupport('offWifiConnectedWithPartialInfo')
11
+ export const offWifiConnected = /* @__PURE__ */ temporarilyNotSupport('offWifiConnected')
12
+ export const offGetWifiList = /* @__PURE__ */ temporarilyNotSupport('offGetWifiList')
13
+ export const getWifiList = /* @__PURE__ */ temporarilyNotSupport('getWifiList')
14
+ export const getConnectedWifi = /* @__PURE__ */ temporarilyNotSupport('getConnectedWifi')
15
+ export const connectWifi = /* @__PURE__ */ temporarilyNotSupport('connectWifi')
@@ -0,0 +1,5 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 第三方平台
4
+ export const getExtConfigSync = /* @__PURE__ */ temporarilyNotSupport('getExtConfigSync')
5
+ export const getExtConfig = /* @__PURE__ */ temporarilyNotSupport('getExtConfig')
@@ -19,11 +19,12 @@
19
19
 
20
20
  import document from '@ohos.document'
21
21
  import fileio from '@ohos.fileio'
22
- import Taro from '@tarojs/taro'
23
22
 
24
23
  import { callAsyncFail, callAsyncSuccess, temporarilyNotSupport, validateParams } from '../utils'
25
24
  import { getFileSystemManager, validateSavedFilePath } from './manager'
26
25
 
26
+ import type Taro from '@tarojs/taro/types'
27
+
27
28
  const filePathSchema = {
28
29
  filePath: 'String'
29
30
  }
@@ -29,10 +29,11 @@ import zlib from '@ohos.zlib'
29
29
  import app from '@system.app'
30
30
  import file from '@system.file'
31
31
  import { isNumber, isString } from '@tarojs/shared'
32
- import Taro from '@tarojs/taro'
33
32
 
34
33
  import { callCallbackFail, callCallbackSuccess, temporarilyNotSupport, validateParams } from '../utils'
35
34
 
35
+ import type Taro from '@tarojs/taro/types'
36
+
36
37
  const rootDataPath = `/data/data/${app.getInfo()?.appID || 'app'}`
37
38
  const rootSavedFilePath = `${rootDataPath}/files`
38
39
 
@@ -1,5 +1,3 @@
1
- import { Current } from '@tarojs/runtime'
2
-
3
1
  import { temporarilyNotSupport } from '../utils'
4
2
 
5
3
  export const ENV_TYPE = {
@@ -19,13 +17,10 @@ export function getEnv () {
19
17
  return ENV_TYPE.HARMONY
20
18
  }
21
19
 
22
- export const getCurrentInstance = () => Current
20
+ // TODO
21
+ export const getCurrentPages = () => []
23
22
 
24
- export const nextTick = (cb: (...args: any[]) => any, ctx?: Record<string, any>) => {
25
- setTimeout(function () {
26
- ctx ? cb.call(ctx) : cb()
27
- }, 1)
28
- }
23
+ export { Current, getCurrentInstance } from '@tarojs/runtime'
29
24
 
30
25
  export const requirePlugin = temporarilyNotSupport('requirePlugin')
31
26
 
@@ -33,7 +33,7 @@ const defaultUnitPrecision = 5
33
33
  const defaultTargetUnit = 'vp'
34
34
 
35
35
  export function getApp () {
36
- return Current.app
36
+ return Current.app || {}
37
37
  }
38
38
 
39
39
  export function initPxTransform ({
@@ -58,20 +58,25 @@ export function initPxTransform ({
58
58
 
59
59
  const display = _display.getDefaultDisplaySync()
60
60
 
61
+ let displayWidth = display.width
62
+ let ratioCache: number | false = false
61
63
  let designWidthFunc: (input: number) => number
64
+ let designWidth = defaultDesignWidth
62
65
  function getRatio (value: number) {
63
- const config = (Current as any).taro?.config || {}
64
- if (!isFunction(designWidthFunc)) {
65
- designWidthFunc = isFunction(config.designWidth)
66
- ? config.designWidth
67
- : () => config.designWidth
68
- }
69
- const designWidth = designWidthFunc(value) || defaultDesignWidth
70
- const deviceRatio = config.deviceRatio || defaultDesignRatio
71
- if (!(designWidth in deviceRatio)) {
72
- throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`)
66
+ // Note: 提前调用 display 可能无法获取正确值
67
+ if (ratioCache === false || displayWidth !== display.width) {
68
+ const config = (Current as any).taro?.config || {}
69
+ if (!isFunction(designWidthFunc)) {
70
+ designWidthFunc = isFunction(config.designWidth)
71
+ ? config.designWidth
72
+ : () => config.designWidth
73
+ designWidth = designWidthFunc(value) || defaultDesignWidth
74
+ }
75
+ displayWidth = display.width
76
+ ratioCache = Math.min(display.width, display.height) / designWidth
73
77
  }
74
- return Math.min(display.width, display.height) / designWidth / deviceRatio[designWidth]
78
+
79
+ return ratioCache
75
80
  }
76
81
 
77
82
  // Note: 设置为 style 单位时会自动完成设计稿转换,设计开发者调用 API 时也许抹平差异,例如 pageScrollTo[option.offsetTop]
@@ -79,6 +84,9 @@ export function pxTransformHelper (size: number, unit?: string, isNumber = false
79
84
  const config = (Current as any).taro?.config || {}
80
85
  const targetUnit = unit || config.targetUnit || defaultTargetUnit
81
86
 
87
+ if (targetUnit === 'PX') {
88
+ return px2vp(size * display.scaledDensity) + 'vp'
89
+ }
82
90
  const ratio = getRatio(size)
83
91
  let val = size * ratio
84
92
 
@@ -92,19 +100,19 @@ export function pxTransformHelper (size: number, unit?: string, isNumber = false
92
100
  return isNumber ? val : val + targetUnit
93
101
  }
94
102
 
95
- export function pxTransform (size: number): number {
103
+ export function pxTransform (size: number): number | string {
96
104
  const config = (Current as any).taro?.config || {}
97
105
  const targetUnit = config.targetUnit || defaultTargetUnit
98
106
 
99
- let val = size
107
+ const val = size
100
108
  switch (targetUnit) {
101
109
  case 'vp':
102
- val = px2vp(size)
103
- break
110
+ return pxTransformHelper(size, 'px')
111
+ // return `${size}lpx`
104
112
  default:
105
113
  // NOTE: 鸿蒙环境下 style 会自动完成设计稿转换,无需在方法内二次调整
106
114
  }
107
- return val + config.targetUnit
115
+ return val + targetUnit
108
116
  }
109
117
 
110
118
  export function canIUseWebp () {
@@ -120,5 +128,7 @@ export function getAppInfo () {
120
128
  }
121
129
  }
122
130
 
131
+ initNativeApi(taro)
132
+
123
133
  export * from './apis'
124
134
  export default taro
@@ -1,3 +1,4 @@
1
+ // @ts-nocheck
1
2
  // HarmonyOS 文档: https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-geolocation-0000001199568865#section13752433138
2
3
  // WX 文档: https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.onLocationChange.html
3
4
  // ✅ wx.offLocationChange
@@ -15,49 +16,20 @@
15
16
  // ❌ wx.startLocationUpdate
16
17
 
17
18
  import geoLocationManager from '@ohos.geoLocationManager'
18
- import Taro from '@tarojs/taro'
19
19
 
20
- import { callAsyncFail, callAsyncSuccess, validateParams } from '../utils'
20
+ import { callAsyncFail, callAsyncSuccess, temporarilyNotSupport, validateParams } from '../utils'
21
+ import { MethodHandler } from '../utils/handler'
21
22
 
22
- interface IGetOHOSGeolocationParams {
23
- type?: string
24
- altitude?: boolean
25
- isHighAccuracy?: boolean
26
- highAccuracyExpireTime?: number
27
- priority?: number // 数值为固定几种
28
- scenario?: number // 数值为固定几种
29
- maxAccuracy?: number // 表示精度信息,单位是米。
30
- timeoutMs?: number
31
- }
32
-
33
- interface ILocationRequest {
34
- priority?: number
35
- scenario?: number // 勘误:注意 Harmony OS 这个参数是必填
36
- timeInterval?: number
37
- distanceInterval?: number
38
- maxAccuracy?: number
39
- }
40
-
41
- interface ILocationSuccessDataOHOS {
42
- latitude: number
43
- longitude: number
44
- altitude: number
45
- accuracy: number
46
- speed: number
47
- timeStamp: number
48
- direction: number
49
- timeSinceBoot: number
50
- additions: Array<string>
51
- additionSize: number
52
- }
23
+ import type Taro from '@tarojs/taro/types'
53
24
 
54
- interface ILocationSuccessOHOS {
55
- code: number
56
- data: ILocationSuccessDataOHOS
57
- }
25
+ // 位置
26
+ export const stopLocationUpdate = /* @__PURE__ */ temporarilyNotSupport('stopLocationUpdate')
27
+ export const startLocationUpdateBackground = /* @__PURE__ */ temporarilyNotSupport('startLocationUpdateBackground')
28
+ export const startLocationUpdate = /* @__PURE__ */ temporarilyNotSupport('startLocationUpdate')
29
+ export const openLocation = /* @__PURE__ */ temporarilyNotSupport('openLocation')
58
30
 
59
- function formatLocation (location: ILocationSuccessDataOHOS) {
60
- const locationWX = {
31
+ function formatLocation (location: Location) {
32
+ const wxLocate = {
61
33
  latitude: location.latitude,
62
34
  longitude: location.longitude,
63
35
  altitude: location.altitude,
@@ -66,7 +38,7 @@ function formatLocation (location: ILocationSuccessDataOHOS) {
66
38
  verticalAccuracy: 0, // OHOS 不支持返回此参数,直接设置为默认值
67
39
  horizontalAccuracy: 0 // OHOS 不支持返回此参数,直接设置为默认值
68
40
  }
69
- return locationWX
41
+ return wxLocate
70
42
  }
71
43
  // TODO:增加参数校验
72
44
  // const getLocationSchema = {
@@ -84,19 +56,18 @@ export const getLocation: typeof Taro.getLocation = function (options = {}) {
84
56
  * 二者参数不一致
85
57
  */
86
58
  const { type, altitude, isHighAccuracy, highAccuracyExpireTime } = options
87
- const params: IGetOHOSGeolocationParams = {
88
- type,
89
- altitude,
90
- isHighAccuracy,
91
- highAccuracyExpireTime
92
- }
93
59
  try {
94
- return geoLocationManager.getCurrentLocation(params).then((location: ILocationSuccessOHOS) => {
60
+ return geoLocationManager.getCurrentLocation({
61
+ type,
62
+ altitude,
63
+ isHighAccuracy,
64
+ highAccuracyExpireTime
65
+ }).then((location: Location) => {
95
66
  if (location.code !== 0) {
96
67
  callAsyncFail(reject, location, options)
97
68
  } else {
98
- const locationWX = formatLocation(location.data)
99
- callAsyncSuccess(resolve, locationWX, options)
69
+ const wxLocate = formatLocation(location.data)
70
+ callAsyncSuccess(resolve, wxLocate, options)
100
71
  }
101
72
  }).catch(error => {
102
73
  callAsyncFail(reject, error, options)
@@ -108,26 +79,48 @@ export const getLocation: typeof Taro.getLocation = function (options = {}) {
108
79
  }
109
80
 
110
81
  export const onLocationChange: typeof Taro.onLocationChange = function (callback) {
111
- validateParams('onLocationChange', [callback], ['Function'])
112
- const requestInfo: ILocationRequest = {}
113
- geoLocationManager.on('locationChange', requestInfo, (location: ILocationSuccessDataOHOS) => {
114
- if (location) {
115
- const locationWX = formatLocation(location)
116
- callback(locationWX)
117
- }
118
- })
82
+ const name = 'onLocationChange'
83
+ const handle = new MethodHandler<Partial<Taro.onLocationChange.CallbackResult>>({ name, complete: callback })
84
+ try {
85
+ validateParams(name, [callback], ['Function'])
86
+ geoLocationManager.on('locationChange', {}, (location: Location) => {
87
+ if (location) {
88
+ const wxLocate = formatLocation(location)
89
+ callback(wxLocate)
90
+ }
91
+ })
92
+ } catch (error) {
93
+ handle.fail({
94
+ errMsg: error
95
+ })
96
+ }
119
97
  }
120
98
 
121
- export const offLocationChange: typeof Taro.offLocationChangeError = function (callback) {
122
- validateParams('offLocationChange', [callback], ['Function'])
123
- geoLocationManager.off('locationChange', (location: ILocationSuccessOHOS) => {
124
- const status = {
125
- errCode: 200,
126
- errMsg: location ? 'offLocationChange is off' : 'offLocationChange err'
127
- }
99
+ export const offLocationChange: typeof Taro.offLocationChange = function (callback) {
100
+ const name = 'offLocationChange'
101
+ const handle = new MethodHandler<Partial<Taro.onLocationChange.CallbackResult>>({ name, complete: callback })
102
+ try {
103
+ validateParams(name, [callback], ['Function'])
104
+ geoLocationManager.off('locationChange', (location: Location) => {
105
+ const status = {
106
+ errCode: 200,
107
+ errMsg: location ? 'offLocationChange is off' : 'offLocationChange err'
108
+ }
128
109
 
129
- if (callback) {
130
- callback(status)
131
- }
132
- })
110
+ if (callback) {
111
+ callback(status)
112
+ }
113
+ })
114
+ } catch (error) {
115
+ handle.fail({
116
+ errMsg: error
117
+ })
118
+ }
133
119
  }
120
+
121
+ export const onLocationChangeError = /* @__PURE__ */ temporarilyNotSupport('onLocationChangeError')
122
+ export const offLocationChangeError = /* @__PURE__ */ temporarilyNotSupport('offLocationChangeError')
123
+
124
+ export const choosePoi = /* @__PURE__ */ temporarilyNotSupport('choosePoi')
125
+ export const chooseLocation = /* @__PURE__ */ temporarilyNotSupport('chooseLocation')
126
+ export const getFuzzyLocation = /* @__PURE__ */ temporarilyNotSupport('getFuzzyLocation')
@@ -0,0 +1,32 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ import type Taro from '@tarojs/taro/types'
4
+
5
+ // 富文本
6
+ export class EditorContext implements Taro.EditorContext {
7
+ blur = temporarilyNotSupport('EditorContext.blur')
8
+
9
+ clear = temporarilyNotSupport('EditorContext.clear')
10
+
11
+ format = temporarilyNotSupport('EditorContext.format')
12
+
13
+ getContents = temporarilyNotSupport('EditorContext.getContents')
14
+
15
+ getSelectionText = temporarilyNotSupport('EditorContext.getSelectionText')
16
+
17
+ insertDivider = temporarilyNotSupport('EditorContext.insertDivider')
18
+
19
+ insertImage = temporarilyNotSupport('EditorContext.insertImage')
20
+
21
+ insertText = temporarilyNotSupport('EditorContext.insertText')
22
+
23
+ redo = temporarilyNotSupport('EditorContext.redo')
24
+
25
+ removeFormat = temporarilyNotSupport('EditorContext.removeFormat')
26
+
27
+ scrollIntoView = temporarilyNotSupport('EditorContext.scrollIntoView')
28
+
29
+ setContents = temporarilyNotSupport('EditorContext.setContents')
30
+
31
+ undo = temporarilyNotSupport('EditorContext.undo')
32
+ }
@@ -0,0 +1,18 @@
1
+ import { temporarilyNotSupport } from '../../utils'
2
+
3
+ // 音频
4
+
5
+ export const stopVoice = /* @__PURE__ */ temporarilyNotSupport('stopVoice')
6
+ export const setInnerAudioOption = /* @__PURE__ */ temporarilyNotSupport('setInnerAudioOption')
7
+ export const playVoice = /* @__PURE__ */ temporarilyNotSupport('playVoice')
8
+ export const pauseVoice = /* @__PURE__ */ temporarilyNotSupport('pauseVoice')
9
+ export const getAvailableAudioSources = /* @__PURE__ */ temporarilyNotSupport('getAvailableAudioSources')
10
+ export const createWebAudioContext = /* @__PURE__ */ temporarilyNotSupport('createWebAudioContext')
11
+ export const createMediaAudioPlayer = /* @__PURE__ */ temporarilyNotSupport('createMediaAudioPlayer')
12
+
13
+ /**
14
+ * 创建内部 audio 上下文 InnerAudioContext 对象。
15
+ */
16
+ export const createInnerAudioContext = /* @__PURE__ */ temporarilyNotSupport('createInnerAudioContext')
17
+
18
+ export const createAudioContext = /* @__PURE__ */ temporarilyNotSupport('createAudioContext')
@@ -0,0 +1,16 @@
1
+ import { temporarilyNotSupport } from '../../utils'
2
+
3
+ // 背景音频
4
+ export const stopBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('stopBackgroundAudio')
5
+ export const seekBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('seekBackgroundAudio')
6
+ export const playBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('playBackgroundAudio')
7
+ export const pauseBackgroundAudio = /* @__PURE__ */ temporarilyNotSupport('pauseBackgroundAudio')
8
+ export const onBackgroundAudioStop = /* @__PURE__ */ temporarilyNotSupport('onBackgroundAudioStop')
9
+ export const onBackgroundAudioPlay = /* @__PURE__ */ temporarilyNotSupport('onBackgroundAudioPlay')
10
+ export const onBackgroundAudioPause = /* @__PURE__ */ temporarilyNotSupport('onBackgroundAudioPause')
11
+ export const getBackgroundAudioPlayerState = /* @__PURE__ */ temporarilyNotSupport('getBackgroundAudioPlayerState')
12
+
13
+ /**
14
+ * 获取全局唯一的背景音频管理器
15
+ */
16
+ export const getBackgroundAudioManager = /* @__PURE__ */ temporarilyNotSupport('getBackgroundAudioManager')
@@ -0,0 +1,16 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ import type Taro from '@tarojs/taro/types'
4
+
5
+ // 相机
6
+ class CameraContext implements Taro.CameraContext {
7
+ onCameraFrame = temporarilyNotSupport('CameraContext.onCameraFrame') as unknown as Taro.CameraContext['onCameraFrame']
8
+ setZoom = temporarilyNotSupport('CameraContext.setZoom')
9
+ startRecord = temporarilyNotSupport('CameraContext.startRecord')
10
+ stopRecord = temporarilyNotSupport('CameraContext.stopRecord')
11
+ takePhoto = temporarilyNotSupport('CameraContext.takePhoto')
12
+ }
13
+
14
+ export const createCameraContext: typeof Taro.createCameraContext = (_?: string) => {
15
+ return new CameraContext()
16
+ }
@@ -4,10 +4,11 @@
4
4
  // ✅ wx.chooseMedia
5
5
 
6
6
  import mediaLibrary from '@ohos.multimedia.mediaLibrary'
7
- import Taro from '@tarojs/taro'
8
7
 
9
8
  import { callAsyncFail, callAsyncSuccess, validateParams } from '../utils'
10
9
 
10
+ import type Taro from '@tarojs/taro/types'
11
+
11
12
  interface IPreviewImagesOptionsOHOS {
12
13
  images: Array<string>
13
14
  index: number
@@ -12,9 +12,10 @@
12
12
  import picker from '@ohos.file.picker'
13
13
  import image from '@ohos.multimedia.image'
14
14
  import { isNull } from '@tarojs/shared'
15
- import Taro from '@tarojs/taro'
16
15
 
17
- import { callAsyncFail, callAsyncSuccess, temporarilyNotSupport, validateParams } from '../utils'
16
+ import { callAsyncFail, callAsyncSuccess, temporarilyNotSupport, validateParams } from '../../utils'
17
+
18
+ import type Taro from '@tarojs/taro/types'
18
19
 
19
20
  interface IPackingOptionOHOS {
20
21
  format: string
@@ -111,7 +112,7 @@ export const chooseImage: typeof Taro.chooseImage = function (options) {
111
112
  photoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE // 过滤选择媒体文件类型为IMAGE
112
113
 
113
114
  photoViewPicker.select(photoSelectOptions).then((photoSelectResult) => {
114
- callAsyncSuccess(resolve, { tempFilePaths: photoSelectResult.photoUris })
115
+ callAsyncSuccess(resolve, { tempFilePaths: photoSelectResult.photoUris }, options)
115
116
  }).catch((error) => {
116
117
  callAsyncFail(reject, error, options)
117
118
  })
@@ -1,3 +1,13 @@
1
+ export * from './audio'
2
+ export * from './background-audio'
3
+ export * from './camera'
1
4
  export * from './common'
2
5
  export * from './image'
6
+ export * from './live'
7
+ export * from './map'
8
+ export * from './media-recorder'
9
+ export * from './recorder'
3
10
  export * from './video'
11
+ export * from './video-decoder'
12
+ export * from './video-processing'
13
+ export * from './voip'
@@ -0,0 +1,5 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 实时音视频
4
+ export const createLivePusherContext = /* @__PURE__ */ temporarilyNotSupport('createLivePusherContext')
5
+ export const createLivePlayerContext = /* @__PURE__ */ temporarilyNotSupport('createLivePlayerContext')
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 地图
4
+ export const createMapContext = /* @__PURE__ */ temporarilyNotSupport('createMapContext')
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 画面录制器
4
+ export const createMediaRecorder = /* @__PURE__ */ temporarilyNotSupport('createMediaRecorder')