@tarojs/taro-h5 3.5.0-beta.1 → 3.5.0-beta.4

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/index.esm.js CHANGED
@@ -4,7 +4,7 @@ export { getCurrentPages, history, navigateBack, navigateTo, reLaunch, redirectT
4
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
 
@@ -241,7 +241,7 @@ const getLogManager = temporarilyNotSupport('getLogManager');
241
241
  const reportPerformance = temporarilyNotSupport('reportPerformance');
242
242
  const getPerformance = temporarilyNotSupport('getPerformance');
243
243
 
244
- /*! *****************************************************************************
244
+ /******************************************************************************
245
245
  Copyright (c) Microsoft Corporation.
246
246
 
247
247
  Permission to use, copy, modify, and/or distribute this software for any
@@ -350,7 +350,11 @@ function __generator(thisArg, body) {
350
350
 
351
351
  var __createBinding = Object.create ? (function(o, m, k, k2) {
352
352
  if (k2 === undefined) k2 = k;
353
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
353
+ var desc = Object.getOwnPropertyDescriptor(m, k);
354
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
355
+ desc = { enumerable: true, get: function() { return m[k]; } };
356
+ }
357
+ Object.defineProperty(o, k2, desc);
354
358
  }) : (function(o, m, k, k2) {
355
359
  if (k2 === undefined) k2 = k;
356
360
  o[k2] = m[k];
@@ -479,6 +483,11 @@ function __classPrivateFieldSet(receiver, state, value, kind, f) {
479
483
  if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
480
484
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
481
485
  return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
486
+ }
487
+
488
+ function __classPrivateFieldIn(state, receiver) {
489
+ if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
490
+ return typeof state === "function" ? receiver === state : state.has(receiver);
482
491
  }
483
492
 
484
493
  class MethodHandler {
@@ -746,6 +755,34 @@ const getSystemInfo = (options = {}) => __awaiter(void 0, void 0, void 0, functi
746
755
  const updateWeChatApp = temporarilyNotSupport('updateWeChatApp');
747
756
  const getUpdateManager = temporarilyNotSupport('getUpdateManager');
748
757
 
758
+ const appShowCallbackManager = new CallbackManager();
759
+ const appHideCallbackManager = new CallbackManager();
760
+ const getApp$1 = () => {
761
+ var _a;
762
+ const path = (_a = Taro.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: 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
+ };
749
786
  // 应用级事件
750
787
  const onUnhandledRejection = temporarilyNotSupport('onUnhandledRejection');
751
788
  const onThemeChange = temporarilyNotSupport('onThemeChange');
@@ -753,16 +790,36 @@ const onPageNotFound = temporarilyNotSupport('onPageNotFound');
753
790
  const onError = temporarilyNotSupport('onError');
754
791
  const onAudioInterruptionEnd = temporarilyNotSupport('onAudioInterruptionEnd');
755
792
  const onAudioInterruptionBegin = temporarilyNotSupport('onAudioInterruptionBegin');
756
- const onAppShow = temporarilyNotSupport('onAppShow');
757
- const onAppHide = temporarilyNotSupport('onAppHide');
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
+ };
758
805
  const offUnhandledRejection = temporarilyNotSupport('offUnhandledRejection');
759
806
  const offThemeChange = temporarilyNotSupport('offThemeChange');
760
807
  const offPageNotFound = temporarilyNotSupport('offPageNotFound');
761
808
  const offError = temporarilyNotSupport('offError');
762
809
  const offAudioInterruptionEnd = temporarilyNotSupport('offAudioInterruptionEnd');
763
810
  const offAudioInterruptionBegin = temporarilyNotSupport('offAudioInterruptionBegin');
764
- const offAppShow = temporarilyNotSupport('offAppShow');
765
- const offAppHide = temporarilyNotSupport('offAppHide');
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
+ };
766
823
 
767
824
  // 生命周期
768
825
  const getLaunchOptionsSync = temporarilyNotSupport('getLaunchOptionsSync');
@@ -2084,7 +2141,7 @@ class InnerAudioContext {
2084
2141
  get duration() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.duration) || 0; }
2085
2142
  set loop(e) { this.setProperty('loop', e); }
2086
2143
  get loop() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.loop) || false; }
2087
- get paused() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.paused) || true; }
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; }
2088
2145
  set src(e) { this.setProperty('src', e); }
2089
2146
  get src() { var _a; return ((_a = this.Instance) === null || _a === void 0 ? void 0 : _a.src) || ''; }
2090
2147
  set volume(e) { this.setProperty('volume', e); }
@@ -2893,7 +2950,7 @@ const createUploadTask = ({ url, filePath, formData = {}, name, header, timeout,
2893
2950
  callbackManager.progressUpdate.trigger({
2894
2951
  progress: Math.round(loaded / total * 100),
2895
2952
  totalBytesSent: loaded,
2896
- totalBytesExpectedToSent: total
2953
+ totalBytesExpectedToSend: total
2897
2954
  });
2898
2955
  };
2899
2956
  xhr.onreadystatechange = () => {