@tarojs/taro-h5 3.5.0-alpha.13 → 3.5.0-alpha.16

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 (295) hide show
  1. package/dist/api/ad/index.d.ts +6 -0
  2. package/dist/api/ai/facial.d.ts +9 -0
  3. package/dist/api/ai/index.d.ts +2 -0
  4. package/dist/api/ai/visual.d.ts +6 -0
  5. package/dist/api/alipay/index.d.ts +3 -0
  6. package/dist/api/base/crypto.d.ts +3 -0
  7. package/dist/api/base/debug.d.ts +9 -0
  8. package/dist/api/base/index.d.ts +12 -0
  9. package/dist/api/base/performance.d.ts +6 -0
  10. package/dist/api/base/system.d.ts +27 -0
  11. package/dist/api/base/system.js +2 -2
  12. package/dist/api/base/update.d.ts +6 -0
  13. package/dist/api/base/weapp/app-event.d.ts +41 -0
  14. package/dist/api/base/weapp/app-event.js +55 -4
  15. package/dist/api/base/weapp/life-cycle.d.ts +6 -0
  16. package/dist/api/canvas/CanvasContext.d.ts +104 -0
  17. package/dist/api/canvas/canvasGetImageData.d.ts +5 -0
  18. package/dist/api/canvas/canvasPutImageData.d.ts +6 -0
  19. package/dist/api/canvas/canvasToTempFilePath.d.ts +6 -0
  20. package/dist/api/canvas/canvasToTempFilePath.js +1 -1
  21. package/dist/api/canvas/createCanvasContext.d.ts +5 -0
  22. package/dist/api/canvas/index.d.ts +12 -0
  23. package/dist/api/cloud/index.d.ts +31 -0
  24. package/dist/api/data-analysis/index.d.ts +12 -0
  25. package/dist/api/device/accelerometer.d.ts +17 -0
  26. package/dist/api/device/accessibility.d.ts +3 -0
  27. package/dist/api/device/battery.d.ts +5 -0
  28. package/dist/api/device/bluetooth-ble.d.ts +48 -0
  29. package/dist/api/device/bluetooth-peripheral.d.ts +9 -0
  30. package/dist/api/device/bluetooth.d.ts +39 -0
  31. package/dist/api/device/calendar.d.ts +6 -0
  32. package/dist/api/device/clipboard.d.ts +15 -0
  33. package/dist/api/device/compass.d.ts +17 -0
  34. package/dist/api/device/contact.d.ts +6 -0
  35. package/dist/api/device/crypto.d.ts +3 -0
  36. package/dist/api/device/gyroscope.d.ts +12 -0
  37. package/dist/api/device/iBeacon.d.ts +21 -0
  38. package/dist/api/device/index.d.ts +23 -0
  39. package/dist/api/device/keyboard.d.ts +12 -0
  40. package/dist/api/device/memory.d.ts +6 -0
  41. package/dist/api/device/motion.d.ts +17 -0
  42. package/dist/api/device/network.d.ts +20 -0
  43. package/dist/api/device/nfc.d.ts +21 -0
  44. package/dist/api/device/phone.d.ts +2 -0
  45. package/dist/api/device/scan.d.ts +3 -0
  46. package/dist/api/device/screen.d.ts +18 -0
  47. package/dist/api/device/vibrate.d.ts +9 -0
  48. package/dist/api/device/vibrate.js +5 -7
  49. package/dist/api/device/wifi.d.ts +33 -0
  50. package/dist/api/ext/index.d.ts +6 -0
  51. package/dist/api/files/index.d.ts +24 -0
  52. package/dist/api/framework/index.d.ts +4 -0
  53. package/dist/api/index.d.ts +24 -0
  54. package/dist/api/location/chooseLocation.d.ts +6 -0
  55. package/dist/api/location/getLocation.d.ts +2 -0
  56. package/dist/api/location/index.d.ts +32 -0
  57. package/dist/api/location/index.js +1 -0
  58. package/dist/api/media/EditorContext.d.ts +42 -0
  59. package/dist/api/media/audio/InnerAudioContext.d.ts +58 -0
  60. package/dist/api/media/audio/InnerAudioContext.js +1 -1
  61. package/dist/api/media/audio/index.d.ts +29 -0
  62. package/dist/api/media/background-audio/BackgroundAudioManager.d.ts +71 -0
  63. package/dist/api/media/background-audio/index.d.ts +29 -0
  64. package/dist/api/media/camera.d.ts +3 -0
  65. package/dist/api/media/image/chooseImage.d.ts +5 -0
  66. package/dist/api/media/image/getImageInfo.d.ts +5 -0
  67. package/dist/api/media/image/index.d.ts +15 -0
  68. package/dist/api/media/image/previewImage.d.ts +8 -0
  69. package/dist/api/media/index.d.ts +12 -0
  70. package/dist/api/media/live.d.ts +6 -0
  71. package/dist/api/media/map.d.ts +3 -0
  72. package/dist/api/media/media-recorder.d.ts +3 -0
  73. package/dist/api/media/recorder.d.ts +9 -0
  74. package/dist/api/media/video/index.d.ts +24 -0
  75. package/dist/api/media/video-decoder.d.ts +3 -0
  76. package/dist/api/media/video-processing.d.ts +3 -0
  77. package/dist/api/media/voip.d.ts +42 -0
  78. package/dist/api/navigate/index.d.ts +12 -0
  79. package/dist/api/network/download.d.ts +6 -0
  80. package/dist/api/network/download.js +1 -0
  81. package/dist/api/network/index.d.ts +7 -0
  82. package/dist/api/network/mdns.d.ts +30 -0
  83. package/dist/api/network/request/index.d.ts +4 -0
  84. package/dist/api/network/tcp.d.ts +3 -0
  85. package/dist/api/network/udp.d.ts +3 -0
  86. package/dist/api/network/upload.d.ts +5 -0
  87. package/dist/api/network/upload.js +2 -1
  88. package/{src/api/network/utils.ts → dist/api/network/utils.d.ts} +44 -71
  89. package/dist/api/network/utils.js +1 -0
  90. package/dist/api/network/websocket/index.d.ts +7 -0
  91. package/dist/api/network/websocket/socketTask.d.ts +25 -0
  92. package/dist/api/open-api/account.d.ts +3 -0
  93. package/dist/api/open-api/address.d.ts +3 -0
  94. package/dist/api/open-api/authorize.d.ts +6 -0
  95. package/dist/api/open-api/card.d.ts +6 -0
  96. package/dist/api/open-api/channels-live.d.ts +18 -0
  97. package/dist/api/open-api/customer-service.d.ts +3 -0
  98. package/dist/api/open-api/facial.d.ts +12 -0
  99. package/dist/api/open-api/favorites.d.ts +6 -0
  100. package/dist/api/open-api/group.d.ts +3 -0
  101. package/dist/api/open-api/index.d.ts +18 -0
  102. package/dist/api/open-api/invoice.d.ts +6 -0
  103. package/dist/api/open-api/license-plate.d.ts +3 -0
  104. package/dist/api/open-api/login.d.ts +9 -0
  105. package/dist/api/open-api/red-package.d.ts +3 -0
  106. package/dist/api/open-api/settings.d.ts +6 -0
  107. package/dist/api/open-api/soter.d.ts +9 -0
  108. package/dist/api/open-api/subscribe-message.d.ts +3 -0
  109. package/dist/api/open-api/user-info.d.ts +6 -0
  110. package/dist/api/open-api/werun.d.ts +6 -0
  111. package/dist/api/payment/index.d.ts +6 -0
  112. package/dist/api/route/index.d.ts +1 -0
  113. package/dist/api/share/index.d.ts +30 -0
  114. package/dist/api/storage/background-fetch.d.ts +12 -0
  115. package/dist/api/storage/index.d.ts +18 -0
  116. package/dist/api/swan/index.d.ts +63 -0
  117. package/dist/api/taro.d.ts +12 -0
  118. package/dist/api/ui/animation/index.d.ts +2 -0
  119. package/dist/api/ui/background.d.ts +6 -0
  120. package/dist/api/ui/custom-component.d.ts +1 -0
  121. package/dist/api/ui/fonts.d.ts +2 -0
  122. package/dist/api/ui/index.d.ts +12 -0
  123. package/dist/api/ui/interaction/actionSheet.d.ts +61 -0
  124. package/dist/api/ui/interaction/index.d.ts +14 -0
  125. package/dist/api/ui/interaction/modal.d.ts +69 -0
  126. package/dist/api/ui/interaction/modal.js +1 -0
  127. package/dist/api/ui/interaction/toast.d.ts +85 -0
  128. package/dist/api/ui/menu.d.ts +3 -0
  129. package/dist/api/ui/navigation-bar/index.d.ts +15 -0
  130. package/dist/api/ui/navigation-bar/index.js +2 -3
  131. package/dist/api/ui/pull-down-refresh.d.ts +9 -0
  132. package/dist/api/ui/scroll/index.d.ts +5 -0
  133. package/dist/api/ui/sticky.d.ts +3 -0
  134. package/dist/api/ui/tab-bar.d.ts +34 -0
  135. package/dist/api/ui/window.d.ts +15 -0
  136. package/dist/api/worker/index.d.ts +3 -0
  137. package/dist/api/wxml/index.d.ts +5 -0
  138. package/dist/api/wxml/nodesRef.d.ts +13 -0
  139. package/dist/api/wxml/selectorQuery.d.ts +24 -0
  140. package/dist/api/wxml/selectorQuery.js +1 -1
  141. package/dist/index.cjs.d.ts +1373 -0
  142. package/dist/index.cjs.js +105 -81
  143. package/dist/index.cjs.js.map +1 -1
  144. package/dist/index.d.ts +4 -0
  145. package/dist/index.esm.d.ts +1373 -0
  146. package/dist/index.esm.js +93 -69
  147. package/dist/index.esm.js.map +1 -1
  148. package/dist/taroApis.d.ts +1364 -0
  149. package/dist/taroApis.js +1 -1
  150. package/dist/utils/animation.d.ts +6 -0
  151. package/dist/utils/handler.d.ts +48 -0
  152. package/dist/utils/index.d.ts +39 -0
  153. package/dist/utils/index.js +3 -7
  154. package/dist/utils/lodash.d.ts +2 -0
  155. package/dist/utils/valid.d.ts +2 -0
  156. package/package.json +17 -19
  157. package/types/api.d.ts +4 -0
  158. package/types/define.d.ts +2 -0
  159. package/types/index.d.ts +33 -0
  160. package/types/overlay.d.ts +9 -0
  161. package/LICENSE +0 -21
  162. package/src/api/ad/index.ts +0 -5
  163. package/src/api/ai/facial.ts +0 -6
  164. package/src/api/ai/index.ts +0 -2
  165. package/src/api/ai/visual.ts +0 -7
  166. package/src/api/alipay/index.ts +0 -4
  167. package/src/api/base/crypto.ts +0 -4
  168. package/src/api/base/debug.ts +0 -5
  169. package/src/api/base/index.ts +0 -23
  170. package/src/api/base/performance.ts +0 -5
  171. package/src/api/base/system.ts +0 -207
  172. package/src/api/base/update.ts +0 -5
  173. package/src/api/base/weapp/app-event.ts +0 -19
  174. package/src/api/base/weapp/life-cycle.ts +0 -5
  175. package/src/api/canvas/CanvasContext.ts +0 -233
  176. package/src/api/canvas/canvasGetImageData.ts +0 -28
  177. package/src/api/canvas/canvasPutImageData.ts +0 -25
  178. package/src/api/canvas/canvasToTempFilePath.ts +0 -25
  179. package/src/api/canvas/createCanvasContext.ts +0 -19
  180. package/src/api/canvas/index.ts +0 -18
  181. package/src/api/cloud/index.ts +0 -32
  182. package/src/api/data-analysis/index.ts +0 -6
  183. package/src/api/device/accelerometer.ts +0 -79
  184. package/src/api/device/accessibility.ts +0 -4
  185. package/src/api/device/battery.ts +0 -23
  186. package/src/api/device/bluetooth-ble.ts +0 -19
  187. package/src/api/device/bluetooth-peripheral.ts +0 -6
  188. package/src/api/device/bluetooth.ts +0 -16
  189. package/src/api/device/calendar.ts +0 -5
  190. package/src/api/device/clipboard.ts +0 -68
  191. package/src/api/device/compass.ts +0 -83
  192. package/src/api/device/contact.ts +0 -5
  193. package/src/api/device/crypto.ts +0 -4
  194. package/src/api/device/gyroscope.ts +0 -7
  195. package/src/api/device/iBeacon.ts +0 -10
  196. package/src/api/device/index.ts +0 -23
  197. package/src/api/device/keyboard.ts +0 -7
  198. package/src/api/device/memory.ts +0 -5
  199. package/src/api/device/motion.ts +0 -77
  200. package/src/api/device/network.ts +0 -90
  201. package/src/api/device/nfc.ts +0 -10
  202. package/src/api/device/phone.ts +0 -31
  203. package/src/api/device/scan.ts +0 -11
  204. package/src/api/device/screen.ts +0 -9
  205. package/src/api/device/vibrate.ts +0 -37
  206. package/src/api/device/wifi.ts +0 -14
  207. package/src/api/ext/index.ts +0 -5
  208. package/src/api/files/index.ts +0 -11
  209. package/src/api/framework/index.ts +0 -10
  210. package/src/api/index.ts +0 -24
  211. package/src/api/location/chooseLocation.ts +0 -117
  212. package/src/api/location/getLocation.ts +0 -81
  213. package/src/api/location/index.ts +0 -22
  214. package/src/api/location/style.css +0 -79
  215. package/src/api/media/EditorContext.ts +0 -32
  216. package/src/api/media/audio/InnerAudioContext.ts +0 -99
  217. package/src/api/media/audio/index.ts +0 -21
  218. package/src/api/media/background-audio/BackgroundAudioManager.ts +0 -104
  219. package/src/api/media/background-audio/index.ts +0 -17
  220. package/src/api/media/camera.ts +0 -4
  221. package/src/api/media/image/chooseImage.ts +0 -95
  222. package/src/api/media/image/getImageInfo.ts +0 -50
  223. package/src/api/media/image/index.ts +0 -13
  224. package/src/api/media/image/previewImage.ts +0 -80
  225. package/src/api/media/index.ts +0 -12
  226. package/src/api/media/live.ts +0 -5
  227. package/src/api/media/map.ts +0 -4
  228. package/src/api/media/media-recorder.ts +0 -4
  229. package/src/api/media/recorder.ts +0 -6
  230. package/src/api/media/video/index.ts +0 -82
  231. package/src/api/media/video-decoder.ts +0 -4
  232. package/src/api/media/video-processing.ts +0 -4
  233. package/src/api/media/voip.ts +0 -17
  234. package/src/api/navigate/index.ts +0 -7
  235. package/src/api/network/download.ts +0 -141
  236. package/src/api/network/index.ts +0 -7
  237. package/src/api/network/mdns.ts +0 -13
  238. package/src/api/network/request/index.ts +0 -135
  239. package/src/api/network/tcp.ts +0 -4
  240. package/src/api/network/udp.ts +0 -4
  241. package/src/api/network/upload.ts +0 -169
  242. package/src/api/network/websocket/index.ts +0 -88
  243. package/src/api/network/websocket/socketTask.ts +0 -89
  244. package/src/api/open-api/account.ts +0 -4
  245. package/src/api/open-api/address.ts +0 -4
  246. package/src/api/open-api/authorize.ts +0 -5
  247. package/src/api/open-api/card.ts +0 -5
  248. package/src/api/open-api/channels-live.ts +0 -9
  249. package/src/api/open-api/customer-service.ts +0 -4
  250. package/src/api/open-api/facial.ts +0 -7
  251. package/src/api/open-api/favorites.ts +0 -5
  252. package/src/api/open-api/group.ts +0 -4
  253. package/src/api/open-api/index.ts +0 -18
  254. package/src/api/open-api/invoice.ts +0 -5
  255. package/src/api/open-api/license-plate.ts +0 -4
  256. package/src/api/open-api/login.ts +0 -6
  257. package/src/api/open-api/red-package.ts +0 -4
  258. package/src/api/open-api/settings.ts +0 -5
  259. package/src/api/open-api/soter.ts +0 -6
  260. package/src/api/open-api/subscribe-message.ts +0 -4
  261. package/src/api/open-api/user-info.ts +0 -5
  262. package/src/api/open-api/werun.ts +0 -5
  263. package/src/api/payment/index.ts +0 -5
  264. package/src/api/route/index.ts +0 -10
  265. package/src/api/share/index.ts +0 -13
  266. package/src/api/storage/background-fetch.ts +0 -7
  267. package/src/api/storage/index.ts +0 -182
  268. package/src/api/swan/index.ts +0 -31
  269. package/src/api/taro.ts +0 -84
  270. package/src/api/ui/animation/index.ts +0 -356
  271. package/src/api/ui/background.ts +0 -5
  272. package/src/api/ui/custom-component.ts +0 -4
  273. package/src/api/ui/fonts.ts +0 -64
  274. package/src/api/ui/index.ts +0 -12
  275. package/src/api/ui/interaction/actionSheet.ts +0 -212
  276. package/src/api/ui/interaction/index.ts +0 -302
  277. package/src/api/ui/interaction/modal.ts +0 -237
  278. package/src/api/ui/interaction/toast.ts +0 -220
  279. package/src/api/ui/menu.ts +0 -4
  280. package/src/api/ui/navigation-bar/index.ts +0 -52
  281. package/src/api/ui/pull-down-refresh.ts +0 -28
  282. package/src/api/ui/scroll/index.ts +0 -85
  283. package/src/api/ui/sticky.ts +0 -4
  284. package/src/api/ui/tab-bar.ts +0 -327
  285. package/src/api/ui/window.ts +0 -38
  286. package/src/api/worker/index.ts +0 -4
  287. package/src/api/wxml/index.ts +0 -10
  288. package/src/api/wxml/nodesRef.ts +0 -56
  289. package/src/api/wxml/selectorQuery.ts +0 -220
  290. package/src/index.ts +0 -6
  291. package/src/utils/animation.ts +0 -15
  292. package/src/utils/handler.ts +0 -105
  293. package/src/utils/index.ts +0 -184
  294. package/src/utils/lodash.ts +0 -30
  295. package/src/utils/valid.ts +0 -8
@@ -1,83 +0,0 @@
1
- import Taro from '@tarojs/api'
2
-
3
- import { throttle } from '../../utils'
4
- import { CallbackManager, MethodHandler } from '../../utils/handler'
5
- import { getDeviceInfo } from '../base/system'
6
-
7
- const callbackManager = new CallbackManager()
8
- let compassListener
9
-
10
- /**
11
- * Note: 按系统类型获取对应绝对 orientation 事件名,因为安卓系统中直接监听 deviceorientation 事件得到的不是绝对 orientation
12
- */
13
- const deviceorientationEventName = ['absolutedeviceorientation', 'deviceorientationabsolute', 'deviceorientation'].find(item => {
14
- if ('on' + item in window) {
15
- return item
16
- }
17
- }) || ''
18
-
19
- /**
20
- * 停止监听罗盘数据
21
- */
22
- export const stopCompass: typeof Taro.stopCompass = ({ success, fail, complete } = {}) => {
23
- const handle = new MethodHandler({ name: 'stopCompass', success, fail, complete })
24
- try {
25
- window.removeEventListener(deviceorientationEventName, compassListener, true)
26
- return handle.success()
27
- } catch (e) {
28
- return handle.fail({ errMsg: e.message })
29
- }
30
- }
31
-
32
- let CompassChangeTrigger = false
33
- /**
34
- * 开始监听罗盘数据
35
- */
36
- export const startCompass: typeof Taro.startCompass = ({ success, fail, complete } = {}) => {
37
- const handle = new MethodHandler({ name: 'startCompass', success, fail, complete })
38
- try {
39
- if (deviceorientationEventName !== '') {
40
- if (compassListener) {
41
- stopCompass()
42
- }
43
- compassListener = throttle((evt: DeviceOrientationEvent) => {
44
- const isAndroid = getDeviceInfo().system === 'AndroidOS'
45
- if (isAndroid && !evt.absolute && !CompassChangeTrigger) {
46
- CompassChangeTrigger = true
47
- console.warn('Warning: In \'onCompassChange\', your browser is not supported to get the orientation relative to the earth, the orientation data will be related to the initial orientation of the device .')
48
- }
49
- const alpha = evt.alpha || 0
50
- /**
51
- * 由于平台差异,accuracy 在 iOS/Android 的值不同。
52
- * - iOS:accuracy 是一个 number 类型的值,表示相对于磁北极的偏差。0 表示设备指向磁北,90 表示指向东,180 表示指向南,依此类推。
53
- * - Android:accuracy 是一个 string 类型的枚举值。
54
- */
55
- const accuracy = isAndroid ? evt.absolute ? 'high' : 'medium' : alpha
56
- callbackManager.trigger({
57
- direction: 360 - alpha,
58
- accuracy: accuracy
59
- } as unknown as Parameters<typeof Taro.onCompassChange>[number])
60
- }, 5000)
61
- window.addEventListener(deviceorientationEventName, compassListener, true)
62
- } else {
63
- throw new Error('compass is not supported')
64
- }
65
- return handle.success()
66
- } catch (e) {
67
- return handle.fail({ errMsg: e.message })
68
- }
69
- }
70
-
71
- /**
72
- * 监听罗盘数据变化事件。频率:5 次/秒,接口调用后会自动开始监听,可使用 wx.stopCompass 停止监听。
73
- */
74
- export const onCompassChange: typeof Taro.onCompassChange = callback => {
75
- callbackManager.add(callback)
76
- }
77
-
78
- /**
79
- * 取消监听罗盘数据变化事件,参数为空,则取消所有的事件监听。
80
- */
81
- export const offCompassChange: typeof Taro.offCompassChange = callback => {
82
- callbackManager.remove(callback)
83
- }
@@ -1,5 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 联系人
4
- export const chooseContact = temporarilyNotSupport('chooseContact')
5
- export const addPhoneContact = temporarilyNotSupport('addPhoneContact')
@@ -1,4 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 加密
4
- export const getRandomValues = temporarilyNotSupport('getRandomValues')
@@ -1,7 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 陀螺仪
4
- export const stopGyroscope = temporarilyNotSupport('stopGyroscope')
5
- export const startGyroscope = temporarilyNotSupport('startGyroscope')
6
- export const onGyroscopeChange = temporarilyNotSupport('onGyroscopeChange')
7
- export const offGyroscopeChange = temporarilyNotSupport('offGyroscopeChange')
@@ -1,10 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 蓝牙-信标(Beacon)
4
- export const stopBeaconDiscovery = temporarilyNotSupport('stopBeaconDiscovery')
5
- export const startBeaconDiscovery = temporarilyNotSupport('startBeaconDiscovery')
6
- export const onBeaconUpdate = temporarilyNotSupport('onBeaconUpdate')
7
- export const onBeaconServiceChange = temporarilyNotSupport('onBeaconServiceChange')
8
- export const offBeaconUpdate = temporarilyNotSupport('offBeaconUpdate')
9
- export const offBeaconServiceChange = temporarilyNotSupport('offBeaconServiceChange')
10
- export const getBeacons = temporarilyNotSupport('getBeacons')
@@ -1,23 +0,0 @@
1
- export * from './accelerometer'
2
- export * from './accessibility'
3
- export * from './battery'
4
- export * from './bluetooth'
5
- export * from './bluetooth-ble'
6
- export * from './bluetooth-peripheral'
7
- export * from './calendar'
8
- export * from './clipboard'
9
- export * from './compass'
10
- export * from './contact'
11
- export * from './crypto'
12
- export * from './gyroscope'
13
- export * from './iBeacon'
14
- export * from './keyboard'
15
- export * from './memory'
16
- export * from './motion'
17
- export * from './network'
18
- export * from './nfc'
19
- export * from './phone'
20
- export * from './scan'
21
- export * from './screen'
22
- export * from './vibrate'
23
- export * from './wifi'
@@ -1,7 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 键盘
4
- export const onKeyboardHeightChange = temporarilyNotSupport('onKeyboardHeightChange')
5
- export const offKeyboardHeightChange = temporarilyNotSupport('offKeyboardHeightChange')
6
- export const hideKeyboard = temporarilyNotSupport('hideKeyboard')
7
- export const getSelectedTextRange = temporarilyNotSupport('getSelectedTextRange')
@@ -1,5 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 内存
4
- export const onMemoryWarning = temporarilyNotSupport('onMemoryWarning')
5
- export const offMemoryWarning = temporarilyNotSupport('offMemoryWarning')
@@ -1,77 +0,0 @@
1
- import Taro from '@tarojs/api'
2
-
3
- import { throttle } from '../../utils'
4
- import { CallbackManager, MethodHandler } from '../../utils/handler'
5
-
6
- const callbackManager = new CallbackManager()
7
- let deviceMotionListener
8
-
9
- const INTERVAL_MAP = {
10
- game: {
11
- interval: 20,
12
- frequency: 50
13
- },
14
- ui: {
15
- interval: 60,
16
- frequency: 16.67
17
- },
18
- normal: {
19
- interval: 200,
20
- frequency: 5
21
- }
22
- }
23
-
24
- /**
25
- * 停止监听设备方向的变化。
26
- */
27
- export const stopDeviceMotionListening: typeof Taro.stopDeviceMotionListening = ({ success, fail, complete } = {}) => {
28
- const handle = new MethodHandler({ name: 'stopDeviceMotionListening', success, fail, complete })
29
- try {
30
- window.removeEventListener('deviceorientation', deviceMotionListener, true)
31
- return handle.success()
32
- } catch (e) {
33
- return handle.fail({ errMsg: e.message })
34
- }
35
- }
36
-
37
- /**
38
- * 开始监听设备方向的变化。
39
- */
40
- export const startDeviceMotionListening: typeof Taro.startDeviceMotionListening = ({ interval = 'normal', success, fail, complete } = {}) => {
41
- const handle = new MethodHandler({ name: 'startDeviceMotionListening', success, fail, complete })
42
- try {
43
- const intervalObj = INTERVAL_MAP[interval]
44
- if (window.DeviceOrientationEvent) {
45
- if (deviceMotionListener) {
46
- stopDeviceMotionListening()
47
- }
48
- deviceMotionListener = throttle((evt: DeviceOrientationEvent) => {
49
- callbackManager.trigger({
50
- alpha: evt.alpha,
51
- beta: evt.beta,
52
- gamma: evt.gamma
53
- })
54
- }, intervalObj.interval)
55
- window.addEventListener('deviceorientation', deviceMotionListener, true)
56
- } else {
57
- throw new Error('deviceMotion is not supported')
58
- }
59
- return handle.success()
60
- } catch (e) {
61
- return handle.fail({ errMsg: e.message })
62
- }
63
- }
64
-
65
- /**
66
- * 监听设备方向变化事件。
67
- */
68
- export const onDeviceMotionChange: typeof Taro.onDeviceMotionChange = callback => {
69
- callbackManager.add(callback)
70
- }
71
-
72
- /**
73
- * 取消监听设备方向变化事件,参数为空,则取消所有的事件监听。
74
- */
75
- export const offDeviceMotionChange: typeof Taro.offDeviceMotionChange = callback => {
76
- callbackManager.remove(callback)
77
- }
@@ -1,90 +0,0 @@
1
- import Taro from '@tarojs/api'
2
-
3
- import { temporarilyNotSupport } from '../../utils'
4
- import { CallbackManager, MethodHandler } from '../../utils/handler'
5
-
6
- function getConnection () {
7
- // @ts-ignore
8
- return navigator.connection || navigator.mozConnection || navigator.webkitConnection || navigator.msConnection
9
- }
10
-
11
- export const getNetworkType: typeof Taro.getNetworkType = (options = {}) => {
12
- const connection = getConnection()
13
- const { success, fail, complete } = options
14
- const handle = new MethodHandler<Taro.getNetworkType.SuccessCallbackResult>({ name: 'getNetworkType', success, fail, complete })
15
-
16
- let networkType: keyof Taro.getNetworkType.NetworkType = 'unknown'
17
- // 浏览器不支持获取网络状态
18
- if (!connection) {
19
- return handle.success({ networkType })
20
- }
21
-
22
- // Supports only the navigator.connection.type value which doesn't match the latest spec.
23
- // https://www.davidbcalhoun.com/2010/using-navigator-connection-android/
24
- if (!isNaN(Number(connection.type))) {
25
- switch (connection.type) {
26
- // @ts-ignore
27
- case connection.WIFI:
28
- networkType = 'wifi'
29
- break
30
- // @ts-ignore
31
- case connection.CELL_3G:
32
- networkType = '3g'
33
- break
34
- // @ts-ignore
35
- case connection.CELL_2G:
36
- networkType = '2g'
37
- break
38
- default:
39
- // ETHERNET, UNKNOWN
40
- networkType = 'unknown'
41
- }
42
- } else if (connection.type) {
43
- // @ts-ignore
44
- networkType = connection.type // Only supports the type value.
45
- // @ts-ignore
46
- } else if (connection.effectiveType) {
47
- // @ts-ignore
48
- networkType = connection.effectiveType
49
- }
50
-
51
- return handle.success({ networkType })
52
- }
53
-
54
- const networkStatusManager = new CallbackManager()
55
-
56
- const networkStatusListener = async () => {
57
- const { networkType } = await getNetworkType()
58
- const isConnected = networkType !== 'none'
59
- const obj = { isConnected, networkType }
60
- networkStatusManager.trigger(obj)
61
- }
62
-
63
- /**
64
- * 在最近的八次网络请求中, 出现下列三个现象之一则判定弱网。
65
- * - 出现三次以上连接超时
66
- * - 出现三次 rtt 超过 400
67
- * - 出现三次以上的丢包
68
- * > 弱网事件通知规则是: 弱网状态变化时立即通知, 状态不变时 30s 内最多通知一次。
69
- */
70
- export const onNetworkWeakChange = temporarilyNotSupport('onNetworkWeakChange')
71
-
72
- export const onNetworkStatusChange: typeof Taro.onNetworkStatusChange = callback => {
73
- networkStatusManager.add(callback)
74
- const connection = getConnection()
75
- if (connection && networkStatusManager.count() === 1) {
76
- connection.addEventListener('change', networkStatusListener)
77
- }
78
- }
79
-
80
- export const offNetworkWeakChange = temporarilyNotSupport('offNetworkStatusChange')
81
-
82
- export const offNetworkStatusChange: typeof Taro.offNetworkStatusChange = callback => {
83
- networkStatusManager.remove(callback)
84
- const connection = getConnection()
85
- if (connection && networkStatusManager.count() === 0) {
86
- connection.removeEventListener('change', networkStatusListener)
87
- }
88
- }
89
-
90
- export const getLocalIPAddress = temporarilyNotSupport('getLocalIPAddress')
@@ -1,10 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // NFC
4
- export const stopHCE = temporarilyNotSupport('stopHCE')
5
- export const startHCE = temporarilyNotSupport('startHCE')
6
- export const sendHCEMessage = temporarilyNotSupport('sendHCEMessage')
7
- export const onHCEMessage = temporarilyNotSupport('onHCEMessage')
8
- export const offHCEMessage = temporarilyNotSupport('offHCEMessage')
9
- export const getNFCAdapter = temporarilyNotSupport('getNFCAdapter')
10
- export const getHCEState = temporarilyNotSupport('getHCEState')
@@ -1,31 +0,0 @@
1
- import Taro from '@tarojs/api'
2
-
3
- import { getParameterError, shouldBeObject } from '../../utils'
4
- import { MethodHandler } from '../../utils/handler'
5
-
6
- export const makePhoneCall: typeof Taro.makePhoneCall = (options) => {
7
- // options must be an Object
8
- const isObject = shouldBeObject(options)
9
- if (!isObject.flag) {
10
- const res = { errMsg: `makePhoneCall:fail ${isObject.msg}` }
11
- console.error(res.errMsg)
12
- return Promise.reject(res)
13
- }
14
-
15
- const { phoneNumber, success, fail, complete } = options
16
- const handle = new MethodHandler({ name: 'makePhoneCall', success, fail, complete })
17
-
18
- if (typeof phoneNumber !== 'string') {
19
- return handle.fail({
20
- errMsg: getParameterError({
21
- para: 'phoneNumber',
22
- correct: 'String',
23
- wrong: phoneNumber
24
- })
25
- })
26
- }
27
-
28
- window.location.href = `tel:${phoneNumber}`
29
-
30
- return handle.success()
31
- }
@@ -1,11 +0,0 @@
1
- import { processOpenApi } from '../../utils'
2
-
3
- // 扫码
4
- export const scanCode = processOpenApi({
5
- name: 'scanQRCode',
6
- defaultOptions: { needResult: 1 },
7
- formatResult: res => ({
8
- errMsg: res.errMsg === 'scanQRCode:ok' ? 'scanCode:ok' : res.errMsg,
9
- result: res.resultStr
10
- })
11
- })
@@ -1,9 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 屏幕
4
- export const setVisualEffectOnCapture = temporarilyNotSupport('setVisualEffectOnCapture')
5
- export const setScreenBrightness = temporarilyNotSupport('setScreenBrightness')
6
- export const setKeepScreenOn = temporarilyNotSupport('setKeepScreenOn')
7
- export const onUserCaptureScreen = temporarilyNotSupport('onUserCaptureScreen')
8
- export const offUserCaptureScreen = temporarilyNotSupport('offUserCaptureScreen')
9
- export const getScreenBrightness = temporarilyNotSupport('getScreenBrightness')
@@ -1,37 +0,0 @@
1
- import Taro from '@tarojs/api'
2
-
3
- import { MethodHandler } from '../../utils/handler'
4
-
5
- const vibrator = function vibrator (mm) {
6
- try {
7
- return window.navigator.vibrate(mm)
8
- } catch (e) {
9
- console.warn('当前浏览器不支持vibrate')
10
- }
11
- }
12
-
13
- /**
14
- * 使手机发生较短时间的振动(15 ms)。仅在 iPhone 7 / 7 Plus 以上及 Android 机型生效
15
- */
16
- export const vibrateShort: typeof Taro.vibrateShort = ({ success, fail, complete } = {}) => {
17
- const handle = new MethodHandler({ name: 'vibrateShort', success, fail, complete })
18
- if (vibrator) {
19
- vibrator(15)
20
- return handle.success()
21
- } else {
22
- return handle.fail()
23
- }
24
- }
25
-
26
- /**
27
- * 使手机发生较长时间的振动(400 ms)
28
- */
29
- export const vibrateLong: typeof Taro.vibrateLong = ({ success, fail, complete } = {}) => {
30
- const handle = new MethodHandler({ name: 'vibrateLong', success, fail, complete })
31
- if (vibrator) {
32
- vibrator(400)
33
- return handle.success()
34
- } else {
35
- return handle.fail()
36
- }
37
- }
@@ -1,14 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // Wi-Fi
4
- export const stopWifi = temporarilyNotSupport('stopWifi')
5
- export const startWifi = temporarilyNotSupport('startWifi')
6
- export const setWifiList = temporarilyNotSupport('setWifiList')
7
- export const onWifiConnectedWithPartialInfo = temporarilyNotSupport('onWifiConnectedWithPartialInfo')
8
- export const onWifiConnected = temporarilyNotSupport('onWifiConnected')
9
- export const onGetWifiList = temporarilyNotSupport('onGetWifiList')
10
- export const offWifiConnected = temporarilyNotSupport('offWifiConnected')
11
- export const offGetWifiList = temporarilyNotSupport('offGetWifiList')
12
- export const getWifiList = temporarilyNotSupport('getWifiList')
13
- export const getConnectedWifi = temporarilyNotSupport('getConnectedWifi')
14
- export const connectWifi = temporarilyNotSupport('connectWifi')
@@ -1,5 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 第三方平台
4
- export const getExtConfigSync = temporarilyNotSupport('getExtConfigSync')
5
- export const getExtConfig = temporarilyNotSupport('getExtConfig')
@@ -1,11 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 文件
4
- export const saveFileToDisk = temporarilyNotSupport('saveFileToDisk')
5
- export const saveFile = temporarilyNotSupport('saveFile')
6
- export const removeSavedFile = temporarilyNotSupport('removeSavedFile')
7
- export const openDocument = temporarilyNotSupport('openDocument')
8
- export const getSavedFileList = temporarilyNotSupport('getSavedFileList')
9
- export const getSavedFileInfo = temporarilyNotSupport('getSavedFileInfo')
10
- export const getFileSystemManager = temporarilyNotSupport('getFileSystemManager')
11
- export const getFileInfo = temporarilyNotSupport('getFileInfo')
@@ -1,10 +0,0 @@
1
- import Taro from '@tarojs/api'
2
-
3
- export const getApp: typeof Taro.getApp = function <T = TaroGeneral.IAnyObject> () {
4
- return Taro.getCurrentInstance().app as unknown as Taro.getApp.Instance<T>
5
- }
6
-
7
- export { getCurrentPages } from '@tarojs/router'
8
-
9
- // 自定义组件
10
- export const getCurrentInstance = Taro.getCurrentInstance
package/src/api/index.ts DELETED
@@ -1,24 +0,0 @@
1
- export * from './ad'
2
- export * from './ai'
3
- export * from './alipay'
4
- export * from './base'
5
- export * from './canvas'
6
- export * from './cloud'
7
- export * from './data-analysis'
8
- export * from './device'
9
- export * from './ext'
10
- export * from './files'
11
- export * from './framework'
12
- export * from './location'
13
- export * from './media'
14
- export * from './navigate'
15
- export * from './network'
16
- export * from './open-api'
17
- export * from './payment'
18
- export * from './route'
19
- export * from './share'
20
- export * from './storage'
21
- export * from './swan'
22
- export * from './ui'
23
- export * from './worker'
24
- export * from './wxml'
@@ -1,117 +0,0 @@
1
- import './style.css'
2
-
3
- import Taro from '@tarojs/api'
4
- import { stringify } from 'query-string'
5
-
6
- import { MethodHandler } from '../../utils/handler'
7
-
8
- function createLocationChooser (handler, key = LOCATION_APIKEY, mapOpt: Taro.chooseLocation.Option['mapOpts'] = {}) {
9
- const { latitude, longitude, ...opts } = mapOpt
10
- const query = {
11
- key,
12
- type: 1,
13
- coord: mapOpt.coord ?? [latitude, longitude].every(e => Number(e) >= 0) ? `${latitude},${longitude}` : undefined,
14
- referer: 'myapp',
15
- ...opts
16
- }
17
- const html = `
18
- <div class='taro_choose_location'>
19
- <div class='taro_choose_location_bar'>
20
- <div class='taro_choose_location_back'></div>
21
- <p class='taro_choose_location_title'>位置</p>
22
- <button class='taro_choose_location_submit'>完成</button>
23
- </div>
24
- <iframe class='taro_choose_location_frame' frameborder='0' src="https://apis.map.qq.com/tools/locpicker?${stringify(query, { arrayFormat: 'comma', skipNull: true })}" />
25
- </div>
26
- `
27
- const container = document.createElement('div')
28
- container.innerHTML = html
29
- const main: HTMLDivElement = container.querySelector('.taro_choose_location') as HTMLDivElement
30
-
31
- function show () {
32
- setTimeout(() => {
33
- main.style.top = '0'
34
- })
35
- }
36
-
37
- function hide () {
38
- main.style.top = '100%'
39
- }
40
-
41
- function back () {
42
- hide()
43
- handler({ errMsg: 'cancel' })
44
- }
45
-
46
- function submit () {
47
- hide()
48
- handler()
49
- }
50
-
51
- function remove () {
52
- container.remove()
53
- window.removeEventListener('popstate', back)
54
- }
55
-
56
- container.querySelector('.taro_choose_location_back')?.addEventListener('click', back)
57
- container.querySelector('.taro_choose_location_submit')?.addEventListener('click', submit)
58
-
59
- window.addEventListener('popstate', back)
60
-
61
- return {
62
- show,
63
- remove,
64
- container
65
- }
66
- }
67
-
68
- /**
69
- * 打开地图选择位置。
70
- */
71
- export const chooseLocation: typeof Taro.chooseLocation = ({ success, fail, complete, mapOpts } = {}) => {
72
- const key = LOCATION_APIKEY
73
- const handle = new MethodHandler({ name: 'chooseLocation', success, fail, complete })
74
- return new Promise((resolve, reject) => {
75
- const chooseLocation: Partial<Taro.chooseLocation.SuccessCallbackResult> = {}
76
- if (!key) {
77
- console.warn('chooseLocation api 依赖腾讯地图定位api,需要在 defineConstants 中配置 LOCATION_APIKEY')
78
- return handle.fail({
79
- errMsg: 'LOCATION_APIKEY needed'
80
- }, reject)
81
- }
82
-
83
- const onMessage = event => {
84
- // 接收位置信息,用户选择确认位置点后选点组件会触发该事件,回传用户的位置信息
85
- const loc = event.data
86
-
87
- // 防止其他应用也会向该页面 post 信息,需判断 module 是否为'locationPicker'
88
- if (!loc || loc.module !== 'locationPicker') return
89
-
90
- chooseLocation.name = loc.poiname
91
- chooseLocation.address = loc.poiaddress
92
- chooseLocation.latitude = loc.latlng.lat
93
- chooseLocation.longitude = loc.latlng.lng
94
- }
95
-
96
- const chooser = createLocationChooser(res => {
97
- window.removeEventListener('message', onMessage, false)
98
- setTimeout(() => {
99
- chooser.remove()
100
- }, 300)
101
- if (res) {
102
- return handle.fail(res, reject)
103
- } else {
104
- if (chooseLocation.latitude && chooseLocation.longitude) {
105
- return handle.success(chooseLocation, resolve)
106
- } else {
107
- return handle.fail({}, reject)
108
- }
109
- }
110
- }, key, mapOpts)
111
-
112
- document.body.appendChild(chooser.container)
113
-
114
- window.addEventListener('message', onMessage, false)
115
- chooser.show()
116
- })
117
- }