@tarojs/taro-h5 3.4.0-beta.3 → 3.5.0-canary.1
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/canvas/CanvasContext.js +1 -1
- package/dist/api/cloud/index.js +4 -0
- package/dist/api/media/{editor.js → EditorContext.js} +0 -0
- package/dist/api/media/audio/InnerAudioContext.js +84 -0
- package/dist/api/media/audio/index.js +1 -74
- package/dist/api/media/background-audio/BackgroundAudioManager.js +86 -0
- package/dist/api/media/{background-audio.js → background-audio/index.js} +6 -2
- package/dist/api/media/index.js +0 -1
- package/dist/api/network/upload.js +1 -1
- package/dist/api/ui/animation/index.js +9 -5
- package/dist/api/ui/interaction/index.js +6 -6
- package/dist/api/ui/navigation-bar/index.js +1 -1
- package/dist/api/ui/scroll/index.js +3 -3
- package/dist/api/utils/handler.js +45 -45
- package/dist/api/utils/index.js +36 -12
- package/dist/index.cjs.js +210 -99
- package/dist/taroApis.js +1 -1
- package/package.json +8 -7
- package/src/api/canvas/CanvasContext.ts +1 -1
- package/src/api/cloud/index.ts +4 -0
- package/src/api/media/{editor.ts → EditorContext.ts} +0 -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/index.ts +0 -1
- package/src/api/network/upload.ts +1 -1
- package/src/api/ui/animation/index.ts +10 -6
- package/src/api/ui/interaction/index.ts +6 -6
- package/src/api/ui/navigation-bar/index.ts +1 -1
- 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
|
@@ -179,7 +179,7 @@ export class CanvasContext {
|
|
|
179
179
|
transform(...args) { return this.enqueueActions(this.ctx.transform, ...args); }
|
|
180
180
|
translate(...args) { return this.enqueueActions(this.ctx.translate, ...args); }
|
|
181
181
|
measureText(text) {
|
|
182
|
-
return this.measureText(text);
|
|
182
|
+
return this.ctx.measureText(text);
|
|
183
183
|
}
|
|
184
184
|
createCircularGradient(x, y, r) {
|
|
185
185
|
const radialGradient = this.ctx.createRadialGradient(x, y, 0, x, y, r);
|
package/dist/api/cloud/index.js
CHANGED
|
@@ -3,15 +3,19 @@ export class cloud {
|
|
|
3
3
|
constructor() {
|
|
4
4
|
this.init = temporarilyNotSupport('cloud.init');
|
|
5
5
|
this.CloudID = temporarilyNotSupport('cloud.CloudID');
|
|
6
|
+
// @ts-ignore
|
|
6
7
|
this.callFunction = temporarilyNotSupport('cloud.callFunction');
|
|
7
8
|
// @ts-ignore
|
|
8
9
|
this.uploadFile = temporarilyNotSupport('cloud.uploadFile');
|
|
9
10
|
// @ts-ignore
|
|
10
11
|
this.downloadFile = temporarilyNotSupport('cloud.downloadFile');
|
|
12
|
+
// @ts-ignore
|
|
11
13
|
this.getTempFileURL = temporarilyNotSupport('cloud.getTempFileURL');
|
|
14
|
+
// @ts-ignore
|
|
12
15
|
this.deleteFile = temporarilyNotSupport('cloud.deleteFile');
|
|
13
16
|
// @ts-ignore
|
|
14
17
|
this.database = temporarilyNotSupport('cloud.database');
|
|
18
|
+
// @ts-ignore
|
|
15
19
|
this.callContainer = temporarilyNotSupport('cloud.callContainer');
|
|
16
20
|
}
|
|
17
21
|
}
|
|
File without changes
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import Taro from '@tarojs/api';
|
|
2
|
+
import { permanentlyNotSupport } from '../../utils';
|
|
3
|
+
import { CallbackManager } from '../../utils/handler';
|
|
4
|
+
export class InnerAudioContext {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.__startTime = 0;
|
|
7
|
+
this.play = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.play(); };
|
|
8
|
+
this.pause = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.pause(); };
|
|
9
|
+
this.stop = () => {
|
|
10
|
+
this.pause();
|
|
11
|
+
this.seek(0);
|
|
12
|
+
this.stopStack.trigger();
|
|
13
|
+
};
|
|
14
|
+
this.seek = (position) => {
|
|
15
|
+
if (this.Instance) {
|
|
16
|
+
this.Instance.currentTime = position;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* @TODO destroy得并不干净
|
|
21
|
+
*/
|
|
22
|
+
this.destroy = () => {
|
|
23
|
+
this.stop();
|
|
24
|
+
if (this.Instance) {
|
|
25
|
+
document.body.removeChild(this.Instance);
|
|
26
|
+
this.Instance = undefined;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
this.onCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('canplay', callback); };
|
|
30
|
+
this.onPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('play', callback); };
|
|
31
|
+
this.onPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('pause', callback); };
|
|
32
|
+
this.onStop = (callback = () => { }) => this.stopStack.add(callback);
|
|
33
|
+
this.onEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('ended', callback); };
|
|
34
|
+
this.onTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('timeupdate', callback); };
|
|
35
|
+
this.onError = (callback) => this.errorStack.add(callback);
|
|
36
|
+
this.onWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('waiting', callback); };
|
|
37
|
+
this.onSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeking', callback); };
|
|
38
|
+
this.onSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeked', callback); };
|
|
39
|
+
this.offCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('canplay', callback); };
|
|
40
|
+
this.offPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('play', callback); };
|
|
41
|
+
this.offPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('pause', callback); };
|
|
42
|
+
this.offStop = (callback = () => { }) => this.stopStack.remove(callback);
|
|
43
|
+
this.offEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('ended', callback); };
|
|
44
|
+
this.offTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('timeupdate', callback); };
|
|
45
|
+
this.offError = (callback = () => { }) => this.errorStack.remove(callback);
|
|
46
|
+
this.offWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('waiting', callback); };
|
|
47
|
+
this.offSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeking', callback); };
|
|
48
|
+
this.offSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeked', callback); };
|
|
49
|
+
this.Instance = new Audio();
|
|
50
|
+
this.errorStack = new CallbackManager();
|
|
51
|
+
this.stopStack = new CallbackManager();
|
|
52
|
+
Taro.eventCenter.on('__taroRouterChange', () => { this.stop(); });
|
|
53
|
+
this.onPlay(() => {
|
|
54
|
+
if (this.currentTime !== this.startTime) {
|
|
55
|
+
this.seek(this.startTime);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
set autoplay(e) { this.setProperty('autoplay', e); }
|
|
60
|
+
get autoplay() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.autoplay) || false; }
|
|
61
|
+
get buffered() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.buffered.length) || 0; }
|
|
62
|
+
get currentTime() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.currentTime) || 0; }
|
|
63
|
+
get duration() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.duration) || 0; }
|
|
64
|
+
set loop(e) { this.setProperty('loop', e); }
|
|
65
|
+
get loop() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.loop) || false; }
|
|
66
|
+
get paused() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused) || true; }
|
|
67
|
+
set src(e) { this.setProperty('src', e); }
|
|
68
|
+
get src() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.src) || ''; }
|
|
69
|
+
set volume(e) { this.setProperty('volume', e); }
|
|
70
|
+
get volume() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.volume) || 0; }
|
|
71
|
+
set playbackRate(e) { this.setProperty('playbackRate', e); }
|
|
72
|
+
get playbackRate() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.playbackRate) || 0; }
|
|
73
|
+
set obeyMuteSwitch(_e) { permanentlyNotSupport('InnerAudioContext.obeyMuteSwitch')(); }
|
|
74
|
+
get obeyMuteSwitch() { return true; }
|
|
75
|
+
set startTime(e) { this.__startTime = e; }
|
|
76
|
+
get startTime() { return this.__startTime || 0; }
|
|
77
|
+
set referrerPolicy(e) { var _a; (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.setAttribute('referrerpolicy', e); }
|
|
78
|
+
get referrerPolicy() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.getAttribute('referrerpolicy')) || 'origin'; }
|
|
79
|
+
setProperty(key, value) {
|
|
80
|
+
if (this.Instance) {
|
|
81
|
+
this.Instance[key] = value;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -1,79 +1,6 @@
|
|
|
1
|
-
import Taro from '@tarojs/api';
|
|
2
1
|
import { temporarilyNotSupport } from '../../utils';
|
|
3
|
-
import {
|
|
2
|
+
import { InnerAudioContext } from './InnerAudioContext';
|
|
4
3
|
// 音频
|
|
5
|
-
class InnerAudioContext {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.play = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.play(); };
|
|
8
|
-
this.pause = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.pause(); };
|
|
9
|
-
this.stop = () => {
|
|
10
|
-
this.pause();
|
|
11
|
-
this.seek(0);
|
|
12
|
-
this.stopStack.trigger();
|
|
13
|
-
};
|
|
14
|
-
this.seek = (position) => {
|
|
15
|
-
if (this.Instance) {
|
|
16
|
-
this.Instance.currentTime = position;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* @TODO destroy得并不干净
|
|
21
|
-
*/
|
|
22
|
-
this.destroy = () => {
|
|
23
|
-
this.stop();
|
|
24
|
-
if (this.Instance) {
|
|
25
|
-
document.body.removeChild(this.Instance);
|
|
26
|
-
this.Instance = undefined;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
this.onCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('canplay', callback); };
|
|
30
|
-
this.onPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('play', callback); };
|
|
31
|
-
this.onPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('pause', callback); };
|
|
32
|
-
this.onStop = (callback = () => { }) => this.stopStack.add(callback);
|
|
33
|
-
this.onEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('ended', callback); };
|
|
34
|
-
this.onTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('timeupdate', callback); };
|
|
35
|
-
this.onError = (callback) => this.errorStack.add(callback);
|
|
36
|
-
this.onWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('waiting', callback); };
|
|
37
|
-
this.onSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeking', callback); };
|
|
38
|
-
this.onSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeked', callback); };
|
|
39
|
-
this.offCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('canplay', callback); };
|
|
40
|
-
this.offPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('play', callback); };
|
|
41
|
-
this.offPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('pause', callback); };
|
|
42
|
-
this.offStop = (callback = () => { }) => this.stopStack.remove(callback);
|
|
43
|
-
this.offEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('ended', callback); };
|
|
44
|
-
this.offTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('timeupdate', callback); };
|
|
45
|
-
this.offError = (callback = () => { }) => this.errorStack.remove(callback);
|
|
46
|
-
this.offWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('waiting', callback); };
|
|
47
|
-
this.offSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeking', callback); };
|
|
48
|
-
this.offSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeked', callback); };
|
|
49
|
-
this.Instance = new Audio();
|
|
50
|
-
this.errorStack = new CallbackManager();
|
|
51
|
-
this.stopStack = new CallbackManager();
|
|
52
|
-
Taro.eventCenter.on('__taroRouterChange', () => { this.stop(); });
|
|
53
|
-
}
|
|
54
|
-
set autoplay(e) { this.setProperty('autoplay', e); }
|
|
55
|
-
get autoplay() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.autoplay) || false; }
|
|
56
|
-
get buffered() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.buffered.length) || 0; }
|
|
57
|
-
get currentTime() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.currentTime) || 0; }
|
|
58
|
-
get duration() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.duration) || 0; }
|
|
59
|
-
set loop(e) { this.setProperty('loop', e); }
|
|
60
|
-
get loop() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.loop) || false; }
|
|
61
|
-
get paused() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused) || true; }
|
|
62
|
-
set src(e) { this.setProperty('src', e); }
|
|
63
|
-
get src() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.src) || ''; }
|
|
64
|
-
set volume(e) { this.setProperty('volume', e); }
|
|
65
|
-
get volume() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.volume) || 0; }
|
|
66
|
-
set playbackRate(e) { this.setProperty('playbackRate', e); }
|
|
67
|
-
get playbackRate() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.volume) || 0; }
|
|
68
|
-
get obeyMuteSwitch() { return true; }
|
|
69
|
-
set startTime(e) { this.setProperty('startTime', e); }
|
|
70
|
-
get startTime() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.volume) || 0; }
|
|
71
|
-
setProperty(key, value) {
|
|
72
|
-
if (this.Instance) {
|
|
73
|
-
this.Instance[key] = value;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
4
|
export const stopVoice = temporarilyNotSupport('stopVoice');
|
|
78
5
|
export const setInnerAudioOption = temporarilyNotSupport('setInnerAudioOption');
|
|
79
6
|
export const playVoice = temporarilyNotSupport('playVoice');
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { permanentlyNotSupport } from '../../utils';
|
|
2
|
+
import { CallbackManager } from '../../utils/handler';
|
|
3
|
+
export class BackgroundAudioManager {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.__startTime = 0;
|
|
6
|
+
this.play = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.play(); };
|
|
7
|
+
this.pause = () => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.pause(); };
|
|
8
|
+
this.seek = (position) => {
|
|
9
|
+
if (this.Instance) {
|
|
10
|
+
this.Instance.currentTime = position;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
this.stop = () => {
|
|
14
|
+
this.pause();
|
|
15
|
+
this.seek(0);
|
|
16
|
+
this.stopStack.trigger();
|
|
17
|
+
};
|
|
18
|
+
this.onCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('canplay', callback); };
|
|
19
|
+
this.onWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('waiting', callback); };
|
|
20
|
+
this.onError = (callback) => this.errorStack.add(callback);
|
|
21
|
+
this.onPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('play', callback); };
|
|
22
|
+
this.onPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('pause', callback); };
|
|
23
|
+
this.onSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeking', callback); };
|
|
24
|
+
this.onSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('seeked', callback); };
|
|
25
|
+
this.onEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('ended', callback); };
|
|
26
|
+
this.onStop = (callback = () => { }) => this.stopStack.add(callback);
|
|
27
|
+
this.onTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.addEventListener('timeupdate', callback); };
|
|
28
|
+
this.onPrev = permanentlyNotSupport('BackgroundAudioManager.onPrev');
|
|
29
|
+
this.onNext = permanentlyNotSupport('BackgroundAudioManager.onNext');
|
|
30
|
+
this.offCanplay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('canplay', callback); };
|
|
31
|
+
this.offWaiting = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('waiting', callback); };
|
|
32
|
+
this.offError = (callback = () => { }) => this.errorStack.remove(callback);
|
|
33
|
+
this.offPlay = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('play', callback); };
|
|
34
|
+
this.offPause = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('pause', callback); };
|
|
35
|
+
this.offSeeking = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeking', callback); };
|
|
36
|
+
this.offSeeked = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('seeked', callback); };
|
|
37
|
+
this.offEnded = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('ended', callback); };
|
|
38
|
+
this.offStop = (callback = () => { }) => this.stopStack.remove(callback);
|
|
39
|
+
this.offTimeUpdate = (callback = () => { }) => { var _a; return (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.removeEventListener('timeupdate', callback); };
|
|
40
|
+
this.offPrev = permanentlyNotSupport('BackgroundAudioManager.offPrev');
|
|
41
|
+
this.offNext = permanentlyNotSupport('BackgroundAudioManager.offNext');
|
|
42
|
+
this.Instance = new Audio();
|
|
43
|
+
this.errorStack = new CallbackManager();
|
|
44
|
+
this.stopStack = new CallbackManager();
|
|
45
|
+
this.Instance.autoplay = true;
|
|
46
|
+
this.onPlay(() => {
|
|
47
|
+
if (this.currentTime !== this.startTime) {
|
|
48
|
+
this.seek(this.startTime);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
set src(e) { this.setProperty('src', e); }
|
|
53
|
+
get src() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.src) || ''; }
|
|
54
|
+
set startTime(e) { this.__startTime = e; }
|
|
55
|
+
get startTime() { return this.__startTime || 0; }
|
|
56
|
+
set title(e) { this.dataset('title', e); }
|
|
57
|
+
get title() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.title) || ''; }
|
|
58
|
+
set epname(e) { this.dataset('epname', e); }
|
|
59
|
+
get epname() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.epname) || ''; }
|
|
60
|
+
set singer(e) { this.dataset('singer', e); }
|
|
61
|
+
get singer() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.singer) || ''; }
|
|
62
|
+
set coverImgUrl(e) { this.dataset('coverImgUrl', e); }
|
|
63
|
+
get coverImgUrl() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.coverImgUrl) || ''; }
|
|
64
|
+
set webUrl(e) { this.dataset('webUrl', e); }
|
|
65
|
+
get webUrl() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.webUrl) || ''; }
|
|
66
|
+
set protocol(e) { this.dataset('protocol', e); }
|
|
67
|
+
get protocol() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.dataset.protocol) || ''; }
|
|
68
|
+
set playbackRate(e) { this.setProperty('playbackRate', e); }
|
|
69
|
+
get playbackRate() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.playbackRate) || 0; }
|
|
70
|
+
get duration() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.duration) || 0; }
|
|
71
|
+
get currentTime() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.currentTime) || 0; }
|
|
72
|
+
get paused() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused) || false; }
|
|
73
|
+
get buffered() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.buffered.length) || 0; }
|
|
74
|
+
set referrerPolicy(e) { var _a; (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.setAttribute('referrerpolicy', e); }
|
|
75
|
+
get referrerPolicy() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.getAttribute('referrerpolicy')) || 'origin'; }
|
|
76
|
+
setProperty(key, value) {
|
|
77
|
+
if (this.Instance) {
|
|
78
|
+
this.Instance[key] = value;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
dataset(key, value) {
|
|
82
|
+
if (this.Instance) {
|
|
83
|
+
this.Instance.dataset[key] = value;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { temporarilyNotSupport } from '
|
|
1
|
+
import { temporarilyNotSupport } from '../../utils';
|
|
2
|
+
import { BackgroundAudioManager } from './BackgroundAudioManager';
|
|
2
3
|
// 背景音频
|
|
3
4
|
export const stopBackgroundAudio = temporarilyNotSupport('stopBackgroundAudio');
|
|
4
5
|
export const seekBackgroundAudio = temporarilyNotSupport('seekBackgroundAudio');
|
|
@@ -8,4 +9,7 @@ export const onBackgroundAudioStop = temporarilyNotSupport('onBackgroundAudioSto
|
|
|
8
9
|
export const onBackgroundAudioPlay = temporarilyNotSupport('onBackgroundAudioPlay');
|
|
9
10
|
export const onBackgroundAudioPause = temporarilyNotSupport('onBackgroundAudioPause');
|
|
10
11
|
export const getBackgroundAudioPlayerState = temporarilyNotSupport('getBackgroundAudioPlayerState');
|
|
11
|
-
|
|
12
|
+
/**
|
|
13
|
+
* 获取全局唯一的背景音频管理器
|
|
14
|
+
*/
|
|
15
|
+
export const getBackgroundAudioManager = () => new BackgroundAudioManager();
|
package/dist/api/media/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../utils';
|
|
2
2
|
import { CallbackManager } from '../utils/handler';
|
|
3
3
|
import { convertObjectUrlToBlob, NETWORK_TIMEOUT, setHeader, XHR_STATS } from './utils';
|
|
4
|
-
const createUploadTask = ({ url, filePath, formData, name, header, timeout, fileName, success, error }) => {
|
|
4
|
+
const createUploadTask = ({ url, filePath, formData = {}, name, header, timeout, fileName, success, error }) => {
|
|
5
5
|
let timeoutInter;
|
|
6
6
|
let formKey;
|
|
7
7
|
const apiName = 'uploadFile';
|
|
@@ -4,12 +4,16 @@
|
|
|
4
4
|
*/
|
|
5
5
|
class StyleSheet {
|
|
6
6
|
constructor() {
|
|
7
|
+
this.$style = null;
|
|
8
|
+
this.sheet = null;
|
|
7
9
|
this.appendStyleSheet = () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
if (this.$style) {
|
|
11
|
+
const head = document.getElementsByTagName('head')[0];
|
|
12
|
+
this.$style.setAttribute('type', 'text/css');
|
|
13
|
+
this.$style.setAttribute('data-type', 'Taro');
|
|
14
|
+
head.appendChild(this.$style);
|
|
15
|
+
this.sheet = this.$style.sheet;
|
|
16
|
+
}
|
|
13
17
|
if (this.sheet && !('insertRule' in this.sheet)) {
|
|
14
18
|
console.warn('当前浏览器不支持 stylesheet.insertRule 接口');
|
|
15
19
|
}
|
|
@@ -52,10 +52,10 @@ const showToast = (options = { title: '' }) => {
|
|
|
52
52
|
options.mask = !!options.mask;
|
|
53
53
|
let errMsg = '';
|
|
54
54
|
if (!toast.el) {
|
|
55
|
-
errMsg = toast.create(options, '
|
|
55
|
+
errMsg = toast.create(options, 'toast');
|
|
56
56
|
}
|
|
57
57
|
else {
|
|
58
|
-
errMsg = toast.show(options, '
|
|
58
|
+
errMsg = toast.show(options, 'toast');
|
|
59
59
|
}
|
|
60
60
|
return handle.success({ errMsg });
|
|
61
61
|
};
|
|
@@ -148,7 +148,7 @@ const showModal = async (options = {}) => {
|
|
|
148
148
|
}
|
|
149
149
|
if (options.cancelText.replace(/[\u0391-\uFFE5]/g, 'aa').length > 8) {
|
|
150
150
|
return handle.fail({
|
|
151
|
-
errMsg: '
|
|
151
|
+
errMsg: 'cancelText length should not larger then 4 Chinese characters'
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
if (typeof options.confirmText !== 'string') {
|
|
@@ -162,7 +162,7 @@ const showModal = async (options = {}) => {
|
|
|
162
162
|
}
|
|
163
163
|
if (options.confirmText.replace(/[\u0391-\uFFE5]/g, 'aa').length > 8) {
|
|
164
164
|
return handle.fail({
|
|
165
|
-
errMsg: '
|
|
165
|
+
errMsg: 'confirmText length should not larger then 4 Chinese characters'
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
if (typeof options.cancelColor !== 'string') {
|
|
@@ -219,10 +219,10 @@ const showActionSheet = async (options = { itemList: [] }) => {
|
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
221
|
if (options.itemList.length < 1) {
|
|
222
|
-
return handle.fail({ errMsg: '
|
|
222
|
+
return handle.fail({ errMsg: 'parameter error: parameter.itemList should have at least 1 item' });
|
|
223
223
|
}
|
|
224
224
|
if (options.itemList.length > 6) {
|
|
225
|
-
return handle.fail({ errMsg: '
|
|
225
|
+
return handle.fail({ errMsg: 'parameter error: parameter.itemList should not be large than 6' });
|
|
226
226
|
}
|
|
227
227
|
for (let i = 0; i < options.itemList.length; i++) {
|
|
228
228
|
if (typeof options.itemList[i] !== 'string') {
|
|
@@ -11,7 +11,7 @@ export function setNavigationBarTitle(options) {
|
|
|
11
11
|
return Promise.reject(res);
|
|
12
12
|
}
|
|
13
13
|
const { title, success, fail, complete } = options;
|
|
14
|
-
const handle = new MethodHandler({ name: '
|
|
14
|
+
const handle = new MethodHandler({ name: 'setNavigationBarTitle', success, fail, complete });
|
|
15
15
|
if (!title || typeof title !== 'string') {
|
|
16
16
|
return handle.fail({
|
|
17
17
|
errMsg: getParameterError({
|
|
@@ -10,16 +10,16 @@ export const pageScrollTo = ({ scrollTop, selector = '', duration = 300, success
|
|
|
10
10
|
let scrollFunc;
|
|
11
11
|
const handle = new MethodHandler({ name: 'pageScrollTo', success, fail, complete });
|
|
12
12
|
return new Promise((resolve, reject) => {
|
|
13
|
-
var _a;
|
|
13
|
+
var _a, _b;
|
|
14
14
|
try {
|
|
15
15
|
if (scrollTop === undefined && !selector) {
|
|
16
16
|
return handle.fail({
|
|
17
17
|
errMsg: 'scrollTop" 或 "selector" 需要其之一'
|
|
18
18
|
}, reject);
|
|
19
19
|
}
|
|
20
|
-
const id = (_a = Current.page) === null || _a === void 0 ? void 0 : _a.path;
|
|
20
|
+
const id = (_b = (_a = Current.page) === null || _a === void 0 ? void 0 : _a.path) === null || _b === void 0 ? void 0 : _b.replace(/([^a-z0-9\u00a0-\uffff_-])/ig, '\\$1');
|
|
21
21
|
const el = (id
|
|
22
|
-
? document.
|
|
22
|
+
? document.querySelector(`.taro_page#${id}`)
|
|
23
23
|
: document.querySelector('.taro_page') ||
|
|
24
24
|
document.querySelector('.taro_router'));
|
|
25
25
|
if (!scrollFunc) {
|
|
@@ -29,52 +29,52 @@ export class MethodHandler {
|
|
|
29
29
|
export class CallbackManager {
|
|
30
30
|
constructor() {
|
|
31
31
|
this.callbacks = [];
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
32
|
+
/**
|
|
33
|
+
* 添加回调
|
|
34
|
+
* @param {{ callback: function, ctx: any } | function} opt
|
|
35
|
+
*/
|
|
36
|
+
this.add = (opt) => {
|
|
37
|
+
if (opt)
|
|
38
|
+
this.callbacks.push(opt);
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* 移除回调
|
|
42
|
+
* @param {{ callback: function, ctx: any } | function} opt
|
|
43
|
+
*/
|
|
44
|
+
this.remove = (opt) => {
|
|
45
|
+
if (opt) {
|
|
46
|
+
let pos = -1;
|
|
47
|
+
this.callbacks.forEach((callback, k) => {
|
|
48
|
+
if (callback === opt) {
|
|
49
|
+
pos = k;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
if (pos > -1) {
|
|
53
|
+
this.callbacks.splice(pos, 1);
|
|
51
54
|
}
|
|
52
|
-
});
|
|
53
|
-
if (pos > -1) {
|
|
54
|
-
this.callbacks.splice(pos, 1);
|
|
55
55
|
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
}
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* 获取回调函数数量
|
|
59
|
+
* @return {number}
|
|
60
|
+
*/
|
|
61
|
+
this.count = () => {
|
|
62
|
+
return this.callbacks.length;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* 触发回调
|
|
66
|
+
* @param {...any} args 回调的调用参数
|
|
67
|
+
*/
|
|
68
|
+
this.trigger = (...args) => {
|
|
69
|
+
this.callbacks.forEach(opt => {
|
|
70
|
+
if (typeof opt === 'function') {
|
|
71
|
+
opt(...args);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
const { callback, ctx } = opt;
|
|
75
|
+
typeof callback === 'function' && callback.call(ctx, ...args);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
79
|
}
|
|
80
80
|
}
|
package/dist/api/utils/index.js
CHANGED
|
@@ -74,28 +74,52 @@ export function serializeParams(params) {
|
|
|
74
74
|
export function temporarilyNotSupport(apiName) {
|
|
75
75
|
return () => {
|
|
76
76
|
const errMsg = `暂时不支持 API ${apiName}`;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
78
|
+
console.error(errMsg);
|
|
79
|
+
return Promise.reject({
|
|
80
|
+
errMsg
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
console.warn(errMsg);
|
|
85
|
+
return Promise.resolve({
|
|
86
|
+
errMsg
|
|
87
|
+
});
|
|
88
|
+
}
|
|
81
89
|
};
|
|
82
90
|
}
|
|
83
91
|
export function weixinCorpSupport(apiName) {
|
|
84
92
|
return () => {
|
|
85
93
|
const errMsg = `h5端仅在微信公众号中支持 API ${apiName}`;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
95
|
+
console.error(errMsg);
|
|
96
|
+
return Promise.reject({
|
|
97
|
+
errMsg
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
console.warn(errMsg);
|
|
102
|
+
return Promise.resolve({
|
|
103
|
+
errMsg
|
|
104
|
+
});
|
|
105
|
+
}
|
|
90
106
|
};
|
|
91
107
|
}
|
|
92
108
|
export function permanentlyNotSupport(apiName) {
|
|
93
109
|
return () => {
|
|
94
110
|
const errMsg = `不支持 API ${apiName}`;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
111
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
112
|
+
console.error(errMsg);
|
|
113
|
+
return Promise.reject({
|
|
114
|
+
errMsg
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
console.warn(errMsg);
|
|
119
|
+
return Promise.resolve({
|
|
120
|
+
errMsg
|
|
121
|
+
});
|
|
122
|
+
}
|
|
99
123
|
};
|
|
100
124
|
}
|
|
101
125
|
export function isFunction(obj) {
|