@tarojs/taro-h5 3.4.0 → 3.4.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.
@@ -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);
@@ -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 { CallbackManager } from '../../utils/handler';
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 '../utils';
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
- export const getBackgroundAudioManager = temporarilyNotSupport('getBackgroundAudioManager');
12
+ /**
13
+ * 获取全局唯一的背景音频管理器
14
+ */
15
+ export const getBackgroundAudioManager = () => new BackgroundAudioManager();
@@ -1,7 +1,6 @@
1
1
  export * from './audio';
2
2
  export * from './background-audio';
3
3
  export * from './camera';
4
- export * from './editor';
5
4
  export * from './image';
6
5
  export * from './live';
7
6
  export * from './map';
@@ -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
- var _a, _b, _c;
9
- (_a = this.$style) === null || _a === void 0 ? void 0 : _a.setAttribute('type', 'text/css');
10
- (_b = this.$style) === null || _b === void 0 ? void 0 : _b.setAttribute('data-type', 'Taro');
11
- document.getElementsByTagName('head')[0].appendChild(this.$style);
12
- this.sheet = (_c = this.$style) === null || _c === void 0 ? void 0 : _c.sheet;
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
  }
@@ -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.getElementById(id)
22
+ ? document.querySelector(`.taro_page#${id}`)
23
23
  : document.querySelector('.taro_page') ||
24
24
  document.querySelector('.taro_router'));
25
25
  if (!scrollFunc) {
@@ -74,28 +74,52 @@ export function serializeParams(params) {
74
74
  export function temporarilyNotSupport(apiName) {
75
75
  return () => {
76
76
  const errMsg = `暂时不支持 API ${apiName}`;
77
- console.error(errMsg);
78
- return Promise.reject({
79
- errMsg
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
- console.error(errMsg);
87
- return Promise.reject({
88
- errMsg
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
- console.error(errMsg);
96
- return Promise.reject({
97
- errMsg
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) {