@tarojs/taro-h5 3.3.16 → 3.3.20
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 +3 -0
- package/dist/api/ai/facial.js +4 -0
- package/dist/api/ai/index.js +2 -0
- package/dist/api/ai/visual.js +2 -0
- package/dist/api/alipay/index.js +2 -0
- package/dist/api/base/crypto.js +2 -0
- package/dist/api/base/debug.js +4 -0
- package/dist/api/base/index.js +16 -0
- package/dist/api/base/performance.js +3 -0
- package/dist/api/base/system/index.js +2 -0
- package/dist/api/base/system/info.js +56 -0
- package/dist/api/base/system/network.js +52 -0
- package/dist/api/base/update.js +3 -0
- package/dist/api/base/weapp/app-event.js +17 -0
- package/dist/api/base/weapp/life-cycle.js +3 -0
- package/dist/api/canvas/CanvasContext.js +182 -0
- package/dist/api/canvas/canvasGetImageData.js +21 -0
- package/dist/api/canvas/canvasPutImageData.js +17 -0
- package/dist/api/canvas/canvasToTempFilePath.js +18 -0
- package/dist/api/canvas/createCanvasContext.js +13 -0
- package/dist/api/canvas/index.js +7 -0
- package/dist/api/cloud/index.js +14 -0
- package/dist/api/data-analysis/index.js +5 -0
- package/dist/api/device/accelerometer.js +71 -0
- package/dist/api/device/accessibility.js +2 -0
- package/dist/api/device/battery.js +3 -0
- package/dist/api/device/bluetooth-ble.js +17 -0
- package/dist/api/device/bluetooth-peripheral.js +4 -0
- package/dist/api/device/bluetooth.js +14 -0
- package/dist/api/device/calendar.js +3 -0
- package/dist/api/device/clipboard.js +48 -0
- package/dist/api/device/compass.js +52 -0
- package/dist/api/device/contact.js +3 -0
- package/dist/api/device/crypto.js +2 -0
- package/dist/api/device/gyroscope.js +5 -0
- package/dist/api/device/iBeacon.js +8 -0
- package/dist/api/device/index.js +22 -0
- package/dist/api/device/keyboard.js +5 -0
- package/dist/api/device/memory.js +3 -0
- package/dist/api/device/motion.js +69 -0
- package/dist/api/device/nfc.js +8 -0
- package/dist/api/device/phone.js +23 -0
- package/dist/api/device/scan.js +5 -0
- package/dist/api/device/screen.js +7 -0
- package/dist/api/device/vibrate.js +29 -0
- package/dist/api/device/wifi.js +11 -0
- package/dist/api/ext/index.js +3 -0
- package/dist/api/files/index.js +9 -0
- package/dist/api/framework/index.js +6 -0
- package/dist/api/index.js +24 -0
- package/dist/api/location/chooseLocation.js +88 -0
- package/dist/api/location/index.js +12 -0
- package/dist/api/location/style.css +79 -0
- package/dist/api/media/audio/index.js +81 -0
- package/dist/api/media/background-audio.js +10 -0
- package/dist/api/media/camera.js +2 -0
- package/dist/api/media/editor.js +17 -0
- package/dist/api/media/image/chooseImage.js +70 -0
- package/dist/api/media/image/getImageInfo.js +27 -0
- package/dist/api/media/image/index.js +8 -0
- package/dist/api/media/image/previewImage.js +57 -0
- package/dist/api/media/index.js +13 -0
- package/dist/api/media/live.js +3 -0
- package/dist/api/media/map.js +2 -0
- package/dist/api/media/media-recorder.js +2 -0
- package/dist/api/media/recorder.js +4 -0
- package/dist/api/media/video/index.js +65 -0
- package/dist/api/media/video-decoder.js +2 -0
- package/dist/api/media/video-processing.js +2 -0
- package/dist/api/media/voip.js +15 -0
- package/dist/api/navigate/index.js +5 -0
- package/dist/api/network/download.js +101 -0
- package/dist/api/network/index.js +7 -0
- package/dist/api/network/mdns.js +11 -0
- package/dist/api/network/request/index.js +123 -0
- package/dist/api/network/tcp.js +2 -0
- package/dist/api/network/udp.js +2 -0
- package/dist/api/network/upload.js +129 -0
- package/dist/api/network/utils.js +30 -0
- package/dist/api/network/websocket/index.js +65 -0
- package/dist/api/network/websocket/socketTask.js +61 -0
- package/dist/api/open-api/account.js +2 -0
- package/dist/api/open-api/address.js +2 -0
- package/dist/api/open-api/authorize.js +3 -0
- package/dist/api/open-api/card.js +3 -0
- package/dist/api/open-api/channels-live.js +7 -0
- package/dist/api/open-api/customer-service.js +2 -0
- package/dist/api/open-api/facial.js +5 -0
- package/dist/api/open-api/favorites.js +3 -0
- package/dist/api/open-api/group.js +2 -0
- package/dist/api/open-api/index.js +18 -0
- package/dist/api/open-api/invoice.js +3 -0
- package/dist/api/open-api/license-plate.js +2 -0
- package/dist/api/open-api/login.js +4 -0
- package/dist/api/open-api/red-package.js +2 -0
- package/dist/api/open-api/settings.js +3 -0
- package/dist/api/open-api/soter.js +4 -0
- package/dist/api/open-api/subscribe-message.js +2 -0
- package/dist/api/open-api/user-info.js +3 -0
- package/dist/api/open-api/werun.js +3 -0
- package/dist/api/payment/index.js +3 -0
- package/dist/api/route/index.js +1 -0
- package/dist/api/share/index.js +11 -0
- package/dist/api/storage/background-fetch.js +5 -0
- package/dist/api/storage/index.js +152 -0
- package/dist/api/swan/index.js +22 -0
- package/dist/api/taro.js +59 -0
- package/dist/api/ui/animation/index.js +250 -0
- package/dist/api/ui/background.js +3 -0
- package/dist/api/ui/custom-component.js +2 -0
- package/dist/api/ui/fonts.js +2 -0
- package/dist/api/ui/index.js +12 -0
- package/dist/api/ui/interaction/actionSheet.js +172 -0
- package/dist/api/ui/interaction/index.js +263 -0
- package/dist/api/ui/interaction/modal.js +185 -0
- package/dist/api/ui/interaction/toast.js +179 -0
- package/dist/api/ui/menu.js +2 -0
- package/dist/api/ui/navigation-bar/index.js +37 -0
- package/dist/api/ui/pull-down-refresh.js +20 -0
- package/dist/api/ui/scroll/index.js +80 -0
- package/dist/api/ui/sticky.js +2 -0
- package/dist/api/ui/tab-bar.js +250 -0
- package/dist/api/ui/window.js +22 -0
- package/dist/api/utils/handler.js +64 -0
- package/dist/api/utils/index.js +141 -0
- package/dist/api/worker/index.js +2 -0
- package/dist/api/wxml/index.js +6 -0
- package/dist/api/wxml/nodesRef.js +42 -0
- package/dist/api/wxml/selectorQuery.js +188 -0
- package/dist/index.cjs.js +7477 -10829
- package/dist/index.js +4 -0
- package/dist/taroApis.js +1 -1
- package/dist/types/type.js +2 -0
- package/package.json +12 -15
- package/src/api/ad/index.ts +5 -0
- package/src/api/ai/facial.ts +6 -0
- package/src/api/ai/index.ts +2 -0
- package/src/api/ai/visual.ts +4 -0
- package/src/api/alipay/index.ts +4 -0
- package/src/api/base/crypto.ts +4 -0
- package/src/api/base/debug.ts +5 -0
- package/src/api/base/index.ts +23 -0
- package/src/api/base/performance.ts +5 -0
- package/src/api/base/system/index.ts +2 -0
- package/src/api/base/system/info.ts +64 -0
- package/src/api/base/system/network.ts +70 -0
- package/src/api/base/update.ts +5 -0
- package/src/api/base/weapp/app-event.ts +19 -0
- package/src/api/base/weapp/life-cycle.ts +5 -0
- package/src/api/canvas/CanvasContext.ts +233 -0
- package/src/api/canvas/canvasGetImageData.ts +27 -0
- package/src/api/canvas/canvasPutImageData.ts +24 -0
- package/src/api/canvas/canvasToTempFilePath.ts +24 -0
- package/src/api/canvas/createCanvasContext.ts +18 -0
- package/src/api/canvas/index.ts +10 -0
- package/src/api/cloud/index.ts +27 -0
- package/src/api/data-analysis/index.ts +6 -0
- package/src/api/device/accelerometer.ts +87 -0
- package/src/api/device/accessibility.ts +4 -0
- package/src/api/device/battery.ts +5 -0
- package/src/api/device/bluetooth-ble.ts +19 -0
- package/src/api/device/bluetooth-peripheral.ts +6 -0
- package/src/api/device/bluetooth.ts +16 -0
- package/src/api/device/calendar.ts +5 -0
- package/src/api/device/clipboard.ts +67 -0
- package/src/api/device/compass.ts +67 -0
- package/src/api/device/contact.ts +5 -0
- package/src/api/device/crypto.ts +4 -0
- package/src/api/device/gyroscope.ts +7 -0
- package/src/api/device/iBeacon.ts +10 -0
- package/src/api/device/index.ts +22 -0
- package/src/api/device/keyboard.ts +7 -0
- package/src/api/device/memory.ts +5 -0
- package/src/api/device/motion.ts +85 -0
- package/src/api/device/nfc.ts +10 -0
- package/src/api/device/phone.ts +30 -0
- package/src/api/device/scan.ts +7 -0
- package/src/api/device/screen.ts +9 -0
- package/src/api/device/vibrate.ts +36 -0
- package/src/api/device/wifi.ts +13 -0
- package/src/api/ext/index.ts +5 -0
- package/src/api/files/index.ts +11 -0
- package/src/api/framework/index.ts +10 -0
- package/src/api/index.ts +25 -0
- package/src/api/location/chooseLocation.ts +106 -0
- package/src/api/location/index.ts +19 -0
- package/src/api/location/style.css +8 -8
- package/src/api/media/audio/index.ts +105 -0
- package/src/api/media/background-audio.ts +12 -0
- package/src/api/media/camera.ts +4 -0
- package/src/api/media/editor.ts +29 -0
- package/src/api/media/image/chooseImage.ts +78 -0
- package/src/api/media/image/getImageInfo.ts +35 -0
- package/src/api/media/image/index.ts +13 -0
- package/src/api/media/image/previewImage.ts +80 -0
- package/src/api/media/index.ts +13 -0
- package/src/api/media/live.ts +5 -0
- package/src/api/media/map.ts +4 -0
- package/src/api/media/media-recorder.ts +4 -0
- package/src/api/media/recorder.ts +6 -0
- package/src/api/media/video/index.ts +82 -0
- package/src/api/media/video-decoder.ts +4 -0
- package/src/api/media/video-processing.ts +4 -0
- package/src/api/media/voip.ts +17 -0
- package/src/api/navigate/index.ts +7 -0
- package/src/api/{fileTransfer/downloadFile.js → network/download.ts} +16 -27
- package/src/api/network/index.ts +7 -0
- package/src/api/network/mdns.ts +13 -0
- package/src/api/{request/index.js → network/request/index.ts} +9 -6
- package/src/api/network/tcp.ts +4 -0
- package/src/api/network/udp.ts +4 -0
- package/src/api/{fileTransfer/uploadFile.js → network/upload.ts} +28 -32
- package/src/api/{fileTransfer/utils.js → network/utils.ts} +0 -0
- package/src/api/network/websocket/index.ts +88 -0
- package/src/api/{webSocket/socketTask.js → network/websocket/socketTask.ts} +17 -7
- package/src/api/open-api/account.ts +4 -0
- package/src/api/open-api/address.ts +4 -0
- package/src/api/open-api/authorize.ts +5 -0
- package/src/api/open-api/card.ts +5 -0
- package/src/api/open-api/channels-live.ts +9 -0
- package/src/api/open-api/customer-service.ts +4 -0
- package/src/api/open-api/facial.ts +7 -0
- package/src/api/open-api/favorites.ts +5 -0
- package/src/api/open-api/group.ts +4 -0
- package/src/api/open-api/index.ts +18 -0
- package/src/api/open-api/invoice.ts +5 -0
- package/src/api/open-api/license-plate.ts +4 -0
- package/src/api/open-api/login.ts +6 -0
- package/src/api/open-api/red-package.ts +4 -0
- package/src/api/open-api/settings.ts +5 -0
- package/src/api/open-api/soter.ts +6 -0
- package/src/api/open-api/subscribe-message.ts +4 -0
- package/src/api/open-api/user-info.ts +5 -0
- package/src/api/open-api/werun.ts +5 -0
- package/src/api/payment/index.ts +5 -0
- package/src/api/route/index.ts +10 -0
- package/src/api/share/index.ts +13 -0
- package/src/api/storage/background-fetch.ts +7 -0
- package/src/api/storage/index.ts +181 -0
- package/src/api/swan/index.ts +31 -0
- package/src/{taro/index.js → api/taro.ts} +133 -149
- package/src/api/{createAnimation/index.js → ui/animation/index.ts} +52 -41
- package/src/api/ui/background.ts +5 -0
- package/src/api/ui/custom-component.ts +4 -0
- package/src/api/ui/fonts.ts +4 -0
- package/src/api/ui/index.ts +12 -0
- package/src/api/ui/interaction/actionSheet.ts +212 -0
- package/src/api/{interactive/index.js → ui/interaction/index.ts} +93 -77
- package/src/api/ui/interaction/modal.ts +237 -0
- package/src/api/{interactive/toast.js → ui/interaction/toast.ts} +35 -33
- package/src/api/ui/menu.ts +4 -0
- package/src/api/ui/navigation-bar/index.ts +52 -0
- package/src/api/ui/pull-down-refresh.ts +27 -0
- package/src/api/ui/scroll/index.ts +85 -0
- package/src/api/ui/sticky.ts +4 -0
- package/src/api/ui/tab-bar.ts +326 -0
- package/src/api/ui/window.ts +37 -0
- package/src/api/utils/handler.ts +105 -0
- package/src/api/utils/{index.js → index.ts} +36 -115
- package/src/api/worker/index.ts +4 -0
- package/src/api/wxml/index.ts +9 -0
- package/src/api/wxml/nodesRef.ts +56 -0
- package/src/api/wxml/selectorQuery.ts +219 -0
- package/src/index.ts +6 -0
- package/src/types/api.d.ts +4 -0
- package/src/types/define.d.ts +2 -0
- package/{types → src/types}/index.d.ts +0 -0
- package/{types → src/types}/type.ts +1 -1
- package/src/api/accelerometer/index.js +0 -105
- package/src/api/audio/index.js +0 -137
- package/src/api/canvas/canvasGetImageData.js +0 -44
- package/src/api/canvas/canvasPutImageData.js +0 -45
- package/src/api/canvas/canvasToTempFilePath.js +0 -49
- package/src/api/canvas/createCanvasContext.js +0 -340
- package/src/api/canvas/index.js +0 -4
- package/src/api/clipboard/index.js +0 -113
- package/src/api/compass/index.js +0 -99
- package/src/api/createSelectorQuery/index.js +0 -193
- package/src/api/deviceMotion/index.js +0 -105
- package/src/api/fileTransfer/index.js +0 -2
- package/src/api/image/chooseImage.js +0 -87
- package/src/api/image/getImageInfo.js +0 -74
- package/src/api/image/index.js +0 -7
- package/src/api/image/previewImage.js +0 -94
- package/src/api/index.js +0 -29
- package/src/api/interactive/actionSheet.js +0 -214
- package/src/api/interactive/modal.js +0 -256
- package/src/api/location/chooseLocation.js +0 -143
- package/src/api/location/index.js +0 -5
- package/src/api/navigationBar/index.js +0 -57
- package/src/api/open/index.js +0 -5
- package/src/api/others/index.js +0 -43
- package/src/api/pullDownRefresh/index.js +0 -51
- package/src/api/scroll/index.js +0 -99
- package/src/api/storage/index.js +0 -211
- package/src/api/system/index.js +0 -9
- package/src/api/system/info.js +0 -36
- package/src/api/system/network.js +0 -68
- package/src/api/tabBar/index.js +0 -402
- package/src/api/unsupportedApi/index.js +0 -278
- package/src/api/vibrate/index.js +0 -49
- package/src/api/video/index.js +0 -87
- package/src/api/webSocket/index.js +0 -103
- package/src/api/window/index.js +0 -38
- package/src/index.cjs.js +0 -11
- package/src/index.js +0 -6
package/dist/index.js
ADDED
package/dist/taroApis.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = new Set(["addCard","addInterceptor","addPhoneContact","advancedGeneralIdentify","animalClassify","arrayBufferToBase64","authorize","base64ToArrayBuffer","canIUse","canvasGetImageData","canvasPutImageData","canvasToTempFilePath","carClassify","checkIsSoterEnrolledInDevice","checkIsSupportFacialRecognition","checkIsSupportSoterAuthentication","checkSession","chooseAddress","chooseImage","chooseInvoice","chooseInvoiceTitle","chooseLocation","chooseVideo","clearStorage","clearStorageSync","closeBLEConnection","closeBluetoothAdapter","closeSocket","connectSocket","connectWifi","createAnimation","createAudioContext","createBLEConnection","createCameraContext","createCanvasContext","createInnerAudioContext","createIntersectionObserver","createLivePlayerContext","createLivePusherContext","createMapContext","createSelectorQuery","createVideoContext","createWorker","dishClassify","downloadFile","drawCanvas","exitMiniProgram","faceVerifyForPay","getAccountInfoSync","getAvailableAudioSources","getBLEDeviceCharacteristics","getBLEDeviceServices","getBackgroundAudioManager","getBackgroundAudioPlayerState","getBeacons","getBluetoothAdapterState","getBluetoothDevices","getClipboardData","getConnectedBluetoothDevices","getConnectedWifi","getExtConfig","getExtConfigSync","getFileInfo","getFileSystemManager","getHCEState","getImageInfo","getLocation","getLogManager","getMenuButtonBoundingClientRect","getNetworkType","getRecorderManager","getSavedFileInfo","getSavedFileList","getScreenBrightness","getSetting","getShareInfo","getStorage","getStorageInfo","getStorageInfoSync","getStorageSync","getSwanId","getSystemInfo","getSystemInfoSync","getUpdateManager","getUserInfo","getWeRunData","getWifiList","hideHomeButton","hideKeyboard","hideLoading","hideNavigationBarLoading","hideShareMenu","hideTabBar","hideTabBarRedDot","hideToast","imageAudit","initTabBarApis","loadFontFace","login","logoClassify","makePhoneCall","navigateBackMiniProgram","navigateBackSmartProgram","navigateToMiniProgram","navigateToSmartGameProgram","navigateToSmartProgram","notifyBLECharacteristicValueChange","objectDetectIdentify","ocrBankCard","ocrDrivingLicense","ocrIdCard","ocrVehicleLicense","offWindowResize","onAccelerometerChange","onBLECharacteristicValueChange","onBLEConnectionStateChange","onBackgroundAudioPause","onBackgroundAudioPlay","onBackgroundAudioStop","onBeaconServiceChange","onBeaconUpdate","onBluetoothAdapterStateChange","onBluetoothDeviceFound","onCompassChange","onDeviceMotionChange","onGetWifiList","onHCEMessage","onMemoryWarning","onNetworkStatusChange","onSocketClose","onSocketError","onSocketMessage","onSocketOpen","onUserCaptureScreen","onWifiConnected","onWindowResize","openBluetoothAdapter","openCard","openDocument","openLocation","openSetting","pageScrollTo","pauseBackgroundAudio","pauseVoice","plantClassify","playBackgroundAudio","playVoice","preloadSubPackage","previewImage","readBLECharacteristicValue","removeSavedFile","removeStorage","removeStorageSync","removeTabBarBadge","reportAnalytics","request","requestPayment","requestPolymerPayment","saveFile","saveImageToPhotosAlbum","saveVideoToPhotosAlbum","scanCode","seekBackgroundAudio","sendHCEMessage","sendSocketMessage","setBackgroundColor","setBackgroundTextStyle","setClipboardData","setEnableDebug","setInnerAudioOption","setKeepScreenOn","setNavigationBarColor","setNavigationBarTitle","setScreenBrightness","setStorage","setStorageSync","setTabBarBadge","setTabBarItem","setTabBarStyle","setTopBarText","setWifiList","showActionSheet","showLoading","showModal","showNavigationBarLoading","showShareMenu","showTabBar","showTabBarRedDot","showToast","startAccelerometer","startBeaconDiscovery","startBluetoothDevicesDiscovery","startCompass","startDeviceMotionListening","startFacialRecognitionVerify","startFacialRecognitionVerifyAndUploadVideo","startHCE","startPullDownRefresh","startRecord","startSoterAuthentication","startWifi","stopAccelerometer","stopBackgroundAudio","stopBeaconDiscovery","stopBluetoothDevicesDiscovery","stopCompass","stopDeviceMotionListening","stopHCE","stopPullDownRefresh","stopRecord","stopVoice","stopWifi","textReview","textToAudio","updateShareMenu","uploadFile","vibrateLong","vibrateShort","writeBLECharacteristicValue"])
|
|
1
|
+
module.exports = new Set(["EditorContext","addCard","addFileToFavorites","addInterceptor","addPhoneCalendar","addPhoneContact","addPhoneRepeatCalendar","addVideoToFavorites","advancedGeneralIdentify","animalClassify","arrayBufferToBase64","authPrivateMessage","authorize","authorizeForMiniProgram","base64ToArrayBuffer","canIUse","canvasGetImageData","canvasPutImageData","canvasToTempFilePath","carClassify","checkIsOpenAccessibility","checkIsSoterEnrolledInDevice","checkIsSupportFacialRecognition","checkIsSupportSoterAuthentication","checkSession","chooseAddress","chooseContact","chooseImage","chooseInvoice","chooseInvoiceTitle","chooseLicensePlate","chooseLocation","chooseMedia","chooseMessageFile","choosePoi","chooseVideo","clearStorage","clearStorageSync","closeBLEConnection","closeBluetoothAdapter","closeSocket","cloud","compressImage","compressVideo","connectSocket","connectWifi","createAnimation","createAudioContext","createBLEConnection","createBLEPeripheralServer","createBufferURL","createCameraContext","createCanvasContext","createInnerAudioContext","createIntersectionObserver","createInterstitialAd","createLivePlayerContext","createLivePusherContext","createMapContext","createMediaAudioPlayer","createMediaContainer","createMediaRecorder","createOffscreenCanvas","createRewardedVideoAd","createSelectorQuery","createTCPSocket","createUDPSocket","createVKSession","createVideoContext","createVideoDecoder","createWebAudioContext","createWorker","disableAlertBeforeUnload","dishClassify","downloadFile","drawCanvas","enableAlertBeforeUnload","exitMiniProgram","exitVoIPChat","faceDetect","faceVerifyForPay","getAccountInfoSync","getApp","getAvailableAudioSources","getBLEDeviceCharacteristics","getBLEDeviceRSSI","getBLEDeviceServices","getBLEMTU","getBackgroundAudioManager","getBackgroundAudioPlayerState","getBackgroundFetchData","getBackgroundFetchToken","getBatteryInfo","getBatteryInfoSync","getBeacons","getBluetoothAdapterState","getBluetoothDevices","getChannelsLiveInfo","getChannelsLiveNoticeInfo","getClipboardData","getConnectedBluetoothDevices","getConnectedWifi","getCurrentInstance","getCurrentPages","getEnterOptionsSync","getExptInfoSync","getExtConfig","getExtConfigSync","getFileInfo","getFileSystemManager","getGroupEnterInfo","getHCEState","getImageInfo","getLaunchOptionsSync","getLocalIPAddress","getLocation","getLogManager","getMenuButtonBoundingClientRect","getNFCAdapter","getNetworkType","getOpenUserInfo","getPerformance","getRandomValues","getRealtimeLogManager","getRecorderManager","getSavedFileInfo","getSavedFileList","getScreenBrightness","getSelectedTextRange","getSetting","getShareInfo","getStorage","getStorageInfo","getStorageInfoSync","getStorageSync","getSwanId","getSystemInfo","getSystemInfoSync","getUpdateManager","getUserCryptoManager","getUserInfo","getUserProfile","getVideoInfo","getWeRunData","getWifiList","hideHomeButton","hideKeyboard","hideLoading","hideNavigationBarLoading","hideShareMenu","hideTabBar","hideTabBarRedDot","hideToast","imageAudit","initFaceDetect","initTabBarApis","isBluetoothDevicePaired","joinVoIPChat","loadFontFace","login","logoClassify","makeBluetoothPair","makePhoneCall","navigateBack","navigateBackMiniProgram","navigateBackSmartProgram","navigateTo","navigateToMiniProgram","navigateToSmartGameProgram","navigateToSmartProgram","nextTick","notifyBLECharacteristicValueChange","objectDetectIdentify","ocrBankCard","ocrDrivingLicense","ocrIdCard","ocrVehicleLicense","offAccelerometerChange","offAppHide","offAppShow","offAudioInterruptionBegin","offAudioInterruptionEnd","offBLECharacteristicValueChange","offBLEConnectionStateChange","offBLEMTUChange","offBLEPeripheralConnectionStateChanged","offBeaconServiceChange","offBeaconUpdate","offBluetoothAdapterStateChange","offBluetoothDeviceFound","offCompassChange","offCopyUrl","offDeviceMotionChange","offError","offGetWifiList","offGyroscopeChange","offHCEMessage","offKeyboardHeightChange","offLocalServiceDiscoveryStop","offLocalServiceFound","offLocalServiceLost","offLocalServiceResolveFail","offLocationChange","offLocationChangeError","offMemoryWarning","offNetworkStatusChange","offPageNotFound","offThemeChange","offUnhandledRejection","offUserCaptureScreen","offVoIPChatInterrupted","offVoIPChatMembersChanged","offVoIPChatStateChanged","offVoIPVideoMembersChanged","offWifiConnected","offWindowResize","onAccelerometerChange","onAppHide","onAppShow","onAudioInterruptionBegin","onAudioInterruptionEnd","onBLECharacteristicValueChange","onBLEConnectionStateChange","onBLEMTUChange","onBLEPeripheralConnectionStateChanged","onBackgroundAudioPause","onBackgroundAudioPlay","onBackgroundAudioStop","onBackgroundFetchData","onBeaconServiceChange","onBeaconUpdate","onBluetoothAdapterStateChange","onBluetoothDeviceFound","onCompassChange","onCopyUrl","onDeviceMotionChange","onError","onGetWifiList","onGyroscopeChange","onHCEMessage","onKeyboardHeightChange","onLocalServiceDiscoveryStop","onLocalServiceFound","onLocalServiceLost","onLocalServiceResolveFail","onLocationChange","onLocationChangeError","onMemoryWarning","onNetworkStatusChange","onPageNotFound","onSocketClose","onSocketError","onSocketMessage","onSocketOpen","onThemeChange","onUnhandledRejection","onUserCaptureScreen","onVoIPChatInterrupted","onVoIPChatMembersChanged","onVoIPChatSpeakersChanged","onVoIPChatStateChanged","onVoIPVideoMembersChanged","onWifiConnected","onWindowResize","openBluetoothAdapter","openCard","openChannelsActivity","openChannelsEvent","openChannelsLive","openCustomerServiceChat","openDocument","openEmbeddedMiniProgram","openLocation","openSetting","openVideoEditor","pageScrollTo","pauseBackgroundAudio","pauseVoice","plantClassify","playBackgroundAudio","playVoice","pluginLogin","preloadSubPackage","previewImage","previewMedia","reLaunch","readBLECharacteristicValue","redirectTo","removeSavedFile","removeStorage","removeStorageSync","removeTabBarBadge","reportAnalytics","reportEvent","reportMonitor","reportPerformance","request","requestOrderPayment","requestPayment","requestPolymerPayment","requestSubscribeMessage","reserveChannelsLive","revokeBufferURL","saveFile","saveFileToDisk","saveImageToPhotosAlbum","saveVideoToPhotosAlbum","scanCode","seekBackgroundAudio","sendHCEMessage","sendSocketMessage","setBLEMTU","setBackgroundColor","setBackgroundFetchToken","setBackgroundTextStyle","setClipboardData","setEnable1v1Chat","setEnableDebug","setInnerAudioOption","setKeepScreenOn","setNavigationBarColor","setNavigationBarTitle","setPageInfo","setScreenBrightness","setStorage","setStorageSync","setTabBarBadge","setTabBarItem","setTabBarStyle","setTopBarText","setVisualEffectOnCapture","setWifiList","setWindowSize","shareFileMessage","shareToWeRun","shareVideoMessage","showActionSheet","showLoading","showModal","showNavigationBarLoading","showRedPackage","showShareImageMenu","showShareMenu","showTabBar","showTabBarRedDot","showToast","startAccelerometer","startBeaconDiscovery","startBluetoothDevicesDiscovery","startCompass","startDeviceMotionListening","startFacialRecognitionVerify","startFacialRecognitionVerifyAndUploadVideo","startGyroscope","startHCE","startLocalServiceDiscovery","startLocationUpdate","startLocationUpdateBackground","startPullDownRefresh","startRecord","startSoterAuthentication","startWifi","stopAccelerometer","stopBackgroundAudio","stopBeaconDiscovery","stopBluetoothDevicesDiscovery","stopCompass","stopDeviceMotionListening","stopFaceDetect","stopGyroscope","stopHCE","stopLocalServiceDiscovery","stopLocationUpdate","stopPullDownRefresh","stopRecord","stopVoice","stopWifi","subscribeVoIPVideoMembers","switchTab","textReview","textToAudio","updateShareMenu","updateVoIPChatMuteConfig","updateWeChatApp","uploadFile","vibrateLong","vibrateShort","writeBLECharacteristicValue"])
|
package/package.json
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/taro-h5",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.20",
|
|
4
4
|
"description": "Taro h5 framework",
|
|
5
|
-
"main:h5": "
|
|
5
|
+
"main:h5": "dist/index.js",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
7
|
-
"typings": "types/index.d.ts",
|
|
7
|
+
"typings": "src/types/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
10
10
|
"src",
|
|
11
|
-
"index.js"
|
|
12
|
-
"types"
|
|
13
|
-
],
|
|
14
|
-
"sideEffects": [
|
|
15
|
-
"*.scss",
|
|
16
|
-
"*.css",
|
|
17
|
-
"./src/taro/index.js"
|
|
11
|
+
"index.js"
|
|
18
12
|
],
|
|
13
|
+
"sideEffects": false,
|
|
19
14
|
"scripts": {
|
|
20
15
|
"test": "jest",
|
|
21
16
|
"test:dev": "jest --watch",
|
|
22
17
|
"test:coverage": "jest --coverage",
|
|
18
|
+
"prebuild": "tsc && copy src/**/*.css dist",
|
|
23
19
|
"build": "rollup -c",
|
|
24
|
-
"dev": "
|
|
20
|
+
"dev": "tsc -w"
|
|
25
21
|
},
|
|
26
22
|
"repository": {
|
|
27
23
|
"type": "git",
|
|
@@ -33,9 +29,10 @@
|
|
|
33
29
|
"author": "O2Team",
|
|
34
30
|
"license": "MIT",
|
|
35
31
|
"dependencies": {
|
|
36
|
-
"@tarojs/api": "3.3.
|
|
37
|
-
"@tarojs/router": "3.3.
|
|
38
|
-
"@tarojs/runtime": "3.3.
|
|
32
|
+
"@tarojs/api": "3.3.20",
|
|
33
|
+
"@tarojs/router": "3.3.20",
|
|
34
|
+
"@tarojs/runtime": "3.3.20",
|
|
35
|
+
"@tarojs/taro": "3.3.20",
|
|
39
36
|
"base64-js": "^1.3.0",
|
|
40
37
|
"jsonp-retry": "^1.0.3",
|
|
41
38
|
"mobile-detect": "^1.4.2",
|
|
@@ -45,5 +42,5 @@
|
|
|
45
42
|
"devDependencies": {
|
|
46
43
|
"jest-fetch-mock": "^3.0.3"
|
|
47
44
|
},
|
|
48
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "f98ceefaa3e419db5a6c3bcd3bf123ce5a0a0124"
|
|
49
46
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../utils'
|
|
2
|
+
|
|
3
|
+
export const setEnableDebug = temporarilyNotSupport('setEnableDebug')
|
|
4
|
+
export const getRealtimeLogManager = temporarilyNotSupport('getRealtimeLogManager')
|
|
5
|
+
export const getLogManager = temporarilyNotSupport('getLogManager')
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { fromByteArray, toByteArray } from 'base64-js'
|
|
2
|
+
|
|
3
|
+
import { temporarilyNotSupport } from '../utils'
|
|
4
|
+
|
|
5
|
+
// TODO env 环境变量
|
|
6
|
+
|
|
7
|
+
export const canIUse = temporarilyNotSupport('canIUse')
|
|
8
|
+
|
|
9
|
+
export function arrayBufferToBase64 (arrayBuffer) {
|
|
10
|
+
return fromByteArray(arrayBuffer)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function base64ToArrayBuffer (base64) {
|
|
14
|
+
return toByteArray(base64)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export * from './system'
|
|
18
|
+
export * from './update'
|
|
19
|
+
export * from './weapp/life-cycle'
|
|
20
|
+
export * from './weapp/app-event'
|
|
21
|
+
export * from './debug'
|
|
22
|
+
export * from './performance'
|
|
23
|
+
export * from './crypto'
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import Taro from '@tarojs/api'
|
|
2
|
+
import MobileDetect from 'mobile-detect'
|
|
3
|
+
|
|
4
|
+
import { MethodHandler } from '../../utils/handler'
|
|
5
|
+
|
|
6
|
+
export const getSystemInfoSync: typeof Taro.getSystemInfoSync = () => {
|
|
7
|
+
const md = new MobileDetect(navigator.userAgent)
|
|
8
|
+
|
|
9
|
+
const info: ReturnType<typeof Taro.getSystemInfoSync> = {
|
|
10
|
+
brand: md.mobile() || '', // 手机品牌
|
|
11
|
+
model: md.mobile() || '', // 手机型号
|
|
12
|
+
system: md.os(), // 操作系统版本
|
|
13
|
+
pixelRatio: window.devicePixelRatio, // 设备像素比
|
|
14
|
+
screenWidth: window.screen.width, // 屏幕宽度
|
|
15
|
+
screenHeight: window.screen.height, // 屏幕高度
|
|
16
|
+
windowWidth: document.documentElement.clientWidth, // 可使用窗口宽度
|
|
17
|
+
windowHeight: document.documentElement.clientHeight, // 可使用窗口高度
|
|
18
|
+
version: '', // 微信版本号
|
|
19
|
+
statusBarHeight: NaN, // 状态栏的高度
|
|
20
|
+
platform: navigator.platform, // 客户端平台
|
|
21
|
+
language: navigator.language, // 微信设置的语言
|
|
22
|
+
fontSizeSetting: NaN, // 用户字体大小设置。以“我-设置-通用-字体大小”中的设置为准,单位:px
|
|
23
|
+
SDKVersion: '', // 客户端基础库版本
|
|
24
|
+
|
|
25
|
+
// TODO
|
|
26
|
+
albumAuthorized: false,
|
|
27
|
+
benchmarkLevel: 0,
|
|
28
|
+
bluetoothEnabled: false,
|
|
29
|
+
cameraAuthorized: false,
|
|
30
|
+
enableDebug: false,
|
|
31
|
+
locationAuthorized: false,
|
|
32
|
+
locationEnabled: false,
|
|
33
|
+
microphoneAuthorized: false,
|
|
34
|
+
notificationAlertAuthorized: false,
|
|
35
|
+
notificationAuthorized: false,
|
|
36
|
+
notificationBadgeAuthorized: false,
|
|
37
|
+
notificationSoundAuthorized: false,
|
|
38
|
+
safeArea: {
|
|
39
|
+
bottom: 0,
|
|
40
|
+
height: 0,
|
|
41
|
+
left: 0,
|
|
42
|
+
right: 0,
|
|
43
|
+
top: 0,
|
|
44
|
+
width: 0
|
|
45
|
+
},
|
|
46
|
+
wifiEnabled: false
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return info
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export const getSystemInfo: typeof Taro.getSystemInfo = async (options = {}) => {
|
|
53
|
+
const { success, fail, complete } = options
|
|
54
|
+
const handle = new MethodHandler({ name: 'getSystemInfo', success, fail, complete })
|
|
55
|
+
|
|
56
|
+
try {
|
|
57
|
+
const info = await getSystemInfoSync()
|
|
58
|
+
return handle.success(info)
|
|
59
|
+
} catch (error) {
|
|
60
|
+
return handle.fail({
|
|
61
|
+
errMsg: error
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import Taro from '@tarojs/api'
|
|
2
|
+
|
|
3
|
+
import { MethodHandler } from '../../utils/handler'
|
|
4
|
+
import { temporarilyNotSupport } from '../../utils'
|
|
5
|
+
|
|
6
|
+
function getConnection () {
|
|
7
|
+
// @ts-ignore
|
|
8
|
+
return navigator.connection || navigator.mozConnection || navigator.webkitConnection || navigator.msConnection
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const getNetworkType: typeof Taro.getNetworkType = (options = {}) => {
|
|
12
|
+
const connection = getConnection()
|
|
13
|
+
const { success, fail, complete } = options
|
|
14
|
+
const handle = new MethodHandler<Taro.getNetworkType.SuccessCallbackResult>({ name: 'getNetworkType', success, fail, complete })
|
|
15
|
+
|
|
16
|
+
let networkType: keyof Taro.getNetworkType.networkType = 'unknown'
|
|
17
|
+
// 浏览器不支持获取网络状态
|
|
18
|
+
if (!connection) {
|
|
19
|
+
return handle.success({ networkType })
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// Supports only the navigator.connection.type value which doesn't match the latest spec.
|
|
23
|
+
// https://www.davidbcalhoun.com/2010/using-navigator-connection-android/
|
|
24
|
+
if (!isNaN(Number(connection.type))) {
|
|
25
|
+
switch (connection.type) {
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
case connection.WIFI:
|
|
28
|
+
networkType = 'wifi'
|
|
29
|
+
break
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
case connection.CELL_3G:
|
|
32
|
+
networkType = '3g'
|
|
33
|
+
break
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
case connection.CELL_2G:
|
|
36
|
+
networkType = '2g'
|
|
37
|
+
break
|
|
38
|
+
default:
|
|
39
|
+
// ETHERNET, UNKNOWN
|
|
40
|
+
networkType = 'unknown'
|
|
41
|
+
}
|
|
42
|
+
} else if (connection.type) {
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
networkType = connection.type // Only supports the type value.
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
} else if (connection.effectiveType) {
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
networkType = connection.effectiveType
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return handle.success({ networkType })
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const onNetworkStatusChange: typeof Taro.onNetworkStatusChange = (cb) => {
|
|
55
|
+
const connection = getConnection()
|
|
56
|
+
if (connection) {
|
|
57
|
+
connection.addEventListener('change', function () {
|
|
58
|
+
getNetworkType()
|
|
59
|
+
.then(res => {
|
|
60
|
+
const { networkType } = res
|
|
61
|
+
const isConnected = networkType !== 'none'
|
|
62
|
+
const obj = { isConnected, networkType }
|
|
63
|
+
cb(obj)
|
|
64
|
+
})
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const offNetworkStatusChange = temporarilyNotSupport('offNetworkStatusChange')
|
|
70
|
+
export const getLocalIPAddress = temporarilyNotSupport('getLocalIPAddress')
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { temporarilyNotSupport } from '../../utils'
|
|
2
|
+
|
|
3
|
+
// 应用级事件
|
|
4
|
+
export const onUnhandledRejection = temporarilyNotSupport('onUnhandledRejection')
|
|
5
|
+
export const onThemeChange = temporarilyNotSupport('onThemeChange')
|
|
6
|
+
export const onPageNotFound = temporarilyNotSupport('onPageNotFound')
|
|
7
|
+
export const onError = temporarilyNotSupport('onError')
|
|
8
|
+
export const onAudioInterruptionEnd = temporarilyNotSupport('onAudioInterruptionEnd')
|
|
9
|
+
export const onAudioInterruptionBegin = temporarilyNotSupport('onAudioInterruptionBegin')
|
|
10
|
+
export const onAppShow = temporarilyNotSupport('onAppShow')
|
|
11
|
+
export const onAppHide = temporarilyNotSupport('onAppHide')
|
|
12
|
+
export const offUnhandledRejection = temporarilyNotSupport('offUnhandledRejection')
|
|
13
|
+
export const offThemeChange = temporarilyNotSupport('offThemeChange')
|
|
14
|
+
export const offPageNotFound = temporarilyNotSupport('offPageNotFound')
|
|
15
|
+
export const offError = temporarilyNotSupport('offError')
|
|
16
|
+
export const offAudioInterruptionEnd = temporarilyNotSupport('offAudioInterruptionEnd')
|
|
17
|
+
export const offAudioInterruptionBegin = temporarilyNotSupport('offAudioInterruptionBegin')
|
|
18
|
+
export const offAppShow = temporarilyNotSupport('offAppShow')
|
|
19
|
+
export const offAppHide = temporarilyNotSupport('offAppHide')
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { CanvasGradient } from '@tarojs/api'
|
|
2
|
+
|
|
3
|
+
interface IAction {
|
|
4
|
+
func: (...arr: any[]) => void
|
|
5
|
+
args: any[]
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const TextBaseLineMap: Record<keyof Taro.CanvasContext.textBaseline, CanvasTextBaseline> = {
|
|
9
|
+
top: 'top',
|
|
10
|
+
bottom: 'bottom',
|
|
11
|
+
middle: 'middle',
|
|
12
|
+
normal: 'alphabetic'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class CanvasContext implements Taro.CanvasContext {
|
|
16
|
+
__raw__: CanvasRenderingContext2D
|
|
17
|
+
actions: IAction[] = []
|
|
18
|
+
|
|
19
|
+
constructor (canvas, ctx) {
|
|
20
|
+
this.canvas = canvas
|
|
21
|
+
this.ctx = ctx
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
set ctx (e: CanvasRenderingContext2D) {
|
|
25
|
+
this.__raw__ = e
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
get ctx () {
|
|
29
|
+
return this.__raw__ || {}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
canvas: HTMLCanvasElement
|
|
33
|
+
|
|
34
|
+
protected emptyActions () {
|
|
35
|
+
this.actions.length = 0
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
protected enqueueActions (func: IAction['func'], ...args) {
|
|
39
|
+
this.actions.push({
|
|
40
|
+
func,
|
|
41
|
+
args
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
set fillStyle (e) { this.enqueueActions(() => { this.ctx.fillStyle = e }) }
|
|
46
|
+
get fillStyle () { return this.ctx.fillStyle as string }
|
|
47
|
+
set font (e) { this.ctx.font = e }
|
|
48
|
+
get font () { return this.ctx.font }
|
|
49
|
+
set globalAlpha (e) { this.enqueueActions(() => { this.ctx.globalAlpha = e }) }
|
|
50
|
+
get globalAlpha () { return this.ctx.globalAlpha }
|
|
51
|
+
set globalCompositeOperation (e) { this.enqueueActions(() => { this.ctx.globalCompositeOperation = e }) }
|
|
52
|
+
get globalCompositeOperation () { return this.ctx.globalCompositeOperation }
|
|
53
|
+
set lineCap (e) { this.enqueueActions(() => { this.ctx.lineCap = e }) }
|
|
54
|
+
get lineCap () { return this.ctx.lineCap }
|
|
55
|
+
set lineDashOffset (e) { this.enqueueActions(() => { this.ctx.lineDashOffset = e }) }
|
|
56
|
+
get lineDashOffset () { return this.ctx.lineDashOffset }
|
|
57
|
+
set lineJoin (e) { this.enqueueActions(() => { this.ctx.lineJoin = e }) }
|
|
58
|
+
get lineJoin () { return this.ctx.lineJoin }
|
|
59
|
+
set lineWidth (e) { this.enqueueActions(() => { this.ctx.lineWidth = e }) }
|
|
60
|
+
get lineWidth () { return this.ctx.lineWidth }
|
|
61
|
+
set miterLimit (e) { this.enqueueActions(() => { this.ctx.miterLimit = e }) }
|
|
62
|
+
get miterLimit () { return this.ctx.miterLimit }
|
|
63
|
+
set shadowBlur (e) { this.enqueueActions(() => { this.ctx.shadowBlur = e }) }
|
|
64
|
+
get shadowBlur () { return this.ctx.shadowBlur }
|
|
65
|
+
set shadowColor (e) { this.enqueueActions(() => { this.ctx.shadowColor = e }) }
|
|
66
|
+
get shadowColor () { return this.ctx.shadowColor }
|
|
67
|
+
set shadowOffsetX (e) { this.enqueueActions(() => { this.ctx.shadowOffsetX = e }) }
|
|
68
|
+
get shadowOffsetX () { return this.ctx.shadowOffsetX }
|
|
69
|
+
set shadowOffsetY (e) { this.enqueueActions(() => { this.ctx.shadowOffsetY = e }) }
|
|
70
|
+
get shadowOffsetY () { return this.ctx.shadowOffsetY }
|
|
71
|
+
set strokeStyle (e) { this.enqueueActions(() => { this.ctx.strokeStyle = e }) }
|
|
72
|
+
get strokeStyle () { return this.ctx.strokeStyle as string }
|
|
73
|
+
/** 小程序文档中不包括 ↓↓↓ */
|
|
74
|
+
set textAlign (e) { this.ctx.textAlign = e }
|
|
75
|
+
get textAlign () { return this.ctx.textAlign }
|
|
76
|
+
set textBaseline (e) { this.ctx.textBaseline = e }
|
|
77
|
+
get textBaseline () { return this.ctx.textBaseline }
|
|
78
|
+
set direction (e) { this.ctx.direction = e }
|
|
79
|
+
get direction () { return this.ctx.direction }
|
|
80
|
+
set imageSmoothingEnabled (e) { this.enqueueActions(() => { this.ctx.imageSmoothingEnabled = e }) }
|
|
81
|
+
get imageSmoothingEnabled () { return this.ctx.imageSmoothingEnabled }
|
|
82
|
+
set imageSmoothingQuality (e) { this.enqueueActions(() => { this.ctx.imageSmoothingQuality = e }) }
|
|
83
|
+
get imageSmoothingQuality () { return this.ctx.imageSmoothingQuality }
|
|
84
|
+
set filter (e) { this.enqueueActions(() => { this.ctx.filter = e }) }
|
|
85
|
+
get filter () { return this.ctx.filter }
|
|
86
|
+
/** 小程序文档中不包括 ↑↑↑ */
|
|
87
|
+
|
|
88
|
+
arc (...args) { return this.enqueueActions(this.ctx.arc, ...args) }
|
|
89
|
+
arcTo (...args) { return this.enqueueActions(this.ctx.arcTo, ...args) }
|
|
90
|
+
beginPath (...args) { return this.enqueueActions(this.ctx.beginPath, ...args) }
|
|
91
|
+
bezierCurveTo (...args) { return this.enqueueActions(this.ctx.bezierCurveTo, ...args) }
|
|
92
|
+
clearRect (...args) { return this.enqueueActions(this.ctx.clearRect, ...args) }
|
|
93
|
+
clip (...args) { return this.enqueueActions(this.ctx.clip, ...args) }
|
|
94
|
+
closePath (...args) { return this.enqueueActions(this.ctx.closePath, ...args) }
|
|
95
|
+
|
|
96
|
+
createPattern (image: string, repetition: keyof Taro.CanvasContext.repetition): void {
|
|
97
|
+
return this.createPattern(image, repetition)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* 将之前在绘图上下文中的描述(路径、变形、样式)画到 canvas 中。
|
|
102
|
+
* @todo 每次 draw 都会读取 width 和 height
|
|
103
|
+
*/
|
|
104
|
+
async draw (reserve?: boolean, callback?: (...args: any[]) => any): Promise<void> {
|
|
105
|
+
try {
|
|
106
|
+
if (!reserve) {
|
|
107
|
+
this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// 部分 action 是异步的
|
|
111
|
+
for (const { func, args } of this.actions) {
|
|
112
|
+
await func.apply(this.ctx, args)
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
this.emptyActions()
|
|
116
|
+
callback && callback()
|
|
117
|
+
} catch (e) {
|
|
118
|
+
/* eslint-disable no-throw-literal */
|
|
119
|
+
throw {
|
|
120
|
+
errMsg: e.message
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
drawImage (imageResource: string, ...extra: any[]): void {
|
|
126
|
+
type TExtra = [number, number]
|
|
127
|
+
this.enqueueActions(() => {
|
|
128
|
+
// 需要转换为 Image
|
|
129
|
+
if (typeof imageResource === 'string') {
|
|
130
|
+
const img = new Image()
|
|
131
|
+
img.src = imageResource
|
|
132
|
+
return new Promise<void>((resolve, reject) => {
|
|
133
|
+
img.onload = () => {
|
|
134
|
+
this.ctx.drawImage(img, ...extra as TExtra)
|
|
135
|
+
resolve()
|
|
136
|
+
}
|
|
137
|
+
img.onerror = reject
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.ctx.drawImage(imageResource, ...extra as TExtra)
|
|
142
|
+
})
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
fill (...args) { return this.enqueueActions(this.ctx.fill, ...args) }
|
|
146
|
+
fillRect (...args) { return this.enqueueActions(this.ctx.fillRect, ...args) }
|
|
147
|
+
fillText (...args) { return this.enqueueActions(this.ctx.fillText, ...args) }
|
|
148
|
+
lineTo (...args) { return this.enqueueActions(this.ctx.lineTo, ...args) }
|
|
149
|
+
moveTo (...args) { return this.enqueueActions(this.ctx.moveTo, ...args) }
|
|
150
|
+
quadraticCurveTo (...args) { return this.enqueueActions(this.ctx.quadraticCurveTo, ...args) }
|
|
151
|
+
rect (...args) { return this.enqueueActions(this.ctx.rect, ...args) }
|
|
152
|
+
restore (...args) { return this.enqueueActions(this.ctx.restore, ...args) }
|
|
153
|
+
rotate (...args) { return this.enqueueActions(this.ctx.rotate, ...args) }
|
|
154
|
+
save (...args) { return this.enqueueActions(this.ctx.save, ...args) }
|
|
155
|
+
scale (...args) { return this.enqueueActions(this.ctx.scale, ...args) }
|
|
156
|
+
|
|
157
|
+
setFillStyle (color: string | CanvasGradient): void {
|
|
158
|
+
this.enqueueActions(() => { this.ctx.fillStyle = color })
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
setFontSize (fontSize: number): void {
|
|
162
|
+
this.font = `${fontSize}px`
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
setGlobalAlpha (alpha: number): void {
|
|
166
|
+
this.globalAlpha = alpha
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
setLineCap (lineCap: keyof Taro.CanvasContext.lineCap): void {
|
|
170
|
+
this.lineCap = lineCap
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
setLineDash (pattern: number[], offset: number): void {
|
|
174
|
+
this.enqueueActions(() => {
|
|
175
|
+
this.ctx.setLineDash(pattern)
|
|
176
|
+
this.ctx.lineDashOffset = offset
|
|
177
|
+
})
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
setLineJoin (lineJoin: keyof Taro.CanvasContext.lineJoin): void {
|
|
181
|
+
this.lineJoin = lineJoin
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
setLineWidth (lineWidth: number): void {
|
|
185
|
+
this.lineWidth = lineWidth
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
setMiterLimit (miterLimit: number): void {
|
|
189
|
+
this.miterLimit = miterLimit
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
setShadow (offsetX: number, offsetY: number, blur: number, color: string): void {
|
|
193
|
+
this.enqueueActions(() => {
|
|
194
|
+
this.ctx.shadowOffsetX = offsetX
|
|
195
|
+
this.ctx.shadowOffsetY = offsetY
|
|
196
|
+
this.ctx.shadowColor = color
|
|
197
|
+
this.ctx.shadowBlur = blur
|
|
198
|
+
})
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
setStrokeStyle (color: string | CanvasGradient): void {
|
|
202
|
+
this.enqueueActions(() => { this.ctx.strokeStyle = color })
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
setTextAlign (align: keyof Taro.CanvasContext.align): void {
|
|
206
|
+
this.textAlign = align
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
setTextBaseline (textBaseline: keyof Taro.CanvasContext.textBaseline): void {
|
|
210
|
+
this.textBaseline = TextBaseLineMap[textBaseline] || 'alphabetic'
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
setTransform (...args) { return this.enqueueActions(this.ctx.setTransform, ...args) }
|
|
214
|
+
stroke (...args) { return this.enqueueActions(this.ctx.stroke, ...args) }
|
|
215
|
+
strokeRect (...args) { return this.enqueueActions(this.ctx.strokeRect, ...args) }
|
|
216
|
+
strokeText (...args) { return this.enqueueActions(this.ctx.strokeText, ...args) }
|
|
217
|
+
transform (...args) { return this.enqueueActions(this.ctx.transform, ...args) }
|
|
218
|
+
translate (...args) { return this.enqueueActions(this.ctx.translate, ...args) }
|
|
219
|
+
|
|
220
|
+
measureText (text: string): TextMetrics {
|
|
221
|
+
return this.measureText(text)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
createCircularGradient (x: number, y: number, r: number): CanvasGradient {
|
|
225
|
+
const radialGradient = this.ctx.createRadialGradient(x, y, 0, x, y, r)
|
|
226
|
+
|
|
227
|
+
return radialGradient
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
createLinearGradient (x0: number, y0: number, x1: number, y1: number): CanvasGradient {
|
|
231
|
+
return this.createLinearGradient(x0, y0, x1, y1)
|
|
232
|
+
}
|
|
233
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Taro from '@tarojs/api'
|
|
2
|
+
import { MethodHandler } from '../utils/handler'
|
|
3
|
+
import { findDOM } from '../utils'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 获取 canvas 区域隐含的像素数据。
|
|
7
|
+
*/
|
|
8
|
+
export const canvasGetImageData: typeof Taro.canvasGetImageData = ({ canvasId, success, fail, complete, x, y, width, height }, inst) => {
|
|
9
|
+
const handle = new MethodHandler({ name: 'canvasGetImageData', success, fail, complete })
|
|
10
|
+
const el = findDOM(inst) as HTMLElement
|
|
11
|
+
const canvas = el?.querySelector(`canvas[canvas-id="${canvasId}"]`) as HTMLCanvasElement
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const ctx = canvas?.getContext('2d')
|
|
15
|
+
// TODO ImageData => Uint8ClampedArray
|
|
16
|
+
const data = ctx?.getImageData(x, y, width, height) as unknown as Uint8ClampedArray
|
|
17
|
+
return handle.success({
|
|
18
|
+
width,
|
|
19
|
+
height,
|
|
20
|
+
data
|
|
21
|
+
})
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return handle.fail({
|
|
24
|
+
errMsg: e.message
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Taro from '@tarojs/api'
|
|
2
|
+
import { MethodHandler } from '../utils/handler'
|
|
3
|
+
import { findDOM } from '../utils'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 将像素数据绘制到画布。在自定义组件下,第二个参数传入自定义组件实例 this,以操作组件内 <canvas> 组件
|
|
7
|
+
* @todo 暂未支持尺寸相关功能
|
|
8
|
+
*/
|
|
9
|
+
export const canvasPutImageData: typeof Taro.canvasPutImageData = ({ canvasId, data, x, y, success, fail, complete }, inst) => {
|
|
10
|
+
const handle = new MethodHandler({ name: 'canvasPutImageData', success, fail, complete })
|
|
11
|
+
const el = findDOM(inst) as HTMLElement
|
|
12
|
+
const canvas = el?.querySelector(`canvas[canvas-id="${canvasId}"]`) as HTMLCanvasElement
|
|
13
|
+
|
|
14
|
+
try {
|
|
15
|
+
const ctx = canvas.getContext('2d')
|
|
16
|
+
// TODO Uint8ClampedArray => ImageData
|
|
17
|
+
ctx?.putImageData(data as unknown as ImageData, x, y)
|
|
18
|
+
return handle.success()
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return handle.fail({
|
|
21
|
+
errMsg: e.message
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
}
|