rn-pendo-sdk
Version:
Pendo Mobile React Native SDK
1 lines • 6.03 kB
JavaScript
Object.defineProperty(exports,"__esModule",{value:true});exports.traverseRootsOniOS=exports.traverseOniOS=void 0;var _reactNative=require("react-native");var _common=require("./common");var _fiberTypes=require("./fiber-types");var _pendoLogger=require("./pendoLogger");var _pendoTypes=require("./pendoTypes");var ReactNativePendo=_reactNative.NativeModules.ReactNativePendo;var traverseRootsOniOS=exports.traverseRootsOniOS=function traverseRootsOniOS(node,options,result){if(_fiberTypes.TagFinder.isRootNode(node,options)){_fiberTypes.TagFinder.findAndAddRootTags(node,options,result,false,false);}if(options.isDrawerVisible&&_fiberTypes.TagFinder.isDrawerRelatedNode(node,options.drawerBaseNameCandidates)){var drawerTag=_fiberTypes.TagFinder.closestDrawerTag(node,options);if(drawerTag&&(options.drawerTakeFirstTag&&result.drawerTag===null||!options.drawerTakeFirstTag)){if(!ReactNativePendo.viewsVisible([drawerTag])){_pendoLogger.Logger.debug('Invalid Drawer discovered ',drawerTag);}else{result.drawerTag=drawerTag;_common.Utils.addRootTag(result,drawerTag,'Drawer discovered: ');}}}if(result.modalTag==null){var modalType=_fiberTypes.TagFinder.getModalType(node,options);if(modalType!==_pendoTypes.ModalType.None){var nodeName=_fiberTypes.TagFinder.getNodeTypeName(node);_pendoLogger.Logger.debug(`Modal detected: type=${_fiberTypes.TagFinder.getModalTypeName(modalType)}, node="${nodeName}"`);var modalTag=null;if(modalType===_pendoTypes.ModalType.GorhomModal||modalType===_pendoTypes.ModalType.ReactNativeModals){modalTag=_fiberTypes.TagFinder.findModalTagViaPortal(node,modalType,options);if(modalTag&&!ReactNativePendo.viewsVisible([modalTag])){_pendoLogger.Logger.debug(`Invalid portal modal discovered (${_fiberTypes.TagFinder.getModalTypeName(modalType)})`,modalTag);modalTag=null;}}if(!modalTag){var modalOptions=_fiberTypes.TagFinder.getModalOptionsByType(modalType,null,options);modalTag=_fiberTypes.TagFinder.closestNativeNodeTag(node,modalOptions.traverseDirection,modalOptions.takeRCTView,modalOptions.nativeNodeIterationCount);}if(modalTag){if(!ReactNativePendo.viewsVisible([modalTag])){_pendoLogger.Logger.debug(`Invalid Modal discovered of type ${modalType}`,modalTag);}else{result.modalTag=modalTag;result.modalType=modalType;_common.Utils.addRootTag(result,modalTag,`${_fiberTypes.TagFinder.getModalTypeName(modalType)} modal discovered: `);}}}}};var traverseOniOS=exports.traverseOniOS=function traverseOniOS(node,options,results){if(_fiberTypes.TagFinder.isNavigationBar(node,options.navigationBarBaseNameCandidates)){var navigationBarTag=_fiberTypes.TagFinder.closestNativeNodeTag(node,options.navigationBarTraverseDirection,options.navigationBarTakeRCTView,options.nativeNodeIterationCount);if(navigationBarTag&&(options.navigationBarTakeFirstTag&&results.navigationBarTag==null||!options.navigationBarTakeFirstTag)){if(!ReactNativePendo.viewsVisible([navigationBarTag])){_pendoLogger.Logger.debug('Invalid NavigationBar discovered ',navigationBarTag);}else{results.navigationBarTag=navigationBarTag;_pendoLogger.Logger.debug('NavigationBar discovered ',navigationBarTag);}}}var materialTabBarExists=_fiberTypes.TagFinder.isMaterialTabBarExists(node,options.tabBarWrapperView);if(materialTabBarExists&&_fiberTypes.TagFinder.isTabBarNavigator(node,options.tabBarBaseNameCandidates)){var materialTabBarTag=_fiberTypes.TagFinder.closestNativeNodeTag(node,options.tabBarTraverseDirection,options.tabBarTakeRCTView,options.nativeNodeIterationCount);if(materialTabBarTag){if(!ReactNativePendo.viewsVisible([materialTabBarTag])){_pendoLogger.Logger.debug('Invalid Material TabBar discovered ',materialTabBarTag);}else{results.tabBarTag=materialTabBarTag;_pendoLogger.Logger.debug('Material TabBar discovered ',results.tabBarTag);}}}if(results.bottomBarTag===null&&_fiberTypes.TagFinder.isBottomTabBar(node,options.bottomBarBaseNameCandidates)){var bottomTabBarTag=_fiberTypes.TagFinder.closestNativeNodeTag(node,options.bottomBarTraverseDirection,options.bottomBarTakeRCTView,options.nativeNodeIterationCount);if(bottomTabBarTag&&(options.bottomBarTakeFirstTag&&results.bottomBarTag==null||!options.bottomBarTakeFirstTag)){if(!ReactNativePendo.viewsVisible([bottomTabBarTag])){_pendoLogger.Logger.debug('Invalid Bottom TabBar discovered ',bottomTabBarTag);}else{results.bottomBarTag=bottomTabBarTag;_pendoLogger.Logger.debug('Bottom TabBar discovered ',results.bottomBarTag);}}}if(_fiberTypes.TagFinder.isMaterialBottomTabNavigator(node,options.materialBottomTabBaseNameCandidates)){var bottomTabBarNode=_fiberTypes.TagFinder.closestNativeNode(node,options.materialBottomTabTraverseDirection,options.materialBottomTabTakeRCTView,options.nativeNodeIterationCount);var materialBottomTabBarTag=_fiberTypes.TagFinder.highestTagInStateNodeChildren(bottomTabBarNode);if(materialBottomTabBarTag){if(!ReactNativePendo.viewsVisible([materialBottomTabBarTag])){_pendoLogger.Logger.debug('Invalid Material Bottom Tab Navigator discovered ',materialBottomTabBarTag);}else{results.bottomBarTag=materialBottomTabBarTag;_pendoLogger.Logger.debug('Material Bottom Tab Navigator was discovered ',results.bottomBarTag);}}}if(_fiberTypes.TagFinder.isBottomSheet(node,options.bottomSheetBaseNameCandidates)&&results.modalType!==_pendoTypes.ModalType.GorhomModal){var bottomSheetNativeTag=_fiberTypes.TagFinder.closestNativeNodeTag(node,options.bottomSheetTraverseDirection,options.bottomSheetTakeRCTView,options.nativeNodeIterationCount);if(bottomSheetNativeTag&&!results.bottomSheetTags.includes(bottomSheetNativeTag)){if(!ReactNativePendo.viewsVisible([bottomSheetNativeTag])){_pendoLogger.Logger.debug('Invalid Bottom Sheet discovered ',bottomSheetNativeTag);}else{results.bottomSheetTags.push(bottomSheetNativeTag);_pendoLogger.Logger.debug('Bottom Sheet was discovered ',bottomSheetNativeTag);}}}if((options.collectAllClickableElements||results.rootTags.length>0)&&_fiberTypes.TagFinder.isNodeClickable(node,options.clickableElementsNativeIDsRegex)){_fiberTypes.TagFinder.addClickableElement(node,options,results);}};