import { AnyObj } from "../api/index.d" ; import intercetorApi , { wrapFn } from "../wxapi/index" ; function getSystemInfo ( params ) { if ( params . success ) { params . success ( { SDKVersion : "2.0.4" , batteryLevel : 100 , benchmarkLevel : 1 , brand : "devtools" , fontSizeSetting : 16 , language : "en" , model : "iPhone 5" , pixelRatio : 2 , platform : "devtools" , screenHeight : 568 , screenWidth : 320 , statusBarHeight : 20 , system : "iOS 10.0.1" , version : "7.0.4" , windowHeight : 504 , windowWidth : 320 , } ) ; } } function loadFontFace ( params ) { if ( params . success ) { params . success ( { status : "loaded" } ) ; } } function getSelectedTextRange ( params ) { if ( params . success ) { params . success ( { start : 0 , end : 0 } ) ; } } function downloadFile ( params ) { if ( params . success ) { params . success ( { statusCode : 400 } ) ; } } function uploadFile ( params ) { if ( params . success ) { params . success ( { statusCode : 400 } ) ; } } function connectSocket ( params ) { if ( params . fail ) { params . fail ( ) ; } } function closeSocket ( params ) { if ( params . fail ) { params . fail ( ) ; } } const asyncApis = [ "setEnableDebug" , "switchTab" , "reLaunch" , "redirectTo" , "navigateTo" , "navigateBack" , "showNavigationBarLoading" , "setNavigationBarTitle" , "setNavigationBarColor" , "hideNavigationBarLoading" , "hideHomeButton" , "setBackgroundTextStyle" , "setBackgroundColor" , "showTabBarRedDot" , "showTabBar" , "setTabBarStyle" , "setTabBarItem" , "setTabBarBadge" , "removeTabBarBadge" , "hideTabBarRedDot" , "hideTabBar" , "stopPullDownRefresh" , "startPullDownRefresh" , "pageScrollTo" , "setTopBarText" , "nextTick" , "hideKeyboard" , "sendSocketMessage" , "stopLocalServiceDiscovery" , "startLocalServiceDiscovery" , "setStorage" , "removeStorage" , "getStorageInfo" , "getStorage" , "clearStorage" , "setBackgroundFetchToken" , "onBackgroundFetchData" , "getBackgroundFetchToken" , "getBackgroundFetchData" , "saveImageToPhotosAlbum" , "previewImage" , "getImageInfo" , "compressImage" , "chooseMessageFile" , "chooseImage" , "saveVideoToPhotosAlbum" , "chooseVideo" , "chooseMedia" , "stopVoice" , "setInnerAudioOption" , "playVoice" , "pauseVoice" , "getAvailableAudioSources" , "stopBackgroundAudio" , "seekBackgroundAudio" , "playBackgroundAudio" , "pauseBackgroundAudio" , "getBackgroundAudioPlayerState" , "startRecord" , "stopRecord" , "stopLocationUpdate" , "startLocationUpdateBackground" , "startLocationUpdate" , "openLocation" , "getLocation" , "chooseLocation" , "updateShareMenu" , "showShareMenu" , "hideShareMenu" , "getShareInfo" , "canvasToTempFilePath" , "canvasPutImageData" , "canvasGetImageData" , "saveFile" , "removeSavedFile" , "openDocument" , "getSavedFileList" , "getSavedFileInfo" , "getFileInfo" , "login" , "checkSession" , "navigateToMiniProgram" , "navigateBackMiniProgram" , "getUserInfo" , "reportMonitor" , "reportAnalytics" , "requestPayment" , "authorize" , "openSetting" , "getSetting" , "chooseAddress" , "openCard" , "addCard" , "chooseInvoiceTitle" , "chooseInvoice" , "startSoterAuthentication" , "checkIsSupportSoterAuthentication" , "checkIsSoterEnrolledInDevice" , "getWeRunData" , "requestSubscribeMessage" , "showRedPackage" , "stopBluetoothDevicesDiscovery" , "startBluetoothDevicesDiscovery" , "openBluetoothAdapter" , "getConnectedBluetoothDevices" , "getBluetoothDevices" , "getBluetoothAdapterState" , "closeBluetoothAdapter" , "stopBeaconDiscovery" , "startBeaconDiscovery" , "getBeacons" , "stopWifi" , "startWifi" , "setWifiList" , "getWifiList" , "getConnectedWifi" , "connectWifi" , "addPhoneContact" , "writeBLECharacteristicValue" , "readBLECharacteristicValue" , "notifyBLECharacteristicValueChange" , "getBLEDeviceServices" , "getBLEDeviceCharacteristics" , "createBLEConnection" , "closeBLEConnection" , "getBatteryInfo" , "setClipboardData" , "getClipboardData" , "stopHCE" , "startHCE" , "sendHCEMessage" , "getHCEState" , "getNetworkType" , "setScreenBrightness" , "setKeepScreenOn" , "getScreenBrightness" , "makePhoneCall" , "stopAccelerometer" , "startAccelerometer" , "stopCompass" , "startCompass" , "stopDeviceMotionListening" , "startDeviceMotionListening" , "stopGyroscope" , "startGyroscope" , "scanCode" , "vibrateShort" , "vibrateLong" , ] ; const apis = { } ; asyncApis . forEach ( key => { apis [ key ] = function ( params ) { if ( params . success ) { params . success ( { } ) ; } } ; } ) ; const promiseApis = { } ; intercetorApi ( promiseApis , apis ) ; promiseApis . getSystemInfo = wrapFn ( getSystemInfo ) ; promiseApis . loadFontFace = wrapFn ( loadFontFace ) ; promiseApis . getSelectedTextRange = wrapFn ( getSelectedTextRange ) ; promiseApis . downloadFile = wrapFn ( downloadFile ) ; promiseApis . uploadFile = wrapFn ( uploadFile ) ; promiseApis . connectSocket = wrapFn ( connectSocket ) ; promiseApis . closeSocket = wrapFn ( closeSocket ) ; export default promiseApis ;