@tarojs/taro-h5 3.4.0-beta.2 → 3.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/dist/api/ad/index.js +4 -0
  2. package/dist/api/ai/facial.js +5 -0
  3. package/dist/api/ai/index.js +2 -0
  4. package/dist/api/ai/visual.js +5 -0
  5. package/dist/api/alipay/index.js +3 -0
  6. package/dist/api/base/crypto.js +3 -0
  7. package/dist/api/base/debug.js +4 -0
  8. package/dist/api/base/index.js +17 -0
  9. package/dist/api/base/performance.js +4 -0
  10. package/dist/api/base/system.js +187 -0
  11. package/dist/api/base/update.js +4 -0
  12. package/dist/api/base/weapp/app-event.js +18 -0
  13. package/dist/api/base/weapp/life-cycle.js +4 -0
  14. package/dist/api/canvas/CanvasContext.js +191 -0
  15. package/dist/api/canvas/canvasGetImageData.js +25 -0
  16. package/dist/api/canvas/canvasPutImageData.js +22 -0
  17. package/dist/api/canvas/canvasToTempFilePath.js +22 -0
  18. package/dist/api/canvas/createCanvasContext.js +16 -0
  19. package/dist/api/canvas/index.js +12 -0
  20. package/dist/api/cloud/index.js +21 -0
  21. package/dist/api/data-analysis/index.js +5 -0
  22. package/dist/api/device/accelerometer.js +83 -0
  23. package/dist/api/device/accessibility.js +3 -0
  24. package/dist/api/device/battery.js +21 -0
  25. package/dist/api/device/bluetooth-ble.js +18 -0
  26. package/dist/api/device/bluetooth-peripheral.js +5 -0
  27. package/dist/api/device/bluetooth.js +15 -0
  28. package/dist/api/device/calendar.js +4 -0
  29. package/dist/api/device/clipboard.js +65 -0
  30. package/dist/api/device/compass.js +64 -0
  31. package/dist/api/device/contact.js +4 -0
  32. package/dist/api/device/crypto.js +3 -0
  33. package/dist/api/device/gyroscope.js +6 -0
  34. package/dist/api/device/iBeacon.js +9 -0
  35. package/dist/api/device/index.js +23 -0
  36. package/dist/api/device/keyboard.js +6 -0
  37. package/dist/api/device/memory.js +4 -0
  38. package/dist/api/device/motion.js +81 -0
  39. package/dist/api/device/network.js +78 -0
  40. package/dist/api/device/nfc.js +9 -0
  41. package/dist/api/device/phone.js +24 -0
  42. package/dist/api/device/scan.js +6 -0
  43. package/dist/api/device/screen.js +8 -0
  44. package/dist/api/device/vibrate.js +35 -0
  45. package/dist/api/device/wifi.js +13 -0
  46. package/dist/api/ext/index.js +4 -0
  47. package/dist/api/files/index.js +10 -0
  48. package/dist/api/framework/index.js +7 -0
  49. package/dist/api/index.js +24 -0
  50. package/dist/api/location/chooseLocation.js +93 -0
  51. package/dist/api/location/index.js +13 -0
  52. package/dist/api/location/style.css +79 -0
  53. package/dist/api/media/EditorContext.js +19 -0
  54. package/dist/api/media/audio/InnerAudioContext.js +84 -0
  55. package/dist/api/media/audio/index.js +15 -0
  56. package/dist/api/media/background-audio/BackgroundAudioManager.js +86 -0
  57. package/dist/api/media/background-audio/index.js +15 -0
  58. package/dist/api/media/camera.js +3 -0
  59. package/dist/api/media/image/chooseImage.js +74 -0
  60. package/dist/api/media/image/getImageInfo.js +31 -0
  61. package/dist/api/media/image/index.js +9 -0
  62. package/dist/api/media/image/previewImage.js +67 -0
  63. package/dist/api/media/index.js +12 -0
  64. package/dist/api/media/live.js +4 -0
  65. package/dist/api/media/map.js +3 -0
  66. package/dist/api/media/media-recorder.js +3 -0
  67. package/dist/api/media/recorder.js +5 -0
  68. package/dist/api/media/video/index.js +74 -0
  69. package/dist/api/media/video-decoder.js +3 -0
  70. package/dist/api/media/video-processing.js +3 -0
  71. package/dist/api/media/voip.js +16 -0
  72. package/dist/api/navigate/index.js +6 -0
  73. package/dist/api/network/download.js +124 -0
  74. package/dist/api/network/index.js +7 -0
  75. package/dist/api/network/mdns.js +12 -0
  76. package/dist/api/network/request/index.js +125 -0
  77. package/dist/api/network/tcp.js +3 -0
  78. package/dist/api/network/udp.js +3 -0
  79. package/dist/api/network/upload.js +146 -0
  80. package/dist/api/network/utils.js +65 -0
  81. package/dist/api/network/websocket/index.js +70 -0
  82. package/dist/api/network/websocket/socketTask.js +63 -0
  83. package/dist/api/open-api/account.js +3 -0
  84. package/dist/api/open-api/address.js +3 -0
  85. package/dist/api/open-api/authorize.js +4 -0
  86. package/dist/api/open-api/card.js +4 -0
  87. package/dist/api/open-api/channels-live.js +8 -0
  88. package/dist/api/open-api/customer-service.js +3 -0
  89. package/dist/api/open-api/facial.js +6 -0
  90. package/dist/api/open-api/favorites.js +4 -0
  91. package/dist/api/open-api/group.js +3 -0
  92. package/dist/api/open-api/index.js +18 -0
  93. package/dist/api/open-api/invoice.js +4 -0
  94. package/dist/api/open-api/license-plate.js +3 -0
  95. package/dist/api/open-api/login.js +5 -0
  96. package/dist/api/open-api/red-package.js +3 -0
  97. package/dist/api/open-api/settings.js +4 -0
  98. package/dist/api/open-api/soter.js +5 -0
  99. package/dist/api/open-api/subscribe-message.js +3 -0
  100. package/dist/api/open-api/user-info.js +4 -0
  101. package/dist/api/open-api/werun.js +4 -0
  102. package/dist/api/payment/index.js +4 -0
  103. package/dist/api/route/index.js +3 -0
  104. package/dist/api/share/index.js +12 -0
  105. package/dist/api/storage/background-fetch.js +6 -0
  106. package/dist/api/storage/index.js +157 -0
  107. package/dist/api/swan/index.js +26 -0
  108. package/dist/api/taro.js +47 -0
  109. package/dist/api/ui/animation/index.js +288 -0
  110. package/dist/api/ui/background.js +4 -0
  111. package/dist/api/ui/custom-component.js +3 -0
  112. package/dist/api/ui/fonts.js +51 -0
  113. package/dist/api/ui/index.js +12 -0
  114. package/dist/api/ui/interaction/actionSheet.js +188 -0
  115. package/dist/api/ui/interaction/index.js +268 -0
  116. package/dist/api/ui/interaction/modal.js +207 -0
  117. package/dist/api/ui/interaction/toast.js +195 -0
  118. package/dist/api/ui/menu.js +3 -0
  119. package/dist/api/ui/navigation-bar/index.js +42 -0
  120. package/dist/api/ui/pull-down-refresh.js +26 -0
  121. package/dist/api/ui/scroll/index.js +83 -0
  122. package/dist/api/ui/sticky.js +3 -0
  123. package/dist/api/ui/tab-bar.js +282 -0
  124. package/dist/api/ui/window.js +31 -0
  125. package/dist/api/utils/handler.js +80 -0
  126. package/dist/api/utils/index.js +172 -0
  127. package/dist/api/worker/index.js +3 -0
  128. package/dist/api/wxml/index.js +6 -0
  129. package/dist/api/wxml/nodesRef.js +42 -0
  130. package/dist/api/wxml/selectorQuery.js +201 -0
  131. package/dist/index.cjs.js +5028 -6988
  132. package/dist/index.js +4 -10767
  133. package/dist/taroApis.js +1 -1
  134. package/dist/types/type.js +2 -0
  135. package/package.json +11 -13
  136. package/src/api/ai/visual.ts +3 -0
  137. package/src/api/base/system.ts +207 -0
  138. package/src/api/canvas/CanvasContext.ts +42 -39
  139. package/src/api/canvas/createCanvasContext.ts +2 -2
  140. package/src/api/canvas/index.ts +10 -2
  141. package/src/api/cloud/index.ts +4 -0
  142. package/src/api/device/battery.ts +18 -1
  143. package/src/api/device/index.ts +1 -0
  144. package/src/api/{base/system → device}/network.ts +35 -15
  145. package/src/api/device/wifi.ts +1 -0
  146. package/src/api/location/chooseLocation.ts +2 -2
  147. package/src/api/media/{editor.ts → EditorContext.ts} +2 -0
  148. package/src/api/media/audio/InnerAudioContext.ts +98 -0
  149. package/src/api/media/audio/index.ts +1 -86
  150. package/src/api/media/background-audio/BackgroundAudioManager.ts +103 -0
  151. package/src/api/media/{background-audio.ts → background-audio/index.ts} +7 -2
  152. package/src/api/media/image/previewImage.ts +4 -25
  153. package/src/api/media/index.ts +0 -1
  154. package/src/api/network/download.ts +5 -5
  155. package/src/api/network/upload.ts +7 -13
  156. package/src/api/network/websocket/index.ts +1 -1
  157. package/src/api/ui/animation/index.ts +11 -12
  158. package/src/api/ui/fonts.ts +61 -2
  159. package/src/api/ui/interaction/index.ts +12 -10
  160. package/src/api/ui/navigation-bar/index.ts +2 -2
  161. package/src/api/ui/scroll/index.ts +3 -3
  162. package/src/api/utils/handler.ts +4 -4
  163. package/src/api/utils/index.ts +34 -13
  164. package/src/api/wxml/nodesRef.ts +10 -3
  165. package/src/api/wxml/selectorQuery.ts +68 -23
  166. package/src/index.ts +2 -2
  167. package/src/api/base/system/index.ts +0 -2
  168. package/src/api/base/system/info.ts +0 -64
package/dist/taroApis.js CHANGED
@@ -1 +1 @@
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"])
1
+ module.exports = new Set(["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","enableAlertBeforeUnload","exitMiniProgram","exitVoIPChat","faceDetect","faceVerifyForPay","getAccountInfoSync","getApp","getAppAuthorizeSetting","getAppBaseInfo","getAvailableAudioSources","getBLEDeviceCharacteristics","getBLEDeviceRSSI","getBLEDeviceServices","getBLEMTU","getBackgroundAudioManager","getBackgroundAudioPlayerState","getBackgroundFetchData","getBackgroundFetchToken","getBatteryInfo","getBatteryInfoSync","getBeacons","getBluetoothAdapterState","getBluetoothDevices","getChannelsLiveInfo","getChannelsLiveNoticeInfo","getClipboardData","getConnectedBluetoothDevices","getConnectedWifi","getCurrentInstance","getCurrentPages","getDeviceInfo","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","getSystemInfoAsync","getSystemInfoSync","getSystemSetting","getUpdateManager","getUserCryptoManager","getUserInfo","getUserProfile","getVideoInfo","getWeRunData","getWifiList","getWindowInfo","hideHomeButton","hideKeyboard","hideLoading","hideNavigationBarLoading","hideShareMenu","hideTabBar","hideTabBarRedDot","hideToast","imageAudit","initFaceDetect","initTabBarApis","isBluetoothDevicePaired","isVKSupport","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","offNetworkWeakChange","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","onNetworkWeakChange","onPageNotFound","onSocketClose","onSocketError","onSocketMessage","onSocketOpen","onThemeChange","onUnhandledRejection","onUserCaptureScreen","onVoIPChatInterrupted","onVoIPChatMembersChanged","onVoIPChatSpeakersChanged","onVoIPChatStateChanged","onVoIPVideoMembersChanged","onWifiConnected","onWifiConnectedWithPartialInfo","onWindowResize","openAppAuthorizeSetting","openBluetoothAdapter","openCard","openChannelsActivity","openChannelsEvent","openChannelsLive","openCustomerServiceChat","openDocument","openEmbeddedMiniProgram","openLocation","openSetting","openSystemBluetoothSetting","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"])
@@ -0,0 +1,2 @@
1
+ const TaroH5 = {};
2
+ export default TaroH5;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarojs/taro-h5",
3
- "version": "3.4.0-beta.2",
3
+ "version": "3.4.2",
4
4
  "description": "Taro h5 framework",
5
5
  "main:h5": "dist/index.js",
6
6
  "main": "dist/index.cjs.js",
@@ -10,17 +10,15 @@
10
10
  "src",
11
11
  "index.js"
12
12
  ],
13
- "sideEffects": [
14
- "*.scss",
15
- "*.css",
16
- "./src/taro/index.js"
17
- ],
13
+ "sideEffects": false,
18
14
  "scripts": {
19
15
  "test": "jest",
16
+ "test:ci": "jest -i --coverage false",
20
17
  "test:dev": "jest --watch",
21
18
  "test:coverage": "jest --coverage",
22
- "build": "rollup -c",
23
- "dev": "rollup -cw"
19
+ "copy:assets": "copy src/**/*.css dist",
20
+ "build": "rollup -c && npm run copy:assets && tsc",
21
+ "dev": "tsc -w & npm run copy:assets"
24
22
  },
25
23
  "repository": {
26
24
  "type": "git",
@@ -32,14 +30,14 @@
32
30
  "author": "O2Team",
33
31
  "license": "MIT",
34
32
  "dependencies": {
35
- "@tarojs/api": "3.4.0-beta.2",
36
- "@tarojs/router": "3.4.0-beta.2",
37
- "@tarojs/runtime": "3.4.0-beta.2",
38
- "@tarojs/taro": "3.4.0-beta.2",
33
+ "@tarojs/api": "3.4.2",
34
+ "@tarojs/router": "3.4.2",
35
+ "@tarojs/runtime": "3.4.2",
36
+ "@tarojs/taro": "3.4.2",
39
37
  "base64-js": "^1.3.0",
40
38
  "jsonp-retry": "^1.0.3",
41
39
  "mobile-detect": "^1.4.2",
42
40
  "whatwg-fetch": "^3.4.0"
43
41
  },
44
- "gitHead": "ac3eb29f11aec15d25e061775d9e970efabc2c98"
42
+ "gitHead": "26b329326c6a7da652e8d712ee33df01ab8d2d0e"
45
43
  }
@@ -1,4 +1,7 @@
1
1
  import { temporarilyNotSupport } from '../utils'
2
2
 
3
+ // 判断支持版本
4
+ export const isVKSupport = temporarilyNotSupport('isVKSupport')
5
+
3
6
  // 视觉算法
4
7
  export const createVKSession = temporarilyNotSupport('createVKSession')
@@ -0,0 +1,207 @@
1
+ import Taro from '@tarojs/api'
2
+ import MobileDetect from 'mobile-detect'
3
+
4
+ import { temporarilyNotSupport } from '../utils'
5
+ import { MethodHandler } from '../utils/handler'
6
+
7
+ /** 跳转系统蓝牙设置页 */
8
+ export const openSystemBluetoothSetting = temporarilyNotSupport('openSystemBluetoothSetting')
9
+
10
+ /** 跳转系统微信授权管理页 */
11
+ export const openAppAuthorizeSetting = temporarilyNotSupport('openAppAuthorizeSetting')
12
+
13
+ /** 获取窗口信息 */
14
+ export const getWindowInfo: typeof Taro.getWindowInfo = () => {
15
+ const info: ReturnType<typeof Taro.getWindowInfo> = {
16
+ /** 设备像素比 */
17
+ pixelRatio: window.devicePixelRatio,
18
+ /** 屏幕宽度,单位px */
19
+ screenWidth: window.screen.width,
20
+ /** 屏幕高度,单位px */
21
+ screenHeight: window.screen.height,
22
+ /** 可使用窗口宽度,单位px */
23
+ windowWidth: document.documentElement.clientWidth,
24
+ /** 可使用窗口高度,单位px */
25
+ windowHeight: document.documentElement.clientHeight,
26
+ /** 状态栏的高度,单位px */
27
+ statusBarHeight: NaN,
28
+ /** 在竖屏正方向下的安全区域 */
29
+ safeArea: {
30
+ bottom: 0,
31
+ height: 0,
32
+ left: 0,
33
+ right: 0,
34
+ top: 0,
35
+ width: 0
36
+ }
37
+ }
38
+
39
+ return info
40
+ }
41
+
42
+ /** 获取设备设置 */
43
+ export const getSystemSetting: typeof Taro.getSystemSetting = () => {
44
+ const isLandscape = window.screen.width >= window.screen.height
45
+ const info: ReturnType<typeof Taro.getSystemSetting> = {
46
+ /** 蓝牙的系统开关 */
47
+ bluetoothEnabled: false,
48
+ /** 地理位置的系统开关 */
49
+ locationEnabled: false,
50
+ /** Wi-Fi 的系统开关 */
51
+ wifiEnabled: false,
52
+ /** 设备方向 */
53
+ deviceOrientation: isLandscape ? 'landscape' : 'portrait'
54
+ }
55
+
56
+ return info
57
+ }
58
+
59
+ /** 获取设备设置 */
60
+ export const getDeviceInfo: typeof Taro.getDeviceInfo = () => {
61
+ const md = new MobileDetect(navigator.userAgent)
62
+
63
+ const info: ReturnType<typeof Taro.getDeviceInfo> = {
64
+ /** 应用二进制接口类型(仅 Android 支持) */
65
+ abi: '',
66
+ /** 设备性能等级(仅Android小游戏)。取值为:-2 或 0(该设备无法运行小游戏),-1(性能未知),>=1(设备性能值,该值越高,设备性能越好,目前最高不到50) */
67
+ benchmarkLevel: -1,
68
+ /** 设备品牌 */
69
+ brand: md.mobile() || '',
70
+ /** 设备型号 */
71
+ model: md.mobile() || '',
72
+ /** 操作系统及版本 */
73
+ system: md.os(),
74
+ /** 客户端平台 */
75
+ platform: navigator.platform
76
+ }
77
+
78
+ return info
79
+ }
80
+
81
+ /** 获取微信APP基础信息 */
82
+ export const getAppBaseInfo: typeof Taro.getAppBaseInfo = () => {
83
+ let isDarkMode = false
84
+ if (window.matchMedia?.('(prefers-color-scheme: dark)').matches) {
85
+ isDarkMode = true
86
+ }
87
+
88
+ const info: ReturnType<typeof Taro.getAppBaseInfo> = {
89
+ /** 客户端基础库版本 */
90
+ SDKVersion: '',
91
+ /** 是否已打开调试。可通过右上角菜单或 [Taro.setEnableDebug](/docs/apis/base/debug/setEnableDebug) 打开调试。 */
92
+ enableDebug: process.env.NODE_ENV === 'development',
93
+ /** 当前小程序运行的宿主环境 */
94
+ // host: { appId: '' },
95
+ /** 微信设置的语言 */
96
+ language: navigator.language,
97
+ /** 微信版本号 */
98
+ version: '',
99
+ /** 系统当前主题,取值为light或dark,全局配置"darkmode":true时才能获取,否则为 undefined (不支持小游戏) */
100
+ theme: isDarkMode ? 'dark' : 'light'
101
+ }
102
+
103
+ return info
104
+ }
105
+
106
+ /** 获取微信APP授权设置 */
107
+ export const getAppAuthorizeSetting: typeof Taro.getAppAuthorizeSetting = () => {
108
+ const info: ReturnType<typeof Taro.getAppAuthorizeSetting> = {
109
+ /** 允许微信使用相册的开关(仅 iOS 有效) */
110
+ albumAuthorized: 'not determined',
111
+ /** 允许微信使用蓝牙的开关(仅 iOS 有效) */
112
+ bluetoothAuthorized: 'not determined',
113
+ /** 允许微信使用摄像头的开关 */
114
+ cameraAuthorized: 'not determined',
115
+ /** 允许微信使用定位的开关 */
116
+ locationAuthorized: 'not determined',
117
+ /** 定位准确度。true 表示模糊定位,false 表示精确定位(仅 iOS 有效) */
118
+ locationReducedAccuracy: false,
119
+ /** 允许微信使用麦克风的开关 */
120
+ microphoneAuthorized: 'not determined',
121
+ /** 允许微信通知的开关 */
122
+ notificationAuthorized: 'not determined',
123
+ /** 允许微信通知带有提醒的开关(仅 iOS 有效) */
124
+ notificationAlertAuthorized: 'not determined',
125
+ /** 允许微信通知带有标记的开关(仅 iOS 有效) */
126
+ notificationBadgeAuthorized: 'not determined',
127
+ /** 允许微信通知带有声音的开关(仅 iOS 有效) */
128
+ notificationSoundAuthorized: 'not determined',
129
+ /** 允许微信使用日历的开关 */
130
+ phoneCalendarAuthorized: 'not determined'
131
+ }
132
+
133
+ return info
134
+ }
135
+
136
+ /** 获取设备设置 */
137
+ export const getSystemInfoSync: typeof Taro.getSystemInfoSync = () => {
138
+ const windowInfo = getWindowInfo()
139
+ const systemSetting = getSystemSetting()
140
+ const deviceInfo: Taro.getDeviceInfo.Result = getDeviceInfo()
141
+ const appBaseInfo = getAppBaseInfo()
142
+ const appAuthorizeSetting = getAppAuthorizeSetting()
143
+ delete deviceInfo.abi
144
+
145
+ const info: ReturnType<typeof Taro.getSystemInfoSync> = {
146
+ ...windowInfo,
147
+ ...systemSetting,
148
+ ...deviceInfo,
149
+ ...appBaseInfo,
150
+ /** 用户字体大小(单位px)。以微信客户端「我-设置-通用-字体大小」中的设置为准 */
151
+ fontSizeSetting: NaN,
152
+ /** 允许微信使用相册的开关(仅 iOS 有效) */
153
+ albumAuthorized: appAuthorizeSetting.albumAuthorized === 'authorized',
154
+ /** 允许微信使用摄像头的开关 */
155
+ cameraAuthorized: appAuthorizeSetting.cameraAuthorized === 'authorized',
156
+ /** 允许微信使用定位的开关 */
157
+ locationAuthorized: appAuthorizeSetting.locationAuthorized === 'authorized',
158
+ /** 允许微信使用麦克风的开关 */
159
+ microphoneAuthorized: appAuthorizeSetting.microphoneAuthorized === 'authorized',
160
+ /** 允许微信通知的开关 */
161
+ notificationAuthorized: appAuthorizeSetting.notificationAuthorized === 'authorized',
162
+ /** 允许微信通知带有提醒的开关(仅 iOS 有效) */
163
+ notificationAlertAuthorized: appAuthorizeSetting.notificationAlertAuthorized === 'authorized',
164
+ /** 允许微信通知带有标记的开关(仅 iOS 有效) */
165
+ notificationBadgeAuthorized: appAuthorizeSetting.notificationBadgeAuthorized === 'authorized',
166
+ /** 允许微信通知带有声音的开关(仅 iOS 有效) */
167
+ notificationSoundAuthorized: appAuthorizeSetting.notificationSoundAuthorized === 'authorized',
168
+ /** 允许微信使用日历的开关 */
169
+ phoneCalendarAuthorized: appAuthorizeSetting.phoneCalendarAuthorized === 'authorized',
170
+ /** `true` 表示模糊定位,`false` 表示精确定位,仅 iOS 支持 */
171
+ locationReducedAccuracy: appAuthorizeSetting.locationReducedAccuracy,
172
+ /** 小程序当前运行环境 */
173
+ environment: ''
174
+ }
175
+
176
+ return info
177
+ }
178
+
179
+ /** 获取系统信息 */
180
+ export const getSystemInfoAsync: typeof Taro.getSystemInfoAsync = async (options = {}) => {
181
+ const { success, fail, complete } = options
182
+ const handle = new MethodHandler({ name: 'getSystemInfoAsync', success, fail, complete })
183
+
184
+ try {
185
+ const info = await getSystemInfoSync()
186
+ return handle.success(info)
187
+ } catch (error) {
188
+ return handle.fail({
189
+ errMsg: error
190
+ })
191
+ }
192
+ }
193
+
194
+ /** 获取系统信息 */
195
+ export const getSystemInfo: typeof Taro.getSystemInfo = async (options = {}) => {
196
+ const { success, fail, complete } = options
197
+ const handle = new MethodHandler({ name: 'getSystemInfo', success, fail, complete })
198
+
199
+ try {
200
+ const info = await getSystemInfoSync()
201
+ return handle.success(info)
202
+ } catch (error) {
203
+ return handle.fail({
204
+ errMsg: error
205
+ })
206
+ }
207
+ }
@@ -5,7 +5,7 @@ interface IAction {
5
5
  args: any[]
6
6
  }
7
7
 
8
- const TextBaseLineMap: Record<keyof Taro.CanvasContext.textBaseline, CanvasTextBaseline> = {
8
+ const TextBaseLineMap: Record<keyof Taro.CanvasContext.TextBaseline, CanvasTextBaseline> = {
9
9
  top: 'top',
10
10
  bottom: 'bottom',
11
11
  middle: 'middle',
@@ -16,12 +16,17 @@ export class CanvasContext implements Taro.CanvasContext {
16
16
  __raw__: CanvasRenderingContext2D
17
17
  actions: IAction[] = []
18
18
 
19
+ constructor (canvas, ctx) {
20
+ this.canvas = canvas
21
+ this.ctx = ctx
22
+ }
23
+
19
24
  set ctx (e: CanvasRenderingContext2D) {
20
25
  this.__raw__ = e
21
26
  }
22
27
 
23
28
  get ctx () {
24
- return this.__raw__
29
+ return this.__raw__ || {}
25
30
  }
26
31
 
27
32
  canvas: HTMLCanvasElement
@@ -30,13 +35,11 @@ export class CanvasContext implements Taro.CanvasContext {
30
35
  this.actions.length = 0
31
36
  }
32
37
 
33
- protected enqueueActions (func: IAction['func']) {
34
- return (...args) => {
35
- this.actions.push({
36
- func,
37
- args
38
- })
39
- }
38
+ protected enqueueActions (func: IAction['func'], ...args) {
39
+ this.actions.push({
40
+ func,
41
+ args
42
+ })
40
43
  }
41
44
 
42
45
  set fillStyle (e) { this.enqueueActions(() => { this.ctx.fillStyle = e }) }
@@ -82,15 +85,15 @@ export class CanvasContext implements Taro.CanvasContext {
82
85
  get filter () { return this.ctx.filter }
83
86
  /** 小程序文档中不包括 ↑↑↑ */
84
87
 
85
- arc = this.enqueueActions(this.ctx.arc)
86
- arcTo = this.enqueueActions(this.ctx.arcTo)
87
- beginPath = this.enqueueActions(this.ctx.beginPath)
88
- bezierCurveTo = this.enqueueActions(this.ctx.bezierCurveTo)
89
- clearRect = this.enqueueActions(this.ctx.clearRect)
90
- clip = this.enqueueActions(this.ctx.clip)
91
- closePath = this.enqueueActions(this.ctx.closePath)
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) }
92
95
 
93
- createPattern (image: string, repetition: keyof Taro.CanvasContext.repetition): void {
96
+ createPattern (image: string, repetition: keyof Taro.CanvasContext.Repetition): void {
94
97
  return this.createPattern(image, repetition)
95
98
  }
96
99
 
@@ -139,17 +142,17 @@ export class CanvasContext implements Taro.CanvasContext {
139
142
  })
140
143
  }
141
144
 
142
- fill = this.enqueueActions(this.ctx.fill)
143
- fillRect = this.enqueueActions(this.ctx.fillRect)
144
- fillText = this.enqueueActions(this.ctx.fillText)
145
- lineTo = this.enqueueActions(this.ctx.lineTo)
146
- moveTo = this.enqueueActions(this.ctx.moveTo)
147
- quadraticCurveTo = this.enqueueActions(this.ctx.quadraticCurveTo)
148
- rect = this.enqueueActions(this.ctx.rect)
149
- restore = this.enqueueActions(this.ctx.restore)
150
- rotate = this.enqueueActions(this.ctx.rotate)
151
- save = this.enqueueActions(this.ctx.save)
152
- scale = this.enqueueActions(this.ctx.scale)
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) }
153
156
 
154
157
  setFillStyle (color: string | CanvasGradient): void {
155
158
  this.enqueueActions(() => { this.ctx.fillStyle = color })
@@ -163,7 +166,7 @@ export class CanvasContext implements Taro.CanvasContext {
163
166
  this.globalAlpha = alpha
164
167
  }
165
168
 
166
- setLineCap (lineCap: keyof Taro.CanvasContext.lineCap): void {
169
+ setLineCap (lineCap: keyof Taro.CanvasContext.LineCap): void {
167
170
  this.lineCap = lineCap
168
171
  }
169
172
 
@@ -174,7 +177,7 @@ export class CanvasContext implements Taro.CanvasContext {
174
177
  })
175
178
  }
176
179
 
177
- setLineJoin (lineJoin: keyof Taro.CanvasContext.lineJoin): void {
180
+ setLineJoin (lineJoin: keyof Taro.CanvasContext.LineJoin): void {
178
181
  this.lineJoin = lineJoin
179
182
  }
180
183
 
@@ -199,23 +202,23 @@ export class CanvasContext implements Taro.CanvasContext {
199
202
  this.enqueueActions(() => { this.ctx.strokeStyle = color })
200
203
  }
201
204
 
202
- setTextAlign (align: keyof Taro.CanvasContext.align): void {
205
+ setTextAlign (align: keyof Taro.CanvasContext.Align): void {
203
206
  this.textAlign = align
204
207
  }
205
208
 
206
- setTextBaseline (textBaseline: keyof Taro.CanvasContext.textBaseline): void {
209
+ setTextBaseline (textBaseline: keyof Taro.CanvasContext.TextBaseline): void {
207
210
  this.textBaseline = TextBaseLineMap[textBaseline] || 'alphabetic'
208
211
  }
209
212
 
210
- setTransform = this.enqueueActions(this.ctx.setTransform)
211
- stroke = this.enqueueActions(this.ctx.stroke)
212
- strokeRect = this.enqueueActions(this.ctx.strokeRect)
213
- strokeText = this.enqueueActions(this.ctx.strokeText)
214
- transform = this.enqueueActions(this.ctx.transform)
215
- translate = this.enqueueActions(this.ctx.translate)
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) }
216
219
 
217
220
  measureText (text: string): TextMetrics {
218
- return this.measureText(text)
221
+ return this.ctx.measureText(text)
219
222
  }
220
223
 
221
224
  createCircularGradient (x: number, y: number, r: number): CanvasGradient {
@@ -6,10 +6,10 @@ import { CanvasContext } from './CanvasContext'
6
6
  * 创建 canvas 的绘图上下文 CanvasContext 对象
7
7
  */
8
8
  export const createCanvasContext: typeof Taro.createCanvasContext = (canvasId, inst) => {
9
- const context = new CanvasContext()
10
9
  const el = findDOM(inst) as HTMLElement
11
10
  const canvas = el?.querySelector(`canvas[canvas-id="${canvasId}"]`) as HTMLCanvasElement
12
- const ctx = canvas?.getContext('2d')
11
+ const ctx = canvas?.getContext('2d') as CanvasRenderingContext2D
12
+ const context = new CanvasContext(canvas, ctx)
13
13
  if (!ctx) return context
14
14
  context.canvas = canvas
15
15
  context.ctx = ctx
@@ -1,10 +1,18 @@
1
1
  import { temporarilyNotSupport } from '../utils'
2
2
 
3
3
  // 画布
4
+
5
+ /** 创建离屏 canvas 实例 */
4
6
  export const createOffscreenCanvas = temporarilyNotSupport('createOffscreenCanvas')
7
+
8
+ /** 创建 canvas 的绘图上下文 CanvasContext 对象 */
5
9
  export * from './createCanvasContext'
10
+
11
+ /** 把当前画布指定区域的内容导出生成指定大小的图片 */
6
12
  export * from './canvasToTempFilePath'
13
+
14
+ /** 将像素数据绘制到画布 */
7
15
  export * from './canvasPutImageData'
8
- export * from './canvasGetImageData'
9
16
 
10
- export const drawCanvas = temporarilyNotSupport('drawCanvas')
17
+ /** 获取 canvas 区域隐含的像素数据 */
18
+ export * from './canvasGetImageData'
@@ -8,6 +8,7 @@ export class cloud implements Taro.cloud {
8
8
 
9
9
  CloudID = temporarilyNotSupport('cloud.CloudID')
10
10
 
11
+ // @ts-ignore
11
12
  callFunction = temporarilyNotSupport('cloud.callFunction')
12
13
 
13
14
  // @ts-ignore
@@ -16,12 +17,15 @@ export class cloud implements Taro.cloud {
16
17
  // @ts-ignore
17
18
  downloadFile = temporarilyNotSupport('cloud.downloadFile')
18
19
 
20
+ // @ts-ignore
19
21
  getTempFileURL = temporarilyNotSupport('cloud.getTempFileURL')
20
22
 
23
+ // @ts-ignore
21
24
  deleteFile = temporarilyNotSupport('cloud.deleteFile')
22
25
 
23
26
  // @ts-ignore
24
27
  database = temporarilyNotSupport('cloud.database')
25
28
 
29
+ // @ts-ignore
26
30
  callContainer = temporarilyNotSupport('cloud.callContainer')
27
31
  }
@@ -1,5 +1,22 @@
1
+ import Taro from '@tarojs/api'
1
2
  import { temporarilyNotSupport } from '../utils'
3
+ import { MethodHandler } from '../utils/handler'
2
4
 
3
5
  // 电量
4
6
  export const getBatteryInfoSync = temporarilyNotSupport('getBatteryInfoSync')
5
- export const getBatteryInfo = temporarilyNotSupport('getBatteryInfo')
7
+
8
+ export const getBatteryInfo: typeof Taro.getBatteryInfo = async ({ success, fail, complete } = {}) => {
9
+ const handle = new MethodHandler({ name: 'getBatteryInfo', success, fail, complete })
10
+ try {
11
+ // @ts-ignore
12
+ const battery = await navigator.getBattery?.()
13
+ return handle.success({
14
+ isCharging: battery.charging,
15
+ level: Number(battery.level || 0) * 100
16
+ })
17
+ } catch (error) {
18
+ return handle.fail({
19
+ errMsg: error?.message || error
20
+ })
21
+ }
22
+ }
@@ -14,6 +14,7 @@ export * from './iBeacon'
14
14
  export * from './keyboard'
15
15
  export * from './memory'
16
16
  export * from './motion'
17
+ export * from './network'
17
18
  export * from './nfc'
18
19
  export * from './phone'
19
20
  export * from './scan'
@@ -1,7 +1,7 @@
1
1
  import Taro from '@tarojs/api'
2
2
 
3
- import { MethodHandler } from '../../utils/handler'
4
- import { temporarilyNotSupport } from '../../utils'
3
+ import { CallbackManager, MethodHandler } from '../utils/handler'
4
+ import { temporarilyNotSupport } from '../utils'
5
5
 
6
6
  function getConnection () {
7
7
  // @ts-ignore
@@ -13,7 +13,7 @@ export const getNetworkType: typeof Taro.getNetworkType = (options = {}) => {
13
13
  const { success, fail, complete } = options
14
14
  const handle = new MethodHandler<Taro.getNetworkType.SuccessCallbackResult>({ name: 'getNetworkType', success, fail, complete })
15
15
 
16
- let networkType: keyof Taro.getNetworkType.networkType = 'unknown'
16
+ let networkType: keyof Taro.getNetworkType.NetworkType = 'unknown'
17
17
  // 浏览器不支持获取网络状态
18
18
  if (!connection) {
19
19
  return handle.success({ networkType })
@@ -51,20 +51,40 @@ export const getNetworkType: typeof Taro.getNetworkType = (options = {}) => {
51
51
  return handle.success({ networkType })
52
52
  }
53
53
 
54
- export const onNetworkStatusChange: typeof Taro.onNetworkStatusChange = (cb) => {
54
+ const networkStatusManager = new CallbackManager()
55
+
56
+ const networkStatusListener = async () => {
57
+ const { networkType } = await getNetworkType()
58
+ const isConnected = networkType !== 'none'
59
+ const obj = { isConnected, networkType }
60
+ networkStatusManager.trigger(obj)
61
+ }
62
+
63
+ /**
64
+ * 在最近的八次网络请求中, 出现下列三个现象之一则判定弱网。
65
+ * - 出现三次以上连接超时
66
+ * - 出现三次 rtt 超过 400
67
+ * - 出现三次以上的丢包
68
+ * > 弱网事件通知规则是: 弱网状态变化时立即通知, 状态不变时 30s 内最多通知一次。
69
+ */
70
+ export const onNetworkWeakChange = temporarilyNotSupport('onNetworkWeakChange')
71
+
72
+ export const onNetworkStatusChange: typeof Taro.onNetworkStatusChange = callback => {
73
+ networkStatusManager.add(callback)
74
+ const connection = getConnection()
75
+ if (connection && networkStatusManager.count() === 1) {
76
+ connection.addEventListener('change', networkStatusListener)
77
+ }
78
+ }
79
+
80
+ export const offNetworkWeakChange = temporarilyNotSupport('offNetworkStatusChange')
81
+
82
+ export const offNetworkStatusChange: typeof Taro.offNetworkStatusChange = callback => {
83
+ networkStatusManager.remove(callback)
55
84
  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
- })
85
+ if (connection && networkStatusManager.count() === 0) {
86
+ connection.removeEventListener('change', networkStatusListener)
66
87
  }
67
88
  }
68
89
 
69
- export const offNetworkStatusChange = temporarilyNotSupport('offNetworkStatusChange')
70
90
  export const getLocalIPAddress = temporarilyNotSupport('getLocalIPAddress')
@@ -4,6 +4,7 @@ import { temporarilyNotSupport } from '../utils'
4
4
  export const stopWifi = temporarilyNotSupport('stopWifi')
5
5
  export const startWifi = temporarilyNotSupport('startWifi')
6
6
  export const setWifiList = temporarilyNotSupport('setWifiList')
7
+ export const onWifiConnectedWithPartialInfo = temporarilyNotSupport('onWifiConnectedWithPartialInfo')
7
8
  export const onWifiConnected = temporarilyNotSupport('onWifiConnected')
8
9
  export const onGetWifiList = temporarilyNotSupport('onGetWifiList')
9
10
  export const offWifiConnected = temporarilyNotSupport('offWifiConnected')