UNPKG

@wscsports/blaze-rtn-sdk

Version:
149 lines (145 loc) 5.85 kB
import { NativeModules } from 'react-native'; import { BlazeGlobalDelegateHelper } from './classes/global-delegate'; import { BlazeEntryPointDelegateHelper } from './classes/entry-point-delegate'; import { mapToBlazeErrorOrRethrow } from './interfaces/blaze-error.interface'; import { BlazeFollowEntitiesDelegateHelper } from './classes/follow-entities-delegate'; import { BlazeCastingDelegateHelper } from './classes/casting-delegate'; import { BlazePipDelegateHelper } from './classes/pip-delegate'; const { RTNBlazeSdk } = NativeModules; const BlazeSDKNativeModule = RTNBlazeSdk; // This wrapper is hiding the internal interface that works with the native module, and serves as additional layer to add custom logic. class BlazeSdkWrapper { init(options) { this.setEntryPointDelegate(options.playerEntryPointDelegate); this.setGlobalDelegate(options.globalDelegate); return BlazeSDKNativeModule.init(options).catch(mapToBlazeErrorOrRethrow); } isInitialized() { return BlazeSDKNativeModule.isInitialized(); } playStory(options) { return BlazeSDKNativeModule.playStory(options).catch(mapToBlazeErrorOrRethrow); } prepareStories(options) { return BlazeSDKNativeModule.prepareStories(options).catch(mapToBlazeErrorOrRethrow); } playStories(options) { return BlazeSDKNativeModule.playStories(options).catch(mapToBlazeErrorOrRethrow); } playMoment(options) { return BlazeSDKNativeModule.playMoment(options).catch(mapToBlazeErrorOrRethrow); } prepareMoments(options) { return BlazeSDKNativeModule.prepareMoments(options).catch(mapToBlazeErrorOrRethrow); } playMoments(options) { return BlazeSDKNativeModule.playMoments(options).catch(mapToBlazeErrorOrRethrow); } playVideo(options) { return BlazeSDKNativeModule.playVideo(options).catch(mapToBlazeErrorOrRethrow); } prepareVideos(options) { return BlazeSDKNativeModule.prepareVideos(options).catch(mapToBlazeErrorOrRethrow); } playVideos(options) { return BlazeSDKNativeModule.playVideos(options).catch(mapToBlazeErrorOrRethrow); } appendMomentsToPlayer(options) { return BlazeSDKNativeModule.appendMomentsToPlayer(options).catch(mapToBlazeErrorOrRethrow); } dismissPlayer() { return BlazeSDKNativeModule.dismissPlayer(); } setExternalUserId(externalUserId) { return BlazeSDKNativeModule.setExternalUserId(externalUserId).catch(mapToBlazeErrorOrRethrow); } setDoNotTrack(doNotTrackUser) { return BlazeSDKNativeModule.setDoNotTrack(doNotTrackUser); } setDisableAnalytics(disableAnalytics) { return BlazeSDKNativeModule.setDisableAnalytics(disableAnalytics); } handleUniversalLink(link) { return BlazeSDKNativeModule.handleUniversalLink(link).catch(mapToBlazeErrorOrRethrow); } canHandleUniversalLink(link) { return BlazeSDKNativeModule.canHandleUniversalLink(link); } updateGeoRestriction(geoLocation) { return BlazeSDKNativeModule.updateGeoRestriction(geoLocation).catch(mapToBlazeErrorOrRethrow); } setGlobalDelegate(globalDelegate) { BlazeGlobalDelegateHelper.registerGlobalDelegate(globalDelegate); } setEntryPointDelegate(playerEntryPointDelegate) { BlazeEntryPointDelegateHelper.registerEntryPointDelegate(playerEntryPointDelegate); } setDefaultVideosPlaybackConfiguration(config) { return BlazeSDKNativeModule.setDefaultVideosPlaybackConfiguration(config).catch(mapToBlazeErrorOrRethrow); } getDefaultVideosPlaybackConfiguration() { return BlazeSDKNativeModule.getDefaultVideosPlaybackConfiguration().catch(mapToBlazeErrorOrRethrow); } setDefaultMomentsPlaybackConfiguration(config) { return BlazeSDKNativeModule.setDefaultMomentsPlaybackConfiguration(config).catch(mapToBlazeErrorOrRethrow); } getDefaultMomentsPlaybackConfiguration() { return BlazeSDKNativeModule.getDefaultMomentsPlaybackConfiguration().catch(mapToBlazeErrorOrRethrow); } canHandlePushNotification(payload) { return BlazeSDKNativeModule.canHandlePushNotification(payload); } handleNotificationPayload(payload) { return BlazeSDKNativeModule.handleNotificationPayload(payload).catch(mapToBlazeErrorOrRethrow); } setFollowEntitiesDelegate(delegate) { BlazeFollowEntitiesDelegateHelper.registerFollowEntitiesDelegate(delegate); } setFollowedEntities(entityIds) { return BlazeSDKNativeModule.setFollowedEntities(entityIds).catch(mapToBlazeErrorOrRethrow); } insertFollowedEntities(entityIds) { return BlazeSDKNativeModule.insertFollowedEntities(entityIds).catch(mapToBlazeErrorOrRethrow); } removeFollowedEntities(entityIds) { return BlazeSDKNativeModule.removeFollowedEntities(entityIds).catch(mapToBlazeErrorOrRethrow); } getFollowedEntities() { return BlazeSDKNativeModule.getFollowedEntities().catch(mapToBlazeErrorOrRethrow); } setPreferredLanguage(language) { return BlazeSDKNativeModule.setPreferredLanguage(language); } showSearchScreen(options) { return BlazeSDKNativeModule.showSearchScreen(options ?? {}).catch(mapToBlazeErrorOrRethrow); } stopActiveCastingSession() { return BlazeSDKNativeModule.stopActiveCastingSession(); } setCastingDelegate(delegate) { BlazeCastingDelegateHelper.registerCastingDelegate(delegate); } stopActivePiPSession() { return BlazeSDKNativeModule.stopActivePiPSession(); } isPiPActive() { return BlazeSDKNativeModule.isPiPActive(); } setPipDelegate(delegate) { BlazePipDelegateHelper.registerPipDelegate(delegate); } // Singleton instance // Private constructor for singleton constructor() {} // Method to get singleton instance static getInstance() { if (!this.instance) { this.instance = new BlazeSdkWrapper(); } return this.instance; } } export const BlazeSDK = BlazeSdkWrapper.getInstance(); //# sourceMappingURL=NativeBlazeSdk.js.map