@tarojs/taro-h5 3.6.16-alpha.0 → 3.6.16

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.cjs.js CHANGED
@@ -1073,8 +1073,19 @@ class CanvasContext {
1073
1073
  clearRect(...args) { return this.enqueueActions(this.ctx.clearRect, ...args); }
1074
1074
  clip(...args) { return this.enqueueActions(this.ctx.clip, ...args); }
1075
1075
  closePath(...args) { return this.enqueueActions(this.ctx.closePath, ...args); }
1076
- createPattern(image, repetition) {
1077
- return this.createPattern(image, repetition);
1076
+ createPattern(imageResource, repetition) {
1077
+ // 需要转换为 Image
1078
+ if (typeof imageResource === 'string') {
1079
+ const img = new Image();
1080
+ img.src = imageResource;
1081
+ return new Promise((resolve, reject) => {
1082
+ img.onload = () => {
1083
+ resolve(this.ctx.createPattern(img, repetition));
1084
+ };
1085
+ img.onerror = reject;
1086
+ });
1087
+ }
1088
+ return this.ctx.createPattern(imageResource, repetition);
1078
1089
  }
1079
1090
  /**
1080
1091
  * 将之前在绘图上下文中的描述(路径、变形、样式)画到 canvas 中。
@@ -4994,15 +5005,17 @@ const downloadFile = ({ url, header, withCredentials, timeout, success, fail, co
4994
5005
  }
4995
5006
  });
4996
5007
  });
4997
- result.headersReceive = task.onHeadersReceived;
4998
- result.progress = task.onProgressUpdate;
4999
- return new Proxy(result, {
5000
- get(target, prop) {
5001
- const object = prop in task ? task : target;
5002
- const value = object[prop];
5003
- return typeof value === 'function' ? value.bind(object) : value;
5004
- },
5008
+ result.headersReceive = task.onHeadersReceived.bind(task);
5009
+ result.progress = task.onProgressUpdate.bind(task);
5010
+ const properties = {};
5011
+ Object.keys(task).forEach(key => {
5012
+ properties[key] = {
5013
+ get() {
5014
+ return typeof task[key] === 'function' ? task[key].bind(task) : task[key];
5015
+ }
5016
+ };
5005
5017
  });
5018
+ return Object.defineProperties(result, properties);
5006
5019
  };
5007
5020
 
5008
5021
  // mDNS
@@ -5313,15 +5326,17 @@ const uploadFile = ({ url, filePath, name, header, formData, timeout, fileName,
5313
5326
  }
5314
5327
  });
5315
5328
  });
5316
- result.headersReceive = task.onHeadersReceived;
5317
- result.progress = task.onProgressUpdate;
5318
- return new Proxy(result, {
5319
- get(target, prop) {
5320
- const object = prop in task ? task : target;
5321
- const value = object[prop];
5322
- return typeof value === 'function' ? value.bind(object) : value;
5323
- },
5329
+ result.headersReceive = task.onHeadersReceived.bind(task);
5330
+ result.progress = task.onProgressUpdate.bind(task);
5331
+ const properties = {};
5332
+ Object.keys(task).forEach(key => {
5333
+ properties[key] = {
5334
+ get() {
5335
+ return typeof task[key] === 'function' ? task[key].bind(task) : task[key];
5336
+ }
5337
+ };
5324
5338
  });
5339
+ return Object.defineProperties(result, properties);
5325
5340
  };
5326
5341
 
5327
5342
  class SocketTask {
@@ -5513,6 +5528,12 @@ const pluginLogin = /* @__PURE__ */ temporarilyNotSupport('pluginLogin');
5513
5528
  const login = /* @__PURE__ */ temporarilyNotSupport('login');
5514
5529
  const checkSession = /* @__PURE__ */ temporarilyNotSupport('checkSession');
5515
5530
 
5531
+ // 隐私信息授权
5532
+ const requirePrivacyAuthorize = /* @__PURE__ */ temporarilyNotSupport('requirePrivacyAuthorize');
5533
+ const openPrivacyContract = /* @__PURE__ */ temporarilyNotSupport('openPrivacyContract');
5534
+ const onNeedPrivacyAuthorization = /* @__PURE__ */ temporarilyNotSupport('onNeedPrivacyAuthorization');
5535
+ const getPrivacySetting = /* @__PURE__ */ temporarilyNotSupport('getPrivacySetting');
5536
+
5516
5537
  // 微信红包
5517
5538
  const showRedPackage = /* @__PURE__ */ temporarilyNotSupport('showRedPackage');
5518
5539
 
@@ -6046,11 +6067,16 @@ function getConfig() {
6046
6067
  return this.pxTransformConfig;
6047
6068
  return ((_a = taro).config || (_a.config = {}));
6048
6069
  }
6049
- const initPxTransform = function ({ designWidth = 750, deviceRatio = {
6070
+ const defaultDesignWidth = 750;
6071
+ const defaultDesignRatio = {
6050
6072
  640: 2.34 / 2,
6051
6073
  750: 1,
6052
6074
  828: 1.81 / 2
6053
- }, baseFontSize = 20, unitPrecision = 5, targetUnit = 'rem' }) {
6075
+ };
6076
+ const defaultBaseFontSize = 20;
6077
+ const defaultUnitPrecision = 5;
6078
+ const defaultTargetUnit = 'rem';
6079
+ const initPxTransform = function ({ designWidth = defaultDesignWidth, deviceRatio = defaultDesignRatio, baseFontSize = defaultBaseFontSize, unitPrecision = defaultUnitPrecision, targetUnit = defaultTargetUnit }) {
6054
6080
  const config = getConfig.call(this);
6055
6081
  config.designWidth = designWidth;
6056
6082
  config.deviceRatio = deviceRatio;
@@ -6060,16 +6086,19 @@ const initPxTransform = function ({ designWidth = 750, deviceRatio = {
6060
6086
  };
6061
6087
  const pxTransform = function (size = 0) {
6062
6088
  const config = getConfig.call(this);
6063
- const baseFontSize = config.baseFontSize || 20;
6089
+ const baseFontSize = config.baseFontSize || defaultBaseFontSize;
6090
+ const deviceRatio = config.deviceRatio || defaultDesignRatio;
6064
6091
  const designWidth = (((input = 0) => shared.isFunction(config.designWidth)
6065
6092
  ? config.designWidth(input)
6066
6093
  : config.designWidth))(size);
6067
6094
  if (!(designWidth in config.deviceRatio)) {
6068
6095
  throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`);
6069
6096
  }
6097
+ const targetUnit = config.targetUnit || defaultTargetUnit;
6098
+ const unitPrecision = config.unitPrecision || defaultUnitPrecision;
6070
6099
  const formatSize = ~~size;
6071
- let rootValue = 1 / config.deviceRatio[designWidth];
6072
- switch (config === null || config === void 0 ? void 0 : config.targetUnit) {
6100
+ let rootValue = 1 / deviceRatio[designWidth];
6101
+ switch (targetUnit) {
6073
6102
  case 'vw':
6074
6103
  rootValue = designWidth / 100;
6075
6104
  break;
@@ -6081,11 +6110,11 @@ const pxTransform = function (size = 0) {
6081
6110
  rootValue *= baseFontSize * 2;
6082
6111
  }
6083
6112
  let val = formatSize / rootValue;
6084
- if (config.unitPrecision >= 0 && config.unitPrecision <= 100) {
6113
+ if (unitPrecision >= 0 && unitPrecision <= 100) {
6085
6114
  // Number(val): 0.50000 => 0.5
6086
- val = Number(val.toFixed(config.unitPrecision));
6115
+ val = Number(val.toFixed(unitPrecision));
6087
6116
  }
6088
- return val + (config === null || config === void 0 ? void 0 : config.targetUnit);
6117
+ return val + targetUnit;
6089
6118
  };
6090
6119
  const canIUseWebp = function () {
6091
6120
  const canvas = document.createElement('canvas');
@@ -6281,6 +6310,7 @@ exports.getNFCAdapter = getNFCAdapter;
6281
6310
  exports.getNetworkType = getNetworkType;
6282
6311
  exports.getOpenUserInfo = getOpenUserInfo;
6283
6312
  exports.getPerformance = getPerformance;
6313
+ exports.getPrivacySetting = getPrivacySetting;
6284
6314
  exports.getRandomValues = getRandomValues;
6285
6315
  exports.getRealtimeLogManager = getRealtimeLogManager;
6286
6316
  exports.getRecorderManager = getRecorderManager;
@@ -6423,6 +6453,7 @@ exports.onLocalServiceResolveFail = onLocalServiceResolveFail;
6423
6453
  exports.onLocationChange = onLocationChange;
6424
6454
  exports.onLocationChangeError = onLocationChangeError;
6425
6455
  exports.onMemoryWarning = onMemoryWarning;
6456
+ exports.onNeedPrivacyAuthorization = onNeedPrivacyAuthorization;
6426
6457
  exports.onNetworkStatusChange = onNetworkStatusChange;
6427
6458
  exports.onNetworkWeakChange = onNetworkWeakChange;
6428
6459
  exports.onPageNotFound = onPageNotFound;
@@ -6454,6 +6485,7 @@ exports.openCustomerServiceChat = openCustomerServiceChat;
6454
6485
  exports.openDocument = openDocument;
6455
6486
  exports.openEmbeddedMiniProgram = openEmbeddedMiniProgram;
6456
6487
  exports.openLocation = openLocation;
6488
+ exports.openPrivacyContract = openPrivacyContract;
6457
6489
  exports.openQzonePublish = openQzonePublish;
6458
6490
  exports.openSetting = openSetting;
6459
6491
  exports.openSystemBluetoothSetting = openSystemBluetoothSetting;
@@ -6492,6 +6524,7 @@ exports.requestPolymerPayment = requestPolymerPayment;
6492
6524
  exports.requestSubscribeDeviceMessage = requestSubscribeDeviceMessage;
6493
6525
  exports.requestSubscribeMessage = requestSubscribeMessage;
6494
6526
  exports.requirePlugin = requirePlugin;
6527
+ exports.requirePrivacyAuthorize = requirePrivacyAuthorize;
6495
6528
  exports.reserveChannelsLive = reserveChannelsLive;
6496
6529
  exports.revokeBufferURL = revokeBufferURL;
6497
6530
  exports.saveFile = saveFile;