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

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 (212) hide show
  1. package/LICENSE +160 -0
  2. package/dist/apis/apis.ts +15 -0
  3. package/dist/apis/base/index.ts +5 -0
  4. package/dist/apis/base/system.ts +77 -0
  5. package/dist/apis/device/accelerometer.ts +76 -0
  6. package/dist/apis/device/battery.ts +24 -0
  7. package/dist/apis/device/clipboard.ts +70 -0
  8. package/dist/apis/device/index.ts +9 -0
  9. package/dist/apis/device/keyboard.ts +62 -0
  10. package/dist/apis/device/memory.ts +4 -0
  11. package/dist/apis/device/network.ts +72 -0
  12. package/dist/apis/device/phone.ts +43 -0
  13. package/dist/apis/device/screen.ts +79 -0
  14. package/dist/apis/device/vibrate.ts +24 -0
  15. package/dist/apis/files/index.ts +135 -0
  16. package/dist/apis/files/manager.ts +941 -0
  17. package/dist/apis/framework/index.ts +32 -0
  18. package/dist/apis/index.ts +124 -0
  19. package/dist/apis/location/index.ts +133 -0
  20. package/dist/apis/media/common.ts +74 -0
  21. package/dist/apis/media/image.ts +122 -0
  22. package/dist/apis/media/index.ts +3 -0
  23. package/dist/apis/media/video.ts +86 -0
  24. package/dist/apis/navigate/index.ts +8 -0
  25. package/dist/apis/network/downloadFile.ts +113 -0
  26. package/dist/apis/network/index.ts +4 -0
  27. package/dist/apis/network/request.ts +113 -0
  28. package/dist/apis/network/uploadFile.ts +158 -0
  29. package/dist/apis/network/webSocket.ts +130 -0
  30. package/dist/apis/open-api/index.ts +7 -0
  31. package/dist/apis/open-api/user-info/index.ts +85 -0
  32. package/dist/apis/page/index.ts +92 -0
  33. package/dist/apis/route/index.ts +138 -0
  34. package/dist/apis/storage/index.ts +133 -0
  35. package/dist/apis/tabbar/index.ts +147 -0
  36. package/dist/apis/ui/animation.ts +222 -0
  37. package/dist/apis/ui/background.ts +35 -0
  38. package/dist/apis/ui/index.ts +14 -0
  39. package/dist/apis/ui/interaction/index.ts +195 -0
  40. package/dist/apis/ui/navigation-bar/index.ts +33 -0
  41. package/dist/apis/ui/pull-down-refresh.ts +41 -0
  42. package/dist/apis/utils/handler.ts +116 -0
  43. package/dist/apis/utils/index.ts +85 -0
  44. package/dist/apis/utils/types.ts +12 -0
  45. package/dist/apis/utils/validate.ts +87 -0
  46. package/dist/apis/wxml/IntersectionObserver.ts +119 -0
  47. package/dist/apis/wxml/index.ts +12 -0
  48. package/dist/apis/wxml/nodesRef.ts +56 -0
  49. package/dist/apis/wxml/selectorQuery.ts +287 -0
  50. package/dist/components/components-react.js +51 -0
  51. package/dist/components/components-react.js.map +1 -0
  52. package/dist/components-harmony/button/index.css +109 -0
  53. package/dist/components-harmony/button/index.hml +31 -0
  54. package/dist/components-harmony/button/index.js +105 -0
  55. package/dist/components-harmony/camera/index.hml +6 -0
  56. package/dist/components-harmony/camera/index.js +12 -0
  57. package/dist/components-harmony/checkbox/index.hml +11 -0
  58. package/dist/components-harmony/checkbox/index.js +60 -0
  59. package/dist/components-harmony/checkbox-group/index.hml +3 -0
  60. package/dist/components-harmony/checkbox-group/index.js +22 -0
  61. package/dist/components-harmony/cover-image/index.css +4 -0
  62. package/dist/components-harmony/cover-image/index.hml +9 -0
  63. package/dist/components-harmony/cover-image/index.js +15 -0
  64. package/dist/components-harmony/form/index.hml +10 -0
  65. package/dist/components-harmony/form/index.js +11 -0
  66. package/dist/components-harmony/icon/index.css +27 -0
  67. package/dist/components-harmony/icon/index.hml +54 -0
  68. package/dist/components-harmony/icon/index.js +17 -0
  69. package/dist/components-harmony/image/index.css +5 -0
  70. package/dist/components-harmony/image/index.hml +11 -0
  71. package/dist/components-harmony/image/index.js +28 -0
  72. package/dist/components-harmony/input/index.hml +21 -0
  73. package/dist/components-harmony/input/index.js +98 -0
  74. package/dist/components-harmony/label/index.hml +3 -0
  75. package/dist/components-harmony/label/index.js +6 -0
  76. package/dist/components-harmony/navbar/index.css +56 -0
  77. package/dist/components-harmony/navbar/index.hml +9 -0
  78. package/dist/components-harmony/navbar/index.js +30 -0
  79. package/dist/components-harmony/navigator/index.css +8 -0
  80. package/dist/components-harmony/navigator/index.hml +9 -0
  81. package/dist/components-harmony/navigator/index.js +104 -0
  82. package/dist/components-harmony/picker/index.hml +25 -0
  83. package/dist/components-harmony/picker/index.js +132 -0
  84. package/dist/components-harmony/picker-view/index.hml +23 -0
  85. package/dist/components-harmony/picker-view/index.js +161 -0
  86. package/dist/components-harmony/picker-view-column/index.hml +3 -0
  87. package/dist/components-harmony/picker-view-column/index.js +3 -0
  88. package/dist/components-harmony/progress/index.css +4 -0
  89. package/dist/components-harmony/progress/index.hml +28 -0
  90. package/dist/components-harmony/progress/index.js +23 -0
  91. package/dist/components-harmony/radio/index.hml +11 -0
  92. package/dist/components-harmony/radio/index.js +41 -0
  93. package/dist/components-harmony/radio-group/index.hml +3 -0
  94. package/dist/components-harmony/radio-group/index.js +11 -0
  95. package/dist/components-harmony/rich-text/index.hml +5 -0
  96. package/dist/components-harmony/rich-text/index.js +16 -0
  97. package/dist/components-harmony/scroll-view/index.css +5 -0
  98. package/dist/components-harmony/scroll-view/index.hml +12 -0
  99. package/dist/components-harmony/scroll-view/index.js +65 -0
  100. package/dist/components-harmony/slider/index.hml +16 -0
  101. package/dist/components-harmony/slider/index.js +53 -0
  102. package/dist/components-harmony/swiper/index.css +3 -0
  103. package/dist/components-harmony/swiper/index.hml +14 -0
  104. package/dist/components-harmony/swiper/index.js +19 -0
  105. package/dist/components-harmony/switch/index.hml +7 -0
  106. package/dist/components-harmony/switch/index.js +16 -0
  107. package/dist/components-harmony/tabbar/index.css +7 -0
  108. package/dist/components-harmony/tabbar/index.hml +26 -0
  109. package/dist/components-harmony/tabbar/index.js +42 -0
  110. package/dist/components-harmony/textarea/index.hml +24 -0
  111. package/dist/components-harmony/textarea/index.js +92 -0
  112. package/dist/components-harmony/utils/index.js +41 -0
  113. package/dist/components-harmony/video/index.hml +7 -0
  114. package/dist/components-harmony/video/index.js +73 -0
  115. package/dist/components-harmony/web-view/index.hml +8 -0
  116. package/dist/components-harmony/web-view/index.js +22 -0
  117. package/dist/components-harmony-ets/base.ets +63 -0
  118. package/dist/components-harmony-ets/button.ets +119 -0
  119. package/dist/components-harmony-ets/checkbox.ets +219 -0
  120. package/dist/components-harmony-ets/element.ets +223 -0
  121. package/dist/components-harmony-ets/form.ets +149 -0
  122. package/dist/components-harmony-ets/icon.ets +84 -0
  123. package/dist/components-harmony-ets/image.ets +85 -0
  124. package/dist/components-harmony-ets/index.ts +49 -0
  125. package/dist/components-harmony-ets/innerHtml.ets +79 -0
  126. package/dist/components-harmony-ets/input.ets +195 -0
  127. package/dist/components-harmony-ets/label.ets +111 -0
  128. package/dist/components-harmony-ets/picker.ets +370 -0
  129. package/dist/components-harmony-ets/radio.ets +225 -0
  130. package/dist/components-harmony-ets/richText.ets +97 -0
  131. package/dist/components-harmony-ets/scrollView.ets +199 -0
  132. package/dist/components-harmony-ets/slider.ets +159 -0
  133. package/dist/components-harmony-ets/swiper.ets +204 -0
  134. package/dist/components-harmony-ets/switch.ets +113 -0
  135. package/dist/components-harmony-ets/text.ets +97 -0
  136. package/dist/components-harmony-ets/textArea.ets +169 -0
  137. package/dist/components-harmony-ets/utils/AttributeManager.ets +250 -0
  138. package/dist/components-harmony-ets/utils/DynamicCenter.ts +48 -0
  139. package/dist/components-harmony-ets/utils/constant/event.ets +25 -0
  140. package/dist/components-harmony-ets/utils/constant/icon.ts +19 -0
  141. package/dist/components-harmony-ets/utils/constant/style.ets +88 -0
  142. package/dist/components-harmony-ets/utils/events.ts +24 -0
  143. package/dist/components-harmony-ets/utils/flexManager.ets +107 -0
  144. package/dist/components-harmony-ets/utils/helper.ets +99 -0
  145. package/dist/components-harmony-ets/utils/htmlParser/HarmonyHTMLParser.ts +103 -0
  146. package/dist/components-harmony-ets/utils/htmlParser/index.ts +56 -0
  147. package/dist/components-harmony-ets/utils/index.ts +83 -0
  148. package/dist/components-harmony-ets/utils/styles.ets +91 -0
  149. package/dist/components-harmony-ets/video.ets +161 -0
  150. package/dist/components-harmony-ets/view.ets +79 -0
  151. package/dist/index.js +1183 -0
  152. package/dist/index.js.map +1 -0
  153. package/dist/runtime-ets/bom/document.ts +38 -0
  154. package/dist/runtime-ets/bom/getComputedStyle.ts +5 -0
  155. package/dist/runtime-ets/bom/navigator.ts +21 -0
  156. package/dist/runtime-ets/bom/raf.ts +37 -0
  157. package/dist/runtime-ets/bom/window.ts +44 -0
  158. package/dist/runtime-ets/constant.ts +29 -0
  159. package/dist/runtime-ets/current.ts +16 -0
  160. package/dist/runtime-ets/dom/class-list.ts +117 -0
  161. package/dist/runtime-ets/dom/comment.ts +10 -0
  162. package/dist/runtime-ets/dom/cssStyleDeclaration.ts +105 -0
  163. package/dist/runtime-ets/dom/document.ts +108 -0
  164. package/dist/runtime-ets/dom/element.ts +457 -0
  165. package/dist/runtime-ets/dom/event.ts +164 -0
  166. package/dist/runtime-ets/dom/eventTarget.ts +98 -0
  167. package/dist/runtime-ets/dom/node.ts +215 -0
  168. package/dist/runtime-ets/dom/stylesheet/index.ts +687 -0
  169. package/dist/runtime-ets/dom/stylesheet/type.ts +136 -0
  170. package/dist/runtime-ets/dom/stylesheet/util.ts +134 -0
  171. package/dist/runtime-ets/dom/text.ts +19 -0
  172. package/dist/runtime-ets/index.ts +19 -0
  173. package/dist/runtime-ets/interface/event.ts +9 -0
  174. package/dist/runtime-ets/interface/index.ts +1 -0
  175. package/dist/runtime-ets/utils/bind.ts +35 -0
  176. package/dist/runtime-ets/utils/index.ts +135 -0
  177. package/dist/runtime-ets/utils/info.ts +128 -0
  178. package/dist/runtime-framework/react/app.ts +256 -0
  179. package/dist/runtime-framework/react/connect.ts +24 -0
  180. package/dist/runtime-framework/react/constant.ts +5 -0
  181. package/dist/runtime-framework/react/hooks.ts +101 -0
  182. package/dist/runtime-framework/react/index.ts +16 -0
  183. package/dist/runtime-framework/react/page.ts +263 -0
  184. package/dist/runtime-framework/react/utils/index.ts +25 -0
  185. package/dist/runtime-framework/react/utils/is.ts +46 -0
  186. package/dist/runtime-framework/solid/README.md +99 -0
  187. package/dist/runtime-framework/solid/app.ts +200 -0
  188. package/dist/runtime-framework/solid/connect.ts +11 -0
  189. package/dist/runtime-framework/solid/contant.ts +5 -0
  190. package/dist/runtime-framework/solid/hooks.ts +88 -0
  191. package/dist/runtime-framework/solid/index.ts +10 -0
  192. package/dist/runtime-framework/solid/page.ts +202 -0
  193. package/dist/runtime-framework/solid/reconciler/h.ts +132 -0
  194. package/dist/runtime-framework/solid/reconciler/index.ts +3 -0
  195. package/dist/runtime-framework/solid/reconciler/props.ts +151 -0
  196. package/dist/runtime-framework/solid/reconciler/render.ts +61 -0
  197. package/dist/runtime-framework/solid/reconciler/use.ts +8 -0
  198. package/dist/runtime-framework/solid/utils/index.ts +49 -0
  199. package/dist/runtime-framework/solid/utils/is.ts +46 -0
  200. package/dist/runtime-utils.js +4149 -0
  201. package/dist/runtime-utils.js.map +1 -0
  202. package/dist/runtime.js +4150 -0
  203. package/dist/runtime.js.map +1 -0
  204. package/dist/template/container.js +7 -0
  205. package/index.js +4 -0
  206. package/package.json +54 -0
  207. package/types/api.d.ts +4 -0
  208. package/types/component.d.ts +4 -0
  209. package/types/harmony.d.ts +11 -0
  210. package/types/runtime.d.ts +15 -0
  211. package/types/taro.d.ts +7 -0
  212. package/types/webpack-sources.d.ts +108 -0
package/LICENSE ADDED
@@ -0,0 +1,160 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 O2Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ ========================================================================
24
+
25
+ MIT (react-devtools):
26
+ The following files embed [react-devtools](https://github.com/facebook/react) MIT:
27
+ `/packages/taro-plugin-react-devtools/src/backend/index.js`
28
+ See `/LICENSE` for details of the license.
29
+
30
+ ==================
31
+
32
+ MIT (vue-devtools):
33
+ The following files embed [vue-devtools](https://github.com/vuejs/devtools) MIT:
34
+ `/packages/taro-plugin-vue-devtools/src/backend/*`
35
+ See `/LICENSE` for details of the license.
36
+
37
+ ==================
38
+
39
+ MIT (vite):
40
+ The following files embed [vite](https://github.com/vitejs/vite) MIT:
41
+ `/packages/taro-webpack5-prebundle/src/prebundle/scanImport.ts`,
42
+ `/packages/taro-webpack5-prebundle/src/prebundle/bundle.ts`,
43
+ `/packages/taro-webpack5-prebundle/src/h5.ts`,
44
+ `/packages/taro-webpack5-prebundle/src/min.ts`
45
+ See `/LICENSE` for details of the license.
46
+
47
+ ==================
48
+
49
+ MIT (webpack):
50
+ The following files embed [webpack](https://github.com/webpack/webpack) MIT:
51
+ `/packages/taro-webpack5-prebundle/src/webpack/TaroContainerEntryModule.ts`,
52
+ `/packages/taro-webpack5-prebundle/src/webpack/TaroContainerPlugin.ts`,
53
+ `/packages/taro-webpack5-prebundle/src/webpack/TaroContainerReferencePlugin.ts`,
54
+ `/packages/taro-webpack5-prebundle/src/webpack/TaroModuleFederationPlugin.ts`
55
+ See `/LICENSE` for details of the license.
56
+
57
+ ==================
58
+
59
+ MIT (sizzle):
60
+ The following files embed [sizzle](https://github.com/jquery/sizzle) MIT:
61
+ `/packages/taro-extends/src/jquery/sizzle.js`
62
+ See `/LICENSE.txt` for details of the license.
63
+
64
+ ==================
65
+
66
+ MIT (zepto):
67
+ The following files embed [zepto](https://github.com/madrobby/zepto) MIT:
68
+ `/packages/taro-extends/src/jquery/zepto.js`,
69
+ `/packages/taro-extends/src/jquery/event.js`
70
+ See `/MIT-LICENSE` for details of the license.
71
+
72
+ ==================
73
+
74
+ MIT (css-to-react-native):
75
+ The following files embed [css-to-react-native](https://github.com/styled-components/css-to-react-native) MIT:
76
+ `/packages/css-to-react-native/src/css-to-react-native/*`
77
+ See `/LICENSE.md` for details of the license.
78
+
79
+ ==================
80
+
81
+ MIT (reactify-wc):
82
+ The following files embed [reactify-wc](https://github.com/BBKolton/reactify-wc) MIT:
83
+ `/packages/taro-components-library-react/src/component-lib/reactify-wc.ts`
84
+ See `/LICENSE` for details of the license.
85
+
86
+ ==================
87
+
88
+ MIT (ant-design-mobile-rn):
89
+ The following files embed [ant-design-mobile-rn](https://github.com/ant-design/ant-design-mobile-rn) MIT:
90
+ `/packages/taro-components-rn/src/components/Swiper/carousel.tsx`
91
+ See `/LICENSE` for details of the license.
92
+
93
+ ==================
94
+
95
+ MIT (react-wx-images-viewer):
96
+ The following files embed [react-wx-images-viewer](https://github.com/react-ld/react-wx-images-viewer) MIT:
97
+ `/packages/taro-h5/src/api/media/image/previewImage.ts`
98
+ See `/LICENSE` for details of the license.
99
+
100
+ ==================
101
+
102
+ MIT (webpack-contrib/css-loader):
103
+ The following files embed [webpack-contrib/css-loader](https://github.com/webpack-contrib/css-loader) MIT:
104
+ `/packages/taro-rn-style-transformer/src/utils/index.ts`
105
+ See `/LICENSE` for details of the license.
106
+
107
+ ==================
108
+
109
+ MIT (react-native):
110
+ The following files embed [react-native](https://github.com/facebook/react-native) MIT:
111
+ `/packages/taro-rn-style-transformer/src/transforms/StyleSheet/*`
112
+ See `/LICENSE` for details of the license.
113
+
114
+ ==================
115
+
116
+ MIT (myrne/performance-now):
117
+ The following files embed [myrne/performance-now](https://github.com/myrne/performance-now) MIT:
118
+ `/packages/taro-runtime/src/bom/raf.ts`
119
+ See `/LICENSE` for details of the license.
120
+
121
+ ==================
122
+
123
+ Apache (chameleon-api):
124
+ The following files embed [chameleon-api](https://github.com/chameleon-team/chameleon-api) Apache:
125
+ `/packages/taro-h5/src/api/device/clipboard.ts`
126
+
127
+ ==================
128
+
129
+ MIT (uni-app):
130
+ The following files embed [uni-app](https://github.com/dcloudio/uni-app) MIT:
131
+ `/packages/taro-components-rn/src/components/Video/index.tsx`
132
+ See `/LICENSE` for details of the license.
133
+
134
+ ==================
135
+
136
+ MIT (miniprogram-render):
137
+ The following files embed [miniprogram-render](https://github.com/Tencent/kbone) MIT:
138
+ `/packages/taro-plugin-http/src/runtime/Cookie.ts`
139
+ See `/LICENSE` for details of the license.
140
+
141
+ ==================
142
+
143
+ MIT (stencil-ds-output-targets):
144
+ The following files embed [stencil-ds-output-targets](https://github.com/ionic-team/stencil-ds-output-targets/) MIT:
145
+ `/packages/taro-components-library-react/src/react-component-lib/utils/attachProps.ts`
146
+ `/packages/taro-components-library-react/src/react-component-lib/utils/case.ts`
147
+ `/packages/taro-components-library-react/src/react-component-lib/utils/dev.ts`
148
+ `/packages/taro-components-library-react/src/react-component-lib/utils/index.tsx`
149
+ `/packages/taro-components-library-react/src/react-component-lib/createComponent.tsx`
150
+ `/packages/taro-components-library-react/src/react-component-lib/createOverlayComponent.tsx`
151
+ `/packages/taro-components-library-react/src/react-component-lib/interfaces.ts`
152
+ `/packages/taro-components-library-vue3/src/vue-component-lib/utils.ts`
153
+ See `/LICENSE` for details of the license.
154
+
155
+ ==================
156
+
157
+ MIT (stencil-vue2-output-target):
158
+ The following files embed [stencil-vue2-output-target](https://github.com/diondree/stencil-vue2-output-target) MIT:
159
+ `/packages/taro-components-library-vue2/src/vue-component-lib/utils.ts`
160
+ See `/LICENSE` for details of the license.
@@ -0,0 +1,15 @@
1
+ export * from './base'
2
+ export * from './device'
3
+ export * from './files'
4
+ export * from './framework'
5
+ export * from './location'
6
+ export * from './media'
7
+ export * from './navigate'
8
+ export * from './network'
9
+ export * from './open-api'
10
+ export * from './page'
11
+ export * from './route'
12
+ export * from './storage'
13
+ export * from './tabbar'
14
+ export * from './ui'
15
+ export * from './wxml'
@@ -0,0 +1,5 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ export const getUpdateManager = temporarilyNotSupport('getUpdateManager')
4
+
5
+ export * from './system'
@@ -0,0 +1,77 @@
1
+ // 设备信息,从 API Version 6 开始支持
2
+ import deviceInfo from '@ohos.deviceInfo'
3
+ // 显示设备属性,从 API Version 7 开始支持
4
+ import _display from '@ohos.display'
5
+ // 从 API Version 7 开始支持
6
+ import i18n from '@ohos.i18n'
7
+ // 设备信息 从API Version 6开始,该接口不再维护,推荐使用新接口'@ohos.deviceInfo'进行设备信息查询
8
+ import deviceMethod from '@system.device'
9
+
10
+ import { callAsyncFail, callAsyncSuccess } from '../utils'
11
+
12
+ import type Taro from '@tarojs/api'
13
+
14
+ const display = _display.getDefaultDisplaySync()
15
+
16
+ let device
17
+
18
+ deviceMethod.getInfo({
19
+ success: data => {
20
+ device = data
21
+ }
22
+ })
23
+
24
+ /* 同步版本 */
25
+ export const getSystemInfoSync: typeof Taro.getSystemInfoSync = function () {
26
+ const res: any = {}
27
+ res.SDKVersion = deviceInfo && deviceInfo.sdkApiVersion // 客户端基础库版本 string
28
+ res.albumAuthorized = false // 允许使用相册的开关(仅 iOS 有效) boolean
29
+ res.benchmarkLevel = null // 设备性能等级 number
30
+ res.bluetoothEnabled = null // 蓝牙的系统开关 boolean
31
+ res.brand = deviceInfo && deviceInfo.brand // 设备品牌 string
32
+ res.cameraAuthorized = null // 允许使用摄像头的开关 boolean
33
+ res.enableDebug = null // 是否已打开调试 boolean
34
+ res.fontSizeSetting = null // 用户字体大小(单位px) number
35
+ res.language = i18n && i18n.getSystemLanguage && i18n.getSystemLanguage() // string
36
+ res.locationAuthorized = null // 定位的开关 boolean
37
+ res.locationEnabled = null // 地理位置的系统开关 boolean
38
+ res.microphoneAuthorized = null // 麦克风的开关 boolean
39
+ res.model = deviceInfo && deviceInfo.deviceType // 设备型号 string
40
+ res.notificationAuthorized = null // 通知的开关 boolean
41
+ res.notificationAlertAuthorized = false // 通知带有提醒的开关(仅 iOS 有效) boolean
42
+ res.notificationBadgeAuthorized = false // 通知带有标记的开关(仅 iOS 有效) boolean
43
+ res.notificationSoundAuthorized = false // 通知带有声音的开关(仅 iOS 有效)boolean
44
+ res.phoneCalendarAuthorized = null // 使用日历的开关 boolean
45
+ 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
57
+
58
+ return res
59
+ }
60
+ /* 异步版本 */
61
+ export const getSystemInfo: typeof Taro.getSystemInfo = function (options) {
62
+ let res = {}
63
+ return new Promise((resolve, reject) => {
64
+ try {
65
+ res = getSystemInfoSync()
66
+ callAsyncSuccess(resolve, res, options)
67
+ } catch (error) {
68
+ res = {
69
+ errMsg: `getSystemInfo:fail ${error && error.toString && error.toString()}`,
70
+ error: error
71
+ }
72
+ callAsyncFail(reject, res, options)
73
+ }
74
+ })
75
+ }
76
+
77
+ globalThis.getSystemInfoSync = getSystemInfoSync
@@ -0,0 +1,76 @@
1
+ import sensor from '@ohos.sensor'
2
+ import Taro from '@tarojs/taro'
3
+
4
+ import { CallbackManager, MethodHandler } from '../utils/handler'
5
+
6
+ const callbackManager = new CallbackManager()
7
+ let devicemotionListener
8
+
9
+ /**
10
+ * 停止监听加速度数据。
11
+ */
12
+ export const stopAccelerometer: typeof Taro.stopAccelerometer = ({ success, fail, complete } = {}) => {
13
+ const res: Partial<TaroGeneral.CallbackResult> = {}
14
+ const handle = new MethodHandler({ name: 'stopAccelerometer', success, fail, complete })
15
+ try {
16
+ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, devicemotionListener)
17
+ return handle.success(res)
18
+ } catch (e) {
19
+ res.errMsg = e.message
20
+ return handle.fail(res)
21
+ }
22
+ }
23
+
24
+ const INTERVAL_MAP = {
25
+ game: {
26
+ interval: 20 * 1000 * 1000,
27
+ frequency: 50
28
+ },
29
+ ui: {
30
+ interval: 60 * 1000 * 1000,
31
+ frequency: 16.67
32
+ },
33
+ normal: {
34
+ interval: 200 * 1000 * 1000,
35
+ frequency: 5
36
+ }
37
+ }
38
+
39
+ /**
40
+ * 开始监听加速度数据。
41
+ */
42
+ export const startAccelerometer: typeof Taro.startAccelerometer = ({ interval = 'normal', success, fail, complete } = {}) => {
43
+ const handle = new MethodHandler({ name: 'startAccelerometer', success, fail, complete })
44
+ try {
45
+ const intervalObj = INTERVAL_MAP[interval]
46
+ if (devicemotionListener) {
47
+ stopAccelerometer()
48
+ }
49
+ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, (data) => {
50
+ callbackManager.trigger({
51
+ x: data?.x || 0,
52
+ y: data?.y || 0,
53
+ z: data?.z || 0
54
+ })
55
+ }, {
56
+ interval: intervalObj.interval,
57
+ })
58
+ return handle.success()
59
+ } catch (e) {
60
+ return handle.fail({ errMsg: e.message })
61
+ }
62
+ }
63
+
64
+ /**
65
+ * 监听加速度数据事件。频率根据 Taro.startAccelerometer() 的 interval 参数。可使用 Taro.stopAccelerometer() 停止监听。
66
+ */
67
+ export const onAccelerometerChange: typeof Taro.onAccelerometerChange = callback => {
68
+ callbackManager.add(callback)
69
+ }
70
+
71
+ /**
72
+ * 取消监听加速度数据事件,参数为空,则取消所有的事件监听
73
+ */
74
+ export const offAccelerometerChange: typeof Taro.offAccelerometerChange = callback => {
75
+ callbackManager.remove(callback)
76
+ }
@@ -0,0 +1,24 @@
1
+ import batteryInfo, { BatteryChargeState } from '@ohos.batteryInfo'
2
+
3
+ import { MethodHandler } from '../utils/handler'
4
+
5
+ import type Taro from '@tarojs/api'
6
+
7
+ // 电量
8
+
9
+ export const getBatteryInfoSync: typeof Taro.getBatteryInfoSync = () => ({
10
+ // @ts-ignore
11
+ isCharging: [BatteryChargeState.ENABLE, BatteryChargeState.FULL].includes(batteryInfo.chargingStatus),
12
+ level: batteryInfo.batterySOC
13
+ })
14
+
15
+ export const getBatteryInfo: typeof Taro.getBatteryInfo = async ({ success, fail, complete } = {}) => {
16
+ const handle = new MethodHandler({ name: 'getBatteryInfo', success, fail, complete })
17
+ try {
18
+ return handle.success(getBatteryInfoSync())
19
+ } catch (error) {
20
+ return handle.fail({
21
+ errMsg: error?.message || error
22
+ })
23
+ }
24
+ }
@@ -0,0 +1,70 @@
1
+ // 从 API Version 6 开始支持
2
+ import pasteboard from '@ohos.pasteboard'
3
+ import { isString } from '@tarojs/shared'
4
+
5
+ import { callAsyncFail, getParameterError, object2String } from '../utils'
6
+ import { MethodHandler } from '../utils/handler'
7
+
8
+ import type Taro from '@tarojs/api'
9
+
10
+ /**
11
+ * 设置系统剪贴板的内容
12
+ */
13
+ export const setClipboardData: typeof Taro.setClipboardData = function (options) {
14
+ const { data, success, fail, complete } = options
15
+ const handle = new MethodHandler<{ data: string }>({ name: 'setClipboardData', success, fail, complete })
16
+ let res = {}
17
+
18
+ if (!isString(data)) {
19
+ return handle.fail({
20
+ errMsg: getParameterError({
21
+ para: 'data',
22
+ correct: 'String',
23
+ wrong: data
24
+ })
25
+ })
26
+ }
27
+
28
+ return new Promise((resolve, reject) => {
29
+ const systemPasteboard = pasteboard.getSystemPasteboard()
30
+ const pasteData = pasteboard.createPlainTextData(data)
31
+
32
+ systemPasteboard.setPasteData(pasteData, (error, data) => { // callback形式调用异步接口
33
+ if (error) {
34
+ console.error('Failed to set PasteData. Cause: ' + JSON.stringify(error))
35
+ res = {
36
+ errMsg: 'setClipboardData:fail,error: ' + object2String(error),
37
+ error: error
38
+ }
39
+ callAsyncFail(reject, res, options)
40
+ } else {
41
+ return handle.success({
42
+ data,
43
+ }, { resolve, reject })
44
+ }
45
+ })
46
+ })
47
+ }
48
+
49
+ /**
50
+ * 获取系统剪贴板的内容
51
+ */
52
+ export const getClipboardData: typeof Taro.getClipboardData = function (options) {
53
+ const { success, fail, complete } = options || {}
54
+ const handle = new MethodHandler({ name: 'getClipboardData', success, fail, complete })
55
+ return new Promise((resolve, reject) => {
56
+ const systemPasteboard = pasteboard.getSystemPasteboard()
57
+ systemPasteboard.getPasteData((error, pasteData) => { // callback 形式调用异步接口
58
+ if (error) {
59
+ console.error('Failed to obtain PasteData. Cause: ' + JSON.stringify(error))
60
+ return handle.fail({
61
+ errMsg: object2String(error),
62
+ }, { resolve, reject })
63
+ } else {
64
+ return handle.success({
65
+ data: pasteData.getPrimaryText(),
66
+ }, { resolve, reject })
67
+ }
68
+ })
69
+ })
70
+ }
@@ -0,0 +1,9 @@
1
+ export * from './accelerometer'
2
+ export * from './battery'
3
+ export * from './clipboard'
4
+ export * from './keyboard'
5
+ export * from './memory'
6
+ export * from './network'
7
+ export * from './phone'
8
+ export * from './screen'
9
+ export * from './vibrate'
@@ -0,0 +1,62 @@
1
+ import inputMethodEngine from '@ohos.inputMethodEngine'
2
+ import { Current, window } from '@tarojs/runtime'
3
+ import Taro from '@tarojs/taro'
4
+
5
+ import { temporarilyNotSupport } from '../utils'
6
+ import { CallbackManager, MethodHandler } from '../utils/handler'
7
+
8
+ const callbackManager = new CallbackManager()
9
+
10
+ const resizeListener = (height) => {
11
+ callbackManager.trigger({
12
+ height,
13
+ })
14
+ }
15
+
16
+ let topWindow: ReturnType<typeof window.__ohos.getLastWindow>
17
+
18
+ export const onKeyboardHeightChange: typeof Taro.onKeyboardHeightChange = callback => {
19
+ callbackManager.add(callback)
20
+ if (callbackManager.count() === 1) {
21
+ (Current as any).contextPromise
22
+ .then(context => {
23
+ const win = window.__ohos.getLastWindow(context)
24
+ win.then(mainWindow => {
25
+ topWindow = mainWindow
26
+ topWindow.on('keyboardHeightChange', resizeListener)
27
+ })
28
+ })
29
+ }
30
+ }
31
+
32
+ export const offKeyboardHeightChange: typeof Taro.offKeyboardHeightChange = callback => {
33
+ callbackManager.remove(callback)
34
+ if (callbackManager.count() === 0) {
35
+ topWindow?.off('keyboardHeightChange', resizeListener)
36
+ }
37
+ }
38
+
39
+ // @ts-ignore
40
+ let keyboardController: inputMethodEngine.KeyboardController
41
+ inputMethodEngine.getInputMethodAbility()
42
+ // FIXME 当前事件无效,等待鸿蒙方面沟通
43
+ .on('inputStart', (kbController) => {
44
+ keyboardController = kbController
45
+ })
46
+
47
+ export const hideKeyboard: typeof Taro.hideKeyboard = function (options) {
48
+ const { success, fail, complete } = options || {}
49
+ const handle = new MethodHandler({ name: 'hideKeyboard', success, fail, complete })
50
+ return new Promise((resolve, reject) => {
51
+ keyboardController?.hide((err) => {
52
+ if (err) {
53
+ return handle.fail({
54
+ errMsg: err,
55
+ }, { resolve, reject })
56
+ }
57
+ return handle.success({}, { resolve, reject })
58
+ })
59
+ })
60
+ }
61
+
62
+ export const getSelectedTextRange = /* @__PURE__ */ temporarilyNotSupport('getSelectedTextRange')
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ export const onMemoryWarning = temporarilyNotSupport('onMemoryWarning')
4
+ export const offMemoryWarning = temporarilyNotSupport('offMemoryWarning')
@@ -0,0 +1,72 @@
1
+ // 网络状态,从API Version 7 开始,该接口不再维护,推荐使用新接口'@ohos.telephony.observer'
2
+ // 但是新接口 @ohos.telephony.observer 没有network.getType。而且网络状态枚举值不清楚
3
+ import network from '@system.network'
4
+ import Taro from '@tarojs/taro'
5
+
6
+ import { temporarilyNotSupport } from '../utils'
7
+ import { CallbackManager, MethodHandler } from '../utils/handler'
8
+
9
+ export const getNetworkType: typeof Taro.getNetworkType = (options = {}) => {
10
+ const { success, fail, complete } = options
11
+ const handle = new MethodHandler<Taro.getNetworkType.SuccessCallbackResult & { code: unknown, metered: boolean }>({ name: 'getNetworkType', success, fail, complete })
12
+
13
+ return new Promise((resolve, reject) => {
14
+ network.getType({
15
+ success: function (data) {
16
+ return handle.success({
17
+ networkType: data.type || 'unknown',
18
+ metered: data.metered
19
+ }, { resolve, reject })
20
+ },
21
+ fail: function (data, code) {
22
+ return handle.fail({
23
+ errMsg: data || '',
24
+ code
25
+ }, { resolve, reject })
26
+ },
27
+ })
28
+ })
29
+ }
30
+
31
+ const networkStatusManager = new CallbackManager()
32
+
33
+ const networkStatusListener = async (data, code = 0) => {
34
+ if (code > 0) {
35
+ return networkStatusManager.trigger({ isConnected: false, networkType: 'none' })
36
+ }
37
+ const networkType = data.type || 'unknown'
38
+ const isConnected = networkType !== 'none'
39
+ const metered = !!data.metered
40
+ const obj = { isConnected, networkType, metered }
41
+ networkStatusManager.trigger(obj)
42
+ }
43
+
44
+ /**
45
+ * 在最近的八次网络请求中, 出现下列三个现象之一则判定弱网。
46
+ * - 出现三次以上连接超时
47
+ * - 出现三次 rtt 超过 400
48
+ * - 出现三次以上的丢包
49
+ * > 弱网事件通知规则是: 弱网状态变化时立即通知, 状态不变时 30s 内最多通知一次。
50
+ */
51
+ export const onNetworkWeakChange = /* @__PURE__ */ temporarilyNotSupport('onNetworkWeakChange')
52
+
53
+ 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,
59
+ })
60
+ }
61
+ }
62
+
63
+ export const offNetworkWeakChange = /* @__PURE__ */ temporarilyNotSupport('offNetworkWeakChange')
64
+
65
+ export const offNetworkStatusChange: typeof Taro.offNetworkStatusChange = callback => {
66
+ networkStatusManager.remove(callback)
67
+ if (networkStatusManager.count() === 0) {
68
+ network.unsubscribe()
69
+ }
70
+ }
71
+
72
+ export const getLocalIPAddress = /* @__PURE__ */ temporarilyNotSupport('getLocalIPAddress')
@@ -0,0 +1,43 @@
1
+ // 从 API Version 7 开始支持。
2
+ import call from '@ohos.telephony.call'
3
+ import { isString } from '@tarojs/shared'
4
+ import Taro from '@tarojs/taro'
5
+
6
+ import { getParameterError, object2String, shouldBeObject } from '../utils'
7
+ import { MethodHandler } from '../utils/handler'
8
+
9
+ export const makePhoneCall: typeof Taro.makePhoneCall = (options) => {
10
+ // options must be an Object
11
+ const isObject = shouldBeObject(options)
12
+ if (!isObject.flag) {
13
+ const res = { errMsg: `makePhoneCall:fail ${isObject.msg}` }
14
+ console.error(res.errMsg)
15
+ return Promise.reject(res)
16
+ }
17
+
18
+ const { phoneNumber, success, fail, complete } = options
19
+ const handle = new MethodHandler({ name: 'makePhoneCall', success, fail, complete })
20
+
21
+ if (!isString(phoneNumber)) {
22
+ return handle.fail({
23
+ errMsg: getParameterError({
24
+ para: 'phoneNumber',
25
+ correct: 'String',
26
+ wrong: phoneNumber
27
+ })
28
+ })
29
+ }
30
+
31
+ return new Promise((resolve, reject) => {
32
+ call.makeCall(phoneNumber, err => {
33
+ if (err) {
34
+ console.error('Failed to makePhoneCall. Cause: ' + JSON.stringify(err))
35
+ return handle.fail({
36
+ errMsg: object2String(err)
37
+ }, { resolve, reject })
38
+ } else {
39
+ return handle.success({}, { resolve, reject })
40
+ }
41
+ })
42
+ })
43
+ }