@tarojs/plugin-platform-harmony-ets 3.7.0-alpha.27 → 4.0.0-alpha.2

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 (202) 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 +1 -1
  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 +18 -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 +1 -1
  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 +5 -6
  41. package/dist/apis/index.ts +2 -0
  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} +3 -2
  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 +20 -18
  93. package/dist/apis/ui/{animation.ts → animation/animation.ts} +2 -2
  94. package/dist/apis/ui/animation/index.ts +7 -0
  95. package/dist/apis/ui/background.ts +2 -18
  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 +3 -0
  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 +1 -1
  103. package/dist/apis/{page → ui/scroll}/index.ts +27 -22
  104. package/dist/apis/ui/sticky.ts +4 -0
  105. package/dist/apis/{tabbar/index.ts → ui/tab-bar.ts} +3 -5
  106. package/dist/apis/ui/window.ts +20 -0
  107. package/dist/apis/utils/handler.ts +4 -4
  108. package/dist/apis/worker/index.ts +4 -0
  109. package/dist/apis/wxml/IntersectionObserver.ts +12 -21
  110. package/dist/apis/wxml/index.ts +7 -2
  111. package/dist/apis/wxml/nodesRef.ts +2 -2
  112. package/dist/apis/wxml/selectorQuery.ts +3 -4
  113. package/dist/components-harmony-ets/button.ets +97 -85
  114. package/dist/components-harmony-ets/checkbox.ets +68 -142
  115. package/dist/components-harmony-ets/form.ets +31 -140
  116. package/dist/components-harmony-ets/icon.ets +60 -75
  117. package/dist/components-harmony-ets/image.ets +14 -69
  118. package/dist/components-harmony-ets/innerHtml.ets +6 -74
  119. package/dist/components-harmony-ets/input.ets +62 -152
  120. package/dist/components-harmony-ets/label.ets +63 -96
  121. package/dist/components-harmony-ets/picker.ets +168 -198
  122. package/dist/components-harmony-ets/radio.ets +69 -146
  123. package/dist/components-harmony-ets/richText.ets +14 -70
  124. package/dist/components-harmony-ets/scrollView.ets +84 -156
  125. package/dist/components-harmony-ets/slider.ets +40 -88
  126. package/dist/components-harmony-ets/style.ets +154 -0
  127. package/dist/components-harmony-ets/swiper.ets +25 -166
  128. package/dist/components-harmony-ets/switch.ets +29 -72
  129. package/dist/components-harmony-ets/text.ets +37 -68
  130. package/dist/components-harmony-ets/textArea.ets +44 -132
  131. package/dist/components-harmony-ets/utils/DynamicCenter.ts +2 -11
  132. package/dist/components-harmony-ets/utils/constant/style.ets +9 -6
  133. package/dist/components-harmony-ets/utils/flexManager.ets +45 -92
  134. package/dist/components-harmony-ets/utils/helper.ets +4 -64
  135. package/dist/components-harmony-ets/utils/index.ts +1 -1
  136. package/dist/components-harmony-ets/utils/styles.ets +62 -27
  137. package/dist/components-harmony-ets/video.ets +63 -122
  138. package/dist/components-harmony-ets/view.ets +52 -69
  139. package/dist/components-harmony-ets/webView.ets +50 -0
  140. package/dist/index.js +135 -8
  141. package/dist/index.js.map +1 -1
  142. package/dist/runtime-ets/bom/getComputedStyle.ts +1 -1
  143. package/dist/runtime-ets/bom/window.ts +2 -2
  144. package/dist/runtime-ets/dom/bind.ts +80 -0
  145. package/dist/runtime-ets/dom/class-list.ts +2 -4
  146. package/dist/runtime-ets/dom/comment.ts +1 -2
  147. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +31 -7
  148. package/dist/runtime-ets/dom/dataSource.ts +64 -0
  149. package/dist/runtime-ets/dom/document.ts +35 -47
  150. package/dist/runtime-ets/dom/element/element.ts +163 -0
  151. package/dist/runtime-ets/dom/element/form.ts +406 -0
  152. package/dist/runtime-ets/dom/element/index.ts +92 -0
  153. package/dist/runtime-ets/dom/element/normal.ts +76 -0
  154. package/dist/runtime-ets/dom/element/scrollView.ts +14 -0
  155. package/dist/runtime-ets/dom/element/text.ts +17 -0
  156. package/dist/runtime-ets/dom/element/video.ts +49 -0
  157. package/dist/runtime-ets/dom/element/webView.ts +61 -0
  158. package/dist/runtime-ets/dom/event.ts +24 -1
  159. package/dist/runtime-ets/dom/eventTarget.ts +2 -1
  160. package/dist/runtime-ets/dom/node.ts +87 -44
  161. package/dist/runtime-ets/dom/stylesheet/covertWeb2Hm.ts +624 -0
  162. package/dist/runtime-ets/dom/stylesheet/index.ts +263 -288
  163. package/dist/runtime-ets/dom/stylesheet/type.ts +47 -11
  164. package/dist/runtime-ets/dom/stylesheet/util.ts +129 -7
  165. package/dist/runtime-ets/index.ts +1 -3
  166. package/dist/runtime-ets/interface/event.ts +2 -1
  167. package/dist/runtime-ets/utils/index.ts +18 -8
  168. package/dist/runtime-ets/utils/info.ts +22 -48
  169. package/dist/runtime-framework/react/app.ts +14 -27
  170. package/dist/runtime-framework/react/hooks.ts +3 -3
  171. package/dist/runtime-framework/react/index.ts +1 -0
  172. package/dist/runtime-framework/react/native-page.ts +344 -0
  173. package/dist/runtime-framework/react/page.ts +4 -11
  174. package/dist/runtime-framework/solid/hooks.ts +3 -3
  175. package/dist/runtime-framework/solid/page.ts +0 -6
  176. package/dist/runtime-utils.js +1216 -349
  177. package/dist/runtime-utils.js.map +1 -1
  178. package/dist/runtime.js +1216 -349
  179. package/dist/runtime.js.map +1 -1
  180. package/package.json +12 -11
  181. package/static/media/cancel.svg +1 -0
  182. package/static/media/circle.svg +1 -0
  183. package/static/media/clear.svg +1 -0
  184. package/static/media/download.svg +1 -0
  185. package/static/media/info.svg +1 -0
  186. package/static/media/info_circle.svg +1 -0
  187. package/static/media/search.svg +1 -0
  188. package/static/media/success.svg +1 -0
  189. package/static/media/success_no_circle.svg +1 -0
  190. package/static/media/taro_arrow_left.svg +1 -0
  191. package/static/media/taro_home.svg +1 -0
  192. package/static/media/waiting.svg +1 -0
  193. package/static/media/warn.svg +1 -0
  194. package/types/runtime.d.ts +6 -0
  195. package/LICENSE +0 -160
  196. package/dist/components-harmony-ets/base.ets +0 -63
  197. package/dist/components-harmony-ets/element.ets +0 -223
  198. package/dist/components-harmony-ets/utils/constant/icon.ts +0 -19
  199. package/dist/runtime-ets/dom/element.ts +0 -457
  200. package/dist/runtime-ets/dom/text.ts +0 -19
  201. package/dist/runtime-ets/utils/bind.ts +0 -35
  202. package/types/api.d.ts +0 -4
package/dist/apis/apis.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  export * from './base'
2
+ export * from './canvas'
3
+ export * from './data-analysis'
2
4
  export * from './device'
5
+ export * from './ext'
3
6
  export * from './files'
4
7
  export * from './framework'
5
8
  export * from './location'
@@ -7,9 +10,10 @@ export * from './media'
7
10
  export * from './navigate'
8
11
  export * from './network'
9
12
  export * from './open-api'
10
- export * from './page'
13
+ export * from './payment'
11
14
  export * from './route'
15
+ export * from './share'
12
16
  export * from './storage'
13
- export * from './tabbar'
14
17
  export * from './ui'
18
+ export * from './worker'
15
19
  export * from './wxml'
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 加密
4
+ export const getUserCryptoManager = /* @__PURE__ */ temporarilyNotSupport('getUserCryptoManager')
@@ -0,0 +1,5 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ export const setEnableDebug = /* @__PURE__ */ temporarilyNotSupport('setEnableDebug')
4
+ export const getRealtimeLogManager = /* @__PURE__ */ temporarilyNotSupport('getRealtimeLogManager')
5
+ export const getLogManager = /* @__PURE__ */ temporarilyNotSupport('getLogManager')
@@ -1,5 +1,13 @@
1
1
  import { temporarilyNotSupport } from '../utils'
2
2
 
3
- export const getUpdateManager = temporarilyNotSupport('getUpdateManager')
3
+ export const canIUse = /* @__PURE__ */ temporarilyNotSupport('canIUse')
4
+ export const arrayBufferToBase64 = /* @__PURE__ */ temporarilyNotSupport('arrayBufferToBase64')
5
+ export const base64ToArrayBuffer = /* @__PURE__ */ temporarilyNotSupport('base64ToArrayBuffer')
4
6
 
7
+ export * from './crypto'
8
+ export * from './debug'
9
+ export * from './performance'
5
10
  export * from './system'
11
+ export * from './update'
12
+ export * from './weapp/app-event'
13
+ export * from './weapp/life-cycle'
@@ -0,0 +1,8 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 性能
4
+ export const reportPerformance = /* @__PURE__ */ temporarilyNotSupport('reportPerformance')
5
+ export const getPerformance = /* @__PURE__ */ temporarilyNotSupport('getPerformance')
6
+ export const preloadWebview = /* @__PURE__ */ temporarilyNotSupport('preloadWebview')
7
+ export const preloadSkylineView = /* @__PURE__ */ temporarilyNotSupport('preloadSkylineView')
8
+ export const preloadAssets = /* @__PURE__ */ temporarilyNotSupport('preloadAssets')
@@ -9,7 +9,7 @@ import deviceMethod from '@system.device'
9
9
 
10
10
  import { callAsyncFail, callAsyncSuccess } from '../utils'
11
11
 
12
- import type Taro from '@tarojs/api'
12
+ import type Taro from '@tarojs/taro/types'
13
13
 
14
14
  const display = _display.getDefaultDisplaySync()
15
15
 
@@ -0,0 +1,5 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 更新
4
+ export const updateWeChatApp = /* @__PURE__ */ temporarilyNotSupport('updateWeChatApp')
5
+ export const getUpdateManager = /* @__PURE__ */ temporarilyNotSupport('getUpdateManager')
@@ -0,0 +1,75 @@
1
+ import errorManager from '@ohos.app.ability.errorManager'
2
+
3
+ import { temporarilyNotSupport } from '../../utils'
4
+ import { CallbackManager } from '../../utils/handler'
5
+
6
+ import type Taro from '@tarojs/taro/types'
7
+
8
+ const unhandledRejectionCallbackManager = new CallbackManager<[Taro.onUnhandledRejection.Result]>()
9
+ const errorCallbackManager = new CallbackManager<Parameters<Taro.onError.Callback>>()
10
+
11
+ const unhandledRejectionListener = (res: PromiseRejectionEvent) => {
12
+ unhandledRejectionCallbackManager.trigger(res)
13
+ }
14
+
15
+ const errorListener = (res: ErrorEvent) => {
16
+ // @ts-ignore
17
+ errorCallbackManager.trigger(res.stack || res.message || res)
18
+ }
19
+
20
+ // 应用级事件
21
+ export const onUnhandledRejection: typeof Taro.onUnhandledRejection = callback => {
22
+ unhandledRejectionCallbackManager.add(callback)
23
+ if (unhandledRejectionCallbackManager.count() === 1) {
24
+ errorManager.on('error', {
25
+ unhandledRejectionListener
26
+ })
27
+ }
28
+ }
29
+
30
+ export const onThemeChange = /* @__PURE__ */ temporarilyNotSupport('onThemeChange')
31
+ export const onPageNotFound = /* @__PURE__ */ temporarilyNotSupport('onPageNotFound')
32
+ export const onLazyLoadError = /* @__PURE__ */ temporarilyNotSupport('onLazyLoadError')
33
+
34
+ export const onError: typeof Taro.onError = callback => {
35
+ errorCallbackManager.add(callback)
36
+ if (errorCallbackManager.count() === 1) {
37
+ errorManager.on('error', {
38
+ onException: errorListener
39
+ })
40
+ }
41
+ }
42
+
43
+ export const onAudioInterruptionEnd = /* @__PURE__ */ temporarilyNotSupport('onAudioInterruptionEnd')
44
+ export const onAudioInterruptionBegin = /* @__PURE__ */ temporarilyNotSupport('onAudioInterruptionBegin')
45
+
46
+ export const onAppShow = /* @__PURE__ */ temporarilyNotSupport('onAppShow')
47
+ export const onAppHide = /* @__PURE__ */ temporarilyNotSupport('onAppHide')
48
+
49
+ export const offUnhandledRejection: typeof Taro.offUnhandledRejection = callback => {
50
+ unhandledRejectionCallbackManager.remove(callback)
51
+ if (unhandledRejectionCallbackManager.count() === 0) {
52
+ errorManager.off('error', {
53
+ unhandledRejectionListener
54
+ })
55
+ }
56
+ }
57
+
58
+ export const offThemeChange = /* @__PURE__ */ temporarilyNotSupport('offThemeChange')
59
+ export const offPageNotFound = /* @__PURE__ */ temporarilyNotSupport('offPageNotFound')
60
+ export const offLazyLoadError = /* @__PURE__ */ temporarilyNotSupport('offLazyLoadError')
61
+
62
+ export const offError: typeof Taro.offError = callback => {
63
+ errorCallbackManager.remove(callback)
64
+ if (errorCallbackManager.count() === 0) {
65
+ errorManager.off('error', {
66
+ onException: errorListener
67
+ })
68
+ }
69
+ }
70
+
71
+ export const offAudioInterruptionEnd = /* @__PURE__ */ temporarilyNotSupport('offAudioInterruptionEnd')
72
+ export const offAudioInterruptionBegin = /* @__PURE__ */ temporarilyNotSupport('offAudioInterruptionBegin')
73
+
74
+ export const offAppShow = /* @__PURE__ */ temporarilyNotSupport('offAppShow')
75
+ export const offAppHide = /* @__PURE__ */ temporarilyNotSupport('offAppHide')
@@ -0,0 +1,21 @@
1
+ import { eventCenter } from '@tarojs/runtime/dist/runtime.esm'
2
+
3
+ import type Taro from '@tarojs/taro/types'
4
+
5
+ const launchOptions: Taro.getLaunchOptionsSync.LaunchOptions = {
6
+ path: '',
7
+ query: {},
8
+ scene: 0,
9
+ shareTicket: '',
10
+ referrerInfo: {}
11
+ }
12
+
13
+ function initLaunchOptions (options = {}) {
14
+ Object.assign(launchOptions, options)
15
+ }
16
+
17
+ eventCenter.once('__taroRouterLaunch', initLaunchOptions)
18
+
19
+ // 生命周期
20
+ export const getLaunchOptionsSync: typeof Taro.getLaunchOptionsSync = () => launchOptions
21
+ export const getEnterOptionsSync: typeof Taro.getEnterOptionsSync = () => launchOptions
@@ -0,0 +1,18 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 画布
4
+
5
+ /** 创建离屏 canvas 实例 */
6
+ export const createOffscreenCanvas = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas')
7
+
8
+ /** 创建 canvas 的绘图上下文 CanvasContext 对象 */
9
+ export const createCanvasContext = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas')
10
+
11
+ /** 把当前画布指定区域的内容导出生成指定大小的图片 */
12
+ export const canvasToTempFilePath = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas')
13
+
14
+ /** 将像素数据绘制到画布 */
15
+ export const canvasPutImageData = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas')
16
+
17
+ /** 获取 canvas 区域隐含的像素数据 */
18
+ export const canvasGetImageData = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas')
@@ -0,0 +1,6 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ export const reportMonitor = /* @__PURE__ */ temporarilyNotSupport('reportMonitor')
4
+ export const reportAnalytics = /* @__PURE__ */ temporarilyNotSupport('reportAnalytics')
5
+ export const reportEvent = /* @__PURE__ */ temporarilyNotSupport('reportEvent')
6
+ export const getExptInfoSync = /* @__PURE__ */ temporarilyNotSupport('getExptInfoSync')
@@ -1,8 +1,9 @@
1
1
  import sensor from '@ohos.sensor'
2
- import Taro from '@tarojs/taro'
3
2
 
4
3
  import { CallbackManager, MethodHandler } from '../utils/handler'
5
4
 
5
+ import type Taro from '@tarojs/taro/types'
6
+
6
7
  const callbackManager = new CallbackManager()
7
8
  let devicemotionListener
8
9
 
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 无障碍
4
+ export const checkIsOpenAccessibility = /* @__PURE__ */ temporarilyNotSupport('checkIsOpenAccessibility')
@@ -2,7 +2,7 @@ import batteryInfo, { BatteryChargeState } from '@ohos.batteryInfo'
2
2
 
3
3
  import { MethodHandler } from '../utils/handler'
4
4
 
5
- import type Taro from '@tarojs/api'
5
+ import type Taro from '@tarojs/taro/types'
6
6
 
7
7
  // 电量
8
8
 
@@ -13,7 +13,7 @@ export const getBatteryInfoSync: typeof Taro.getBatteryInfoSync = () => ({
13
13
  })
14
14
 
15
15
  export const getBatteryInfo: typeof Taro.getBatteryInfo = async ({ success, fail, complete } = {}) => {
16
- const handle = new MethodHandler({ name: 'getBatteryInfo', success, fail, complete })
16
+ const handle = new MethodHandler<Taro.getBatteryInfo.SuccessCallbackResult>({ name: 'getBatteryInfo', success, fail, complete })
17
17
  try {
18
18
  return handle.success(getBatteryInfoSync())
19
19
  } catch (error) {
@@ -0,0 +1,19 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 蓝牙-低功耗中心设备
4
+ export const writeBLECharacteristicValue = /* @__PURE__ */ temporarilyNotSupport('writeBLECharacteristicValue')
5
+ export const setBLEMTU = /* @__PURE__ */ temporarilyNotSupport('setBLEMTU')
6
+ export const readBLECharacteristicValue = /* @__PURE__ */ temporarilyNotSupport('readBLECharacteristicValue')
7
+ export const onBLEMTUChange = /* @__PURE__ */ temporarilyNotSupport('onBLEMTUChange')
8
+ export const onBLEConnectionStateChange = /* @__PURE__ */ temporarilyNotSupport('onBLEConnectionStateChange')
9
+ export const onBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('onBLECharacteristicValueChange')
10
+ export const offBLEMTUChange = /* @__PURE__ */ temporarilyNotSupport('offBLEMTUChange')
11
+ export const offBLEConnectionStateChange = /* @__PURE__ */ temporarilyNotSupport('offBLEConnectionStateChange')
12
+ export const offBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('offBLECharacteristicValueChange')
13
+ export const notifyBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('notifyBLECharacteristicValueChange')
14
+ export const getBLEMTU = /* @__PURE__ */ temporarilyNotSupport('getBLEMTU')
15
+ export const getBLEDeviceServices = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceServices')
16
+ export const getBLEDeviceRSSI = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceRSSI')
17
+ export const getBLEDeviceCharacteristics = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceCharacteristics')
18
+ export const createBLEConnection = /* @__PURE__ */ temporarilyNotSupport('createBLEConnection')
19
+ export const closeBLEConnection = /* @__PURE__ */ temporarilyNotSupport('closeBLEConnection')
@@ -0,0 +1,6 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 蓝牙-低功耗外围设备
4
+ export const onBLEPeripheralConnectionStateChanged = /* @__PURE__ */ temporarilyNotSupport('onBLEPeripheralConnectionStateChanged')
5
+ export const offBLEPeripheralConnectionStateChanged = /* @__PURE__ */ temporarilyNotSupport('offBLEPeripheralConnectionStateChanged')
6
+ export const createBLEPeripheralServer = /* @__PURE__ */ temporarilyNotSupport('createBLEPeripheralServer')
@@ -0,0 +1,16 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 蓝牙-通用
4
+ export const stopBluetoothDevicesDiscovery = /* @__PURE__ */ temporarilyNotSupport('stopBluetoothDevicesDiscovery')
5
+ export const startBluetoothDevicesDiscovery = /* @__PURE__ */ temporarilyNotSupport('startBluetoothDevicesDiscovery')
6
+ export const openBluetoothAdapter = /* @__PURE__ */ temporarilyNotSupport('openBluetoothAdapter')
7
+ export const onBluetoothDeviceFound = /* @__PURE__ */ temporarilyNotSupport('onBluetoothDeviceFound')
8
+ export const onBluetoothAdapterStateChange = /* @__PURE__ */ temporarilyNotSupport('onBluetoothAdapterStateChange')
9
+ export const offBluetoothDeviceFound = /* @__PURE__ */ temporarilyNotSupport('offBluetoothDeviceFound')
10
+ export const offBluetoothAdapterStateChange = /* @__PURE__ */ temporarilyNotSupport('offBluetoothAdapterStateChange')
11
+ export const makeBluetoothPair = /* @__PURE__ */ temporarilyNotSupport('makeBluetoothPair')
12
+ export const isBluetoothDevicePaired = /* @__PURE__ */ temporarilyNotSupport('isBluetoothDevicePaired')
13
+ export const getConnectedBluetoothDevices = /* @__PURE__ */ temporarilyNotSupport('getConnectedBluetoothDevices')
14
+ export const getBluetoothDevices = /* @__PURE__ */ temporarilyNotSupport('getBluetoothDevices')
15
+ export const getBluetoothAdapterState = /* @__PURE__ */ temporarilyNotSupport('getBluetoothAdapterState')
16
+ export const closeBluetoothAdapter = /* @__PURE__ */ temporarilyNotSupport('closeBluetoothAdapter')
@@ -0,0 +1,5 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 日历
4
+ export const addPhoneRepeatCalendar = temporarilyNotSupport('addPhoneRepeatCalendar')
5
+ export const addPhoneCalendar = temporarilyNotSupport('addPhoneCalendar')
@@ -5,7 +5,7 @@ import { isString } from '@tarojs/shared'
5
5
  import { callAsyncFail, getParameterError, object2String } from '../utils'
6
6
  import { MethodHandler } from '../utils/handler'
7
7
 
8
- import type Taro from '@tarojs/api'
8
+ import type Taro from '@tarojs/taro/types'
9
9
 
10
10
  /**
11
11
  * 设置系统剪贴板的内容
@@ -0,0 +1,21 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ /**
4
+ * 停止监听罗盘数据
5
+ */
6
+ export const stopCompass = temporarilyNotSupport('stopCompass')
7
+
8
+ /**
9
+ * 开始监听罗盘数据
10
+ */
11
+ export const startCompass = temporarilyNotSupport('startCompass')
12
+
13
+ /**
14
+ * 监听罗盘数据变化事件。频率:5 次/秒,接口调用后会自动开始监听,可使用 wx.stopCompass 停止监听。
15
+ */
16
+ export const onCompassChange = temporarilyNotSupport('onCompassChange')
17
+
18
+ /**
19
+ * 取消监听罗盘数据变化事件,参数为空,则取消所有的事件监听。
20
+ */
21
+ export const offCompassChange = temporarilyNotSupport('offCompassChange')
@@ -0,0 +1,5 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 联系人
4
+ export const chooseContact = /* @__PURE__ */ temporarilyNotSupport('chooseContact')
5
+ export const addPhoneContact = /* @__PURE__ */ temporarilyNotSupport('addPhoneContact')
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 加密
4
+ export const getRandomValues = /* @__PURE__ */ temporarilyNotSupport('getRandomValues')
@@ -0,0 +1,7 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 陀螺仪
4
+ export const stopGyroscope = /* @__PURE__ */ temporarilyNotSupport('stopGyroscope')
5
+ export const startGyroscope = /* @__PURE__ */ temporarilyNotSupport('startGyroscope')
6
+ export const onGyroscopeChange = /* @__PURE__ */ temporarilyNotSupport('onGyroscopeChange')
7
+ export const offGyroscopeChange = /* @__PURE__ */ temporarilyNotSupport('offGyroscopeChange')
@@ -0,0 +1,10 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 蓝牙-信标(Beacon)
4
+ export const stopBeaconDiscovery = /* @__PURE__ */ temporarilyNotSupport('stopBeaconDiscovery')
5
+ export const startBeaconDiscovery = /* @__PURE__ */ temporarilyNotSupport('startBeaconDiscovery')
6
+ export const onBeaconUpdate = /* @__PURE__ */ temporarilyNotSupport('onBeaconUpdate')
7
+ export const onBeaconServiceChange = /* @__PURE__ */ temporarilyNotSupport('onBeaconServiceChange')
8
+ export const offBeaconUpdate = /* @__PURE__ */ temporarilyNotSupport('offBeaconUpdate')
9
+ export const offBeaconServiceChange = /* @__PURE__ */ temporarilyNotSupport('offBeaconServiceChange')
10
+ export const getBeacons = /* @__PURE__ */ temporarilyNotSupport('getBeacons')
@@ -1,9 +1,24 @@
1
1
  export * from './accelerometer'
2
+ export * from './accessibility'
2
3
  export * from './battery'
4
+ export * from './bluetooth'
5
+ export * from './bluetooth-ble'
6
+ export * from './bluetooth-peripheral'
7
+ export * from './calendar'
3
8
  export * from './clipboard'
9
+ export * from './compass'
10
+ export * from './contact'
11
+ export * from './crypto'
12
+ export * from './gyroscope'
13
+ export * from './iBeacon'
4
14
  export * from './keyboard'
5
15
  export * from './memory'
16
+ export * from './motion'
6
17
  export * from './network'
18
+ export * from './nfc'
7
19
  export * from './phone'
20
+ export * from './scan'
8
21
  export * from './screen'
22
+ export * from './sms'
9
23
  export * from './vibrate'
24
+ export * from './wifi'
@@ -1,10 +1,11 @@
1
1
  import inputMethodEngine from '@ohos.inputMethodEngine'
2
2
  import { Current, window } from '@tarojs/runtime'
3
- import Taro from '@tarojs/taro'
4
3
 
5
4
  import { temporarilyNotSupport } from '../utils'
6
5
  import { CallbackManager, MethodHandler } from '../utils/handler'
7
6
 
7
+ import type Taro from '@tarojs/taro/types'
8
+
8
9
  const callbackManager = new CallbackManager()
9
10
 
10
11
  const resizeListener = (height) => {
@@ -1,4 +1,11 @@
1
- import { temporarilyNotSupport } from '../utils'
1
+ import { hooks } from '@tarojs/runtime'
2
2
 
3
- export const onMemoryWarning = temporarilyNotSupport('onMemoryWarning')
4
- export const offMemoryWarning = temporarilyNotSupport('offMemoryWarning')
3
+ export const onMemoryWarning = (listener) => {
4
+ hooks.tap('getMemoryLevel', (res) => {
5
+ listener(res)
6
+ })
7
+ }
8
+
9
+ export const offMemoryWarning = (listener) => {
10
+ hooks.off('getMemoryLevel', listener)
11
+ }
@@ -0,0 +1,6 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ export const stopDeviceMotionListening = temporarilyNotSupport('stopDeviceMotionListening')
4
+ export const startDeviceMotionListening = temporarilyNotSupport('startDeviceMotionListening')
5
+ export const onDeviceMotionChange = temporarilyNotSupport('onDeviceMotionChange')
6
+ export const offDeviceMotionChange = temporarilyNotSupport('offDeviceMotionChange')
@@ -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