@tarojs/taro-h5 3.6.7 → 3.6.9-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/ad/index.js +2 -2
- package/dist/api/ad/index.js.map +1 -1
- package/dist/api/ai/facial.js +3 -3
- package/dist/api/ai/facial.js.map +1 -1
- package/dist/api/ai/visual.js +2 -2
- package/dist/api/ai/visual.js.map +1 -1
- package/dist/api/alipay/index.js +1 -1
- package/dist/api/alipay/index.js.map +1 -1
- package/dist/api/base/crypto.js +1 -1
- package/dist/api/base/crypto.js.map +1 -1
- package/dist/api/base/debug.js +3 -3
- package/dist/api/base/debug.js.map +1 -1
- package/dist/api/base/index.d.ts +1 -2
- package/dist/api/base/index.js +3 -3
- package/dist/api/base/index.js.map +1 -1
- package/dist/api/base/performance.js +2 -2
- package/dist/api/base/performance.js.map +1 -1
- package/dist/api/base/system.js +2 -2
- package/dist/api/base/system.js.map +1 -1
- package/dist/api/base/update.js +2 -2
- package/dist/api/base/update.js.map +1 -1
- package/dist/api/base/weapp/app-event.js +7 -8
- package/dist/api/base/weapp/app-event.js.map +1 -1
- package/dist/api/canvas/CanvasContext.d.ts +2 -1
- package/dist/api/canvas/CanvasContext.js.map +1 -1
- package/dist/api/canvas/index.js +1 -1
- package/dist/api/canvas/index.js.map +1 -1
- package/dist/api/data-analysis/index.js +4 -4
- package/dist/api/data-analysis/index.js.map +1 -1
- package/dist/api/device/accelerometer.js +1 -2
- package/dist/api/device/accelerometer.js.map +1 -1
- package/dist/api/device/accessibility.js +1 -1
- package/dist/api/device/accessibility.js.map +1 -1
- package/dist/api/device/battery.js +1 -1
- package/dist/api/device/battery.js.map +1 -1
- package/dist/api/device/bluetooth-ble.js +16 -16
- package/dist/api/device/bluetooth-ble.js.map +1 -1
- package/dist/api/device/bluetooth-peripheral.js +3 -3
- package/dist/api/device/bluetooth-peripheral.js.map +1 -1
- package/dist/api/device/bluetooth.js +13 -13
- package/dist/api/device/bluetooth.js.map +1 -1
- package/dist/api/device/calendar.d.ts +3 -2
- package/dist/api/device/calendar.js +142 -3
- package/dist/api/device/calendar.js.map +1 -1
- package/dist/api/device/compass.js +1 -2
- package/dist/api/device/compass.js.map +1 -1
- package/dist/api/device/contact.js +2 -2
- package/dist/api/device/contact.js.map +1 -1
- package/dist/api/device/crypto.js +1 -1
- package/dist/api/device/crypto.js.map +1 -1
- package/dist/api/device/gyroscope.js +4 -4
- package/dist/api/device/gyroscope.js.map +1 -1
- package/dist/api/device/iBeacon.js +7 -7
- package/dist/api/device/iBeacon.js.map +1 -1
- package/dist/api/device/keyboard.js +4 -4
- package/dist/api/device/keyboard.js.map +1 -1
- package/dist/api/device/memory.js +2 -2
- package/dist/api/device/memory.js.map +1 -1
- package/dist/api/device/motion.js +1 -2
- package/dist/api/device/motion.js.map +1 -1
- package/dist/api/device/network.js +3 -3
- package/dist/api/device/network.js.map +1 -1
- package/dist/api/device/nfc.js +7 -7
- package/dist/api/device/nfc.js.map +1 -1
- package/dist/api/device/scan.js +1 -1
- package/dist/api/device/scan.js.map +1 -1
- package/dist/api/device/screen.js +6 -6
- package/dist/api/device/screen.js.map +1 -1
- package/dist/api/device/wifi.js +12 -12
- package/dist/api/device/wifi.js.map +1 -1
- package/dist/api/ext/index.js +2 -2
- package/dist/api/ext/index.js.map +1 -1
- package/dist/api/files/index.js +8 -8
- package/dist/api/files/index.js.map +1 -1
- package/dist/api/index.js +8 -3
- package/dist/api/index.js.map +1 -1
- package/dist/api/location/chooseLocation.js +9 -5
- package/dist/api/location/chooseLocation.js.map +1 -1
- package/dist/api/location/getLocation.js +1 -1
- package/dist/api/location/getLocation.js.map +1 -1
- package/dist/api/location/index.js +10 -10
- package/dist/api/location/index.js.map +1 -1
- package/dist/api/media/audio/index.js +8 -8
- package/dist/api/media/audio/index.js.map +1 -1
- package/dist/api/media/background-audio/index.js +8 -8
- package/dist/api/media/background-audio/index.js.map +1 -1
- package/dist/api/media/camera.js +1 -1
- package/dist/api/media/camera.js.map +1 -1
- package/dist/api/media/image/chooseImage.d.ts +1 -0
- package/dist/api/media/image/chooseImage.js +28 -71
- package/dist/api/media/image/chooseImage.js.map +1 -1
- package/dist/api/media/image/index.d.ts +4 -3
- package/dist/api/media/image/index.js +8 -9
- package/dist/api/media/image/index.js.map +1 -1
- package/dist/api/media/image/saveImageToPhotosAlbum.d.ts +3 -0
- package/dist/api/media/image/saveImageToPhotosAlbum.js +30 -0
- package/dist/api/media/image/saveImageToPhotosAlbum.js.map +1 -0
- package/dist/api/media/index.js +2 -2
- package/dist/api/media/live.js +2 -2
- package/dist/api/media/live.js.map +1 -1
- package/dist/api/media/map.js +1 -1
- package/dist/api/media/map.js.map +1 -1
- package/dist/api/media/media-recorder.js +1 -1
- package/dist/api/media/media-recorder.js.map +1 -1
- package/dist/api/media/recorder.js +3 -3
- package/dist/api/media/recorder.js.map +1 -1
- package/dist/api/media/video/chooseMedia.d.ts +6 -0
- package/dist/api/media/video/chooseMedia.js +208 -0
- package/dist/api/media/video/chooseMedia.js.map +1 -0
- package/dist/api/media/video/chooseVideo.d.ts +7 -0
- package/dist/api/media/video/chooseVideo.js +44 -0
- package/dist/api/media/video/chooseVideo.js.map +1 -0
- package/dist/api/media/video/getVideoInfo.d.ts +3 -0
- package/dist/api/media/video/getVideoInfo.js +63 -0
- package/dist/api/media/video/getVideoInfo.js.map +1 -0
- package/dist/api/media/video/index.d.ts +5 -8
- package/dist/api/media/video/index.js +8 -67
- package/dist/api/media/video/index.js.map +1 -1
- package/dist/api/media/video/saveVideoToPhotosAlbum.d.ts +3 -0
- package/dist/api/media/video/saveVideoToPhotosAlbum.js +30 -0
- package/dist/api/media/video/saveVideoToPhotosAlbum.js.map +1 -0
- package/dist/api/media/video-decoder.js +1 -1
- package/dist/api/media/video-decoder.js.map +1 -1
- package/dist/api/media/video-processing.js +1 -1
- package/dist/api/media/video-processing.js.map +1 -1
- package/dist/api/media/voip.js +14 -14
- package/dist/api/media/voip.js.map +1 -1
- package/dist/api/navigate/index.js +5 -5
- package/dist/api/navigate/index.js.map +1 -1
- package/dist/api/network/mdns.js +10 -10
- package/dist/api/network/mdns.js.map +1 -1
- package/dist/api/network/request/index.d.ts +1 -1
- package/dist/api/network/request/index.js +22 -17
- package/dist/api/network/request/index.js.map +1 -1
- package/dist/api/network/tcp.js +1 -1
- package/dist/api/network/tcp.js.map +1 -1
- package/dist/api/network/udp.js +1 -1
- package/dist/api/network/udp.js.map +1 -1
- package/dist/api/open-api/account.js +1 -1
- package/dist/api/open-api/account.js.map +1 -1
- package/dist/api/open-api/address.js +1 -1
- package/dist/api/open-api/address.js.map +1 -1
- package/dist/api/open-api/authorize.js +2 -2
- package/dist/api/open-api/authorize.js.map +1 -1
- package/dist/api/open-api/card.js +2 -2
- package/dist/api/open-api/card.js.map +1 -1
- package/dist/api/open-api/channels-live.js +6 -6
- package/dist/api/open-api/channels-live.js.map +1 -1
- package/dist/api/open-api/customer-service.js +1 -1
- package/dist/api/open-api/customer-service.js.map +1 -1
- package/dist/api/open-api/facial.js +4 -4
- package/dist/api/open-api/facial.js.map +1 -1
- package/dist/api/open-api/favorites.js +3 -3
- package/dist/api/open-api/favorites.js.map +1 -1
- package/dist/api/open-api/group.js +1 -1
- package/dist/api/open-api/group.js.map +1 -1
- package/dist/api/open-api/invoice.js +2 -2
- package/dist/api/open-api/invoice.js.map +1 -1
- package/dist/api/open-api/license-plate.js +1 -1
- package/dist/api/open-api/license-plate.js.map +1 -1
- package/dist/api/open-api/login.js +3 -3
- package/dist/api/open-api/login.js.map +1 -1
- package/dist/api/open-api/red-package.js +1 -1
- package/dist/api/open-api/red-package.js.map +1 -1
- package/dist/api/open-api/settings.js +2 -2
- package/dist/api/open-api/settings.js.map +1 -1
- package/dist/api/open-api/soter.js +3 -3
- package/dist/api/open-api/soter.js.map +1 -1
- package/dist/api/open-api/subscribe-message.js +2 -2
- package/dist/api/open-api/subscribe-message.js.map +1 -1
- package/dist/api/open-api/user-info.js +2 -2
- package/dist/api/open-api/user-info.js.map +1 -1
- package/dist/api/open-api/werun.js +2 -2
- package/dist/api/open-api/werun.js.map +1 -1
- package/dist/api/payment/index.js +2 -2
- package/dist/api/payment/index.js.map +1 -1
- package/dist/api/qq/index.js +1 -1
- package/dist/api/qq/index.js.map +1 -1
- package/dist/api/share/index.d.ts +10 -0
- package/dist/api/share/index.js +21 -11
- package/dist/api/share/index.js.map +1 -1
- package/dist/api/storage/background-fetch.js +4 -4
- package/dist/api/storage/background-fetch.js.map +1 -1
- package/dist/api/storage/index.js +2 -2
- package/dist/api/storage/index.js.map +1 -1
- package/dist/api/swan/index.js +21 -21
- package/dist/api/swan/index.js.map +1 -1
- package/dist/api/taro.js +1 -1
- package/dist/api/taro.js.map +1 -1
- package/dist/api/ui/background.js +2 -2
- package/dist/api/ui/background.js.map +1 -1
- package/dist/api/ui/interaction/index.d.ts +1 -1
- package/dist/api/ui/interaction/index.js +4 -4
- package/dist/api/ui/interaction/index.js.map +1 -1
- package/dist/api/ui/interaction/modal.js +6 -0
- package/dist/api/ui/interaction/modal.js.map +1 -1
- package/dist/api/ui/interaction/toast.js +4 -0
- package/dist/api/ui/interaction/toast.js.map +1 -1
- package/dist/api/ui/menu.js +1 -1
- package/dist/api/ui/menu.js.map +1 -1
- package/dist/api/ui/navigation-bar/index.js +3 -3
- package/dist/api/ui/navigation-bar/index.js.map +1 -1
- package/dist/api/ui/scroll/index.js +4 -3
- package/dist/api/ui/scroll/index.js.map +1 -1
- package/dist/api/ui/sticky.js +1 -1
- package/dist/api/ui/sticky.js.map +1 -1
- package/dist/api/ui/window.js +2 -2
- package/dist/api/ui/window.js.map +1 -1
- package/dist/api/worker/index.js +1 -1
- package/dist/api/worker/index.js.map +1 -1
- package/dist/api/wxml/IntersectionObserver.d.ts +1 -1
- package/dist/api/wxml/IntersectionObserver.js +8 -6
- package/dist/api/wxml/IntersectionObserver.js.map +1 -1
- package/dist/api/wxml/MediaQueryObserver.d.ts +1 -1
- package/dist/api/wxml/MediaQueryObserver.js.map +1 -1
- package/dist/api/wxml/selectorQuery.js +9 -6
- package/dist/api/wxml/selectorQuery.js.map +1 -1
- package/dist/index.cjs.d.ts +27 -13
- package/dist/index.cjs.js +3564 -20439
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.d.ts +27 -13
- package/dist/index.esm.js +3832 -20702
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/utils/helper.d.ts +2 -0
- package/dist/utils/helper.js +11 -0
- package/dist/utils/helper.js.map +1 -0
- package/dist/utils/index.d.ts +5 -3
- package/dist/utils/index.js +4 -9
- package/dist/utils/index.js.map +1 -1
- package/package.json +16 -10
- package/dist/_virtual/_commonjsHelpers.js +0 -35
- package/dist/_virtual/_commonjsHelpers.js.map +0 -1
- package/dist/_virtual/lodash.js +0 -4
- package/dist/_virtual/lodash.js.map +0 -1
- package/dist/node_modules/.pnpm/registry.npmjs.org_lodash@4.17.21/node_modules/lodash/lodash.js +0 -17220
- package/dist/node_modules/.pnpm/registry.npmjs.org_lodash@4.17.21/node_modules/lodash/lodash.js.map +0 -1
- package/dist/utils/lodash.d.ts +0 -3
- package/dist/utils/lodash.js +0 -32
- package/dist/utils/lodash.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
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;
|
|
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 = /* @__PURE__ */ 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;AACa,MAAA,kBAAkB,mBAAmB,qBAAqB,CAAC,oBAAoB,EAAC;AAEtF,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,22 +1,22 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../../utils/index.js';
|
|
2
2
|
|
|
3
3
|
// 蓝牙-低功耗中心设备
|
|
4
|
-
const writeBLECharacteristicValue = temporarilyNotSupport('writeBLECharacteristicValue');
|
|
5
|
-
const setBLEMTU = temporarilyNotSupport('setBLEMTU');
|
|
6
|
-
const readBLECharacteristicValue = temporarilyNotSupport('readBLECharacteristicValue');
|
|
7
|
-
const onBLEMTUChange = temporarilyNotSupport('onBLEMTUChange');
|
|
8
|
-
const onBLEConnectionStateChange = temporarilyNotSupport('onBLEConnectionStateChange');
|
|
9
|
-
const onBLECharacteristicValueChange = temporarilyNotSupport('onBLECharacteristicValueChange');
|
|
10
|
-
const offBLEMTUChange = temporarilyNotSupport('offBLEMTUChange');
|
|
11
|
-
const offBLEConnectionStateChange = temporarilyNotSupport('offBLEConnectionStateChange');
|
|
12
|
-
const offBLECharacteristicValueChange = temporarilyNotSupport('offBLECharacteristicValueChange');
|
|
13
|
-
const notifyBLECharacteristicValueChange = temporarilyNotSupport('notifyBLECharacteristicValueChange');
|
|
14
|
-
const getBLEMTU = temporarilyNotSupport('getBLEMTU');
|
|
15
|
-
const getBLEDeviceServices = temporarilyNotSupport('getBLEDeviceServices');
|
|
16
|
-
const getBLEDeviceRSSI = temporarilyNotSupport('getBLEDeviceRSSI');
|
|
17
|
-
const getBLEDeviceCharacteristics = temporarilyNotSupport('getBLEDeviceCharacteristics');
|
|
18
|
-
const createBLEConnection = temporarilyNotSupport('createBLEConnection');
|
|
19
|
-
const closeBLEConnection = temporarilyNotSupport('closeBLEConnection');
|
|
4
|
+
const writeBLECharacteristicValue = /* @__PURE__ */ temporarilyNotSupport('writeBLECharacteristicValue');
|
|
5
|
+
const setBLEMTU = /* @__PURE__ */ temporarilyNotSupport('setBLEMTU');
|
|
6
|
+
const readBLECharacteristicValue = /* @__PURE__ */ temporarilyNotSupport('readBLECharacteristicValue');
|
|
7
|
+
const onBLEMTUChange = /* @__PURE__ */ temporarilyNotSupport('onBLEMTUChange');
|
|
8
|
+
const onBLEConnectionStateChange = /* @__PURE__ */ temporarilyNotSupport('onBLEConnectionStateChange');
|
|
9
|
+
const onBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('onBLECharacteristicValueChange');
|
|
10
|
+
const offBLEMTUChange = /* @__PURE__ */ temporarilyNotSupport('offBLEMTUChange');
|
|
11
|
+
const offBLEConnectionStateChange = /* @__PURE__ */ temporarilyNotSupport('offBLEConnectionStateChange');
|
|
12
|
+
const offBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('offBLECharacteristicValueChange');
|
|
13
|
+
const notifyBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('notifyBLECharacteristicValueChange');
|
|
14
|
+
const getBLEMTU = /* @__PURE__ */ temporarilyNotSupport('getBLEMTU');
|
|
15
|
+
const getBLEDeviceServices = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceServices');
|
|
16
|
+
const getBLEDeviceRSSI = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceRSSI');
|
|
17
|
+
const getBLEDeviceCharacteristics = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceCharacteristics');
|
|
18
|
+
const createBLEConnection = /* @__PURE__ */ temporarilyNotSupport('createBLEConnection');
|
|
19
|
+
const closeBLEConnection = /* @__PURE__ */ temporarilyNotSupport('closeBLEConnection');
|
|
20
20
|
|
|
21
21
|
export { closeBLEConnection, createBLEConnection, getBLEDeviceCharacteristics, getBLEDeviceRSSI, getBLEDeviceServices, getBLEMTU, notifyBLECharacteristicValueChange, offBLECharacteristicValueChange, offBLEConnectionStateChange, offBLEMTUChange, onBLECharacteristicValueChange, onBLEConnectionStateChange, onBLEMTUChange, readBLECharacteristicValue, setBLEMTU, writeBLECharacteristicValue };
|
|
22
22
|
//# sourceMappingURL=bluetooth-ble.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bluetooth-ble.js","sources":["../../../src/api/device/bluetooth-ble.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 蓝牙-低功耗中心设备\nexport const writeBLECharacteristicValue = temporarilyNotSupport('writeBLECharacteristicValue')\nexport const setBLEMTU = temporarilyNotSupport('setBLEMTU')\nexport const readBLECharacteristicValue = temporarilyNotSupport('readBLECharacteristicValue')\nexport const onBLEMTUChange = temporarilyNotSupport('onBLEMTUChange')\nexport const onBLEConnectionStateChange = temporarilyNotSupport('onBLEConnectionStateChange')\nexport const onBLECharacteristicValueChange = temporarilyNotSupport('onBLECharacteristicValueChange')\nexport const offBLEMTUChange = temporarilyNotSupport('offBLEMTUChange')\nexport const offBLEConnectionStateChange = temporarilyNotSupport('offBLEConnectionStateChange')\nexport const offBLECharacteristicValueChange = temporarilyNotSupport('offBLECharacteristicValueChange')\nexport const notifyBLECharacteristicValueChange = temporarilyNotSupport('notifyBLECharacteristicValueChange')\nexport const getBLEMTU = temporarilyNotSupport('getBLEMTU')\nexport const getBLEDeviceServices = temporarilyNotSupport('getBLEDeviceServices')\nexport const getBLEDeviceRSSI = temporarilyNotSupport('getBLEDeviceRSSI')\nexport const getBLEDeviceCharacteristics = temporarilyNotSupport('getBLEDeviceCharacteristics')\nexport const createBLEConnection = temporarilyNotSupport('createBLEConnection')\nexport const closeBLEConnection = temporarilyNotSupport('closeBLEConnection')\n"],"names":[],"mappings":";;AAEA;
|
|
1
|
+
{"version":3,"file":"bluetooth-ble.js","sources":["../../../src/api/device/bluetooth-ble.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 蓝牙-低功耗中心设备\nexport const writeBLECharacteristicValue = /* @__PURE__ */ temporarilyNotSupport('writeBLECharacteristicValue')\nexport const setBLEMTU = /* @__PURE__ */ temporarilyNotSupport('setBLEMTU')\nexport const readBLECharacteristicValue = /* @__PURE__ */ temporarilyNotSupport('readBLECharacteristicValue')\nexport const onBLEMTUChange = /* @__PURE__ */ temporarilyNotSupport('onBLEMTUChange')\nexport const onBLEConnectionStateChange = /* @__PURE__ */ temporarilyNotSupport('onBLEConnectionStateChange')\nexport const onBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('onBLECharacteristicValueChange')\nexport const offBLEMTUChange = /* @__PURE__ */ temporarilyNotSupport('offBLEMTUChange')\nexport const offBLEConnectionStateChange = /* @__PURE__ */ temporarilyNotSupport('offBLEConnectionStateChange')\nexport const offBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('offBLECharacteristicValueChange')\nexport const notifyBLECharacteristicValueChange = /* @__PURE__ */ temporarilyNotSupport('notifyBLECharacteristicValueChange')\nexport const getBLEMTU = /* @__PURE__ */ temporarilyNotSupport('getBLEMTU')\nexport const getBLEDeviceServices = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceServices')\nexport const getBLEDeviceRSSI = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceRSSI')\nexport const getBLEDeviceCharacteristics = /* @__PURE__ */ temporarilyNotSupport('getBLEDeviceCharacteristics')\nexport const createBLEConnection = /* @__PURE__ */ temporarilyNotSupport('createBLEConnection')\nexport const closeBLEConnection = /* @__PURE__ */ temporarilyNotSupport('closeBLEConnection')\n"],"names":[],"mappings":";;AAEA;AACa,MAAA,2BAA2B,mBAAmB,qBAAqB,CAAC,6BAA6B,EAAC;AAClG,MAAA,SAAS,mBAAmB,qBAAqB,CAAC,WAAW,EAAC;AAC9D,MAAA,0BAA0B,mBAAmB,qBAAqB,CAAC,4BAA4B,EAAC;AAChG,MAAA,cAAc,mBAAmB,qBAAqB,CAAC,gBAAgB,EAAC;AACxE,MAAA,0BAA0B,mBAAmB,qBAAqB,CAAC,4BAA4B,EAAC;AAChG,MAAA,8BAA8B,mBAAmB,qBAAqB,CAAC,gCAAgC,EAAC;AACxG,MAAA,eAAe,mBAAmB,qBAAqB,CAAC,iBAAiB,EAAC;AAC1E,MAAA,2BAA2B,mBAAmB,qBAAqB,CAAC,6BAA6B,EAAC;AAClG,MAAA,+BAA+B,mBAAmB,qBAAqB,CAAC,iCAAiC,EAAC;AAC1G,MAAA,kCAAkC,mBAAmB,qBAAqB,CAAC,oCAAoC,EAAC;AAChH,MAAA,SAAS,mBAAmB,qBAAqB,CAAC,WAAW,EAAC;AAC9D,MAAA,oBAAoB,mBAAmB,qBAAqB,CAAC,sBAAsB,EAAC;AACpF,MAAA,gBAAgB,mBAAmB,qBAAqB,CAAC,kBAAkB,EAAC;AAC5E,MAAA,2BAA2B,mBAAmB,qBAAqB,CAAC,6BAA6B,EAAC;AAClG,MAAA,mBAAmB,mBAAmB,qBAAqB,CAAC,qBAAqB,EAAC;AAClF,MAAA,kBAAkB,mBAAmB,qBAAqB,CAAC,oBAAoB;;;;"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../../utils/index.js';
|
|
2
2
|
|
|
3
3
|
// 蓝牙-低功耗外围设备
|
|
4
|
-
const onBLEPeripheralConnectionStateChanged = temporarilyNotSupport('onBLEPeripheralConnectionStateChanged');
|
|
5
|
-
const offBLEPeripheralConnectionStateChanged = temporarilyNotSupport('offBLEPeripheralConnectionStateChanged');
|
|
6
|
-
const createBLEPeripheralServer = temporarilyNotSupport('createBLEPeripheralServer');
|
|
4
|
+
const onBLEPeripheralConnectionStateChanged = /* @__PURE__ */ temporarilyNotSupport('onBLEPeripheralConnectionStateChanged');
|
|
5
|
+
const offBLEPeripheralConnectionStateChanged = /* @__PURE__ */ temporarilyNotSupport('offBLEPeripheralConnectionStateChanged');
|
|
6
|
+
const createBLEPeripheralServer = /* @__PURE__ */ temporarilyNotSupport('createBLEPeripheralServer');
|
|
7
7
|
|
|
8
8
|
export { createBLEPeripheralServer, offBLEPeripheralConnectionStateChanged, onBLEPeripheralConnectionStateChanged };
|
|
9
9
|
//# sourceMappingURL=bluetooth-peripheral.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bluetooth-peripheral.js","sources":["../../../src/api/device/bluetooth-peripheral.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 蓝牙-低功耗外围设备\nexport const onBLEPeripheralConnectionStateChanged = temporarilyNotSupport('onBLEPeripheralConnectionStateChanged')\nexport const offBLEPeripheralConnectionStateChanged = temporarilyNotSupport('offBLEPeripheralConnectionStateChanged')\nexport const createBLEPeripheralServer = temporarilyNotSupport('createBLEPeripheralServer')\n"],"names":[],"mappings":";;AAEA;
|
|
1
|
+
{"version":3,"file":"bluetooth-peripheral.js","sources":["../../../src/api/device/bluetooth-peripheral.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 蓝牙-低功耗外围设备\nexport const onBLEPeripheralConnectionStateChanged = /* @__PURE__ */ temporarilyNotSupport('onBLEPeripheralConnectionStateChanged')\nexport const offBLEPeripheralConnectionStateChanged = /* @__PURE__ */ temporarilyNotSupport('offBLEPeripheralConnectionStateChanged')\nexport const createBLEPeripheralServer = /* @__PURE__ */ temporarilyNotSupport('createBLEPeripheralServer')\n"],"names":[],"mappings":";;AAEA;AACa,MAAA,qCAAqC,mBAAmB,qBAAqB,CAAC,uCAAuC,EAAC;AACtH,MAAA,sCAAsC,mBAAmB,qBAAqB,CAAC,wCAAwC,EAAC;AACxH,MAAA,yBAAyB,mBAAmB,qBAAqB,CAAC,2BAA2B;;;;"}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../../utils/index.js';
|
|
2
2
|
|
|
3
3
|
// 蓝牙-通用
|
|
4
|
-
const stopBluetoothDevicesDiscovery = temporarilyNotSupport('stopBluetoothDevicesDiscovery');
|
|
5
|
-
const startBluetoothDevicesDiscovery = temporarilyNotSupport('startBluetoothDevicesDiscovery');
|
|
6
|
-
const openBluetoothAdapter = temporarilyNotSupport('openBluetoothAdapter');
|
|
7
|
-
const onBluetoothDeviceFound = temporarilyNotSupport('onBluetoothDeviceFound');
|
|
8
|
-
const onBluetoothAdapterStateChange = temporarilyNotSupport('onBluetoothAdapterStateChange');
|
|
9
|
-
const offBluetoothDeviceFound = temporarilyNotSupport('offBluetoothDeviceFound');
|
|
10
|
-
const offBluetoothAdapterStateChange = temporarilyNotSupport('offBluetoothAdapterStateChange');
|
|
11
|
-
const makeBluetoothPair = temporarilyNotSupport('makeBluetoothPair');
|
|
12
|
-
const isBluetoothDevicePaired = temporarilyNotSupport('isBluetoothDevicePaired');
|
|
13
|
-
const getConnectedBluetoothDevices = temporarilyNotSupport('getConnectedBluetoothDevices');
|
|
14
|
-
const getBluetoothDevices = temporarilyNotSupport('getBluetoothDevices');
|
|
15
|
-
const getBluetoothAdapterState = temporarilyNotSupport('getBluetoothAdapterState');
|
|
16
|
-
const closeBluetoothAdapter = temporarilyNotSupport('closeBluetoothAdapter');
|
|
4
|
+
const stopBluetoothDevicesDiscovery = /* @__PURE__ */ temporarilyNotSupport('stopBluetoothDevicesDiscovery');
|
|
5
|
+
const startBluetoothDevicesDiscovery = /* @__PURE__ */ temporarilyNotSupport('startBluetoothDevicesDiscovery');
|
|
6
|
+
const openBluetoothAdapter = /* @__PURE__ */ temporarilyNotSupport('openBluetoothAdapter');
|
|
7
|
+
const onBluetoothDeviceFound = /* @__PURE__ */ temporarilyNotSupport('onBluetoothDeviceFound');
|
|
8
|
+
const onBluetoothAdapterStateChange = /* @__PURE__ */ temporarilyNotSupport('onBluetoothAdapterStateChange');
|
|
9
|
+
const offBluetoothDeviceFound = /* @__PURE__ */ temporarilyNotSupport('offBluetoothDeviceFound');
|
|
10
|
+
const offBluetoothAdapterStateChange = /* @__PURE__ */ temporarilyNotSupport('offBluetoothAdapterStateChange');
|
|
11
|
+
const makeBluetoothPair = /* @__PURE__ */ temporarilyNotSupport('makeBluetoothPair');
|
|
12
|
+
const isBluetoothDevicePaired = /* @__PURE__ */ temporarilyNotSupport('isBluetoothDevicePaired');
|
|
13
|
+
const getConnectedBluetoothDevices = /* @__PURE__ */ temporarilyNotSupport('getConnectedBluetoothDevices');
|
|
14
|
+
const getBluetoothDevices = /* @__PURE__ */ temporarilyNotSupport('getBluetoothDevices');
|
|
15
|
+
const getBluetoothAdapterState = /* @__PURE__ */ temporarilyNotSupport('getBluetoothAdapterState');
|
|
16
|
+
const closeBluetoothAdapter = /* @__PURE__ */ temporarilyNotSupport('closeBluetoothAdapter');
|
|
17
17
|
|
|
18
18
|
export { closeBluetoothAdapter, getBluetoothAdapterState, getBluetoothDevices, getConnectedBluetoothDevices, isBluetoothDevicePaired, makeBluetoothPair, offBluetoothAdapterStateChange, offBluetoothDeviceFound, onBluetoothAdapterStateChange, onBluetoothDeviceFound, openBluetoothAdapter, startBluetoothDevicesDiscovery, stopBluetoothDevicesDiscovery };
|
|
19
19
|
//# sourceMappingURL=bluetooth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bluetooth.js","sources":["../../../src/api/device/bluetooth.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 蓝牙-通用\nexport const stopBluetoothDevicesDiscovery = temporarilyNotSupport('stopBluetoothDevicesDiscovery')\nexport const startBluetoothDevicesDiscovery = temporarilyNotSupport('startBluetoothDevicesDiscovery')\nexport const openBluetoothAdapter = temporarilyNotSupport('openBluetoothAdapter')\nexport const onBluetoothDeviceFound = temporarilyNotSupport('onBluetoothDeviceFound')\nexport const onBluetoothAdapterStateChange = temporarilyNotSupport('onBluetoothAdapterStateChange')\nexport const offBluetoothDeviceFound = temporarilyNotSupport('offBluetoothDeviceFound')\nexport const offBluetoothAdapterStateChange = temporarilyNotSupport('offBluetoothAdapterStateChange')\nexport const makeBluetoothPair = temporarilyNotSupport('makeBluetoothPair')\nexport const isBluetoothDevicePaired = temporarilyNotSupport('isBluetoothDevicePaired')\nexport const getConnectedBluetoothDevices = temporarilyNotSupport('getConnectedBluetoothDevices')\nexport const getBluetoothDevices = temporarilyNotSupport('getBluetoothDevices')\nexport const getBluetoothAdapterState = temporarilyNotSupport('getBluetoothAdapterState')\nexport const closeBluetoothAdapter = temporarilyNotSupport('closeBluetoothAdapter')\n"],"names":[],"mappings":";;AAEA;
|
|
1
|
+
{"version":3,"file":"bluetooth.js","sources":["../../../src/api/device/bluetooth.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 蓝牙-通用\nexport const stopBluetoothDevicesDiscovery = /* @__PURE__ */ temporarilyNotSupport('stopBluetoothDevicesDiscovery')\nexport const startBluetoothDevicesDiscovery = /* @__PURE__ */ temporarilyNotSupport('startBluetoothDevicesDiscovery')\nexport const openBluetoothAdapter = /* @__PURE__ */ temporarilyNotSupport('openBluetoothAdapter')\nexport const onBluetoothDeviceFound = /* @__PURE__ */ temporarilyNotSupport('onBluetoothDeviceFound')\nexport const onBluetoothAdapterStateChange = /* @__PURE__ */ temporarilyNotSupport('onBluetoothAdapterStateChange')\nexport const offBluetoothDeviceFound = /* @__PURE__ */ temporarilyNotSupport('offBluetoothDeviceFound')\nexport const offBluetoothAdapterStateChange = /* @__PURE__ */ temporarilyNotSupport('offBluetoothAdapterStateChange')\nexport const makeBluetoothPair = /* @__PURE__ */ temporarilyNotSupport('makeBluetoothPair')\nexport const isBluetoothDevicePaired = /* @__PURE__ */ temporarilyNotSupport('isBluetoothDevicePaired')\nexport const getConnectedBluetoothDevices = /* @__PURE__ */ temporarilyNotSupport('getConnectedBluetoothDevices')\nexport const getBluetoothDevices = /* @__PURE__ */ temporarilyNotSupport('getBluetoothDevices')\nexport const getBluetoothAdapterState = /* @__PURE__ */ temporarilyNotSupport('getBluetoothAdapterState')\nexport const closeBluetoothAdapter = /* @__PURE__ */ temporarilyNotSupport('closeBluetoothAdapter')\n"],"names":[],"mappings":";;AAEA;AACa,MAAA,6BAA6B,mBAAmB,qBAAqB,CAAC,+BAA+B,EAAC;AACtG,MAAA,8BAA8B,mBAAmB,qBAAqB,CAAC,gCAAgC,EAAC;AACxG,MAAA,oBAAoB,mBAAmB,qBAAqB,CAAC,sBAAsB,EAAC;AACpF,MAAA,sBAAsB,mBAAmB,qBAAqB,CAAC,wBAAwB,EAAC;AACxF,MAAA,6BAA6B,mBAAmB,qBAAqB,CAAC,+BAA+B,EAAC;AACtG,MAAA,uBAAuB,mBAAmB,qBAAqB,CAAC,yBAAyB,EAAC;AAC1F,MAAA,8BAA8B,mBAAmB,qBAAqB,CAAC,gCAAgC,EAAC;AACxG,MAAA,iBAAiB,mBAAmB,qBAAqB,CAAC,mBAAmB,EAAC;AAC9E,MAAA,uBAAuB,mBAAmB,qBAAqB,CAAC,yBAAyB,EAAC;AAC1F,MAAA,4BAA4B,mBAAmB,qBAAqB,CAAC,8BAA8B,EAAC;AACpG,MAAA,mBAAmB,mBAAmB,qBAAqB,CAAC,qBAAqB,EAAC;AAClF,MAAA,wBAAwB,mBAAmB,qBAAqB,CAAC,0BAA0B,EAAC;AAC5F,MAAA,qBAAqB,mBAAmB,qBAAqB,CAAC,uBAAuB;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
declare const
|
|
1
|
+
import Taro from '@tarojs/api';
|
|
2
|
+
declare const addPhoneRepeatCalendar: typeof Taro.addPhoneRepeatCalendar;
|
|
3
|
+
declare const addPhoneCalendar: typeof Taro.addPhoneCalendar;
|
|
3
4
|
export { addPhoneRepeatCalendar, addPhoneCalendar };
|
|
@@ -1,8 +1,147 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as ics from 'ics';
|
|
2
|
+
import { shouldBeObject, getParameterError } from '../../utils/index.js';
|
|
3
|
+
import { MethodHandler } from '../../utils/handler.js';
|
|
4
|
+
import { createDownload } from '../../utils/helper.js';
|
|
2
5
|
|
|
3
6
|
// 日历
|
|
4
|
-
const addPhoneRepeatCalendar =
|
|
5
|
-
const
|
|
7
|
+
const addPhoneRepeatCalendar = (options) => {
|
|
8
|
+
const methodName = 'addPhoneRepeatCalendar';
|
|
9
|
+
// options must be an Object
|
|
10
|
+
const isObject = shouldBeObject(options);
|
|
11
|
+
if (!isObject.flag) {
|
|
12
|
+
const res = { errMsg: `${methodName}:fail ${isObject.msg}` };
|
|
13
|
+
console.error(res.errMsg);
|
|
14
|
+
return Promise.reject(res);
|
|
15
|
+
}
|
|
16
|
+
const { title, startTime = new Date().getTime(), allDay = false, description = '', location = '', endTime, alarm = true, alarmOffset = 0, repeatInterval = 'month', repeatEndTime, success, fail, complete, } = options;
|
|
17
|
+
const handle = new MethodHandler({ name: methodName, success, fail, complete });
|
|
18
|
+
if (typeof title !== 'string') {
|
|
19
|
+
return handle.fail({
|
|
20
|
+
errMsg: getParameterError({
|
|
21
|
+
para: 'title',
|
|
22
|
+
correct: 'String',
|
|
23
|
+
wrong: title
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const start = new Date(startTime);
|
|
28
|
+
const end = new Date(endTime || startTime);
|
|
29
|
+
if (!endTime && allDay) {
|
|
30
|
+
end.setDate(end.getDate() + 1);
|
|
31
|
+
}
|
|
32
|
+
const interval = 1000 * 60 * 60 * 24;
|
|
33
|
+
let days = 1;
|
|
34
|
+
let repeat = 1;
|
|
35
|
+
if (repeatEndTime) {
|
|
36
|
+
const repeatEnd = new Date(repeatEndTime);
|
|
37
|
+
if (repeatEnd < start) {
|
|
38
|
+
return handle.fail({
|
|
39
|
+
errMsg: 'repeatEndTime must be greater than startTime'
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
switch (repeatInterval) {
|
|
43
|
+
case 'week':
|
|
44
|
+
days = 7;
|
|
45
|
+
break;
|
|
46
|
+
case 'month':
|
|
47
|
+
days = 30;
|
|
48
|
+
break;
|
|
49
|
+
case 'year':
|
|
50
|
+
days = 365;
|
|
51
|
+
break;
|
|
52
|
+
default:
|
|
53
|
+
}
|
|
54
|
+
repeat = Math.ceil((repeatEnd.getTime() - start.getTime()) / (interval * days));
|
|
55
|
+
}
|
|
56
|
+
const { error, value } = ics.createEvent({
|
|
57
|
+
title,
|
|
58
|
+
start: parseTime2Array(start, allDay),
|
|
59
|
+
description,
|
|
60
|
+
location,
|
|
61
|
+
end: parseTime2Array(end, allDay),
|
|
62
|
+
alarms: alarm ? [{
|
|
63
|
+
action: 'display',
|
|
64
|
+
description,
|
|
65
|
+
trigger: {
|
|
66
|
+
before: true,
|
|
67
|
+
seconds: alarmOffset,
|
|
68
|
+
},
|
|
69
|
+
duration: {
|
|
70
|
+
days,
|
|
71
|
+
},
|
|
72
|
+
repeat,
|
|
73
|
+
}] : [],
|
|
74
|
+
});
|
|
75
|
+
if (error || !value) {
|
|
76
|
+
return handle.fail({
|
|
77
|
+
errMsg: error === null || error === void 0 ? void 0 : error.message
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
const url = URL.createObjectURL(new Blob([value]));
|
|
81
|
+
createDownload(url, `${title}.ics`);
|
|
82
|
+
return handle.success();
|
|
83
|
+
};
|
|
84
|
+
const addPhoneCalendar = (options) => {
|
|
85
|
+
const methodName = 'addPhoneCalendar';
|
|
86
|
+
// options must be an Object
|
|
87
|
+
const isObject = shouldBeObject(options);
|
|
88
|
+
if (!isObject.flag) {
|
|
89
|
+
const res = { errMsg: `${methodName}:fail ${isObject.msg}` };
|
|
90
|
+
console.error(res.errMsg);
|
|
91
|
+
return Promise.reject(res);
|
|
92
|
+
}
|
|
93
|
+
const { title, startTime = new Date().getTime(), allDay = false, description = '', location = '', endTime, alarm = true, alarmOffset = 0, success, fail, complete, } = options;
|
|
94
|
+
const handle = new MethodHandler({ name: methodName, success, fail, complete });
|
|
95
|
+
if (typeof title !== 'string') {
|
|
96
|
+
return handle.fail({
|
|
97
|
+
errMsg: getParameterError({
|
|
98
|
+
para: 'title',
|
|
99
|
+
correct: 'String',
|
|
100
|
+
wrong: title
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
const start = new Date(startTime);
|
|
105
|
+
const end = new Date(endTime || startTime);
|
|
106
|
+
if (!endTime && allDay) {
|
|
107
|
+
end.setDate(end.getDate() + 1);
|
|
108
|
+
}
|
|
109
|
+
const { error, value } = ics.createEvent({
|
|
110
|
+
title,
|
|
111
|
+
start: parseTime2Array(start, allDay),
|
|
112
|
+
description,
|
|
113
|
+
location,
|
|
114
|
+
end: parseTime2Array(end, allDay),
|
|
115
|
+
alarms: alarm ? [{
|
|
116
|
+
action: 'display',
|
|
117
|
+
description,
|
|
118
|
+
trigger: {
|
|
119
|
+
before: true,
|
|
120
|
+
seconds: alarmOffset,
|
|
121
|
+
},
|
|
122
|
+
}] : [],
|
|
123
|
+
});
|
|
124
|
+
if (error || !value) {
|
|
125
|
+
return handle.fail({
|
|
126
|
+
errMsg: error === null || error === void 0 ? void 0 : error.message
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
const url = URL.createObjectURL(new Blob([value]));
|
|
130
|
+
createDownload(url, `${title}.ics`);
|
|
131
|
+
return handle.success();
|
|
132
|
+
};
|
|
133
|
+
function parseTime2Array(time, allDay = false) {
|
|
134
|
+
const t = new Date(time);
|
|
135
|
+
const timeArr = [
|
|
136
|
+
t.getFullYear(),
|
|
137
|
+
t.getMonth() + 1,
|
|
138
|
+
t.getDate(),
|
|
139
|
+
];
|
|
140
|
+
if (!allDay) {
|
|
141
|
+
timeArr.push(t.getHours(), t.getMinutes());
|
|
142
|
+
}
|
|
143
|
+
return timeArr;
|
|
144
|
+
}
|
|
6
145
|
|
|
7
146
|
export { addPhoneCalendar, addPhoneRepeatCalendar };
|
|
8
147
|
//# sourceMappingURL=calendar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calendar.js","sources":["../../../src/api/device/calendar.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"calendar.js","sources":["../../../src/api/device/calendar.ts"],"sourcesContent":["import Taro from '@tarojs/api'\nimport * as ics from 'ics'\n\nimport { createDownload, getParameterError, shouldBeObject } from '../../utils'\nimport { MethodHandler } from '../../utils/handler'\n\nimport type { DateArray } from 'ics'\n\n// 日历\nexport const addPhoneRepeatCalendar: typeof Taro.addPhoneRepeatCalendar = (options) => {\n const methodName = 'addPhoneRepeatCalendar'\n // options must be an Object\n const isObject = shouldBeObject(options)\n if (!isObject.flag) {\n const res = { errMsg: `${methodName}:fail ${isObject.msg}` }\n console.error(res.errMsg)\n return Promise.reject(res)\n }\n\n const {\n title,\n startTime = new Date().getTime(),\n allDay = false,\n description = '',\n location = '',\n endTime,\n alarm = true,\n alarmOffset = 0,\n repeatInterval = 'month',\n repeatEndTime,\n success,\n fail,\n complete,\n } = options\n const handle = new MethodHandler({ name: methodName, success, fail, complete })\n if (typeof title !== 'string') {\n return handle.fail({\n errMsg: getParameterError({\n para: 'title',\n correct: 'String',\n wrong: title\n })\n })\n }\n\n const start = new Date(startTime)\n const end = new Date(endTime || startTime)\n if (!endTime && allDay) {\n end.setDate(end.getDate() + 1)\n }\n\n const interval = 1000 * 60 * 60 * 24\n let days = 1\n let repeat = 1\n if (repeatEndTime) {\n const repeatEnd = new Date(repeatEndTime)\n if (repeatEnd < start) {\n return handle.fail({\n errMsg: 'repeatEndTime must be greater than startTime'\n })\n }\n switch (repeatInterval) {\n case 'week':\n days = 7\n break\n case 'month':\n days = 30\n break\n case 'year':\n days = 365\n break\n default:\n }\n repeat = Math.ceil((repeatEnd.getTime() - start.getTime()) / (interval * days))\n }\n const { error, value } = ics.createEvent({\n title,\n start: parseTime2Array(start, allDay),\n description,\n location,\n end: parseTime2Array(end, allDay),\n alarms: alarm ? [{\n action: 'display',\n description,\n trigger: {\n before: true,\n seconds: alarmOffset,\n },\n duration: {\n days,\n },\n repeat,\n }] : [],\n })\n if (error || !value) {\n return handle.fail({\n errMsg: error?.message\n })\n }\n const url = URL.createObjectURL(new Blob([value]))\n createDownload(url, `${title}.ics`)\n return handle.success()\n}\n\nexport const addPhoneCalendar: typeof Taro.addPhoneCalendar = (options) => {\n const methodName = 'addPhoneCalendar'\n // options must be an Object\n const isObject = shouldBeObject(options)\n if (!isObject.flag) {\n const res = { errMsg: `${methodName}:fail ${isObject.msg}` }\n console.error(res.errMsg)\n return Promise.reject(res)\n }\n\n const {\n title,\n startTime = new Date().getTime(),\n allDay = false,\n description = '',\n location = '',\n endTime,\n alarm = true,\n alarmOffset = 0,\n success,\n fail,\n complete,\n } = options\n const handle = new MethodHandler({ name: methodName, success, fail, complete })\n if (typeof title !== 'string') {\n return handle.fail({\n errMsg: getParameterError({\n para: 'title',\n correct: 'String',\n wrong: title\n })\n })\n }\n\n const start = new Date(startTime)\n const end = new Date(endTime || startTime)\n if (!endTime && allDay) {\n end.setDate(end.getDate() + 1)\n }\n const { error, value } = ics.createEvent({\n title,\n start: parseTime2Array(start, allDay),\n description,\n location,\n end: parseTime2Array(end, allDay),\n alarms: alarm ? [{\n action: 'display',\n description,\n trigger: {\n before: true,\n seconds: alarmOffset,\n },\n }] : [],\n })\n if (error || !value) {\n return handle.fail({\n errMsg: error?.message\n })\n }\n const url = URL.createObjectURL(new Blob([value]))\n createDownload(url, `${title}.ics`)\n return handle.success()\n}\n\nfunction parseTime2Array (time: Date, allDay = false): DateArray {\n const t = new Date(time)\n const timeArr: DateArray = [\n t.getFullYear(),\n t.getMonth() + 1,\n t.getDate(),\n ]\n if (!allDay) {\n timeArr.push(t.getHours(), t.getMinutes())\n }\n return timeArr\n}\n"],"names":[],"mappings":";;;;;AAQA;AACa,MAAA,sBAAsB,GAAuC,CAAC,OAAO,KAAI;IACpF,MAAM,UAAU,GAAG,wBAAwB,CAAA;;AAE3C,IAAA,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,CAAA;AACxC,IAAA,IAAI,CAA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;QACnB,OAAO,MAAM,CAAC,IAAI,CAAC;AACjB,YAAA,MAAM,EAAE,KAAK,KAAA,IAAA,IAAL,KAAK,KAAL,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,KAAK,CAAE,OAAO;AACvB,SAAA,CAAC,CAAA;AACH,KAAA;AACD,IAAA,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;AAClD,IAAA,cAAc,CAAC,GAAG,EAAE,GAAG,KAAK,CAAA,IAAA,CAAM,CAAC,CAAA;AACnC,IAAA,OAAO,MAAM,CAAC,OAAO,EAAE,CAAA;AACzB,EAAC;AAED,SAAS,eAAe,CAAE,IAAU,EAAE,MAAM,GAAG,KAAK,EAAA;AAClD,IAAA,MAAM,CAAC,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,CAAA;AACxB,IAAA,MAAM,OAAO,GAAc;QACzB,CAAC,CAAC,WAAW,EAAE;AACf,QAAA,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC;QAChB,CAAC,CAAC,OAAO,EAAE;KACZ,CAAA;IACD,IAAI,CAAC,MAAM,EAAE;AACX,QAAA,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAA;AAC3C,KAAA;AACD,IAAA,OAAO,OAAO,CAAA;AAChB;;;;"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import throttle from 'lodash-es/throttle';
|
|
2
2
|
import { CallbackManager, MethodHandler } from '../../utils/handler.js';
|
|
3
3
|
import { getDeviceInfo } from '../base/system.js';
|
|
4
|
-
import { throttle } from '../../utils/lodash.js';
|
|
5
4
|
|
|
6
5
|
const callbackManager = new CallbackManager();
|
|
7
6
|
let compassListener;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compass.js","sources":["../../../src/api/device/compass.ts"],"sourcesContent":["import Taro from '@tarojs/api'\r\
|
|
1
|
+
{"version":3,"file":"compass.js","sources":["../../../src/api/device/compass.ts"],"sourcesContent":["import Taro from '@tarojs/api'\r\nimport throttle from 'lodash-es/throttle'\r\n\r\nimport { CallbackManager, MethodHandler } from '../../utils/handler'\r\nimport { getDeviceInfo } from '../base/system'\r\n\r\nconst callbackManager = new CallbackManager()\r\nlet compassListener\r\n\r\n/**\r\n * Note: 按系统类型获取对应绝对 orientation 事件名,因为安卓系统中直接监听 deviceorientation 事件得到的不是绝对 orientation\r\n */\r\nconst deviceorientationEventName = ['absolutedeviceorientation', 'deviceorientationabsolute', 'deviceorientation'].find(item => {\r\n if ('on' + item in window) {\r\n return item\r\n }\r\n}) || ''\r\n\r\n/**\r\n * 停止监听罗盘数据\r\n */\r\nexport const stopCompass: typeof Taro.stopCompass = ({ success, fail, complete } = {}) => {\r\n const handle = new MethodHandler({ name: 'stopCompass', success, fail, complete })\r\n try {\r\n window.removeEventListener(deviceorientationEventName, compassListener, true)\r\n return handle.success()\r\n } catch (e) {\r\n return handle.fail({ errMsg: e.message })\r\n }\r\n}\r\n\r\nlet CompassChangeTrigger = false\r\n/**\r\n * 开始监听罗盘数据\r\n */\r\nexport const startCompass: typeof Taro.startCompass = ({ success, fail, complete } = {}) => {\r\n const handle = new MethodHandler({ name: 'startCompass', success, fail, complete })\r\n try {\r\n if (deviceorientationEventName !== '') {\r\n if (compassListener) {\r\n stopCompass()\r\n }\r\n compassListener = throttle((evt: DeviceOrientationEvent) => {\r\n const isAndroid = getDeviceInfo().system === 'AndroidOS'\r\n if (isAndroid && !evt.absolute && !CompassChangeTrigger) {\r\n CompassChangeTrigger = true\r\n console.warn('Warning: In \\'onCompassChange\\', your browser is not supported to get the orientation relative to the earth, the orientation data will be related to the initial orientation of the device .')\r\n }\r\n const alpha = evt.alpha || 0\r\n /**\r\n * 由于平台差异,accuracy 在 iOS/Android 的值不同。\r\n * - iOS:accuracy 是一个 number 类型的值,表示相对于磁北极的偏差。0 表示设备指向磁北,90 表示指向东,180 表示指向南,依此类推。\r\n * - Android:accuracy 是一个 string 类型的枚举值。\r\n */\r\n const accuracy = isAndroid ? evt.absolute ? 'high' : 'medium' : alpha\r\n callbackManager.trigger({\r\n direction: 360 - alpha,\r\n accuracy: accuracy\r\n } as unknown as Parameters<typeof Taro.onCompassChange>[number])\r\n }, 5000)\r\n window.addEventListener(deviceorientationEventName, compassListener, true)\r\n } else {\r\n throw new Error('compass is not supported')\r\n }\r\n return handle.success()\r\n } catch (e) {\r\n return handle.fail({ errMsg: e.message })\r\n }\r\n}\r\n\r\n/**\r\n * 监听罗盘数据变化事件。频率:5 次/秒,接口调用后会自动开始监听,可使用 wx.stopCompass 停止监听。\r\n */\r\nexport const onCompassChange: typeof Taro.onCompassChange = callback => {\r\n callbackManager.add(callback)\r\n}\r\n\r\n/**\r\n * 取消监听罗盘数据变化事件,参数为空,则取消所有的事件监听。\r\n */\r\nexport const offCompassChange: typeof Taro.offCompassChange = callback => {\r\n callbackManager.remove(callback)\r\n}\r\n"],"names":[],"mappings":";;;;AAMA,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAA;AAC7C,IAAI,eAAe,CAAA;AAEnB;;AAEG;AACH,MAAM,0BAA0B,GAAG,CAAC,2BAA2B,EAAE,2BAA2B,EAAE,mBAAmB,CAAC,CAAC,IAAI,CAAC,IAAI,IAAG;AAC7H,IAAA,IAAI,IAAI,GAAG,IAAI,IAAI,MAAM,EAAE;AACzB,QAAA,OAAO,IAAI,CAAA;AACZ,KAAA;AACH,CAAC,CAAC,IAAI,EAAE,CAAA;AAER;;AAEG;AACI,MAAM,WAAW,GAA4B,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAI;AACvF,IAAA,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;IAClF,I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G,KAAK;AACtB,oBAAA,QAAQ,EAAE,QAAQ;AAC2C,iBAAA,CAAC,CAAA;aACjE,EAAE,IAAI,CAAC,CAAA;YACR,MAAM,CAAC,gBAAgB,CAAC,0BAA0B,EAAE,eAAe,EAAE,IAAI,CAAC,CAAA;AAC3E,SAAA;AAAM,aAAA;AACL,YAAA,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAA;AAC5C,SAAA;AACD,QAAA,OAAO,MAAM,CAAC,OAAO,EAAE,CAAA;AACxB,KAAA;AAAC,IAAA,OAAO,CAAC,EAAE;AACV,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;AAC1C,KAAA;AACH,EAAC;AAED;;AAEG;AACU,MAAA,eAAe,GAAgC,QAAQ,IAAG;AACrE,IAAA,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAC/B,EAAC;AAED;;AAEG;AACU,MAAA,gBAAgB,GAAiC,QAAQ,IAAG;AACvE,IAAA,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AAClC;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../../utils/index.js';
|
|
2
2
|
|
|
3
3
|
// 联系人
|
|
4
|
-
const chooseContact = temporarilyNotSupport('chooseContact');
|
|
5
|
-
const addPhoneContact = temporarilyNotSupport('addPhoneContact');
|
|
4
|
+
const chooseContact = /* @__PURE__ */ temporarilyNotSupport('chooseContact');
|
|
5
|
+
const addPhoneContact = /* @__PURE__ */ temporarilyNotSupport('addPhoneContact');
|
|
6
6
|
|
|
7
7
|
export { addPhoneContact, chooseContact };
|
|
8
8
|
//# sourceMappingURL=contact.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contact.js","sources":["../../../src/api/device/contact.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 联系人\nexport const chooseContact = temporarilyNotSupport('chooseContact')\nexport const addPhoneContact = temporarilyNotSupport('addPhoneContact')\n"],"names":[],"mappings":";;AAEA;
|
|
1
|
+
{"version":3,"file":"contact.js","sources":["../../../src/api/device/contact.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 联系人\nexport const chooseContact = /* @__PURE__ */ temporarilyNotSupport('chooseContact')\nexport const addPhoneContact = /* @__PURE__ */ temporarilyNotSupport('addPhoneContact')\n"],"names":[],"mappings":";;AAEA;AACa,MAAA,aAAa,mBAAmB,qBAAqB,CAAC,eAAe,EAAC;AACtE,MAAA,eAAe,mBAAmB,qBAAqB,CAAC,iBAAiB;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../../utils/index.js';
|
|
2
2
|
|
|
3
3
|
// 加密
|
|
4
|
-
const getRandomValues = temporarilyNotSupport('getRandomValues');
|
|
4
|
+
const getRandomValues = /* @__PURE__ */ temporarilyNotSupport('getRandomValues');
|
|
5
5
|
|
|
6
6
|
export { getRandomValues };
|
|
7
7
|
//# sourceMappingURL=crypto.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.js","sources":["../../../src/api/device/crypto.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 加密\nexport const getRandomValues = temporarilyNotSupport('getRandomValues')\n"],"names":[],"mappings":";;AAEA;
|
|
1
|
+
{"version":3,"file":"crypto.js","sources":["../../../src/api/device/crypto.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 加密\nexport const getRandomValues = /* @__PURE__ */ temporarilyNotSupport('getRandomValues')\n"],"names":[],"mappings":";;AAEA;AACa,MAAA,eAAe,mBAAmB,qBAAqB,CAAC,iBAAiB;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../../utils/index.js';
|
|
2
2
|
|
|
3
3
|
// 陀螺仪
|
|
4
|
-
const stopGyroscope = temporarilyNotSupport('stopGyroscope');
|
|
5
|
-
const startGyroscope = temporarilyNotSupport('startGyroscope');
|
|
6
|
-
const onGyroscopeChange = temporarilyNotSupport('onGyroscopeChange');
|
|
7
|
-
const offGyroscopeChange = temporarilyNotSupport('offGyroscopeChange');
|
|
4
|
+
const stopGyroscope = /* @__PURE__ */ temporarilyNotSupport('stopGyroscope');
|
|
5
|
+
const startGyroscope = /* @__PURE__ */ temporarilyNotSupport('startGyroscope');
|
|
6
|
+
const onGyroscopeChange = /* @__PURE__ */ temporarilyNotSupport('onGyroscopeChange');
|
|
7
|
+
const offGyroscopeChange = /* @__PURE__ */ temporarilyNotSupport('offGyroscopeChange');
|
|
8
8
|
|
|
9
9
|
export { offGyroscopeChange, onGyroscopeChange, startGyroscope, stopGyroscope };
|
|
10
10
|
//# sourceMappingURL=gyroscope.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gyroscope.js","sources":["../../../src/api/device/gyroscope.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 陀螺仪\nexport const stopGyroscope = temporarilyNotSupport('stopGyroscope')\nexport const startGyroscope = temporarilyNotSupport('startGyroscope')\nexport const onGyroscopeChange = temporarilyNotSupport('onGyroscopeChange')\nexport const offGyroscopeChange = temporarilyNotSupport('offGyroscopeChange')\n"],"names":[],"mappings":";;AAEA;
|
|
1
|
+
{"version":3,"file":"gyroscope.js","sources":["../../../src/api/device/gyroscope.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 陀螺仪\nexport const stopGyroscope = /* @__PURE__ */ temporarilyNotSupport('stopGyroscope')\nexport const startGyroscope = /* @__PURE__ */ temporarilyNotSupport('startGyroscope')\nexport const onGyroscopeChange = /* @__PURE__ */ temporarilyNotSupport('onGyroscopeChange')\nexport const offGyroscopeChange = /* @__PURE__ */ temporarilyNotSupport('offGyroscopeChange')\n"],"names":[],"mappings":";;AAEA;AACa,MAAA,aAAa,mBAAmB,qBAAqB,CAAC,eAAe,EAAC;AACtE,MAAA,cAAc,mBAAmB,qBAAqB,CAAC,gBAAgB,EAAC;AACxE,MAAA,iBAAiB,mBAAmB,qBAAqB,CAAC,mBAAmB,EAAC;AAC9E,MAAA,kBAAkB,mBAAmB,qBAAqB,CAAC,oBAAoB;;;;"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../../utils/index.js';
|
|
2
2
|
|
|
3
3
|
// 蓝牙-信标(Beacon)
|
|
4
|
-
const stopBeaconDiscovery = temporarilyNotSupport('stopBeaconDiscovery');
|
|
5
|
-
const startBeaconDiscovery = temporarilyNotSupport('startBeaconDiscovery');
|
|
6
|
-
const onBeaconUpdate = temporarilyNotSupport('onBeaconUpdate');
|
|
7
|
-
const onBeaconServiceChange = temporarilyNotSupport('onBeaconServiceChange');
|
|
8
|
-
const offBeaconUpdate = temporarilyNotSupport('offBeaconUpdate');
|
|
9
|
-
const offBeaconServiceChange = temporarilyNotSupport('offBeaconServiceChange');
|
|
10
|
-
const getBeacons = temporarilyNotSupport('getBeacons');
|
|
4
|
+
const stopBeaconDiscovery = /* @__PURE__ */ temporarilyNotSupport('stopBeaconDiscovery');
|
|
5
|
+
const startBeaconDiscovery = /* @__PURE__ */ temporarilyNotSupport('startBeaconDiscovery');
|
|
6
|
+
const onBeaconUpdate = /* @__PURE__ */ temporarilyNotSupport('onBeaconUpdate');
|
|
7
|
+
const onBeaconServiceChange = /* @__PURE__ */ temporarilyNotSupport('onBeaconServiceChange');
|
|
8
|
+
const offBeaconUpdate = /* @__PURE__ */ temporarilyNotSupport('offBeaconUpdate');
|
|
9
|
+
const offBeaconServiceChange = /* @__PURE__ */ temporarilyNotSupport('offBeaconServiceChange');
|
|
10
|
+
const getBeacons = /* @__PURE__ */ temporarilyNotSupport('getBeacons');
|
|
11
11
|
|
|
12
12
|
export { getBeacons, offBeaconServiceChange, offBeaconUpdate, onBeaconServiceChange, onBeaconUpdate, startBeaconDiscovery, stopBeaconDiscovery };
|
|
13
13
|
//# sourceMappingURL=iBeacon.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iBeacon.js","sources":["../../../src/api/device/iBeacon.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 蓝牙-信标(Beacon)\nexport const stopBeaconDiscovery = temporarilyNotSupport('stopBeaconDiscovery')\nexport const startBeaconDiscovery = temporarilyNotSupport('startBeaconDiscovery')\nexport const onBeaconUpdate = temporarilyNotSupport('onBeaconUpdate')\nexport const onBeaconServiceChange = temporarilyNotSupport('onBeaconServiceChange')\nexport const offBeaconUpdate = temporarilyNotSupport('offBeaconUpdate')\nexport const offBeaconServiceChange = temporarilyNotSupport('offBeaconServiceChange')\nexport const getBeacons = temporarilyNotSupport('getBeacons')\n"],"names":[],"mappings":";;AAEA;
|
|
1
|
+
{"version":3,"file":"iBeacon.js","sources":["../../../src/api/device/iBeacon.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 蓝牙-信标(Beacon)\nexport const stopBeaconDiscovery = /* @__PURE__ */ temporarilyNotSupport('stopBeaconDiscovery')\nexport const startBeaconDiscovery = /* @__PURE__ */ temporarilyNotSupport('startBeaconDiscovery')\nexport const onBeaconUpdate = /* @__PURE__ */ temporarilyNotSupport('onBeaconUpdate')\nexport const onBeaconServiceChange = /* @__PURE__ */ temporarilyNotSupport('onBeaconServiceChange')\nexport const offBeaconUpdate = /* @__PURE__ */ temporarilyNotSupport('offBeaconUpdate')\nexport const offBeaconServiceChange = /* @__PURE__ */ temporarilyNotSupport('offBeaconServiceChange')\nexport const getBeacons = /* @__PURE__ */ temporarilyNotSupport('getBeacons')\n"],"names":[],"mappings":";;AAEA;AACa,MAAA,mBAAmB,mBAAmB,qBAAqB,CAAC,qBAAqB,EAAC;AAClF,MAAA,oBAAoB,mBAAmB,qBAAqB,CAAC,sBAAsB,EAAC;AACpF,MAAA,cAAc,mBAAmB,qBAAqB,CAAC,gBAAgB,EAAC;AACxE,MAAA,qBAAqB,mBAAmB,qBAAqB,CAAC,uBAAuB,EAAC;AACtF,MAAA,eAAe,mBAAmB,qBAAqB,CAAC,iBAAiB,EAAC;AAC1E,MAAA,sBAAsB,mBAAmB,qBAAqB,CAAC,wBAAwB,EAAC;AACxF,MAAA,UAAU,mBAAmB,qBAAqB,CAAC,YAAY;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../../utils/index.js';
|
|
2
2
|
|
|
3
3
|
// 键盘
|
|
4
|
-
const onKeyboardHeightChange = temporarilyNotSupport('onKeyboardHeightChange');
|
|
5
|
-
const offKeyboardHeightChange = temporarilyNotSupport('offKeyboardHeightChange');
|
|
6
|
-
const hideKeyboard = temporarilyNotSupport('hideKeyboard');
|
|
7
|
-
const getSelectedTextRange = temporarilyNotSupport('getSelectedTextRange');
|
|
4
|
+
const onKeyboardHeightChange = /* @__PURE__ */ temporarilyNotSupport('onKeyboardHeightChange');
|
|
5
|
+
const offKeyboardHeightChange = /* @__PURE__ */ temporarilyNotSupport('offKeyboardHeightChange');
|
|
6
|
+
const hideKeyboard = /* @__PURE__ */ temporarilyNotSupport('hideKeyboard');
|
|
7
|
+
const getSelectedTextRange = /* @__PURE__ */ temporarilyNotSupport('getSelectedTextRange');
|
|
8
8
|
|
|
9
9
|
export { getSelectedTextRange, hideKeyboard, offKeyboardHeightChange, onKeyboardHeightChange };
|
|
10
10
|
//# sourceMappingURL=keyboard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboard.js","sources":["../../../src/api/device/keyboard.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 键盘\nexport const onKeyboardHeightChange = temporarilyNotSupport('onKeyboardHeightChange')\nexport const offKeyboardHeightChange = temporarilyNotSupport('offKeyboardHeightChange')\nexport const hideKeyboard = temporarilyNotSupport('hideKeyboard')\nexport const getSelectedTextRange = temporarilyNotSupport('getSelectedTextRange')\n"],"names":[],"mappings":";;AAEA;
|
|
1
|
+
{"version":3,"file":"keyboard.js","sources":["../../../src/api/device/keyboard.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 键盘\nexport const onKeyboardHeightChange = /* @__PURE__ */ temporarilyNotSupport('onKeyboardHeightChange')\nexport const offKeyboardHeightChange = /* @__PURE__ */ temporarilyNotSupport('offKeyboardHeightChange')\nexport const hideKeyboard = /* @__PURE__ */ temporarilyNotSupport('hideKeyboard')\nexport const getSelectedTextRange = /* @__PURE__ */ temporarilyNotSupport('getSelectedTextRange')\n"],"names":[],"mappings":";;AAEA;AACa,MAAA,sBAAsB,mBAAmB,qBAAqB,CAAC,wBAAwB,EAAC;AACxF,MAAA,uBAAuB,mBAAmB,qBAAqB,CAAC,yBAAyB,EAAC;AAC1F,MAAA,YAAY,mBAAmB,qBAAqB,CAAC,cAAc,EAAC;AACpE,MAAA,oBAAoB,mBAAmB,qBAAqB,CAAC,sBAAsB;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { temporarilyNotSupport } from '../../utils/index.js';
|
|
2
2
|
|
|
3
3
|
// 内存
|
|
4
|
-
const onMemoryWarning = temporarilyNotSupport('onMemoryWarning');
|
|
5
|
-
const offMemoryWarning = temporarilyNotSupport('offMemoryWarning');
|
|
4
|
+
const onMemoryWarning = /* @__PURE__ */ temporarilyNotSupport('onMemoryWarning');
|
|
5
|
+
const offMemoryWarning = /* @__PURE__ */ temporarilyNotSupport('offMemoryWarning');
|
|
6
6
|
|
|
7
7
|
export { offMemoryWarning, onMemoryWarning };
|
|
8
8
|
//# sourceMappingURL=memory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory.js","sources":["../../../src/api/device/memory.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 内存\nexport const onMemoryWarning = temporarilyNotSupport('onMemoryWarning')\nexport const offMemoryWarning = temporarilyNotSupport('offMemoryWarning')\n"],"names":[],"mappings":";;AAEA;
|
|
1
|
+
{"version":3,"file":"memory.js","sources":["../../../src/api/device/memory.ts"],"sourcesContent":["import { temporarilyNotSupport } from '../../utils'\n\n// 内存\nexport const onMemoryWarning = /* @__PURE__ */ temporarilyNotSupport('onMemoryWarning')\nexport const offMemoryWarning = /* @__PURE__ */ temporarilyNotSupport('offMemoryWarning')\n"],"names":[],"mappings":";;AAEA;AACa,MAAA,eAAe,mBAAmB,qBAAqB,CAAC,iBAAiB,EAAC;AAC1E,MAAA,gBAAgB,mBAAmB,qBAAqB,CAAC,kBAAkB;;;;"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import '
|
|
1
|
+
import throttle from 'lodash-es/throttle';
|
|
2
2
|
import { CallbackManager, MethodHandler } from '../../utils/handler.js';
|
|
3
|
-
import { throttle } from '../../utils/lodash.js';
|
|
4
3
|
|
|
5
4
|
const callbackManager = new CallbackManager();
|
|
6
5
|
let deviceMotionListener;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motion.js","sources":["../../../src/api/device/motion.ts"],"sourcesContent":["import Taro from '@tarojs/api'\r\
|
|
1
|
+
{"version":3,"file":"motion.js","sources":["../../../src/api/device/motion.ts"],"sourcesContent":["import Taro from '@tarojs/api'\r\nimport throttle from 'lodash-es/throttle'\r\n\r\nimport { CallbackManager, MethodHandler } from '../../utils/handler'\r\n\r\nconst callbackManager = new CallbackManager()\r\nlet deviceMotionListener\r\n\r\nconst INTERVAL_MAP = {\r\n game: {\r\n interval: 20,\r\n frequency: 50\r\n },\r\n ui: {\r\n interval: 60,\r\n frequency: 16.67\r\n },\r\n normal: {\r\n interval: 200,\r\n frequency: 5\r\n }\r\n}\r\n\r\n/**\r\n * 停止监听设备方向的变化。\r\n */\r\nexport const stopDeviceMotionListening: typeof Taro.stopDeviceMotionListening = ({ success, fail, complete } = {}) => {\r\n const handle = new MethodHandler({ name: 'stopDeviceMotionListening', success, fail, complete })\r\n try {\r\n window.removeEventListener('deviceorientation', deviceMotionListener, true)\r\n return handle.success()\r\n } catch (e) {\r\n return handle.fail({ errMsg: e.message })\r\n }\r\n}\r\n\r\n/**\r\n * 开始监听设备方向的变化。\r\n */\r\nexport const startDeviceMotionListening: typeof Taro.startDeviceMotionListening = ({ interval = 'normal', success, fail, complete } = {}) => {\r\n const handle = new MethodHandler({ name: 'startDeviceMotionListening', success, fail, complete })\r\n try {\r\n const intervalObj = INTERVAL_MAP[interval]\r\n if (window.DeviceOrientationEvent) {\r\n if (deviceMotionListener) {\r\n stopDeviceMotionListening()\r\n }\r\n deviceMotionListener = throttle((evt: DeviceOrientationEvent) => {\r\n callbackManager.trigger({\r\n alpha: evt.alpha,\r\n beta: evt.beta,\r\n gamma: evt.gamma\r\n })\r\n }, intervalObj.interval)\r\n window.addEventListener('deviceorientation', deviceMotionListener, true)\r\n } else {\r\n throw new Error('deviceMotion is not supported')\r\n }\r\n return handle.success()\r\n } catch (e) {\r\n return handle.fail({ errMsg: e.message })\r\n }\r\n}\r\n\r\n/**\r\n * 监听设备方向变化事件。\r\n */\r\nexport const onDeviceMotionChange: typeof Taro.onDeviceMotionChange = callback => {\r\n callbackManager.add(callback)\r\n}\r\n\r\n/**\r\n * 取消监听设备方向变化事件,参数为空,则取消所有的事件监听。\r\n */\r\nexport const offDeviceMotionChange: typeof Taro.offDeviceMotionChange = callback => {\r\n callbackManager.remove(callback)\r\n}\r\n"],"names":[],"mappings":";;;AAKA,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAA;AAC7C,IAAI,oBAAoB,CAAA;AAExB,MAAM,YAAY,GAAG;AACnB,IAAA,IAAI,EAAE;AACJ,QAAA,QAAQ,EAAE,EAAE;AACZ,QAAA,SAAS,EAAE,EAAE;AACd,KAAA;AACD,IAAA,EAAE,EAAE;AACF,QAAA,QAAQ,EAAE,EAAE;AACZ,QAAA,SAAS,EAAE,KAAK;AACjB,KAAA;AACD,IAAA,MAAM,EAAE;AACN,QAAA,QAAQ,EAAE,GAAG;AACb,QAAA,SAAS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,iBAAA,CAAC,CAAA;AACJ,aAAC,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAA;YACxB,MAAM,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,oBAAoB,EAAE,IAAI,CAAC,CAAA;AACzE,SAAA;AAAM,aAAA;AACL,YAAA,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;AACjD,SAAA;AACD,QAAA,OAAO,MAAM,CAAC,OAAO,EAAE,CAAA;AACxB,KAAA;AAAC,IAAA,OAAO,CAAC,EAAE;AACV,QAAA,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAA;AAC1C,KAAA;AACH,EAAC;AAED;;AAEG;AACU,MAAA,oBAAoB,GAAqC,QAAQ,IAAG;AAC/E,IAAA,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAA;AAC/B,EAAC;AAED;;AAEG;AACU,MAAA,qBAAqB,GAAsC,QAAQ,IAAG;AACjF,IAAA,eAAe,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AAClC;;;;"}
|
|
@@ -61,7 +61,7 @@ const networkStatusListener = () => __awaiter(void 0, void 0, void 0, function*
|
|
|
61
61
|
* - 出现三次以上的丢包
|
|
62
62
|
* > 弱网事件通知规则是: 弱网状态变化时立即通知, 状态不变时 30s 内最多通知一次。
|
|
63
63
|
*/
|
|
64
|
-
const onNetworkWeakChange = temporarilyNotSupport('onNetworkWeakChange');
|
|
64
|
+
const onNetworkWeakChange = /* @__PURE__ */ temporarilyNotSupport('onNetworkWeakChange');
|
|
65
65
|
const onNetworkStatusChange = callback => {
|
|
66
66
|
networkStatusManager.add(callback);
|
|
67
67
|
const connection = getConnection();
|
|
@@ -69,7 +69,7 @@ const onNetworkStatusChange = callback => {
|
|
|
69
69
|
connection.addEventListener('change', networkStatusListener);
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
-
const offNetworkWeakChange = temporarilyNotSupport('
|
|
72
|
+
const offNetworkWeakChange = /* @__PURE__ */ temporarilyNotSupport('offNetworkWeakChange');
|
|
73
73
|
const offNetworkStatusChange = callback => {
|
|
74
74
|
networkStatusManager.remove(callback);
|
|
75
75
|
const connection = getConnection();
|
|
@@ -77,7 +77,7 @@ const offNetworkStatusChange = callback => {
|
|
|
77
77
|
connection.removeEventListener('change', networkStatusListener);
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
|
-
const getLocalIPAddress = temporarilyNotSupport('getLocalIPAddress');
|
|
80
|
+
const getLocalIPAddress = /* @__PURE__ */ temporarilyNotSupport('getLocalIPAddress');
|
|
81
81
|
|
|
82
82
|
export { getLocalIPAddress, getNetworkType, offNetworkStatusChange, offNetworkWeakChange, onNetworkStatusChange, onNetworkWeakChange };
|
|
83
83
|
//# sourceMappingURL=network.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"network.js","sources":["../../../src/api/device/network.ts"],"sourcesContent":["import Taro from '@tarojs/api'\n\nimport { temporarilyNotSupport } from '../../utils'\nimport { CallbackManager, MethodHandler } from '../../utils/handler'\n\nfunction getConnection () {\n // @ts-ignore\n return navigator.connection || navigator.mozConnection || navigator.webkitConnection || navigator.msConnection\n}\n\nexport const getNetworkType: typeof Taro.getNetworkType = (options = {}) => {\n const connection = getConnection()\n const { success, fail, complete } = options\n const handle = new MethodHandler<Taro.getNetworkType.SuccessCallbackResult>({ name: 'getNetworkType', success, fail, complete })\n\n let networkType: keyof Taro.getNetworkType.NetworkType = 'unknown'\n // 浏览器不支持获取网络状态\n if (!connection) {\n return handle.success({ networkType })\n }\n\n // Supports only the navigator.connection.type value which doesn't match the latest spec.\n // https://www.davidbcalhoun.com/2010/using-navigator-connection-android/\n if (!isNaN(Number(connection.type))) {\n switch (connection.type) {\n // @ts-ignore\n case connection.WIFI:\n networkType = 'wifi'\n break\n // @ts-ignore\n case connection.CELL_3G:\n networkType = '3g'\n break\n // @ts-ignore\n case connection.CELL_2G:\n networkType = '2g'\n break\n default:\n // ETHERNET, UNKNOWN\n networkType = 'unknown'\n }\n } else if (connection.type) {\n // @ts-ignore\n networkType = connection.type // Only supports the type value.\n // @ts-ignore\n } else if (connection.effectiveType) {\n // @ts-ignore\n networkType = connection.effectiveType\n }\n\n return handle.success({ networkType })\n}\n\nconst networkStatusManager = new CallbackManager()\n\nconst networkStatusListener = async () => {\n const { networkType } = await getNetworkType()\n const isConnected = networkType !== 'none'\n const obj = { isConnected, networkType }\n networkStatusManager.trigger(obj)\n}\n\n/**\n * 在最近的八次网络请求中, 出现下列三个现象之一则判定弱网。\n * - 出现三次以上连接超时\n * - 出现三次 rtt 超过 400\n * - 出现三次以上的丢包\n * > 弱网事件通知规则是: 弱网状态变化时立即通知, 状态不变时 30s 内最多通知一次。\n */\nexport const onNetworkWeakChange = temporarilyNotSupport('onNetworkWeakChange')\n\nexport const onNetworkStatusChange: typeof Taro.onNetworkStatusChange = callback => {\n networkStatusManager.add(callback)\n const connection = getConnection()\n if (connection && networkStatusManager.count() === 1) {\n connection.addEventListener('change', networkStatusListener)\n }\n}\n\nexport const offNetworkWeakChange = temporarilyNotSupport('
|
|
1
|
+
{"version":3,"file":"network.js","sources":["../../../src/api/device/network.ts"],"sourcesContent":["import Taro from '@tarojs/api'\n\nimport { temporarilyNotSupport } from '../../utils'\nimport { CallbackManager, MethodHandler } from '../../utils/handler'\n\nfunction getConnection () {\n // @ts-ignore\n return navigator.connection || navigator.mozConnection || navigator.webkitConnection || navigator.msConnection\n}\n\nexport const getNetworkType: typeof Taro.getNetworkType = (options = {}) => {\n const connection = getConnection()\n const { success, fail, complete } = options\n const handle = new MethodHandler<Taro.getNetworkType.SuccessCallbackResult>({ name: 'getNetworkType', success, fail, complete })\n\n let networkType: keyof Taro.getNetworkType.NetworkType = 'unknown'\n // 浏览器不支持获取网络状态\n if (!connection) {\n return handle.success({ networkType })\n }\n\n // Supports only the navigator.connection.type value which doesn't match the latest spec.\n // https://www.davidbcalhoun.com/2010/using-navigator-connection-android/\n if (!isNaN(Number(connection.type))) {\n switch (connection.type) {\n // @ts-ignore\n case connection.WIFI:\n networkType = 'wifi'\n break\n // @ts-ignore\n case connection.CELL_3G:\n networkType = '3g'\n break\n // @ts-ignore\n case connection.CELL_2G:\n networkType = '2g'\n break\n default:\n // ETHERNET, UNKNOWN\n networkType = 'unknown'\n }\n } else if (connection.type) {\n // @ts-ignore\n networkType = connection.type // Only supports the type value.\n // @ts-ignore\n } else if (connection.effectiveType) {\n // @ts-ignore\n networkType = connection.effectiveType\n }\n\n return handle.success({ networkType })\n}\n\nconst networkStatusManager = new CallbackManager()\n\nconst networkStatusListener = async () => {\n const { networkType } = await getNetworkType()\n const isConnected = networkType !== 'none'\n const obj = { isConnected, networkType }\n networkStatusManager.trigger(obj)\n}\n\n/**\n * 在最近的八次网络请求中, 出现下列三个现象之一则判定弱网。\n * - 出现三次以上连接超时\n * - 出现三次 rtt 超过 400\n * - 出现三次以上的丢包\n * > 弱网事件通知规则是: 弱网状态变化时立即通知, 状态不变时 30s 内最多通知一次。\n */\nexport const onNetworkWeakChange = /* @__PURE__ */ temporarilyNotSupport('onNetworkWeakChange')\n\nexport const onNetworkStatusChange: typeof Taro.onNetworkStatusChange = callback => {\n networkStatusManager.add(callback)\n const connection = getConnection()\n if (connection && networkStatusManager.count() === 1) {\n connection.addEventListener('change', networkStatusListener)\n }\n}\n\nexport const offNetworkWeakChange = /* @__PURE__ */ temporarilyNotSupport('offNetworkWeakChange')\n\nexport const offNetworkStatusChange: typeof Taro.offNetworkStatusChange = callback => {\n networkStatusManager.remove(callback)\n const connection = getConnection()\n if (connection && networkStatusManager.count() === 0) {\n connection.removeEventListener('change', networkStatusListener)\n }\n}\n\nexport const getLocalIPAddress = /* @__PURE__ */ temporarilyNotSupport('getLocalIPAddress')\n"],"names":[],"mappings":";;;;AAKA,SAAS,aAAa,GAAA;;AAEpB,IAAA,OAAO,SAAS,CAAC,UAAU,IAAI,SAAS,CAAC,aAAa,IAAI,SAAS,CAAC,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