@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,182 +0,0 @@
1
- import Taro from '@tarojs/api'
2
-
3
- import { getParameterError, shouldBeObject, temporarilyNotSupport } from '../../utils'
4
- import { MethodHandler } from '../../utils/handler'
5
-
6
- function getItem (key) {
7
- let item
8
- try {
9
- item = JSON.parse(localStorage.getItem(key) || '')
10
- } catch (e) {}
11
-
12
- // 只返回使用 Taro.setStorage API 存储的数据
13
- if (item && typeof item === 'object' && item.hasOwnProperty('data')) {
14
- return { result: true, data: item.data }
15
- } else {
16
- return { result: false }
17
- }
18
- }
19
-
20
- // 数据缓存
21
- export const setStorageSync: typeof Taro.setStorageSync = (key, data = '') => {
22
- if (typeof key !== 'string') {
23
- console.error(getParameterError({
24
- name: 'setStorage',
25
- correct: 'String',
26
- wrong: key
27
- }))
28
- return
29
- }
30
-
31
- const type = typeof data
32
- let obj = {}
33
-
34
- if (type === 'symbol') {
35
- obj = { data: '' }
36
- } else {
37
- obj = { data }
38
- }
39
- localStorage.setItem(key, JSON.stringify(obj))
40
- }
41
-
42
- export const setStorage: typeof Taro.setStorage = (options) => {
43
- // options must be an Object
44
- const isObject = shouldBeObject(options)
45
- if (!isObject.flag) {
46
- const res = { errMsg: `setStorage:fail ${isObject.msg}` }
47
- console.error(res.errMsg)
48
- return Promise.reject(res)
49
- }
50
-
51
- const { key, data, success, fail, complete } = options
52
- const handle = new MethodHandler({ name: 'setStorage', success, fail, complete })
53
-
54
- if (typeof key !== 'string') {
55
- return handle.fail({
56
- errMsg: getParameterError({
57
- para: 'key',
58
- correct: 'String',
59
- wrong: key
60
- })
61
- })
62
- }
63
-
64
- setStorageSync(key, data)
65
- return handle.success()
66
- }
67
-
68
- export const revokeBufferURL = temporarilyNotSupport('revokeBufferURL')
69
-
70
- export const removeStorageSync: typeof Taro.removeStorageSync = (key: string) => {
71
- if (typeof key !== 'string') {
72
- console.error(getParameterError({
73
- name: 'removeStorage',
74
- correct: 'String',
75
- wrong: key
76
- }))
77
- return
78
- }
79
-
80
- localStorage.removeItem(key)
81
- }
82
-
83
- export const removeStorage: typeof Taro.removeStorage = (options: Taro.removeStorage.Option) => {
84
- // options must be an Object
85
- const isObject = shouldBeObject(options)
86
- if (!isObject.flag) {
87
- const res = { errMsg: `removeStorage:fail ${isObject.msg}` }
88
- console.error(res.errMsg)
89
- return Promise.reject(res)
90
- }
91
- const { key, success, fail, complete } = options
92
- const handle = new MethodHandler({ name: 'removeStorage', success, fail, complete })
93
-
94
- if (typeof key !== 'string') {
95
- return handle.fail({
96
- errMsg: getParameterError({
97
- para: 'key',
98
- correct: 'String',
99
- wrong: key
100
- })
101
- })
102
- }
103
-
104
- removeStorageSync(key)
105
- return handle.success()
106
- }
107
-
108
- export const getStorageSync: typeof Taro.getStorageSync = (key) => {
109
- if (typeof key !== 'string') {
110
- console.error(getParameterError({
111
- name: 'getStorageSync',
112
- correct: 'String',
113
- wrong: key
114
- }))
115
- return
116
- }
117
-
118
- const res = getItem(key)
119
- if (res.result) return res.data
120
-
121
- return ''
122
- }
123
-
124
- export const getStorageInfoSync: typeof Taro.getStorageInfoSync = () => {
125
- const res: Taro.getStorageInfoSync.Option = {
126
- keys: Object.keys(localStorage),
127
- limitSize: NaN,
128
- currentSize: NaN
129
- }
130
- return res
131
- }
132
-
133
- export const getStorageInfo: typeof Taro.getStorageInfo = ({ success, fail, complete } = {}) => {
134
- const handle = new MethodHandler<Taro.getStorageInfo.SuccessCallbackOption>({ name: 'getStorageInfo', success, fail, complete })
135
- return handle.success(getStorageInfoSync())
136
- }
137
-
138
- export const getStorage: typeof Taro.getStorage = <T>(options) => {
139
- // options must be an Object
140
- const isObject = shouldBeObject(options)
141
- if (!isObject.flag) {
142
- const res = { errMsg: `getStorage:fail ${isObject.msg}` }
143
- console.error(res.errMsg)
144
- return Promise.reject(res)
145
- }
146
-
147
- const { key, success, fail, complete } = options
148
- const handle = new MethodHandler<Taro.getStorage.SuccessCallbackResult<T>>({ name: 'getStorage', success, fail, complete })
149
-
150
- if (typeof key !== 'string') {
151
- return handle.fail({
152
- errMsg: getParameterError({
153
- para: 'key',
154
- correct: 'String',
155
- wrong: key
156
- })
157
- })
158
- }
159
-
160
- const { result, data } = getItem(key)
161
- if (result) {
162
- return handle.success({ data })
163
- } else {
164
- return handle.fail({
165
- errMsg: 'data not found'
166
- })
167
- }
168
- }
169
-
170
- export const createBufferURL = temporarilyNotSupport('createBufferURL')
171
-
172
- export const clearStorageSync: typeof Taro.clearStorageSync = () => {
173
- localStorage.clear()
174
- }
175
-
176
- export const clearStorage: typeof Taro.clearStorage = ({ success, fail, complete } = {}) => {
177
- const handle = new MethodHandler({ name: 'clearStorage', success, fail, complete })
178
- clearStorageSync()
179
- return handle.success()
180
- }
181
-
182
- export * from './background-fetch'
@@ -1,31 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- export const setPageInfo = temporarilyNotSupport('setPageInfo')
4
-
5
- // 百度小程序 AI 相关
6
- export const ocrIdCard = temporarilyNotSupport('ocrIdCard')
7
- export const ocrBankCard = temporarilyNotSupport('ocrBankCard')
8
- export const ocrDrivingLicense = temporarilyNotSupport('ocrDrivingLicense')
9
- export const ocrVehicleLicense = temporarilyNotSupport('ocrVehicleLicense')
10
- export const textReview = temporarilyNotSupport('textReview')
11
- export const textToAudio = temporarilyNotSupport('textToAudio')
12
- export const imageAudit = temporarilyNotSupport('imageAudit')
13
- export const advancedGeneralIdentify = temporarilyNotSupport('advancedGeneralIdentify')
14
- export const objectDetectIdentify = temporarilyNotSupport('objectDetectIdentify')
15
- export const carClassify = temporarilyNotSupport('carClassify')
16
- export const dishClassify = temporarilyNotSupport('dishClassify')
17
- export const logoClassify = temporarilyNotSupport('logoClassify')
18
- export const animalClassify = temporarilyNotSupport('animalClassify')
19
- export const plantClassify = temporarilyNotSupport('plantClassify')
20
-
21
- // 用户信息
22
- export const getSwanId = temporarilyNotSupport('getSwanId')
23
-
24
- // 百度收银台支付
25
- export const requestPolymerPayment = temporarilyNotSupport('requestPolymerPayment')
26
-
27
- // 打开小程序
28
- export const navigateToSmartGameProgram = temporarilyNotSupport('navigateToSmartGameProgram')
29
- export const navigateToSmartProgram = temporarilyNotSupport('navigateToSmartProgram')
30
- export const navigateBackSmartProgram = temporarilyNotSupport('navigateBackSmartProgram')
31
- export const preloadSubPackage = temporarilyNotSupport('preloadSubPackage')
package/src/api/taro.ts DELETED
@@ -1,84 +0,0 @@
1
- import Taro from '@tarojs/api'
2
- import { history } from '@tarojs/router'
3
-
4
- import { getApp, getCurrentInstance, getCurrentPages, navigateBack, navigateTo, nextTick, redirectTo, reLaunch, switchTab } from '../api'
5
- import { permanentlyNotSupport } from '../utils'
6
-
7
- const {
8
- Behavior,
9
- getEnv,
10
- ENV_TYPE,
11
- Link,
12
- interceptors,
13
- getInitPxTransform,
14
- Current,
15
- options,
16
- eventCenter,
17
- Events,
18
- preload
19
- } = Taro as any
20
-
21
- const taro: typeof Taro = {
22
- // @ts-ignore
23
- Behavior,
24
- getEnv,
25
- ENV_TYPE,
26
- Link,
27
- interceptors,
28
- Current,
29
- getCurrentInstance,
30
- options,
31
- nextTick,
32
- eventCenter,
33
- Events,
34
- preload,
35
- history,
36
- navigateBack,
37
- navigateTo,
38
- reLaunch,
39
- redirectTo,
40
- getCurrentPages,
41
- switchTab
42
- }
43
-
44
- const initPxTransform = getInitPxTransform(taro)
45
-
46
- const requirePlugin = permanentlyNotSupport('requirePlugin')
47
-
48
- const pxTransform = function (size) {
49
- // @ts-ignore
50
- const { designWidth } = taro.config
51
- return Math.ceil((((parseInt(size, 10) / 40) * 640) / designWidth) * 10000) / 10000 + 'rem'
52
- }
53
-
54
- const canIUseWebp = function () {
55
- const canvas = document.createElement('canvas')
56
- return canvas.toDataURL('image/webp').indexOf('data:image/webp') === 0
57
- }
58
-
59
- taro.requirePlugin = requirePlugin
60
- taro.getApp = getApp
61
- taro.pxTransform = pxTransform
62
- taro.initPxTransform = initPxTransform
63
- // @ts-ignore
64
- taro.canIUseWebp = canIUseWebp
65
-
66
- export default taro
67
-
68
- export {
69
- Behavior,
70
- canIUseWebp,
71
- Current,
72
- ENV_TYPE,
73
- eventCenter,
74
- Events,
75
- getEnv,
76
- history,
77
- initPxTransform,
78
- interceptors,
79
- Link,
80
- options,
81
- preload,
82
- pxTransform,
83
- requirePlugin
84
- }
@@ -1,356 +0,0 @@
1
- import Taro from '@tarojs/api'
2
-
3
- /**
4
- * H5 下的 styleSheet 操作
5
- * @author leeenx
6
- */
7
- class StyleSheet {
8
- constructor () {
9
- this.$style = document.createElement('style')
10
- }
11
-
12
- $style?: HTMLStyleElement | null = null
13
- sheet?: CSSStyleSheet | null = null
14
-
15
- appendStyleSheet = () => {
16
- if (this.$style) {
17
- const head = document.getElementsByTagName('head')[0]
18
- this.$style.setAttribute('type', 'text/css')
19
- this.$style.setAttribute('data-type', 'Taro')
20
- head.appendChild(this.$style)
21
- this.sheet = this.$style.sheet
22
- }
23
- if (this.sheet && !('insertRule' in this.sheet)) {
24
- console.warn('当前浏览器不支持 stylesheet.insertRule 接口')
25
- }
26
- }
27
-
28
- // 添加样式命令
29
- add = (cssText, index = 0) => {
30
- if (this.sheet === null) {
31
- // $style 未插入到 DOM
32
- this.appendStyleSheet()
33
- }
34
- this.sheet?.insertRule(cssText, index)
35
- }
36
- }
37
-
38
- const styleSheet = new StyleSheet()
39
-
40
- // 监听事件
41
- let TRANSITION_END = 'transitionend'
42
- let TRANSFORM = 'transform'
43
-
44
- const $detect = document.createElement('div')
45
- $detect.style.cssText = '-webkit-animation-name:webkit;-moz-animation-name:moz;-ms-animation-name:ms;animation-name:standard;'
46
- if ($detect.style['animation-name'] === 'standard') {
47
- // 支持标准写法
48
- TRANSITION_END = 'transitionend'
49
- TRANSFORM = 'transform'
50
- } else if ($detect.style['-webkit-animation-name'] === 'webkit') {
51
- // webkit 前缀
52
- TRANSITION_END = 'webkitTransitionEnd'
53
- TRANSFORM = '-webkit-transform'
54
- } else if ($detect.style['-moz-animation-name'] === 'moz') {
55
- // moz 前缀
56
- TRANSITION_END = 'mozTransitionEnd'
57
- TRANSFORM = '-moz-transform'
58
- } else if ($detect.style['-ms-animation-name'] === 'ms') {
59
- // ms 前缀
60
- TRANSITION_END = 'msTransitionEnd'
61
- TRANSFORM = '-ms-transform'
62
- }
63
-
64
- let animId = 0
65
-
66
- interface IAnimationAttr {
67
- duration: number
68
- delay: number
69
- timingFunction: string
70
- transformOrigin: string
71
- }
72
-
73
- class Animation implements Taro.Animation {
74
- unit: string
75
- id: number
76
- DEFAULT: IAnimationAttr
77
-
78
- constructor (
79
- {
80
- duration = 400,
81
- delay = 0,
82
- timingFunction = 'linear',
83
- transformOrigin = '50% 50% 0',
84
- unit = 'px'
85
- }: Taro.createAnimation.Option = {}
86
- ) {
87
- // 默认值
88
- this.setDefault(duration, delay, timingFunction, transformOrigin)
89
- this.unit = unit
90
- // atom 环境下,animation 属性不会显示,所以要改成 data-animation
91
- let animAttr = 'animation'
92
- // 动画 id
93
- this.id = ++animId
94
- // 监听事件
95
- document.body.addEventListener(TRANSITION_END, (e: TransitionEvent) => {
96
- const target = e.target as HTMLElement
97
- if (target.getAttribute(animAttr) === null) {
98
- animAttr = 'data-animation'
99
- }
100
- const animData = target.getAttribute(animAttr)
101
- // 没有动画存在
102
- if (animData === null) return
103
- const [animName, animPath] = animData.split('__')
104
- if (animName === `taro-h5-poly-fill/${this.id}/create-animation`) {
105
- const [animIndex, __stepIndex = 0] = animPath.split('--')
106
- const stepIndex = Number(__stepIndex)
107
- // 动画总的关键帧
108
- const animStepsCount = this.animationMap[`${animName}__${animIndex}`]
109
- const animStepsMaxIndex = animStepsCount - 1
110
- if (stepIndex < animStepsMaxIndex) {
111
- // 播放下一个关键帧(因为 nerv 和 react 有差异所以 animation & data-animation 都需要写)
112
- target.setAttribute(animAttr, `${animName}__${animIndex}--${stepIndex + 1}`)
113
- if (animAttr === 'animation') {
114
- // Nerv 环境,animation & data-animation 双重保险
115
- target.setAttribute('data-animation', `${animName}__${animIndex}--${stepIndex + 1}`)
116
- }
117
- }
118
- }
119
- })
120
- }
121
-
122
- transformUnit (...args) {
123
- const ret: string[] = []
124
- args.forEach(each => {
125
- ret.push(isNaN(each) ? each : `${each}${this.unit}`)
126
- })
127
- return ret
128
- }
129
-
130
- // 设置默认值
131
- setDefault (duration, delay, timingFunction, transformOrigin) {
132
- this.DEFAULT = { duration, delay, timingFunction, transformOrigin }
133
- }
134
-
135
- // 属性组合
136
- rules: string[] = []
137
- // transform 对象
138
- transform = [`${TRANSFORM}:`]
139
- // 组合动画
140
- steps: string[] = []
141
- // 动画 map ----- 永久保留
142
- animationMap = {}
143
- // animationMap 的长度
144
- animationMapCount = 0
145
-
146
- matrix (a: number, b: number, c: number, d: number, tx: number, ty: number) {
147
- this.transform.push(`matrix(${a}, ${b}, ${c}, ${d}, ${tx}, ${ty})`)
148
- return this
149
- }
150
-
151
- matrix3d (a1: number, b1: number, c1: number, d1: number, a2: number, b2: number, c2: number, d2: number, a3: number, b3: number, c3: number, d3: number, a4: number, b4: number, c4: number, d4: number) {
152
- this.transform.push(`matrix3d(${a1}, ${b1}, ${c1}, ${d1}, ${a2}, ${b2}, ${c2}, ${d2}, ${a3}, ${b3}, ${c3}, ${d3}, ${a4}, ${b4}, ${c4}, ${d4})`)
153
- return this
154
- }
155
-
156
- rotate (angle: number) {
157
- this.transform.push(`rotate(${angle}deg)`)
158
- return this
159
- }
160
-
161
- rotate3d (x: number, y?: number, z?: number, angle?: number) {
162
- if (typeof y !== 'number') {
163
- this.transform.push(`rotate3d(${x})`)
164
- } else {
165
- this.transform.push(`rotate3d(${x}, ${y || 0}, ${z || 0}, ${angle || 0}deg)`)
166
- }
167
- return this
168
- }
169
-
170
- rotateX (angle) {
171
- this.transform.push(`rotateX(${angle}deg)`)
172
- return this
173
- }
174
-
175
- rotateY (angle) {
176
- this.transform.push(`rotateY(${angle}deg)`)
177
- return this
178
- }
179
-
180
- rotateZ (angle) {
181
- this.transform.push(`rotateZ(${angle}deg)`)
182
- return this
183
- }
184
-
185
- scale (x, y) {
186
- this.transform.push(`scale(${x}, ${y})`)
187
- return this
188
- }
189
-
190
- scale3d (x, y, z) {
191
- this.transform.push(`scale3d(${x}, ${y}, ${z})`)
192
- return this
193
- }
194
-
195
- scaleX (scale) {
196
- this.transform.push(`scaleX(${scale})`)
197
- return this
198
- }
199
-
200
- scaleY (scale) {
201
- this.transform.push(`scaleY(${scale})`)
202
- return this
203
- }
204
-
205
- scaleZ (scale) {
206
- this.transform.push(`scaleZ(${scale})`)
207
- return this
208
- }
209
-
210
- skew (x, y) {
211
- this.transform.push(`skew(${x}, ${y})`)
212
- return this
213
- }
214
-
215
- skewX (angle) {
216
- this.transform.push(`skewX(${angle})`)
217
- return this
218
- }
219
-
220
- skewY (angle) {
221
- this.transform.push(`skewY(${angle})`)
222
- return this
223
- }
224
-
225
- translate (x, y) {
226
- [x, y] = this.transformUnit(x, y)
227
- this.transform.push(`translate(${x}, ${y})`)
228
- return this
229
- }
230
-
231
- translate3d (x, y, z) {
232
- [x, y, z] = this.transformUnit(x, y, z)
233
- this.transform.push(
234
- `translate3d(${x}, ${y}, ${z})`
235
- )
236
- return this
237
- }
238
-
239
- translateX (translate) {
240
- [translate] = this.transformUnit(translate)
241
- this.transform.push(`translateX(${translate})`)
242
- return this
243
- }
244
-
245
- translateY (translate) {
246
- [translate] = this.transformUnit(translate)
247
- this.transform.push(`translateY(${translate})`)
248
- return this
249
- }
250
-
251
- translateZ (translate) {
252
- [translate] = this.transformUnit(translate)
253
- this.transform.push(`translateZ(${translate})`)
254
- return this
255
- }
256
-
257
- opacity (value) {
258
- this.rules.push(`opacity: ${value}`)
259
- return this
260
- }
261
-
262
- backgroundColor (value) {
263
- this.rules.push(`background-color: ${value}`)
264
- return this
265
- }
266
-
267
- width (value) {
268
- [value] = this.transformUnit(value)
269
- this.rules.push(`width: ${value}`)
270
- return this
271
- }
272
-
273
- height (value) {
274
- [value] = this.transformUnit(value)
275
- this.rules.push(`height: ${value}`)
276
- return this
277
- }
278
-
279
- top (value) {
280
- [value] = this.transformUnit(value)
281
- this.rules.push(`top: ${value}`)
282
- return this
283
- }
284
-
285
- right (value) {
286
- [value] = this.transformUnit(value)
287
- this.rules.push(`right: ${value}`)
288
- return this
289
- }
290
-
291
- bottom (value) {
292
- [value] = this.transformUnit(value)
293
- this.rules.push(`bottom: ${value}`)
294
- return this
295
- }
296
-
297
- left (value) {
298
- [value] = this.transformUnit(value)
299
- this.rules.push(`left: ${value}`)
300
- return this
301
- }
302
-
303
- // 关键帧载入
304
- step (arg: Partial<IAnimationAttr> = {}) {
305
- const { DEFAULT } = this
306
- const {
307
- duration = DEFAULT.duration,
308
- delay = DEFAULT.delay,
309
- timingFunction = DEFAULT.timingFunction,
310
- transformOrigin = DEFAULT.transformOrigin
311
- } = arg
312
- // 生成一条 transition 动画
313
- this.steps.push(
314
- [
315
- this.rules.map(rule => `${rule}!important`).join(';'),
316
- `${this.transform.join(' ')}!important`,
317
- `${TRANSFORM}-origin: ${transformOrigin}`,
318
- `transition: all ${duration}ms ${timingFunction} ${delay}ms`
319
- ]
320
- .filter(item => item !== '' && item !== `${TRANSFORM}:`)
321
- .join(';')
322
- )
323
- // 清空 rules 和 transform
324
- this.rules = []
325
- this.transform = [`${TRANSFORM}:`]
326
- return this as Taro.Animation
327
- }
328
-
329
- // 创建底层数据
330
- createAnimationData () {
331
- const animIndex = `taro-h5-poly-fill/${this.id}/create-animation__${this.animationMapCount++}`
332
- // 记录动画分几个 step
333
- this.animationMap[animIndex] = this.steps.length
334
- // 吐出 step
335
- this.steps.forEach((step, index) => {
336
- const selector = index === 0
337
- ? `[animation="${animIndex}"], [data-animation="${animIndex}"]`
338
- : `[animation="${animIndex}--${index}"], [data-animation="${animIndex}--${index}"]`
339
- styleSheet.add(`${selector} { ${step} }`)
340
- })
341
-
342
- // 清空 steps
343
- this.steps = []
344
- return animIndex
345
- }
346
-
347
- // 动画数据产出
348
- export () {
349
- return this.createAnimationData() as unknown as ReturnType<Taro.Animation['export']>
350
- }
351
- }
352
-
353
- // h5 的 createAnimation
354
- export const createAnimation: typeof Taro.createAnimation = (option) => {
355
- return new Animation(option)
356
- }
@@ -1,5 +0,0 @@
1
- import { temporarilyNotSupport } from '../../utils'
2
-
3
- // 背景
4
- export const setBackgroundTextStyle = temporarilyNotSupport('setBackgroundTextStyle')
5
- export const setBackgroundColor = temporarilyNotSupport('setBackgroundColor')
@@ -1,4 +0,0 @@
1
- import Taro from '@tarojs/api'
2
-
3
- // 自定义组件
4
- export const nextTick = Taro.nextTick