@tarojs/taro-h5 3.3.16 → 3.3.17

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 (169) hide show
  1. package/dist/index.cjs.js +5863 -8163
  2. package/dist/index.js +9044 -0
  3. package/dist/taroApis.js +1 -1
  4. package/package.json +9 -9
  5. package/src/api/ad/index.ts +5 -0
  6. package/src/api/ai/facial.ts +6 -0
  7. package/src/api/ai/index.ts +2 -0
  8. package/src/api/ai/visual.ts +4 -0
  9. package/src/api/alipay/index.ts +4 -0
  10. package/src/api/base/crypto.ts +4 -0
  11. package/src/api/base/debug.ts +5 -0
  12. package/src/api/base/index.ts +23 -0
  13. package/src/api/base/performance.ts +5 -0
  14. package/src/api/base/system/index.ts +2 -0
  15. package/src/api/base/system/info.ts +64 -0
  16. package/src/api/base/system/network.ts +70 -0
  17. package/src/api/base/update.ts +5 -0
  18. package/src/api/base/weapp/app-event.ts +19 -0
  19. package/src/api/base/weapp/life-cycle.ts +5 -0
  20. package/src/api/canvas/CanvasContext.ts +230 -0
  21. package/src/api/canvas/canvasGetImageData.ts +29 -0
  22. package/src/api/canvas/canvasPutImageData.ts +26 -0
  23. package/src/api/canvas/canvasToTempFilePath.ts +26 -0
  24. package/src/api/canvas/createCanvasContext.ts +20 -0
  25. package/src/api/canvas/{index.js → index.ts} +9 -3
  26. package/src/api/cloud/index.ts +27 -0
  27. package/src/api/data-analysis/index.ts +6 -0
  28. package/src/api/device/accelerometer.ts +89 -0
  29. package/src/api/device/accessibility.ts +4 -0
  30. package/src/api/device/battery.ts +5 -0
  31. package/src/api/device/bluetooth-ble.ts +19 -0
  32. package/src/api/device/bluetooth-peripheral.ts +6 -0
  33. package/src/api/device/bluetooth.ts +16 -0
  34. package/src/api/device/calendar.ts +5 -0
  35. package/src/api/device/clipboard.ts +67 -0
  36. package/src/api/device/compass.ts +74 -0
  37. package/src/api/device/contact.ts +5 -0
  38. package/src/api/device/crypto.ts +4 -0
  39. package/src/api/device/gyroscope.ts +7 -0
  40. package/src/api/device/iBeacon.ts +10 -0
  41. package/src/api/device/index.ts +22 -0
  42. package/src/api/device/keyboard.ts +7 -0
  43. package/src/api/device/memory.ts +5 -0
  44. package/src/api/device/motion.ts +92 -0
  45. package/src/api/device/nfc.ts +10 -0
  46. package/src/api/device/phone.ts +30 -0
  47. package/src/api/device/scan.ts +7 -0
  48. package/src/api/device/screen.ts +9 -0
  49. package/src/api/device/vibrate.ts +36 -0
  50. package/src/api/device/wifi.ts +13 -0
  51. package/src/api/ext/index.ts +5 -0
  52. package/src/api/files/index.ts +11 -0
  53. package/src/api/framework/index.ts +10 -0
  54. package/src/api/index.ts +25 -0
  55. package/src/api/location/chooseLocation.ts +106 -0
  56. package/src/api/location/index.ts +19 -0
  57. package/src/api/location/style.css +8 -8
  58. package/src/api/media/audio/index.ts +99 -0
  59. package/src/api/media/background-audio.ts +12 -0
  60. package/src/api/media/camera.ts +4 -0
  61. package/src/api/media/editor.ts +29 -0
  62. package/src/api/media/image/chooseImage.ts +80 -0
  63. package/src/api/{image → media/image}/getImageInfo.js +0 -0
  64. package/src/api/media/image/index.ts +13 -0
  65. package/src/api/{image → media/image}/previewImage.js +4 -0
  66. package/src/api/media/index.ts +13 -0
  67. package/src/api/media/live.ts +5 -0
  68. package/src/api/media/map.ts +4 -0
  69. package/src/api/media/media-recorder.ts +4 -0
  70. package/src/api/media/recorder.ts +6 -0
  71. package/src/api/media/video/index.ts +82 -0
  72. package/src/api/media/video-decoder.ts +4 -0
  73. package/src/api/media/video-processing.ts +4 -0
  74. package/src/api/media/voip.ts +17 -0
  75. package/src/api/navigate/index.ts +7 -0
  76. package/src/api/{fileTransfer/downloadFile.js → network/download.ts} +16 -25
  77. package/src/api/network/index.ts +7 -0
  78. package/src/api/network/mdns.ts +13 -0
  79. package/src/api/{request/index.js → network/request/index.ts} +9 -6
  80. package/src/api/network/tcp.ts +4 -0
  81. package/src/api/network/udp.ts +4 -0
  82. package/src/api/{fileTransfer/uploadFile.js → network/upload.ts} +28 -30
  83. package/src/api/{fileTransfer/utils.js → network/utils.ts} +0 -0
  84. package/src/api/{webSocket/index.js → network/websocket/index.ts} +49 -56
  85. package/src/api/{webSocket/socketTask.js → network/websocket/socketTask.ts} +16 -6
  86. package/src/api/open-api/account.ts +4 -0
  87. package/src/api/open-api/address.ts +4 -0
  88. package/src/api/open-api/authorize.ts +5 -0
  89. package/src/api/open-api/card.ts +5 -0
  90. package/src/api/open-api/channels-live.ts +9 -0
  91. package/src/api/open-api/customer-service.ts +4 -0
  92. package/src/api/open-api/facial.ts +7 -0
  93. package/src/api/open-api/favorites.ts +5 -0
  94. package/src/api/open-api/group.ts +4 -0
  95. package/src/api/open-api/index.ts +18 -0
  96. package/src/api/open-api/invoice.ts +5 -0
  97. package/src/api/open-api/license-plate.ts +4 -0
  98. package/src/api/open-api/login.ts +6 -0
  99. package/src/api/open-api/red-package.ts +4 -0
  100. package/src/api/open-api/settings.ts +5 -0
  101. package/src/api/open-api/soter.ts +6 -0
  102. package/src/api/open-api/subscribe-message.ts +4 -0
  103. package/src/api/open-api/user-info.ts +5 -0
  104. package/src/api/open-api/werun.ts +5 -0
  105. package/src/api/payment/index.ts +5 -0
  106. package/src/api/route/index.ts +10 -0
  107. package/src/api/share/index.ts +13 -0
  108. package/src/api/storage/background-fetch.ts +7 -0
  109. package/src/api/storage/index.ts +193 -0
  110. package/src/api/swan/index.ts +31 -0
  111. package/src/{taro/index.js → api/taro.ts} +133 -149
  112. package/src/api/{createAnimation/index.js → ui/animation/index.ts} +26 -14
  113. package/src/api/ui/background.ts +5 -0
  114. package/src/api/ui/custom-component.ts +4 -0
  115. package/src/api/ui/fonts.ts +4 -0
  116. package/src/api/ui/index.ts +12 -0
  117. package/src/api/ui/interaction/actionSheet.ts +212 -0
  118. package/src/api/{interactive/index.js → ui/interaction/index.ts} +102 -90
  119. package/src/api/ui/interaction/modal.ts +237 -0
  120. package/src/api/{interactive/toast.js → ui/interaction/toast.ts} +35 -33
  121. package/src/api/ui/menu.ts +4 -0
  122. package/src/api/ui/navigation-bar/index.ts +52 -0
  123. package/src/api/ui/pull-down-refresh.ts +32 -0
  124. package/src/api/{scroll/index.js → ui/scroll/index.ts} +16 -28
  125. package/src/api/ui/sticky.ts +4 -0
  126. package/src/api/ui/tab-bar.ts +326 -0
  127. package/src/api/ui/window.ts +37 -0
  128. package/src/api/utils/handler.ts +105 -0
  129. package/src/api/utils/{index.js → index.ts} +23 -86
  130. package/src/api/worker/index.ts +4 -0
  131. package/src/api/wxml/index.ts +9 -0
  132. package/src/api/{createSelectorQuery/index.js → wxml/selectorQuery.ts} +86 -59
  133. package/src/index.ts +6 -0
  134. package/src/types/api.d.ts +4 -0
  135. package/src/types/define.d.ts +2 -0
  136. package/{types → src/types}/index.d.ts +0 -0
  137. package/{types → src/types}/type.ts +1 -1
  138. package/src/api/accelerometer/index.js +0 -105
  139. package/src/api/audio/index.js +0 -137
  140. package/src/api/canvas/canvasGetImageData.js +0 -44
  141. package/src/api/canvas/canvasPutImageData.js +0 -45
  142. package/src/api/canvas/canvasToTempFilePath.js +0 -49
  143. package/src/api/canvas/createCanvasContext.js +0 -340
  144. package/src/api/clipboard/index.js +0 -113
  145. package/src/api/compass/index.js +0 -99
  146. package/src/api/deviceMotion/index.js +0 -105
  147. package/src/api/fileTransfer/index.js +0 -2
  148. package/src/api/image/chooseImage.js +0 -87
  149. package/src/api/image/index.js +0 -7
  150. package/src/api/index.js +0 -29
  151. package/src/api/interactive/actionSheet.js +0 -214
  152. package/src/api/interactive/modal.js +0 -256
  153. package/src/api/location/chooseLocation.js +0 -143
  154. package/src/api/location/index.js +0 -5
  155. package/src/api/navigationBar/index.js +0 -57
  156. package/src/api/open/index.js +0 -5
  157. package/src/api/others/index.js +0 -43
  158. package/src/api/pullDownRefresh/index.js +0 -51
  159. package/src/api/storage/index.js +0 -211
  160. package/src/api/system/index.js +0 -9
  161. package/src/api/system/info.js +0 -36
  162. package/src/api/system/network.js +0 -68
  163. package/src/api/tabBar/index.js +0 -402
  164. package/src/api/unsupportedApi/index.js +0 -278
  165. package/src/api/vibrate/index.js +0 -49
  166. package/src/api/video/index.js +0 -87
  167. package/src/api/window/index.js +0 -38
  168. package/src/index.cjs.js +0 -11
  169. package/src/index.js +0 -6
@@ -1,49 +0,0 @@
1
- import { successHandler, errorHandler } from '../utils/index'
2
-
3
- const vibrator = function vibrator (mm) {
4
- try {
5
- return window.navigator.vibrate(mm)
6
- } catch (e) {
7
- console.warn('当前浏览器不支持vibrate')
8
- }
9
- }
10
-
11
- /**
12
- * 使手机发生较短时间的振动(15 ms)。仅在 iPhone 7 / 7 Plus 以上及 Android 机型生效
13
- * @param {Object} object 参数
14
- * @param {function} [object.success] 接口调用成功的回调函数
15
- * @param {function} [object.fail] 接口调用失败的回调函数
16
- * @param {function} [object.complete] 接口调用结束的回调函数(调用成功、失败都会执行)
17
- */
18
- export const vibrateShort = ({ success, fail, complete } = {}) => {
19
- if (vibrator) {
20
- vibrator(15)
21
- return successHandler(success, complete)({
22
- errMsg: 'vibrateShort:ok'
23
- })
24
- } else {
25
- return errorHandler(fail, complete)({
26
- errMsg: 'vibrateShort:fail'
27
- })
28
- }
29
- }
30
-
31
- /**
32
- * 使手机发生较长时间的振动(400 ms)
33
- * @param {Object} object 参数
34
- * @param {function} [object.success] 接口调用成功的回调函数
35
- * @param {function} [object.fail] 接口调用失败的回调函数
36
- * @param {function} [object.complete] 接口调用结束的回调函数(调用成功、失败都会执行)
37
- */
38
- export const vibrateLong = ({ success, fail, complete } = {}) => {
39
- if (vibrator) {
40
- vibrator(400)
41
- return successHandler(success, complete)({
42
- errMsg: 'vibrateLong:ok'
43
- })
44
- } else {
45
- return errorHandler(fail, complete)({
46
- errMsg: 'vibrateLong:fail'
47
- })
48
- }
49
- }
@@ -1,87 +0,0 @@
1
- import { shouldBeObject, getParameterError, findDOM } from '../utils'
2
-
3
- /**
4
- * @typedef {Object} ChooseVideoParam
5
- * @property {Array.<string>} [sourceType=['album', 'camera']] 视频选择的来源
6
- * @property {boolean} [compressed=true] 是否压缩所选择的视频文件
7
- * @property {number} [maxDuration=60] 拍摄视频最长拍摄时间,单位秒
8
- * @property {string} [camera=back] 默认拉起的是前置或者后置摄像头。部分 Android 手机下由于系统 ROM 不支持无法生效
9
- * @property {function} [success] 接口调用成功的回调函数
10
- * @property {function} [fail] 接口调用失败的回调函数
11
- * @property {function} [complete] 接口调用结束的回调函数(调用成功、失败都会执行)
12
- */
13
-
14
- /**
15
- * 拍摄视频或从手机相册中选视频。
16
- * @param {ChooseVideoParam} options
17
- */
18
- export function chooseVideo (options) {
19
- // options must be an Object
20
-
21
- const isObject = shouldBeObject(options)
22
- if (!isObject.res) {
23
- const res = { errMsg: `chooseVideo${isObject.msg}` }
24
- console.error(res.errMsg)
25
- return Promise.reject(res)
26
- }
27
-
28
- const { count = 1, success, fail, complete } = options
29
- const res = {
30
- errMsg: 'chooseVideo:ok',
31
- tempFilePaths: [],
32
- tempFiles: []
33
- }
34
-
35
- if (count && typeof count !== 'number') {
36
- res.errMsg = getParameterError({
37
- name: 'chooseVideo',
38
- para: 'count',
39
- correct: 'Number',
40
- wrong: count
41
- })
42
- console.error(res.errMsg)
43
- typeof fail === 'function' && fail(res)
44
- typeof complete === 'function' && complete(res)
45
- return Promise.reject(res)
46
- }
47
-
48
- const taroChooseVideo = document.createElement('input')
49
- taroChooseVideo.setAttribute('type', 'file')
50
- taroChooseVideo.setAttribute('multiple', 'multiple')
51
- taroChooseVideo.setAttribute('accept', 'video/*')
52
- taroChooseVideo.setAttribute('style', 'position: fixed; top: -4000px; left: -3000px; z-index: -300;')
53
- document.body.appendChild(taroChooseVideo)
54
-
55
- let taroChooseVideoCallback
56
- const taroChooseVideoPromise = new Promise(resolve => {
57
- taroChooseVideoCallback = resolve
58
- })
59
- const TaroMouseEvents = document.createEvent('MouseEvents')
60
- TaroMouseEvents.initEvent('click', true, true)
61
- taroChooseVideo.dispatchEvent(TaroMouseEvents)
62
- taroChooseVideo.onchange = function (e) {
63
- const arr = [...e.target.files]
64
- arr && arr.forEach(item => {
65
- const blob = new Blob([item])
66
- const url = URL.createObjectURL(blob)
67
- res.tempFilePaths.push(url)
68
- res.tempFiles.push({ path: url, size: item.size, type: item.type })
69
- })
70
- typeof success === 'function' && success(res)
71
- typeof complete === 'function' && complete(res)
72
- taroChooseVideoCallback(res)
73
- }
74
- taroChooseVideoPromise.finally(() => {
75
- document.body.removeChild(taroChooseVideo)
76
- })
77
- return taroChooseVideoPromise
78
- }
79
-
80
- /**
81
- * 创建 video 上下文 VideoContext 对象。
82
- * @param {string} id <video> 组件的 id
83
- */
84
- export function createVideoContext (id, inst) {
85
- /** @type {HTMLVideoElement} */
86
- return findDOM(inst).querySelector(`taro-video-core[id=${id}]`)
87
- }
@@ -1,38 +0,0 @@
1
- import { createCallbackManager } from '../utils/index'
2
-
3
- const callbackManager = createCallbackManager()
4
-
5
- const resizeListener = () => {
6
- callbackManager.trigger({
7
- windowWidth: window.screen.width,
8
- windowHeight: window.screen.height
9
- })
10
- }
11
-
12
- /**
13
- * @typedef {Object} WindowResizeParam
14
- * @property {number} windowWidth 变化后的窗口宽度,单位 px
15
- * @property {number} windowHeight 变化后的窗口高度,单位 px
16
- */
17
-
18
- /**
19
- * 监听窗口尺寸变化事件
20
- * @param {(size: WindowResizeParam) => void} callback 窗口尺寸变化事件的回调函数
21
- */
22
- export const onWindowResize = callback => {
23
- callbackManager.add(callback)
24
- if (callbackManager.count() === 1) {
25
- window.addEventListener('resize', resizeListener)
26
- }
27
- }
28
-
29
- /**
30
- * 取消监听窗口尺寸变化事件
31
- * @param {(size: WindowResizeParam) => void} callback 窗口尺寸变化事件的回调函数
32
- */
33
- export const offWindowResize = callback => {
34
- callbackManager.remove(callback)
35
- if (callbackManager.count() === 0) {
36
- window.removeEventListener('resize', resizeListener)
37
- }
38
- }
package/src/index.cjs.js DELETED
@@ -1,11 +0,0 @@
1
- /* 这个入口提供给使用require的用户 */
2
-
3
- import Taro from './taro/index'
4
- import * as TaroApis from './api/index'
5
-
6
- export * from './taro/index'
7
- export * from './api/index'
8
-
9
- Object.assign(Taro, TaroApis)
10
-
11
- export default Taro
package/src/index.js DELETED
@@ -1,6 +0,0 @@
1
- import Taro from './taro/index'
2
-
3
- export * from './api/index'
4
-
5
- export default Taro
6
- export * from './taro/index'