@tarojs/taro-h5 3.4.10 → 3.4.13
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/base/weapp/app-event.js +55 -4
- package/dist/api/media/audio/InnerAudioContext.js +1 -1
- package/dist/api/network/upload.js +1 -1
- package/dist/dist/api/base/weapp/app-event.d.ts +5 -12
- package/dist/dist/api/media/audio/InnerAudioContext.d.ts +1 -1
- package/dist/index.cjs.js +54 -6
- package/dist/index.cjs.js.map +1 -1
- package/package.json +6 -6
- package/src/api/base/weapp/app-event.ts +64 -4
- package/src/api/media/audio/InnerAudioContext.ts +1 -1
- package/src/api/network/upload.ts +1 -1
- package/src/types/api.d.ts +1 -1
|
@@ -1,4 +1,35 @@
|
|
|
1
|
+
import Taro from '@tarojs/api';
|
|
2
|
+
import { parse } from 'query-string';
|
|
1
3
|
import { temporarilyNotSupport } from '../../utils';
|
|
4
|
+
import { CallbackManager } from '../../utils/handler';
|
|
5
|
+
const appShowCallbackManager = new CallbackManager();
|
|
6
|
+
const appHideCallbackManager = new CallbackManager();
|
|
7
|
+
const getApp = () => {
|
|
8
|
+
var _a;
|
|
9
|
+
const path = (_a = Taro.Current.page) === null || _a === void 0 ? void 0 : _a.path;
|
|
10
|
+
return {
|
|
11
|
+
/** 小程序切前台的路径 */
|
|
12
|
+
path: path === null || path === void 0 ? void 0 : path.substring(0, path.indexOf('?')),
|
|
13
|
+
/** 小程序切前台的 query 参数 */
|
|
14
|
+
query: parse(location.search),
|
|
15
|
+
/** 来源信息。 */
|
|
16
|
+
referrerInfo: {},
|
|
17
|
+
/** 小程序切前台的[场景值](https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/scene.html) */
|
|
18
|
+
scene: 0,
|
|
19
|
+
/** shareTicket,详见[获取更多转发信息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) */
|
|
20
|
+
shareTicket: ''
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
const appShowListener = () => {
|
|
24
|
+
if (document.visibilityState !== 'hidden') {
|
|
25
|
+
appShowCallbackManager.trigger(getApp());
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const appHideListener = () => {
|
|
29
|
+
if (document.visibilityState === 'hidden') {
|
|
30
|
+
appHideCallbackManager.trigger(getApp());
|
|
31
|
+
}
|
|
32
|
+
};
|
|
2
33
|
// 应用级事件
|
|
3
34
|
export const onUnhandledRejection = temporarilyNotSupport('onUnhandledRejection');
|
|
4
35
|
export const onThemeChange = temporarilyNotSupport('onThemeChange');
|
|
@@ -6,13 +37,33 @@ export const onPageNotFound = temporarilyNotSupport('onPageNotFound');
|
|
|
6
37
|
export const onError = temporarilyNotSupport('onError');
|
|
7
38
|
export const onAudioInterruptionEnd = temporarilyNotSupport('onAudioInterruptionEnd');
|
|
8
39
|
export const onAudioInterruptionBegin = temporarilyNotSupport('onAudioInterruptionBegin');
|
|
9
|
-
export const onAppShow =
|
|
10
|
-
|
|
40
|
+
export const onAppShow = callback => {
|
|
41
|
+
appShowCallbackManager.add(callback);
|
|
42
|
+
if (appShowCallbackManager.count() === 1) {
|
|
43
|
+
window.addEventListener('visibilitychange', appShowListener);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
export const onAppHide = callback => {
|
|
47
|
+
appHideCallbackManager.add(callback);
|
|
48
|
+
if (appHideCallbackManager.count() === 1) {
|
|
49
|
+
window.addEventListener('visibilitychange', appHideListener);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
11
52
|
export const offUnhandledRejection = temporarilyNotSupport('offUnhandledRejection');
|
|
12
53
|
export const offThemeChange = temporarilyNotSupport('offThemeChange');
|
|
13
54
|
export const offPageNotFound = temporarilyNotSupport('offPageNotFound');
|
|
14
55
|
export const offError = temporarilyNotSupport('offError');
|
|
15
56
|
export const offAudioInterruptionEnd = temporarilyNotSupport('offAudioInterruptionEnd');
|
|
16
57
|
export const offAudioInterruptionBegin = temporarilyNotSupport('offAudioInterruptionBegin');
|
|
17
|
-
export const offAppShow =
|
|
18
|
-
|
|
58
|
+
export const offAppShow = callback => {
|
|
59
|
+
appShowCallbackManager.remove(callback);
|
|
60
|
+
if (appShowCallbackManager.count() === 0) {
|
|
61
|
+
window.removeEventListener('visibilitychange', appShowListener);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
export const offAppHide = callback => {
|
|
65
|
+
appHideCallbackManager.remove(callback);
|
|
66
|
+
if (appHideCallbackManager.count() === 0) {
|
|
67
|
+
window.removeEventListener('visibilitychange', appHideListener);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
@@ -63,7 +63,7 @@ export class InnerAudioContext {
|
|
|
63
63
|
get duration() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.duration) || 0; }
|
|
64
64
|
set loop(e) { this.setProperty('loop', e); }
|
|
65
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)
|
|
66
|
+
get paused() { var _a, _b; return (_b = (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused) !== null && _b !== void 0 ? _b : true; }
|
|
67
67
|
set src(e) { this.setProperty('src', e); }
|
|
68
68
|
get src() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.src) || ''; }
|
|
69
69
|
set volume(e) { this.setProperty('volume', e); }
|
|
@@ -20,7 +20,7 @@ const createUploadTask = ({ url, filePath, formData = {}, name, header, timeout,
|
|
|
20
20
|
callbackManager.progressUpdate.trigger({
|
|
21
21
|
progress: Math.round(loaded / total * 100),
|
|
22
22
|
totalBytesSent: loaded,
|
|
23
|
-
|
|
23
|
+
totalBytesExpectedToSend: total
|
|
24
24
|
});
|
|
25
25
|
};
|
|
26
26
|
xhr.onreadystatechange = () => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Taro from '@tarojs/api';
|
|
1
2
|
export declare const onUnhandledRejection: () => Promise<{
|
|
2
3
|
errMsg: string;
|
|
3
4
|
}>;
|
|
@@ -16,12 +17,8 @@ export declare const onAudioInterruptionEnd: () => Promise<{
|
|
|
16
17
|
export declare const onAudioInterruptionBegin: () => Promise<{
|
|
17
18
|
errMsg: string;
|
|
18
19
|
}>;
|
|
19
|
-
export declare const onAppShow:
|
|
20
|
-
|
|
21
|
-
}>;
|
|
22
|
-
export declare const onAppHide: () => Promise<{
|
|
23
|
-
errMsg: string;
|
|
24
|
-
}>;
|
|
20
|
+
export declare const onAppShow: typeof Taro.onAppShow;
|
|
21
|
+
export declare const onAppHide: typeof Taro.onAppHide;
|
|
25
22
|
export declare const offUnhandledRejection: () => Promise<{
|
|
26
23
|
errMsg: string;
|
|
27
24
|
}>;
|
|
@@ -40,9 +37,5 @@ export declare const offAudioInterruptionEnd: () => Promise<{
|
|
|
40
37
|
export declare const offAudioInterruptionBegin: () => Promise<{
|
|
41
38
|
errMsg: string;
|
|
42
39
|
}>;
|
|
43
|
-
export declare const offAppShow:
|
|
44
|
-
|
|
45
|
-
}>;
|
|
46
|
-
export declare const offAppHide: () => Promise<{
|
|
47
|
-
errMsg: string;
|
|
48
|
-
}>;
|
|
40
|
+
export declare const offAppShow: typeof Taro.offWindowResize;
|
|
41
|
+
export declare const offAppHide: typeof Taro.offWindowResize;
|
|
@@ -13,7 +13,7 @@ export declare class InnerAudioContext implements Taro.InnerAudioContext {
|
|
|
13
13
|
get duration(): number;
|
|
14
14
|
set loop(e: boolean);
|
|
15
15
|
get loop(): boolean;
|
|
16
|
-
get paused():
|
|
16
|
+
get paused(): boolean;
|
|
17
17
|
set src(e: string);
|
|
18
18
|
get src(): string;
|
|
19
19
|
set volume(e: number);
|
package/dist/index.cjs.js
CHANGED
|
@@ -514,6 +514,34 @@ const getUpdateManager = temporarilyNotSupport('getUpdateManager');
|
|
|
514
514
|
const getLaunchOptionsSync = temporarilyNotSupport('getLaunchOptionsSync');
|
|
515
515
|
const getEnterOptionsSync = temporarilyNotSupport('getEnterOptionsSync');
|
|
516
516
|
|
|
517
|
+
const appShowCallbackManager = new CallbackManager();
|
|
518
|
+
const appHideCallbackManager = new CallbackManager();
|
|
519
|
+
const getApp$1 = () => {
|
|
520
|
+
var _a;
|
|
521
|
+
const path = (_a = Taro__default["default"].Current.page) === null || _a === void 0 ? void 0 : _a.path;
|
|
522
|
+
return {
|
|
523
|
+
/** 小程序切前台的路径 */
|
|
524
|
+
path: path === null || path === void 0 ? void 0 : path.substring(0, path.indexOf('?')),
|
|
525
|
+
/** 小程序切前台的 query 参数 */
|
|
526
|
+
query: queryString.parse(location.search),
|
|
527
|
+
/** 来源信息。 */
|
|
528
|
+
referrerInfo: {},
|
|
529
|
+
/** 小程序切前台的[场景值](https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/scene.html) */
|
|
530
|
+
scene: 0,
|
|
531
|
+
/** shareTicket,详见[获取更多转发信息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) */
|
|
532
|
+
shareTicket: ''
|
|
533
|
+
};
|
|
534
|
+
};
|
|
535
|
+
const appShowListener = () => {
|
|
536
|
+
if (document.visibilityState !== 'hidden') {
|
|
537
|
+
appShowCallbackManager.trigger(getApp$1());
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
const appHideListener = () => {
|
|
541
|
+
if (document.visibilityState === 'hidden') {
|
|
542
|
+
appHideCallbackManager.trigger(getApp$1());
|
|
543
|
+
}
|
|
544
|
+
};
|
|
517
545
|
// 应用级事件
|
|
518
546
|
const onUnhandledRejection = temporarilyNotSupport('onUnhandledRejection');
|
|
519
547
|
const onThemeChange = temporarilyNotSupport('onThemeChange');
|
|
@@ -521,16 +549,36 @@ const onPageNotFound = temporarilyNotSupport('onPageNotFound');
|
|
|
521
549
|
const onError = temporarilyNotSupport('onError');
|
|
522
550
|
const onAudioInterruptionEnd = temporarilyNotSupport('onAudioInterruptionEnd');
|
|
523
551
|
const onAudioInterruptionBegin = temporarilyNotSupport('onAudioInterruptionBegin');
|
|
524
|
-
const onAppShow =
|
|
525
|
-
|
|
552
|
+
const onAppShow = callback => {
|
|
553
|
+
appShowCallbackManager.add(callback);
|
|
554
|
+
if (appShowCallbackManager.count() === 1) {
|
|
555
|
+
window.addEventListener('visibilitychange', appShowListener);
|
|
556
|
+
}
|
|
557
|
+
};
|
|
558
|
+
const onAppHide = callback => {
|
|
559
|
+
appHideCallbackManager.add(callback);
|
|
560
|
+
if (appHideCallbackManager.count() === 1) {
|
|
561
|
+
window.addEventListener('visibilitychange', appHideListener);
|
|
562
|
+
}
|
|
563
|
+
};
|
|
526
564
|
const offUnhandledRejection = temporarilyNotSupport('offUnhandledRejection');
|
|
527
565
|
const offThemeChange = temporarilyNotSupport('offThemeChange');
|
|
528
566
|
const offPageNotFound = temporarilyNotSupport('offPageNotFound');
|
|
529
567
|
const offError = temporarilyNotSupport('offError');
|
|
530
568
|
const offAudioInterruptionEnd = temporarilyNotSupport('offAudioInterruptionEnd');
|
|
531
569
|
const offAudioInterruptionBegin = temporarilyNotSupport('offAudioInterruptionBegin');
|
|
532
|
-
const offAppShow =
|
|
533
|
-
|
|
570
|
+
const offAppShow = callback => {
|
|
571
|
+
appShowCallbackManager.remove(callback);
|
|
572
|
+
if (appShowCallbackManager.count() === 0) {
|
|
573
|
+
window.removeEventListener('visibilitychange', appShowListener);
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
const offAppHide = callback => {
|
|
577
|
+
appHideCallbackManager.remove(callback);
|
|
578
|
+
if (appHideCallbackManager.count() === 0) {
|
|
579
|
+
window.removeEventListener('visibilitychange', appHideListener);
|
|
580
|
+
}
|
|
581
|
+
};
|
|
534
582
|
|
|
535
583
|
const setEnableDebug = temporarilyNotSupport('setEnableDebug');
|
|
536
584
|
const getRealtimeLogManager = temporarilyNotSupport('getRealtimeLogManager');
|
|
@@ -1863,7 +1911,7 @@ class InnerAudioContext {
|
|
|
1863
1911
|
get duration() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.duration) || 0; }
|
|
1864
1912
|
set loop(e) { this.setProperty('loop', e); }
|
|
1865
1913
|
get loop() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.loop) || false; }
|
|
1866
|
-
get paused() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused)
|
|
1914
|
+
get paused() { var _a, _b; return (_b = (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused) !== null && _b !== void 0 ? _b : true; }
|
|
1867
1915
|
set src(e) { this.setProperty('src', e); }
|
|
1868
1916
|
get src() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.src) || ''; }
|
|
1869
1917
|
set volume(e) { this.setProperty('volume', e); }
|
|
@@ -2669,7 +2717,7 @@ const createUploadTask = ({ url, filePath, formData = {}, name, header, timeout,
|
|
|
2669
2717
|
callbackManager.progressUpdate.trigger({
|
|
2670
2718
|
progress: Math.round(loaded / total * 100),
|
|
2671
2719
|
totalBytesSent: loaded,
|
|
2672
|
-
|
|
2720
|
+
totalBytesExpectedToSend: total
|
|
2673
2721
|
});
|
|
2674
2722
|
};
|
|
2675
2723
|
xhr.onreadystatechange = () => {
|