@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
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')
@@ -1,26 +1,78 @@
1
+ import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant'
1
2
  // 设备信息,从 API Version 6 开始支持
2
3
  import deviceInfo from '@ohos.deviceInfo'
3
4
  // 显示设备属性,从 API Version 7 开始支持
4
5
  import _display from '@ohos.display'
5
6
  // 从 API Version 7 开始支持
6
7
  import i18n from '@ohos.i18n'
7
- // 设备信息 从API Version 6开始,该接口不再维护,推荐使用新接口'@ohos.deviceInfo'进行设备信息查询
8
- import deviceMethod from '@system.device'
8
+ import { Current, window } from '@tarojs/runtime'
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
- const display = _display.getDefaultDisplaySync()
14
+ let display
15
+ let navigationIndicatorRect
16
+ let safeArea: TaroGeneral.SafeAreaResult | null = null
17
+ let statusBarHeight
18
+ let windowRect
15
19
 
16
- let device
20
+ (Current as any).contextPromise.then((context) => {
21
+ const win = window.__ohos.getLastWindow(context)
22
+ win.then(mainWindow => {
23
+ const topRect = mainWindow.getWindowAvoidArea(window.__ohos.AvoidAreaType.TYPE_SYSTEM).topRect
24
+ navigationIndicatorRect = mainWindow.getWindowAvoidArea(window.__ohos.AvoidAreaType.TYPE_NAVIGATION_INDICATOR).bottomRect
25
+ statusBarHeight = topRect.top + topRect.height
26
+ windowRect = mainWindow.getWindowProperties().windowRect
17
27
 
18
- deviceMethod.getInfo({
19
- success: data => {
20
- device = data
21
- }
28
+ try {
29
+ display = _display.getDefaultDisplaySync()
30
+
31
+ setSafeArea({
32
+ top: statusBarHeight,
33
+ left: 0,
34
+ right: display.width,
35
+ bottom: navigationIndicatorRect?.top
36
+ })
37
+
38
+ // @ts-ignore
39
+ display.getCutoutInfo((err, { boundingRects = [], waterfallDisplayAreaRects = {} }: _display.CutoutInfo = {}) => {
40
+ if (err?.code) {
41
+ console.error('Failed to get cutout info', JSON.stringify(err))
42
+ return
43
+ }
44
+
45
+ const top = Math.max(...boundingRects.map(rect => rect.top + rect.height), waterfallDisplayAreaRects.top?.top + waterfallDisplayAreaRects.top?.height, statusBarHeight)
46
+ const bottom = Math.min(display.height - waterfallDisplayAreaRects.bottom?.top, navigationIndicatorRect?.top)
47
+ const left = waterfallDisplayAreaRects.left?.left + waterfallDisplayAreaRects.left?.width
48
+ const right = display.width - waterfallDisplayAreaRects.right?.left
49
+
50
+ setSafeArea({
51
+ top,
52
+ left,
53
+ right,
54
+ bottom
55
+ })
56
+ })
57
+ } catch (e) {
58
+ console.error('Failed to get display', e)
59
+ }
60
+ })
22
61
  })
23
62
 
63
+
64
+ function setSafeArea({ top, left, right, bottom }) {
65
+ safeArea = {
66
+ top,
67
+ bottom,
68
+ left,
69
+ right,
70
+ height: bottom - top,
71
+ width: right - left,
72
+ }
73
+ }
74
+
75
+
24
76
  /* 同步版本 */
25
77
  export const getSystemInfoSync: typeof Taro.getSystemInfoSync = function () {
26
78
  const res: any = {}
@@ -32,7 +84,7 @@ export const getSystemInfoSync: typeof Taro.getSystemInfoSync = function () {
32
84
  res.cameraAuthorized = null // 允许使用摄像头的开关 boolean
33
85
  res.enableDebug = null // 是否已打开调试 boolean
34
86
  res.fontSizeSetting = null // 用户字体大小(单位px) number
35
- res.language = i18n && i18n.getSystemLanguage && i18n.getSystemLanguage() // string
87
+ res.language = i18n?.getSystemLanguage?.() // string
36
88
  res.locationAuthorized = null // 定位的开关 boolean
37
89
  res.locationEnabled = null // 地理位置的系统开关 boolean
38
90
  res.microphoneAuthorized = null // 麦克风的开关 boolean
@@ -43,17 +95,18 @@ export const getSystemInfoSync: typeof Taro.getSystemInfoSync = function () {
43
95
  res.notificationSoundAuthorized = false // 通知带有声音的开关(仅 iOS 有效)boolean
44
96
  res.phoneCalendarAuthorized = null // 使用日历的开关 boolean
45
97
  res.wifiEnabled = false // Wi-Fi 的系统开关 boolean
46
- res.pixelRatio = null // 设备像素比,number
47
- res.platform = 'android' // 客户端平台 string
48
- res.safeArea = null // 在竖屏正方向下的安全区域 General.SafeAreaResult
49
- res.screenHeight = display && display.height // 屏幕高度,单位px number
50
- res.screenWidth = display && display.width // 屏幕宽度,单位px number
51
- res.statusBarHeight = null // 状态栏的高度,单位px number
52
- res.system = deviceInfo && deviceInfo.osFullName // 操作系统及版本 string
53
- res.theme = null // 系统当前主题,取值为light或dark 'light' | 'dark'
54
- res.windowWidth = device && device.windowWidth // 可使用窗口宽度,单位px number
55
- res.windowHeight = device && device.windowHeight // 可使用窗口高度,单位px number
56
- res.version = deviceInfo && deviceInfo.displayVersion // 版本号 string
98
+ res.pixelRatio = display && display.densityPixels // 设备像素比,number
99
+ res.platform = 'harmony' // 客户端平台 string
100
+ res.safeArea = safeArea // 在竖屏正方向下的安全区域 General.SafeAreaResult
101
+ res.screenHeight = display?.height // 屏幕高度,单位px number
102
+ res.screenWidth = display?.width // 屏幕宽度,单位px number
103
+ res.statusBarHeight = statusBarHeight // 状态栏的高度,单位px number
104
+ res.system = deviceInfo?.osFullName // 操作系统及版本 string
105
+ // Note: 更新配置时才能记录
106
+ res.theme = AppStorage.get('__TARO_APP_CONFIG')?.colorMode === ConfigurationConstant.ColorMode.COLOR_MODE_DARK ? 'dark' : 'light' // 系统当前主题,取值为light或dark 'light' | 'dark'
107
+ res.windowHeight = windowRect?.height // 可使用窗口高度,单位px number
108
+ res.windowWidth = windowRect?.width // 可使用窗口宽度,单位px number
109
+ res.version = deviceInfo?.displayVersion // 版本号 string
57
110
 
58
111
  return res
59
112
  }
@@ -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,27 @@
1
+ import { eventSource } from '@tarojs/runtime'
2
+
3
+ import { temporarilyNotSupport } from '../utils'
4
+
5
+ // @ts-ignore
6
+ import type { TaroCanvasElement } from '@tarojs/runtime'
7
+ // 画布
8
+
9
+ /** 创建离屏 canvas 实例 */
10
+ export const createOffscreenCanvas = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas')
11
+
12
+ /** 创建 canvas 的绘图上下文 CanvasContext 对象 */
13
+ // export const createCanvasContext = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas')
14
+ export const createCanvasContext = (canvasId: string) => {
15
+ const dom = eventSource.get(`canvasId-${canvasId}`)
16
+ // return dom as TaroCanvasElement
17
+ if (dom) return (dom as unknown as TaroCanvasElement).context
18
+ }
19
+
20
+ /** 把当前画布指定区域的内容导出生成指定大小的图片 */
21
+ export const canvasToTempFilePath = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas')
22
+
23
+ /** 将像素数据绘制到画布 */
24
+ export const canvasPutImageData = /* @__PURE__ */ temporarilyNotSupport('createOffscreenCanvas')
25
+
26
+ /** 获取 canvas 区域隐含的像素数据 */
27
+ 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')
@@ -1,11 +1,12 @@
1
1
  // 从 API Version 6 开始支持
2
2
  import pasteboard from '@ohos.pasteboard'
3
+ import promptAction from '@ohos.promptAction'
3
4
  import { isString } from '@tarojs/shared'
4
5
 
5
6
  import { callAsyncFail, getParameterError, object2String } from '../utils'
6
7
  import { MethodHandler } from '../utils/handler'
7
8
 
8
- import type Taro from '@tarojs/api'
9
+ import type Taro from '@tarojs/taro/types'
9
10
 
10
11
  /**
11
12
  * 设置系统剪贴板的内容
@@ -27,9 +28,20 @@ export const setClipboardData: typeof Taro.setClipboardData = function (options)
27
28
 
28
29
  return new Promise((resolve, reject) => {
29
30
  const systemPasteboard = pasteboard.getSystemPasteboard()
30
- const pasteData = pasteboard.createPlainTextData(data)
31
+ const pasteData = pasteboard.createData(pasteboard.MIMETYPE_TEXT_PLAIN, data)
31
32
 
32
- systemPasteboard.setPasteData(pasteData, (error, data) => { // callback形式调用异步接口
33
+ try {
34
+ systemPasteboard.setDataSync(pasteData)
35
+ promptAction.showToast({
36
+ message: '内容已复制',
37
+ duration: 1500,
38
+ bottom: '50%',
39
+ showMode: 1 // 设置弹窗显示模式,显示在应用之上。
40
+ })
41
+ return handle.success({
42
+ data,
43
+ }, { resolve, reject })
44
+ } catch (error) {
33
45
  if (error) {
34
46
  console.error('Failed to set PasteData. Cause: ' + JSON.stringify(error))
35
47
  res = {
@@ -37,12 +49,8 @@ export const setClipboardData: typeof Taro.setClipboardData = function (options)
37
49
  error: error
38
50
  }
39
51
  callAsyncFail(reject, res, options)
40
- } else {
41
- return handle.success({
42
- data,
43
- }, { resolve, reject })
44
52
  }
45
- })
53
+ }
46
54
  })
47
55
  }
48
56
 
@@ -54,7 +62,7 @@ export const getClipboardData: typeof Taro.getClipboardData = function (options)
54
62
  const handle = new MethodHandler({ name: 'getClipboardData', success, fail, complete })
55
63
  return new Promise((resolve, reject) => {
56
64
  const systemPasteboard = pasteboard.getSystemPasteboard()
57
- systemPasteboard.getPasteData((error, pasteData) => { // callback 形式调用异步接口
65
+ systemPasteboard.getData((error, pasteData) => { // callback 形式调用异步接口
58
66
  if (error) {
59
67
  console.error('Failed to obtain PasteData. Cause: ' + JSON.stringify(error))
60
68
  return handle.fail({
@@ -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')