@tarojs/taro-h5 3.5.0-beta.2 → 3.5.0-beta.3
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/index.cjs.js +53 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +54 -6
- package/dist/index.esm.js.map +1 -1
- package/package.json +5 -5
- package/src/api/base/weapp/app-event.ts +64 -4
- package/src/api/media/audio/InnerAudioContext.ts +1 -1
- package/src/api/network/websocket/socketTask.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); }
|
package/dist/index.cjs.js
CHANGED
|
@@ -755,6 +755,34 @@ const getSystemInfo = (options = {}) => __awaiter(void 0, void 0, void 0, functi
|
|
|
755
755
|
const updateWeChatApp = temporarilyNotSupport('updateWeChatApp');
|
|
756
756
|
const getUpdateManager = temporarilyNotSupport('getUpdateManager');
|
|
757
757
|
|
|
758
|
+
const appShowCallbackManager = new CallbackManager();
|
|
759
|
+
const appHideCallbackManager = new CallbackManager();
|
|
760
|
+
const getApp$1 = () => {
|
|
761
|
+
var _a;
|
|
762
|
+
const path = (_a = Taro__default["default"].Current.page) === null || _a === void 0 ? void 0 : _a.path;
|
|
763
|
+
return {
|
|
764
|
+
/** 小程序切前台的路径 */
|
|
765
|
+
path: path === null || path === void 0 ? void 0 : path.substring(0, path.indexOf('?')),
|
|
766
|
+
/** 小程序切前台的 query 参数 */
|
|
767
|
+
query: queryString.parse(location.search),
|
|
768
|
+
/** 来源信息。 */
|
|
769
|
+
referrerInfo: {},
|
|
770
|
+
/** 小程序切前台的[场景值](https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/scene.html) */
|
|
771
|
+
scene: 0,
|
|
772
|
+
/** shareTicket,详见[获取更多转发信息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) */
|
|
773
|
+
shareTicket: ''
|
|
774
|
+
};
|
|
775
|
+
};
|
|
776
|
+
const appShowListener = () => {
|
|
777
|
+
if (document.visibilityState !== 'hidden') {
|
|
778
|
+
appShowCallbackManager.trigger(getApp$1());
|
|
779
|
+
}
|
|
780
|
+
};
|
|
781
|
+
const appHideListener = () => {
|
|
782
|
+
if (document.visibilityState === 'hidden') {
|
|
783
|
+
appHideCallbackManager.trigger(getApp$1());
|
|
784
|
+
}
|
|
785
|
+
};
|
|
758
786
|
// 应用级事件
|
|
759
787
|
const onUnhandledRejection = temporarilyNotSupport('onUnhandledRejection');
|
|
760
788
|
const onThemeChange = temporarilyNotSupport('onThemeChange');
|
|
@@ -762,16 +790,36 @@ const onPageNotFound = temporarilyNotSupport('onPageNotFound');
|
|
|
762
790
|
const onError = temporarilyNotSupport('onError');
|
|
763
791
|
const onAudioInterruptionEnd = temporarilyNotSupport('onAudioInterruptionEnd');
|
|
764
792
|
const onAudioInterruptionBegin = temporarilyNotSupport('onAudioInterruptionBegin');
|
|
765
|
-
const onAppShow =
|
|
766
|
-
|
|
793
|
+
const onAppShow = callback => {
|
|
794
|
+
appShowCallbackManager.add(callback);
|
|
795
|
+
if (appShowCallbackManager.count() === 1) {
|
|
796
|
+
window.addEventListener('visibilitychange', appShowListener);
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
const onAppHide = callback => {
|
|
800
|
+
appHideCallbackManager.add(callback);
|
|
801
|
+
if (appHideCallbackManager.count() === 1) {
|
|
802
|
+
window.addEventListener('visibilitychange', appHideListener);
|
|
803
|
+
}
|
|
804
|
+
};
|
|
767
805
|
const offUnhandledRejection = temporarilyNotSupport('offUnhandledRejection');
|
|
768
806
|
const offThemeChange = temporarilyNotSupport('offThemeChange');
|
|
769
807
|
const offPageNotFound = temporarilyNotSupport('offPageNotFound');
|
|
770
808
|
const offError = temporarilyNotSupport('offError');
|
|
771
809
|
const offAudioInterruptionEnd = temporarilyNotSupport('offAudioInterruptionEnd');
|
|
772
810
|
const offAudioInterruptionBegin = temporarilyNotSupport('offAudioInterruptionBegin');
|
|
773
|
-
const offAppShow =
|
|
774
|
-
|
|
811
|
+
const offAppShow = callback => {
|
|
812
|
+
appShowCallbackManager.remove(callback);
|
|
813
|
+
if (appShowCallbackManager.count() === 0) {
|
|
814
|
+
window.removeEventListener('visibilitychange', appShowListener);
|
|
815
|
+
}
|
|
816
|
+
};
|
|
817
|
+
const offAppHide = callback => {
|
|
818
|
+
appHideCallbackManager.remove(callback);
|
|
819
|
+
if (appHideCallbackManager.count() === 0) {
|
|
820
|
+
window.removeEventListener('visibilitychange', appHideListener);
|
|
821
|
+
}
|
|
822
|
+
};
|
|
775
823
|
|
|
776
824
|
// 生命周期
|
|
777
825
|
const getLaunchOptionsSync = temporarilyNotSupport('getLaunchOptionsSync');
|
|
@@ -2093,7 +2141,7 @@ class InnerAudioContext {
|
|
|
2093
2141
|
get duration() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.duration) || 0; }
|
|
2094
2142
|
set loop(e) { this.setProperty('loop', e); }
|
|
2095
2143
|
get loop() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.loop) || false; }
|
|
2096
|
-
get paused() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused)
|
|
2144
|
+
get paused() { var _a, _b; return (_b = (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused) !== null && _b !== void 0 ? _b : true; }
|
|
2097
2145
|
set src(e) { this.setProperty('src', e); }
|
|
2098
2146
|
get src() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.src) || ''; }
|
|
2099
2147
|
set volume(e) { this.setProperty('volume', e); }
|