diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index da6577d..277f5cc 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -5,7 +5,7 @@ name: Node.js CI on: push: - branches: [ "main" ] + branches: [ "master" ] pull_request: branches: '*' diff --git a/__app/component/AutoFillOtp/AutoFillOtp.js b/__app/component/AutoFillOtp/AutoFillOtp.js index efa3b7b..6a4653b 100644 --- a/__app/component/AutoFillOtp/AutoFillOtp.js +++ b/__app/component/AutoFillOtp/AutoFillOtp.js @@ -7,11 +7,20 @@ const abortAutoFill = (abort, time) => { }, time * 60 * 1000); }; +const defaultProps = { + successCb: (() => {}), + failureCb: (() => {}), + successMsg: 'OTP autofilled successfully', + failureMsg: { + UN_SUPPORTED_FEATURE: 'Your device is not supporting AutofillOTP', + ERROR: '', + }, +}; function AutoFillOtp(props = {}) { - const successCb = props.successCb || (() => {}); - const failureCb = props.failureCb || (() => {}); - const successMsg = props.successMsg || ''; - const failureMsg = props.failureMsg || {}; + const successCb = props.successCb || defaultProps.successCb; + const failureCb = props.failureCb || defaultProps.failureCb; + const successMsg = props.successMsg || defaultProps.successMsg; + const failureMsg = { ...defaultProps.failureMsg, ...props.failureMsg }; if (AutoFillOtp.isBrowserSupport()) { const abort = new AbortController(); @@ -24,7 +33,7 @@ function AutoFillOtp(props = {}) { handleSuccess({ msgType: 'SUCCESSFUL', msg: successMsg, successCb, data: code }); }).catch((error) => handleError({ msgType: 'ERROR', msg: error, failureCb })); } else { - return handleError({ msgType: 'UN_SUPPORTED_FEATURE', msg: failureMsg.unSupported || 'Your device is not supporting AutofillOTP', failureCb }); + return handleError({ msgType: 'UN_SUPPORTED_FEATURE', msg: failureMsg.unSupported, failureCb }); } } diff --git a/__app/component/ColorPicker/ColorPicker.js b/__app/component/ColorPicker/ColorPicker.js index 8120e9b..a183d77 100644 --- a/__app/component/ColorPicker/ColorPicker.js +++ b/__app/component/ColorPicker/ColorPicker.js @@ -3,13 +3,20 @@ import PropTypes from 'prop-types'; import { handleSuccess, handleError } from '../services/handlerService'; import Wrapper from '../Wrapper/Wrapper'; +const failureMsgDefault = { + unSupported: 'Your browser does not support the Color Picker fetaure', + error: 'Unable to copy color code', +}; + function ColorPicker({ successCb, failureCb, successMsg, - failureMsg, + failureMsg: failureMsgProps, children, }) { + const failureMsg = { ...failureMsgDefault, ...failureMsgProps }; + const pickColor = () => { if (ColorPicker.isBrowserSupport()) { const eyeDropper = new globalThis.EyeDropper(); @@ -45,10 +52,7 @@ ColorPicker.defaultProps = { successCb: () => {}, failureCb: () => {}, successMsg: 'Color copied successfully!!', - failureMsg: { - unSupported: 'Your browser does not support the Color Picker fetaure', - error: 'Unable to copy color code', - }, + failureMsg: { ...failureMsgDefault }, }; export default Wrapper(ColorPicker); diff --git a/__app/component/CopyToClipboard/CopyToClipboard.js b/__app/component/CopyToClipboard/CopyToClipboard.js index 590b6d5..285118b 100644 --- a/__app/component/CopyToClipboard/CopyToClipboard.js +++ b/__app/component/CopyToClipboard/CopyToClipboard.js @@ -3,15 +3,22 @@ import PropTypes from 'prop-types'; import { handleSuccess, handleError, handleLoading } from '../services/handlerService'; import Wrapper from '../Wrapper/Wrapper'; +const failureMsgDefault = { + unSupported: 'Copy To ClipBoard is not supporting in your device', + error: 'Unable to copy', +}; + function CopyToClipboard({ successCb, failureCb, loadingCb, successMsg, - failureMsg, + failureMsg: failureMsgProps, children, elementToBeCopy, }) { + const failureMsg = { ...failureMsgDefault, ...failureMsgProps }; + const copyText = () => { if (CopyToClipboard.isBrowserSupport()) { handleLoading({ loadingCb }); @@ -45,10 +52,7 @@ CopyToClipboard.defaultProps = { failureCb: () => {}, loadingCb: () => {}, successMsg: 'Copied Successfully', - failureMsg: { - unSupported: 'Copy To ClipBoard is not supporting in your device', - error: 'Unable to copy', - }, + failureMsg: { ...failureMsgDefault }, }; export default Wrapper(CopyToClipboard); diff --git a/__app/component/FaceDetector/FaceDetectorInit.js b/__app/component/FaceDetector/FaceDetectorInit.js index 0219e2b..894da6a 100644 --- a/__app/component/FaceDetector/FaceDetectorInit.js +++ b/__app/component/FaceDetector/FaceDetectorInit.js @@ -15,16 +15,16 @@ const failureMsgDefault = { }; function FaceDetectorInit({ - successCb, + // successCb, failureCb, loadingCb, - successMsg, - failureMsg, + // successMsg, + failureMsg: failureMsgProps, cameraType, zIndex, children, }) { - const failureMsgMerge = { ...failureMsgDefault, ...failureMsg }; + const failureMsg = { ...failureMsgDefault, ...failureMsgProps }; let list = null; let video = null; let facingMode; @@ -63,7 +63,7 @@ function FaceDetectorInit({ // clearTimeout(unmoutRenderLoop); } } catch (error) { - return handleError({ msgType: 'BAR_CODE_DETECTION_FAILED', msg: failureMsgMerge.barCodeDetectionFailed || JSON.stringify(error), failureCb }); + return handleError({ msgType: 'BAR_CODE_DETECTION_FAILED', msg: failureMsg.barCodeDetectionFailed || JSON.stringify(error), failureCb }); } } @@ -112,7 +112,7 @@ function FaceDetectorInit({ }, }); } catch (error) { - return handleError({ msgType: 'STREAMING_FAILED', msg: failureMsgMerge.streamingFailed || JSON.stringify(error), failureCb }); + return handleError({ msgType: 'STREAMING_FAILED', msg: failureMsg.streamingFailed || JSON.stringify(error), failureCb }); } return mediaStream; }; @@ -131,7 +131,7 @@ function FaceDetectorInit({ }); setFlash((s) => !s); } catch (error) { - return handleError({ msgType: 'FLASH_UPSUPPORTED', msg: failureMsgMerge.flashUnsupported, failureCb }); + return handleError({ msgType: 'FLASH_UPSUPPORTED', msg: failureMsg.flashUnsupported, failureCb }); } return true; }; @@ -152,7 +152,7 @@ function FaceDetectorInit({ startVideo(); } else { - return handleError({ msgType: 'UN_SUPPORTED_FEATURE', msg: failureMsgMerge.unSupported, failureCb }); + return handleError({ msgType: 'UN_SUPPORTED_FEATURE', msg: failureMsg.unSupported, failureCb }); } return true; @@ -176,10 +176,6 @@ function FaceDetectorInit({ allClear, toggleCamera, toggleFlash, - successCb, - successMsg, - failureCb, - failureMsg, })) } { @@ -206,20 +202,20 @@ function FaceDetectorInit({ FaceDetectorInit.isBrowserSupport = () => navigator?.mediaDevices && globalThis.FaceDetector; FaceDetectorInit.propTypes = { - successCb: PropTypes.func, + // successCb: PropTypes.func, failureCb: PropTypes.func, loadingCb: PropTypes.func, - successMsg: PropTypes.string, + // successMsg: PropTypes.string, failureMsg: PropTypes.object, zIndex: PropTypes.number, cameraType: PropTypes.oneOf(['back', 'front']), }; FaceDetectorInit.defaultProps = { - successCb: () => {}, + // successCb: () => {}, failureCb: () => {}, loadingCb: () => {}, - successMsg: '', + // successMsg: '', failureMsg: { ...failureMsgDefault }, zIndex: 9, cameraType: 'back', diff --git a/__app/component/LiveLocationTracking/LiveLocationTracking.js b/__app/component/LiveLocationTracking/LiveLocationTracking.js index ee9c35c..4bd3201 100644 --- a/__app/component/LiveLocationTracking/LiveLocationTracking.js +++ b/__app/component/LiveLocationTracking/LiveLocationTracking.js @@ -5,6 +5,17 @@ import dependentJsService from '../services/dependentJsService'; import { handleError, handleSuccess, handleLoading } from '../services/handlerService'; import Wrapper from '../Wrapper/Wrapper'; +const failureMsgDefault = { + unSupported: 'LiveLocationTracking is not supporting in your device', + permissionDenied: 'Permission Denied', + unableToLocateDirection: 'Unable To get Updated Location', + browserPermissionAPIFailed: 'Unable to check browser permission', + unableToLoadGoogleAPI: 'Unable to load google api script', + locationNotFound: 'Unable To get Updated Location', + googleAPIKeyMissing: 'Unable to check browser permission', + error: '', +}; + const checkPermitByBrowser = async (failureMsg, failureCb) => { try { const permissions = await navigator.permissions.query({ name: 'geolocation' }); @@ -35,7 +46,7 @@ function LiveLocationTracking({ successCb, failureCb, successMsg, - failureMsg, + failureMsg: failureMsgProps, loadingCb, googleKey, isProdKey, @@ -53,6 +64,7 @@ function LiveLocationTracking({ let directionsService; let directionsRenderer; let watchID = null; + const failureMsg = { ...failureMsgDefault, ...failureMsgProps }; const createMarker = async (googleMap, userCurrenrLocation, url) => { const { AdvancedMarkerElement } = await google.maps.importLibrary('marker'); @@ -238,17 +250,8 @@ LiveLocationTracking.defaultProps = { failureCb: () => {}, loadingCb: () => {}, successMsg: '', - failureMsg: { - unSupported: 'LiveLocationTracking is not supporting in your device', - permissionDenied: 'Permission Denied', - unableToLocateDirection: 'Unable To get Updated Location', - browserPermissionAPIFailed: 'Unable to check browser permission', - unableToLoadGoogleAPI: 'Unable to load google api script', - locationNotFound: 'Unable To get Updated Location', - // invalidLatLng: '', - googleAPIKeyMissing: 'Unable to check browser permission', - error: '', - }, + failureMsg: { ...failureMsgDefault }, + destinationLatLng: { lat: 12.9387901, lng: 77.6407703 }, isProdKey: true, googleKey: '', diff --git a/__app/component/LocateMe/LocateMe.js b/__app/component/LocateMe/LocateMe.js index 036de21..e200695 100644 --- a/__app/component/LocateMe/LocateMe.js +++ b/__app/component/LocateMe/LocateMe.js @@ -4,6 +4,16 @@ import Wrapper from '../Wrapper/Wrapper'; import { handleSuccess, handleError, handleLoading } from '../services/handlerService'; import dependentJsService from '../services/dependentJsService'; +const failureMsgDefault = { + unSupported: 'LocationMe is not supporting in your device', + permissionDenied: 'Permission Denied', + googleAPIKeyMissing: 'Google Key is missing', + unableToLoadGoogleAPI: 'Unable to load google api script', + browserPermissionAPIFailed: 'Unable to check browser permission', + invalidLatLng: 'Invalid Lat lng', + error: '', +}; + const checkPermitByBrowser = async (failureMsg, failureCb) => { try { const permissions = await navigator.permissions.query({ name: 'geolocation' }); @@ -79,18 +89,19 @@ function LocateMe({ successCb, failureCb, successMsg, - failureMsg, + failureMsg: failureMsgProps, loadingCb, children, isProdKey, googleKey, }) { + const failureMsg = { ...failureMsgDefault, ...failureMsgProps }; + const onClick = async () => { if (LocateMe.isBrowserSupport()) { handleLoading({ loadingCb }); const isPermitByBrowser = await checkPermitByBrowser(failureMsg, failureCb); const isScriptInBrowser = await checkScriptInBrowser( - failureMsg, failureCb, isProdKey, @@ -154,15 +165,7 @@ LocateMe.defaultProps = { failureCb: () => {}, loadingCb: () => {}, successMsg: 'Located Successfully', - failureMsg: { - unSupported: 'LocationMe is not supporting in your device', - permissionDenied: 'Permission Denied', - browserPermissionAPIFailed: 'Unable to check browser permission', - googleAPIKeyMissing: 'Google Key is missing', - unableToLoadGoogleAPI: 'Unable to load google api script', - invalidLatLng: 'Invalid Lat lng', - error: '', - }, + failureMsg: { ...failureMsgDefault }, isProdKey: true, googleKey: '', }; diff --git a/__app/component/PhoneBook/PhoneBook.js b/__app/component/PhoneBook/PhoneBook.js index 3008963..bfa4155 100644 --- a/__app/component/PhoneBook/PhoneBook.js +++ b/__app/component/PhoneBook/PhoneBook.js @@ -3,16 +3,24 @@ import PropTypes from 'prop-types'; import { handleSuccess, handleError, handleLoading } from '../services/handlerService'; import Wrapper from '../Wrapper/Wrapper'; +const failureMsgDefault = { + unSupported: 'PhoneBook is not supporting in your device', + cancelled: 'Feature Cancelled', + error: 'Unable to fetch details from PhoneBook', +}; + function PhoneBook({ successCb, failureCb, loadingCb, successMsg, - failureMsg, + failureMsg: failureMsgProps, children, contactProperty, isSelectMultiple, }) { + const failureMsg = { ...failureMsgDefault, ...failureMsgProps }; + const getContacts = async () => { const opts = { multiple: isSelectMultiple }; if (PhoneBook.isBrowserSupport()) { @@ -60,11 +68,7 @@ PhoneBook.defaultProps = { failureCb: () => {}, loadingCb: () => {}, successMsg: 'Phonebook details fetch Successfully', - failureMsg: { - unSupported: 'PhoneBook is not supporting in your device', - cancelled: 'Feature Cancelled', - error: 'Unable to fetch details from PhoneBook', - }, + failureMsg: { ...failureMsgDefault }, contactProperty: ['name', 'email', 'tel', 'address', 'icon'], isSelectMultiple: false, }; diff --git a/__app/component/Scanner/ScannerInit.js b/__app/component/Scanner/ScannerInit.js index c16aa45..56f4ea9 100644 --- a/__app/component/Scanner/ScannerInit.js +++ b/__app/component/Scanner/ScannerInit.js @@ -8,12 +8,21 @@ let mediaStream = null; let videoUnmount = null; let unmoutRenderLoop = null; +const failureMsgDefault = { + unSupported: 'QR-Code/Bar-Code/UPI Scanner is not supporting in your device', + streamingFailed: 'Camera streaming failed', + barCodeDetectionFailed: 'Bar code detection failed', + invalidImage: 'Invalid Images', + flashUnsupported: 'Flash is not supporting in your device', + unableToScan: 'Unable to scan', +}; + function ScannerInit({ successCb, failureCb, loadingCb, successMsg, - failureMsg, + failureMsg: failureMsgProps, cameraType, zIndex, children, @@ -21,6 +30,7 @@ function ScannerInit({ let list = null; let video = null; let facingMode; + const failureMsg = { ...failureMsgDefault, ...failureMsgProps }; const [flash, setFlash] = useState(false); const [isBrowser, setIsBrowser] = useState(false); @@ -198,14 +208,7 @@ ScannerInit.defaultProps = { failureCb: () => {}, loadingCb: () => {}, successMsg: '', - failureMsg: { - unSupported: 'QR-Code/Bar-Code/UPI Scanner is not supporting in your device', - streamingFailed: 'Camera streaming failed', - barCodeDetectionFailed: 'Bar code detection failed', - invalidImage: 'Invalid Images', - flashUnsupported: 'Flash is not supporting in your device', - unableToScan: 'Unable to scan', - }, + failureMsg: { ...failureMsgDefault }, zIndex: 9, cameraType: 'back', }; diff --git a/__app/component/Share/Share.js b/__app/component/Share/Share.js index 9f1b98e..00b9a49 100644 --- a/__app/component/Share/Share.js +++ b/__app/component/Share/Share.js @@ -3,6 +3,12 @@ import PropTypes from 'prop-types'; import { handleSuccess, handleError, handleLoading } from '../services/handlerService'; import Wrapper from '../Wrapper/Wrapper'; +const failureMsgDefault = { + unSupported: 'Share is not supporting in your device', + badRequest: 'Missing props', + error: 'Unable to share', +}; + const isShareAPIDataValid = (sharingData) => { if (navigator.canShare) { return navigator.canShare(sharingData); @@ -16,12 +22,13 @@ function Share({ failureCb, loadingCb, successMsg, - failureMsg, + failureMsg: failureMsgProps, children, sName, sTitle, sUrl, }) { + const failureMsg = { ...failureMsgDefault, ...failureMsgProps }; const sharingData = { title: sName, text: sTitle, url: sUrl }; const showDropdown = () => { @@ -65,11 +72,7 @@ Share.defaultProps = { failureCb: () => {}, loadingCb: () => {}, successMsg: 'Shared Successfully', - failureMsg: { - unSupported: 'Share is not supporting in your device', - badRequest: 'Missing props', - error: 'Unable to share', - }, + failureMsg: { ...failureMsgDefault }, sName: 'fe-pilot', sTitle: 'A React library for advance JS features', sUrl: 'https://www.npmjs.com/package/fe-pilot', diff --git a/__app/component/TextToSpeech/TextToSpeechInit.js b/__app/component/TextToSpeech/TextToSpeechInit.js index 2c5beef..6b71c23 100644 --- a/__app/component/TextToSpeech/TextToSpeechInit.js +++ b/__app/component/TextToSpeech/TextToSpeechInit.js @@ -4,15 +4,22 @@ import Wrapper from '../Wrapper/Wrapper'; import textToSpeech from './textToSpeechService'; import { handleSuccess, handleError, handleLoading } from '../services/handlerService'; +const failureMsgDefault = { + unSupported: 'Text To Speech feature is not supporting in your device', + badRequest: 'Missing props', + error: 'Unable to convert text to voice', +}; + function TextToSpeechInit({ successCb, failureCb, loadingCb, successMsg, - failureMsg, + failureMsg: failureMsgProps, children, text, }) { + const failureMsg = { ...failureMsgDefault, ...failureMsgProps }; const [isAudioOn, setIsAudioOn] = useState(false); const handlePlay = async () => { @@ -81,11 +88,7 @@ TextToSpeechInit.defaultProps = { failureCb: () => {}, loadingCb: () => {}, successMsg: 'Converted text to voice Successfully', - failureMsg: { - unSupported: 'Text To Speech feature is not supporting in your device', - badRequest: 'Missing props', - error: 'Unable to convert text to voice', - }, + failureMsg: { ...failureMsgDefault }, }; export default Wrapper(TextToSpeechInit); diff --git a/__app/component/Vibrate/Vibrate.js b/__app/component/Vibrate/Vibrate.js index b21b8a4..d523e55 100644 --- a/__app/component/Vibrate/Vibrate.js +++ b/__app/component/Vibrate/Vibrate.js @@ -1,17 +1,29 @@ import { handleError, handleSuccess } from '../services/handlerService'; +const defaultProps = { + successCb: (() => {}), + failureCb: (() => {}), + successMsg: 'OTP autofilled successfully', + failureMsg: { + UN_SUPPORTED_FEATURE: 'Your device is not supporting Vibrate', + ERROR: '', + }, + vibrationSeq: [100, 30, 100, 30, 100, 30, 200, 30, 200, 30], +}; + function Vibrate(props = {}) { - const successCb = props.successCb || (() => {}); - const failureCb = props.failureCb || (() => {}); - const successMsg = props.successMsg || ''; - const failureMsg = props.failureMsg || {}; - const vibrationSeq = props.vibrationSeq || [100, 30, 100, 30, 100, 30, 200, 30, 200, 30]; + const successCb = props.successCb || defaultProps.successCb; + const failureCb = props.failureCb || defaultProps.failureCb; + const successMsg = props.successMsg || defaultProps.successMsg; + const failureMsg = { ...defaultProps.failureMsg, ...props.failureMsg }; + + const vibrationSeq = props.vibrationSeq || defaultProps.vibrationSeq; if (Vibrate.isBrowserSupport()) { window.navigator.vibrate(vibrationSeq); handleSuccess({ msgType: 'SUCCESSFUL', msg: successMsg, successCb, data: vibrationSeq }); } else { - return handleError({ msgType: 'UN_SUPPORTED_FEATURE', msg: failureMsg.unSupported || 'Your device is not supporting Vibrate', failureCb }); + return handleError({ msgType: 'UN_SUPPORTED_FEATURE', msg: failureMsg.unSupported, failureCb }); } } diff --git a/__app/component/VoiceRecognition/VoiceRecognitionInit.js b/__app/component/VoiceRecognition/VoiceRecognitionInit.js index bd44b40..4cf84b2 100644 --- a/__app/component/VoiceRecognition/VoiceRecognitionInit.js +++ b/__app/component/VoiceRecognition/VoiceRecognitionInit.js @@ -3,14 +3,20 @@ import PropTypes from 'prop-types'; import Wrapper from '../Wrapper/Wrapper'; import { handleSuccess, handleError, handleLoading } from '../services/handlerService'; +const failureMsgDefault = { + unSupported: 'Voice Recognition feature is not supporting in your device', + error: 'Unable to convert your voice to text', +}; + function VoiceRecognition({ successCb, failureCb, loadingCb, successMsg, - failureMsg, + failureMsg: failureMsgProps, children, }) { + const failureMsg = { ...failureMsgDefault, ...failureMsgProps }; const [isModalVisible, setIsModalVisible] = useState(false); const [isVoiceStarted, setIsVoiceStarted] = useState(false); const [voiceText, setVoiceText] = useState(''); @@ -92,10 +98,7 @@ VoiceRecognition.defaultProps = { failureCb: () => {}, loadingCb: () => {}, successMsg: 'Successfully converted your voice to text', - failureMsg: { - unSupported: 'Voice Recognition feature is not supporting in your device', - error: 'Unable to convert your voice to text', - }, + failureMsg: { ...failureMsgDefault }, }; export default Wrapper(VoiceRecognition);