shakebug-react-native 1.0.14
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/DeviceInfo/index.js.flow +177 -0
- package/DeviceInfo/index.ts +1034 -0
- package/DeviceInfo/internal/asyncHookWrappers.ts +59 -0
- package/DeviceInfo/internal/devicesWithDynamicIsland.ts +30 -0
- package/DeviceInfo/internal/devicesWithNotch.ts +374 -0
- package/DeviceInfo/internal/nativeInterface.ts +28 -0
- package/DeviceInfo/internal/privateTypes.ts +231 -0
- package/DeviceInfo/internal/supported-platform-info.ts +97 -0
- package/DeviceInfo/internal/types.ts +19 -0
- package/DeviceInfo/web/index.js +223 -0
- package/GetLocals/src/NativeRNLocalize.ts +18 -0
- package/GetLocals/src/constants.ts +269 -0
- package/GetLocals/src/index.ts +56 -0
- package/GetLocals/src/module.ts +51 -0
- package/GetLocals/src/module.web.ts +148 -0
- package/GetLocals/src/types.ts +31 -0
- package/GetLocation/LocationError.ts +20 -0
- package/GetLocation/index.ts +46 -0
- package/GetLocation/utils.ts +89 -0
- package/ImageOrVedioPicker/src/index.ts +28 -0
- package/ImageOrVedioPicker/src/platforms/NativeImagePicker.ts +10 -0
- package/ImageOrVedioPicker/src/platforms/native.ts +61 -0
- package/ImageOrVedioPicker/src/platforms/web.ts +159 -0
- package/ImageOrVedioPicker/src/types.ts +74 -0
- package/NetInfo/src/__tests__/eventListenerCallbacks.spec.ts +332 -0
- package/NetInfo/src/__tests__/fetch.spec.ts +479 -0
- package/NetInfo/src/index.ts +186 -0
- package/NetInfo/src/internal/__mocks__/nativeModule.ts +13 -0
- package/NetInfo/src/internal/defaultConfiguration.ts +17 -0
- package/NetInfo/src/internal/defaultConfiguration.web.ts +17 -0
- package/NetInfo/src/internal/internetReachability.ts +180 -0
- package/NetInfo/src/internal/nativeInterface.ts +43 -0
- package/NetInfo/src/internal/nativeInterface.web.ts +27 -0
- package/NetInfo/src/internal/nativeModule.ts +15 -0
- package/NetInfo/src/internal/nativeModule.web.ts +306 -0
- package/NetInfo/src/internal/privateTypes.ts +41 -0
- package/NetInfo/src/internal/state.ts +137 -0
- package/NetInfo/src/internal/types.ts +128 -0
- package/README.md +246 -0
- package/RecordScreen/src/index.tsx +75 -0
- package/ScreenShot/src/RNViewShot.js +3 -0
- package/ScreenShot/src/RNViewShot.web.js +42 -0
- package/ScreenShot/src/index.js +308 -0
- package/Sensor/src/index.js +14 -0
- package/Sensor/src/rnsensors.js +57 -0
- package/Sensor/src/sensors.js +97 -0
- package/VideoPlayer/PlayVideo.tsx +51 -0
- package/VideoPlayer/index.js +69 -0
- package/android/README.md +14 -0
- package/android/build/generated/source/buildConfig/debug/com/shakebug/BuildConfig.java +10 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/AndroidManifest.xml +42 -0
- package/android/build/intermediates/aapt_friendly_merged_manifests/debug/aapt/output-metadata.json +18 -0
- package/android/build/intermediates/aar_metadata/debug/aar-metadata.properties +6 -0
- package/android/build/intermediates/annotation_processor_list/debug/annotationProcessors.json +1 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/classes.jar +0 -0
- package/android/build/intermediates/compile_r_class_jar/debug/R.jar +0 -0
- package/android/build/intermediates/compile_symbol_list/debug/R.txt +47 -0
- package/android/build/intermediates/compiled_local_resources/debug/out/xml_imagepicker_provider_paths.xml.flat +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +12 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +2 -0
- package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +2 -0
- package/android/build/intermediates/incremental/packageDebugAssets/merger.xml +2 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/BuildConfig.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/CustomMediaMetadataRetriever.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ImageMetadata.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ImagePickerProvider.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/Metadata.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/Options.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/RecordScreenModule$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/RecordScreenModule.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/Shakebug.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ShakebugPackage.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/Utility.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/Utils.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/VideoMetadata.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$1.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$2.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$Formats.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$Results.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot$ReusableByteArrayOutputStream.class +0 -0
- package/android/build/intermediates/javac/debug/classes/com/shakebug/ViewShot.class +0 -0
- package/android/build/intermediates/local_only_symbol_list/debug/R-def.txt +49 -0
- package/android/build/intermediates/manifest_merge_blame_file/debug/manifest-merger-blame-debug-report.txt +82 -0
- package/android/build/intermediates/merged_manifest/debug/AndroidManifest.xml +42 -0
- package/android/build/intermediates/navigation_json/debug/navigation.json +1 -0
- package/android/build/intermediates/packaged_res/debug/values/values.xml +25 -0
- package/android/build/intermediates/packaged_res/debug/xml/imagepicker_provider_paths.xml +4 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/BuildConfig.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/CustomMediaMetadataRetriever.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ImageMetadata.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ImagePickerProvider.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Metadata.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Options.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/RecordScreenModule$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/RecordScreenModule.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Shakebug.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ShakebugPackage.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Utility.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/Utils.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/VideoMetadata.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$2.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$Formats.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$Results.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot$ReusableByteArrayOutputStream.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/com/shakebug/ViewShot.class +0 -0
- package/android/build/intermediates/symbol_list_with_package_name/debug/package-aware-r.txt +48 -0
- package/android/build/outputs/logs/manifest-merger-debug-report.txt +97 -0
- package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
- package/android/build.gradle +235 -0
- package/android/src/main/AndroidManifest.xml +40 -0
- package/android/src/main/java/com/shakebug/AmazonFireDeviceConnectivityPoller.java +170 -0
- package/android/src/main/java/com/shakebug/BaseUtils.java +33 -0
- package/android/src/main/java/com/shakebug/BroadcastReceiverConnectivityReceiver.java +131 -0
- package/android/src/main/java/com/shakebug/ConnectivityReceiver.java +318 -0
- package/android/src/main/java/com/shakebug/CrashLoggerModule.java +48 -0
- package/android/src/main/java/com/shakebug/DateUtil.java +64 -0
- package/android/src/main/java/com/shakebug/DeviceType.java +18 -0
- package/android/src/main/java/com/shakebug/DeviceUtil.java +46 -0
- package/android/src/main/java/com/shakebug/DrawingView.java +90 -0
- package/android/src/main/java/com/shakebug/DrawingViewManager.java +38 -0
- package/android/src/main/java/com/shakebug/GetLocation.java +147 -0
- package/android/src/main/java/com/shakebug/ImageMetadata.java +42 -0
- package/android/src/main/java/com/shakebug/ImagePickerProvider.java +8 -0
- package/android/src/main/java/com/shakebug/Metadata.java +46 -0
- package/android/src/main/java/com/shakebug/NetInfoModule.java +79 -0
- package/android/src/main/java/com/shakebug/NetInfoUtils.java +50 -0
- package/android/src/main/java/com/shakebug/NetworkCallbackConnectivityReceiver.java +209 -0
- package/android/src/main/java/com/shakebug/Options.java +42 -0
- package/android/src/main/java/com/shakebug/RNDeviceModule.java +1036 -0
- package/android/src/main/java/com/shakebug/RNInstallReferrerClient.java +124 -0
- package/android/src/main/java/com/shakebug/RNLocalizeModule.java +79 -0
- package/android/src/main/java/com/shakebug/RNLocalizeModuleImpl.java +258 -0
- package/android/src/main/java/com/shakebug/ReactNativeGetLocationModule.java +95 -0
- package/android/src/main/java/com/shakebug/RecordScreenModule.java +202 -0
- package/android/src/main/java/com/shakebug/ScreenshotDetectorModule.java +63 -0
- package/android/src/main/java/com/shakebug/SettingsUtil.java +44 -0
- package/android/src/main/java/com/shakebug/Shakebug.java +181 -0
- package/android/src/main/java/com/shakebug/ShakebugPackage.java +75 -0
- package/android/src/main/java/com/shakebug/ShakebugSDKImagePickerModule.java +56 -0
- package/android/src/main/java/com/shakebug/ShakebugSDKImagePickerModuleImpl.java +230 -0
- package/android/src/main/java/com/shakebug/ShakebugSDKScreenShotModule.java +196 -0
- package/android/src/main/java/com/shakebug/SharedPreferencesModule.java +39 -0
- package/android/src/main/java/com/shakebug/UnitConverter.java +48 -0
- package/android/src/main/java/com/shakebug/Utility.java +29 -0
- package/android/src/main/java/com/shakebug/Utils.java +593 -0
- package/android/src/main/java/com/shakebug/VideoMetadata.java +91 -0
- package/android/src/main/java/com/shakebug/VideoPlayerModule.java +199 -0
- package/android/src/main/java/com/shakebug/VideoThumbnailModule.java +215 -0
- package/android/src/main/java/com/shakebug/VideoTrimModule.java +372 -0
- package/android/src/main/java/com/shakebug/ViewShot.java +627 -0
- package/android/src/main/java/com/shakebug/adapters/VideoTrimmerAdapter.java +54 -0
- package/android/src/main/java/com/shakebug/callback/SingleCallback.java +11 -0
- package/android/src/main/java/com/shakebug/interfaces/IVideoTrimmerView.java +5 -0
- package/android/src/main/java/com/shakebug/interfaces/VideoPlayerListner.java +5 -0
- package/android/src/main/java/com/shakebug/interfaces/VideoTrimListener.java +10 -0
- package/android/src/main/java/com/shakebug/resolver/DeviceIdResolver.java +87 -0
- package/android/src/main/java/com/shakebug/resolver/DeviceTypeResolver.java +94 -0
- package/android/src/main/java/com/shakebug/thread/BackgroundExecutor.java +246 -0
- package/android/src/main/java/com/shakebug/thread/UiThreadExecutor.java +120 -0
- package/android/src/main/java/com/shakebug/types/CellularGeneration.java +60 -0
- package/android/src/main/java/com/shakebug/types/ConnectionType.java +26 -0
- package/android/src/main/java/com/shakebug/utils/StorageUtil.java +139 -0
- package/android/src/main/java/com/shakebug/utils/VideoTrimmerUtil.java +89 -0
- package/android/src/main/java/com/shakebug/widgets/RangeSeekBarView.java +534 -0
- package/android/src/main/java/com/shakebug/widgets/SpacesItemDecoration2.java +32 -0
- package/android/src/main/java/com/shakebug/widgets/VideoPlayerView.java +429 -0
- package/android/src/main/java/com/shakebug/widgets/VideoTrimmerView.java +477 -0
- package/android/src/main/java/com/shakebug/widgets/ZVideoView.java +48 -0
- package/android/src/main/res/drawable/custom_progress.xml +16 -0
- package/android/src/main/res/drawable/custom_thumb.xml +4 -0
- package/android/src/main/res/drawable/ic_close_button.xml +10 -0
- package/android/src/main/res/drawable/ic_video_pause_black.png +0 -0
- package/android/src/main/res/drawable/ic_video_play_black.png +0 -0
- package/android/src/main/res/drawable/ic_video_thumb_handle.png +0 -0
- package/android/src/main/res/drawable/icon_seek_bar.png +0 -0
- package/android/src/main/res/layout/video_player_view.xml +121 -0
- package/android/src/main/res/layout/video_thumb_item_layout.xml +16 -0
- package/android/src/main/res/layout/video_trimmer_view.xml +148 -0
- package/android/src/main/res/values/colors.xml +17 -0
- package/android/src/main/res/values/strings.xml +14 -0
- package/android/src/main/res/xml/imagepicker_provider_paths.xml +4 -0
- package/ios/CammeraPermission/RNCameraPermission.h +16 -0
- package/ios/CammeraPermission/RNCameraPermission.m +46 -0
- package/ios/DeviceInfo/DeviceUID.h +14 -0
- package/ios/DeviceInfo/DeviceUID.m +202 -0
- package/ios/DeviceInfo/EnvironmentUtil.h +41 -0
- package/ios/DeviceInfo/EnvironmentUtil.m +56 -0
- package/ios/DeviceInfo/RNDeviceInfo.h +22 -0
- package/ios/DeviceInfo/RNDeviceInfo.m +918 -0
- package/ios/GetLocals/ShakebugSDKRNLocalize.h +21 -0
- package/ios/GetLocals/ShakebugSDKRNLocalize.m +296 -0
- package/ios/GetLocation/SettingsUtil.h +16 -0
- package/ios/GetLocation/SettingsUtil.m +21 -0
- package/ios/GetLocation/ShakebugSDKLocationModule.h +17 -0
- package/ios/GetLocation/ShakebugSDKLocationModule.m +218 -0
- package/ios/ImageOrVideoPicker/ShakebugSDKImagePickerManager.h +40 -0
- package/ios/ImageOrVideoPicker/ShakebugSDKImagePickerManager.m +588 -0
- package/ios/ImageOrVideoPicker/ShakebugSDKImagePickerUtils.h +26 -0
- package/ios/ImageOrVideoPicker/ShakebugSDKImagePickerUtils.m +194 -0
- package/ios/MicrophonePermissionManager.h +14 -0
- package/ios/MicrophonePermissionManager.m +35 -0
- package/ios/NetInfo/RNCConnectionState.h +42 -0
- package/ios/NetInfo/RNCConnectionState.m +119 -0
- package/ios/NetInfo/RNCConnectionStateWatcher.h +31 -0
- package/ios/NetInfo/RNCConnectionStateWatcher.m +136 -0
- package/ios/NetInfo/RNCNetInfo.h +13 -0
- package/ios/NetInfo/RNCNetInfo.m +269 -0
- package/ios/RecordScreen/ShakebugSDKRecordScreen.h +31 -0
- package/ios/RecordScreen/ShakebugSDKRecordScreen.m +309 -0
- package/ios/ScreenShot/ShakebugSDKRNViewShot.h +6 -0
- package/ios/ScreenShot/ShakebugSDKRNViewShot.m +186 -0
- package/ios/ScreenshotDetector/ScreenShotDetector.h +12 -0
- package/ios/ScreenshotDetector/ScreenShotDetector.m +37 -0
- package/ios/Senors/RNSensorsAccelerometer.h +22 -0
- package/ios/Senors/RNSensorsAccelerometer.m +162 -0
- package/ios/Senors/RNSensorsBarometer.h +22 -0
- package/ios/Senors/RNSensorsBarometer.m +141 -0
- package/ios/Senors/RNSensorsGravity.h +22 -0
- package/ios/Senors/RNSensorsGravity.m +165 -0
- package/ios/Senors/RNSensorsGyroscope.h +22 -0
- package/ios/Senors/RNSensorsGyroscope.m +160 -0
- package/ios/Senors/RNSensorsMagnetometer.h +22 -0
- package/ios/Senors/RNSensorsMagnetometer.m +163 -0
- package/ios/Senors/RNSensorsOrientation.h +22 -0
- package/ios/Senors/RNSensorsOrientation.m +189 -0
- package/ios/Senors/RNSensorsUtils.h +7 -0
- package/ios/Senors/RNSensorsUtils.m +9 -0
- package/ios/Shakebug.h +7 -0
- package/ios/Shakebug.m +16 -0
- package/ios/Shakebug.xcodeproj/project.pbxproj +872 -0
- package/ios/Shakebug.xcodeproj/xcshareddata/xcschemes/Shakebug.xcscheme +66 -0
- package/ios/Shakebug.xcworkspace/contents.xcworkspacedata +10 -0
- package/ios/Shakebug.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/ios/SketchCanvas/DrawingView.h +18 -0
- package/ios/SketchCanvas/DrawingView.m +96 -0
- package/ios/SketchCanvas/DrawingViewManager.h +12 -0
- package/ios/SketchCanvas/DrawingViewManager.m +35 -0
- package/ios/Storage/SharedPreferencesModule.h +13 -0
- package/ios/Storage/SharedPreferencesModule.m +35 -0
- package/ios/Thumbnaill/VideoThumbnailManager.h +12 -0
- package/ios/Thumbnaill/VideoThumbnailManager.m +73 -0
- package/ios/TrimVideo/ShakebugSDKVideoTrim.swift +372 -0
- package/ios/TrimVideo/VideoTrim-Bridging-Header.h +10 -0
- package/ios/TrimVideo/VideoTrim.m +23 -0
- package/ios/TrimVideo/VideoTrimmer.swift +810 -0
- package/ios/TrimVideo/VideoTrimmerThumb.swift +119 -0
- package/ios/TrimVideo/VideoTrimmerViewController.swift +301 -0
- package/ios/VideoPlayer/VideoPlayerModule.h +14 -0
- package/ios/VideoPlayer/VideoPlayerModule.m +29 -0
- package/ios/VideoPlayer/VideoPlayerViewController.h +18 -0
- package/ios/VideoPlayer/VideoPlayerViewController.m +29 -0
- package/package.json +45 -0
- package/shakebug-react-native.podspec +50 -0
- package/src/APIs/AddIssue.js +70 -0
- package/src/APIs/EndSession.js +32 -0
- package/src/APIs/Event.js +39 -0
- package/src/APIs/MatchKey.js +40 -0
- package/src/APIs/StartSession.js +84 -0
- package/src/Assets/images/OpenSketch.png +0 -0
- package/src/Assets/images/Push.png +0 -0
- package/src/Assets/images/RemoveTextView.png +0 -0
- package/src/Assets/images/black.png +0 -0
- package/src/Assets/images/blue.png +0 -0
- package/src/Assets/images/borderdBlack.png +0 -0
- package/src/Assets/images/borderdBlue.png +0 -0
- package/src/Assets/images/borderdGreen.png +0 -0
- package/src/Assets/images/borderdRed.png +0 -0
- package/src/Assets/images/borderdYellow.png +0 -0
- package/src/Assets/images/clear.png +0 -0
- package/src/Assets/images/close.png +0 -0
- package/src/Assets/images/green.png +0 -0
- package/src/Assets/images/next.png +0 -0
- package/src/Assets/images/play.png +0 -0
- package/src/Assets/images/red.png +0 -0
- package/src/Assets/images/shake.png +0 -0
- package/src/Assets/images/shakebugLogo.png +0 -0
- package/src/Assets/images/stopButton.png +0 -0
- package/src/Assets/images/text_icon.png +0 -0
- package/src/Assets/images/yellow.png +0 -0
- package/src/Componanats/CustomAlert.js +80 -0
- package/src/Componanats/ErrorHandler.js +80 -0
- package/src/Componanats/GlobalStateContext.js +22 -0
- package/src/Componanats/KeyboardAvoidingWrapper.js +43 -0
- package/src/Componanats/NavigationContext.js +42 -0
- package/src/Componanats/ShakeFunction.js +562 -0
- package/src/Componanats/localization.js +482 -0
- package/src/Screens/AddDetailsScreen.js +462 -0
- package/src/Screens/FirstScreen.js +629 -0
- package/src/Screens/Shakebug.js +487 -0
- package/src/Screens/StrockView.js +20 -0
- package/src/Screens/TrimVideoScreen.js +81 -0
- package/src/Screens/TutorialScreen.js +36 -0
- package/src/index.tsx +117 -0
- package/trimVideo/src/index.tsx +141 -0
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import {NativeEventSubscription} from 'react-native';
|
|
11
|
+
import NativeInterface from './nativeInterface';
|
|
12
|
+
import InternetReachability from './internetReachability';
|
|
13
|
+
import * as Types from './types';
|
|
14
|
+
import * as PrivateTypes from './privateTypes';
|
|
15
|
+
|
|
16
|
+
export default class State {
|
|
17
|
+
private _nativeEventSubscription: NativeEventSubscription | null = null;
|
|
18
|
+
private _subscriptions = new Set<Types.NetInfoChangeHandler>();
|
|
19
|
+
private _latestState: Types.NetInfoState | null = null;
|
|
20
|
+
private _internetReachability: InternetReachability;
|
|
21
|
+
|
|
22
|
+
constructor(configuration: Types.NetInfoConfiguration) {
|
|
23
|
+
// Add the listener to the internet connectivity events
|
|
24
|
+
this._internetReachability = new InternetReachability(
|
|
25
|
+
configuration,
|
|
26
|
+
this._handleInternetReachabilityUpdate,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
// Add the subscription to the native events
|
|
30
|
+
this._nativeEventSubscription = NativeInterface.eventEmitter.addListener(
|
|
31
|
+
PrivateTypes.DEVICE_CONNECTIVITY_EVENT,
|
|
32
|
+
this._handleNativeStateUpdate,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
// Fetch the current state from the native module
|
|
36
|
+
this._fetchCurrentState();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private _handleNativeStateUpdate = (
|
|
40
|
+
state: PrivateTypes.NetInfoNativeModuleState,
|
|
41
|
+
): void => {
|
|
42
|
+
// Update the internet reachability module
|
|
43
|
+
this._internetReachability.update(state);
|
|
44
|
+
|
|
45
|
+
// Convert the state from native to JS shape
|
|
46
|
+
const convertedState = this._convertState(state);
|
|
47
|
+
|
|
48
|
+
// Update the listeners
|
|
49
|
+
this._latestState = convertedState;
|
|
50
|
+
this._subscriptions.forEach((handler): void => handler(convertedState));
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
private _handleInternetReachabilityUpdate = (
|
|
54
|
+
isInternetReachable: boolean | null | undefined,
|
|
55
|
+
): void => {
|
|
56
|
+
if (!this._latestState) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const nextState = {
|
|
61
|
+
...this._latestState,
|
|
62
|
+
isInternetReachable,
|
|
63
|
+
} as Types.NetInfoState;
|
|
64
|
+
this._latestState = nextState;
|
|
65
|
+
this._subscriptions.forEach((handler): void => handler(nextState));
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
public _fetchCurrentState = async (
|
|
69
|
+
requestedInterface?: string,
|
|
70
|
+
): Promise<Types.NetInfoState> => {
|
|
71
|
+
const state = await NativeInterface.getCurrentState(requestedInterface);
|
|
72
|
+
|
|
73
|
+
// Update the internet reachability module
|
|
74
|
+
this._internetReachability.update(state);
|
|
75
|
+
// Convert and store the new state
|
|
76
|
+
const convertedState = this._convertState(state);
|
|
77
|
+
if (!requestedInterface) {
|
|
78
|
+
this._latestState = convertedState;
|
|
79
|
+
this._subscriptions.forEach((handler): void => handler(convertedState));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return convertedState;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
private _convertState = (
|
|
86
|
+
input: PrivateTypes.NetInfoNativeModuleState,
|
|
87
|
+
): Types.NetInfoState => {
|
|
88
|
+
if (typeof input.isInternetReachable === 'boolean') {
|
|
89
|
+
return input as Types.NetInfoState;
|
|
90
|
+
} else {
|
|
91
|
+
return {
|
|
92
|
+
...input,
|
|
93
|
+
isInternetReachable: this._internetReachability.currentState(),
|
|
94
|
+
} as Types.NetInfoState;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
public latest = (
|
|
99
|
+
requestedInterface?: string,
|
|
100
|
+
): Promise<Types.NetInfoState> => {
|
|
101
|
+
if (requestedInterface) {
|
|
102
|
+
return this._fetchCurrentState(requestedInterface);
|
|
103
|
+
} else if (this._latestState) {
|
|
104
|
+
return Promise.resolve(this._latestState);
|
|
105
|
+
} else {
|
|
106
|
+
return this._fetchCurrentState();
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
public add = (handler: Types.NetInfoChangeHandler): void => {
|
|
111
|
+
// Add the subscription handler to our set
|
|
112
|
+
this._subscriptions.add(handler);
|
|
113
|
+
|
|
114
|
+
// Send it the latest data we have
|
|
115
|
+
if (this._latestState) {
|
|
116
|
+
handler(this._latestState);
|
|
117
|
+
} else {
|
|
118
|
+
this.latest().then(handler);
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
public remove = (handler: Types.NetInfoChangeHandler): void => {
|
|
123
|
+
this._subscriptions.delete(handler);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
public tearDown = (): void => {
|
|
127
|
+
if (this._internetReachability) {
|
|
128
|
+
this._internetReachability.tearDown();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (this._nativeEventSubscription) {
|
|
132
|
+
this._nativeEventSubscription.remove();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
this._subscriptions.clear();
|
|
136
|
+
};
|
|
137
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the MIT license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*
|
|
7
|
+
* @format
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export enum NetInfoStateType {
|
|
11
|
+
unknown = 'unknown',
|
|
12
|
+
none = 'none',
|
|
13
|
+
cellular = 'cellular',
|
|
14
|
+
wifi = 'wifi',
|
|
15
|
+
bluetooth = 'bluetooth',
|
|
16
|
+
ethernet = 'ethernet',
|
|
17
|
+
wimax = 'wimax',
|
|
18
|
+
vpn = 'vpn',
|
|
19
|
+
other = 'other',
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type NetInfoMethodType = 'HEAD' | 'GET';
|
|
23
|
+
|
|
24
|
+
export enum NetInfoCellularGeneration {
|
|
25
|
+
'2g' = '2g',
|
|
26
|
+
'3g' = '3g',
|
|
27
|
+
'4g' = '4g',
|
|
28
|
+
'5g' = '5g',
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface NetInfoConnectedDetails {
|
|
32
|
+
isConnectionExpensive: boolean;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
interface NetInfoConnectedState<
|
|
36
|
+
T extends NetInfoStateType,
|
|
37
|
+
D extends Record<string, unknown> = Record<string, unknown>
|
|
38
|
+
> {
|
|
39
|
+
type: T;
|
|
40
|
+
isConnected: true;
|
|
41
|
+
isInternetReachable: boolean | null;
|
|
42
|
+
details: D & NetInfoConnectedDetails;
|
|
43
|
+
isWifiEnabled?: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface NetInfoDisconnectedState<T extends NetInfoStateType> {
|
|
47
|
+
type: T;
|
|
48
|
+
isConnected: false;
|
|
49
|
+
isInternetReachable: false;
|
|
50
|
+
details: null;
|
|
51
|
+
isWifiEnabled?: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface NetInfoUnknownState {
|
|
55
|
+
type: NetInfoStateType.unknown;
|
|
56
|
+
isConnected: boolean | null;
|
|
57
|
+
isInternetReachable: null;
|
|
58
|
+
details: null;
|
|
59
|
+
isWifiEnabled?: boolean;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type NetInfoNoConnectionState = NetInfoDisconnectedState<
|
|
63
|
+
NetInfoStateType.none
|
|
64
|
+
>;
|
|
65
|
+
export type NetInfoDisconnectedStates =
|
|
66
|
+
| NetInfoUnknownState
|
|
67
|
+
| NetInfoNoConnectionState;
|
|
68
|
+
|
|
69
|
+
export type NetInfoCellularState = NetInfoConnectedState<
|
|
70
|
+
NetInfoStateType.cellular,
|
|
71
|
+
{
|
|
72
|
+
cellularGeneration: NetInfoCellularGeneration | null;
|
|
73
|
+
carrier: string | null;
|
|
74
|
+
}
|
|
75
|
+
>;
|
|
76
|
+
export type NetInfoWifiState = NetInfoConnectedState<
|
|
77
|
+
NetInfoStateType.wifi,
|
|
78
|
+
{
|
|
79
|
+
ssid: string | null;
|
|
80
|
+
bssid: string | null;
|
|
81
|
+
strength: number | null;
|
|
82
|
+
ipAddress: string | null;
|
|
83
|
+
subnet: string | null;
|
|
84
|
+
frequency: number | null;
|
|
85
|
+
linkSpeed: number | null;
|
|
86
|
+
rxLinkSpeed: number | null;
|
|
87
|
+
txLinkSpeed: number | null;
|
|
88
|
+
}
|
|
89
|
+
>;
|
|
90
|
+
export type NetInfoBluetoothState = NetInfoConnectedState<
|
|
91
|
+
NetInfoStateType.bluetooth
|
|
92
|
+
>;
|
|
93
|
+
export type NetInfoEthernetState = NetInfoConnectedState<
|
|
94
|
+
NetInfoStateType.ethernet,
|
|
95
|
+
{
|
|
96
|
+
ipAddress: string | null;
|
|
97
|
+
subnet: string | null;
|
|
98
|
+
}
|
|
99
|
+
>;
|
|
100
|
+
export type NetInfoWimaxState = NetInfoConnectedState<NetInfoStateType.wimax>;
|
|
101
|
+
export type NetInfoVpnState = NetInfoConnectedState<NetInfoStateType.vpn>;
|
|
102
|
+
export type NetInfoOtherState = NetInfoConnectedState<NetInfoStateType.other>;
|
|
103
|
+
export type NetInfoConnectedStates =
|
|
104
|
+
| NetInfoCellularState
|
|
105
|
+
| NetInfoWifiState
|
|
106
|
+
| NetInfoBluetoothState
|
|
107
|
+
| NetInfoEthernetState
|
|
108
|
+
| NetInfoWimaxState
|
|
109
|
+
| NetInfoVpnState
|
|
110
|
+
| NetInfoOtherState;
|
|
111
|
+
|
|
112
|
+
export type NetInfoState = NetInfoDisconnectedStates | NetInfoConnectedStates;
|
|
113
|
+
|
|
114
|
+
export type NetInfoChangeHandler = (state: NetInfoState) => void;
|
|
115
|
+
export type NetInfoSubscription = () => void;
|
|
116
|
+
|
|
117
|
+
export interface NetInfoConfiguration {
|
|
118
|
+
reachabilityUrl: string;
|
|
119
|
+
reachabilityMethod?: NetInfoMethodType;
|
|
120
|
+
reachabilityHeaders?: Record<string, string>;
|
|
121
|
+
reachabilityTest: (response: Response) => Promise<boolean>;
|
|
122
|
+
reachabilityLongTimeout: number;
|
|
123
|
+
reachabilityShortTimeout: number;
|
|
124
|
+
reachabilityRequestTimeout: number;
|
|
125
|
+
reachabilityShouldRun: () => boolean;
|
|
126
|
+
shouldFetchWiFiSSID: boolean;
|
|
127
|
+
useNativeReachability: boolean;
|
|
128
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# shakebug-react-native
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
<a href="https://www.shakebug.com"><img src="https://www.shakebug.com/assets/images/logo.png"></a>
|
|
5
|
+
|
|
6
|
+
Shakebug allows users to report the bug from your mobile phone for your application. Here users just need to shake their mobile and all the data regarding bugs & crashes can be seen by developers through their log in panel easily.
|
|
7
|
+
|
|
8
|
+
For more info, visit [shakebug.com](https://www.shakebug.com).
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
Navigate to your React Native project directory and install `shakebug-react-native`
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install shakebug-react-native
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or if you prefer to use Yarn instead of npm:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
yarn add shakebug-react-native
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### iOS
|
|
27
|
+
|
|
28
|
+
1. You need to provide permissions inside `ios/YourProjectName/info.plist`:
|
|
29
|
+
|
|
30
|
+
```xml
|
|
31
|
+
<key>NSCameraUsageDescription</key>
|
|
32
|
+
<string></string>
|
|
33
|
+
|
|
34
|
+
<key>NSMicrophoneUsageDescription</key>
|
|
35
|
+
<string></string>
|
|
36
|
+
|
|
37
|
+
<key>NSPhotoLibraryUsageDescription</key>
|
|
38
|
+
<string></string>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
2. CocoaPods installation:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
cd ios && pod install && cd ..
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Android
|
|
48
|
+
|
|
49
|
+
Android minSdkVersion 24 required
|
|
50
|
+
You can change it in `android/build.gradle`
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
buildscript {
|
|
54
|
+
...
|
|
55
|
+
ext {
|
|
56
|
+
...
|
|
57
|
+
minSdkVersion = 24 or later
|
|
58
|
+
...
|
|
59
|
+
}
|
|
60
|
+
...
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Usage
|
|
65
|
+
|
|
66
|
+
you Need to import ShakebugView in root file of application (App.js)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
|
|
71
|
+
Import ShakebugView from 'shakebug-react-native';
|
|
72
|
+
|
|
73
|
+
export default App = () => {
|
|
74
|
+
return(
|
|
75
|
+
<ShakebugView
|
|
76
|
+
Android_appkey= “your android app key”
|
|
77
|
+
iOS_appkey= “your ios app key”
|
|
78
|
+
other options...
|
|
79
|
+
>
|
|
80
|
+
//Your code...
|
|
81
|
+
</ShakebugView>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
If you use NavigationContainer in App.js/root file (where you import ShakebugView) then you need to pass independent as parameter in NavigationContainer
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
|
|
90
|
+
Import ShakebugView from 'shakebug-react-native';
|
|
91
|
+
|
|
92
|
+
export default App = () => {
|
|
93
|
+
return(
|
|
94
|
+
<ShakebugView
|
|
95
|
+
Android_appkey= “your android app key”
|
|
96
|
+
iOS_appkey= “your ios app key”
|
|
97
|
+
other options…
|
|
98
|
+
>
|
|
99
|
+
<NavigationContainer independent>
|
|
100
|
+
//Your code...
|
|
101
|
+
</NavigationContainer>
|
|
102
|
+
</ShakebugView>
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
```
|
|
107
|
+
You can add event on click:
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
|
|
111
|
+
import { Button } from 'react-native';
|
|
112
|
+
import ShakebugView, { addEventKey } from 'react-native-shakebug';
|
|
113
|
+
|
|
114
|
+
export default App = () => {
|
|
115
|
+
return(
|
|
116
|
+
<Button
|
|
117
|
+
title='Prees'
|
|
118
|
+
onPress={() => {
|
|
119
|
+
addEventKey("key_name", value)
|
|
120
|
+
}}
|
|
121
|
+
/>
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
To ensure the privacy of your users' sensitive information, such as payment details or account information etc.., you can mark any view containing this information as private using ShakebugSdkProtectedView. By doing so, the private view will automatically appear with a black overlay in any screenshots taken and while recording screen:
|
|
128
|
+
|
|
129
|
+
```javascript
|
|
130
|
+
|
|
131
|
+
import { Button } from 'react-native';
|
|
132
|
+
import { ShakebugSdkProtectedView } from 'react-native-shakebug';
|
|
133
|
+
|
|
134
|
+
export default App = () => {
|
|
135
|
+
return(
|
|
136
|
+
<ShakebugSdkProtectedView>
|
|
137
|
+
<View>
|
|
138
|
+
<Text>This is sensitive information!</Text>
|
|
139
|
+
</View>
|
|
140
|
+
</ShakebugSdkProtectedView>
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Properties
|
|
147
|
+
|
|
148
|
+
<table>
|
|
149
|
+
<tr>
|
|
150
|
+
<th>Key Name</th>
|
|
151
|
+
<th>Type</th>
|
|
152
|
+
<th>Description</th>
|
|
153
|
+
<th>Default Value</th>
|
|
154
|
+
<tr>
|
|
155
|
+
<tr>
|
|
156
|
+
<td>Android_appkey</td>
|
|
157
|
+
<td>String(required)</td>
|
|
158
|
+
<td>This initializes Shake Bug with the default invocation event. Be sure to pass <Your Key> your application key which given by ShakeBug website.</td>
|
|
159
|
+
<td></td>
|
|
160
|
+
</tr>
|
|
161
|
+
<tr>
|
|
162
|
+
<td>iOS_appkey</td>
|
|
163
|
+
<td>String(required)</td>
|
|
164
|
+
<td>This initializes Shake Bug with the default invocation event. Be sure to pass <Your Key> your application key which given by ShakeBug website.</td>
|
|
165
|
+
<td></td>
|
|
166
|
+
</tr>
|
|
167
|
+
<tr>
|
|
168
|
+
<td>showTutorialScreenFirstTime</td>
|
|
169
|
+
<td>boolean</td>
|
|
170
|
+
<td>Add the following for enabling/disabling first time tutorial screen.</td>
|
|
171
|
+
<td>true</td>
|
|
172
|
+
</tr>
|
|
173
|
+
<tr>
|
|
174
|
+
<td>ShakebugThemeColor</td>
|
|
175
|
+
<td>String</td>
|
|
176
|
+
<td>Developer can also set custome theme color in Shakebug SDK screens.</td>
|
|
177
|
+
<td></td>
|
|
178
|
+
</tr>
|
|
179
|
+
<tr>
|
|
180
|
+
<td>changeSDKScreenTitle</td>
|
|
181
|
+
<td>Array</td>
|
|
182
|
+
<td>Developer can also set custom title for Shakebug annotate and feedback input screen.</td>
|
|
183
|
+
<td>["Annotate your bug", "Add Details"]</td>
|
|
184
|
+
</tr>
|
|
185
|
+
<tr>
|
|
186
|
+
<td>allowToReportBugByShakingMobile</td>
|
|
187
|
+
<td>boolean</td>
|
|
188
|
+
<td>Add the following to allow report bug by shaking mobile.</td>
|
|
189
|
+
<td>true</td>
|
|
190
|
+
</tr>
|
|
191
|
+
<tr>
|
|
192
|
+
<td>allowToReportBugByScreenCapture</td>
|
|
193
|
+
<td>boolean</td>
|
|
194
|
+
<td>Add the following to allow report bug by screenshot capture event.</td>
|
|
195
|
+
<td>false</td>
|
|
196
|
+
</tr>
|
|
197
|
+
<tr>
|
|
198
|
+
<td>ShakebugLanguage</td>
|
|
199
|
+
<td>String</td>
|
|
200
|
+
<td>If you want to set forcefully any language for the bug reporting screen then use following prop.</td>
|
|
201
|
+
<td>Your Device's language</td>
|
|
202
|
+
</tr>
|
|
203
|
+
<tr>
|
|
204
|
+
<td>allowCrashReport</td>
|
|
205
|
+
<td>boolean</td>
|
|
206
|
+
<td>If you want to allow report crash while app get crashed then use following prop.</td>
|
|
207
|
+
<td>true</td>
|
|
208
|
+
</tr>
|
|
209
|
+
<tr>
|
|
210
|
+
<td>makeLogEnabled</td>
|
|
211
|
+
<td>boolean</td>
|
|
212
|
+
<td>If you want to show any logs on console then use following prop.</td>
|
|
213
|
+
<td>false</td>
|
|
214
|
+
</tr>
|
|
215
|
+
<tr>
|
|
216
|
+
<td>setShakebugSDKEndPointURL</td>
|
|
217
|
+
<td>Array</td>
|
|
218
|
+
<td>If you have on-premise hosting plan then following prop will be used.</td>
|
|
219
|
+
<td></td>
|
|
220
|
+
</tr>
|
|
221
|
+
</table>
|
|
222
|
+
|
|
223
|
+
## Methods
|
|
224
|
+
|
|
225
|
+
<table>
|
|
226
|
+
<tr>
|
|
227
|
+
<th>Name</th>
|
|
228
|
+
<th>Description</th>
|
|
229
|
+
<th>Usage</th>
|
|
230
|
+
</tr>
|
|
231
|
+
<tr>
|
|
232
|
+
<td>addEventKey</td>
|
|
233
|
+
<td>If you want add event to any screen or activity use following method</td>
|
|
234
|
+
<td>addEventKey("Key_name", value)</td>
|
|
235
|
+
</tr>
|
|
236
|
+
</table>
|
|
237
|
+
|
|
238
|
+
## Documentation
|
|
239
|
+
|
|
240
|
+
[View our documentation](https://www.shakebug.com/installation#react).
|
|
241
|
+
|
|
242
|
+
## Contact
|
|
243
|
+
|
|
244
|
+
Visit on: [https://www.shakebug.com](https://www.shakebug.com).
|
|
245
|
+
|
|
246
|
+
Contact us on [support@shakebug.com](mailto:support@shakebug.com) in case of any use.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { NativeModules, Dimensions } from 'react-native';
|
|
2
|
+
|
|
3
|
+
export const RecordingResult = {
|
|
4
|
+
Started: 'started',
|
|
5
|
+
PermissionError: 'permission_error',
|
|
6
|
+
} as const;
|
|
7
|
+
|
|
8
|
+
export type RecordingStartResponse =
|
|
9
|
+
(typeof RecordingResult)[keyof typeof RecordingResult];
|
|
10
|
+
|
|
11
|
+
export type RecordScreenConfigType = {
|
|
12
|
+
fps?: number;
|
|
13
|
+
bitrate?: number;
|
|
14
|
+
mic?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type RecordingSuccessResponse = {
|
|
18
|
+
status: 'success';
|
|
19
|
+
result: {
|
|
20
|
+
outputURL: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type RecordingErrorResponse = {
|
|
25
|
+
status: 'error';
|
|
26
|
+
result: unknown;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type RecordingResponse =
|
|
30
|
+
| RecordingSuccessResponse
|
|
31
|
+
| RecordingErrorResponse;
|
|
32
|
+
|
|
33
|
+
type RecordScreenNativeModule = {
|
|
34
|
+
setup(
|
|
35
|
+
config: RecordScreenConfigType & { width: number; height: number }
|
|
36
|
+
): void;
|
|
37
|
+
startRecording(): Promise<RecordingStartResponse>;
|
|
38
|
+
stopRecording(): Promise<RecordingResponse>;
|
|
39
|
+
clean(): Promise<string>;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const { ShakebugSDKRecordScreen } = NativeModules;
|
|
43
|
+
|
|
44
|
+
const RS = ShakebugSDKRecordScreen as RecordScreenNativeModule;
|
|
45
|
+
|
|
46
|
+
class ReactNativeRecordScreenClass {
|
|
47
|
+
private setup(config: RecordScreenConfigType = {}): void {
|
|
48
|
+
const { width, height } = Dimensions.get('window');
|
|
49
|
+
RS.setup({
|
|
50
|
+
mic: true,
|
|
51
|
+
width,
|
|
52
|
+
height,
|
|
53
|
+
fps: 60,
|
|
54
|
+
bitrate: 1920 * 1080 * 144,
|
|
55
|
+
...config,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
startRecording(config: RecordScreenConfigType = {}) {
|
|
60
|
+
this.setup(config);
|
|
61
|
+
return RS.startRecording();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
stopRecording() {
|
|
65
|
+
return RS.stopRecording();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
clean() {
|
|
69
|
+
return RS.clean();
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const ReactNativeRecordScreen = new ReactNativeRecordScreenClass();
|
|
74
|
+
|
|
75
|
+
export default ReactNativeRecordScreen;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//@flow
|
|
2
|
+
import html2canvas from "html2canvas";
|
|
3
|
+
|
|
4
|
+
async function captureRef(view, options) {
|
|
5
|
+
if (options.result === "tmpfile") {
|
|
6
|
+
console.warn("Tmpfile is not implemented for web. Try base64 or file.\n"+
|
|
7
|
+
"For compatibility, it currently returns the same result as data-uri");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
// TODO: implement snapshotContentContainer option
|
|
11
|
+
|
|
12
|
+
const h2cOptions = {};
|
|
13
|
+
let renderedCanvas = await html2canvas(view, h2cOptions);
|
|
14
|
+
|
|
15
|
+
if (options.width && options.height) {
|
|
16
|
+
// Resize result
|
|
17
|
+
const resizedCanvas = document.createElement('canvas');
|
|
18
|
+
const resizedContext = resizedCanvas.getContext('2d');
|
|
19
|
+
resizedCanvas.height = options.height;
|
|
20
|
+
resizedCanvas.width = options.width;
|
|
21
|
+
resizedContext.drawImage(renderedCanvas, 0, 0, resizedCanvas.width, resizedCanvas.height);
|
|
22
|
+
renderedCanvas = resizedCanvas;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const dataUrl = renderedCanvas.toDataURL("image/" + options.format, options.quality);
|
|
26
|
+
if (options.result === "data-uri" || options.result === "tmpfile") return dataUrl;
|
|
27
|
+
return dataUrl.replace(/data:image\/(\w+);base64,/, '');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function captureScreen(options) {
|
|
31
|
+
return captureRef(window.document.body, options);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function releaseCapture(uri) {
|
|
35
|
+
throw new Error("Tmpfile is not implemented for web. Try base64 or file");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export default {
|
|
39
|
+
captureRef,
|
|
40
|
+
captureScreen,
|
|
41
|
+
releaseCapture
|
|
42
|
+
}
|