@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,80 +0,0 @@
1
- import Taro from '@tarojs/api'
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
- }
@@ -1,12 +0,0 @@
1
- export * from './audio'
2
- export * from './background-audio'
3
- export * from './camera'
4
- export * from './image'
5
- export * from './live'
6
- export * from './map'
7
- export * from './media-recorder'
8
- export * from './recorder'
9
- export * from './video'
10
- export * from './video-decoder'
11
- export * from './video-processing'
12
- export * from './voip'
@@ -1,5 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 实时音视频
4
- export const createLivePusherContext = temporarilyNotSupport('createLivePusherContext')
5
- export const createLivePlayerContext = temporarilyNotSupport('createLivePlayerContext')
@@ -1,4 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 地图
4
- export const createMapContext = temporarilyNotSupport('createMapContext')
@@ -1,4 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 画面录制器
4
- export const createMediaRecorder = temporarilyNotSupport('createMediaRecorder')
@@ -1,6 +0,0 @@
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')
@@ -1,82 +0,0 @@
1
- import Taro from '@tarojs/api'
2
-
3
- import { findDOM, shouldBeObject, temporarilyNotSupport } from '../../../utils'
4
- import { MethodHandler } from '../../../utils/handler'
5
-
6
- // 视频
7
- export const saveVideoToPhotosAlbum = temporarilyNotSupport('saveVideoToPhotosAlbum')
8
- export const openVideoEditor = temporarilyNotSupport('openVideoEditor')
9
- export const getVideoInfo = temporarilyNotSupport('getVideoInfo')
10
-
11
- /**
12
- * 创建 video 上下文 VideoContext 对象。
13
- */
14
- export const createVideoContext: typeof Taro.createVideoContext = (id, inst) => {
15
- const el = findDOM(inst) as HTMLVideoElement
16
- // TODO HTMLVideoElement to VideoContext
17
- return el?.querySelector(`taro-video-core[id=${id}]`) as unknown as Taro.VideoContext
18
- }
19
-
20
- export const compressVideo = temporarilyNotSupport('compressVideo')
21
-
22
- /**
23
- * 拍摄视频或从手机相册中选视频。
24
- */
25
- export const chooseVideo: typeof Taro.chooseVideo = (options) => {
26
- // options must be an Object
27
- const isObject = shouldBeObject(options)
28
- if (!isObject.flag) {
29
- const res = { errMsg: `chooseVideo:fail ${isObject.msg}` }
30
- console.error(res.errMsg)
31
- return Promise.reject(res)
32
- }
33
-
34
- const { success, fail, complete } = options
35
- const handle = new MethodHandler<Taro.chooseVideo.SuccessCallbackResult>({ name: 'chooseVideo', success, fail, complete })
36
- const res: Partial<Taro.chooseVideo.SuccessCallbackResult> = {
37
- tempFilePath: '',
38
- duration: 0,
39
- size: 0,
40
- height: 0,
41
- width: 0
42
- }
43
-
44
- const inputEl = document.createElement('input')
45
- inputEl.setAttribute('type', 'file')
46
- inputEl.setAttribute('multiple', 'multiple')
47
- inputEl.setAttribute('accept', 'video/*')
48
- inputEl.setAttribute('style', 'position: fixed; top: -4000px; left: -3000px; z-index: -300;')
49
- document.body.appendChild(inputEl)
50
-
51
- return new Promise<Taro.chooseVideo.SuccessCallbackResult>(resolve => {
52
- const TaroMouseEvents = document.createEvent('MouseEvents')
53
- TaroMouseEvents.initEvent('click', true, true)
54
- inputEl.dispatchEvent(TaroMouseEvents)
55
- inputEl.onchange = function (e) {
56
- const target = e.target as HTMLInputElement
57
- const file = target.files?.[0]
58
- const reader = new FileReader()
59
- reader.onload = function (event: ProgressEvent<FileReader>) {
60
- const videoEl = document.createElement('video')
61
- const url = event.target?.result as string
62
- videoEl.preload = 'metadata'
63
- videoEl.src = url
64
- videoEl.onloadedmetadata = () => {
65
- res.tempFilePath = url
66
- res.duration = videoEl.duration
67
- res.size = event.total
68
- res.height = videoEl.videoHeight
69
- res.width = videoEl.videoHeight
70
- return handle.success(res, resolve)
71
- }
72
- }
73
- if (file) {
74
- reader.readAsDataURL(file)
75
- }
76
- }
77
- }).finally(() => {
78
- document.body.removeChild(inputEl)
79
- })
80
- }
81
-
82
- export const chooseMedia = temporarilyNotSupport('chooseMedia')
@@ -1,4 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 视频解码器
4
- export const createVideoDecoder = temporarilyNotSupport('createVideoDecoder')
@@ -1,4 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 音视频合成
4
- export const createMediaContainer = temporarilyNotSupport('createMediaContainer')
@@ -1,17 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 实时语音
4
- export const updateVoIPChatMuteConfig = temporarilyNotSupport('updateVoIPChatMuteConfig')
5
- export const subscribeVoIPVideoMembers = temporarilyNotSupport('subscribeVoIPVideoMembers')
6
- export const setEnable1v1Chat = temporarilyNotSupport('setEnable1v1Chat')
7
- export const onVoIPVideoMembersChanged = temporarilyNotSupport('onVoIPVideoMembersChanged')
8
- export const onVoIPChatStateChanged = temporarilyNotSupport('onVoIPChatStateChanged')
9
- export const onVoIPChatSpeakersChanged = temporarilyNotSupport('onVoIPChatSpeakersChanged')
10
- export const onVoIPChatMembersChanged = temporarilyNotSupport('onVoIPChatMembersChanged')
11
- export const onVoIPChatInterrupted = temporarilyNotSupport('onVoIPChatInterrupted')
12
- export const offVoIPVideoMembersChanged = temporarilyNotSupport('offVoIPVideoMembersChanged')
13
- export const offVoIPChatStateChanged = temporarilyNotSupport('offVoIPChatStateChanged')
14
- export const offVoIPChatMembersChanged = temporarilyNotSupport('offVoIPChatMembersChanged')
15
- export const offVoIPChatInterrupted = temporarilyNotSupport('offVoIPChatInterrupted')
16
- export const joinVoIPChat = temporarilyNotSupport('joinVoIPChat')
17
- export const exitVoIPChat = temporarilyNotSupport('exitVoIPChat')
@@ -1,7 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 跳转
4
- export const openEmbeddedMiniProgram = temporarilyNotSupport('openEmbeddedMiniProgram')
5
- export const navigateToMiniProgram = temporarilyNotSupport('navigateToMiniProgram')
6
- export const navigateBackMiniProgram = temporarilyNotSupport('navigateBackMiniProgram')
7
- export const exitMiniProgram = temporarilyNotSupport('exitMiniProgram')
@@ -1,141 +0,0 @@
1
- import Taro from '@tarojs/api'
2
-
3
- import { CallbackManager } from '../../utils/handler'
4
- import { NETWORK_TIMEOUT, setHeader, XHR_STATS } from './utils'
5
-
6
- const createDownloadTask = ({ url, header, success, error }): Taro.DownloadTask => {
7
- let timeout: ReturnType<typeof setTimeout>
8
- const apiName = 'downloadFile'
9
- const xhr = new XMLHttpRequest()
10
- const callbackManager = {
11
- headersReceived: new CallbackManager(),
12
- progressUpdate: new CallbackManager()
13
- }
14
-
15
- xhr.open('GET', url, true)
16
- xhr.responseType = 'blob'
17
- setHeader(xhr, header)
18
-
19
- xhr.onprogress = e => {
20
- const { loaded, total } = e
21
- callbackManager.progressUpdate.trigger({
22
- progress: Math.round(loaded / total * 100),
23
- totalBytesWritten: loaded,
24
- totalBytesExpectedToWrite: total
25
- })
26
- }
27
-
28
- xhr.onreadystatechange = () => {
29
- if (xhr.readyState !== XHR_STATS.HEADERS_RECEIVED) return
30
- callbackManager.headersReceived.trigger({
31
- header: xhr.getAllResponseHeaders()
32
- })
33
- }
34
-
35
- xhr.onload = () => {
36
- const response = xhr.response
37
- const status = xhr.status
38
- success({
39
- errMsg: `${apiName}:ok`,
40
- statusCode: status,
41
- tempFilePath: window.URL.createObjectURL(response)
42
- })
43
- }
44
-
45
- xhr.onabort = () => {
46
- clearTimeout(timeout)
47
- error({
48
- errMsg: `${apiName}:fail abort`
49
- })
50
- }
51
-
52
- xhr.onerror = (e: ProgressEvent<EventTarget> & { message?: string }) => {
53
- error({
54
- errMsg: `${apiName}:fail ${e.message}`
55
- })
56
- }
57
-
58
- /**
59
- * 中断任务
60
- */
61
- const abort = () => {
62
- xhr.abort()
63
- }
64
-
65
- const send = () => {
66
- xhr.send()
67
- timeout = setTimeout(() => {
68
- xhr.onabort = null
69
- xhr.onload = null
70
- xhr.onprogress = null
71
- xhr.onreadystatechange = null
72
- xhr.onerror = null
73
- abort()
74
- error({
75
- errMsg: `${apiName}:fail timeout`
76
- })
77
- }, NETWORK_TIMEOUT)
78
- }
79
-
80
- send()
81
-
82
- /**
83
- * 监听 HTTP Response Header 事件。会比请求完成事件更早
84
- * @param {HeadersReceivedCallback} callback HTTP Response Header 事件的回调函数
85
- */
86
- const onHeadersReceived = callbackManager.headersReceived.add
87
- /**
88
- * 取消监听 HTTP Response Header 事件
89
- * @param {HeadersReceivedCallback} callback HTTP Response Header 事件的回调函数
90
- */
91
- const offHeadersReceived = callbackManager.headersReceived.remove
92
-
93
- /**
94
- * 监听进度变化事件
95
- * @param {ProgressUpdateCallback} callback HTTP Response Header 事件的回调函数
96
- */
97
- const onProgressUpdate = callbackManager.progressUpdate.add
98
- /**
99
- * 取消监听进度变化事件
100
- * @param {ProgressUpdateCallback} callback HTTP Response Header 事件的回调函数
101
- */
102
- const offProgressUpdate = callbackManager.progressUpdate.remove
103
-
104
- return {
105
- abort,
106
- onHeadersReceived,
107
- offHeadersReceived,
108
- onProgressUpdate,
109
- offProgressUpdate
110
- }
111
- }
112
-
113
- /**
114
- * 下载文件资源到本地。客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径。使用前请注意阅读相关说明。
115
- * 注意:请在服务端响应的 header 中指定合理的 Content-Type 字段,以保证客户端正确处理文件类型。
116
- */
117
- export const downloadFile: typeof Taro.downloadFile = ({ url, header, success, fail, complete }) => {
118
- let task!: Taro.DownloadTask
119
- const result: ReturnType<typeof Taro.downloadFile> = new Promise((resolve, reject) => {
120
- task = createDownloadTask({
121
- url,
122
- header,
123
- success: res => {
124
- success && success(res)
125
- complete && complete(res)
126
- resolve(res)
127
- },
128
- error: res => {
129
- fail && fail(res)
130
- complete && complete(res)
131
- reject(res)
132
- }
133
- })
134
- }) as any
135
-
136
- result.headersReceive = task.onHeadersReceived
137
- result.progress = task.onProgressUpdate
138
- result.abort = task.abort
139
-
140
- return result
141
- }
@@ -1,7 +0,0 @@
1
- export * from './download'
2
- export * from './mdns'
3
- export * from './request'
4
- export * from './tcp'
5
- export * from './udp'
6
- export * from './upload'
7
- export * from './websocket'
@@ -1,13 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // mDNS
4
- export const stopLocalServiceDiscovery = temporarilyNotSupport('stopLocalServiceDiscovery')
5
- export const startLocalServiceDiscovery = temporarilyNotSupport('startLocalServiceDiscovery')
6
- export const onLocalServiceResolveFail = temporarilyNotSupport('onLocalServiceResolveFail')
7
- export const onLocalServiceLost = temporarilyNotSupport('onLocalServiceLost')
8
- export const onLocalServiceFound = temporarilyNotSupport('onLocalServiceFound')
9
- export const onLocalServiceDiscoveryStop = temporarilyNotSupport('onLocalServiceDiscoveryStop')
10
- export const offLocalServiceResolveFail = temporarilyNotSupport('offLocalServiceResolveFail')
11
- export const offLocalServiceLost = temporarilyNotSupport('offLocalServiceLost')
12
- export const offLocalServiceFound = temporarilyNotSupport('offLocalServiceFound')
13
- export const offLocalServiceDiscoveryStop = temporarilyNotSupport('offLocalServiceDiscoveryStop')
@@ -1,135 +0,0 @@
1
- import 'whatwg-fetch'
2
-
3
- import Taro from '@tarojs/api'
4
- import jsonpRetry from 'jsonp-retry'
5
-
6
- import { serializeParams } from '../../../utils'
7
-
8
- // @ts-ignore
9
- const { Link } = Taro
10
-
11
- function generateRequestUrlWithParams (url: string, params?: unknown) {
12
- params = typeof params === 'string' ? params : serializeParams(params)
13
- if (params) {
14
- url += (~url.indexOf('?') ? '&' : '?') + params
15
- }
16
- url = url.replace('?&', '?')
17
- return url
18
- }
19
-
20
- // FIXME 移除 any 标注
21
- function _request (options) {
22
- options = options || {}
23
- if (typeof options === 'string') {
24
- options = {
25
- url: options
26
- }
27
- }
28
- const { success, complete, fail } = options
29
- let url = options.url
30
- const params: any = {}
31
- const res: any = {}
32
- if (options.jsonp) {
33
- Object.assign(params, options)
34
- params.params = options.data
35
- params.cache = options.jsonpCache
36
- if (typeof options.jsonp === 'string') {
37
- params.name = options.jsonp
38
- }
39
- delete params.jsonp
40
- return jsonpRetry(url, params)
41
- .then(data => {
42
- res.statusCode = 200
43
- res.data = data
44
- typeof success === 'function' && success(res)
45
- typeof complete === 'function' && complete(res)
46
- return res
47
- })
48
- .catch(err => {
49
- typeof fail === 'function' && fail(err)
50
- typeof complete === 'function' && complete(res)
51
- return Promise.reject(err)
52
- })
53
- }
54
- params.method = options.method || 'GET'
55
- const methodUpper = params.method.toUpperCase()
56
- params.cache = options.cache || 'default'
57
- if (methodUpper === 'GET' || methodUpper === 'HEAD') {
58
- url = generateRequestUrlWithParams(url, options.data)
59
- } else if (typeof options.data === 'object') {
60
- options.header = options.header || {}
61
-
62
- const keyOfContentType = Object.keys(options.header).find(item => item.toLowerCase() === 'content-type')
63
- if (!keyOfContentType) {
64
- options.header['Content-Type'] = 'application/json'
65
- }
66
- const contentType = options.header[keyOfContentType || 'Content-Type']
67
-
68
- if (contentType.indexOf('application/json') >= 0) {
69
- params.body = JSON.stringify(options.data)
70
- } else if (contentType.indexOf('application/x-www-form-urlencoded') >= 0) {
71
- params.body = serializeParams(options.data)
72
- } else {
73
- params.body = options.data
74
- }
75
- } else {
76
- params.body = options.data
77
- }
78
- if (options.header) {
79
- params.headers = options.header
80
- }
81
- if (options.mode) {
82
- params.mode = options.mode
83
- }
84
- if (options.signal) {
85
- params.signal = options.signal
86
- }
87
- params.credentials = options.credentials
88
- return fetch(url, params)
89
- .then(response => {
90
- if (!response) {
91
- const errorResponse = { ok: false }
92
- throw errorResponse
93
- }
94
- res.statusCode = response.status
95
- res.header = {}
96
- for (const key of response.headers.keys()) {
97
- res.header[key] = response.headers.get(key)
98
- }
99
- if (!response.ok) {
100
- throw response
101
- }
102
- if (options.responseType === 'arraybuffer') {
103
- return response.arrayBuffer()
104
- }
105
- if (res.statusCode !== 204) {
106
- if (options.dataType === 'json' || typeof options.dataType === 'undefined') {
107
- return response.json()
108
- }
109
- }
110
- if (options.responseType === 'text' || options.dataType === 'text') {
111
- return response.text()
112
- }
113
- return Promise.resolve(null)
114
- })
115
- .then(data => {
116
- res.data = data
117
- typeof success === 'function' && success(res)
118
- typeof complete === 'function' && complete(res)
119
- return res
120
- })
121
- .catch(err => {
122
- typeof fail === 'function' && fail(err)
123
- typeof complete === 'function' && complete(res)
124
- return Promise.reject(err)
125
- })
126
- }
127
-
128
- function taroInterceptor (chain) {
129
- return _request(chain.requestParams)
130
- }
131
-
132
- const link = new Link(taroInterceptor)
133
-
134
- export const request: typeof Taro.request = link.request.bind(link)
135
- export const addInterceptor = link.addInterceptor.bind(link)
@@ -1,4 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // TCP 通信
4
- export const createTCPSocket = temporarilyNotSupport('createTCPSocket')
@@ -1,4 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // UDP 通信
4
- export const createUDPSocket = temporarilyNotSupport('createUDPSocket')