@tarojs/taro-h5 3.3.16 → 3.3.20

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 (306) hide show
  1. package/dist/api/ad/index.js +3 -0
  2. package/dist/api/ai/facial.js +4 -0
  3. package/dist/api/ai/index.js +2 -0
  4. package/dist/api/ai/visual.js +2 -0
  5. package/dist/api/alipay/index.js +2 -0
  6. package/dist/api/base/crypto.js +2 -0
  7. package/dist/api/base/debug.js +4 -0
  8. package/dist/api/base/index.js +16 -0
  9. package/dist/api/base/performance.js +3 -0
  10. package/dist/api/base/system/index.js +2 -0
  11. package/dist/api/base/system/info.js +56 -0
  12. package/dist/api/base/system/network.js +52 -0
  13. package/dist/api/base/update.js +3 -0
  14. package/dist/api/base/weapp/app-event.js +17 -0
  15. package/dist/api/base/weapp/life-cycle.js +3 -0
  16. package/dist/api/canvas/CanvasContext.js +182 -0
  17. package/dist/api/canvas/canvasGetImageData.js +21 -0
  18. package/dist/api/canvas/canvasPutImageData.js +17 -0
  19. package/dist/api/canvas/canvasToTempFilePath.js +18 -0
  20. package/dist/api/canvas/createCanvasContext.js +13 -0
  21. package/dist/api/canvas/index.js +7 -0
  22. package/dist/api/cloud/index.js +14 -0
  23. package/dist/api/data-analysis/index.js +5 -0
  24. package/dist/api/device/accelerometer.js +71 -0
  25. package/dist/api/device/accessibility.js +2 -0
  26. package/dist/api/device/battery.js +3 -0
  27. package/dist/api/device/bluetooth-ble.js +17 -0
  28. package/dist/api/device/bluetooth-peripheral.js +4 -0
  29. package/dist/api/device/bluetooth.js +14 -0
  30. package/dist/api/device/calendar.js +3 -0
  31. package/dist/api/device/clipboard.js +48 -0
  32. package/dist/api/device/compass.js +52 -0
  33. package/dist/api/device/contact.js +3 -0
  34. package/dist/api/device/crypto.js +2 -0
  35. package/dist/api/device/gyroscope.js +5 -0
  36. package/dist/api/device/iBeacon.js +8 -0
  37. package/dist/api/device/index.js +22 -0
  38. package/dist/api/device/keyboard.js +5 -0
  39. package/dist/api/device/memory.js +3 -0
  40. package/dist/api/device/motion.js +69 -0
  41. package/dist/api/device/nfc.js +8 -0
  42. package/dist/api/device/phone.js +23 -0
  43. package/dist/api/device/scan.js +5 -0
  44. package/dist/api/device/screen.js +7 -0
  45. package/dist/api/device/vibrate.js +29 -0
  46. package/dist/api/device/wifi.js +11 -0
  47. package/dist/api/ext/index.js +3 -0
  48. package/dist/api/files/index.js +9 -0
  49. package/dist/api/framework/index.js +6 -0
  50. package/dist/api/index.js +24 -0
  51. package/dist/api/location/chooseLocation.js +88 -0
  52. package/dist/api/location/index.js +12 -0
  53. package/dist/api/location/style.css +79 -0
  54. package/dist/api/media/audio/index.js +81 -0
  55. package/dist/api/media/background-audio.js +10 -0
  56. package/dist/api/media/camera.js +2 -0
  57. package/dist/api/media/editor.js +17 -0
  58. package/dist/api/media/image/chooseImage.js +70 -0
  59. package/dist/api/media/image/getImageInfo.js +27 -0
  60. package/dist/api/media/image/index.js +8 -0
  61. package/dist/api/media/image/previewImage.js +57 -0
  62. package/dist/api/media/index.js +13 -0
  63. package/dist/api/media/live.js +3 -0
  64. package/dist/api/media/map.js +2 -0
  65. package/dist/api/media/media-recorder.js +2 -0
  66. package/dist/api/media/recorder.js +4 -0
  67. package/dist/api/media/video/index.js +65 -0
  68. package/dist/api/media/video-decoder.js +2 -0
  69. package/dist/api/media/video-processing.js +2 -0
  70. package/dist/api/media/voip.js +15 -0
  71. package/dist/api/navigate/index.js +5 -0
  72. package/dist/api/network/download.js +101 -0
  73. package/dist/api/network/index.js +7 -0
  74. package/dist/api/network/mdns.js +11 -0
  75. package/dist/api/network/request/index.js +123 -0
  76. package/dist/api/network/tcp.js +2 -0
  77. package/dist/api/network/udp.js +2 -0
  78. package/dist/api/network/upload.js +129 -0
  79. package/dist/api/network/utils.js +30 -0
  80. package/dist/api/network/websocket/index.js +65 -0
  81. package/dist/api/network/websocket/socketTask.js +61 -0
  82. package/dist/api/open-api/account.js +2 -0
  83. package/dist/api/open-api/address.js +2 -0
  84. package/dist/api/open-api/authorize.js +3 -0
  85. package/dist/api/open-api/card.js +3 -0
  86. package/dist/api/open-api/channels-live.js +7 -0
  87. package/dist/api/open-api/customer-service.js +2 -0
  88. package/dist/api/open-api/facial.js +5 -0
  89. package/dist/api/open-api/favorites.js +3 -0
  90. package/dist/api/open-api/group.js +2 -0
  91. package/dist/api/open-api/index.js +18 -0
  92. package/dist/api/open-api/invoice.js +3 -0
  93. package/dist/api/open-api/license-plate.js +2 -0
  94. package/dist/api/open-api/login.js +4 -0
  95. package/dist/api/open-api/red-package.js +2 -0
  96. package/dist/api/open-api/settings.js +3 -0
  97. package/dist/api/open-api/soter.js +4 -0
  98. package/dist/api/open-api/subscribe-message.js +2 -0
  99. package/dist/api/open-api/user-info.js +3 -0
  100. package/dist/api/open-api/werun.js +3 -0
  101. package/dist/api/payment/index.js +3 -0
  102. package/dist/api/route/index.js +1 -0
  103. package/dist/api/share/index.js +11 -0
  104. package/dist/api/storage/background-fetch.js +5 -0
  105. package/dist/api/storage/index.js +152 -0
  106. package/dist/api/swan/index.js +22 -0
  107. package/dist/api/taro.js +59 -0
  108. package/dist/api/ui/animation/index.js +250 -0
  109. package/dist/api/ui/background.js +3 -0
  110. package/dist/api/ui/custom-component.js +2 -0
  111. package/dist/api/ui/fonts.js +2 -0
  112. package/dist/api/ui/index.js +12 -0
  113. package/dist/api/ui/interaction/actionSheet.js +172 -0
  114. package/dist/api/ui/interaction/index.js +263 -0
  115. package/dist/api/ui/interaction/modal.js +185 -0
  116. package/dist/api/ui/interaction/toast.js +179 -0
  117. package/dist/api/ui/menu.js +2 -0
  118. package/dist/api/ui/navigation-bar/index.js +37 -0
  119. package/dist/api/ui/pull-down-refresh.js +20 -0
  120. package/dist/api/ui/scroll/index.js +80 -0
  121. package/dist/api/ui/sticky.js +2 -0
  122. package/dist/api/ui/tab-bar.js +250 -0
  123. package/dist/api/ui/window.js +22 -0
  124. package/dist/api/utils/handler.js +64 -0
  125. package/dist/api/utils/index.js +141 -0
  126. package/dist/api/worker/index.js +2 -0
  127. package/dist/api/wxml/index.js +6 -0
  128. package/dist/api/wxml/nodesRef.js +42 -0
  129. package/dist/api/wxml/selectorQuery.js +188 -0
  130. package/dist/index.cjs.js +7477 -10829
  131. package/dist/index.js +4 -0
  132. package/dist/taroApis.js +1 -1
  133. package/dist/types/type.js +2 -0
  134. package/package.json +12 -15
  135. package/src/api/ad/index.ts +5 -0
  136. package/src/api/ai/facial.ts +6 -0
  137. package/src/api/ai/index.ts +2 -0
  138. package/src/api/ai/visual.ts +4 -0
  139. package/src/api/alipay/index.ts +4 -0
  140. package/src/api/base/crypto.ts +4 -0
  141. package/src/api/base/debug.ts +5 -0
  142. package/src/api/base/index.ts +23 -0
  143. package/src/api/base/performance.ts +5 -0
  144. package/src/api/base/system/index.ts +2 -0
  145. package/src/api/base/system/info.ts +64 -0
  146. package/src/api/base/system/network.ts +70 -0
  147. package/src/api/base/update.ts +5 -0
  148. package/src/api/base/weapp/app-event.ts +19 -0
  149. package/src/api/base/weapp/life-cycle.ts +5 -0
  150. package/src/api/canvas/CanvasContext.ts +233 -0
  151. package/src/api/canvas/canvasGetImageData.ts +27 -0
  152. package/src/api/canvas/canvasPutImageData.ts +24 -0
  153. package/src/api/canvas/canvasToTempFilePath.ts +24 -0
  154. package/src/api/canvas/createCanvasContext.ts +18 -0
  155. package/src/api/canvas/index.ts +10 -0
  156. package/src/api/cloud/index.ts +27 -0
  157. package/src/api/data-analysis/index.ts +6 -0
  158. package/src/api/device/accelerometer.ts +87 -0
  159. package/src/api/device/accessibility.ts +4 -0
  160. package/src/api/device/battery.ts +5 -0
  161. package/src/api/device/bluetooth-ble.ts +19 -0
  162. package/src/api/device/bluetooth-peripheral.ts +6 -0
  163. package/src/api/device/bluetooth.ts +16 -0
  164. package/src/api/device/calendar.ts +5 -0
  165. package/src/api/device/clipboard.ts +67 -0
  166. package/src/api/device/compass.ts +67 -0
  167. package/src/api/device/contact.ts +5 -0
  168. package/src/api/device/crypto.ts +4 -0
  169. package/src/api/device/gyroscope.ts +7 -0
  170. package/src/api/device/iBeacon.ts +10 -0
  171. package/src/api/device/index.ts +22 -0
  172. package/src/api/device/keyboard.ts +7 -0
  173. package/src/api/device/memory.ts +5 -0
  174. package/src/api/device/motion.ts +85 -0
  175. package/src/api/device/nfc.ts +10 -0
  176. package/src/api/device/phone.ts +30 -0
  177. package/src/api/device/scan.ts +7 -0
  178. package/src/api/device/screen.ts +9 -0
  179. package/src/api/device/vibrate.ts +36 -0
  180. package/src/api/device/wifi.ts +13 -0
  181. package/src/api/ext/index.ts +5 -0
  182. package/src/api/files/index.ts +11 -0
  183. package/src/api/framework/index.ts +10 -0
  184. package/src/api/index.ts +25 -0
  185. package/src/api/location/chooseLocation.ts +106 -0
  186. package/src/api/location/index.ts +19 -0
  187. package/src/api/location/style.css +8 -8
  188. package/src/api/media/audio/index.ts +105 -0
  189. package/src/api/media/background-audio.ts +12 -0
  190. package/src/api/media/camera.ts +4 -0
  191. package/src/api/media/editor.ts +29 -0
  192. package/src/api/media/image/chooseImage.ts +78 -0
  193. package/src/api/media/image/getImageInfo.ts +35 -0
  194. package/src/api/media/image/index.ts +13 -0
  195. package/src/api/media/image/previewImage.ts +80 -0
  196. package/src/api/media/index.ts +13 -0
  197. package/src/api/media/live.ts +5 -0
  198. package/src/api/media/map.ts +4 -0
  199. package/src/api/media/media-recorder.ts +4 -0
  200. package/src/api/media/recorder.ts +6 -0
  201. package/src/api/media/video/index.ts +82 -0
  202. package/src/api/media/video-decoder.ts +4 -0
  203. package/src/api/media/video-processing.ts +4 -0
  204. package/src/api/media/voip.ts +17 -0
  205. package/src/api/navigate/index.ts +7 -0
  206. package/src/api/{fileTransfer/downloadFile.js → network/download.ts} +16 -27
  207. package/src/api/network/index.ts +7 -0
  208. package/src/api/network/mdns.ts +13 -0
  209. package/src/api/{request/index.js → network/request/index.ts} +9 -6
  210. package/src/api/network/tcp.ts +4 -0
  211. package/src/api/network/udp.ts +4 -0
  212. package/src/api/{fileTransfer/uploadFile.js → network/upload.ts} +28 -32
  213. package/src/api/{fileTransfer/utils.js → network/utils.ts} +0 -0
  214. package/src/api/network/websocket/index.ts +88 -0
  215. package/src/api/{webSocket/socketTask.js → network/websocket/socketTask.ts} +17 -7
  216. package/src/api/open-api/account.ts +4 -0
  217. package/src/api/open-api/address.ts +4 -0
  218. package/src/api/open-api/authorize.ts +5 -0
  219. package/src/api/open-api/card.ts +5 -0
  220. package/src/api/open-api/channels-live.ts +9 -0
  221. package/src/api/open-api/customer-service.ts +4 -0
  222. package/src/api/open-api/facial.ts +7 -0
  223. package/src/api/open-api/favorites.ts +5 -0
  224. package/src/api/open-api/group.ts +4 -0
  225. package/src/api/open-api/index.ts +18 -0
  226. package/src/api/open-api/invoice.ts +5 -0
  227. package/src/api/open-api/license-plate.ts +4 -0
  228. package/src/api/open-api/login.ts +6 -0
  229. package/src/api/open-api/red-package.ts +4 -0
  230. package/src/api/open-api/settings.ts +5 -0
  231. package/src/api/open-api/soter.ts +6 -0
  232. package/src/api/open-api/subscribe-message.ts +4 -0
  233. package/src/api/open-api/user-info.ts +5 -0
  234. package/src/api/open-api/werun.ts +5 -0
  235. package/src/api/payment/index.ts +5 -0
  236. package/src/api/route/index.ts +10 -0
  237. package/src/api/share/index.ts +13 -0
  238. package/src/api/storage/background-fetch.ts +7 -0
  239. package/src/api/storage/index.ts +181 -0
  240. package/src/api/swan/index.ts +31 -0
  241. package/src/{taro/index.js → api/taro.ts} +133 -149
  242. package/src/api/{createAnimation/index.js → ui/animation/index.ts} +52 -41
  243. package/src/api/ui/background.ts +5 -0
  244. package/src/api/ui/custom-component.ts +4 -0
  245. package/src/api/ui/fonts.ts +4 -0
  246. package/src/api/ui/index.ts +12 -0
  247. package/src/api/ui/interaction/actionSheet.ts +212 -0
  248. package/src/api/{interactive/index.js → ui/interaction/index.ts} +93 -77
  249. package/src/api/ui/interaction/modal.ts +237 -0
  250. package/src/api/{interactive/toast.js → ui/interaction/toast.ts} +35 -33
  251. package/src/api/ui/menu.ts +4 -0
  252. package/src/api/ui/navigation-bar/index.ts +52 -0
  253. package/src/api/ui/pull-down-refresh.ts +27 -0
  254. package/src/api/ui/scroll/index.ts +85 -0
  255. package/src/api/ui/sticky.ts +4 -0
  256. package/src/api/ui/tab-bar.ts +326 -0
  257. package/src/api/ui/window.ts +37 -0
  258. package/src/api/utils/handler.ts +105 -0
  259. package/src/api/utils/{index.js → index.ts} +36 -115
  260. package/src/api/worker/index.ts +4 -0
  261. package/src/api/wxml/index.ts +9 -0
  262. package/src/api/wxml/nodesRef.ts +56 -0
  263. package/src/api/wxml/selectorQuery.ts +219 -0
  264. package/src/index.ts +6 -0
  265. package/src/types/api.d.ts +4 -0
  266. package/src/types/define.d.ts +2 -0
  267. package/{types → src/types}/index.d.ts +0 -0
  268. package/{types → src/types}/type.ts +1 -1
  269. package/src/api/accelerometer/index.js +0 -105
  270. package/src/api/audio/index.js +0 -137
  271. package/src/api/canvas/canvasGetImageData.js +0 -44
  272. package/src/api/canvas/canvasPutImageData.js +0 -45
  273. package/src/api/canvas/canvasToTempFilePath.js +0 -49
  274. package/src/api/canvas/createCanvasContext.js +0 -340
  275. package/src/api/canvas/index.js +0 -4
  276. package/src/api/clipboard/index.js +0 -113
  277. package/src/api/compass/index.js +0 -99
  278. package/src/api/createSelectorQuery/index.js +0 -193
  279. package/src/api/deviceMotion/index.js +0 -105
  280. package/src/api/fileTransfer/index.js +0 -2
  281. package/src/api/image/chooseImage.js +0 -87
  282. package/src/api/image/getImageInfo.js +0 -74
  283. package/src/api/image/index.js +0 -7
  284. package/src/api/image/previewImage.js +0 -94
  285. package/src/api/index.js +0 -29
  286. package/src/api/interactive/actionSheet.js +0 -214
  287. package/src/api/interactive/modal.js +0 -256
  288. package/src/api/location/chooseLocation.js +0 -143
  289. package/src/api/location/index.js +0 -5
  290. package/src/api/navigationBar/index.js +0 -57
  291. package/src/api/open/index.js +0 -5
  292. package/src/api/others/index.js +0 -43
  293. package/src/api/pullDownRefresh/index.js +0 -51
  294. package/src/api/scroll/index.js +0 -99
  295. package/src/api/storage/index.js +0 -211
  296. package/src/api/system/index.js +0 -9
  297. package/src/api/system/info.js +0 -36
  298. package/src/api/system/network.js +0 -68
  299. package/src/api/tabBar/index.js +0 -402
  300. package/src/api/unsupportedApi/index.js +0 -278
  301. package/src/api/vibrate/index.js +0 -49
  302. package/src/api/video/index.js +0 -87
  303. package/src/api/webSocket/index.js +0 -103
  304. package/src/api/window/index.js +0 -38
  305. package/src/index.cjs.js +0 -11
  306. package/src/index.js +0 -6
@@ -0,0 +1,11 @@
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')
@@ -0,0 +1,10 @@
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
@@ -0,0 +1,25 @@
1
+ export * from './ad'
2
+ export * from './ai'
3
+ export * from './base'
4
+ export * from './canvas'
5
+ export * from './cloud'
6
+ export * from './data-analysis'
7
+ export * from './device'
8
+ export * from './ext'
9
+ export * from './files'
10
+ export * from './framework'
11
+ export * from './location'
12
+ export * from './media'
13
+ export * from './navigate'
14
+ export * from './network'
15
+ export * from './open-api'
16
+ export * from './payment'
17
+ export * from './route'
18
+ export * from './share'
19
+ export * from './storage'
20
+ export * from './ui'
21
+ export * from './worker'
22
+ export * from './wxml'
23
+
24
+ export * from './alipay'
25
+ export * from './swan'
@@ -0,0 +1,106 @@
1
+ import Taro from '@tarojs/api'
2
+ import { MethodHandler } from '../utils/handler'
3
+ import './style.css'
4
+
5
+ function createLocationChooser (handler, key = LOCATION_APIKEY) {
6
+ const html = `
7
+ <div class='taro_choose_location'>
8
+ <div class='taro_choose_location_bar'>
9
+ <div class='taro_choose_location_back'></div>
10
+ <p class='taro_choose_location_title'>位置</p>
11
+ <button class='taro_choose_location_submit'>完成</button>
12
+ </div>
13
+ <iframe class='taro_choose_location_frame' frameborder='0' src='https://apis.map.qq.com/tools/locpicker?search=1&type=1&key=${key}&referer=myapp'></iframe>
14
+ </div>
15
+ `
16
+ const container = document.createElement('div')
17
+ container.innerHTML = html
18
+ const main: HTMLDivElement = container.querySelector('.taro_choose_location') as HTMLDivElement
19
+
20
+ function show () {
21
+ setTimeout(() => {
22
+ main.style.top = '0'
23
+ })
24
+ }
25
+
26
+ function hide () {
27
+ main.style.top = '100%'
28
+ }
29
+
30
+ function back () {
31
+ hide()
32
+ handler({ errMsg: 'cancel' })
33
+ }
34
+
35
+ function submit () {
36
+ hide()
37
+ handler()
38
+ }
39
+
40
+ function remove () {
41
+ container.remove()
42
+ window.removeEventListener('popstate', back)
43
+ }
44
+
45
+ container.querySelector('.taro_choose_location_back')?.addEventListener('click', back)
46
+ container.querySelector('.taro_choose_location_submit')?.addEventListener('click', submit)
47
+
48
+ window.addEventListener('popstate', back)
49
+
50
+ return {
51
+ show,
52
+ remove,
53
+ container
54
+ }
55
+ }
56
+
57
+ /**
58
+ * 打开地图选择位置。
59
+ */
60
+ export const chooseLocation: typeof Taro.chooseLocation = ({ success, fail, complete } = {}) => {
61
+ const key = LOCATION_APIKEY
62
+ const handle = new MethodHandler({ name: 'chooseLocation', success, fail, complete })
63
+ return new Promise((resolve, reject) => {
64
+ const chooseLocation: Partial<Taro.chooseLocation.SuccessCallbackResult> = {}
65
+ if (!key) {
66
+ console.warn('chooseLocation api 依赖腾讯地图定位api,需要在 defineConstants 中配置 LOCATION_APIKEY')
67
+ return handle.fail({
68
+ errMsg: 'LOCATION_APIKEY needed'
69
+ }, reject)
70
+ }
71
+
72
+ const onMessage = event => {
73
+ // 接收位置信息,用户选择确认位置点后选点组件会触发该事件,回传用户的位置信息
74
+ const loc = event.data
75
+
76
+ // 防止其他应用也会向该页面 post 信息,需判断 module 是否为'locationPicker'
77
+ if (!loc || loc.module !== 'locationPicker') return
78
+
79
+ chooseLocation.name = loc.poiname
80
+ chooseLocation.address = loc.poiaddress
81
+ chooseLocation.latitude = loc.latlng.lat
82
+ chooseLocation.longitude = loc.latlng.lng
83
+ }
84
+
85
+ const chooser = createLocationChooser(res => {
86
+ window.removeEventListener('message', onMessage, false)
87
+ setTimeout(() => {
88
+ chooser.remove()
89
+ }, 300)
90
+ if (res) {
91
+ return handle.fail(res, reject)
92
+ } else {
93
+ if (chooseLocation.latitude && chooseLocation.longitude) {
94
+ return handle.success(chooseLocation, resolve)
95
+ } else {
96
+ return handle.fail({}, reject)
97
+ }
98
+ }
99
+ }, key)
100
+
101
+ document.body.appendChild(chooser.container)
102
+
103
+ window.addEventListener('message', onMessage, false)
104
+ chooser.show()
105
+ })
106
+ }
@@ -0,0 +1,19 @@
1
+ import { processOpenApi, temporarilyNotSupport } from '../utils/index'
2
+
3
+ // 位置
4
+ export const stopLocationUpdate = temporarilyNotSupport('stopLocationUpdate')
5
+ export const startLocationUpdateBackground = temporarilyNotSupport('startLocationUpdateBackground')
6
+ export const startLocationUpdate = temporarilyNotSupport('startLocationUpdate')
7
+
8
+ export const openLocation = processOpenApi('openLocation', { scale: 18 })
9
+
10
+ export const onLocationChangeError = temporarilyNotSupport('onLocationChangeError')
11
+ export const onLocationChange = temporarilyNotSupport('onLocationChange')
12
+ export const offLocationChangeError = temporarilyNotSupport('offLocationChangeError')
13
+ export const offLocationChange = temporarilyNotSupport('offLocationChange')
14
+
15
+ export const getLocation = processOpenApi('getLocation')
16
+
17
+ export const choosePoi = temporarilyNotSupport('choosePoi')
18
+
19
+ export * from './chooseLocation'
@@ -1,4 +1,4 @@
1
- .taro_chooselocation {
1
+ .taro_choose_location {
2
2
  position: fixed;
3
3
  display: flex;
4
4
  flex-direction: column;
@@ -10,7 +10,7 @@
10
10
  z-index: 1;
11
11
  }
12
12
 
13
- .taro_chooselocation_bar {
13
+ .taro_choose_location_bar {
14
14
  display: flex;
15
15
  flex: 0 95px;
16
16
  height: 95px;
@@ -18,7 +18,7 @@
18
18
  color: #090909;
19
19
  }
20
20
 
21
- .taro_chooselocation_back {
21
+ .taro_choose_location_back {
22
22
  flex: 0 45px;
23
23
  position: relative;
24
24
  width: 33px;
@@ -26,7 +26,7 @@
26
26
  margin-top: 30px;
27
27
  }
28
28
 
29
- .taro_chooselocation_back::before {
29
+ .taro_choose_location_back::before {
30
30
  content: '';
31
31
  position: absolute;
32
32
  top: 0;
@@ -41,7 +41,7 @@
41
41
  border-left-color: transparent;
42
42
  }
43
43
 
44
- .taro_chooselocation_back::after {
44
+ .taro_choose_location_back::after {
45
45
  content: '';
46
46
  position: absolute;
47
47
  display: block;
@@ -56,13 +56,13 @@
56
56
  border-left-color: transparent;
57
57
  }
58
58
 
59
- .taro_chooselocation_title {
59
+ .taro_choose_location_title {
60
60
  flex: 1;
61
61
  line-height: 95px;
62
62
  padding-left: 30px;
63
63
  }
64
64
 
65
- .taro_chooselocation_submit {
65
+ .taro_choose_location_submit {
66
66
  width: 110px;
67
67
  height: 60px;
68
68
  color: #fff;
@@ -74,6 +74,6 @@
74
74
  margin: 18px 30px 0 0;
75
75
  }
76
76
 
77
- .taro_chooselocation_frame {
77
+ .taro_choose_location_frame {
78
78
  flex: 1;
79
79
  }
@@ -0,0 +1,105 @@
1
+ import Taro from '@tarojs/api'
2
+ import { temporarilyNotSupport } from '../../utils'
3
+ import { CallbackManager } from '../../utils/handler'
4
+
5
+ // 音频
6
+ class InnerAudioContext implements Taro.InnerAudioContext {
7
+ Instance?: HTMLAudioElement
8
+ errorStack: CallbackManager
9
+ stopStack: CallbackManager
10
+
11
+ constructor () {
12
+ this.Instance = new Audio()
13
+ this.errorStack = new CallbackManager()
14
+ this.stopStack = new CallbackManager()
15
+
16
+ Taro.eventCenter.on('__taroRouterChange', () => { this.stop() })
17
+ }
18
+
19
+ set autoplay (e) { this.setProperty('autoplay', e) }
20
+ get autoplay () { return this.Instance?.autoplay || false }
21
+ get buffered () { return this.Instance?.buffered.length || 0 }
22
+ get currentTime () { return this.Instance?.currentTime || 0 }
23
+ get duration () { return this.Instance?.duration || 0 }
24
+ set loop (e) { this.setProperty('loop', e) }
25
+ get loop () { return this.Instance?.loop || false }
26
+ get paused () { return this.Instance?.paused || true }
27
+ set src (e) { this.setProperty('src', e) }
28
+ get src () { return this.Instance?.src || '' }
29
+ set volume (e) { this.setProperty('volume', e) }
30
+ get volume () { return this.Instance?.volume || 0 }
31
+ set playbackRate (e) { this.setProperty('playbackRate', e) }
32
+ get playbackRate () { return this.Instance?.volume || 0 }
33
+ get obeyMuteSwitch () { return true }
34
+ set startTime (e) { this.setProperty('startTime', e) }
35
+ get startTime () { return this.Instance?.volume || 0 }
36
+
37
+ private setProperty (key: string, value: unknown) {
38
+ if (this.Instance) {
39
+ this.Instance[key] = value
40
+ }
41
+ }
42
+
43
+ play = () => this.Instance?.play()
44
+
45
+ pause = () => this.Instance?.pause()
46
+
47
+ stop = () => {
48
+ this.pause()
49
+ this.seek(0)
50
+ this.stopStack.trigger()
51
+ }
52
+
53
+ seek = (position: number) => {
54
+ if (this.Instance) {
55
+ this.Instance.currentTime = position
56
+ }
57
+ }
58
+
59
+ /**
60
+ * @TODO destroy得并不干净
61
+ */
62
+ destroy = () => {
63
+ this.stop()
64
+ if (this.Instance) {
65
+ document.body.removeChild(this.Instance)
66
+ this.Instance = undefined
67
+ }
68
+ }
69
+
70
+ onCanplay = (callback = () => {}) => this.Instance?.addEventListener('canplay', callback)
71
+ onPlay = (callback = () => {}) => this.Instance?.addEventListener('play', callback)
72
+ onPause = (callback = () => {}) => this.Instance?.addEventListener('pause', callback)
73
+ onStop = (callback = () => {}) => this.stopStack.add(callback)
74
+ onEnded = (callback = () => {}) => this.Instance?.addEventListener('ended', callback)
75
+ onTimeUpdate = (callback = () => {}) => this.Instance?.addEventListener('timeupdate', callback)
76
+ onError = (callback?: ((res: Taro.InnerAudioContext.onErrorDetail) => void)) => this.errorStack.add(callback)
77
+ onWaiting = (callback = () => {}) => this.Instance?.addEventListener('waiting', callback)
78
+ onSeeking = (callback = () => {}) => this.Instance?.addEventListener('seeking', callback)
79
+ onSeeked = (callback = () => {}) => this.Instance?.addEventListener('seeked', callback)
80
+ offCanplay = (callback = () => {}) => this.Instance?.removeEventListener('canplay', callback)
81
+ offPlay = (callback = () => {}) => this.Instance?.removeEventListener('play', callback)
82
+ offPause = (callback = () => {}) => this.Instance?.removeEventListener('pause', callback)
83
+ offStop = (callback = () => {}) => this.stopStack.remove(callback)
84
+ offEnded = (callback = () => {}) => this.Instance?.removeEventListener('ended', callback)
85
+ offTimeUpdate = (callback = () => {}) => this.Instance?.removeEventListener('timeupdate', callback)
86
+ offError = (callback = () => {}) => this.errorStack.remove(callback)
87
+ offWaiting = (callback = () => {}) => this.Instance?.removeEventListener('waiting', callback)
88
+ offSeeking = (callback = () => {}) => this.Instance?.removeEventListener('seeking', callback)
89
+ offSeeked = (callback = () => {}) => this.Instance?.removeEventListener('seeked', callback)
90
+ }
91
+
92
+ export const stopVoice = temporarilyNotSupport('stopVoice')
93
+ export const setInnerAudioOption = temporarilyNotSupport('setInnerAudioOption')
94
+ export const playVoice = temporarilyNotSupport('playVoice')
95
+ export const pauseVoice = temporarilyNotSupport('pauseVoice')
96
+ export const getAvailableAudioSources = temporarilyNotSupport('getAvailableAudioSources')
97
+ export const createWebAudioContext = temporarilyNotSupport('createWebAudioContext')
98
+ export const createMediaAudioPlayer = temporarilyNotSupport('createMediaAudioPlayer')
99
+
100
+ /**
101
+ * 创建内部 audio 上下文 InnerAudioContext 对象。
102
+ */
103
+ export const createInnerAudioContext: typeof Taro.createInnerAudioContext = () => new InnerAudioContext()
104
+
105
+ export const createAudioContext = temporarilyNotSupport('createAudioContext')
@@ -0,0 +1,12 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 背景音频
4
+ export const stopBackgroundAudio = temporarilyNotSupport('stopBackgroundAudio')
5
+ export const seekBackgroundAudio = temporarilyNotSupport('seekBackgroundAudio')
6
+ export const playBackgroundAudio = temporarilyNotSupport('playBackgroundAudio')
7
+ export const pauseBackgroundAudio = temporarilyNotSupport('pauseBackgroundAudio')
8
+ export const onBackgroundAudioStop = temporarilyNotSupport('onBackgroundAudioStop')
9
+ export const onBackgroundAudioPlay = temporarilyNotSupport('onBackgroundAudioPlay')
10
+ export const onBackgroundAudioPause = temporarilyNotSupport('onBackgroundAudioPause')
11
+ export const getBackgroundAudioPlayerState = temporarilyNotSupport('getBackgroundAudioPlayerState')
12
+ export const getBackgroundAudioManager = temporarilyNotSupport('getBackgroundAudioManager')
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 相机
4
+ export const createCameraContext = temporarilyNotSupport('createCameraContext')
@@ -0,0 +1,29 @@
1
+ import Taro from '@tarojs/api'
2
+ import { temporarilyNotSupport } from '../utils'
3
+
4
+ // 富文本
5
+ export class EditorContext implements Taro.EditorContext {
6
+ blur = temporarilyNotSupport('EditorContext.blur')
7
+
8
+ clear = temporarilyNotSupport('EditorContext.clear')
9
+
10
+ format = temporarilyNotSupport('EditorContext.format')
11
+
12
+ getContents = temporarilyNotSupport('EditorContext.getContents')
13
+
14
+ insertDivider = temporarilyNotSupport('EditorContext.insertDivider')
15
+
16
+ insertImage = temporarilyNotSupport('EditorContext.insertImage')
17
+
18
+ insertText = temporarilyNotSupport('EditorContext.insertText')
19
+
20
+ redo = temporarilyNotSupport('EditorContext.redo')
21
+
22
+ removeFormat = temporarilyNotSupport('EditorContext.removeFormat')
23
+
24
+ scrollIntoView = temporarilyNotSupport('EditorContext.scrollIntoView')
25
+
26
+ setContents = temporarilyNotSupport('EditorContext.setContents')
27
+
28
+ undo = temporarilyNotSupport('EditorContext.undo')
29
+ }
@@ -0,0 +1,78 @@
1
+ import Taro from '@tarojs/api'
2
+
3
+ import { MethodHandler } from '../../utils/handler'
4
+ import { shouldBeObject, getParameterError } from '../../utils'
5
+
6
+ /**
7
+ * 从本地相册选择图片或使用相机拍照。
8
+ */
9
+ export const chooseImage: typeof Taro.chooseImage = function (options) {
10
+ // options must be an Object
11
+ const isObject = shouldBeObject(options)
12
+ if (!isObject.flag) {
13
+ const res = { errMsg: `chooseImage:fail ${isObject.msg}` }
14
+ console.error(res.errMsg)
15
+ return Promise.reject(res)
16
+ }
17
+
18
+ const { count = 1, success, fail, complete, imageId = 'taroChooseImage' } = options
19
+ const handle = new MethodHandler({ name: 'chooseImage', success, fail, complete })
20
+ const res: Partial<Taro.chooseImage.SuccessCallbackResult> = {
21
+ tempFilePaths: [],
22
+ tempFiles: []
23
+ }
24
+
25
+ if (count && typeof count !== 'number') {
26
+ res.errMsg = getParameterError({
27
+ para: 'count',
28
+ correct: 'Number',
29
+ wrong: count
30
+ })
31
+ return handle.fail(res)
32
+ }
33
+
34
+ let el = document.getElementById(imageId)
35
+ if (!el) {
36
+ const obj = document.createElement('input')
37
+ obj.setAttribute('type', 'file')
38
+ obj.setAttribute('id', imageId)
39
+ if (count > 1) {
40
+ obj.setAttribute('multiple', 'multiple')
41
+ }
42
+ obj.setAttribute('accept', 'image/*')
43
+ obj.setAttribute('style', 'position: fixed; top: -4000px; left: -3000px; z-index: -300;')
44
+ document.body.appendChild(obj)
45
+ el = document.getElementById(imageId)
46
+ } else {
47
+ if (count > 1) {
48
+ el.setAttribute('multiple', 'multiple')
49
+ } else {
50
+ el.removeAttribute('multiple')
51
+ }
52
+ }
53
+
54
+ return new Promise(resolve => {
55
+ const TaroMouseEvents = document.createEvent('MouseEvents')
56
+ TaroMouseEvents.initEvent('click', true, true)
57
+ if (el) {
58
+ el.dispatchEvent(TaroMouseEvents)
59
+ el.onchange = function (e) {
60
+ const target = e.target as HTMLInputElement
61
+ if (target) {
62
+ const files = target.files || []
63
+ const arr = [...files]
64
+ arr && arr.forEach(item => {
65
+ const blob = new Blob([item], {
66
+ type: item.type
67
+ })
68
+ const url = URL.createObjectURL(blob)
69
+ res.tempFilePaths?.push(url)
70
+ res.tempFiles?.push({ path: url, size: item.size, type: item.type, originalFileObj: item })
71
+ })
72
+ handle.success(res, resolve)
73
+ target.value = ''
74
+ }
75
+ }
76
+ }
77
+ })
78
+ }
@@ -0,0 +1,35 @@
1
+ import Taro from '@tarojs/api'
2
+
3
+ import { shouldBeObject } from '../../utils'
4
+ import { MethodHandler } from '../../utils/handler'
5
+
6
+ /**
7
+ * 获取图片信息。网络图片需先配置download域名才能生效。
8
+ */
9
+ export const getImageInfo: typeof Taro.getImageInfo = (options) => {
10
+ // options must be an Object
11
+ const isObject = shouldBeObject(options)
12
+ if (!isObject.flag) {
13
+ const res = { errMsg: `getImageInfo:fail ${isObject.msg}` }
14
+ console.error(res.errMsg)
15
+ return Promise.reject(res)
16
+ }
17
+
18
+ const { src, success, fail, complete } = options
19
+ const handle = new MethodHandler({ name: 'getImageInfo', success, fail, complete })
20
+ return new Promise((resolve, reject) => {
21
+ const image = new Image()
22
+ image.onload = () => {
23
+ handle.success({
24
+ width: image.naturalWidth,
25
+ height: image.naturalHeight
26
+ }, resolve)
27
+ }
28
+ image.onerror = (e: any) => {
29
+ handle.fail({
30
+ errMsg: e.message
31
+ }, reject)
32
+ }
33
+ image.src = src
34
+ })
35
+ }
@@ -0,0 +1,13 @@
1
+ import { temporarilyNotSupport } from '../../utils'
2
+
3
+ // 图片
4
+ export const saveImageToPhotosAlbum = temporarilyNotSupport('saveImageToPhotosAlbum')
5
+ export const previewMedia = temporarilyNotSupport('previewMedia')
6
+
7
+ export * from './previewImage'
8
+ export * from './getImageInfo'
9
+
10
+ export const compressImage = temporarilyNotSupport('compressImage')
11
+ export const chooseMessageFile = temporarilyNotSupport('chooseMessageFile')
12
+
13
+ export * from './chooseImage'
@@ -0,0 +1,80 @@
1
+ import Taro from '@tarojs/taro'
2
+
3
+ import { shouldBeObject } from '../../utils'
4
+ import { MethodHandler } from '../../utils/handler'
5
+
6
+ /**
7
+ * previewImage api基于开源的React组件[react-wx-images-viewer](https://github.com/react-ld/react-wx-images-viewer)开发,感谢!
8
+ */
9
+
10
+ /**
11
+ * 在新页面中全屏预览图片。预览的过程中用户可以进行保存图片、发送给朋友等操作。
12
+ */
13
+ export const previewImage: typeof Taro.previewImage = async (options) => {
14
+ function loadImage (url: string, loadFail: typeof fail): Promise<Node> {
15
+ return new Promise((resolve) => {
16
+ const item = document.createElement('taro-swiper-item-core')
17
+ item.style.cssText = 'display:flex;align-items:start;justify-content:center;overflow-y:scroll;'
18
+ const image = new Image()
19
+ image.style.maxWidth = '100%'
20
+ image.src = url
21
+ const div = document.createElement('div')
22
+ div.style.cssText = 'display:flex;align-items:center;justify-content:center;max-width:100%;min-height:100%;'
23
+ div.appendChild(image)
24
+ item.appendChild(div)
25
+ // Note: 等待图片加载完后返回,会导致轮播被卡住
26
+ resolve(item)
27
+ if (typeof loadFail === 'function') {
28
+ image.addEventListener('error', (err) => {
29
+ loadFail({ errMsg: err.message })
30
+ })
31
+ }
32
+ })
33
+ }
34
+
35
+ // options must be an Object
36
+ const isObject = shouldBeObject(options)
37
+ if (!isObject.flag) {
38
+ const res = { errMsg: `previewImage:fail ${isObject.msg}` }
39
+ console.error(res.errMsg)
40
+ return Promise.reject(res)
41
+ }
42
+
43
+ const { urls = [], current = '', success, fail, complete } = options
44
+ const handle = new MethodHandler({ name: 'previewImage', success, fail, complete })
45
+ const container = document.createElement('div')
46
+ container.classList.add('preview-image')
47
+ container.style.cssText = 'position:fixed;top:0;left:0;z-index:1050;width:100%;height:100%;overflow:hidden;outline:0;background-color:#111;'
48
+ container.addEventListener('click', () => {
49
+ container.remove()
50
+ })
51
+
52
+ const swiper = document.createElement('taro-swiper-core')
53
+ // @ts-ignore
54
+ swiper.full = true
55
+
56
+ let children: Node[] = []
57
+ try {
58
+ children = await Promise.all(
59
+ urls.map(e => loadImage(e, fail))
60
+ )
61
+ } catch (error) {
62
+ return handle.fail({
63
+ errMsg: error
64
+ })
65
+ }
66
+
67
+ for (let i = 0; i < children.length; i++) {
68
+ const child = children[i]
69
+ swiper.appendChild(child)
70
+ }
71
+
72
+ const currentIndex = urls.indexOf(current)
73
+ // @ts-ignore
74
+ swiper.current = currentIndex
75
+
76
+ container.appendChild(swiper)
77
+ document.body.appendChild(container)
78
+
79
+ return handle.success()
80
+ }
@@ -0,0 +1,13 @@
1
+ export * from './audio'
2
+ export * from './background-audio'
3
+ export * from './camera'
4
+ export * from './editor'
5
+ export * from './image'
6
+ export * from './live'
7
+ export * from './map'
8
+ export * from './media-recorder'
9
+ export * from './recorder'
10
+ export * from './video'
11
+ export * from './video-decoder'
12
+ export * from './video-processing'
13
+ export * from './voip'
@@ -0,0 +1,5 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 实时音视频
4
+ export const createLivePusherContext = temporarilyNotSupport('createLivePusherContext')
5
+ export const createLivePlayerContext = temporarilyNotSupport('createLivePlayerContext')
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 地图
4
+ export const createMapContext = temporarilyNotSupport('createMapContext')
@@ -0,0 +1,4 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 画面录制器
4
+ export const createMediaRecorder = temporarilyNotSupport('createMediaRecorder')
@@ -0,0 +1,6 @@
1
+ import { temporarilyNotSupport } from '../utils'
2
+
3
+ // 录音
4
+ export const stopRecord = temporarilyNotSupport('stopRecord')
5
+ export const startRecord = temporarilyNotSupport('startRecord')
6
+ export const getRecorderManager = temporarilyNotSupport('getRecorderManager')