@tarojs/taro-h5 3.6.5 → 3.7.0-alpha.1

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/index.js CHANGED
@@ -78,7 +78,7 @@ export { createMediaContainer } from './media/video-processing.js';
78
78
  export { exitVoIPChat, joinVoIPChat, offVoIPChatInterrupted, offVoIPChatMembersChanged, offVoIPChatStateChanged, offVoIPVideoMembersChanged, onVoIPChatInterrupted, onVoIPChatMembersChanged, onVoIPChatSpeakersChanged, onVoIPChatStateChanged, onVoIPVideoMembersChanged, setEnable1v1Chat, subscribeVoIPVideoMembers, updateVoIPChatMuteConfig } from './media/voip.js';
79
79
  export { downloadFile } from './network/download.js';
80
80
  export { offLocalServiceDiscoveryStop, offLocalServiceFound, offLocalServiceLost, offLocalServiceResolveFail, onLocalServiceDiscoveryStop, onLocalServiceFound, onLocalServiceLost, onLocalServiceResolveFail, startLocalServiceDiscovery, stopLocalServiceDiscovery } from './network/mdns.js';
81
- export { addInterceptor, request } from './network/request/index.js';
81
+ export { addInterceptor, cleanInterceptors, request } from './network/request/index.js';
82
82
  export { createTCPSocket } from './network/tcp.js';
83
83
  export { createUDPSocket } from './network/udp.js';
84
84
  export { uploadFile } from './network/upload.js';
@@ -1,6 +1,6 @@
1
1
  export { downloadFile } from './download.js';
2
2
  export { offLocalServiceDiscoveryStop, offLocalServiceFound, offLocalServiceLost, offLocalServiceResolveFail, onLocalServiceDiscoveryStop, onLocalServiceFound, onLocalServiceLost, onLocalServiceResolveFail, startLocalServiceDiscovery, stopLocalServiceDiscovery } from './mdns.js';
3
- export { addInterceptor, request } from './request/index.js';
3
+ export { addInterceptor, cleanInterceptors, request } from './request/index.js';
4
4
  export { createTCPSocket } from './tcp.js';
5
5
  export { createUDPSocket } from './udp.js';
6
6
  export { uploadFile } from './upload.js';
@@ -1,4 +1,5 @@
1
1
  import Taro from '@tarojs/api';
2
2
  declare const request: typeof Taro.request;
3
3
  declare const addInterceptor: any;
4
- export { request, addInterceptor };
4
+ declare const cleanInterceptors: any;
5
+ export { request, addInterceptor, cleanInterceptors };
@@ -147,6 +147,7 @@ function taroInterceptor(chain) {
147
147
  const link = new Link(taroInterceptor);
148
148
  const request = link.request.bind(link);
149
149
  const addInterceptor = link.addInterceptor.bind(link);
150
+ const cleanInterceptors = link.cleanInterceptors.bind(link);
150
151
 
151
- export { addInterceptor, request };
152
+ export { addInterceptor, cleanInterceptors, request };
152
153
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/api/network/request/index.ts"],"sourcesContent":["import 'whatwg-fetch'\nimport 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'\n\nimport Taro from '@tarojs/api'\nimport { isFunction } from '@tarojs/shared'\nimport jsonpRetry from 'jsonp-retry'\n\nimport { serializeParams } from '../../../utils'\n\n// @ts-ignore\nconst { Link } = Taro\n\nfunction generateRequestUrlWithParams (url: string, params?: unknown) {\n params = typeof params === 'string' ? params : serializeParams(params)\n if (params) {\n url += (~url.indexOf('?') ? '&' : '?') + params\n }\n url = url.replace('?&', '?')\n return url\n}\n\n// FIXME 移除 any 标注\nfunction _request (options) {\n options = options || {}\n if (typeof options === 'string') {\n options = {\n url: options\n }\n }\n const { success, complete, fail } = options\n let url = options.url\n const params: any = {}\n const res: any = {}\n if (options.jsonp) {\n Object.assign(params, options)\n params.params = options.data\n params.cache = options.jsonpCache\n if (typeof options.jsonp === 'string') {\n params.name = options.jsonp\n }\n delete params.jsonp\n return jsonpRetry(url, params)\n .then(data => {\n res.statusCode = 200\n res.data = data\n isFunction(success) && success(res)\n isFunction(complete) && complete(res)\n return res\n })\n .catch(err => {\n isFunction(fail) && fail(err)\n isFunction(complete) && complete(res)\n return Promise.reject(err)\n })\n }\n params.method = options.method || 'GET'\n const methodUpper = params.method.toUpperCase()\n params.cache = options.cache || 'default'\n if (methodUpper === 'GET' || methodUpper === 'HEAD') {\n url = generateRequestUrlWithParams(url, options.data)\n } else if (Object.prototype.toString.call(options.data) === '[object Object]') {\n options.header = options.header || {}\n\n const keyOfContentType = Object.keys(options.header).find(item => item.toLowerCase() === 'content-type')\n if (!keyOfContentType) {\n options.header['Content-Type'] = 'application/json'\n }\n const contentType = options.header[keyOfContentType || 'Content-Type']\n\n if (contentType.indexOf('application/json') >= 0) {\n params.body = JSON.stringify(options.data)\n } else if (contentType.indexOf('application/x-www-form-urlencoded') >= 0) {\n params.body = serializeParams(options.data)\n } else {\n params.body = options.data\n }\n } else {\n params.body = options.data\n }\n if (options.header) {\n params.headers = options.header\n }\n if (options.mode) {\n params.mode = options.mode\n }\n let timeoutTimer: ReturnType<typeof setTimeout> | null = null\n if (options.signal) {\n params.signal = options.signal\n } else if (typeof options.timeout === 'number') {\n const controller = new window.AbortController()\n params.signal = controller.signal\n timeoutTimer = setTimeout(function () {\n controller.abort()\n }, options.timeout)\n }\n params.credentials = options.credentials\n return fetch(url, params)\n .then(response => {\n if (timeoutTimer) {\n clearTimeout(timeoutTimer)\n timeoutTimer = null\n }\n if (!response) {\n const errorResponse = { ok: false }\n throw errorResponse\n }\n res.statusCode = response.status\n res.header = {}\n for (const key of response.headers.keys()) {\n res.header[key] = response.headers.get(key)\n }\n if (options.responseType === 'arraybuffer') {\n return response.arrayBuffer()\n }\n if (res.statusCode !== 204) {\n if (options.dataType === 'json' || typeof options.dataType === 'undefined') {\n return response.json().catch(() => {\n return null\n })\n }\n }\n if (options.responseType === 'text' || options.dataType === 'text') {\n return response.text()\n }\n return Promise.resolve(null)\n })\n .then(data => {\n res.data = data\n isFunction(success) && success(res)\n isFunction(complete) && complete(res)\n return res\n })\n .catch(err => {\n if (timeoutTimer) {\n clearTimeout(timeoutTimer)\n timeoutTimer = null\n }\n isFunction(fail) && fail(err)\n isFunction(complete) && complete(res)\n err.statusCode = res.statusCode\n err.errMsg = err.message\n return Promise.reject(err)\n })\n}\n\nfunction taroInterceptor (chain) {\n return _request(chain.requestParams)\n}\n\nconst link = new Link(taroInterceptor)\n\nexport const request: typeof Taro.request = link.request.bind(link)\nexport const addInterceptor = link.addInterceptor.bind(link)\n"],"names":[],"mappings":";;;;;;;AASA;AACA,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;AAErB,SAAS,4BAA4B,CAAE,GAAW,EAAE,MAAgB,EAAA;AAClE,IAAA,MAAM,GAAG,OAAO,MAAM,KAAK,QAAQ,GAAG,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAA;AACtE,IAAA,IAAI,MAAM,EAAE;QACV,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,MAAM,CAAA;AAChD,KAAA;IACD,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;AAC5B,IAAA,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;AACA,SAAS,QAAQ,CAAE,OAAO,EAAA;AACxB,IAAA,OAAO,GAAG,OAAO,IAAI,EAAE,CAAA;AACvB,IAAA,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;AAC/B,QAAA,OAAO,GAAG;AACR,YAAA,GAAG,EAAE,OAAO;SACb,CAAA;AACF,KAAA;IACD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,OAAO,CAAA;AAC3C,IAAA,IAAI,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;IACrB,MAAM,MAAM,GAAQ,EAAE,CAAA;IACtB,MAAM,GAAG,GAAQ,EAAE,CAAA;IACnB,IAAI,OAAO,CAAC,KAAK,EAAE;AACjB,QAAA,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAC9B,QAAA,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAA;AAC5B,QAAA,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,UAAU,CAAA;AACjC,QAAA,IAAI,OAAO,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AK,EAAA;AAC7B,IAAA,OAAO,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;AACtC,CAAC;AAED,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,eAAe,CAAC,CAAA;AAE/B,MAAM,OAAO,GAAwB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAC;AAC5D,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/api/network/request/index.ts"],"sourcesContent":["import 'whatwg-fetch'\nimport 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only'\n\nimport Taro from '@tarojs/api'\nimport { isFunction } from '@tarojs/shared'\nimport jsonpRetry from 'jsonp-retry'\n\nimport { serializeParams } from '../../../utils'\n\n// @ts-ignore\nconst { Link } = Taro\n\nfunction generateRequestUrlWithParams (url: string, params?: unknown) {\n params = typeof params === 'string' ? params : serializeParams(params)\n if (params) {\n url += (~url.indexOf('?') ? '&' : '?') + params\n }\n url = url.replace('?&', '?')\n return url\n}\n\n// FIXME 移除 any 标注\nfunction _request (options) {\n options = options || {}\n if (typeof options === 'string') {\n options = {\n url: options\n }\n }\n const { success, complete, fail } = options\n let url = options.url\n const params: any = {}\n const res: any = {}\n if (options.jsonp) {\n Object.assign(params, options)\n params.params = options.data\n params.cache = options.jsonpCache\n if (typeof options.jsonp === 'string') {\n params.name = options.jsonp\n }\n delete params.jsonp\n return jsonpRetry(url, params)\n .then(data => {\n res.statusCode = 200\n res.data = data\n isFunction(success) && success(res)\n isFunction(complete) && complete(res)\n return res\n })\n .catch(err => {\n isFunction(fail) && fail(err)\n isFunction(complete) && complete(res)\n return Promise.reject(err)\n })\n }\n params.method = options.method || 'GET'\n const methodUpper = params.method.toUpperCase()\n params.cache = options.cache || 'default'\n if (methodUpper === 'GET' || methodUpper === 'HEAD') {\n url = generateRequestUrlWithParams(url, options.data)\n } else if (Object.prototype.toString.call(options.data) === '[object Object]') {\n options.header = options.header || {}\n\n const keyOfContentType = Object.keys(options.header).find(item => item.toLowerCase() === 'content-type')\n if (!keyOfContentType) {\n options.header['Content-Type'] = 'application/json'\n }\n const contentType = options.header[keyOfContentType || 'Content-Type']\n\n if (contentType.indexOf('application/json') >= 0) {\n params.body = JSON.stringify(options.data)\n } else if (contentType.indexOf('application/x-www-form-urlencoded') >= 0) {\n params.body = serializeParams(options.data)\n } else {\n params.body = options.data\n }\n } else {\n params.body = options.data\n }\n if (options.header) {\n params.headers = options.header\n }\n if (options.mode) {\n params.mode = options.mode\n }\n let timeoutTimer: ReturnType<typeof setTimeout> | null = null\n if (options.signal) {\n params.signal = options.signal\n } else if (typeof options.timeout === 'number') {\n const controller = new window.AbortController()\n params.signal = controller.signal\n timeoutTimer = setTimeout(function () {\n controller.abort()\n }, options.timeout)\n }\n params.credentials = options.credentials\n return fetch(url, params)\n .then(response => {\n if (timeoutTimer) {\n clearTimeout(timeoutTimer)\n timeoutTimer = null\n }\n if (!response) {\n const errorResponse = { ok: false }\n throw errorResponse\n }\n res.statusCode = response.status\n res.header = {}\n for (const key of response.headers.keys()) {\n res.header[key] = response.headers.get(key)\n }\n if (options.responseType === 'arraybuffer') {\n return response.arrayBuffer()\n }\n if (res.statusCode !== 204) {\n if (options.dataType === 'json' || typeof options.dataType === 'undefined') {\n return response.json().catch(() => {\n return null\n })\n }\n }\n if (options.responseType === 'text' || options.dataType === 'text') {\n return response.text()\n }\n return Promise.resolve(null)\n })\n .then(data => {\n res.data = data\n isFunction(success) && success(res)\n isFunction(complete) && complete(res)\n return res\n })\n .catch(err => {\n if (timeoutTimer) {\n clearTimeout(timeoutTimer)\n timeoutTimer = null\n }\n isFunction(fail) && fail(err)\n isFunction(complete) && complete(res)\n err.statusCode = res.statusCode\n err.errMsg = err.message\n return Promise.reject(err)\n })\n}\n\nfunction taroInterceptor (chain) {\n return _request(chain.requestParams)\n}\n\nconst link = new Link(taroInterceptor)\n\nexport const request: typeof Taro.request = link.request.bind(link)\nexport const addInterceptor = link.addInterceptor.bind(link)\nexport const cleanInterceptors = link.cleanInterceptors.bind(link)\n"],"names":[],"mappings":";;;;;;;AASA;AACA,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAA;AAErB,SAAS,4BAA4B,CAAE,GAAW,EAAE,MAAgB,EAAA;AAClE,IAAA,MAAM,GAAG,OAAO,MAAM,KAAK,QAAQ,GAAG,MAAM,GAAG,eAAe,CAAC,MAAM,CAAC,CAAA;AACtE,IAAA,IAAI,MAAM,EAAE;QACV,GAAG,IAAI,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,MAAM,CAAA;AAChD,KAAA;IACD,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;AAC5B,IAAA,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;AACA,SAAS,QAAQ,CAAE,OAAO,EAAA;AACxB,IAAA,OAAO,GAAG,OAAO,IAAI,EAAE,CAAA;AACvB,IAAA,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;AAC/B,QAAA,OAAO,GAAG;AACR,YAAA,GAAG,EAAE,OAAO;SACb,CAAA;AACF,KAAA;IACD,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,OAAO,CAAA;AAC3C,IAAA,IAAI,GAAG,GAAG,OAAO,CAAC,GAAG,CAAA;IACrB,MAAM,MAAM,GAAQ,EAAE,CAAA;IACtB,MAAM,GAAG,GAAQ,EAAE,CAAA;IACnB,IAAI,OAAO,CAAC,KAAK,EAAE;AACjB,QAAA,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;AAC9B,QAAA,MAAM,CAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAA;AAC5B,QAAA,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,UAAU,CAAA;AACjC,QAAA,IAAI,OAAO,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AK,EAAA;AAC7B,IAAA,OAAO,QAAQ,CAAC,KAAK,CAAC,aAAa,CAAC,CAAA;AACtC,CAAC;AAED,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,eAAe,CAAC,CAAA;AAE/B,MAAM,OAAO,GAAwB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAC;AAC5D,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAC;AACrD,MAAM,iBAAiB,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI;;;;"}
package/dist/api/taro.js CHANGED
@@ -59,17 +59,22 @@ const pxTransform = function (size = 0) {
59
59
  throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`);
60
60
  }
61
61
  const formatSize = ~~size;
62
- let rootValue = 1 / config.deviceRatio[designWidth] * 2;
62
+ let rootValue = 1 / config.deviceRatio[designWidth];
63
63
  switch (config === null || config === void 0 ? void 0 : config.targetUnit) {
64
64
  case 'vw':
65
- rootValue *= 0.5 * designWidth / 100;
65
+ rootValue = designWidth / 100;
66
+ break;
67
+ case 'px':
68
+ rootValue *= 2;
66
69
  break;
67
70
  default:
68
- rootValue *= baseFontSize;
71
+ // rem
72
+ rootValue *= baseFontSize * 2;
69
73
  }
70
74
  let val = formatSize / rootValue;
71
75
  if (config.unitPrecision >= 0 && config.unitPrecision <= 100) {
72
- val = val.toFixed(config.unitPrecision);
76
+ // Number(val): 0.50000 => 0.5
77
+ val = Number(val.toFixed(config.unitPrecision));
73
78
  }
74
79
  return val + (config === null || config === void 0 ? void 0 : config.targetUnit);
75
80
  };
@@ -1 +1 @@
1
- {"version":3,"file":"taro.js","sources":["../../src/api/taro.ts"],"sourcesContent":["import Taro from '@tarojs/api'\nimport { history } from '@tarojs/router'\nimport { isFunction } from '@tarojs/shared'\n\nimport { getApp, getCurrentInstance, getCurrentPages, navigateBack, navigateTo, nextTick, redirectTo, reLaunch, switchTab } from '../api'\nimport { permanentlyNotSupport } from '../utils'\n\nconst {\n Behavior,\n getEnv,\n ENV_TYPE,\n Link,\n interceptors,\n Current,\n options,\n eventCenter,\n Events,\n preload\n} = Taro as any\n\nconst taro: typeof Taro = {\n // @ts-ignore\n Behavior,\n getEnv,\n ENV_TYPE,\n Link,\n interceptors,\n Current,\n getCurrentInstance,\n options,\n nextTick,\n eventCenter,\n Events,\n preload,\n history,\n navigateBack,\n navigateTo,\n reLaunch,\n redirectTo,\n getCurrentPages,\n switchTab\n}\n\nconst requirePlugin = permanentlyNotSupport('requirePlugin')\n\nfunction getConfig (): Record<string, any> {\n if (this?.pxTransformConfig) return this.pxTransformConfig\n return ((taro as any).config ||= {})\n}\n\nconst initPxTransform = function ({\n designWidth = 750,\n deviceRatio = {\n 640: 2.34 / 2,\n 750: 1,\n 828: 1.81 / 2\n } as TaroGeneral.TDeviceRatio,\n baseFontSize = 20,\n unitPrecision = 5,\n targetUnit = 'rem'\n}) {\n const config = getConfig.call(this)\n config.designWidth = designWidth\n config.deviceRatio = deviceRatio\n config.baseFontSize = baseFontSize\n config.targetUnit = targetUnit\n config.unitPrecision = unitPrecision\n}\n\nconst pxTransform = function (size = 0) {\n const config = getConfig.call(this)\n const baseFontSize = config.baseFontSize || 20\n const designWidth = (((input = 0) => isFunction(config.designWidth)\n ? config.designWidth(input)\n : config.designWidth))(size)\n if (!(designWidth in config.deviceRatio)) {\n throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`)\n }\n const formatSize = ~~size\n let rootValue = 1 / config.deviceRatio[designWidth] * 2\n switch (config?.targetUnit) {\n case 'vw':\n rootValue *= 0.5 * designWidth / 100\n break\n default:\n rootValue *= baseFontSize\n }\n let val: number | string = formatSize / rootValue\n if (config.unitPrecision >= 0 && config.unitPrecision <= 100) {\n val = val.toFixed(config.unitPrecision)\n }\n return val + config?.targetUnit\n}\n\nconst canIUseWebp = function () {\n const canvas = document.createElement('canvas')\n return canvas.toDataURL('image/webp').indexOf('data:image/webp') === 0\n}\n\ntaro.requirePlugin = requirePlugin\ntaro.getApp = getApp\ntaro.pxTransform = pxTransform\ntaro.initPxTransform = initPxTransform\ntaro.canIUseWebp = canIUseWebp\n\nexport default taro\n\nexport {\n Behavior,\n canIUseWebp,\n Current,\n ENV_TYPE,\n eventCenter,\n Events,\n getEnv,\n history,\n initPxTransform,\n interceptors,\n Link,\n options,\n preload,\n pxTransform,\n requirePlugin\n}\n"],"names":[],"mappings":";;;;;;;;;AAOM,MAAA,EACJ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,IAAI,EACJ,YAAY,EACZ,OAAO,EACP,OAAO,EACP,WAAW,EACX,MAAM,EACN,OAAO,EACR,GAAG,KAAW;AAEf,MAAM,IAAI,GAAgB;;IAExB,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,IAAI;IACJ,YAAY;IACZ,OAAO;IACP,kBAAkB;IAClB,OAAO;IACP,QAAQ;IACR,WAAW;IACX,MAAM;IACN,OAAO;IACP,OAAO;IACP,YAAY;IACZ,UAAU;IACV,QAAQ;IACR,UAAU;IACV,eAAe;IACf,SAAS;EACV;AAED,MAAM,aAAa,GAAG,qBAAqB,CAAC,eAAe,EAAC;AAE5D,SAAS,SAAS,GAAA;;AAChB,IAAA,IAAI,IAAI,KAAJ,IAAA,IAAA,IAAI,KAAJ,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,IAAI,CAAE,iBAAiB;QAAE,OAAO,IAAI,CAAC,iBAAiB,CAAA;IAC1D,QAAO,CAAA,EAAA,GAAE,IAAY,EAAC,MAAM,QAAN,MAAM,GAAK,EAAE,CAAA,EAAC;AACtC,CAAC;AAEK,MAAA,eAAe,GAAG,UAAU,EAChC,WAAW,GAAG,GAAG,EACjB,WAAW,GAAG;IACZ,GAAG,EAAE,IAAI,GAAG,CAAC;AACb,IAAA,GAAG,EAAE,CAAC;IACN,GAAG,EAAE,IAAI,GAAG,CAAC;CACc,EAC7B,YAAY,GAAG,EAAE,EACjB,aAAa,GAAG,CAAC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AAS,IAAI,YAAY,CAAA;AAC5B,KAAA;AACD,IAAA,IAAI,GAAG,GAAoB,UAAU,GAAG,SAAS,CAAA;IACjD,IAAI,MAAM,CAAC,aAAa,IAAI,CAAC,IAAI,MAAM,CAAC,aAAa,IAAI,GAAG,EAAE;QAC5D,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;AACxC,KAAA;IACD,OAAO,GAAG,IAAG,MAAM,KAAN,IAAA,IAAA,MAAM,uBAAN,MAAM,CAAE,UAAU,CAAA,CAAA;AACjC,EAAC;AAED,MAAM,WAAW,GAAG,YAAA;IAClB,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;AAC/C,IAAA,OAAO,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAA;AACxE,EAAC;AAED,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;AAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;AACpB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;AAC9B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;AACtC,IAAI,CAAC,WAAW,GAAG,WAAW;;;;"}
1
+ {"version":3,"file":"taro.js","sources":["../../src/api/taro.ts"],"sourcesContent":["import Taro from '@tarojs/api'\nimport { history } from '@tarojs/router'\nimport { isFunction } from '@tarojs/shared'\n\nimport { getApp, getCurrentInstance, getCurrentPages, navigateBack, navigateTo, nextTick, redirectTo, reLaunch, switchTab } from '../api'\nimport { permanentlyNotSupport } from '../utils'\n\nconst {\n Behavior,\n getEnv,\n ENV_TYPE,\n Link,\n interceptors,\n Current,\n options,\n eventCenter,\n Events,\n preload\n} = Taro as any\n\nconst taro: typeof Taro = {\n // @ts-ignore\n Behavior,\n getEnv,\n ENV_TYPE,\n Link,\n interceptors,\n Current,\n getCurrentInstance,\n options,\n nextTick,\n eventCenter,\n Events,\n preload,\n history,\n navigateBack,\n navigateTo,\n reLaunch,\n redirectTo,\n getCurrentPages,\n switchTab\n}\n\nconst requirePlugin = permanentlyNotSupport('requirePlugin')\n\nfunction getConfig (): Record<string, any> {\n if (this?.pxTransformConfig) return this.pxTransformConfig\n return ((taro as any).config ||= {})\n}\n\nconst initPxTransform = function ({\n designWidth = 750,\n deviceRatio = {\n 640: 2.34 / 2,\n 750: 1,\n 828: 1.81 / 2\n } as TaroGeneral.TDeviceRatio,\n baseFontSize = 20,\n unitPrecision = 5,\n targetUnit = 'rem'\n}) {\n const config = getConfig.call(this)\n config.designWidth = designWidth\n config.deviceRatio = deviceRatio\n config.baseFontSize = baseFontSize\n config.targetUnit = targetUnit\n config.unitPrecision = unitPrecision\n}\n\nconst pxTransform = function (size = 0) {\n const config = getConfig.call(this)\n const baseFontSize = config.baseFontSize || 20\n const designWidth = (((input = 0) => isFunction(config.designWidth)\n ? config.designWidth(input)\n : config.designWidth))(size)\n if (!(designWidth in config.deviceRatio)) {\n throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`)\n }\n const formatSize = ~~size\n let rootValue = 1 / config.deviceRatio[designWidth]\n switch (config?.targetUnit) {\n case 'vw':\n rootValue = designWidth / 100\n break\n case 'px':\n rootValue *= 2\n break\n default:\n // rem\n rootValue *= baseFontSize * 2\n }\n let val: number | string = formatSize / rootValue\n if (config.unitPrecision >= 0 && config.unitPrecision <= 100) {\n // Number(val): 0.50000 => 0.5\n val = Number(val.toFixed(config.unitPrecision))\n }\n return val + config?.targetUnit\n}\n\nconst canIUseWebp = function () {\n const canvas = document.createElement('canvas')\n return canvas.toDataURL('image/webp').indexOf('data:image/webp') === 0\n}\n\ntaro.requirePlugin = requirePlugin\ntaro.getApp = getApp\ntaro.pxTransform = pxTransform\ntaro.initPxTransform = initPxTransform\ntaro.canIUseWebp = canIUseWebp\n\nexport default taro\n\nexport {\n Behavior,\n canIUseWebp,\n Current,\n ENV_TYPE,\n eventCenter,\n Events,\n get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AAM,CAAC,aAAa,IAAI,GAAG,EAAE;;AAE5D,QAAA,GAAG,GAAG,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAA;AAChD,KAAA;IACD,OAAO,GAAG,IAAG,MAAM,KAAN,IAAA,IAAA,MAAM,uBAAN,MAAM,CAAE,UAAU,CAAA,CAAA;AACjC,EAAC;AAED,MAAM,WAAW,GAAG,YAAA;IAClB,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;AAC/C,IAAA,OAAO,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAA;AACxE,EAAC;AAED,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;AAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;AACpB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;AAC9B,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;AACtC,IAAI,CAAC,WAAW,GAAG,WAAW;;;;"}
@@ -550,6 +550,7 @@ declare const offLocalServiceFound: (option?: {}, ...args: any[]) => Promise<Par
550
550
  declare const offLocalServiceDiscoveryStop: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
551
551
  declare const request: typeof Taro.request;
552
552
  declare const addInterceptor: any;
553
+ declare const cleanInterceptors: any;
553
554
  // TCP 通信
554
555
  declare const createTCPSocket: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
555
556
  // UDP 通信
@@ -770,5 +771,5 @@ declare const createWorker: (option?: {}, ...args: any[]) => Promise<Partial<Tar
770
771
  declare const createSelectorQuery: typeof Taro.createSelectorQuery;
771
772
  declare const createIntersectionObserver: typeof Taro.createIntersectionObserver;
772
773
  declare const createMediaQueryObserver: typeof Taro.createMediaQueryObserver;
773
- export { taro as default, taro, createRewardedVideoAd, createInterstitialAd, stopFaceDetect, initFaceDetect, faceDetect, isVKSupport, createVKSession, getOpenUserInfo, env, canIUse, arrayBufferToBase64, base64ToArrayBuffer, getUserCryptoManager, setEnableDebug, getRealtimeLogManager, getLogManager, reportPerformance, getPerformance, openSystemBluetoothSetting, openAppAuthorizeSetting, getWindowInfo, getSystemSetting, getDeviceInfo, getAppBaseInfo, getAppAuthorizeSetting, getSystemInfoSync, getSystemInfoAsync, getSystemInfo, updateWeChatApp, getUpdateManager, onUnhandledRejection, onThemeChange, onPageNotFound, onError, onAudioInterruptionEnd, onAudioInterruptionBegin, onAppShow, onAppHide, offUnhandledRejection, offThemeChange, offPageNotFound, offError, offAudioInterruptionEnd, offAudioInterruptionBegin, offAppShow, offAppHide, getLaunchOptionsSync, getEnterOptionsSync, createOffscreenCanvas, createCanvasContext, canvasToTempFilePath, canvasPutImageData, canvasGetImageData, cloud, reportMonitor, reportAnalytics, reportEvent, getExptInfoSync, stopAccelerometer, startAccelerometer, onAccelerometerChange, offAccelerometerChange, checkIsOpenAccessibility, getBatteryInfoSync, getBatteryInfo, stopBluetoothDevicesDiscovery, startBluetoothDevicesDiscovery, openBluetoothAdapter, onBluetoothDeviceFound, onBluetoothAdapterStateChange, offBluetoothDeviceFound, offBluetoothAdapterStateChange, makeBluetoothPair, isBluetoothDevicePaired, getConnectedBluetoothDevices, getBluetoothDevices, getBluetoothAdapterState, closeBluetoothAdapter, writeBLECharacteristicValue, setBLEMTU, readBLECharacteristicValue, onBLEMTUChange, onBLEConnectionStateChange, onBLECharacteristicValueChange, offBLEMTUChange, offBLEConnectionStateChange, offBLECharacteristicValueChange, notifyBLECharacteristicValueChange, getBLEMTU, getBLEDeviceServices, getBLEDeviceRSSI, getBLEDeviceCharacteristics, createBLEConnection, closeBLEConnection, onBLEPeripheralConnectionStateChanged, offBLEPeripheralConnectionStateChanged, createBLEPeripheralServer, addPhoneRepeatCalendar, addPhoneCalendar, setClipboardData, getClipboardData, stopCompass, startCompass, onCompassChange, offCompassChange, chooseContact, addPhoneContact, getRandomValues, stopGyroscope, startGyroscope, onGyroscopeChange, offGyroscopeChange, stopBeaconDiscovery, startBeaconDiscovery, onBeaconUpdate, onBeaconServiceChange, offBeaconUpdate, offBeaconServiceChange, getBeacons, onKeyboardHeightChange, offKeyboardHeightChange, hideKeyboard, getSelectedTextRange, onMemoryWarning, offMemoryWarning, stopDeviceMotionListening, startDeviceMotionListening, onDeviceMotionChange, offDeviceMotionChange, getNetworkType, onNetworkWeakChange, onNetworkStatusChange, offNetworkWeakChange, offNetworkStatusChange, getLocalIPAddress, stopHCE, startHCE, sendHCEMessage, onHCEMessage, offHCEMessage, getNFCAdapter, getHCEState, makePhoneCall, scanCode, setVisualEffectOnCapture, setScreenBrightness, setKeepScreenOn, onUserCaptureScreen, offUserCaptureScreen, getScreenBrightness, vibrateShort, vibrateLong, stopWifi, startWifi, setWifiList, onWifiConnectedWithPartialInfo, onWifiConnected, onGetWifiList, offWifiConnected, offGetWifiList, getWifiList, getConnectedWifi, connectWifi, getExtConfigSync, getExtConfig, saveFileToDisk, saveFile, removeSavedFile, openDocument, getSavedFileList, getSavedFileInfo, getFileSystemManager, getFileInfo, getApp, getCurrentInstance, stopLocationUpdate, startLocationUpdateBackground, startLocationUpdate, openLocation, onLocationChangeError, onLocationChange, offLocationChangeError, offLocationChange, getLocation, choosePoi, getFuzzyLocation, chooseLocation, stopVoice, setInnerAudioOption, playVoice, pauseVoice, getAvailableAudioSources, createWebAudioContext, createMediaAudioPlayer, createInnerAudioContext, createAudioContext, stopBackgroundAudio, seekBackgroundAudio, playBackgroundAudio, pauseBackgroundAudio, onBackgroundAudioStop, onBackgroundAudioPlay, onBackgroundAudioPause, getBackgroundAudioPlayerState, getBackgroundAudioManager, createCameraContext, saveImageToPhotosAlbum, previewMedia, getImageInfo, previewImage, compressImage, chooseMessageFile, chooseImage, createLivePusherContext, createLivePlayerContext, createMapContext, createMediaRecorder, stopRecord, startRecord, getRecorderManager, saveVideoToPhotosAlbum, openVideoEditor, getVideoInfo, createVideoContext, compressVideo, chooseVideo, chooseMedia, createVideoDecoder, createMediaContainer, updateVoIPChatMuteConfig, subscribeVoIPVideoMembers, setEnable1v1Chat, onVoIPVideoMembersChanged, onVoIPChatStateChanged, onVoIPChatSpeakersChanged, onVoIPChatMembersChanged, onVoIPChatInterrupted, offVoIPVideoMembersChanged, offVoIPChatStateChanged, offVoIPChatMembersChanged, offVoIPChatInterrupted, joinVoIPChat, exitVoIPChat, openEmbeddedMiniProgram, navigateToMiniProgram, navigateBackMiniProgram, exitMiniProgram, openBusinessView, downloadFile, stopLocalServiceDiscovery, startLocalServiceDiscovery, onLocalServiceResolveFail, onLocalServiceLost, onLocalServiceFound, onLocalServiceDiscoveryStop, offLocalServiceResolveFail, offLocalServiceLost, offLocalServiceFound, offLocalServiceDiscoveryStop, request, addInterceptor, createTCPSocket, createUDPSocket, uploadFile, sendSocketMessage, onSocketOpen, onSocketMessage, onSocketError, onSocketClose, connectSocket, closeSocket, getAccountInfoSync, chooseAddress, authorizeForMiniProgram, authorize, openCard, addCard, reserveChannelsLive, openChannelsLive, openChannelsEvent, openChannelsActivity, getChannelsLiveNoticeInfo, getChannelsLiveInfo, openCustomerServiceChat, checkIsSupportFacialRecognition, startFacialRecognitionVerify, startFacialRecognitionVerifyAndUploadVideo, faceVerifyForPay, addVideoToFavorites, addFileToFavorites, checkIsAddedToMyMiniProgram, getGroupEnterInfo, chooseInvoiceTitle, chooseInvoice, chooseLicensePlate, pluginLogin, login, checkSession, showRedPackage, openSetting, getSetting, startSoterAuthentication, checkIsSupportSoterAuthentication, checkIsSoterEnrolledInDevice, requestSubscribeMessage, getUserProfile, getUserInfo, shareToWeRun, getWeRunData, requestPayment, requestOrderPayment, updateShareMenu, showShareMenu, showShareImageMenu, shareVideoMessage, shareFileMessage, onCopyUrl, offCopyUrl, hideShareMenu, getShareInfo, authPrivateMessage, setStorageSync, setStorage, revokeBufferURL, removeStorageSync, removeStorage, getStorageSync, getStorageInfoSync, getStorageInfo, getStorage, createBufferURL, clearStorageSync, clearStorage, setBackgroundFetchToken, onBackgroundFetchData, getBackgroundFetchToken, getBackgroundFetchData, setPageInfo, ocrIdCard, ocrBankCard, ocrDrivingLicense, ocrVehicleLicense, textReview, textToAudio, imageAudit, advancedGeneralIdentify, objectDetectIdentify, carClassify, dishClassify, logoClassify, animalClassify, plantClassify, getSwanId, requestPolymerPayment, navigateToSmartGameProgram, navigateToSmartProgram, navigateBackSmartProgram, preloadSubPackage, createAnimation, setBackgroundTextStyle, setBackgroundColor, nextTick, loadFontFace, disableAlertBeforeUnload, enableAlertBeforeUnload, hideLoading, hideToast, showActionSheet, showLoading, showModal, showToast, getMenuButtonBoundingClientRect, showNavigationBarLoading, setNavigationBarTitle, setNavigationBarColor, hideNavigationBarLoading, hideHomeButton, startPullDownRefresh, stopPullDownRefresh, pageScrollTo, setTopBarText, initTabBarApis, showTabBarRedDot, showTabBar, setTabBarStyle, setTabBarItem, setTabBarBadge, removeTabBarBadge, hideTabBarRedDot, hideTabBar, setWindowSize, onWindowResize, offWindowResize, createWorker, createSelectorQuery, createIntersectionObserver, createMediaQueryObserver, Behavior, canIUseWebp, Current, ENV_TYPE, eventCenter, Events, getEnv, history, initPxTransform, interceptors, Link, options, preload, pxTransform, requirePlugin };
774
+ export { taro as default, taro, createRewardedVideoAd, createInterstitialAd, stopFaceDetect, initFaceDetect, faceDetect, isVKSupport, createVKSession, getOpenUserInfo, env, canIUse, arrayBufferToBase64, base64ToArrayBuffer, getUserCryptoManager, setEnableDebug, getRealtimeLogManager, getLogManager, reportPerformance, getPerformance, openSystemBluetoothSetting, openAppAuthorizeSetting, getWindowInfo, getSystemSetting, getDeviceInfo, getAppBaseInfo, getAppAuthorizeSetting, getSystemInfoSync, getSystemInfoAsync, getSystemInfo, updateWeChatApp, getUpdateManager, onUnhandledRejection, onThemeChange, onPageNotFound, onError, onAudioInterruptionEnd, onAudioInterruptionBegin, onAppShow, onAppHide, offUnhandledRejection, offThemeChange, offPageNotFound, offError, offAudioInterruptionEnd, offAudioInterruptionBegin, offAppShow, offAppHide, getLaunchOptionsSync, getEnterOptionsSync, createOffscreenCanvas, createCanvasContext, canvasToTempFilePath, canvasPutImageData, canvasGetImageData, cloud, reportMonitor, reportAnalytics, reportEvent, getExptInfoSync, stopAccelerometer, startAccelerometer, onAccelerometerChange, offAccelerometerChange, checkIsOpenAccessibility, getBatteryInfoSync, getBatteryInfo, stopBluetoothDevicesDiscovery, startBluetoothDevicesDiscovery, openBluetoothAdapter, onBluetoothDeviceFound, onBluetoothAdapterStateChange, offBluetoothDeviceFound, offBluetoothAdapterStateChange, makeBluetoothPair, isBluetoothDevicePaired, getConnectedBluetoothDevices, getBluetoothDevices, getBluetoothAdapterState, closeBluetoothAdapter, writeBLECharacteristicValue, setBLEMTU, readBLECharacteristicValue, onBLEMTUChange, onBLEConnectionStateChange, onBLECharacteristicValueChange, offBLEMTUChange, offBLEConnectionStateChange, offBLECharacteristicValueChange, notifyBLECharacteristicValueChange, getBLEMTU, getBLEDeviceServices, getBLEDeviceRSSI, getBLEDeviceCharacteristics, createBLEConnection, closeBLEConnection, onBLEPeripheralConnectionStateChanged, offBLEPeripheralConnectionStateChanged, createBLEPeripheralServer, addPhoneRepeatCalendar, addPhoneCalendar, setClipboardData, getClipboardData, stopCompass, startCompass, onCompassChange, offCompassChange, chooseContact, addPhoneContact, getRandomValues, stopGyroscope, startGyroscope, onGyroscopeChange, offGyroscopeChange, stopBeaconDiscovery, startBeaconDiscovery, onBeaconUpdate, onBeaconServiceChange, offBeaconUpdate, offBeaconServiceChange, getBeacons, onKeyboardHeightChange, offKeyboardHeightChange, hideKeyboard, getSelectedTextRange, onMemoryWarning, offMemoryWarning, stopDeviceMotionListening, startDeviceMotionListening, onDeviceMotionChange, offDeviceMotionChange, getNetworkType, onNetworkWeakChange, onNetworkStatusChange, offNetworkWeakChange, offNetworkStatusChange, getLocalIPAddress, stopHCE, startHCE, sendHCEMessage, onHCEMessage, offHCEMessage, getNFCAdapter, getHCEState, makePhoneCall, scanCode, setVisualEffectOnCapture, setScreenBrightness, setKeepScreenOn, onUserCaptureScreen, offUserCaptureScreen, getScreenBrightness, vibrateShort, vibrateLong, stopWifi, startWifi, setWifiList, onWifiConnectedWithPartialInfo, onWifiConnected, onGetWifiList, offWifiConnected, offGetWifiList, getWifiList, getConnectedWifi, connectWifi, getExtConfigSync, getExtConfig, saveFileToDisk, saveFile, removeSavedFile, openDocument, getSavedFileList, getSavedFileInfo, getFileSystemManager, getFileInfo, getApp, getCurrentInstance, stopLocationUpdate, startLocationUpdateBackground, startLocationUpdate, openLocation, onLocationChangeError, onLocationChange, offLocationChangeError, offLocationChange, getLocation, choosePoi, getFuzzyLocation, chooseLocation, stopVoice, setInnerAudioOption, playVoice, pauseVoice, getAvailableAudioSources, createWebAudioContext, createMediaAudioPlayer, createInnerAudioContext, createAudioContext, stopBackgroundAudio, seekBackgroundAudio, playBackgroundAudio, pauseBackgroundAudio, onBackgroundAudioStop, onBackgroundAudioPlay, onBackgroundAudioPause, getBackgroundAudioPlayerState, getBackgroundAudioManager, createCameraContext, saveImageToPhotosAlbum, previewMedia, getImageInfo, previewImage, compressImage, chooseMessageFile, chooseImage, createLivePusherContext, createLivePlayerContext, createMapContext, createMediaRecorder, stopRecord, startRecord, getRecorderManager, saveVideoToPhotosAlbum, openVideoEditor, getVideoInfo, createVideoContext, compressVideo, chooseVideo, chooseMedia, createVideoDecoder, createMediaContainer, updateVoIPChatMuteConfig, subscribeVoIPVideoMembers, setEnable1v1Chat, onVoIPVideoMembersChanged, onVoIPChatStateChanged, onVoIPChatSpeakersChanged, onVoIPChatMembersChanged, onVoIPChatInterrupted, offVoIPVideoMembersChanged, offVoIPChatStateChanged, offVoIPChatMembersChanged, offVoIPChatInterrupted, joinVoIPChat, exitVoIPChat, openEmbeddedMiniProgram, navigateToMiniProgram, navigateBackMiniProgram, exitMiniProgram, openBusinessView, downloadFile, stopLocalServiceDiscovery, startLocalServiceDiscovery, onLocalServiceResolveFail, onLocalServiceLost, onLocalServiceFound, onLocalServiceDiscoveryStop, offLocalServiceResolveFail, offLocalServiceLost, offLocalServiceFound, offLocalServiceDiscoveryStop, request, addInterceptor, cleanInterceptors, createTCPSocket, createUDPSocket, uploadFile, sendSocketMessage, onSocketOpen, onSocketMessage, onSocketError, onSocketClose, connectSocket, closeSocket, getAccountInfoSync, chooseAddress, authorizeForMiniProgram, authorize, openCard, addCard, reserveChannelsLive, openChannelsLive, openChannelsEvent, openChannelsActivity, getChannelsLiveNoticeInfo, getChannelsLiveInfo, openCustomerServiceChat, checkIsSupportFacialRecognition, startFacialRecognitionVerify, startFacialRecognitionVerifyAndUploadVideo, faceVerifyForPay, addVideoToFavorites, addFileToFavorites, checkIsAddedToMyMiniProgram, getGroupEnterInfo, chooseInvoiceTitle, chooseInvoice, chooseLicensePlate, pluginLogin, login, checkSession, showRedPackage, openSetting, getSetting, startSoterAuthentication, checkIsSupportSoterAuthentication, checkIsSoterEnrolledInDevice, requestSubscribeMessage, getUserProfile, getUserInfo, shareToWeRun, getWeRunData, requestPayment, requestOrderPayment, updateShareMenu, showShareMenu, showShareImageMenu, shareVideoMessage, shareFileMessage, onCopyUrl, offCopyUrl, hideShareMenu, getShareInfo, authPrivateMessage, setStorageSync, setStorage, revokeBufferURL, removeStorageSync, removeStorage, getStorageSync, getStorageInfoSync, getStorageInfo, getStorage, createBufferURL, clearStorageSync, clearStorage, setBackgroundFetchToken, onBackgroundFetchData, getBackgroundFetchToken, getBackgroundFetchData, setPageInfo, ocrIdCard, ocrBankCard, ocrDrivingLicense, ocrVehicleLicense, textReview, textToAudio, imageAudit, advancedGeneralIdentify, objectDetectIdentify, carClassify, dishClassify, logoClassify, animalClassify, plantClassify, getSwanId, requestPolymerPayment, navigateToSmartGameProgram, navigateToSmartProgram, navigateBackSmartProgram, preloadSubPackage, createAnimation, setBackgroundTextStyle, setBackgroundColor, nextTick, loadFontFace, disableAlertBeforeUnload, enableAlertBeforeUnload, hideLoading, hideToast, showActionSheet, showLoading, showModal, showToast, getMenuButtonBoundingClientRect, showNavigationBarLoading, setNavigationBarTitle, setNavigationBarColor, hideNavigationBarLoading, hideHomeButton, startPullDownRefresh, stopPullDownRefresh, pageScrollTo, setTopBarText, initTabBarApis, showTabBarRedDot, showTabBar, setTabBarStyle, setTabBarItem, setTabBarBadge, removeTabBarBadge, hideTabBarRedDot, hideTabBar, setWindowSize, onWindowResize, offWindowResize, createWorker, createSelectorQuery, createIntersectionObserver, createMediaQueryObserver, Behavior, canIUseWebp, Current, ENV_TYPE, eventCenter, Events, getEnv, history, initPxTransform, interceptors, Link, options, preload, pxTransform, requirePlugin };
774
775
  export { getCurrentPages, navigateBack, navigateTo, redirectTo, reLaunch, switchTab } from "@tarojs/router";
package/dist/index.cjs.js CHANGED
@@ -3077,6 +3077,7 @@ function taroInterceptor(chain) {
3077
3077
  const link = new Link$1(taroInterceptor);
3078
3078
  const request = link.request.bind(link);
3079
3079
  const addInterceptor = link.addInterceptor.bind(link);
3080
+ const cleanInterceptors = link.cleanInterceptors.bind(link);
3080
3081
 
3081
3082
  // TCP 通信
3082
3083
  const createTCPSocket = temporarilyNotSupport('createTCPSocket');
@@ -5585,17 +5586,22 @@ const pxTransform = function (size = 0) {
5585
5586
  throw new Error(`deviceRatio 配置中不存在 ${designWidth} 的设置!`);
5586
5587
  }
5587
5588
  const formatSize = ~~size;
5588
- let rootValue = 1 / config.deviceRatio[designWidth] * 2;
5589
+ let rootValue = 1 / config.deviceRatio[designWidth];
5589
5590
  switch (config === null || config === void 0 ? void 0 : config.targetUnit) {
5590
5591
  case 'vw':
5591
- rootValue *= 0.5 * designWidth / 100;
5592
+ rootValue = designWidth / 100;
5593
+ break;
5594
+ case 'px':
5595
+ rootValue *= 2;
5592
5596
  break;
5593
5597
  default:
5594
- rootValue *= baseFontSize;
5598
+ // rem
5599
+ rootValue *= baseFontSize * 2;
5595
5600
  }
5596
5601
  let val = formatSize / rootValue;
5597
5602
  if (config.unitPrecision >= 0 && config.unitPrecision <= 100) {
5598
- val = val.toFixed(config.unitPrecision);
5603
+ // Number(val): 0.50000 => 0.5
5604
+ val = Number(val.toFixed(config.unitPrecision));
5599
5605
  }
5600
5606
  return val + (config === null || config === void 0 ? void 0 : config.targetUnit);
5601
5607
  };
@@ -5679,6 +5685,7 @@ exports.chooseMedia = chooseMedia;
5679
5685
  exports.chooseMessageFile = chooseMessageFile;
5680
5686
  exports.choosePoi = choosePoi;
5681
5687
  exports.chooseVideo = chooseVideo;
5688
+ exports.cleanInterceptors = cleanInterceptors;
5682
5689
  exports.clearStorage = clearStorage;
5683
5690
  exports.clearStorageSync = clearStorageSync;
5684
5691
  exports.closeBLEConnection = closeBLEConnection;