@tarojs/taro-h5 3.5.7 → 3.5.9

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.
@@ -1,3 +1,3 @@
1
1
  export declare const scanCode: (options?: Partial<{
2
2
  needResult: number;
3
- }>) => Promise<any>;
3
+ }>, ...args: any[]) => Promise<any>;
@@ -1,2 +1,2 @@
1
1
  import Taro from '@tarojs/api';
2
- export declare const getLocation: (options?: Partial<Taro.getLocation.Option>) => Promise<Taro.getLocation.SuccessCallbackResult>;
2
+ export declare const getLocation: (options?: Partial<Taro.getLocation.Option>, ...args: any[]) => Promise<Taro.getLocation.SuccessCallbackResult>;
@@ -3,7 +3,7 @@ export declare const startLocationUpdateBackground: (option?: {}, ...args: any[]
3
3
  export declare const startLocationUpdate: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
4
4
  export declare const openLocation: (options?: Partial<{
5
5
  scale: number;
6
- }>) => Promise<any>;
6
+ }>, ...args: any[]) => Promise<any>;
7
7
  export declare const onLocationChangeError: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
8
8
  export declare const onLocationChange: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
9
9
  export declare const offLocationChangeError: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
@@ -24,6 +24,7 @@ export const previewImage = (options) => __awaiter(void 0, void 0, void 0, funct
24
24
  image.style.maxWidth = '100%';
25
25
  image.src = url;
26
26
  const div = document.createElement('div');
27
+ div.classList.add('swiper-zoom-container');
27
28
  div.style.cssText = 'display:flex;align-items:center;justify-content:center;max-width:100%;min-height:100%;';
28
29
  div.appendChild(image);
29
30
  item.appendChild(div);
@@ -54,6 +55,8 @@ export const previewImage = (options) => __awaiter(void 0, void 0, void 0, funct
54
55
  const swiper = document.createElement('taro-swiper-core');
55
56
  // @ts-ignore
56
57
  swiper.full = true;
58
+ // @ts-ignore
59
+ swiper.zoom = true;
57
60
  let children = [];
58
61
  try {
59
62
  children = yield Promise.all(urls.map(e => loadImage(e, fail)));
@@ -1,7 +1,7 @@
1
1
  import { CallbackManager } from '../../utils/handler';
2
2
  import { NETWORK_TIMEOUT, setHeader, XHR_STATS } from './utils';
3
- const createDownloadTask = ({ url, header, withCredentials = true, success, error }) => {
4
- let timeout;
3
+ const createDownloadTask = ({ url, header, withCredentials = true, timeout, success, error }) => {
4
+ let timeoutInter;
5
5
  const apiName = 'downloadFile';
6
6
  const xhr = new XMLHttpRequest();
7
7
  const callbackManager = {
@@ -37,7 +37,7 @@ const createDownloadTask = ({ url, header, withCredentials = true, success, erro
37
37
  });
38
38
  };
39
39
  xhr.onabort = () => {
40
- clearTimeout(timeout);
40
+ clearTimeout(timeoutInter);
41
41
  error({
42
42
  errMsg: `${apiName}:fail abort`
43
43
  });
@@ -55,7 +55,7 @@ const createDownloadTask = ({ url, header, withCredentials = true, success, erro
55
55
  };
56
56
  const send = () => {
57
57
  xhr.send();
58
- timeout = setTimeout(() => {
58
+ timeoutInter = setTimeout(() => {
59
59
  xhr.onabort = null;
60
60
  xhr.onload = null;
61
61
  xhr.onprogress = null;
@@ -65,7 +65,7 @@ const createDownloadTask = ({ url, header, withCredentials = true, success, erro
65
65
  error({
66
66
  errMsg: `${apiName}:fail timeout`
67
67
  });
68
- }, NETWORK_TIMEOUT);
68
+ }, timeout || NETWORK_TIMEOUT);
69
69
  };
70
70
  send();
71
71
  /**
@@ -100,13 +100,14 @@ const createDownloadTask = ({ url, header, withCredentials = true, success, erro
100
100
  * 下载文件资源到本地。客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径。使用前请注意阅读相关说明。
101
101
  * 注意:请在服务端响应的 header 中指定合理的 Content-Type 字段,以保证客户端正确处理文件类型。
102
102
  */
103
- export const downloadFile = ({ url, header, withCredentials, success, fail, complete }) => {
103
+ export const downloadFile = ({ url, header, withCredentials, timeout, success, fail, complete }) => {
104
104
  let task;
105
105
  const result = new Promise((resolve, reject) => {
106
106
  task = createDownloadTask({
107
107
  url,
108
108
  header,
109
109
  withCredentials,
110
+ timeout,
110
111
  success: res => {
111
112
  success && success(res);
112
113
  complete && complete(res);
@@ -49,6 +49,7 @@ export default class ActionSheet {
49
49
  };
50
50
  lastConfig: {};
51
51
  el: HTMLDivElement;
52
+ mask: HTMLDivElement;
52
53
  actionSheet: HTMLDivElement;
53
54
  menu: HTMLDivElement;
54
55
  cells: HTMLDivElement[];
@@ -65,8 +65,8 @@ export default class ActionSheet {
65
65
  this.el.style.opacity = '0';
66
66
  this.el.style.transition = 'opacity 0.2s linear';
67
67
  // mask
68
- const mask = document.createElement('div');
69
- mask.setAttribute('style', inlineStyle(maskStyle));
68
+ this.mask = document.createElement('div');
69
+ this.mask.setAttribute('style', inlineStyle(maskStyle));
70
70
  // actionSheet
71
71
  this.actionSheet = document.createElement('div');
72
72
  this.actionSheet.setAttribute('style', inlineStyle(actionSheetStyle));
@@ -96,14 +96,14 @@ export default class ActionSheet {
96
96
  this.cells.forEach(item => this.menu.appendChild(item));
97
97
  this.actionSheet.appendChild(this.menu);
98
98
  this.actionSheet.appendChild(this.cancel);
99
- this.el.appendChild(mask);
99
+ this.el.appendChild(this.mask);
100
100
  this.el.appendChild(this.actionSheet);
101
101
  // callbacks
102
102
  const cb = () => {
103
103
  this.hide();
104
104
  resolve('cancel');
105
105
  };
106
- mask.onclick = cb;
106
+ this.mask.onclick = cb;
107
107
  this.cancel.onclick = cb;
108
108
  // show immediately
109
109
  document.body.appendChild(this.el);
@@ -157,6 +157,13 @@ export default class ActionSheet {
157
157
  }
158
158
  this.cells.splice(itemListLen);
159
159
  }
160
+ // callbacks
161
+ const cb = () => {
162
+ this.hide();
163
+ resolve('cancel');
164
+ };
165
+ this.mask.onclick = cb;
166
+ this.cancel.onclick = cb;
160
167
  // show
161
168
  this.el.style.display = 'block';
162
169
  setTimeout(() => {
@@ -269,7 +269,7 @@ declare const makePhoneCall: typeof Taro.makePhoneCall;
269
269
  // 扫码
270
270
  declare const scanCode: (options?: Partial<{
271
271
  needResult: number;
272
- }>) => Promise<any>;
272
+ }>, ...args: any[]) => Promise<any>;
273
273
  // 屏幕
274
274
  declare const setVisualEffectOnCapture: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
275
275
  declare const setScreenBrightness: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
@@ -318,12 +318,12 @@ declare const startLocationUpdateBackground: (option?: {}, ...args: any[]) => Pr
318
318
  declare const startLocationUpdate: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
319
319
  declare const openLocation: (options?: Partial<{
320
320
  scale: number;
321
- }>) => Promise<any>;
321
+ }>, ...args: any[]) => Promise<any>;
322
322
  declare const onLocationChangeError: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
323
323
  declare const onLocationChange: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
324
324
  declare const offLocationChangeError: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
325
325
  declare const offLocationChange: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
326
- declare const getLocation: (options?: Partial<Taro.getLocation.Option>) => Promise<Taro.getLocation.SuccessCallbackResult>;
326
+ declare const getLocation: (options?: Partial<Taro.getLocation.Option>, ...args: any[]) => Promise<Taro.getLocation.SuccessCallbackResult>;
327
327
  declare const choosePoi: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
328
328
  declare const getFuzzyLocation: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
329
329
  /**
package/dist/index.cjs.js CHANGED
@@ -281,7 +281,7 @@ function permanentlyNotSupport(name = '') {
281
281
  }
282
282
  function processOpenApi({ name, defaultOptions, standardMethod, formatOptions = options => options, formatResult = res => res }) {
283
283
  const notSupported = weixinCorpSupport(name);
284
- return (options = {}) => {
284
+ return (options = {}, ...args) => {
285
285
  var _a;
286
286
  // @ts-ignore
287
287
  const targetApi = (_a = window === null || window === void 0 ? void 0 : window.wx) === null || _a === void 0 ? void 0 : _a[name];
@@ -307,7 +307,7 @@ function processOpenApi({ name, defaultOptions, standardMethod, formatOptions =
307
307
  return standardMethod(opts);
308
308
  }
309
309
  else {
310
- return notSupported();
310
+ return notSupported(options, ...args);
311
311
  }
312
312
  };
313
313
  }
@@ -2335,6 +2335,7 @@ const previewImage = (options) => __awaiter(void 0, void 0, void 0, function* ()
2335
2335
  image.style.maxWidth = '100%';
2336
2336
  image.src = url;
2337
2337
  const div = document.createElement('div');
2338
+ div.classList.add('swiper-zoom-container');
2338
2339
  div.style.cssText = 'display:flex;align-items:center;justify-content:center;max-width:100%;min-height:100%;';
2339
2340
  div.appendChild(image);
2340
2341
  item.appendChild(div);
@@ -2365,6 +2366,8 @@ const previewImage = (options) => __awaiter(void 0, void 0, void 0, function* ()
2365
2366
  const swiper = document.createElement('taro-swiper-core');
2366
2367
  // @ts-ignore
2367
2368
  swiper.full = true;
2369
+ // @ts-ignore
2370
+ swiper.zoom = true;
2368
2371
  let children = [];
2369
2372
  try {
2370
2373
  children = yield Promise.all(urls.map(e => loadImage(e, fail)));
@@ -2660,8 +2663,8 @@ const convertObjectUrlToBlob = url => {
2660
2663
  });
2661
2664
  };
2662
2665
 
2663
- const createDownloadTask = ({ url, header, withCredentials = true, success, error }) => {
2664
- let timeout;
2666
+ const createDownloadTask = ({ url, header, withCredentials = true, timeout, success, error }) => {
2667
+ let timeoutInter;
2665
2668
  const apiName = 'downloadFile';
2666
2669
  const xhr = new XMLHttpRequest();
2667
2670
  const callbackManager = {
@@ -2697,7 +2700,7 @@ const createDownloadTask = ({ url, header, withCredentials = true, success, erro
2697
2700
  });
2698
2701
  };
2699
2702
  xhr.onabort = () => {
2700
- clearTimeout(timeout);
2703
+ clearTimeout(timeoutInter);
2701
2704
  error({
2702
2705
  errMsg: `${apiName}:fail abort`
2703
2706
  });
@@ -2715,7 +2718,7 @@ const createDownloadTask = ({ url, header, withCredentials = true, success, erro
2715
2718
  };
2716
2719
  const send = () => {
2717
2720
  xhr.send();
2718
- timeout = setTimeout(() => {
2721
+ timeoutInter = setTimeout(() => {
2719
2722
  xhr.onabort = null;
2720
2723
  xhr.onload = null;
2721
2724
  xhr.onprogress = null;
@@ -2725,7 +2728,7 @@ const createDownloadTask = ({ url, header, withCredentials = true, success, erro
2725
2728
  error({
2726
2729
  errMsg: `${apiName}:fail timeout`
2727
2730
  });
2728
- }, NETWORK_TIMEOUT);
2731
+ }, timeout || NETWORK_TIMEOUT);
2729
2732
  };
2730
2733
  send();
2731
2734
  /**
@@ -2760,13 +2763,14 @@ const createDownloadTask = ({ url, header, withCredentials = true, success, erro
2760
2763
  * 下载文件资源到本地。客户端直接发起一个 HTTPS GET 请求,返回文件的本地临时路径。使用前请注意阅读相关说明。
2761
2764
  * 注意:请在服务端响应的 header 中指定合理的 Content-Type 字段,以保证客户端正确处理文件类型。
2762
2765
  */
2763
- const downloadFile = ({ url, header, withCredentials, success, fail, complete }) => {
2766
+ const downloadFile = ({ url, header, withCredentials, timeout, success, fail, complete }) => {
2764
2767
  let task;
2765
2768
  const result = new Promise((resolve, reject) => {
2766
2769
  task = createDownloadTask({
2767
2770
  url,
2768
2771
  header,
2769
2772
  withCredentials,
2773
+ timeout,
2770
2774
  success: res => {
2771
2775
  success && success(res);
2772
2776
  complete && complete(res);
@@ -3740,8 +3744,8 @@ class ActionSheet {
3740
3744
  this.el.style.opacity = '0';
3741
3745
  this.el.style.transition = 'opacity 0.2s linear';
3742
3746
  // mask
3743
- const mask = document.createElement('div');
3744
- mask.setAttribute('style', inlineStyle(maskStyle));
3747
+ this.mask = document.createElement('div');
3748
+ this.mask.setAttribute('style', inlineStyle(maskStyle));
3745
3749
  // actionSheet
3746
3750
  this.actionSheet = document.createElement('div');
3747
3751
  this.actionSheet.setAttribute('style', inlineStyle(actionSheetStyle));
@@ -3771,14 +3775,14 @@ class ActionSheet {
3771
3775
  this.cells.forEach(item => this.menu.appendChild(item));
3772
3776
  this.actionSheet.appendChild(this.menu);
3773
3777
  this.actionSheet.appendChild(this.cancel);
3774
- this.el.appendChild(mask);
3778
+ this.el.appendChild(this.mask);
3775
3779
  this.el.appendChild(this.actionSheet);
3776
3780
  // callbacks
3777
3781
  const cb = () => {
3778
3782
  this.hide();
3779
3783
  resolve('cancel');
3780
3784
  };
3781
- mask.onclick = cb;
3785
+ this.mask.onclick = cb;
3782
3786
  this.cancel.onclick = cb;
3783
3787
  // show immediately
3784
3788
  document.body.appendChild(this.el);
@@ -3832,6 +3836,13 @@ class ActionSheet {
3832
3836
  }
3833
3837
  this.cells.splice(itemListLen);
3834
3838
  }
3839
+ // callbacks
3840
+ const cb = () => {
3841
+ this.hide();
3842
+ resolve('cancel');
3843
+ };
3844
+ this.mask.onclick = cb;
3845
+ this.cancel.onclick = cb;
3835
3846
  // show
3836
3847
  this.el.style.display = 'block';
3837
3848
  setTimeout(() => {