@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,48 @@
1
+ import { Current, getCurrentInstance } from '@tarojs/runtime'
2
+
3
+ import { temporarilyNotSupport } from '../utils'
4
+
5
+ import type { TaroAny } from '@tarojs/runtime'
6
+
7
+ export const ENV_TYPE = {
8
+ WEAPP: 'WEAPP',
9
+ SWAN: 'SWAN',
10
+ ALIPAY: 'ALIPAY',
11
+ TT: 'TT',
12
+ QQ: 'QQ',
13
+ JD: 'JD',
14
+ WEB: 'WEB',
15
+ RN: 'RN',
16
+ HARMONY: 'HARMONY',
17
+ QUICKAPP: 'QUICKAPP'
18
+ }
19
+
20
+ export function getEnv () {
21
+ return ENV_TYPE.HARMONY
22
+ }
23
+
24
+ // TODO
25
+ export const getCurrentPages = () => []
26
+
27
+ export { Current, getCurrentInstance }
28
+
29
+ export const requirePlugin = temporarilyNotSupport('requirePlugin')
30
+
31
+ /** 鸿蒙专属 */
32
+ export function updatePageSync () {
33
+ const node = (getCurrentInstance()?.page as TaroAny)?.node
34
+
35
+ if (!node) return
36
+
37
+ Current.nativeModule.updatePageSync(node)
38
+ }
39
+
40
+ export function unstable_SetPageIsTextNeedLayout(isNeed: boolean) {
41
+ const node = (getCurrentInstance()?.page as TaroAny)?.node
42
+
43
+ if (!node) return
44
+
45
+ Current.nativeModule.unstable_SetPageIsTextNeedLayout(node, isNeed)
46
+ }
47
+
48
+ export { eventCenter, Events, History } from '@tarojs/runtime'
@@ -0,0 +1,39 @@
1
+ import { eventCenter } from '@tarojs/runtime'
2
+
3
+ import { ETS_METHODS_TRIGGER_EVENTNAME, MethodHandler } from '../utils'
4
+
5
+ import type { TaroAny } from '@tarojs/runtime'
6
+
7
+ const scope = 'taskpool'
8
+ const type = 'method'
9
+
10
+ // TaskPool 专属方法
11
+ export const triggerTaskPoolMethods = ({
12
+ name = '',
13
+ args = [],
14
+ complete,
15
+ fail,
16
+ success,
17
+ }: {
18
+ name?: string
19
+ args?: TaroAny[]
20
+ complete?: (res: TaroAny) => void
21
+ fail?: (res: TaroAny) => void
22
+ success?: (res: TaroAny) => void
23
+ } = {}) => {
24
+ if (!name) {
25
+ throw new Error('triggerTaskPoolMethods 方法必须传入 name 参数')
26
+ }
27
+
28
+ const handle = new MethodHandler({ name, success, fail, complete })
29
+ return new Promise((resolve, reject) => {
30
+ eventCenter.trigger(ETS_METHODS_TRIGGER_EVENTNAME, {
31
+ name,
32
+ args,
33
+ scope,
34
+ type,
35
+ successHandler: (res = {}) => handle.success(res, { resolve, reject }),
36
+ errorHandler: (res = {}) => handle.fail(res, { resolve, reject })
37
+ })
38
+ })
39
+ }
@@ -0,0 +1,61 @@
1
+ import { Current, hooks } from '@tarojs/runtime'
2
+ import { PLATFORM_TYPE } from '@tarojs/shared'
3
+
4
+ import * as apis from './apis'
5
+ import { permanentlyNotSupport } from './utils'
6
+ import { initPxTransform, pxTransform } from './utils/unit'
7
+
8
+ const taro = Object.assign({}, apis)
9
+
10
+ const requirePlugin = /* @__PURE__ */ permanentlyNotSupport('requirePlugin')
11
+ export function initNativeApi (taro) {
12
+ Current.taro = taro
13
+ taro.requirePlugin = requirePlugin
14
+ taro.getApp = getApp
15
+ taro.pxTransform = pxTransform
16
+ taro.initPxTransform = initPxTransform
17
+ taro.canIUseWebp = canIUseWebp
18
+ taro.getAppInfo = getAppInfo
19
+ taro.getUIContext = getUIContext
20
+
21
+ if (hooks.isExist('initNativeApi')) {
22
+ hooks.call('initNativeApi', taro)
23
+ }
24
+ }
25
+
26
+ export function getApp () {
27
+ if (Current.page && Current.page.$isUseReact18) {
28
+ return Current.entryAsync || {}
29
+ }
30
+
31
+ return Current.app || {}
32
+ }
33
+
34
+ export * from './utils/unit'
35
+
36
+ export function canIUseWebp () {
37
+ return true
38
+ }
39
+
40
+ export function getAppInfo () {
41
+ const config = Current.taro?.config
42
+ return {
43
+ platform: process.env.TARO_PLATFORM || PLATFORM_TYPE.HARMONY,
44
+ taroVersion: process.env.TARO_VERSION || 'unknown',
45
+ designWidth: config?.designWidth,
46
+ }
47
+ }
48
+
49
+ export function getUIContext () {
50
+ // @ts-ignore
51
+ const uiContext = Current?.page?.getUIContext?.()
52
+
53
+ if (!uiContext) return null
54
+
55
+ return uiContext
56
+ }
57
+
58
+ initNativeApi(taro)
59
+
60
+ export * from './apis'
61
+ export default taro
@@ -0,0 +1,133 @@
1
+ // HarmonyOS 文档: https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-geolocation-0000001199568865#section13752433138
2
+ // WX 文档: https://developers.weixin.qq.com/miniprogram/dev/api/location/wx.onLocationChange.html
3
+ // ✅ wx.offLocationChange
4
+ // ✅ wx.getLocation
5
+ // ✅ wx.onLocationChange
6
+
7
+ // 不支持实现
8
+ // ❌ wx.startLocationUpdateBackground
9
+ // ❌ wx.onLocationChangeError
10
+ // ❌ wx.offLocationChangeError
11
+ // ❌ wx.openLocation 地图相关
12
+ // ❌ wx.choosePoi 地图相关
13
+ // ❌ wx.chooseLocation 地图相关
14
+ // ❌ wx.stopLocationUpdate
15
+ // ❌ wx.startLocationUpdate
16
+
17
+ import geoLocationManager from '@ohos.geoLocationManager'
18
+
19
+ import { callAsyncFail, callAsyncSuccess, temporarilyNotSupport, validateParams } from '../utils'
20
+ import { MethodHandler } from '../utils/handler'
21
+
22
+ import type Taro from '@tarojs/taro/types'
23
+
24
+ interface ILocation {
25
+ latitude: number
26
+ longitude: number
27
+ altitude: number
28
+ accuracy: number
29
+ speed: number
30
+ }
31
+
32
+ // 位置
33
+ export const stopLocationUpdate = /* @__PURE__ */ temporarilyNotSupport('stopLocationUpdate')
34
+ export const startLocationUpdateBackground = /* @__PURE__ */ temporarilyNotSupport('startLocationUpdateBackground')
35
+ export const startLocationUpdate = /* @__PURE__ */ temporarilyNotSupport('startLocationUpdate')
36
+ export const openLocation = /* @__PURE__ */ temporarilyNotSupport('openLocation')
37
+
38
+ function formatLocation (location: ILocation) {
39
+ const wxLocate = {
40
+ latitude: location.latitude,
41
+ longitude: location.longitude,
42
+ altitude: location.altitude,
43
+ accuracy: location.accuracy,
44
+ speed: location.speed,
45
+ verticalAccuracy: 0, // OHOS 不支持返回此参数,直接设置为默认值
46
+ horizontalAccuracy: 0 // OHOS 不支持返回此参数,直接设置为默认值
47
+ }
48
+ return wxLocate
49
+ }
50
+ // TODO:增加参数校验
51
+ // const getLocationSchema = {
52
+ // type: 'String',
53
+ // altitude: 'Boolean',
54
+ // ishighAccuracy: 'Boolean',
55
+ // highAccuracyExpireTime: 'number'
56
+ // }
57
+
58
+ export const getLocation: typeof Taro.getLocation = function (options = {}) {
59
+ return new Promise((resolve, reject) => {
60
+ /**
61
+ * ohos 有 priority, scenario, maxAccuracy, timeoutMs
62
+ * wx 有 type, altitude, isHighAccuracy, highAccuracyExpireTime
63
+ * 二者参数不一致
64
+ */
65
+ const { type, altitude, isHighAccuracy, highAccuracyExpireTime } = options
66
+ try {
67
+ return geoLocationManager.getCurrentLocation({
68
+ type,
69
+ altitude,
70
+ isHighAccuracy,
71
+ highAccuracyExpireTime
72
+ }).then((location: any) => {
73
+ if (location.code !== 0) {
74
+ callAsyncFail(reject, location, options)
75
+ } else {
76
+ const wxLocate = formatLocation(location.data)
77
+ callAsyncSuccess(resolve, wxLocate, options)
78
+ }
79
+ }).catch(error => {
80
+ callAsyncFail(reject, error, options)
81
+ })
82
+ } catch (error) {
83
+ callAsyncFail(reject, error, options)
84
+ }
85
+ })
86
+ }
87
+
88
+ export const onLocationChange: typeof Taro.onLocationChange = function (callback) {
89
+ const name = 'onLocationChange'
90
+ const handle = new MethodHandler<Partial<Taro.onLocationChange.CallbackResult>>({ name, complete: callback })
91
+ try {
92
+ validateParams(name, [callback], ['Function'])
93
+ geoLocationManager.on('locationChange', {}, (location: any) => {
94
+ if (location) {
95
+ const wxLocate = formatLocation(location)
96
+ callback(wxLocate)
97
+ }
98
+ })
99
+ } catch (error) {
100
+ handle.fail({
101
+ errMsg: error
102
+ })
103
+ }
104
+ }
105
+
106
+ export const offLocationChange: typeof Taro.offLocationChange = function (callback) {
107
+ const name = 'offLocationChange'
108
+ const handle = new MethodHandler<Partial<Taro.onLocationChange.CallbackResult>>({ name, complete: callback })
109
+ try {
110
+ validateParams(name, [callback], ['Function'])
111
+ geoLocationManager.off('locationChange', (location: any) => {
112
+ const status = {
113
+ errCode: 200,
114
+ errMsg: location ? 'offLocationChange is off' : 'offLocationChange err'
115
+ }
116
+
117
+ if (callback) {
118
+ callback(status as any)
119
+ }
120
+ })
121
+ } catch (error) {
122
+ handle.fail({
123
+ errMsg: error
124
+ })
125
+ }
126
+ }
127
+
128
+ export const onLocationChangeError = /* @__PURE__ */ temporarilyNotSupport('onLocationChangeError')
129
+ export const offLocationChangeError = /* @__PURE__ */ temporarilyNotSupport('offLocationChangeError')
130
+
131
+ export const choosePoi = /* @__PURE__ */ temporarilyNotSupport('choosePoi')
132
+ export const chooseLocation = /* @__PURE__ */ temporarilyNotSupport('chooseLocation')
133
+ 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,36 @@
1
+ import audio from '@ohos.multimedia.audio'
2
+
3
+ import { temporarilyNotSupport } from '../../utils'
4
+
5
+ // 音频
6
+
7
+ export const stopVoice = /* @__PURE__ */ temporarilyNotSupport('stopVoice')
8
+ export const setInnerAudioOption = /* @__PURE__ */ temporarilyNotSupport('setInnerAudioOption')
9
+ export const playVoice = /* @__PURE__ */ temporarilyNotSupport('playVoice')
10
+ export const pauseVoice = /* @__PURE__ */ temporarilyNotSupport('pauseVoice')
11
+ export const getAvailableAudioSources = /* @__PURE__ */ temporarilyNotSupport('getAvailableAudioSources')
12
+ export const createWebAudioContext = /* @__PURE__ */ temporarilyNotSupport('createWebAudioContext')
13
+ export const createMediaAudioPlayer = /* @__PURE__ */ temporarilyNotSupport('createMediaAudioPlayer')
14
+
15
+ /**
16
+ * 创建内部 audio 上下文 InnerAudioContext 对象。
17
+ */
18
+ export const createInnerAudioContext = /* @__PURE__ */ temporarilyNotSupport('createInnerAudioContext')
19
+
20
+ export const createAudioContext = /* @__PURE__ */ temporarilyNotSupport('createAudioContext')
21
+
22
+ /** Harmony 专属,更新 audio 状态 */
23
+ export const refreshAudioSession = () => {
24
+ const audioManager = audio.getAudioManager()
25
+ const audioSessionManager = audioManager.getSessionManager()
26
+ if (audioSessionManager) {
27
+ audioSessionManager.deactivateAudioSession().then(() => {
28
+ setTimeout(() => {
29
+ const strategy = {
30
+ concurrencyMode: audio.AudioConcurrencyMode.CONCURRENCY_PAUSE_OTHERS
31
+ }
32
+ audioSessionManager.activateAudioSession(strategy)
33
+ }, 100)
34
+ })
35
+ }
36
+ }
@@ -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
+ }
@@ -0,0 +1,58 @@
1
+ // HarmonyOS 文档链接:https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-media-0000001103383404
2
+ // WX 文档链接:https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.previewMedia.html
3
+ // ✅ wx.previewMedia(Object object)
4
+ // ✅ wx.chooseMedia
5
+
6
+ import photoAccessHelper from '@ohos.file.photoAccessHelper'
7
+
8
+ import { callAsyncFail, callAsyncSuccess, temporarilyNotSupport, validateParams } from '../utils'
9
+
10
+ import type Taro from '@tarojs/taro/types'
11
+
12
+ // TODO: 扩展支持预览video
13
+ export const previewMedia = temporarilyNotSupport('previewMedia')
14
+
15
+ export const chooseMedia: typeof Taro.chooseMedia = function (options) {
16
+ return new Promise((resolve, reject) => {
17
+ try {
18
+ validateParams('chooseMedia', [options], ['Object'])
19
+ } catch (error) {
20
+ const res = { errMsg: error.message }
21
+ return callAsyncFail(reject, res, options)
22
+ }
23
+ const { count = 9, mediaType = ['image'] } = options
24
+
25
+ const mediaTypeAdapter = {
26
+ 0b1: photoAccessHelper.PhotoViewMIMETypes.IMAGE_TYPE,
27
+ 0b10: photoAccessHelper.PhotoViewMIMETypes.VIDEO_TYPE,
28
+ 0b11: photoAccessHelper.PhotoViewMIMETypes.IMAGE_VIDEO_TYPE,
29
+ }
30
+
31
+ const photoViewPicker = new photoAccessHelper.PhotoViewPicker()
32
+ const photoSelectOptions = new photoAccessHelper.PhotoSelectOptions()
33
+ photoSelectOptions.maxSelectNumber = count // 选择媒体文件的最大数目
34
+ photoSelectOptions.MIMEType =
35
+ mediaTypeAdapter[
36
+ mediaType.reduce((acc: number, cur: string) => {
37
+ switch (cur) {
38
+ case 'image':
39
+ return acc | 0b1
40
+ case 'video':
41
+ return acc | 0b10
42
+ default:
43
+ return acc
44
+ }
45
+ }, 0b1)
46
+ ]
47
+ photoSelectOptions.isOriginalSupported = true
48
+ photoViewPicker
49
+ .select(photoSelectOptions)
50
+ .then((photoSelectResult) => {
51
+ const uris = photoSelectResult.photoUris
52
+ callAsyncSuccess(resolve, { tempFilePaths: uris })
53
+ })
54
+ .catch((error) => {
55
+ callAsyncFail(reject, error, options)
56
+ })
57
+ })
58
+ }