@tarojs/taro-h5 3.5.0-beta.0 → 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/api/network/upload.js +1 -1
- package/dist/index.cjs.js +56 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +58 -14
- package/dist/index.esm.js.map +1 -1
- package/dist/utils/index.js +3 -7
- 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/upload.ts +1 -1
- package/src/api/network/websocket/socketTask.ts +1 -1
- package/src/utils/index.ts +3 -8
package/dist/index.esm.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import Taro from '@tarojs/api';
|
|
2
2
|
import { history, navigateBack, navigateTo, reLaunch, redirectTo, getCurrentPages, switchTab } from '@tarojs/router';
|
|
3
3
|
export { getCurrentPages, history, navigateBack, navigateTo, reLaunch, redirectTo, switchTab } from '@tarojs/router';
|
|
4
|
-
import {
|
|
4
|
+
import { hooks, Current as Current$1 } from '@tarojs/runtime';
|
|
5
5
|
import { fromByteArray, toByteArray } from 'base64-js';
|
|
6
6
|
import MobileDetect from 'mobile-detect';
|
|
7
|
-
import { stringify } from 'query-string';
|
|
7
|
+
import { parse, stringify } from 'query-string';
|
|
8
8
|
import 'whatwg-fetch';
|
|
9
9
|
import jsonpRetry from 'jsonp-retry';
|
|
10
10
|
|
|
@@ -74,12 +74,8 @@ function shouldBeObject(target) {
|
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
function findDOM(inst) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const find = runtimeHooks.getDOMNode;
|
|
80
|
-
if (typeof find === 'function') {
|
|
81
|
-
return find(inst);
|
|
82
|
-
}
|
|
77
|
+
if (inst && hooks.isExist('getDOMNode')) {
|
|
78
|
+
return hooks.call('getDOMNode', inst);
|
|
83
79
|
}
|
|
84
80
|
const page = Current$1.page;
|
|
85
81
|
const path = page === null || page === void 0 ? void 0 : page.path;
|
|
@@ -750,6 +746,34 @@ const getSystemInfo = (options = {}) => __awaiter(void 0, void 0, void 0, functi
|
|
|
750
746
|
const updateWeChatApp = temporarilyNotSupport('updateWeChatApp');
|
|
751
747
|
const getUpdateManager = temporarilyNotSupport('getUpdateManager');
|
|
752
748
|
|
|
749
|
+
const appShowCallbackManager = new CallbackManager();
|
|
750
|
+
const appHideCallbackManager = new CallbackManager();
|
|
751
|
+
const getApp$1 = () => {
|
|
752
|
+
var _a;
|
|
753
|
+
const path = (_a = Taro.Current.page) === null || _a === void 0 ? void 0 : _a.path;
|
|
754
|
+
return {
|
|
755
|
+
/** 小程序切前台的路径 */
|
|
756
|
+
path: path === null || path === void 0 ? void 0 : path.substring(0, path.indexOf('?')),
|
|
757
|
+
/** 小程序切前台的 query 参数 */
|
|
758
|
+
query: parse(location.search),
|
|
759
|
+
/** 来源信息。 */
|
|
760
|
+
referrerInfo: {},
|
|
761
|
+
/** 小程序切前台的[场景值](https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/scene.html) */
|
|
762
|
+
scene: 0,
|
|
763
|
+
/** shareTicket,详见[获取更多转发信息](https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/share.html) */
|
|
764
|
+
shareTicket: ''
|
|
765
|
+
};
|
|
766
|
+
};
|
|
767
|
+
const appShowListener = () => {
|
|
768
|
+
if (document.visibilityState !== 'hidden') {
|
|
769
|
+
appShowCallbackManager.trigger(getApp$1());
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
const appHideListener = () => {
|
|
773
|
+
if (document.visibilityState === 'hidden') {
|
|
774
|
+
appHideCallbackManager.trigger(getApp$1());
|
|
775
|
+
}
|
|
776
|
+
};
|
|
753
777
|
// 应用级事件
|
|
754
778
|
const onUnhandledRejection = temporarilyNotSupport('onUnhandledRejection');
|
|
755
779
|
const onThemeChange = temporarilyNotSupport('onThemeChange');
|
|
@@ -757,16 +781,36 @@ const onPageNotFound = temporarilyNotSupport('onPageNotFound');
|
|
|
757
781
|
const onError = temporarilyNotSupport('onError');
|
|
758
782
|
const onAudioInterruptionEnd = temporarilyNotSupport('onAudioInterruptionEnd');
|
|
759
783
|
const onAudioInterruptionBegin = temporarilyNotSupport('onAudioInterruptionBegin');
|
|
760
|
-
const onAppShow =
|
|
761
|
-
|
|
784
|
+
const onAppShow = callback => {
|
|
785
|
+
appShowCallbackManager.add(callback);
|
|
786
|
+
if (appShowCallbackManager.count() === 1) {
|
|
787
|
+
window.addEventListener('visibilitychange', appShowListener);
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
const onAppHide = callback => {
|
|
791
|
+
appHideCallbackManager.add(callback);
|
|
792
|
+
if (appHideCallbackManager.count() === 1) {
|
|
793
|
+
window.addEventListener('visibilitychange', appHideListener);
|
|
794
|
+
}
|
|
795
|
+
};
|
|
762
796
|
const offUnhandledRejection = temporarilyNotSupport('offUnhandledRejection');
|
|
763
797
|
const offThemeChange = temporarilyNotSupport('offThemeChange');
|
|
764
798
|
const offPageNotFound = temporarilyNotSupport('offPageNotFound');
|
|
765
799
|
const offError = temporarilyNotSupport('offError');
|
|
766
800
|
const offAudioInterruptionEnd = temporarilyNotSupport('offAudioInterruptionEnd');
|
|
767
801
|
const offAudioInterruptionBegin = temporarilyNotSupport('offAudioInterruptionBegin');
|
|
768
|
-
const offAppShow =
|
|
769
|
-
|
|
802
|
+
const offAppShow = callback => {
|
|
803
|
+
appShowCallbackManager.remove(callback);
|
|
804
|
+
if (appShowCallbackManager.count() === 0) {
|
|
805
|
+
window.removeEventListener('visibilitychange', appShowListener);
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
const offAppHide = callback => {
|
|
809
|
+
appHideCallbackManager.remove(callback);
|
|
810
|
+
if (appHideCallbackManager.count() === 0) {
|
|
811
|
+
window.removeEventListener('visibilitychange', appHideListener);
|
|
812
|
+
}
|
|
813
|
+
};
|
|
770
814
|
|
|
771
815
|
// 生命周期
|
|
772
816
|
const getLaunchOptionsSync = temporarilyNotSupport('getLaunchOptionsSync');
|
|
@@ -2088,7 +2132,7 @@ class InnerAudioContext {
|
|
|
2088
2132
|
get duration() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.duration) || 0; }
|
|
2089
2133
|
set loop(e) { this.setProperty('loop', e); }
|
|
2090
2134
|
get loop() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.loop) || false; }
|
|
2091
|
-
get paused() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused)
|
|
2135
|
+
get paused() { var _a, _b; return (_b = (_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused) !== null && _b !== void 0 ? _b : true; }
|
|
2092
2136
|
set src(e) { this.setProperty('src', e); }
|
|
2093
2137
|
get src() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.src) || ''; }
|
|
2094
2138
|
set volume(e) { this.setProperty('volume', e); }
|
|
@@ -2897,7 +2941,7 @@ const createUploadTask = ({ url, filePath, formData = {}, name, header, timeout,
|
|
|
2897
2941
|
callbackManager.progressUpdate.trigger({
|
|
2898
2942
|
progress: Math.round(loaded / total * 100),
|
|
2899
2943
|
totalBytesSent: loaded,
|
|
2900
|
-
|
|
2944
|
+
totalBytesExpectedToSend: total
|
|
2901
2945
|
});
|
|
2902
2946
|
};
|
|
2903
2947
|
xhr.onreadystatechange = () => {
|