@tarojs/taro-h5 3.4.0-beta.2 → 3.4.2
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.
- package/dist/api/ad/index.js +4 -0
- package/dist/api/ai/facial.js +5 -0
- package/dist/api/ai/index.js +2 -0
- package/dist/api/ai/visual.js +5 -0
- package/dist/api/alipay/index.js +3 -0
- package/dist/api/base/crypto.js +3 -0
- package/dist/api/base/debug.js +4 -0
- package/dist/api/base/index.js +17 -0
- package/dist/api/base/performance.js +4 -0
- package/dist/api/base/system.js +187 -0
- package/dist/api/base/update.js +4 -0
- package/dist/api/base/weapp/app-event.js +18 -0
- package/dist/api/base/weapp/life-cycle.js +4 -0
- package/dist/api/canvas/CanvasContext.js +191 -0
- package/dist/api/canvas/canvasGetImageData.js +25 -0
- package/dist/api/canvas/canvasPutImageData.js +22 -0
- package/dist/api/canvas/canvasToTempFilePath.js +22 -0
- package/dist/api/canvas/createCanvasContext.js +16 -0
- package/dist/api/canvas/index.js +12 -0
- package/dist/api/cloud/index.js +21 -0
- package/dist/api/data-analysis/index.js +5 -0
- package/dist/api/device/accelerometer.js +83 -0
- package/dist/api/device/accessibility.js +3 -0
- package/dist/api/device/battery.js +21 -0
- package/dist/api/device/bluetooth-ble.js +18 -0
- package/dist/api/device/bluetooth-peripheral.js +5 -0
- package/dist/api/device/bluetooth.js +15 -0
- package/dist/api/device/calendar.js +4 -0
- package/dist/api/device/clipboard.js +65 -0
- package/dist/api/device/compass.js +64 -0
- package/dist/api/device/contact.js +4 -0
- package/dist/api/device/crypto.js +3 -0
- package/dist/api/device/gyroscope.js +6 -0
- package/dist/api/device/iBeacon.js +9 -0
- package/dist/api/device/index.js +23 -0
- package/dist/api/device/keyboard.js +6 -0
- package/dist/api/device/memory.js +4 -0
- package/dist/api/device/motion.js +81 -0
- package/dist/api/device/network.js +78 -0
- package/dist/api/device/nfc.js +9 -0
- package/dist/api/device/phone.js +24 -0
- package/dist/api/device/scan.js +6 -0
- package/dist/api/device/screen.js +8 -0
- package/dist/api/device/vibrate.js +35 -0
- package/dist/api/device/wifi.js +13 -0
- package/dist/api/ext/index.js +4 -0
- package/dist/api/files/index.js +10 -0
- package/dist/api/framework/index.js +7 -0
- package/dist/api/index.js +24 -0
- package/dist/api/location/chooseLocation.js +93 -0
- package/dist/api/location/index.js +13 -0
- package/dist/api/location/style.css +79 -0
- package/dist/api/media/EditorContext.js +19 -0
- package/dist/api/media/audio/InnerAudioContext.js +84 -0
- package/dist/api/media/audio/index.js +15 -0
- package/dist/api/media/background-audio/BackgroundAudioManager.js +86 -0
- package/dist/api/media/background-audio/index.js +15 -0
- package/dist/api/media/camera.js +3 -0
- package/dist/api/media/image/chooseImage.js +74 -0
- package/dist/api/media/image/getImageInfo.js +31 -0
- package/dist/api/media/image/index.js +9 -0
- package/dist/api/media/image/previewImage.js +67 -0
- package/dist/api/media/index.js +12 -0
- package/dist/api/media/live.js +4 -0
- package/dist/api/media/map.js +3 -0
- package/dist/api/media/media-recorder.js +3 -0
- package/dist/api/media/recorder.js +5 -0
- package/dist/api/media/video/index.js +74 -0
- package/dist/api/media/video-decoder.js +3 -0
- package/dist/api/media/video-processing.js +3 -0
- package/dist/api/media/voip.js +16 -0
- package/dist/api/navigate/index.js +6 -0
- package/dist/api/network/download.js +124 -0
- package/dist/api/network/index.js +7 -0
- package/dist/api/network/mdns.js +12 -0
- package/dist/api/network/request/index.js +125 -0
- package/dist/api/network/tcp.js +3 -0
- package/dist/api/network/udp.js +3 -0
- package/dist/api/network/upload.js +146 -0
- package/dist/api/network/utils.js +65 -0
- package/dist/api/network/websocket/index.js +70 -0
- package/dist/api/network/websocket/socketTask.js +63 -0
- package/dist/api/open-api/account.js +3 -0
- package/dist/api/open-api/address.js +3 -0
- package/dist/api/open-api/authorize.js +4 -0
- package/dist/api/open-api/card.js +4 -0
- package/dist/api/open-api/channels-live.js +8 -0
- package/dist/api/open-api/customer-service.js +3 -0
- package/dist/api/open-api/facial.js +6 -0
- package/dist/api/open-api/favorites.js +4 -0
- package/dist/api/open-api/group.js +3 -0
- package/dist/api/open-api/index.js +18 -0
- package/dist/api/open-api/invoice.js +4 -0
- package/dist/api/open-api/license-plate.js +3 -0
- package/dist/api/open-api/login.js +5 -0
- package/dist/api/open-api/red-package.js +3 -0
- package/dist/api/open-api/settings.js +4 -0
- package/dist/api/open-api/soter.js +5 -0
- package/dist/api/open-api/subscribe-message.js +3 -0
- package/dist/api/open-api/user-info.js +4 -0
- package/dist/api/open-api/werun.js +4 -0
- package/dist/api/payment/index.js +4 -0
- package/dist/api/route/index.js +3 -0
- package/dist/api/share/index.js +12 -0
- package/dist/api/storage/background-fetch.js +6 -0
- package/dist/api/storage/index.js +157 -0
- package/dist/api/swan/index.js +26 -0
- package/dist/api/taro.js +47 -0
- package/dist/api/ui/animation/index.js +288 -0
- package/dist/api/ui/background.js +4 -0
- package/dist/api/ui/custom-component.js +3 -0
- package/dist/api/ui/fonts.js +51 -0
- package/dist/api/ui/index.js +12 -0
- package/dist/api/ui/interaction/actionSheet.js +188 -0
- package/dist/api/ui/interaction/index.js +268 -0
- package/dist/api/ui/interaction/modal.js +207 -0
- package/dist/api/ui/interaction/toast.js +195 -0
- package/dist/api/ui/menu.js +3 -0
- package/dist/api/ui/navigation-bar/index.js +42 -0
- package/dist/api/ui/pull-down-refresh.js +26 -0
- package/dist/api/ui/scroll/index.js +83 -0
- package/dist/api/ui/sticky.js +3 -0
- package/dist/api/ui/tab-bar.js +282 -0
- package/dist/api/ui/window.js +31 -0
- package/dist/api/utils/handler.js +80 -0
- package/dist/api/utils/index.js +172 -0
- package/dist/api/worker/index.js +3 -0
- package/dist/api/wxml/index.js +6 -0
- package/dist/api/wxml/nodesRef.js +42 -0
- package/dist/api/wxml/selectorQuery.js +201 -0
- package/dist/index.cjs.js +5028 -6988
- package/dist/index.js +4 -10767
- package/dist/taroApis.js +1 -1
- package/dist/types/type.js +2 -0
- package/package.json +11 -13
- package/src/api/ai/visual.ts +3 -0
- package/src/api/base/system.ts +207 -0
- package/src/api/canvas/CanvasContext.ts +42 -39
- package/src/api/canvas/createCanvasContext.ts +2 -2
- package/src/api/canvas/index.ts +10 -2
- package/src/api/cloud/index.ts +4 -0
- package/src/api/device/battery.ts +18 -1
- package/src/api/device/index.ts +1 -0
- package/src/api/{base/system → device}/network.ts +35 -15
- package/src/api/device/wifi.ts +1 -0
- package/src/api/location/chooseLocation.ts +2 -2
- package/src/api/media/{editor.ts → EditorContext.ts} +2 -0
- package/src/api/media/audio/InnerAudioContext.ts +98 -0
- package/src/api/media/audio/index.ts +1 -86
- package/src/api/media/background-audio/BackgroundAudioManager.ts +103 -0
- package/src/api/media/{background-audio.ts → background-audio/index.ts} +7 -2
- package/src/api/media/image/previewImage.ts +4 -25
- package/src/api/media/index.ts +0 -1
- package/src/api/network/download.ts +5 -5
- package/src/api/network/upload.ts +7 -13
- package/src/api/network/websocket/index.ts +1 -1
- package/src/api/ui/animation/index.ts +11 -12
- package/src/api/ui/fonts.ts +61 -2
- package/src/api/ui/interaction/index.ts +12 -10
- package/src/api/ui/navigation-bar/index.ts +2 -2
- package/src/api/ui/scroll/index.ts +3 -3
- package/src/api/utils/handler.ts +4 -4
- package/src/api/utils/index.ts +34 -13
- package/src/api/wxml/nodesRef.ts +10 -3
- package/src/api/wxml/selectorQuery.ts +68 -23
- package/src/index.ts +2 -2
- package/src/api/base/system/index.ts +0 -2
- package/src/api/base/system/info.ts +0 -64
|
@@ -28,13 +28,13 @@ function createLocationChooser (handler, key = LOCATION_APIKEY) {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
function back () {
|
|
31
|
-
handler({ errMsg: 'cancel' })
|
|
32
31
|
hide()
|
|
32
|
+
handler({ errMsg: 'cancel' })
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
function submit () {
|
|
36
|
-
handler()
|
|
37
36
|
hide()
|
|
37
|
+
handler()
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
function remove () {
|
|
@@ -11,6 +11,8 @@ export class EditorContext implements Taro.EditorContext {
|
|
|
11
11
|
|
|
12
12
|
getContents = temporarilyNotSupport('EditorContext.getContents')
|
|
13
13
|
|
|
14
|
+
getSelectionText = temporarilyNotSupport('EditorContext.getSelectionText')
|
|
15
|
+
|
|
14
16
|
insertDivider = temporarilyNotSupport('EditorContext.insertDivider')
|
|
15
17
|
|
|
16
18
|
insertImage = temporarilyNotSupport('EditorContext.insertImage')
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import Taro from '@tarojs/api'
|
|
2
|
+
import { permanentlyNotSupport } from '../../utils'
|
|
3
|
+
import { CallbackManager } from '../../utils/handler'
|
|
4
|
+
|
|
5
|
+
export class InnerAudioContext implements Taro.InnerAudioContext {
|
|
6
|
+
Instance?: HTMLAudioElement
|
|
7
|
+
errorStack: CallbackManager
|
|
8
|
+
stopStack: CallbackManager
|
|
9
|
+
__startTime = 0
|
|
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
|
+
this.onPlay(() => {
|
|
18
|
+
if (this.currentTime !== this.startTime) {
|
|
19
|
+
this.seek(this.startTime)
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
set autoplay (e) { this.setProperty('autoplay', e) }
|
|
25
|
+
get autoplay () { return this.Instance?.autoplay || false }
|
|
26
|
+
get buffered () { return this.Instance?.buffered.length || 0 }
|
|
27
|
+
get currentTime () { return this.Instance?.currentTime || 0 }
|
|
28
|
+
get duration () { return this.Instance?.duration || 0 }
|
|
29
|
+
set loop (e) { this.setProperty('loop', e) }
|
|
30
|
+
get loop () { return this.Instance?.loop || false }
|
|
31
|
+
get paused () { return this.Instance?.paused || true }
|
|
32
|
+
set src (e) { this.setProperty('src', e) }
|
|
33
|
+
get src () { return this.Instance?.src || '' }
|
|
34
|
+
set volume (e) { this.setProperty('volume', e) }
|
|
35
|
+
get volume () { return this.Instance?.volume || 0 }
|
|
36
|
+
set playbackRate (e) { this.setProperty('playbackRate', e) }
|
|
37
|
+
get playbackRate () { return this.Instance?.playbackRate || 0 }
|
|
38
|
+
set obeyMuteSwitch (_e) { permanentlyNotSupport('InnerAudioContext.obeyMuteSwitch')() }
|
|
39
|
+
get obeyMuteSwitch () { return true }
|
|
40
|
+
set startTime (e) { this.__startTime = e }
|
|
41
|
+
get startTime () { return this.__startTime || 0 }
|
|
42
|
+
set referrerPolicy (e) { this.Instance?.setAttribute('referrerpolicy', e) }
|
|
43
|
+
get referrerPolicy () { return this.Instance?.getAttribute('referrerpolicy') || 'origin' }
|
|
44
|
+
|
|
45
|
+
private setProperty (key: string, value: unknown) {
|
|
46
|
+
if (this.Instance) {
|
|
47
|
+
this.Instance[key] = value
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
play = () => this.Instance?.play()
|
|
52
|
+
|
|
53
|
+
pause = () => this.Instance?.pause()
|
|
54
|
+
|
|
55
|
+
stop = () => {
|
|
56
|
+
this.pause()
|
|
57
|
+
this.seek(0)
|
|
58
|
+
this.stopStack.trigger()
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
seek = (position: number) => {
|
|
62
|
+
if (this.Instance) {
|
|
63
|
+
this.Instance.currentTime = position
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @TODO destroy得并不干净
|
|
69
|
+
*/
|
|
70
|
+
destroy = () => {
|
|
71
|
+
this.stop()
|
|
72
|
+
if (this.Instance) {
|
|
73
|
+
document.body.removeChild(this.Instance)
|
|
74
|
+
this.Instance = undefined
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
onCanplay = (callback = () => {}) => this.Instance?.addEventListener('canplay', callback)
|
|
79
|
+
onPlay = (callback = () => {}) => this.Instance?.addEventListener('play', callback)
|
|
80
|
+
onPause = (callback = () => {}) => this.Instance?.addEventListener('pause', callback)
|
|
81
|
+
onStop = (callback = () => {}) => this.stopStack.add(callback)
|
|
82
|
+
onEnded = (callback = () => {}) => this.Instance?.addEventListener('ended', callback)
|
|
83
|
+
onTimeUpdate = (callback = () => {}) => this.Instance?.addEventListener('timeupdate', callback)
|
|
84
|
+
onError = (callback?: ((res: Taro.InnerAudioContext.onErrorDetail) => void)) => this.errorStack.add(callback)
|
|
85
|
+
onWaiting = (callback = () => {}) => this.Instance?.addEventListener('waiting', callback)
|
|
86
|
+
onSeeking = (callback = () => {}) => this.Instance?.addEventListener('seeking', callback)
|
|
87
|
+
onSeeked = (callback = () => {}) => this.Instance?.addEventListener('seeked', callback)
|
|
88
|
+
offCanplay = (callback = () => {}) => this.Instance?.removeEventListener('canplay', callback)
|
|
89
|
+
offPlay = (callback = () => {}) => this.Instance?.removeEventListener('play', callback)
|
|
90
|
+
offPause = (callback = () => {}) => this.Instance?.removeEventListener('pause', callback)
|
|
91
|
+
offStop = (callback = () => {}) => this.stopStack.remove(callback)
|
|
92
|
+
offEnded = (callback = () => {}) => this.Instance?.removeEventListener('ended', callback)
|
|
93
|
+
offTimeUpdate = (callback = () => {}) => this.Instance?.removeEventListener('timeupdate', callback)
|
|
94
|
+
offError = (callback = () => {}) => this.errorStack.remove(callback)
|
|
95
|
+
offWaiting = (callback = () => {}) => this.Instance?.removeEventListener('waiting', callback)
|
|
96
|
+
offSeeking = (callback = () => {}) => this.Instance?.removeEventListener('seeking', callback)
|
|
97
|
+
offSeeked = (callback = () => {}) => this.Instance?.removeEventListener('seeked', callback)
|
|
98
|
+
}
|
|
@@ -1,93 +1,8 @@
|
|
|
1
1
|
import Taro from '@tarojs/api'
|
|
2
2
|
import { temporarilyNotSupport } from '../../utils'
|
|
3
|
-
import {
|
|
3
|
+
import { InnerAudioContext } from './InnerAudioContext'
|
|
4
4
|
|
|
5
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('oncanplay', callback)
|
|
71
|
-
onPlay = (callback = () => {}) => this.Instance?.addEventListener('onplay', callback)
|
|
72
|
-
onPause = (callback = () => {}) => this.Instance?.addEventListener('onpause', callback)
|
|
73
|
-
onStop = (callback = () => {}) => this.stopStack.add(callback)
|
|
74
|
-
onEnded = (callback = () => {}) => this.Instance?.addEventListener('onended', callback)
|
|
75
|
-
onTimeUpdate = (callback = () => {}) => this.Instance?.addEventListener('ontimeUpdate', callback)
|
|
76
|
-
onError = (callback?: ((res: Taro.InnerAudioContext.onErrorDetail) => void)) => this.errorStack.add(callback)
|
|
77
|
-
onWaiting = (callback = () => {}) => this.Instance?.addEventListener('onwaiting', callback)
|
|
78
|
-
onSeeking = (callback = () => {}) => this.Instance?.addEventListener('onseeking', callback)
|
|
79
|
-
onSeeked = (callback = () => {}) => this.Instance?.addEventListener('onseeked', callback)
|
|
80
|
-
offCanplay = (callback = () => {}) => this.Instance?.removeEventListener('offcanplay', callback)
|
|
81
|
-
offPlay = (callback = () => {}) => this.Instance?.removeEventListener('offplay', callback)
|
|
82
|
-
offPause = (callback = () => {}) => this.Instance?.removeEventListener('offpause', callback)
|
|
83
|
-
offStop = (callback = () => {}) => this.stopStack.remove(callback)
|
|
84
|
-
offEnded = (callback = () => {}) => this.Instance?.removeEventListener('offended', callback)
|
|
85
|
-
offTimeUpdate = (callback = () => {}) => this.Instance?.removeEventListener('offtimeUpdate', callback)
|
|
86
|
-
offError = (callback = () => {}) => this.errorStack.remove(callback)
|
|
87
|
-
offWaiting = (callback = () => {}) => this.Instance?.removeEventListener('offwaiting', callback)
|
|
88
|
-
offSeeking = (callback = () => {}) => this.Instance?.removeEventListener('offseeking', callback)
|
|
89
|
-
offSeeked = (callback = () => {}) => this.Instance?.removeEventListener('offseeked', callback)
|
|
90
|
-
}
|
|
91
6
|
|
|
92
7
|
export const stopVoice = temporarilyNotSupport('stopVoice')
|
|
93
8
|
export const setInnerAudioOption = temporarilyNotSupport('setInnerAudioOption')
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import Taro from '@tarojs/api'
|
|
2
|
+
import { permanentlyNotSupport } from '../../utils'
|
|
3
|
+
import { CallbackManager } from '../../utils/handler'
|
|
4
|
+
|
|
5
|
+
export class BackgroundAudioManager implements Taro.BackgroundAudioManager {
|
|
6
|
+
Instance?: HTMLAudioElement
|
|
7
|
+
errorStack: CallbackManager
|
|
8
|
+
stopStack: CallbackManager
|
|
9
|
+
__startTime = 0
|
|
10
|
+
|
|
11
|
+
constructor () {
|
|
12
|
+
this.Instance = new Audio()
|
|
13
|
+
this.errorStack = new CallbackManager()
|
|
14
|
+
this.stopStack = new CallbackManager()
|
|
15
|
+
this.Instance.autoplay = true
|
|
16
|
+
this.onPlay(() => {
|
|
17
|
+
if (this.currentTime !== this.startTime) {
|
|
18
|
+
this.seek(this.startTime)
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
set src (e) { this.setProperty('src', e) }
|
|
24
|
+
get src () { return this.Instance?.src || '' }
|
|
25
|
+
set startTime (e) { this.__startTime = e }
|
|
26
|
+
get startTime () { return this.__startTime || 0 }
|
|
27
|
+
set title (e) { this.dataset('title', e) }
|
|
28
|
+
get title () { return this.Instance?.dataset.title || '' }
|
|
29
|
+
set epname (e) { this.dataset('epname', e) }
|
|
30
|
+
get epname () { return this.Instance?.dataset.epname || '' }
|
|
31
|
+
set singer (e) { this.dataset('singer', e) }
|
|
32
|
+
get singer () { return this.Instance?.dataset.singer || '' }
|
|
33
|
+
set coverImgUrl (e) { this.dataset('coverImgUrl', e) }
|
|
34
|
+
get coverImgUrl () { return this.Instance?.dataset.coverImgUrl || '' }
|
|
35
|
+
set webUrl (e) { this.dataset('webUrl', e) }
|
|
36
|
+
get webUrl () { return this.Instance?.dataset.webUrl || '' }
|
|
37
|
+
set protocol (e) { this.dataset('protocol', e) }
|
|
38
|
+
get protocol () { return this.Instance?.dataset.protocol || '' }
|
|
39
|
+
set playbackRate (e) { this.setProperty('playbackRate', e) }
|
|
40
|
+
get playbackRate () { return this.Instance?.playbackRate || 0 }
|
|
41
|
+
get duration () { return this.Instance?.duration || 0 }
|
|
42
|
+
get currentTime () { return this.Instance?.currentTime || 0 }
|
|
43
|
+
get paused () { return this.Instance?.paused || false }
|
|
44
|
+
get buffered () { return this.Instance?.buffered.length || 0 }
|
|
45
|
+
set referrerPolicy (e) { this.Instance?.setAttribute('referrerpolicy', e) }
|
|
46
|
+
get referrerPolicy () { return this.Instance?.getAttribute('referrerpolicy') || 'origin' }
|
|
47
|
+
|
|
48
|
+
private setProperty (key: string, value: unknown) {
|
|
49
|
+
if (this.Instance) {
|
|
50
|
+
this.Instance[key] = value
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private dataset (key: string, value: string) {
|
|
55
|
+
if (this.Instance) {
|
|
56
|
+
this.Instance.dataset[key] = value
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
play = () => this.Instance?.play()
|
|
61
|
+
|
|
62
|
+
pause = () => this.Instance?.pause()
|
|
63
|
+
|
|
64
|
+
seek = (position: number) => {
|
|
65
|
+
if (this.Instance) {
|
|
66
|
+
this.Instance.currentTime = position
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
stop = () => {
|
|
71
|
+
this.pause()
|
|
72
|
+
this.seek(0)
|
|
73
|
+
this.stopStack.trigger()
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
onCanplay = (callback = () => {}) => this.Instance?.addEventListener('canplay', callback)
|
|
77
|
+
onWaiting = (callback = () => {}) => this.Instance?.addEventListener('waiting', callback)
|
|
78
|
+
onError = (callback?: ((res: Taro.InnerAudioContext.onErrorDetail) => void)) => this.errorStack.add(callback)
|
|
79
|
+
onPlay = (callback = () => {}) => this.Instance?.addEventListener('play', callback)
|
|
80
|
+
onPause = (callback = () => {}) => this.Instance?.addEventListener('pause', callback)
|
|
81
|
+
onSeeking = (callback = () => {}) => this.Instance?.addEventListener('seeking', callback)
|
|
82
|
+
onSeeked = (callback = () => {}) => this.Instance?.addEventListener('seeked', callback)
|
|
83
|
+
|
|
84
|
+
onEnded = (callback = () => {}) => this.Instance?.addEventListener('ended', callback)
|
|
85
|
+
onStop = (callback = () => {}) => this.stopStack.add(callback)
|
|
86
|
+
onTimeUpdate = (callback = () => {}) => this.Instance?.addEventListener('timeupdate', callback)
|
|
87
|
+
onPrev = permanentlyNotSupport('BackgroundAudioManager.onPrev')
|
|
88
|
+
onNext = permanentlyNotSupport('BackgroundAudioManager.onNext')
|
|
89
|
+
|
|
90
|
+
offCanplay = (callback = () => {}) => this.Instance?.removeEventListener('canplay', callback)
|
|
91
|
+
offWaiting = (callback = () => {}) => this.Instance?.removeEventListener('waiting', callback)
|
|
92
|
+
offError = (callback = () => {}) => this.errorStack.remove(callback)
|
|
93
|
+
offPlay = (callback = () => {}) => this.Instance?.removeEventListener('play', callback)
|
|
94
|
+
offPause = (callback = () => {}) => this.Instance?.removeEventListener('pause', callback)
|
|
95
|
+
offSeeking = (callback = () => {}) => this.Instance?.removeEventListener('seeking', callback)
|
|
96
|
+
offSeeked = (callback = () => {}) => this.Instance?.removeEventListener('seeked', callback)
|
|
97
|
+
|
|
98
|
+
offEnded = (callback = () => {}) => this.Instance?.removeEventListener('ended', callback)
|
|
99
|
+
offStop = (callback = () => {}) => this.stopStack.remove(callback)
|
|
100
|
+
offTimeUpdate = (callback = () => {}) => this.Instance?.removeEventListener('timeupdate', callback)
|
|
101
|
+
offPrev = permanentlyNotSupport('BackgroundAudioManager.offPrev')
|
|
102
|
+
offNext = permanentlyNotSupport('BackgroundAudioManager.offNext')
|
|
103
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { temporarilyNotSupport } from '
|
|
1
|
+
import { temporarilyNotSupport } from '../../utils'
|
|
2
|
+
import { BackgroundAudioManager } from './BackgroundAudioManager'
|
|
2
3
|
|
|
3
4
|
// 背景音频
|
|
4
5
|
export const stopBackgroundAudio = temporarilyNotSupport('stopBackgroundAudio')
|
|
@@ -9,4 +10,8 @@ export const onBackgroundAudioStop = temporarilyNotSupport('onBackgroundAudioSto
|
|
|
9
10
|
export const onBackgroundAudioPlay = temporarilyNotSupport('onBackgroundAudioPlay')
|
|
10
11
|
export const onBackgroundAudioPause = temporarilyNotSupport('onBackgroundAudioPause')
|
|
11
12
|
export const getBackgroundAudioPlayerState = temporarilyNotSupport('getBackgroundAudioPlayerState')
|
|
12
|
-
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 获取全局唯一的背景音频管理器
|
|
16
|
+
*/
|
|
17
|
+
export const getBackgroundAudioManager = () => new BackgroundAudioManager()
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Taro from '@tarojs/
|
|
1
|
+
import Taro from '@tarojs/api'
|
|
2
2
|
|
|
3
3
|
import { shouldBeObject } from '../../utils'
|
|
4
4
|
import { MethodHandler } from '../../utils/handler'
|
|
@@ -14,23 +14,12 @@ export const previewImage: typeof Taro.previewImage = async (options) => {
|
|
|
14
14
|
function loadImage (url: string, loadFail: typeof fail): Promise<Node> {
|
|
15
15
|
return new Promise((resolve) => {
|
|
16
16
|
const item = document.createElement('taro-swiper-item-core')
|
|
17
|
-
item.style.cssText =
|
|
18
|
-
display: flex;
|
|
19
|
-
align-items: start;
|
|
20
|
-
justify-content: center;
|
|
21
|
-
overflow-y: scroll;
|
|
22
|
-
`
|
|
17
|
+
item.style.cssText = 'display:flex;align-items:start;justify-content:center;overflow-y:scroll;'
|
|
23
18
|
const image = new Image()
|
|
24
19
|
image.style.maxWidth = '100%'
|
|
25
20
|
image.src = url
|
|
26
21
|
const div = document.createElement('div')
|
|
27
|
-
div.style.cssText =
|
|
28
|
-
display: flex;
|
|
29
|
-
align-items: center;
|
|
30
|
-
justify-content: center;
|
|
31
|
-
max-width: 100%;
|
|
32
|
-
min-height: 100%;
|
|
33
|
-
`
|
|
22
|
+
div.style.cssText = 'display:flex;align-items:center;justify-content:center;max-width:100%;min-height:100%;'
|
|
34
23
|
div.appendChild(image)
|
|
35
24
|
item.appendChild(div)
|
|
36
25
|
// Note: 等待图片加载完后返回,会导致轮播被卡住
|
|
@@ -55,17 +44,7 @@ export const previewImage: typeof Taro.previewImage = async (options) => {
|
|
|
55
44
|
const handle = new MethodHandler({ name: 'previewImage', success, fail, complete })
|
|
56
45
|
const container = document.createElement('div')
|
|
57
46
|
container.classList.add('preview-image')
|
|
58
|
-
container.style.cssText =
|
|
59
|
-
position: fixed;
|
|
60
|
-
top: 0;
|
|
61
|
-
left: 0;
|
|
62
|
-
z-index: 1050;
|
|
63
|
-
width: 100%;
|
|
64
|
-
height: 100%;
|
|
65
|
-
overflow: hidden;
|
|
66
|
-
outline: 0;
|
|
67
|
-
background-color: #111;
|
|
68
|
-
`
|
|
47
|
+
container.style.cssText = 'position:fixed;top:0;left:0;z-index:1050;width:100%;height:100%;overflow:hidden;outline:0;background-color:#111;'
|
|
69
48
|
container.addEventListener('click', () => {
|
|
70
49
|
container.remove()
|
|
71
50
|
})
|
package/src/api/media/index.ts
CHANGED
|
@@ -114,7 +114,7 @@ const createDownloadTask = ({ url, header, success, error }): Taro.DownloadTask
|
|
|
114
114
|
* 注意:请在服务端响应的 header 中指定合理的 Content-Type 字段,以保证客户端正确处理文件类型。
|
|
115
115
|
*/
|
|
116
116
|
export const downloadFile: typeof Taro.downloadFile = ({ url, header, success, fail, complete }) => {
|
|
117
|
-
let task
|
|
117
|
+
let task!: Taro.DownloadTask
|
|
118
118
|
const result: ReturnType<typeof Taro.downloadFile> = new Promise((resolve, reject) => {
|
|
119
119
|
task = createDownloadTask({
|
|
120
120
|
url,
|
|
@@ -130,11 +130,11 @@ export const downloadFile: typeof Taro.downloadFile = ({ url, header, success, f
|
|
|
130
130
|
reject(res)
|
|
131
131
|
}
|
|
132
132
|
})
|
|
133
|
-
|
|
134
|
-
result.headersReceive = task.onHeadersReceived
|
|
135
|
-
result.progress = task.onProgressUpdate
|
|
136
|
-
result.abort = task.abort
|
|
137
133
|
}) as any
|
|
138
134
|
|
|
135
|
+
result.headersReceive = task.onHeadersReceived
|
|
136
|
+
result.progress = task.onProgressUpdate
|
|
137
|
+
result.abort = task.abort
|
|
138
|
+
|
|
139
139
|
return result
|
|
140
140
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import Taro from '@tarojs/api'
|
|
2
|
-
import { temporarilyNotSupport } from '../utils'
|
|
3
2
|
import { CallbackManager } from '../utils/handler'
|
|
4
3
|
import {
|
|
5
4
|
convertObjectUrlToBlob,
|
|
@@ -8,7 +7,7 @@ import {
|
|
|
8
7
|
XHR_STATS
|
|
9
8
|
} from './utils'
|
|
10
9
|
|
|
11
|
-
const createUploadTask = ({ url, filePath, formData, name, header, timeout, fileName, success, error }): Taro.UploadTask => {
|
|
10
|
+
const createUploadTask = ({ url, filePath, formData = {}, name, header, timeout, fileName, success, error }): Taro.UploadTask => {
|
|
12
11
|
let timeoutInter
|
|
13
12
|
let formKey
|
|
14
13
|
const apiName = 'uploadFile'
|
|
@@ -125,17 +124,12 @@ const createUploadTask = ({ url, filePath, formData, name, header, timeout, file
|
|
|
125
124
|
*/
|
|
126
125
|
const offProgressUpdate = callbackManager.progressUpdate.remove
|
|
127
126
|
|
|
128
|
-
const headersReceived = temporarilyNotSupport('UploadTask.headersReceived')
|
|
129
|
-
const progress = temporarilyNotSupport('UploadTask.progress')
|
|
130
|
-
|
|
131
127
|
return {
|
|
132
128
|
abort,
|
|
133
129
|
onHeadersReceived,
|
|
134
130
|
offHeadersReceived,
|
|
135
131
|
onProgressUpdate,
|
|
136
|
-
offProgressUpdate
|
|
137
|
-
headersReceived,
|
|
138
|
-
progress
|
|
132
|
+
offProgressUpdate
|
|
139
133
|
}
|
|
140
134
|
}
|
|
141
135
|
|
|
@@ -143,7 +137,7 @@ const createUploadTask = ({ url, filePath, formData, name, header, timeout, file
|
|
|
143
137
|
* 将本地资源上传到服务器。客户端发起一个 HTTPS POST 请求,其中 content-type 为 multipart/form-data。使用前请注意阅读相关说明。
|
|
144
138
|
*/
|
|
145
139
|
export const uploadFile: typeof Taro.uploadFile = ({ url, filePath, name, header, formData, timeout, fileName, success, fail, complete }) => {
|
|
146
|
-
let task
|
|
140
|
+
let task!: Taro.UploadTask
|
|
147
141
|
const result: ReturnType<typeof Taro.uploadFile> = new Promise((resolve, reject) => {
|
|
148
142
|
task = createUploadTask({
|
|
149
143
|
url,
|
|
@@ -164,11 +158,11 @@ export const uploadFile: typeof Taro.uploadFile = ({ url, filePath, name, header
|
|
|
164
158
|
reject(res)
|
|
165
159
|
}
|
|
166
160
|
})
|
|
167
|
-
|
|
168
|
-
result.headersReceive = task.onHeadersReceived
|
|
169
|
-
result.progress = task.onProgressUpdate
|
|
170
|
-
result.abort = task.abort
|
|
171
161
|
}) as any
|
|
172
162
|
|
|
163
|
+
result.headersReceive = task.onHeadersReceived
|
|
164
|
+
result.progress = task.onProgressUpdate
|
|
165
|
+
result.abort = task.abort
|
|
166
|
+
|
|
173
167
|
return result
|
|
174
168
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SocketTask } from './socketTask'
|
|
2
2
|
import { shouldBeObject, getParameterError } from '../../utils'
|
|
3
|
-
import { MethodHandler } from '
|
|
3
|
+
import { MethodHandler } from '../../utils/handler'
|
|
4
4
|
|
|
5
5
|
let socketTasks: SocketTask[] = []
|
|
6
6
|
let socketsCounter = 1
|
|
@@ -9,13 +9,17 @@ class StyleSheet {
|
|
|
9
9
|
this.$style = document.createElement('style')
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
$style
|
|
13
|
-
sheet?: CSSStyleSheet | null
|
|
12
|
+
$style?: HTMLStyleElement | null = null
|
|
13
|
+
sheet?: CSSStyleSheet | null = null
|
|
14
|
+
|
|
14
15
|
appendStyleSheet = () => {
|
|
15
|
-
this.$style
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
+
}
|
|
19
23
|
if (this.sheet && !('insertRule' in this.sheet)) {
|
|
20
24
|
console.warn('当前浏览器不支持 stylesheet.insertRule 接口')
|
|
21
25
|
}
|
|
@@ -38,12 +42,7 @@ let TRANSITION_END = 'transitionend'
|
|
|
38
42
|
let TRANSFORM = 'transform'
|
|
39
43
|
|
|
40
44
|
const $detect = document.createElement('div')
|
|
41
|
-
$detect.style.cssText =
|
|
42
|
-
-webkit-animation-name: webkit;
|
|
43
|
-
-moz-animation-name: moz;
|
|
44
|
-
-ms-animation-name: ms;
|
|
45
|
-
animation-name: standard;
|
|
46
|
-
`
|
|
45
|
+
$detect.style.cssText = '-webkit-animation-name:webkit;-moz-animation-name:moz;-ms-animation-name:ms;animation-name:standard;'
|
|
47
46
|
if ($detect.style['animation-name'] === 'standard') {
|
|
48
47
|
// 支持标准写法
|
|
49
48
|
TRANSITION_END = 'transitionend'
|
package/src/api/ui/fonts.ts
CHANGED
|
@@ -1,4 +1,63 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Taro from '@tarojs/api'
|
|
2
|
+
import { MethodHandler } from '../utils/handler'
|
|
2
3
|
|
|
3
4
|
// 字体
|
|
4
|
-
export const loadFontFace =
|
|
5
|
+
export const loadFontFace: typeof Taro.loadFontFace = async options => {
|
|
6
|
+
options = Object.assign({ global: false }, options)
|
|
7
|
+
const { success, fail, complete, family, source, desc = {} } = options
|
|
8
|
+
const handle = new MethodHandler({ name: 'loadFontFace', success, fail, complete })
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
const fonts = document.fonts
|
|
11
|
+
if (fonts) {
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
const fontFace = new FontFace(family, source, desc)
|
|
14
|
+
try {
|
|
15
|
+
await fontFace.load()
|
|
16
|
+
fonts.add(fontFace)
|
|
17
|
+
return handle.success({})
|
|
18
|
+
} catch (error) {
|
|
19
|
+
return handle.fail({
|
|
20
|
+
errMsg: error.message || error
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
} else {
|
|
24
|
+
const style = document.createElement('style')
|
|
25
|
+
let innerText = `font-family:"${
|
|
26
|
+
family
|
|
27
|
+
}";src:${
|
|
28
|
+
source
|
|
29
|
+
};font-style:${
|
|
30
|
+
desc.style || 'normal'
|
|
31
|
+
};font-weight:${
|
|
32
|
+
desc.weight || 'normal'
|
|
33
|
+
};font-variant:${
|
|
34
|
+
desc.variant || 'normal'
|
|
35
|
+
};`
|
|
36
|
+
|
|
37
|
+
if (desc.ascentOverride) {
|
|
38
|
+
innerText += `ascent-override:${desc.ascentOverride};`
|
|
39
|
+
}
|
|
40
|
+
if (desc.descentOverride) {
|
|
41
|
+
innerText += `descent-override:${desc.descentOverride};`
|
|
42
|
+
}
|
|
43
|
+
if (desc.featureSettings) {
|
|
44
|
+
innerText += `font-feature-settings:${desc.featureSettings};`
|
|
45
|
+
}
|
|
46
|
+
if (desc.lineGapOverride) {
|
|
47
|
+
innerText += `line-gap-override:${desc.lineGapOverride};`
|
|
48
|
+
}
|
|
49
|
+
if (desc.stretch) {
|
|
50
|
+
innerText += `font-stretch:${desc.stretch};`
|
|
51
|
+
}
|
|
52
|
+
if (desc.unicodeRange) {
|
|
53
|
+
innerText += `unicode-range:${desc.unicodeRange};`
|
|
54
|
+
}
|
|
55
|
+
if (desc.variationSettings) {
|
|
56
|
+
innerText += `font-variation-settings:${desc.variationSettings};`
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
style.innerText = `@font-face{${innerText}}`
|
|
60
|
+
document.head.appendChild(style)
|
|
61
|
+
return handle.success()
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -62,9 +62,9 @@ const showToast: typeof Taro.showToast = (options = { title: '' }) => {
|
|
|
62
62
|
|
|
63
63
|
let errMsg = ''
|
|
64
64
|
if (!toast.el) {
|
|
65
|
-
errMsg = toast.create(options, '
|
|
65
|
+
errMsg = toast.create(options, 'toast')
|
|
66
66
|
} else {
|
|
67
|
-
errMsg = toast.show(options, '
|
|
67
|
+
errMsg = toast.show(options, 'toast')
|
|
68
68
|
}
|
|
69
69
|
return handle.success({ errMsg })
|
|
70
70
|
}
|
|
@@ -167,7 +167,7 @@ const showModal: typeof Taro.showModal = async (options = {}) => {
|
|
|
167
167
|
|
|
168
168
|
if (options.cancelText.replace(/[\u0391-\uFFE5]/g, 'aa').length > 8) {
|
|
169
169
|
return handle.fail({
|
|
170
|
-
errMsg: '
|
|
170
|
+
errMsg: 'cancelText length should not larger then 4 Chinese characters'
|
|
171
171
|
})
|
|
172
172
|
}
|
|
173
173
|
|
|
@@ -183,7 +183,7 @@ const showModal: typeof Taro.showModal = async (options = {}) => {
|
|
|
183
183
|
|
|
184
184
|
if (options.confirmText.replace(/[\u0391-\uFFE5]/g, 'aa').length > 8) {
|
|
185
185
|
return handle.fail({
|
|
186
|
-
errMsg: '
|
|
186
|
+
errMsg: 'confirmText length should not larger then 4 Chinese characters'
|
|
187
187
|
})
|
|
188
188
|
}
|
|
189
189
|
|
|
@@ -209,13 +209,15 @@ const showModal: typeof Taro.showModal = async (options = {}) => {
|
|
|
209
209
|
|
|
210
210
|
options.showCancel = !!options.showCancel
|
|
211
211
|
|
|
212
|
-
let
|
|
212
|
+
let result = ''
|
|
213
213
|
if (!modal.el) {
|
|
214
|
-
|
|
214
|
+
result = await modal.create(options)
|
|
215
215
|
} else {
|
|
216
|
-
|
|
216
|
+
result = await modal.show(options)
|
|
217
217
|
}
|
|
218
|
-
|
|
218
|
+
const res = { cancel: !1, confirm: !1 }
|
|
219
|
+
res[result] = !0
|
|
220
|
+
return handle.success(res)
|
|
219
221
|
}
|
|
220
222
|
|
|
221
223
|
function hideModal () {
|
|
@@ -244,11 +246,11 @@ const showActionSheet: typeof Taro.showActionSheet = async (options = { itemList
|
|
|
244
246
|
}
|
|
245
247
|
|
|
246
248
|
if (options.itemList.length < 1) {
|
|
247
|
-
return handle.fail({ errMsg: '
|
|
249
|
+
return handle.fail({ errMsg: 'parameter error: parameter.itemList should have at least 1 item' })
|
|
248
250
|
}
|
|
249
251
|
|
|
250
252
|
if (options.itemList.length > 6) {
|
|
251
|
-
return handle.fail({ errMsg: '
|
|
253
|
+
return handle.fail({ errMsg: 'parameter error: parameter.itemList should not be large than 6' })
|
|
252
254
|
}
|
|
253
255
|
|
|
254
256
|
for (let i = 0; i < options.itemList.length; i++) {
|