@tarojs/taro-h5 3.6.5-alpha → 3.6.5-alpha.2
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/ai/index.d.ts +2 -2
- package/dist/api/base/index.d.ts +7 -7
- package/dist/api/canvas/index.d.ts +4 -4
- package/dist/api/device/battery.js +3 -2
- package/dist/api/device/battery.js.map +1 -1
- package/dist/api/device/index.d.ts +23 -23
- package/dist/api/framework/index.js.map +1 -1
- package/dist/api/index.d.ts +24 -24
- package/dist/api/location/index.d.ts +2 -2
- package/dist/api/location/style.scss.js +2 -2
- package/dist/api/media/audio/InnerAudioContext.d.ts +1 -1
- package/dist/api/media/background-audio/BackgroundAudioManager.d.ts +1 -1
- package/dist/api/media/background-audio/index.d.ts +1 -1
- package/dist/api/media/image/index.d.ts +3 -3
- package/dist/api/media/index.d.ts +12 -12
- package/dist/api/network/index.d.ts +7 -7
- package/dist/api/network/request/index.js +17 -0
- package/dist/api/network/request/index.js.map +1 -1
- package/dist/api/open-api/index.d.ts +18 -18
- package/dist/api/storage/index.d.ts +1 -1
- package/dist/api/ui/index.d.ts +12 -12
- package/dist/api/wxml/IntersectionObserver.js +7 -7
- package/dist/api/wxml/IntersectionObserver.js.map +1 -1
- package/dist/api/wxml/MediaQueryObserver.js +2 -0
- package/dist/api/wxml/MediaQueryObserver.js.map +1 -1
- package/dist/api/wxml/nodesRef.d.ts +1 -1
- package/dist/api/wxml/selectorQuery.d.ts +1 -1
- package/dist/index.cjs.d.ts +1 -0
- package/dist/index.cjs.js +30 -10
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.esm.d.ts +1 -0
- package/dist/index.esm.js +30 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/utils/index.d.ts +3 -3
- package/package.json +10 -7
package/dist/api/ai/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./facial";
|
|
2
|
-
export * from "./visual";
|
|
1
|
+
export * from "./facial.js";
|
|
2
|
+
export * from "./visual.js";
|
package/dist/api/base/index.d.ts
CHANGED
|
@@ -8,10 +8,10 @@ declare const canIUse: (option?: {}, ...args: any[]) => Promise<Partial<TaroGene
|
|
|
8
8
|
declare function arrayBufferToBase64(arrayBuffer: ArrayBuffer): string;
|
|
9
9
|
declare function base64ToArrayBuffer(base64: string): Uint8Array;
|
|
10
10
|
export { env, canIUse, arrayBufferToBase64, base64ToArrayBuffer };
|
|
11
|
-
export * from "./crypto";
|
|
12
|
-
export * from "./debug";
|
|
13
|
-
export * from "./performance";
|
|
14
|
-
export * from "./system";
|
|
15
|
-
export * from "./update";
|
|
16
|
-
export * from "./weapp/app-event";
|
|
17
|
-
export * from "./weapp/life-cycle";
|
|
11
|
+
export * from "./crypto.js";
|
|
12
|
+
export * from "./debug.js";
|
|
13
|
+
export * from "./performance.js";
|
|
14
|
+
export * from "./system.js";
|
|
15
|
+
export * from "./update.js";
|
|
16
|
+
export * from "./weapp/app-event.js";
|
|
17
|
+
export * from "./weapp/life-cycle.js";
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
declare const createOffscreenCanvas: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
3
3
|
export { createOffscreenCanvas };
|
|
4
4
|
/** 创建 canvas 的绘图上下文 CanvasContext 对象 */
|
|
5
|
-
export * from "./createCanvasContext";
|
|
5
|
+
export * from "./createCanvasContext.js";
|
|
6
6
|
/** 把当前画布指定区域的内容导出生成指定大小的图片 */
|
|
7
|
-
export * from "./canvasToTempFilePath";
|
|
7
|
+
export * from "./canvasToTempFilePath.js";
|
|
8
8
|
/** 将像素数据绘制到画布 */
|
|
9
|
-
export * from "./canvasPutImageData";
|
|
9
|
+
export * from "./canvasPutImageData.js";
|
|
10
10
|
/** 获取 canvas 区域隐含的像素数据 */
|
|
11
|
-
export * from "./canvasGetImageData";
|
|
11
|
+
export * from "./canvasGetImageData.js";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { __awaiter } from '../../node_modules/.pnpm/registry.npmjs.org_tslib@1.14.1/node_modules/tslib/tslib.es6.js';
|
|
2
|
-
import {
|
|
2
|
+
import { permanentlyNotSupport } from '../../utils/index.js';
|
|
3
3
|
import { MethodHandler } from '../../utils/handler.js';
|
|
4
4
|
|
|
5
5
|
// 电量
|
|
6
|
-
|
|
6
|
+
// Note: 浏览器标准下不支持,其他实现方案不准确,不建议开发者使用
|
|
7
|
+
const getBatteryInfoSync = permanentlyNotSupport('getBatteryInfoSync');
|
|
7
8
|
const getBatteryInfo = ({ success, fail, complete } = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
8
9
|
var _a;
|
|
9
10
|
const handle = new MethodHandler({ name: 'getBatteryInfo', success, fail, complete });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"battery.js","sources":["../../../src/api/device/battery.ts"],"sourcesContent":["import Taro from '@tarojs/api'\n\nimport {
|
|
1
|
+
{"version":3,"file":"battery.js","sources":["../../../src/api/device/battery.ts"],"sourcesContent":["import Taro from '@tarojs/api'\n\nimport { permanentlyNotSupport } from '../../utils'\nimport { MethodHandler } from '../../utils/handler'\n\n// 电量\n\n// Note: 浏览器标准下不支持,其他实现方案不准确,不建议开发者使用\nexport const getBatteryInfoSync = permanentlyNotSupport('getBatteryInfoSync')\n\nexport const getBatteryInfo: typeof Taro.getBatteryInfo = async ({ success, fail, complete } = {}) => {\n const handle = new MethodHandler({ name: 'getBatteryInfo', success, fail, complete })\n try {\n // @ts-ignore\n const battery = await navigator.getBattery?.()\n return handle.success({\n isCharging: battery.charging,\n level: Number(battery.level || 0) * 100\n })\n } catch (error) {\n return handle.fail({\n errMsg: error?.message || error\n })\n }\n}\n"],"names":[],"mappings":";;;;AAKA;AAEA;MACa,kBAAkB,GAAG,qBAAqB,CAAC,oBAAoB,EAAC;AAEtE,MAAM,cAAc,GAA+B,CAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAI,SAAA,CAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,aAAA;;AACnG,IAAA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;IACrF,IAAI;;QAEF,MAAM,OAAO,GAAG,OAAM,CAAA,EAAA,GAAA,SAAS,CAAC,UAAU,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,IAAA,CAAA,SAAA,CAAA,CAAA,CAAA;QAC9C,OAAO,MAAM,CAAC,OAAO,CAAC;YACpB,UAAU,EAAE,OAAO,CAAC,QAAQ;YAC5B,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,GAAG;AACxC,SAAA,CAAC,CAAA;AACH,KAAA;AAAC,IAAA,OAAO,KAAK,EAAE;QACd,OAAO,MAAM,CAAC,IAAI,CAAC;YACjB,MAAM,EAAE,CAAA,KAAK,KAAL,IAAA,IAAA,KAAK,uBAAL,KAAK,CAAE,OAAO,KAAI,KAAK;AAChC,SAAA,CAAC,CAAA;AACH,KAAA;AACH,CAAC;;;;"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export * from "./accelerometer";
|
|
2
|
-
export * from "./accessibility";
|
|
3
|
-
export * from "./battery";
|
|
4
|
-
export * from "./bluetooth";
|
|
5
|
-
export * from "./bluetooth-ble";
|
|
6
|
-
export * from "./bluetooth-peripheral";
|
|
7
|
-
export * from "./calendar";
|
|
8
|
-
export * from "./clipboard";
|
|
9
|
-
export * from "./compass";
|
|
10
|
-
export * from "./contact";
|
|
11
|
-
export * from "./crypto";
|
|
12
|
-
export * from "./gyroscope";
|
|
13
|
-
export * from "./iBeacon";
|
|
14
|
-
export * from "./keyboard";
|
|
15
|
-
export * from "./memory";
|
|
16
|
-
export * from "./motion";
|
|
17
|
-
export * from "./network";
|
|
18
|
-
export * from "./nfc";
|
|
19
|
-
export * from "./phone";
|
|
20
|
-
export * from "./scan";
|
|
21
|
-
export * from "./screen";
|
|
22
|
-
export * from "./vibrate";
|
|
23
|
-
export * from "./wifi";
|
|
1
|
+
export * from "./accelerometer.js";
|
|
2
|
+
export * from "./accessibility.js";
|
|
3
|
+
export * from "./battery.js";
|
|
4
|
+
export * from "./bluetooth.js";
|
|
5
|
+
export * from "./bluetooth-ble.js";
|
|
6
|
+
export * from "./bluetooth-peripheral.js";
|
|
7
|
+
export * from "./calendar.js";
|
|
8
|
+
export * from "./clipboard.js";
|
|
9
|
+
export * from "./compass.js";
|
|
10
|
+
export * from "./contact.js";
|
|
11
|
+
export * from "./crypto.js";
|
|
12
|
+
export * from "./gyroscope.js";
|
|
13
|
+
export * from "./iBeacon.js";
|
|
14
|
+
export * from "./keyboard.js";
|
|
15
|
+
export * from "./memory.js";
|
|
16
|
+
export * from "./motion.js";
|
|
17
|
+
export * from "./network.js";
|
|
18
|
+
export * from "./nfc.js";
|
|
19
|
+
export * from "./phone.js";
|
|
20
|
+
export * from "./scan.js";
|
|
21
|
+
export * from "./screen.js";
|
|
22
|
+
export * from "./vibrate.js";
|
|
23
|
+
export * from "./wifi.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/api/framework/index.ts"],"sourcesContent":["import Taro from '@tarojs/api'\n\nexport const getApp: typeof Taro.getApp = function <T = TaroGeneral.IAnyObject> () {\n return Taro.getCurrentInstance().app as unknown as
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/api/framework/index.ts"],"sourcesContent":["import Taro from '@tarojs/api'\n\nexport const getApp: typeof Taro.getApp = function <T extends Taro.App = TaroGeneral.IAnyObject> () {\n return Taro.getCurrentInstance().app as unknown as T\n}\n\nexport { getCurrentPages } from '@tarojs/router'\n\n// 自定义组件\nexport const getCurrentInstance = Taro.getCurrentInstance\n"],"names":[],"mappings":";;;AAEa,MAAA,MAAM,GAAuB,YAAA;AACxC,IAAA,OAAO,IAAI,CAAC,kBAAkB,EAAE,CAAC,GAAmB,CAAA;AACtD,EAAC;AAID;AACa,MAAA,kBAAkB,GAAG,IAAI,CAAC;;;;"}
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
export * from "./ad/index";
|
|
2
|
-
export * from "./ai/index";
|
|
3
|
-
export * from "./alipay/index";
|
|
4
|
-
export * from "./base/index";
|
|
5
|
-
export * from "./canvas/index";
|
|
6
|
-
export * from "./cloud/index";
|
|
7
|
-
export * from "./data-analysis/index";
|
|
8
|
-
export * from "./device/index";
|
|
9
|
-
export * from "./ext/index";
|
|
10
|
-
export * from "./files/index";
|
|
11
|
-
export * from "./framework/index";
|
|
12
|
-
export * from "./location/index";
|
|
13
|
-
export * from "./media/index";
|
|
14
|
-
export * from "./navigate/index";
|
|
15
|
-
export * from "./network/index";
|
|
16
|
-
export * from "./open-api/index";
|
|
17
|
-
export * from "./payment/index";
|
|
18
|
-
export * from "./route/index";
|
|
19
|
-
export * from "./share/index";
|
|
20
|
-
export * from "./storage/index";
|
|
21
|
-
export * from "./swan/index";
|
|
22
|
-
export * from "./ui/index";
|
|
23
|
-
export * from "./worker/index";
|
|
24
|
-
export * from "./wxml/index";
|
|
1
|
+
export * from "./ad/index.js";
|
|
2
|
+
export * from "./ai/index.js";
|
|
3
|
+
export * from "./alipay/index.js";
|
|
4
|
+
export * from "./base/index.js";
|
|
5
|
+
export * from "./canvas/index.js";
|
|
6
|
+
export * from "./cloud/index.js";
|
|
7
|
+
export * from "./data-analysis/index.js";
|
|
8
|
+
export * from "./device/index.js";
|
|
9
|
+
export * from "./ext/index.js";
|
|
10
|
+
export * from "./files/index.js";
|
|
11
|
+
export * from "./framework/index.js";
|
|
12
|
+
export * from "./location/index.js";
|
|
13
|
+
export * from "./media/index.js";
|
|
14
|
+
export * from "./navigate/index.js";
|
|
15
|
+
export * from "./network/index.js";
|
|
16
|
+
export * from "./open-api/index.js";
|
|
17
|
+
export * from "./payment/index.js";
|
|
18
|
+
export * from "./route/index.js";
|
|
19
|
+
export * from "./share/index.js";
|
|
20
|
+
export * from "./storage/index.js";
|
|
21
|
+
export * from "./swan/index.js";
|
|
22
|
+
export * from "./ui/index.js";
|
|
23
|
+
export * from "./worker/index.js";
|
|
24
|
+
export * from "./wxml/index.js";
|
|
@@ -11,5 +11,5 @@ declare const offLocationChange: (option?: {}, ...args: any[]) => Promise<Partia
|
|
|
11
11
|
declare const choosePoi: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
12
12
|
declare const getFuzzyLocation: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
13
13
|
export { stopLocationUpdate, startLocationUpdateBackground, startLocationUpdate, openLocation, onLocationChangeError, onLocationChange, offLocationChangeError, offLocationChange, choosePoi, getFuzzyLocation };
|
|
14
|
-
export { getLocation } from "./getLocation";
|
|
15
|
-
export { chooseLocation } from "./chooseLocation";
|
|
14
|
+
export { getLocation } from "./getLocation.js";
|
|
15
|
+
export { chooseLocation } from "./chooseLocation.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styleInject from '../../node_modules/.pnpm/registry.npmjs.org_style-inject@0.3.0/node_modules/style-inject/dist/style-inject.es.js';
|
|
2
2
|
|
|
3
|
-
var css_248z = ".taro_choose_location {\n display: flex;\n position: fixed;\n top: 100%;\n z-index: 1;\n flex-direction: column;\n width: 100%;\n height: 100%;\n background-color: #fff;\n transition: ease top 0.3s
|
|
4
|
-
var stylesheet=".taro_choose_location {\n display: flex;\n position: fixed;\n top: 100%;\n z-index: 1;\n flex-direction: column;\n width: 100%;\n height: 100%;\n background-color: #fff;\n transition: ease top 0.3s
|
|
3
|
+
var css_248z = ".taro_choose_location {\n display: flex;\n position: fixed;\n top: 100%;\n z-index: 1;\n flex-direction: column;\n width: 100%;\n height: 100%;\n background-color: #fff;\n transition: ease top 0.3s;\n}\n.taro_choose_location_bar {\n display: flex;\n flex: 0 95px;\n height: 95px;\n background-color: #ededed;\n color: #090909;\n}\n.taro_choose_location_back {\n position: relative;\n flex: 0 45px;\n margin-top: 30px;\n width: 33px;\n height: 30px;\n}\n.taro_choose_location_back::before {\n display: block;\n position: absolute;\n left: 0;\n top: 0;\n border: solid 15px;\n border-color: transparent #090909 transparent transparent;\n width: 0;\n height: 0;\n content: \"\";\n}\n.taro_choose_location_back::after {\n display: block;\n position: absolute;\n left: 3px;\n top: 0;\n border: solid 15px;\n border-color: transparent #ededed transparent transparent;\n width: 0;\n height: 0;\n content: \"\";\n}\n.taro_choose_location_title {\n flex: 1;\n padding-left: 30px;\n line-height: 95px;\n}\n.taro_choose_location_submit {\n margin: 18px 30px 0 0;\n padding: 0;\n border: none;\n width: 110px;\n height: 60px;\n background-color: #08bf62;\n line-height: 60px;\n font-size: 28px;\n color: #fff;\n}\n.taro_choose_location_frame {\n flex: 1;\n}";
|
|
4
|
+
var stylesheet=".taro_choose_location {\n display: flex;\n position: fixed;\n top: 100%;\n z-index: 1;\n flex-direction: column;\n width: 100%;\n height: 100%;\n background-color: #fff;\n transition: ease top 0.3s;\n}\n.taro_choose_location_bar {\n display: flex;\n flex: 0 95px;\n height: 95px;\n background-color: #ededed;\n color: #090909;\n}\n.taro_choose_location_back {\n position: relative;\n flex: 0 45px;\n margin-top: 30px;\n width: 33px;\n height: 30px;\n}\n.taro_choose_location_back::before {\n display: block;\n position: absolute;\n left: 0;\n top: 0;\n border: solid 15px;\n border-color: transparent #090909 transparent transparent;\n width: 0;\n height: 0;\n content: \"\";\n}\n.taro_choose_location_back::after {\n display: block;\n position: absolute;\n left: 3px;\n top: 0;\n border: solid 15px;\n border-color: transparent #ededed transparent transparent;\n width: 0;\n height: 0;\n content: \"\";\n}\n.taro_choose_location_title {\n flex: 1;\n padding-left: 30px;\n line-height: 95px;\n}\n.taro_choose_location_submit {\n margin: 18px 30px 0 0;\n padding: 0;\n border: none;\n width: 110px;\n height: 60px;\n background-color: #08bf62;\n line-height: 60px;\n font-size: 28px;\n color: #fff;\n}\n.taro_choose_location_frame {\n flex: 1;\n}";
|
|
5
5
|
styleInject(css_248z,{"insertAt":"top"});
|
|
6
6
|
|
|
7
7
|
export { css_248z as default, stylesheet };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Taro from '@tarojs/api';
|
|
2
|
-
import { CallbackManager } from "../../../utils/handler";
|
|
2
|
+
import { CallbackManager } from "../../../utils/handler.js";
|
|
3
3
|
declare class InnerAudioContext implements Taro.InnerAudioContext {
|
|
4
4
|
Instance?: HTMLAudioElement;
|
|
5
5
|
errorStack: CallbackManager;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Taro from '@tarojs/api';
|
|
2
|
-
import { CallbackManager } from "../../../utils/handler";
|
|
2
|
+
import { CallbackManager } from "../../../utils/handler.js";
|
|
3
3
|
declare class BackgroundAudioManager implements Taro.BackgroundAudioManager {
|
|
4
4
|
Instance?: HTMLAudioElement;
|
|
5
5
|
errorStack: CallbackManager;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BackgroundAudioManager } from "./BackgroundAudioManager";
|
|
1
|
+
import { BackgroundAudioManager } from "./BackgroundAudioManager.js";
|
|
2
2
|
declare const stopBackgroundAudio: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
3
3
|
declare const seekBackgroundAudio: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
4
4
|
declare const playBackgroundAudio: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
@@ -3,6 +3,6 @@ declare const previewMedia: (option?: {}, ...args: any[]) => Promise<Partial<Tar
|
|
|
3
3
|
declare const compressImage: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
4
4
|
declare const chooseMessageFile: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
5
5
|
export { saveImageToPhotosAlbum, previewMedia, compressImage, chooseMessageFile };
|
|
6
|
-
export * from "./getImageInfo";
|
|
7
|
-
export * from "./previewImage";
|
|
8
|
-
export * from "./chooseImage";
|
|
6
|
+
export * from "./getImageInfo.js";
|
|
7
|
+
export * from "./previewImage.js";
|
|
8
|
+
export * from "./chooseImage.js";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export * from "./audio/index";
|
|
2
|
-
export * from "./background-audio/index";
|
|
3
|
-
export * from "./camera";
|
|
4
|
-
export * from "./image/index";
|
|
5
|
-
export * from "./live";
|
|
6
|
-
export * from "./map";
|
|
7
|
-
export * from "./media-recorder";
|
|
8
|
-
export * from "./recorder";
|
|
9
|
-
export * from "./video/index";
|
|
10
|
-
export * from "./video-decoder";
|
|
11
|
-
export * from "./video-processing";
|
|
12
|
-
export * from "./voip";
|
|
1
|
+
export * from "./audio/index.js";
|
|
2
|
+
export * from "./background-audio/index.js";
|
|
3
|
+
export * from "./camera.js";
|
|
4
|
+
export * from "./image/index.js";
|
|
5
|
+
export * from "./live.js";
|
|
6
|
+
export * from "./map.js";
|
|
7
|
+
export * from "./media-recorder.js";
|
|
8
|
+
export * from "./recorder.js";
|
|
9
|
+
export * from "./video/index.js";
|
|
10
|
+
export * from "./video-decoder.js";
|
|
11
|
+
export * from "./video-processing.js";
|
|
12
|
+
export * from "./voip.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export * from "./download";
|
|
2
|
-
export * from "./mdns";
|
|
3
|
-
export * from "./request/index";
|
|
4
|
-
export * from "./tcp";
|
|
5
|
-
export * from "./udp";
|
|
6
|
-
export * from "./upload";
|
|
7
|
-
export * from "./websocket/index";
|
|
1
|
+
export * from "./download.js";
|
|
2
|
+
export * from "./mdns.js";
|
|
3
|
+
export * from "./request/index.js";
|
|
4
|
+
export * from "./tcp.js";
|
|
5
|
+
export * from "./udp.js";
|
|
6
|
+
export * from "./upload.js";
|
|
7
|
+
export * from "./websocket/index.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import 'whatwg-fetch';
|
|
2
|
+
import 'abortcontroller-polyfill/dist/abortcontroller-polyfill-only';
|
|
2
3
|
import Taro from '@tarojs/api';
|
|
3
4
|
import { isFunction } from '@tarojs/shared';
|
|
4
5
|
import jsonpRetry from 'jsonp-retry';
|
|
@@ -80,12 +81,24 @@ function _request(options) {
|
|
|
80
81
|
if (options.mode) {
|
|
81
82
|
params.mode = options.mode;
|
|
82
83
|
}
|
|
84
|
+
let timeoutTimer = null;
|
|
83
85
|
if (options.signal) {
|
|
84
86
|
params.signal = options.signal;
|
|
85
87
|
}
|
|
88
|
+
else if (typeof options.timeout === 'number') {
|
|
89
|
+
const controller = new window.AbortController();
|
|
90
|
+
params.signal = controller.signal;
|
|
91
|
+
timeoutTimer = setTimeout(function () {
|
|
92
|
+
controller.abort();
|
|
93
|
+
}, options.timeout);
|
|
94
|
+
}
|
|
86
95
|
params.credentials = options.credentials;
|
|
87
96
|
return fetch(url, params)
|
|
88
97
|
.then(response => {
|
|
98
|
+
if (timeoutTimer) {
|
|
99
|
+
clearTimeout(timeoutTimer);
|
|
100
|
+
timeoutTimer = null;
|
|
101
|
+
}
|
|
89
102
|
if (!response) {
|
|
90
103
|
const errorResponse = { ok: false };
|
|
91
104
|
throw errorResponse;
|
|
@@ -117,6 +130,10 @@ function _request(options) {
|
|
|
117
130
|
return res;
|
|
118
131
|
})
|
|
119
132
|
.catch(err => {
|
|
133
|
+
if (timeoutTimer) {
|
|
134
|
+
clearTimeout(timeoutTimer);
|
|
135
|
+
timeoutTimer = null;
|
|
136
|
+
}
|
|
120
137
|
isFunction(fail) && fail(err);
|
|
121
138
|
isFunction(complete) && complete(res);
|
|
122
139
|
err.statusCode = res.statusCode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/api/network/request/index.ts"],"sourcesContent":["import 'whatwg-fetch'\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 if (options.signal) {\n params.signal = options.signal\n }\n params.credentials = options.credentials\n return fetch(url, params)\n .then(response => {\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 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":";;;;;;AAQA;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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C,UAAU,GAAG,GAAG,CAAC,UAAU,CAAA;AAC/B,QAAA,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,OAAO,CAAA;AACxB,QAAA,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;AAC5B,KAAC,CAAC,CAAA;AACN,CAAC;AAED,SAAS,eAAe,CAAE,KAAK,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)\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,CA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AU,CAAA;AAC/B,QAAA,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,OAAO,CAAA;AACxB,QAAA,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;AAC5B,KAAC,CAAC,CAAA;AACN,CAAC;AAED,SAAS,eAAe,CAAE,KAAK,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,18 +1,18 @@
|
|
|
1
|
-
export * from "./account";
|
|
2
|
-
export * from "./address";
|
|
3
|
-
export * from "./authorize";
|
|
4
|
-
export * from "./card";
|
|
5
|
-
export * from "./channels-live";
|
|
6
|
-
export * from "./customer-service";
|
|
7
|
-
export * from "./facial";
|
|
8
|
-
export * from "./favorites";
|
|
9
|
-
export * from "./group";
|
|
10
|
-
export * from "./invoice";
|
|
11
|
-
export * from "./license-plate";
|
|
12
|
-
export * from "./login";
|
|
13
|
-
export * from "./red-package";
|
|
14
|
-
export * from "./settings";
|
|
15
|
-
export * from "./soter";
|
|
16
|
-
export * from "./subscribe-message";
|
|
17
|
-
export * from "./user-info";
|
|
18
|
-
export * from "./werun";
|
|
1
|
+
export * from "./account.js";
|
|
2
|
+
export * from "./address.js";
|
|
3
|
+
export * from "./authorize.js";
|
|
4
|
+
export * from "./card.js";
|
|
5
|
+
export * from "./channels-live.js";
|
|
6
|
+
export * from "./customer-service.js";
|
|
7
|
+
export * from "./facial.js";
|
|
8
|
+
export * from "./favorites.js";
|
|
9
|
+
export * from "./group.js";
|
|
10
|
+
export * from "./invoice.js";
|
|
11
|
+
export * from "./license-plate.js";
|
|
12
|
+
export * from "./login.js";
|
|
13
|
+
export * from "./red-package.js";
|
|
14
|
+
export * from "./settings.js";
|
|
15
|
+
export * from "./soter.js";
|
|
16
|
+
export * from "./subscribe-message.js";
|
|
17
|
+
export * from "./user-info.js";
|
|
18
|
+
export * from "./werun.js";
|
|
@@ -12,4 +12,4 @@ declare const createBufferURL: (option?: {}, ...args: any[]) => Promise<Partial<
|
|
|
12
12
|
declare const clearStorageSync: typeof Taro.clearStorageSync;
|
|
13
13
|
declare const clearStorage: typeof Taro.clearStorage;
|
|
14
14
|
export { setStorageSync, setStorage, revokeBufferURL, removeStorageSync, removeStorage, getStorageSync, getStorageInfoSync, getStorageInfo, getStorage, createBufferURL, clearStorageSync, clearStorage };
|
|
15
|
-
export * from "./background-fetch";
|
|
15
|
+
export * from "./background-fetch.js";
|
package/dist/api/ui/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export * from "./animation/index";
|
|
2
|
-
export * from "./background";
|
|
3
|
-
export * from "./custom-component";
|
|
4
|
-
export * from "./fonts";
|
|
5
|
-
export * from "./interaction/index";
|
|
6
|
-
export * from "./menu";
|
|
7
|
-
export * from "./navigation-bar/index";
|
|
8
|
-
export * from "./pull-down-refresh";
|
|
9
|
-
export * from "./scroll/index";
|
|
10
|
-
export * from "./sticky";
|
|
11
|
-
export * from "./tab-bar";
|
|
12
|
-
export * from "./window";
|
|
1
|
+
export * from "./animation/index.js";
|
|
2
|
+
export * from "./background.js";
|
|
3
|
+
export * from "./custom-component.js";
|
|
4
|
+
export * from "./fonts.js";
|
|
5
|
+
export * from "./interaction/index.js";
|
|
6
|
+
export * from "./menu.js";
|
|
7
|
+
export * from "./navigation-bar/index.js";
|
|
8
|
+
export * from "./pull-down-refresh.js";
|
|
9
|
+
export * from "./scroll/index.js";
|
|
10
|
+
export * from "./sticky.js";
|
|
11
|
+
export * from "./tab-bar.js";
|
|
12
|
+
export * from "./window.js";
|
|
@@ -3,6 +3,13 @@ import { findDOM } from '../../utils/index.js';
|
|
|
3
3
|
// pollify
|
|
4
4
|
import('intersection-observer');
|
|
5
5
|
class TaroH5IntersectionObserver {
|
|
6
|
+
// selector 的容器节点
|
|
7
|
+
get container() {
|
|
8
|
+
const container = (this._component !== null
|
|
9
|
+
? (findDOM(this._component) || document)
|
|
10
|
+
: document);
|
|
11
|
+
return container;
|
|
12
|
+
}
|
|
6
13
|
constructor(component, options = {}) {
|
|
7
14
|
// 选项
|
|
8
15
|
this._options = {
|
|
@@ -19,13 +26,6 @@ class TaroH5IntersectionObserver {
|
|
|
19
26
|
this._component = component;
|
|
20
27
|
Object.assign(this._options, options);
|
|
21
28
|
}
|
|
22
|
-
// selector 的容器节点
|
|
23
|
-
get container() {
|
|
24
|
-
const container = (this._component !== null
|
|
25
|
-
? (findDOM(this._component) || document)
|
|
26
|
-
: document);
|
|
27
|
-
return container;
|
|
28
|
-
}
|
|
29
29
|
createInst() {
|
|
30
30
|
// 去除原本的实例
|
|
31
31
|
this.disconnect();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntersectionObserver.js","sources":["../../../src/api/wxml/IntersectionObserver.ts"],"sourcesContent":["import Taro from '@tarojs/taro'\n\nimport { findDOM } from '../../utils'\n// pollify\nimport('intersection-observer')\n\ntype TElement = Document | HTMLElement | Element\n\ntype TListener = {\n element: Element\n callback: Taro.IntersectionObserver.ObserveCallback\n}\n\nexport class TaroH5IntersectionObserver implements Taro.IntersectionObserver {\n\n // 自定义组件实例\n private _component: TaroGeneral.IAnyObject\n // 选项\n private _options = {\n thresholds: [0],\n initialRatio: 0,\n observeAll: false\n }\n\n // Observer实例\n private _observerInst: IntersectionObserver\n // 监控中的选择器\n private _listeners: TListener[] = []\n // 参照区域\n private _root: Element | null\n // 用来扩展(或收缩)参照节点布局区域的边界\n private _rootMargin: Taro.IntersectionObserver.RelativeToViewportMargins = {}\n // 是否已初始化\n private _isInited = false\n\n // selector 的容器节点\n protected get container () {\n const container: TElement = (\n this._component !== null \n ? (findDOM(this._component) as HTMLElement || document) \n : document\n )\n return container\n }\n\n constructor (component: TaroGeneral.IAnyObject, options: Taro.createIntersectionObserver.Option = {}) {\n this._component = component\n Object.assign(this._options, options)\n }\n\n private createInst () {\n // 去除原本的实例\n this.disconnect()\n\n const { left = 0, top = 0, bottom = 0, right = 0 } = this._rootMargin\n return new IntersectionObserver(entries => {\n entries.forEach(entry => {\n const _callback = this._getCallbackByElement(entry.target)\n const result = {\n boundingClientRect: entry.boundingClientRect,\n intersectionRatio: entry.intersectionRatio,\n intersectionRect: entry.intersectionRect,\n relativeRect: entry.rootBounds || { left: 0, right: 0, top: 0, bottom: 0 },\n time: entry.time\n }\n // web端会默认首次触发\n if (!this._isInited && this._options.initialRatio <= Math.min.apply(Math, this._options.thresholds)) {\n // 初始的相交比例,如果调用时检测到的相交比例与这个值不相等且达到阈值,则会触发一次监听器的回调函数。\n return\n }\n _callback && _callback.call(this, result)\n })\n this._isInited = true\n }, {\n root: this._root,\n rootMargin: [`${top}px`, `${right}px`, `${bottom}px`, `${left}px`].join(' '),\n threshold: this._options.thresholds\n })\n }\n\n public disconnect (): void {\n if (this._observerInst) {\n let listener\n while ((listener = this._listeners.pop())) {\n this._observerInst.unobserve(listener.element)\n }\n this._observerInst.disconnect()\n }\n }\n\n public observe (targetSelector: string, callback: Taro.IntersectionObserver.ObserveCallback): void {\n // 同wx小程序效果一致,每个实例监听一个Selector\n if (this._listeners.length) return\n // 监听前没有设置关联的节点\n if (!this._observerInst) {\n console.warn('Intersection observer will be ignored because no relative nodes are found.')\n return\n }\n \n const nodeList = this._options.observeAll \n ? this.container.querySelectorAll(targetSelector) \n : [this.container.querySelector(targetSelector)]\n \n nodeList.forEach(element => {\n if (!element) return\n this._observerInst.observe(element)\n this._listeners.push({ element, callback })\n })\n }\n\n public relativeTo (selector: string, margins?: Taro.IntersectionObserver.RelativeToMargins | undefined): Taro.IntersectionObserver {\n // 已设置observe监听后,重新关联节点\n if (this._listeners.length) {\n console.error('Relative nodes cannot be added after \"observe\" call in IntersectionObserver')\n return this\n }\n this._root = this.container.querySelector(selector) || null\n if (margins) {\n this._rootMargin = margins\n }\n this._observerInst = this.createInst()\n return this\n }\n\n public relativeToViewport (margins?: Taro.IntersectionObserver.RelativeToViewportMargins | undefined): Taro.IntersectionObserver {\n return this.relativeTo('.taro_page', margins)\n }\n\n private _getCallbackByElement (element: Element) {\n const listener = this._listeners.find(listener => listener.element === element)\n return listener ? listener.callback : null\n }\n\n}\n"],"names":[],"mappings":";;AAGA;AACA,OAAO,uBAAuB,CAAC,CAAA;MASlB,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"IntersectionObserver.js","sources":["../../../src/api/wxml/IntersectionObserver.ts"],"sourcesContent":["import Taro from '@tarojs/taro'\n\nimport { findDOM } from '../../utils'\n// pollify\nimport('intersection-observer')\n\ntype TElement = Document | HTMLElement | Element\n\ntype TListener = {\n element: Element\n callback: Taro.IntersectionObserver.ObserveCallback\n}\n\nexport class TaroH5IntersectionObserver implements Taro.IntersectionObserver {\n\n // 自定义组件实例\n private _component: TaroGeneral.IAnyObject\n // 选项\n private _options = {\n thresholds: [0],\n initialRatio: 0,\n observeAll: false\n }\n\n // Observer实例\n private _observerInst: IntersectionObserver\n // 监控中的选择器\n private _listeners: TListener[] = []\n // 参照区域\n private _root: Element | null\n // 用来扩展(或收缩)参照节点布局区域的边界\n private _rootMargin: Taro.IntersectionObserver.RelativeToViewportMargins = {}\n // 是否已初始化\n private _isInited = false\n\n // selector 的容器节点\n protected get container () {\n const container: TElement = (\n this._component !== null \n ? (findDOM(this._component) as HTMLElement || document) \n : document\n )\n return container\n }\n\n constructor (component: TaroGeneral.IAnyObject, options: Taro.createIntersectionObserver.Option = {}) {\n this._component = component\n Object.assign(this._options, options)\n }\n\n private createInst () {\n // 去除原本的实例\n this.disconnect()\n\n const { left = 0, top = 0, bottom = 0, right = 0 } = this._rootMargin\n return new IntersectionObserver(entries => {\n entries.forEach(entry => {\n const _callback = this._getCallbackByElement(entry.target)\n const result = {\n boundingClientRect: entry.boundingClientRect,\n intersectionRatio: entry.intersectionRatio,\n intersectionRect: entry.intersectionRect,\n relativeRect: entry.rootBounds || { left: 0, right: 0, top: 0, bottom: 0 },\n time: entry.time\n }\n // web端会默认首次触发\n if (!this._isInited && this._options.initialRatio <= Math.min.apply(Math, this._options.thresholds)) {\n // 初始的相交比例,如果调用时检测到的相交比例与这个值不相等且达到阈值,则会触发一次监听器的回调函数。\n return\n }\n _callback && _callback.call(this, result)\n })\n this._isInited = true\n }, {\n root: this._root,\n rootMargin: [`${top}px`, `${right}px`, `${bottom}px`, `${left}px`].join(' '),\n threshold: this._options.thresholds\n })\n }\n\n public disconnect (): void {\n if (this._observerInst) {\n let listener\n while ((listener = this._listeners.pop())) {\n this._observerInst.unobserve(listener.element)\n }\n this._observerInst.disconnect()\n }\n }\n\n public observe (targetSelector: string, callback: Taro.IntersectionObserver.ObserveCallback): void {\n // 同wx小程序效果一致,每个实例监听一个Selector\n if (this._listeners.length) return\n // 监听前没有设置关联的节点\n if (!this._observerInst) {\n console.warn('Intersection observer will be ignored because no relative nodes are found.')\n return\n }\n \n const nodeList = this._options.observeAll \n ? this.container.querySelectorAll(targetSelector) \n : [this.container.querySelector(targetSelector)]\n \n nodeList.forEach(element => {\n if (!element) return\n this._observerInst.observe(element)\n this._listeners.push({ element, callback })\n })\n }\n\n public relativeTo (selector: string, margins?: Taro.IntersectionObserver.RelativeToMargins | undefined): Taro.IntersectionObserver {\n // 已设置observe监听后,重新关联节点\n if (this._listeners.length) {\n console.error('Relative nodes cannot be added after \"observe\" call in IntersectionObserver')\n return this\n }\n this._root = this.container.querySelector(selector) || null\n if (margins) {\n this._rootMargin = margins\n }\n this._observerInst = this.createInst()\n return this\n }\n\n public relativeToViewport (margins?: Taro.IntersectionObserver.RelativeToViewportMargins | undefined): Taro.IntersectionObserver {\n return this.relativeTo('.taro_page', margins)\n }\n\n private _getCallbackByElement (element: Element) {\n const listener = this._listeners.find(listener => listener.element === element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IAAI,CAAA;KACZ;AAEM,IAAA,kBAAkB,CAAE,OAAyE,EAAA;QAClG,OAAO,IAAI,CAAC,UAAU,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;KAC9C;AAEO,IAAA,qBAAqB,CAAE,OAAgB,EAAA;AAC7C,QAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,OAAO,KAAK,OAAO,CAAC,CAAA;QAC/E,OAAO,QAAQ,GAAG,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAA;KAC3C;AAEF;;;;"}
|
|
@@ -32,6 +32,7 @@ class MediaQueryObserver {
|
|
|
32
32
|
this._mediaQueryObserver.addEventListener('change', this._listener);
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
|
+
// @ts-ignore
|
|
35
36
|
this._mediaQueryObserver.addListener(this._listener);
|
|
36
37
|
}
|
|
37
38
|
}
|
|
@@ -44,6 +45,7 @@ class MediaQueryObserver {
|
|
|
44
45
|
this._mediaQueryObserver.removeEventListener('change', this._listener);
|
|
45
46
|
}
|
|
46
47
|
else {
|
|
48
|
+
// @ts-ignore
|
|
47
49
|
this._mediaQueryObserver.removeListener(this._listener);
|
|
48
50
|
}
|
|
49
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MediaQueryObserver.js","sources":["../../../src/api/wxml/MediaQueryObserver.ts"],"sourcesContent":["\nimport { isFunction } from '@tarojs/shared'\nimport Taro from '@tarojs/taro'\n\nimport { toKebabCase } from '../../utils'\n\nfunction generateMediaQueryStr (descriptor: Taro.MediaQueryObserver.descriptor) {\n const mediaQueryArr: string[] = []\n const descriptorMenu = ['width', 'minWidth', 'maxWidth', 'height', 'minHeight', 'maxHeight', 'orientation']\n for (const item of descriptorMenu) {\n if (\n item !== 'orientation' &&\n descriptor[item] &&\n Number(descriptor[item]) >= 0\n ) {\n mediaQueryArr.push(`(${(toKebabCase(item))}: ${Number(descriptor[item])}px)`)\n }\n if (item === 'orientation' && descriptor[item]) {\n mediaQueryArr.push(`(${toKebabCase(item)}: ${descriptor[item]})`)\n }\n }\n return mediaQueryArr.join(' and ')\n}\n\n\nexport class MediaQueryObserver implements Taro.MediaQueryObserver {\n private _mediaQueryObserver: MediaQueryList\n private _listener: (ev: MediaQueryListEvent) => void\n\n // 监听页面媒体查询变化情况\n public observe (descriptor: Taro.MediaQueryObserver.descriptor, callback: Taro.MediaQueryObserver.observeCallback): void {\n if (isFunction(callback)) {\n // 创建媒体查询对象\n this._mediaQueryObserver = window.matchMedia(generateMediaQueryStr(descriptor))\n // 监听器\n this._listener = (ev: MediaQueryListEvent) => {\n callback({ matches: ev.matches })\n }\n callback({ matches: this._mediaQueryObserver.matches })\n // 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'addEventListener'\n if ('addEventListener' in this._mediaQueryObserver) {\n this._mediaQueryObserver.addEventListener('change', this._listener)\n } else {\n this._mediaQueryObserver.addListener(this._listener)\n }\n }\n }\n\n // 停止监听,销毁媒体查询对象\n public disconnect (): void {\n if (this._mediaQueryObserver && this._listener) {\n // 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'removeEventListener'\n if ('removeEventListener' in this._mediaQueryObserver) {\n this._mediaQueryObserver.removeEventListener('change', this._listener)\n } else {\n this._mediaQueryObserver.removeListener(this._listener)\n }\n }\n }\n\n}\n"],"names":[],"mappings":";;;AAMA,SAAS,qBAAqB,CAAE,UAA8C,EAAA;IAC5E,MAAM,aAAa,GAAa,EAAE,CAAA;AAClC,IAAA,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,CAAC,CAAA;AAC3G,IAAA,KAAK,MAAM,IAAI,IAAI,cAAc,EAAE;QACjC,IACE,IAAI,KAAK,aAAa;YACtB,UAAU,CAAC,IAAI,CAAC;YAChB,MAAM,CAAC,UA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ourcesContent":["\nimport { isFunction } from '@tarojs/shared'\nimport Taro from '@tarojs/taro'\n\nimport { toKebabCase } from '../../utils'\n\nfunction generateMediaQueryStr (descriptor: Taro.MediaQueryObserver.descriptor) {\n const mediaQueryArr: string[] = []\n const descriptorMenu = ['width', 'minWidth', 'maxWidth', 'height', 'minHeight', 'maxHeight', 'orientation']\n for (const item of descriptorMenu) {\n if (\n item !== 'orientation' &&\n descriptor[item] &&\n Number(descriptor[item]) >= 0\n ) {\n mediaQueryArr.push(`(${(toKebabCase(item))}: ${Number(descriptor[item])}px)`)\n }\n if (item === 'orientation' && descriptor[item]) {\n mediaQueryArr.push(`(${toKebabCase(item)}: ${descriptor[item]})`)\n }\n }\n return mediaQueryArr.join(' and ')\n}\n\n\nexport class MediaQueryObserver implements Taro.MediaQueryObserver {\n private _mediaQueryObserver: MediaQueryList\n private _listener: (ev: MediaQueryListEvent) => void\n\n // 监听页面媒体查询变化情况\n public observe (descriptor: Taro.MediaQueryObserver.descriptor, callback: Taro.MediaQueryObserver.observeCallback): void {\n if (isFunction(callback)) {\n // 创建媒体查询对象\n this._mediaQueryObserver = window.matchMedia(generateMediaQueryStr(descriptor))\n // 监听器\n this._listener = (ev: MediaQueryListEvent) => {\n callback({ matches: ev.matches })\n }\n callback({ matches: this._mediaQueryObserver.matches })\n // 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'addEventListener'\n if ('addEventListener' in this._mediaQueryObserver) {\n this._mediaQueryObserver.addEventListener('change', this._listener)\n } else {\n // @ts-ignore\n this._mediaQueryObserver.addListener(this._listener)\n }\n }\n }\n\n // 停止监听,销毁媒体查询对象\n public disconnect (): void {\n if (this._mediaQueryObserver && this._listener) {\n // 兼容旧浏览器中 MediaQueryList 尚未继承于 EventTarget 导致不存在 'removeEventListener'\n if ('removeEventListener' in this._mediaQueryObserver) {\n this._mediaQueryObserver.removeEventListener('change', this._listener)\n } else {\n // @ts-ignore\n this._mediaQueryObserver.removeListener(this._listener)\n }\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,CAAA;AACnC,aAAC,CAAA;YACD,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC,CAAA;;AAEvD,YAAA,IAAI,kBAAkB,IAAI,IAAI,CAAC,mBAAmB,EAAE;gBAClD,IAAI,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;AACpE,aAAA;AAAM,iBAAA;;gBAEL,IAAI,CAAC,mBAAmB,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AACrD,aAAA;AACF,SAAA;KACF;;IAGM,UAAU,GAAA;AACf,QAAA,IAAI,IAAI,CAAC,mBAAmB,IAAI,IAAI,CAAC,SAAS,EAAE;;AAE9C,YAAA,IAAI,qBAAqB,IAAI,IAAI,CAAC,mBAAmB,EAAE;gBACrD,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,CAAA;AACvE,aAAA;AAAM,iBAAA;;gBAEL,IAAI,CAAC,mBAAmB,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;AACxD,aAAA;AACF,SAAA;KACF;AAEF;;;;"}
|
package/dist/index.cjs.d.ts
CHANGED
|
@@ -149,6 +149,7 @@ declare const offAccelerometerChange: typeof Taro.offAccelerometerChange;
|
|
|
149
149
|
// 无障碍
|
|
150
150
|
declare const checkIsOpenAccessibility: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
151
151
|
// 电量
|
|
152
|
+
// Note: 浏览器标准下不支持,其他实现方案不准确,不建议开发者使用
|
|
152
153
|
declare const getBatteryInfoSync: (option?: {}, ...args: any[]) => Promise<Partial<TaroGeneral.CallbackResult> & Record<string, unknown> & TaroGeneral.CallbackResult>;
|
|
153
154
|
declare const getBatteryInfo: typeof Taro.getBatteryInfo;
|
|
154
155
|
// 蓝牙-通用
|