@buoy-gg/events 7.0.78 → 7.0.80
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/lib/commonjs/components/UnifiedEventDetail.js +1 -1
- package/lib/commonjs/components/UnifiedEventItem.js +1 -1
- package/lib/commonjs/hooks/useUnifiedEvents.js +1 -1
- package/lib/commonjs/sources/sourceIds.js +1 -1
- package/lib/commonjs/stores/unifiedEventStore.js +1 -1
- package/lib/commonjs/sync/eventsSyncAdapter.js +1 -1
- package/lib/commonjs/utils/autoDiscoverEventSources.js +1 -1
- package/lib/commonjs/utils/eventExportFormatter.js +1 -1
- package/lib/module/components/UnifiedEventDetail.js +1 -1
- package/lib/module/components/UnifiedEventItem.js +1 -1
- package/lib/module/hooks/useUnifiedEvents.js +1 -1
- package/lib/module/sources/sourceIds.js +1 -1
- package/lib/module/stores/unifiedEventStore.js +1 -1
- package/lib/module/sync/eventsSyncAdapter.js +1 -1
- package/lib/module/utils/autoDiscoverEventSources.js +1 -1
- package/lib/module/utils/eventExportFormatter.js +1 -1
- package/lib/typescript/types/index.d.ts +1 -1
- package/lib/web/index.mjs +9 -9
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.UnifiedEventDetail=void 0;var _utils=require("@buoy-gg/shared-ui/utils");var _reactNative=require("react-native");var _react=require("react");var _sharedUi=require("@buoy-gg/shared-ui");var _dataViewer=require("@buoy-gg/shared-ui/dataViewer");var _ReactQueryEventDetail=require("./ReactQueryEventDetail");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function tryLoadOptionalDetailComponents(){const o={StorageEventDetailContent:null,ReduxActionDetailContent:null,NetworkEventDetailView:null,RenderDetailView:null,ZustandStateDetailContent:null,JotaiAtomDetailContent:null,RouteEventDetail:null};try{const e=(0,_utils.loadToolModule)("@buoy-gg/storage");o.StorageEventDetailContent=e.StorageEventDetailContent}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/redux");o.ReduxActionDetailContent=e.ReduxActionDetailContent}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/network");o.NetworkEventDetailView=e.NetworkEventDetailView}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/highlight-updates");o.RenderDetailView=e.RenderDetailView}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/zustand");o.ZustandStateDetailContent=e.ZustandStateDetailContent}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/jotai");o.JotaiAtomDetailContent=e.JotaiAtomDetailContent}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/route-events");o.RouteEventDetail=e.RouteEventDetail}catch{}return o}let optionalComponents;let componentVersion=-1;function getOptionalComponents(){if(!optionalComponents||componentVersion!==(0,_utils.getToolModuleVersion)()){optionalComponents=tryLoadOptionalDetailComponents();componentVersion=(0,_utils.getToolModuleVersion)()}return optionalComponents}const SOURCE_CONFIG={"storage-async":{label:"AsyncStorage",color:"#8B5CF6"},"storage-mmkv":{label:"MMKV",color:"#F59E0B"},redux:{label:"Redux",color:"#3B82F6"},network:{label:"Network",color:"#10B981"},"react-query":{label:"React Query",color:"#EC4899"},"react-query-query":{label:"Query",color:"#EC4899"},"react-query-mutation":{label:"Mutation",color:"#F97316"},route:{label:"Route",color:"#06B6D4"},zustand:{label:"Zustand",color:"#764ABC"},jotai:{label:"Jotai",color:"#14B8A6"},render:{label:"Render",color:"#F472B6"},three:{label:"Scene loads",color:"#F59E0B"},capacitor:{label:"Capacitor",color:"#119EFF"}};function isStorageEvent(o){return o==="storage-async"||o==="storage-mmkv"}function getValueType(o){const e=(0,_sharedUi.parseValue)(o);if(e===null)return"null";if(e===void 0)return"undefined";if(Array.isArray(e))return"array";if(typeof e==="boolean")return"boolean";if(typeof e==="number")return"number";if(typeof e==="string")return"string";if(typeof e==="object")return"object";return"undefined"}function PassThrough({children:o}){return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:o})}const UnifiedEventDetail=exports.UnifiedEventDetail=(0,_react.memo)(function o({event:e,onBack:x,NetworkEventDetailViewComponent:g,networkDetailWrapper:E,RouteEventDetailComponent:y,detailComponents:l,onNavigate:D}){const r=(0,_react.useMemo)(()=>({...getOptionalComponents(),...l}),[l,(0,_utils.getToolModuleVersion)()]);const a=SOURCE_CONFIG[e.source];const i=new Date(e.timestamp);const{values:T,toggle:h}=(0,_sharedUi.useIgnoredPatterns)();const s=(0,_react.useMemo)(()=>{if(!isStorageEvent(e.source))return null;if(!r.StorageEventDetailContent)return null;const n=e.originalEvent;const t={...n,timestamp:new Date(n.timestamp)};return{key:t.data?.key||"unknown",lastEvent:t,events:[t],totalOperations:1,currentValue:t.data?.value,valueType:getValueType(t.data?.value),storageTypes:new Set([t.storageType||"async"])}},[e,r]);if(s&&r.StorageEventDetailContent){const{StorageEventDetailContent:n}=r;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-storage`,children:(0,_jsxRuntime.jsx)(n,{conversation:s,selectedEventIndex:0,onEventIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="redux"&&r.ReduxActionDetailContent){const{ReduxActionDetailContent:n}=r;const t=e.originalEvent;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-redux`,children:(0,_jsxRuntime.jsx)(n,{action:t,actions:[t],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}const c=g??r.NetworkEventDetailView;if(e.source==="network"&&c){const n=e.originalEvent;const t=E??PassThrough;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,children:(0,_jsxRuntime.jsx)(t,{children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",style:styles.content,testID:`${_testIDs.EVENTS_TEST_ID}-detail-network`,children:(0,_jsxRuntime.jsx)(c,{event:n,ignoredPatterns:T,onTogglePattern:h})})})})}if(e.source==="react-query"||e.source==="react-query-query"||e.source==="react-query-mutation"){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-react-query`,children:(0,_jsxRuntime.jsx)(_ReactQueryEventDetail.ReactQueryEventDetail,{event:e})})}if(e.source==="zustand"&&r.ZustandStateDetailContent){const{ZustandStateDetailContent:n}=r;const t=e.originalEvent;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-zustand`,children:(0,_jsxRuntime.jsx)(n,{change:t,changes:[t],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="jotai"&&r.JotaiAtomDetailContent){const{JotaiAtomDetailContent:n}=r;const t=e.originalEvent;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-jotai`,children:(0,_jsxRuntime.jsx)(n,{change:t,changes:[t],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="render"&&r.RenderDetailView){const{RenderDetailView:n}=r;const t=e.originalEvent;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",style:styles.content,testID:`${_testIDs.EVENTS_TEST_ID}-detail-render`,children:(0,_jsxRuntime.jsx)(n,{render:t.render})})})}const d=y??r.RouteEventDetail;if(e.source==="route"&&d){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-route`,children:(0,_jsxRuntime.jsx)(d,{event:e.originalEvent,onNavigate:D})})})}const u=()=>{return e.originalEvent};const m=async()=>{await(0,_sharedUi.copyToClipboard)({source:e.source,timestamp:i.toISOString(),title:e.title,subtitle:e.subtitle,data:u()})};return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail`,children:(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",style:styles.content,contentContainerStyle:styles.contentContainer,testID:`${_testIDs.EVENTS_TEST_ID}-detail-scroll`,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.sourceBadgeRow,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.sourceBadge,{backgroundColor:a.color+"20"}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.sourceDot,{backgroundColor:a.color}]}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.sourceLabel,{color:a.color}],testID:`${_testIDs.EVENTS_TEST_ID}-detail-source`,children:a.label})]})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.title,testID:`${_testIDs.EVENTS_TEST_ID}-detail-title`,children:e.title}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.subtitle,testID:`${_testIDs.EVENTS_TEST_ID}-detail-subtitle`,children:e.subtitle}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.timestampRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.timestampLabel,children:"Timestamp"}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.timestampValue,testID:`${_testIDs.EVENTS_TEST_ID}-detail-timestamp`,children:[i.toLocaleTimeString()," (",(0,_sharedUi.formatRelativeTime)(i),")"]})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.dataSection,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionLabel,children:"Event Data"}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.dataContainer,testID:`${_testIDs.EVENTS_TEST_ID}-detail-data`,children:(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{testIDPrefix:`${_testIDs.EVENTS_TEST_ID}-detail-data`,data:u(),title:"",showTypeFilter:true,rawMode:true,initialExpanded:true})})]})]})})});const styles=_reactNative.StyleSheet.create({container:{flex:1,backgroundColor:"transparent"},content:{flex:1},contentContainer:{padding:16},sourceBadgeRow:{flexDirection:"row",marginBottom:12},sourceBadge:{flexDirection:"row",alignItems:"center",paddingHorizontal:10,paddingVertical:6,borderRadius:12,gap:6},sourceDot:{width:6,height:6,borderRadius:3},sourceLabel:{fontSize:12,fontWeight:"600"},title:{fontSize:24,fontWeight:"700",color:_sharedUi.night.color.text,marginBottom:4},subtitle:{fontSize:16,color:_sharedUi.night.color.textTertiary,marginBottom:16},timestampRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,borderTopWidth:1,borderTopColor:_sharedUi.night.color.border,borderBottomWidth:1,borderBottomColor:_sharedUi.night.color.border,marginBottom:16},timestampLabel:{fontSize:14,color:_sharedUi.night.color.textTertiary},timestampValue:{fontSize:14,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},dataSection:{marginTop:8},sectionLabel:{fontSize:12,fontWeight:"600",color:_sharedUi.night.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8},dataContainer:{backgroundColor:_sharedUi.night.color.surface,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,overflow:"hidden"}});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.UnifiedEventDetail=void 0;var _utils=require("@buoy-gg/shared-ui/utils");var _reactNative=require("react-native");var _react=require("react");var _sharedUi=require("@buoy-gg/shared-ui");var _dataViewer=require("@buoy-gg/shared-ui/dataViewer");var _ReactQueryEventDetail=require("./ReactQueryEventDetail");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function tryLoadOptionalDetailComponents(){const o={StorageEventDetailContent:null,ReduxActionDetailContent:null,NetworkEventDetailView:null,RenderDetailView:null,ZustandStateDetailContent:null,JotaiAtomDetailContent:null,RouteEventDetail:null};try{const e=(0,_utils.loadToolModule)("@buoy-gg/storage");o.StorageEventDetailContent=e.StorageEventDetailContent}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/redux");o.ReduxActionDetailContent=e.ReduxActionDetailContent}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/network");o.NetworkEventDetailView=e.NetworkEventDetailView}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/highlight-updates");o.RenderDetailView=e.RenderDetailView}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/zustand");o.ZustandStateDetailContent=e.ZustandStateDetailContent}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/jotai");o.JotaiAtomDetailContent=e.JotaiAtomDetailContent}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/route-events");o.RouteEventDetail=e.RouteEventDetail}catch{}return o}let optionalComponents;let componentVersion=-1;function getOptionalComponents(){if(!optionalComponents||componentVersion!==(0,_utils.getToolModuleVersion)()){optionalComponents=tryLoadOptionalDetailComponents();componentVersion=(0,_utils.getToolModuleVersion)()}return optionalComponents}const SOURCE_CONFIG={"storage-async":{label:"AsyncStorage",color:"#8B5CF6"},"storage-mmkv":{label:"MMKV",color:"#F59E0B"},redux:{label:"Redux",color:"#3B82F6"},network:{label:"Network",color:"#10B981"},"react-query":{label:"React Query",color:"#EC4899"},"react-query-query":{label:"Query",color:"#EC4899"},"react-query-mutation":{label:"Mutation",color:"#F97316"},route:{label:"Route",color:"#06B6D4"},zustand:{label:"Zustand",color:"#764ABC"},jotai:{label:"Jotai",color:"#14B8A6"},render:{label:"Render",color:"#F472B6"},three:{label:"Scene loads",color:"#F59E0B"},socket:{label:"Sockets",color:"#20C997"},capacitor:{label:"Capacitor",color:"#119EFF"}};function isStorageEvent(o){return o==="storage-async"||o==="storage-mmkv"}function getValueType(o){const e=(0,_sharedUi.parseValue)(o);if(e===null)return"null";if(e===void 0)return"undefined";if(Array.isArray(e))return"array";if(typeof e==="boolean")return"boolean";if(typeof e==="number")return"number";if(typeof e==="string")return"string";if(typeof e==="object")return"object";return"undefined"}function PassThrough({children:o}){return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:o})}const UnifiedEventDetail=exports.UnifiedEventDetail=(0,_react.memo)(function o({event:e,onBack:x,NetworkEventDetailViewComponent:g,networkDetailWrapper:E,RouteEventDetailComponent:y,detailComponents:l,onNavigate:D}){const r=(0,_react.useMemo)(()=>({...getOptionalComponents(),...l}),[l,(0,_utils.getToolModuleVersion)()]);const a=SOURCE_CONFIG[e.source];const i=new Date(e.timestamp);const{values:T,toggle:h}=(0,_sharedUi.useIgnoredPatterns)();const s=(0,_react.useMemo)(()=>{if(!isStorageEvent(e.source))return null;if(!r.StorageEventDetailContent)return null;const n=e.originalEvent;const t={...n,timestamp:new Date(n.timestamp)};return{key:t.data?.key||"unknown",lastEvent:t,events:[t],totalOperations:1,currentValue:t.data?.value,valueType:getValueType(t.data?.value),storageTypes:new Set([t.storageType||"async"])}},[e,r]);if(s&&r.StorageEventDetailContent){const{StorageEventDetailContent:n}=r;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-storage`,children:(0,_jsxRuntime.jsx)(n,{conversation:s,selectedEventIndex:0,onEventIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="redux"&&r.ReduxActionDetailContent){const{ReduxActionDetailContent:n}=r;const t=e.originalEvent;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-redux`,children:(0,_jsxRuntime.jsx)(n,{action:t,actions:[t],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}const c=g??r.NetworkEventDetailView;if(e.source==="network"&&c){const n=e.originalEvent;const t=E??PassThrough;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,children:(0,_jsxRuntime.jsx)(t,{children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",style:styles.content,testID:`${_testIDs.EVENTS_TEST_ID}-detail-network`,children:(0,_jsxRuntime.jsx)(c,{event:n,ignoredPatterns:T,onTogglePattern:h})})})})}if(e.source==="react-query"||e.source==="react-query-query"||e.source==="react-query-mutation"){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-react-query`,children:(0,_jsxRuntime.jsx)(_ReactQueryEventDetail.ReactQueryEventDetail,{event:e})})}if(e.source==="zustand"&&r.ZustandStateDetailContent){const{ZustandStateDetailContent:n}=r;const t=e.originalEvent;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-zustand`,children:(0,_jsxRuntime.jsx)(n,{change:t,changes:[t],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="jotai"&&r.JotaiAtomDetailContent){const{JotaiAtomDetailContent:n}=r;const t=e.originalEvent;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-jotai`,children:(0,_jsxRuntime.jsx)(n,{change:t,changes:[t],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="render"&&r.RenderDetailView){const{RenderDetailView:n}=r;const t=e.originalEvent;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",style:styles.content,testID:`${_testIDs.EVENTS_TEST_ID}-detail-render`,children:(0,_jsxRuntime.jsx)(n,{render:t.render})})})}const d=y??r.RouteEventDetail;if(e.source==="route"&&d){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-route`,children:(0,_jsxRuntime.jsx)(d,{event:e.originalEvent,onNavigate:D})})})}const u=()=>{return e.originalEvent};const m=async()=>{await(0,_sharedUi.copyToClipboard)({source:e.source,timestamp:i.toISOString(),title:e.title,subtitle:e.subtitle,data:u()})};return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail`,children:(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",style:styles.content,contentContainerStyle:styles.contentContainer,testID:`${_testIDs.EVENTS_TEST_ID}-detail-scroll`,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.sourceBadgeRow,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.sourceBadge,{backgroundColor:a.color+"20"}],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.sourceDot,{backgroundColor:a.color}]}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.sourceLabel,{color:a.color}],testID:`${_testIDs.EVENTS_TEST_ID}-detail-source`,children:a.label})]})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.title,testID:`${_testIDs.EVENTS_TEST_ID}-detail-title`,children:e.title}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.subtitle,testID:`${_testIDs.EVENTS_TEST_ID}-detail-subtitle`,children:e.subtitle}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.timestampRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.timestampLabel,children:"Timestamp"}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.timestampValue,testID:`${_testIDs.EVENTS_TEST_ID}-detail-timestamp`,children:[i.toLocaleTimeString()," (",(0,_sharedUi.formatRelativeTime)(i),")"]})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.dataSection,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionLabel,children:"Event Data"}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.dataContainer,testID:`${_testIDs.EVENTS_TEST_ID}-detail-data`,children:(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{testIDPrefix:`${_testIDs.EVENTS_TEST_ID}-detail-data`,data:u(),title:"",showTypeFilter:true,rawMode:true,initialExpanded:true})})]})]})})});const styles=_reactNative.StyleSheet.create({container:{flex:1,backgroundColor:"transparent"},content:{flex:1},contentContainer:{padding:16},sourceBadgeRow:{flexDirection:"row",marginBottom:12},sourceBadge:{flexDirection:"row",alignItems:"center",paddingHorizontal:10,paddingVertical:6,borderRadius:12,gap:6},sourceDot:{width:6,height:6,borderRadius:3},sourceLabel:{fontSize:12,fontWeight:"600"},title:{fontSize:24,fontWeight:"700",color:_sharedUi.night.color.text,marginBottom:4},subtitle:{fontSize:16,color:_sharedUi.night.color.textTertiary,marginBottom:16},timestampRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,borderTopWidth:1,borderTopColor:_sharedUi.night.color.border,borderBottomWidth:1,borderBottomColor:_sharedUi.night.color.border,marginBottom:16},timestampLabel:{fontSize:14,color:_sharedUi.night.color.textTertiary},timestampValue:{fontSize:14,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},dataSection:{marginTop:8},sectionLabel:{fontSize:12,fontWeight:"600",color:_sharedUi.night.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8},dataContainer:{backgroundColor:_sharedUi.night.color.surface,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,overflow:"hidden"}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.UnifiedEventItem=void 0;var _utils=require("@buoy-gg/shared-ui/utils");var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function tryLoadOptionalComponents(){const t={StorageEventCard:null,getValueType:null,ReduxActionItem:null,NetworkEventItemCompact:null,RouteEventItemCompact:null,ZustandStateChangeItem:null,JotaiAtomChangeItem:null};try{const e=(0,_utils.loadToolModule)("@buoy-gg/storage");t.StorageEventCard=e.StorageEventCard;t.getValueType=e.getValueType}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/redux");t.ReduxActionItem=e.ReduxActionItem}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/network");t.NetworkEventItemCompact=e.NetworkEventItemCompact}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/route-events");t.RouteEventItemCompact=e.RouteEventItemCompact}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/zustand");t.ZustandStateChangeItem=e.ZustandStateChangeItem}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/jotai");t.JotaiAtomChangeItem=e.JotaiAtomChangeItem}catch{}return t}let optionalComponents;let componentVersion=-1;function getOptionalComponents(){if(!optionalComponents||componentVersion!==(0,_utils.getToolModuleVersion)()){optionalComponents=tryLoadOptionalComponents();componentVersion=(0,_utils.getToolModuleVersion)()}return optionalComponents}const SOURCE_CONFIG={"storage-async":{label:"Storage",color:"#8B5CF6"},"storage-mmkv":{label:"MMKV",color:"#F59E0B"},redux:{label:"Redux",color:"#3B82F6"},network:{label:"Network",color:"#10B981"},"react-query":{label:"Query",color:"#EC4899"},"react-query-query":{label:"Query",color:"#EC4899"},"react-query-mutation":{label:"Mutation",color:"#F97316"},route:{label:"Route",color:"#06B6D4"},zustand:{label:"Zustand",color:"#764ABC"},jotai:{label:"Jotai",color:"#14B8A6"},render:{label:"Render",color:"#F472B6"},three:{label:"Scene loads",color:"#F59E0B"},capacitor:{label:"Capacitor",color:"#119EFF"}};function getStatusColor(t){switch(t){case"success":return"#10B981";case"error":return"#EF4444";case"pending":return"#F59E0B";case"neutral":default:return"#6B7280"}}function isStorageEvent(t){return t==="storage-async"||t==="storage-mmkv"}function CorrelationBadge({label:t,color:e,testID:o}){return(0,_jsxRuntime.jsx)(_sharedUi.Pill,{label:t,color:e,variant:"soft",size:"sm",style:{marginLeft:6},testID:o})}const SOURCE_BADGE_LABELS={"storage-async":"STORAGE","storage-mmkv":"MMKV",redux:"REDUX",network:"NET","react-query":"QUERY","react-query-query":"QUERY","react-query-mutation":"MUTATION",route:"ROUTE",zustand:"ZUSTAND",jotai:"JOTAI",render:"RENDER",capacitor:"CAPACITOR",three:"SCENE"};function SourceBadgeWrapper({source:t,testID:e,children:o}){const n=SOURCE_CONFIG[t].color;const s=SOURCE_BADGE_LABELS[t];return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.badgeWrapper,testID:e,children:[o,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.sourceBadge,{backgroundColor:`${n}20`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.sourceBadgeText,{color:n}],testID:e?`${e}-badge`:void 0,children:s})})]})}const UnifiedEventItem=exports.UnifiedEventItem=(0,_react.memo)(function t({event:e,onPress:o,isSelected:n=false,isExpanded:s=false,onNavigate:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.UnifiedEventItem=void 0;var _utils=require("@buoy-gg/shared-ui/utils");var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function tryLoadOptionalComponents(){const t={StorageEventCard:null,getValueType:null,ReduxActionItem:null,NetworkEventItemCompact:null,RouteEventItemCompact:null,ZustandStateChangeItem:null,JotaiAtomChangeItem:null};try{const e=(0,_utils.loadToolModule)("@buoy-gg/storage");t.StorageEventCard=e.StorageEventCard;t.getValueType=e.getValueType}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/redux");t.ReduxActionItem=e.ReduxActionItem}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/network");t.NetworkEventItemCompact=e.NetworkEventItemCompact}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/route-events");t.RouteEventItemCompact=e.RouteEventItemCompact}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/zustand");t.ZustandStateChangeItem=e.ZustandStateChangeItem}catch{}try{const e=(0,_utils.loadToolModule)("@buoy-gg/jotai");t.JotaiAtomChangeItem=e.JotaiAtomChangeItem}catch{}return t}let optionalComponents;let componentVersion=-1;function getOptionalComponents(){if(!optionalComponents||componentVersion!==(0,_utils.getToolModuleVersion)()){optionalComponents=tryLoadOptionalComponents();componentVersion=(0,_utils.getToolModuleVersion)()}return optionalComponents}const SOURCE_CONFIG={"storage-async":{label:"Storage",color:"#8B5CF6"},"storage-mmkv":{label:"MMKV",color:"#F59E0B"},redux:{label:"Redux",color:"#3B82F6"},network:{label:"Network",color:"#10B981"},"react-query":{label:"Query",color:"#EC4899"},"react-query-query":{label:"Query",color:"#EC4899"},"react-query-mutation":{label:"Mutation",color:"#F97316"},route:{label:"Route",color:"#06B6D4"},zustand:{label:"Zustand",color:"#764ABC"},jotai:{label:"Jotai",color:"#14B8A6"},render:{label:"Render",color:"#F472B6"},three:{label:"Scene loads",color:"#F59E0B"},socket:{label:"Sockets",color:"#20C997"},capacitor:{label:"Capacitor",color:"#119EFF"}};function getStatusColor(t){switch(t){case"success":return"#10B981";case"error":return"#EF4444";case"pending":return"#F59E0B";case"neutral":default:return"#6B7280"}}function isStorageEvent(t){return t==="storage-async"||t==="storage-mmkv"}function CorrelationBadge({label:t,color:e,testID:o}){return(0,_jsxRuntime.jsx)(_sharedUi.Pill,{label:t,color:e,variant:"soft",size:"sm",style:{marginLeft:6},testID:o})}const SOURCE_BADGE_LABELS={"storage-async":"STORAGE","storage-mmkv":"MMKV",redux:"REDUX",network:"NET","react-query":"QUERY","react-query-query":"QUERY","react-query-mutation":"MUTATION",route:"ROUTE",zustand:"ZUSTAND",jotai:"JOTAI",render:"RENDER",capacitor:"CAPACITOR",three:"SCENE",socket:"SOCKET"};function SourceBadgeWrapper({source:t,testID:e,children:o}){const n=SOURCE_CONFIG[t].color;const s=SOURCE_BADGE_LABELS[t];return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.badgeWrapper,testID:e,children:[o,(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.sourceBadge,{backgroundColor:`${n}20`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.sourceBadgeText,{color:n}],testID:e?`${e}-badge`:void 0,children:s})})]})}const UnifiedEventItem=exports.UnifiedEventItem=(0,_react.memo)(function t({event:e,onPress:o,isSelected:n=false,isExpanded:s=false,onNavigate:C,correlationCount:l=1,correlationLabel:u,correlationColor:c}){const{StorageEventCard:i,getValueType:d,ReduxActionItem:g,NetworkEventItemCompact:m,RouteEventItemCompact:E,ZustandStateChangeItem:p,JotaiAtomChangeItem:y}=getOptionalComponents();const x=SOURCE_CONFIG[e.source];const I=getStatusColor(e.status);const a=(0,_testIDs.eventRowTestID)(e);if(isStorageEvent(e.source)&&i&&d){const r=e.originalEvent;const h={key:r.data?.key||"unknown",lastAction:r.action,totalOperations:1,lastEventTimestamp:new Date(e.timestamp),storageTypes:new Set([r.storageType||"async"]),valueType:r.data?.value!==void 0?d(r.data.value):void 0};return(0,_jsxRuntime.jsx)(SourceBadgeWrapper,{source:e.source,testID:a,children:(0,_jsxRuntime.jsx)(i,{data:h,onPress:o,isSelected:n})})}if(e.source==="redux"&&g){const r=e.originalEvent;return(0,_jsxRuntime.jsx)(SourceBadgeWrapper,{source:e.source,testID:a,children:(0,_jsxRuntime.jsx)(g,{action:r,onPress:()=>o()})})}if(e.source==="network"&&m){const r=e.originalEvent;return(0,_jsxRuntime.jsx)(_reactNative.View,{testID:a,children:(0,_jsxRuntime.jsx)(m,{event:r,onPress:()=>o()})})}if(e.source==="route"&&E){const r=e.originalEvent;return(0,_jsxRuntime.jsx)(SourceBadgeWrapper,{source:e.source,testID:a,children:(0,_jsxRuntime.jsx)(E,{event:r,visitNumber:0,isExpanded:s,onPress:()=>o(),onNavigate:C})})}if(e.source==="zustand"&&p){return(0,_jsxRuntime.jsx)(SourceBadgeWrapper,{source:e.source,testID:a,children:(0,_jsxRuntime.jsx)(p,{change:e.originalEvent,onPress:()=>o()})})}if(e.source==="jotai"&&y){return(0,_jsxRuntime.jsx)(SourceBadgeWrapper,{source:e.source,testID:a,children:(0,_jsxRuntime.jsx)(y,{change:e.originalEvent,onPress:()=>o()})})}const b=u&&c?(0,_jsxRuntime.jsx)(CorrelationBadge,{label:u,color:c,testID:`${a}-correlation`}):null;return(0,_jsxRuntime.jsx)(_sharedUi.CompactRow,{statusDotColor:x.color,statusLabel:x.label,primaryText:e.title,secondaryText:e.subtitle,badgeText:l>1&&!u?`${l}`:"",badgeColor:c||I,customBadge:b,bottomRightText:(0,_sharedUi.formatRelativeTime)(new Date(e.timestamp)),showChevron:true,isSelected:n,onPress:o,testID:a})});const styles=_reactNative.StyleSheet.create({badgeWrapper:{position:"relative"},sourceBadge:{position:"absolute",top:4,right:12,paddingHorizontal:6,paddingVertical:2,borderRadius:4,zIndex:10},sourceBadgeText:{fontSize:8,fontWeight:"700",letterSpacing:.5}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.useUnifiedEvents=useUnifiedEvents;var _react=require("react");var _sharedUi=require("@buoy-gg/shared-ui");var _unifiedEventStore=require("../stores/unifiedEventStore");var _badgeSelectionStorage=require("../utils/badgeSelectionStorage");var _autoDiscoverEventSources=require("../utils/autoDiscoverEventSources");var _eventVisibility=require("../utils/eventVisibility");function matchesSearch(i,S){if(i.title.toLowerCase().includes(S))return true;if(i.subtitle.toLowerCase().includes(S))return true;const l=i.originalEvent?.url;return typeof l==="string"&&l.toLowerCase().includes(S)}const ALL_DISPLAY_SOURCES=["storage-async","redux","network","react-query-query","react-query-mutation","route","zustand","jotai","render","capacitor"];const DEFAULT_ENABLED_SOURCES=ALL_DISPLAY_SOURCES.filter(i=>i!=="render");const SOURCE_TO_EVENT_SOURCES={"storage-async":["storage-async","storage-mmkv"],"storage-mmkv":["storage-mmkv"],redux:["redux"],network:["network"],"react-query":["react-query","react-query-query"],"react-query-query":["react-query","react-query-query"],"react-query-mutation":["react-query-mutation"],route:["route"],zustand:["zustand"],jotai:["jotai"],render:["render"],capacitor:["capacitor"],three:["three"]};function useUnifiedEvents(i){const{isPro:S}=(0,_sharedUi.useFeatureGate)();const l=(0,_sharedUi.useLimit)("events.entries");const{patterns:_}=(0,_sharedUi.useIgnoredPatterns)();const[y,P]=(0,_react.useState)([]);const[o,m]=(0,_react.useState)(()=>new Set(DEFAULT_ENABLED_SOURCES));const[f,g]=(0,_react.useState)(true);const[L,R]=(0,_react.useState)("");const E=(0,_react.useRef)(false);const x=i?.capturingOverride??f;const a=(0,_react.useRef)(null);const p=(0,_react.useRef)([]);const[z,w]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{if(x){if(a.current!==null){p.current=[...p.current,[a.current,Date.now()]];a.current=null;w(e=>e+1);(0,_badgeSelectionStorage.savePausedAt)(null)}}else if(a.current===null){a.current=Date.now();w(e=>e+1);(0,_badgeSelectionStorage.savePausedAt)(a.current)}},[x]);const D=(0,_react.useCallback)(e=>{const s=a.current;if(s!==null&&e>s)return true;for(const[r,u]of p.current){if(e>r&&e<=u)return true}return false},[]);const[h,M]=(0,_react.useState)(()=>(0,_unifiedEventStore.getAvailableEventSources)());const[T,U]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{return(0,_sharedUi.subscribeToSubscriberCountChanges)(()=>{U(e=>e+1)})},[]);const d=(0,_react.useMemo)(()=>{return ALL_DISPLAY_SOURCES.filter(e=>{const s=SOURCE_TO_EVENT_SOURCES[e]||[e];return s.some(r=>h.has(r))})},[h]);(0,_react.useEffect)(()=>{let e=null;const s=(0,_unifiedEventStore.subscribe)(()=>{if(e!=null)return;e=requestAnimationFrame(()=>{e=null;r()})});const r=()=>{const u=(0,_unifiedEventStore.getEvents)();P(u);M(c=>{const t=(0,_unifiedEventStore.getAvailableEventSources)();if(c.size===t.size&&[...t].every(n=>c.has(n))){return c}return new Set(t)})};return()=>{s();if(e!=null)cancelAnimationFrame(e)}},[]);(0,_react.useEffect)(()=>{const e=async()=>{const s=await(0,_badgeSelectionStorage.loadEnabledSources)();let r;const u=d.filter(n=>DEFAULT_ENABLED_SOURCES.includes(n));if(s&&s.length>0){const n=s.filter(v=>d.includes(v));if(n.length>0){r=new Set(n)}else{r=new Set(u)}}else{r=new Set(u)}m(r);const c=await(0,_badgeSelectionStorage.loadCapturingState)();const t=c!==null?c:true;if(!t&&a.current===null){const n=await(0,_badgeSelectionStorage.loadPausedAt)();a.current=n??Date.now();w(v=>v+1)}g(t);E.current=true;void(0,_unifiedEventStore.setLocalEnabledSources)(t?Array.from(r):[])};e()},[d]);(0,_react.useEffect)(()=>{if(!E.current){return}void(0,_unifiedEventStore.setLocalEnabledSources)(f?Array.from(o):[])},[o,f]);(0,_react.useEffect)(()=>{if(!E.current){return}(0,_badgeSelectionStorage.saveEnabledSources)(Array.from(o))},[o]);(0,_react.useEffect)(()=>{if(!E.current){return}(0,_badgeSelectionStorage.saveCapturingState)(f)},[f]);const q=(0,_react.useMemo)(()=>{const e=new Set;o.forEach(s=>{const r=SOURCE_TO_EVENT_SOURCES[s];if(r){r.forEach(u=>e.add(u))}});return e},[o]);const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.useUnifiedEvents=useUnifiedEvents;var _react=require("react");var _sharedUi=require("@buoy-gg/shared-ui");var _unifiedEventStore=require("../stores/unifiedEventStore");var _badgeSelectionStorage=require("../utils/badgeSelectionStorage");var _autoDiscoverEventSources=require("../utils/autoDiscoverEventSources");var _eventVisibility=require("../utils/eventVisibility");function matchesSearch(i,S){if(i.title.toLowerCase().includes(S))return true;if(i.subtitle.toLowerCase().includes(S))return true;const l=i.originalEvent?.url;return typeof l==="string"&&l.toLowerCase().includes(S)}const ALL_DISPLAY_SOURCES=["storage-async","redux","network","react-query-query","react-query-mutation","route","zustand","jotai","render","capacitor"];const DEFAULT_ENABLED_SOURCES=ALL_DISPLAY_SOURCES.filter(i=>i!=="render");const SOURCE_TO_EVENT_SOURCES={"storage-async":["storage-async","storage-mmkv"],"storage-mmkv":["storage-mmkv"],redux:["redux"],network:["network"],"react-query":["react-query","react-query-query"],"react-query-query":["react-query","react-query-query"],"react-query-mutation":["react-query-mutation"],route:["route"],zustand:["zustand"],jotai:["jotai"],render:["render"],capacitor:["capacitor"],three:["three"],socket:["socket"]};function useUnifiedEvents(i){const{isPro:S}=(0,_sharedUi.useFeatureGate)();const l=(0,_sharedUi.useLimit)("events.entries");const{patterns:_}=(0,_sharedUi.useIgnoredPatterns)();const[y,P]=(0,_react.useState)([]);const[o,m]=(0,_react.useState)(()=>new Set(DEFAULT_ENABLED_SOURCES));const[f,g]=(0,_react.useState)(true);const[L,R]=(0,_react.useState)("");const E=(0,_react.useRef)(false);const x=i?.capturingOverride??f;const a=(0,_react.useRef)(null);const p=(0,_react.useRef)([]);const[z,w]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{if(x){if(a.current!==null){p.current=[...p.current,[a.current,Date.now()]];a.current=null;w(e=>e+1);(0,_badgeSelectionStorage.savePausedAt)(null)}}else if(a.current===null){a.current=Date.now();w(e=>e+1);(0,_badgeSelectionStorage.savePausedAt)(a.current)}},[x]);const D=(0,_react.useCallback)(e=>{const s=a.current;if(s!==null&&e>s)return true;for(const[r,u]of p.current){if(e>r&&e<=u)return true}return false},[]);const[h,M]=(0,_react.useState)(()=>(0,_unifiedEventStore.getAvailableEventSources)());const[T,U]=(0,_react.useState)(0);(0,_react.useEffect)(()=>{return(0,_sharedUi.subscribeToSubscriberCountChanges)(()=>{U(e=>e+1)})},[]);const d=(0,_react.useMemo)(()=>{return ALL_DISPLAY_SOURCES.filter(e=>{const s=SOURCE_TO_EVENT_SOURCES[e]||[e];return s.some(r=>h.has(r))})},[h]);(0,_react.useEffect)(()=>{let e=null;const s=(0,_unifiedEventStore.subscribe)(()=>{if(e!=null)return;e=requestAnimationFrame(()=>{e=null;r()})});const r=()=>{const u=(0,_unifiedEventStore.getEvents)();P(u);M(c=>{const t=(0,_unifiedEventStore.getAvailableEventSources)();if(c.size===t.size&&[...t].every(n=>c.has(n))){return c}return new Set(t)})};return()=>{s();if(e!=null)cancelAnimationFrame(e)}},[]);(0,_react.useEffect)(()=>{const e=async()=>{const s=await(0,_badgeSelectionStorage.loadEnabledSources)();let r;const u=d.filter(n=>DEFAULT_ENABLED_SOURCES.includes(n));if(s&&s.length>0){const n=s.filter(v=>d.includes(v));if(n.length>0){r=new Set(n)}else{r=new Set(u)}}else{r=new Set(u)}m(r);const c=await(0,_badgeSelectionStorage.loadCapturingState)();const t=c!==null?c:true;if(!t&&a.current===null){const n=await(0,_badgeSelectionStorage.loadPausedAt)();a.current=n??Date.now();w(v=>v+1)}g(t);E.current=true;void(0,_unifiedEventStore.setLocalEnabledSources)(t?Array.from(r):[])};e()},[d]);(0,_react.useEffect)(()=>{if(!E.current){return}void(0,_unifiedEventStore.setLocalEnabledSources)(f?Array.from(o):[])},[o,f]);(0,_react.useEffect)(()=>{if(!E.current){return}(0,_badgeSelectionStorage.saveEnabledSources)(Array.from(o))},[o]);(0,_react.useEffect)(()=>{if(!E.current){return}(0,_badgeSelectionStorage.saveCapturingState)(f)},[f]);const q=(0,_react.useMemo)(()=>{const e=new Set;o.forEach(s=>{const r=SOURCE_TO_EVENT_SOURCES[s];if(r){r.forEach(u=>e.add(u))}});return e},[o]);const k=L.trim().toLowerCase();const b=(0,_react.useMemo)(()=>y.filter(e=>!D(e.timestamp)&&!(0,_eventVisibility.isBuoyInternalEvent)(e)&&!(0,_eventVisibility.isNetworkEventIgnored)(e,_)),[y,_,D,z]);const C=(0,_react.useMemo)(()=>{if(q.size===0){return[]}return b.filter(e=>q.has(e.source)&&(k===""||matchesSearch(e,k)))},[b,q,k]);const I=(0,_react.useMemo)(()=>C.slice(0,l),[C,l]);const O=(0,_react.useMemo)(()=>Math.max(0,C.length-l),[C,l]);const V=(0,_react.useMemo)(()=>{const e=b.reduce((t,n)=>{t[n.source]=(t[n.source]??0)+1;return t},{});const s=(0,_unifiedEventStore.getSubscriberCounts)();const r={};for(const t of s.sources){r[t.sourceId]=t.counts.total}const u={"storage-async":"storage","storage-mmkv":"storage",redux:"redux",network:"network","react-query":"react-query","react-query-query":"react-query","react-query-mutation":"react-query",route:"route-events",zustand:"zustand",jotai:"jotai",render:"render",capacitor:"capacitor",three:"three",socket:"socket"};const c=d.map(t=>{const n=SOURCE_TO_EVENT_SOURCES[t]||[t];const v=n.reduce((K,Q)=>K+(e[Q]||0),0);const H=(0,_autoDiscoverEventSources.getSourceDisplayConfig)(t);const A=u[t];const J=A&&A in r?r[A]:void 0;return{source:t,...H,count:v,enabled:o.has(t),subscriberCount:J}});return c.sort((t,n)=>{if(t.enabled&&!n.enabled)return-1;if(!t.enabled&&n.enabled)return 1;return 0})},[b,o,d,T]);const j=(0,_react.useCallback)(e=>{m(s=>{const r=new Set(s);if(r.has(e)){r.delete(e)}else{r.add(e)}return r})},[]);const F=(0,_react.useCallback)(()=>{m(new Set(d))},[d]);const B=(0,_react.useCallback)(()=>{(0,_unifiedEventStore.clearEvents)()},[]);const N=(0,_react.useCallback)(()=>{g(true)},[]);const G=(0,_react.useCallback)(()=>{g(false)},[]);const W=(0,_react.useCallback)(()=>{g(e=>!e)},[]);const Y=(0,_unifiedEventStore.getSubscriberCounts)().totalSubscribers;return{events:y,filteredEvents:I,availableSources:V,enabledSources:o,searchText:L,setSearchText:R,toggleSource:j,enableAllSources:F,clearEvents:B,totalCount:b.length,filteredCount:I.length,isCapturing:f,startCapturing:N,stopCapturing:G,toggleCapturing:W,discoveredSources:h,hiddenEventsCount:O,isPro:S,totalSubscriberCount:Y}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.EVENT_SOURCE_TO_DISCOVERY_ID=void 0;const EVENT_SOURCE_TO_DISCOVERY_ID=exports.EVENT_SOURCE_TO_DISCOVERY_ID={"storage-async":"storage","storage-mmkv":"storage",redux:"redux",network:"network","react-query":"react-query","react-query-query":"react-query","react-query-mutation":"react-query",route:"route-events",zustand:"zustand",jotai:"jotai",render:"render",capacitor:"capacitor",three:"three"};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.EVENT_SOURCE_TO_DISCOVERY_ID=void 0;const EVENT_SOURCE_TO_DISCOVERY_ID=exports.EVENT_SOURCE_TO_DISCOVERY_ID={"storage-async":"storage","storage-mmkv":"storage",redux:"redux",network:"network","react-query":"react-query","react-query-query":"react-query","react-query-mutation":"react-query",route:"route-events",zustand:"zustand",jotai:"jotai",render:"render",capacitor:"capacitor",three:"three",socket:"socket"};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.watchEvents=exports.unsubscribeFromZustand=exports.unsubscribeFromStorage=exports.unsubscribeFromRoutes=exports.unsubscribeFromRender=exports.unsubscribeFromRedux=exports.unsubscribeFromReactQuery=exports.unsubscribeFromNetwork=exports.unsubscribeFromJotai=exports.unsubscribeAll=exports.unifiedEventStore=exports.subscribeToZustand=exports.subscribeToStorage=exports.subscribeToRoutes=exports.subscribeToRender=exports.subscribeToRedux=exports.subscribeToReactQuery=exports.subscribeToNetwork=exports.subscribeToJotai=exports.subscribeToAll=exports.subscribe=exports.setLocalEnabledSources=exports.isSourceSubscribed=exports.getSubscriptionStatus=exports.getSubscriberCounts=exports.getSourceCounts=exports.getEvents=exports.getEventCount=exports.getDiscoveredSources=exports.getAvailableEventSources=exports.getActiveSources=exports.clearEvents=void 0;var _eventVisibility=require("../utils/eventVisibility");var _autoDiscoverEventSources=require("../utils/autoDiscoverEventSources");var _sharedUi=require("@buoy-gg/shared-ui");var _sourceIds=require("../sources/sourceIds");const MAX_EVENTS=200;const SUBSCRIBE_ALL_EXCLUDED_SOURCE_IDS=new Set(["render"]);class UnifiedEventStore extends _sharedUi.ChangeLog{activeSources=new Set;remoteAvailableSources=null;sourceUnsubscribers=new Map;remoteDiscoveryIds=new Set;localDiscoveryIds=new Set;localSyncChain=Promise.resolve();networkEventIdMap=new Map;constructor(){super({max:MAX_EVENTS})}getDiscoveredSources(){return(0,_autoDiscoverEventSources.getCachedDiscovery)().sources}getAvailableEventSources(){if(this.remoteAvailableSources){return this.remoteAvailableSources}return(0,_autoDiscoverEventSources.getCachedDiscovery)().availableEventSources}setRemoteAvailableSources(e){const s=e?new Set(e):null;const r=this.remoteAvailableSources;const c=r===null&&s===null||!!r&&!!s&&r.size===s.size&&[...s].every(t=>r.has(t));this.remoteAvailableSources=s;if(!c){this.notifyListeners()}}replaceEvents(e){e=e.map(_eventVisibility.appUnifiedEvent).filter(s=>s!==null);this.activeSources=new Set(e.map(s=>s.source));this.setItems(e)}async subscribeToAll(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();for(const s of e){if(SUBSCRIBE_ALL_EXCLUDED_SOURCE_IDS.has(s.id)){continue}await this.subscribeToSource(s)}}async subscribeToSource(e){const s=this.sourceUnsubscribers.get(e.id);if(s){s.refCount++;return}const r={unsubscribe:()=>{},refCount:1};this.sourceUnsubscribers.set(e.id,r);try{if(e.setup){await e.setup()}const c=await e.subscribe(t=>{this.addEvent(t)});if(c){r.unsubscribe=c}}catch{if(this.sourceUnsubscribers.get(e.id)===r&&r.refCount<=1){this.sourceUnsubscribers.delete(e.id)}}}unsubscribeFromSource(e){const s=this.sourceUnsubscribers.get(e);if(!s)return;s.refCount--;if(s.refCount<=0){s.unsubscribe();this.sourceUnsubscribers.delete(e)}}async subscribeToStorage(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const s=e.find(r=>r.id==="storage");if(s){await this.subscribeToSource(s)}}unsubscribeFromStorage(){this.unsubscribeFromSource("storage");this.activeSources.delete("storage-async");this.activeSources.delete("storage-mmkv")}subscribeToRedux(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const s=e.find(r=>r.id==="redux");if(s){this.subscribeToSource(s)}}unsubscribeFromRedux(){this.unsubscribeFromSource("redux");this.activeSources.delete("redux")}subscribeToNetwork(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const s=e.find(r=>r.id==="network");if(s){this.subscribeToSource(s)}}unsubscribeFromNetwork(){this.unsubscribeFromSource("network");this.activeSources.delete("network")}subscribeToReactQuery(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const s=e.find(r=>r.id==="react-query");if(s){this.subscribeToSource(s)}}unsubscribeFromReactQuery(){this.unsubscribeFromSource("react-query");this.activeSources.delete("react-query");this.activeSources.delete("react-query-query");this.activeSources.delete("react-query-mutation")}subscribeToRoutes(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const s=e.find(r=>r.id==="route-events");if(s){this.subscribeToSource(s)}}unsubscribeFromRoutes(){this.unsubscribeFromSource("route-events");this.activeSources.delete("route")}subscribeToZustand(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const s=e.find(r=>r.id==="zustand");if(s){this.subscribeToSource(s)}}unsubscribeFromZustand(){this.unsubscribeFromSource("zustand");this.activeSources.delete("zustand")}subscribeToJotai(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const s=e.find(r=>r.id==="jotai");if(s){this.subscribeToSource(s)}}unsubscribeFromJotai(){this.unsubscribeFromSource("jotai");this.activeSources.delete("jotai")}subscribeToRender(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const s=e.find(r=>r.id==="render");if(s){this.subscribeToSource(s)}}unsubscribeFromRender(){this.unsubscribeFromSource("render");this.activeSources.delete("render")}addEvent(e){const s=(0,_eventVisibility.appUnifiedEvent)(e);if(!s)return;e=s;if(e.source==="network"){const r=e.originalEvent;if(r?.id){const c=this.networkEventIdMap.get(r.id);if(c){const t=this.items.findIndex(o=>o.id===c);if(t>=0){e.id=c;this.items=[...this.items.slice(0,t),e,...this.items.slice(t+1)];this.notifyListeners();return}}this.networkEventIdMap.set(r.id,e.id)}}this.push(e);this.activeSources.add(e.source);this.notifyListeners()}getEvents(e){if(!e||e.size===0){return this.items}return this.items.filter(s=>e.has(s.source))}getActiveSources(){return Array.from(this.activeSources)}getSourceCounts(){const e={"storage-async":0,"storage-mmkv":0,redux:0,network:0,"react-query":0,"react-query-query":0,"react-query-mutation":0,route:0,zustand:0,jotai:0,render:0,capacitor:0,three:0};for(const s of this.items){e[s.source]++}return e}clearEvents(){this.activeSources.clear();this.networkEventIdMap.clear();this.clear()}subscribe(e){const s=super.subscribe(e);e(this.items);return s}getEventCount(){return this.items.length}unsubscribeAll(){for(const[,e]of this.sourceUnsubscribers){e.unsubscribe()}this.sourceUnsubscribers.clear();this.activeSources.clear();this.remoteDiscoveryIds.clear();this.localDiscoveryIds.clear()}watch(e,s,r=Date.now()){const c=new Set(e);const t=new Set;for(const n of e){const b=_sourceIds.EVENT_SOURCE_TO_DISCOVERY_ID[n];if(b)t.add(b)}const{sources:o}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const i=[];for(const n of t){const b=o.find(h=>h.id===n);if(!b)continue;i.push(n);void this.subscribeToSource(b)}let a=false;const d=this.subscribe(n=>{if(a)return;s(n.filter(b=>b.timestamp>=r&&c.has(b.source)))});return()=>{if(a)return;a=true;d();for(const n of i)this.unsubscribeFromSource(n)}}setLocalEnabledSources(e){const s=async()=>{const r=new Set;for(const o of e){const i=_sourceIds.EVENT_SOURCE_TO_DISCOVERY_ID[o];if(i)r.add(i)}const c=this.localDiscoveryIds;this.localDiscoveryIds=r;const{sources:t}=(0,_autoDiscoverEventSources.getCachedDiscovery)();for(const o of r){if(!c.has(o)){const i=t.find(a=>a.id===o);if(i)await this.subscribeToSource(i)}}for(const o of c){if(!r.has(o)){this.unsubscribeFromSource(o)}}};this.localSyncChain=this.localSyncChain.then(s,s);return this.localSyncChain}async setRemoteEnabledSources(e){const{sources:s}=(0,_autoDiscoverEventSources.getCachedDiscovery)();let r;if(e==="all"){r=new Set(s.map(t=>t.id).filter(t=>!SUBSCRIBE_ALL_EXCLUDED_SOURCE_IDS.has(t)))}else{r=new Set;for(const t of e){const o=_sourceIds.EVENT_SOURCE_TO_DISCOVERY_ID[t];if(o)r.add(o)}}const c=this.remoteDiscoveryIds;this.remoteDiscoveryIds=r;for(const t of r){if(!c.has(t)){const o=s.find(i=>i.id===t);if(o)await this.subscribeToSource(o)}}for(const t of c){if(!r.has(t)){this.unsubscribeFromSource(t)}}}ensureRemoteSourcesDefault(){if(this.remoteDiscoveryIds.size===0){void this.setRemoteEnabledSources("all")}}clearRemoteSources(){for(const e of this.remoteDiscoveryIds){this.unsubscribeFromSource(e)}this.remoteDiscoveryIds.clear()}isSourceSubscribed(e){switch(e){case"storage-async":case"storage-mmkv":return this.sourceUnsubscribers.has("storage");case"redux":return this.sourceUnsubscribers.has("redux");case"network":return this.sourceUnsubscribers.has("network");case"react-query":case"react-query-query":case"react-query-mutation":return this.sourceUnsubscribers.has("react-query");case"route":return this.sourceUnsubscribers.has("route-events");case"zustand":return this.sourceUnsubscribers.has("zustand");case"jotai":return this.sourceUnsubscribers.has("jotai");case"render":return this.sourceUnsubscribers.has("render");case"three":return this.sourceUnsubscribers.has("three");case"capacitor":return this.sourceUnsubscribers.has("capacitor");default:return false}}getSubscriptionStatus(){return{"storage-async":this.sourceUnsubscribers.has("storage"),"storage-mmkv":this.sourceUnsubscribers.has("storage"),redux:this.sourceUnsubscribers.has("redux"),network:this.sourceUnsubscribers.has("network"),"react-query":this.sourceUnsubscribers.has("react-query"),"react-query-query":this.sourceUnsubscribers.has("react-query"),"react-query-mutation":this.sourceUnsubscribers.has("react-query"),route:this.sourceUnsubscribers.has("route-events"),zustand:this.sourceUnsubscribers.has("zustand"),jotai:this.sourceUnsubscribers.has("jotai"),render:this.sourceUnsubscribers.has("render"),capacitor:this.sourceUnsubscribers.has("capacitor"),three:this.sourceUnsubscribers.has("three")}}getSubscriberCounts(){return(0,_autoDiscoverEventSources.getAggregatedSubscriberCounts)()}}const unifiedEventStore=exports.unifiedEventStore=new UnifiedEventStore;const subscribeToStorage=()=>unifiedEventStore.subscribeToStorage();exports.subscribeToStorage=subscribeToStorage;const unsubscribeFromStorage=()=>unifiedEventStore.unsubscribeFromStorage();exports.unsubscribeFromStorage=unsubscribeFromStorage;const subscribeToRedux=()=>unifiedEventStore.subscribeToRedux();exports.subscribeToRedux=subscribeToRedux;const unsubscribeFromRedux=()=>unifiedEventStore.unsubscribeFromRedux();exports.unsubscribeFromRedux=unsubscribeFromRedux;const subscribeToNetwork=()=>unifiedEventStore.subscribeToNetwork();exports.subscribeToNetwork=subscribeToNetwork;const unsubscribeFromNetwork=()=>unifiedEventStore.unsubscribeFromNetwork();exports.unsubscribeFromNetwork=unsubscribeFromNetwork;const subscribeToReactQuery=()=>unifiedEventStore.subscribeToReactQuery();exports.subscribeToReactQuery=subscribeToReactQuery;const unsubscribeFromReactQuery=()=>unifiedEventStore.unsubscribeFromReactQuery();exports.unsubscribeFromReactQuery=unsubscribeFromReactQuery;const subscribeToRoutes=()=>unifiedEventStore.subscribeToRoutes();exports.subscribeToRoutes=subscribeToRoutes;const unsubscribeFromRoutes=()=>unifiedEventStore.unsubscribeFromRoutes();exports.unsubscribeFromRoutes=unsubscribeFromRoutes;const subscribeToZustand=()=>unifiedEventStore.subscribeToZustand();exports.subscribeToZustand=subscribeToZustand;const unsubscribeFromZustand=()=>unifiedEventStore.unsubscribeFromZustand();exports.unsubscribeFromZustand=unsubscribeFromZustand;const subscribeToJotai=()=>unifiedEventStore.subscribeToJotai();exports.subscribeToJotai=subscribeToJotai;const unsubscribeFromJotai=()=>unifiedEventStore.unsubscribeFromJotai();exports.unsubscribeFromJotai=unsubscribeFromJotai;const subscribeToRender=()=>unifiedEventStore.subscribeToRender();exports.subscribeToRender=subscribeToRender;const unsubscribeFromRender=()=>unifiedEventStore.unsubscribeFromRender();exports.unsubscribeFromRender=unsubscribeFromRender;const getEvents=u=>unifiedEventStore.getEvents(u);exports.getEvents=getEvents;const getActiveSources=()=>unifiedEventStore.getActiveSources();exports.getActiveSources=getActiveSources;const getSourceCounts=()=>unifiedEventStore.getSourceCounts();exports.getSourceCounts=getSourceCounts;const clearEvents=()=>unifiedEventStore.clearEvents();exports.clearEvents=clearEvents;const subscribe=u=>unifiedEventStore.subscribe(u);exports.subscribe=subscribe;const getEventCount=()=>unifiedEventStore.getEventCount();exports.getEventCount=getEventCount;const isSourceSubscribed=u=>unifiedEventStore.isSourceSubscribed(u);exports.isSourceSubscribed=isSourceSubscribed;const getSubscriptionStatus=()=>unifiedEventStore.getSubscriptionStatus();exports.getSubscriptionStatus=getSubscriptionStatus;const unsubscribeAll=()=>unifiedEventStore.unsubscribeAll();exports.unsubscribeAll=unsubscribeAll;const setLocalEnabledSources=u=>unifiedEventStore.setLocalEnabledSources(u);exports.setLocalEnabledSources=setLocalEnabledSources;const getDiscoveredSources=()=>unifiedEventStore.getDiscoveredSources();exports.getDiscoveredSources=getDiscoveredSources;const getAvailableEventSources=()=>unifiedEventStore.getAvailableEventSources();exports.getAvailableEventSources=getAvailableEventSources;const subscribeToAll=()=>unifiedEventStore.subscribeToAll();exports.subscribeToAll=subscribeToAll;const watchEvents=(u,e,s)=>unifiedEventStore.watch(u,e,s);exports.watchEvents=watchEvents;const getSubscriberCounts=()=>unifiedEventStore.getSubscriberCounts();exports.getSubscriberCounts=getSubscriberCounts;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.watchEvents=exports.unsubscribeFromZustand=exports.unsubscribeFromStorage=exports.unsubscribeFromRoutes=exports.unsubscribeFromRender=exports.unsubscribeFromRedux=exports.unsubscribeFromReactQuery=exports.unsubscribeFromNetwork=exports.unsubscribeFromJotai=exports.unsubscribeAll=exports.unifiedEventStore=exports.subscribeToZustand=exports.subscribeToStorage=exports.subscribeToRoutes=exports.subscribeToRender=exports.subscribeToRedux=exports.subscribeToReactQuery=exports.subscribeToNetwork=exports.subscribeToJotai=exports.subscribeToAll=exports.subscribe=exports.setLocalEnabledSources=exports.isSourceSubscribed=exports.getSubscriptionStatus=exports.getSubscriberCounts=exports.getSourceCounts=exports.getEvents=exports.getEventCount=exports.getDiscoveredSources=exports.getAvailableEventSources=exports.getActiveSources=exports.clearEvents=void 0;var _eventVisibility=require("../utils/eventVisibility");var _autoDiscoverEventSources=require("../utils/autoDiscoverEventSources");var _sharedUi=require("@buoy-gg/shared-ui");var _sourceIds=require("../sources/sourceIds");const MAX_EVENTS=200;const SUBSCRIBE_ALL_EXCLUDED_SOURCE_IDS=new Set(["render"]);class UnifiedEventStore extends _sharedUi.ChangeLog{activeSources=new Set;remoteAvailableSources=null;sourceUnsubscribers=new Map;remoteDiscoveryIds=new Set;localDiscoveryIds=new Set;localSyncChain=Promise.resolve();networkEventIdMap=new Map;constructor(){super({max:MAX_EVENTS})}getDiscoveredSources(){return(0,_autoDiscoverEventSources.getCachedDiscovery)().sources}getAvailableEventSources(){if(this.remoteAvailableSources){return this.remoteAvailableSources}return(0,_autoDiscoverEventSources.getCachedDiscovery)().availableEventSources}setRemoteAvailableSources(e){const s=e?new Set(e):null;const r=this.remoteAvailableSources;const c=r===null&&s===null||!!r&&!!s&&r.size===s.size&&[...s].every(t=>r.has(t));this.remoteAvailableSources=s;if(!c){this.notifyListeners()}}replaceEvents(e){e=e.map(_eventVisibility.appUnifiedEvent).filter(s=>s!==null);this.activeSources=new Set(e.map(s=>s.source));this.setItems(e)}async subscribeToAll(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();for(const s of e){if(SUBSCRIBE_ALL_EXCLUDED_SOURCE_IDS.has(s.id)){continue}await this.subscribeToSource(s)}}async subscribeToSource(e){const s=this.sourceUnsubscribers.get(e.id);if(s){s.refCount++;return}const r={unsubscribe:()=>{},refCount:1};this.sourceUnsubscribers.set(e.id,r);try{if(e.setup){await e.setup()}const c=await e.subscribe(t=>{this.addEvent(t)});if(c){r.unsubscribe=c}}catch{if(this.sourceUnsubscribers.get(e.id)===r&&r.refCount<=1){this.sourceUnsubscribers.delete(e.id)}}}unsubscribeFromSource(e){const s=this.sourceUnsubscribers.get(e);if(!s)return;s.refCount--;if(s.refCount<=0){s.unsubscribe();this.sourceUnsubscribers.delete(e)}}async subscribeToStorage(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const s=e.find(r=>r.id==="storage");if(s){await this.subscribeToSource(s)}}unsubscribeFromStorage(){this.unsubscribeFromSource("storage");this.activeSources.delete("storage-async");this.activeSources.delete("storage-mmkv")}subscribeToRedux(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const s=e.find(r=>r.id==="redux");if(s){this.subscribeToSource(s)}}unsubscribeFromRedux(){this.unsubscribeFromSource("redux");this.activeSources.delete("redux")}subscribeToNetwork(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const s=e.find(r=>r.id==="network");if(s){this.subscribeToSource(s)}}unsubscribeFromNetwork(){this.unsubscribeFromSource("network");this.activeSources.delete("network")}subscribeToReactQuery(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const s=e.find(r=>r.id==="react-query");if(s){this.subscribeToSource(s)}}unsubscribeFromReactQuery(){this.unsubscribeFromSource("react-query");this.activeSources.delete("react-query");this.activeSources.delete("react-query-query");this.activeSources.delete("react-query-mutation")}subscribeToRoutes(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const s=e.find(r=>r.id==="route-events");if(s){this.subscribeToSource(s)}}unsubscribeFromRoutes(){this.unsubscribeFromSource("route-events");this.activeSources.delete("route")}subscribeToZustand(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const s=e.find(r=>r.id==="zustand");if(s){this.subscribeToSource(s)}}unsubscribeFromZustand(){this.unsubscribeFromSource("zustand");this.activeSources.delete("zustand")}subscribeToJotai(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const s=e.find(r=>r.id==="jotai");if(s){this.subscribeToSource(s)}}unsubscribeFromJotai(){this.unsubscribeFromSource("jotai");this.activeSources.delete("jotai")}subscribeToRender(){const{sources:e}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const s=e.find(r=>r.id==="render");if(s){this.subscribeToSource(s)}}unsubscribeFromRender(){this.unsubscribeFromSource("render");this.activeSources.delete("render")}addEvent(e){const s=(0,_eventVisibility.appUnifiedEvent)(e);if(!s)return;e=s;if(e.source==="network"){const r=e.originalEvent;if(r?.id){const c=this.networkEventIdMap.get(r.id);if(c){const t=this.items.findIndex(o=>o.id===c);if(t>=0){e.id=c;this.items=[...this.items.slice(0,t),e,...this.items.slice(t+1)];this.notifyListeners();return}}this.networkEventIdMap.set(r.id,e.id)}}this.push(e);this.activeSources.add(e.source);this.notifyListeners()}getEvents(e){if(!e||e.size===0){return this.items}return this.items.filter(s=>e.has(s.source))}getActiveSources(){return Array.from(this.activeSources)}getSourceCounts(){const e={"storage-async":0,"storage-mmkv":0,redux:0,network:0,"react-query":0,"react-query-query":0,"react-query-mutation":0,route:0,zustand:0,jotai:0,render:0,capacitor:0,three:0,socket:0};for(const s of this.items){e[s.source]++}return e}clearEvents(){this.activeSources.clear();this.networkEventIdMap.clear();this.clear()}subscribe(e){const s=super.subscribe(e);e(this.items);return s}getEventCount(){return this.items.length}unsubscribeAll(){for(const[,e]of this.sourceUnsubscribers){e.unsubscribe()}this.sourceUnsubscribers.clear();this.activeSources.clear();this.remoteDiscoveryIds.clear();this.localDiscoveryIds.clear()}watch(e,s,r=Date.now()){const c=new Set(e);const t=new Set;for(const n of e){const b=_sourceIds.EVENT_SOURCE_TO_DISCOVERY_ID[n];if(b)t.add(b)}const{sources:o}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const i=[];for(const n of t){const b=o.find(h=>h.id===n);if(!b)continue;i.push(n);void this.subscribeToSource(b)}let a=false;const d=this.subscribe(n=>{if(a)return;s(n.filter(b=>b.timestamp>=r&&c.has(b.source)))});return()=>{if(a)return;a=true;d();for(const n of i)this.unsubscribeFromSource(n)}}setLocalEnabledSources(e){const s=async()=>{const r=new Set;for(const o of e){const i=_sourceIds.EVENT_SOURCE_TO_DISCOVERY_ID[o];if(i)r.add(i)}const c=this.localDiscoveryIds;this.localDiscoveryIds=r;const{sources:t}=(0,_autoDiscoverEventSources.getCachedDiscovery)();for(const o of r){if(!c.has(o)){const i=t.find(a=>a.id===o);if(i)await this.subscribeToSource(i)}}for(const o of c){if(!r.has(o)){this.unsubscribeFromSource(o)}}};this.localSyncChain=this.localSyncChain.then(s,s);return this.localSyncChain}async setRemoteEnabledSources(e){const{sources:s}=(0,_autoDiscoverEventSources.getCachedDiscovery)();let r;if(e==="all"){r=new Set(s.map(t=>t.id).filter(t=>!SUBSCRIBE_ALL_EXCLUDED_SOURCE_IDS.has(t)))}else{r=new Set;for(const t of e){const o=_sourceIds.EVENT_SOURCE_TO_DISCOVERY_ID[t];if(o)r.add(o)}}const c=this.remoteDiscoveryIds;this.remoteDiscoveryIds=r;for(const t of r){if(!c.has(t)){const o=s.find(i=>i.id===t);if(o)await this.subscribeToSource(o)}}for(const t of c){if(!r.has(t)){this.unsubscribeFromSource(t)}}}ensureRemoteSourcesDefault(){if(this.remoteDiscoveryIds.size===0){void this.setRemoteEnabledSources("all")}}clearRemoteSources(){for(const e of this.remoteDiscoveryIds){this.unsubscribeFromSource(e)}this.remoteDiscoveryIds.clear()}isSourceSubscribed(e){switch(e){case"storage-async":case"storage-mmkv":return this.sourceUnsubscribers.has("storage");case"redux":return this.sourceUnsubscribers.has("redux");case"network":return this.sourceUnsubscribers.has("network");case"react-query":case"react-query-query":case"react-query-mutation":return this.sourceUnsubscribers.has("react-query");case"route":return this.sourceUnsubscribers.has("route-events");case"zustand":return this.sourceUnsubscribers.has("zustand");case"jotai":return this.sourceUnsubscribers.has("jotai");case"render":return this.sourceUnsubscribers.has("render");case"three":return this.sourceUnsubscribers.has("three");case"socket":return this.sourceUnsubscribers.has("socket");case"capacitor":return this.sourceUnsubscribers.has("capacitor");default:return false}}getSubscriptionStatus(){return{"storage-async":this.sourceUnsubscribers.has("storage"),"storage-mmkv":this.sourceUnsubscribers.has("storage"),redux:this.sourceUnsubscribers.has("redux"),network:this.sourceUnsubscribers.has("network"),"react-query":this.sourceUnsubscribers.has("react-query"),"react-query-query":this.sourceUnsubscribers.has("react-query"),"react-query-mutation":this.sourceUnsubscribers.has("react-query"),route:this.sourceUnsubscribers.has("route-events"),zustand:this.sourceUnsubscribers.has("zustand"),jotai:this.sourceUnsubscribers.has("jotai"),render:this.sourceUnsubscribers.has("render"),capacitor:this.sourceUnsubscribers.has("capacitor"),three:this.sourceUnsubscribers.has("three"),socket:this.sourceUnsubscribers.has("socket")}}getSubscriberCounts(){return(0,_autoDiscoverEventSources.getAggregatedSubscriberCounts)()}}const unifiedEventStore=exports.unifiedEventStore=new UnifiedEventStore;const subscribeToStorage=()=>unifiedEventStore.subscribeToStorage();exports.subscribeToStorage=subscribeToStorage;const unsubscribeFromStorage=()=>unifiedEventStore.unsubscribeFromStorage();exports.unsubscribeFromStorage=unsubscribeFromStorage;const subscribeToRedux=()=>unifiedEventStore.subscribeToRedux();exports.subscribeToRedux=subscribeToRedux;const unsubscribeFromRedux=()=>unifiedEventStore.unsubscribeFromRedux();exports.unsubscribeFromRedux=unsubscribeFromRedux;const subscribeToNetwork=()=>unifiedEventStore.subscribeToNetwork();exports.subscribeToNetwork=subscribeToNetwork;const unsubscribeFromNetwork=()=>unifiedEventStore.unsubscribeFromNetwork();exports.unsubscribeFromNetwork=unsubscribeFromNetwork;const subscribeToReactQuery=()=>unifiedEventStore.subscribeToReactQuery();exports.subscribeToReactQuery=subscribeToReactQuery;const unsubscribeFromReactQuery=()=>unifiedEventStore.unsubscribeFromReactQuery();exports.unsubscribeFromReactQuery=unsubscribeFromReactQuery;const subscribeToRoutes=()=>unifiedEventStore.subscribeToRoutes();exports.subscribeToRoutes=subscribeToRoutes;const unsubscribeFromRoutes=()=>unifiedEventStore.unsubscribeFromRoutes();exports.unsubscribeFromRoutes=unsubscribeFromRoutes;const subscribeToZustand=()=>unifiedEventStore.subscribeToZustand();exports.subscribeToZustand=subscribeToZustand;const unsubscribeFromZustand=()=>unifiedEventStore.unsubscribeFromZustand();exports.unsubscribeFromZustand=unsubscribeFromZustand;const subscribeToJotai=()=>unifiedEventStore.subscribeToJotai();exports.subscribeToJotai=subscribeToJotai;const unsubscribeFromJotai=()=>unifiedEventStore.unsubscribeFromJotai();exports.unsubscribeFromJotai=unsubscribeFromJotai;const subscribeToRender=()=>unifiedEventStore.subscribeToRender();exports.subscribeToRender=subscribeToRender;const unsubscribeFromRender=()=>unifiedEventStore.unsubscribeFromRender();exports.unsubscribeFromRender=unsubscribeFromRender;const getEvents=u=>unifiedEventStore.getEvents(u);exports.getEvents=getEvents;const getActiveSources=()=>unifiedEventStore.getActiveSources();exports.getActiveSources=getActiveSources;const getSourceCounts=()=>unifiedEventStore.getSourceCounts();exports.getSourceCounts=getSourceCounts;const clearEvents=()=>unifiedEventStore.clearEvents();exports.clearEvents=clearEvents;const subscribe=u=>unifiedEventStore.subscribe(u);exports.subscribe=subscribe;const getEventCount=()=>unifiedEventStore.getEventCount();exports.getEventCount=getEventCount;const isSourceSubscribed=u=>unifiedEventStore.isSourceSubscribed(u);exports.isSourceSubscribed=isSourceSubscribed;const getSubscriptionStatus=()=>unifiedEventStore.getSubscriptionStatus();exports.getSubscriptionStatus=getSubscriptionStatus;const unsubscribeAll=()=>unifiedEventStore.unsubscribeAll();exports.unsubscribeAll=unsubscribeAll;const setLocalEnabledSources=u=>unifiedEventStore.setLocalEnabledSources(u);exports.setLocalEnabledSources=setLocalEnabledSources;const getDiscoveredSources=()=>unifiedEventStore.getDiscoveredSources();exports.getDiscoveredSources=getDiscoveredSources;const getAvailableEventSources=()=>unifiedEventStore.getAvailableEventSources();exports.getAvailableEventSources=getAvailableEventSources;const subscribeToAll=()=>unifiedEventStore.subscribeToAll();exports.subscribeToAll=subscribeToAll;const watchEvents=(u,e,s)=>unifiedEventStore.watch(u,e,s);exports.watchEvents=watchEvents;const getSubscriberCounts=()=>unifiedEventStore.getSubscriberCounts();exports.getSubscriberCounts=getSubscriberCounts;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.eventsSyncAdapter=void 0;var _sharedUi=require("@buoy-gg/shared-ui");var _unifiedEventStore=require("../stores/unifiedEventStore");var _eventExportFormatter=require("../utils/eventExportFormatter");var _copySettings=require("../types/copySettings");const MAX_SYNC_ORIGINAL_EVENT_BYTES=16*1024;function truncatedMarker(e,r){return{__buoyTruncated:true,approxBytes:e,note:r??`Payload (\u2265${(e/1024).toFixed(0)}KB approx) exceeds the ${MAX_SYNC_ORIGINAL_EVENT_BYTES/1024}KB sync limit and stayed on the device. Open the tool on-device (or use the source tool's detail action) for the full payload.`}}const STATE_TREE_OMITTED={__buoyOmitted:"state-tree",note:"prevState/nextState stay on the device (use get_redux_state / the on-device tool)."};const QUERY_PAYLOAD_OMITTED={__buoyOmitted:"query-payload",note:"Query/mutation data stays on the device (open the Query tool or the on-device Events detail)."};const NETWORK_BODY_OMITTED={__buoyOmitted:"network-body",note:"Request/response body stays on the device (open the Network tool or the on-device Events detail)."};const NETWORK_HEADERS_OMITTED={__buoyOmitted:"network-headers",note:"Request/response headers stay on the device (open the Network tool or the on-device Events detail)."};const GRAPHQL_VARS_OMITTED={__buoyOmitted:"graphql-variables",note:"GraphQL variables stay on the device (open the Network tool or the on-device Events detail)."};const STORAGE_VALUE_OMITTED={__buoyOmitted:"storage-value",note:"Storage value stays on the device (open the Storage tool or the on-device Events detail)."};const ROUTE_PARAMS_OMITTED={__buoyOmitted:"route-params",note:"Navigation params stay on the device (open the Routes tool or the on-device Events detail)."};function isReactQuerySource(e){return e==="react-query"||e==="react-query-query"||e==="react-query-mutation"}function omitIfHeavy(e,r){if(e===void 0)return void 0;return(0,_sharedUi.isOverWireBudget)(e,MAX_SYNC_ORIGINAL_EVENT_BYTES)?{...r}:e}function wireQueryPayload(e){return omitIfHeavy(e,QUERY_PAYLOAD_OMITTED)}function wireError(e){if(e==null)return e;if(e instanceof Error){return{name:e.name,message:e.message}}return wireQueryPayload(e)}const compactionCache=new WeakMap;function compactEventForSync(e){const r=e.originalEvent;if(typeof r!=="object"||r===null)return e;const i=compactionCache.get(e);if(i!==void 0)return i;let n=e;let t=r;if((e.source==="redux"||e.source==="zustand")&&("prevState"in t||"nextState"in t)){t={...t,prevState:{...STATE_TREE_OMITTED},nextState:{...STATE_TREE_OMITTED},...e.source==="zustand"&&"partial"in t?{partial:{...STATE_TREE_OMITTED}}:{}};n={...e,originalEvent:t}}else if(e.source==="jotai"&&("prevValue"in t||"nextValue"in t)){t={...t,prevValue:{...STATE_TREE_OMITTED},nextValue:{...STATE_TREE_OMITTED}};n={...e,originalEvent:t}}else if(e.source==="render"){const o=t.render;const s=t.event;const a=c=>{if(!c||typeof c!=="object")return c;const{hookChanges:E
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.eventsSyncAdapter=void 0;var _sharedUi=require("@buoy-gg/shared-ui");var _unifiedEventStore=require("../stores/unifiedEventStore");var _eventExportFormatter=require("../utils/eventExportFormatter");var _copySettings=require("../types/copySettings");const MAX_SYNC_ORIGINAL_EVENT_BYTES=16*1024;function truncatedMarker(e,r){return{__buoyTruncated:true,approxBytes:e,note:r??`Payload (\u2265${(e/1024).toFixed(0)}KB approx) exceeds the ${MAX_SYNC_ORIGINAL_EVENT_BYTES/1024}KB sync limit and stayed on the device. Open the tool on-device (or use the source tool's detail action) for the full payload.`}}const STATE_TREE_OMITTED={__buoyOmitted:"state-tree",note:"prevState/nextState stay on the device (use get_redux_state / the on-device tool)."};const QUERY_PAYLOAD_OMITTED={__buoyOmitted:"query-payload",note:"Query/mutation data stays on the device (open the Query tool or the on-device Events detail)."};const NETWORK_BODY_OMITTED={__buoyOmitted:"network-body",note:"Request/response body stays on the device (open the Network tool or the on-device Events detail)."};const NETWORK_HEADERS_OMITTED={__buoyOmitted:"network-headers",note:"Request/response headers stay on the device (open the Network tool or the on-device Events detail)."};const GRAPHQL_VARS_OMITTED={__buoyOmitted:"graphql-variables",note:"GraphQL variables stay on the device (open the Network tool or the on-device Events detail)."};const STORAGE_VALUE_OMITTED={__buoyOmitted:"storage-value",note:"Storage value stays on the device (open the Storage tool or the on-device Events detail)."};const ROUTE_PARAMS_OMITTED={__buoyOmitted:"route-params",note:"Navigation params stay on the device (open the Routes tool or the on-device Events detail)."};function isReactQuerySource(e){return e==="react-query"||e==="react-query-query"||e==="react-query-mutation"}function omitIfHeavy(e,r){if(e===void 0)return void 0;return(0,_sharedUi.isOverWireBudget)(e,MAX_SYNC_ORIGINAL_EVENT_BYTES)?{...r}:e}function wireQueryPayload(e){return omitIfHeavy(e,QUERY_PAYLOAD_OMITTED)}function wireError(e){if(e==null)return e;if(e instanceof Error){return{name:e.name,message:e.message}}return wireQueryPayload(e)}const compactionCache=new WeakMap;function compactEventForSync(e){const r=e.originalEvent;if(typeof r!=="object"||r===null)return e;const i=compactionCache.get(e);if(i!==void 0)return i;let n=e;let t=r;if((e.source==="redux"||e.source==="zustand")&&("prevState"in t||"nextState"in t)){t={...t,prevState:{...STATE_TREE_OMITTED},nextState:{...STATE_TREE_OMITTED},...e.source==="zustand"&&"partial"in t?{partial:{...STATE_TREE_OMITTED}}:{}};n={...e,originalEvent:t}}else if(e.source==="jotai"&&("prevValue"in t||"nextValue"in t)){t={...t,prevValue:{...STATE_TREE_OMITTED},nextValue:{...STATE_TREE_OMITTED}};n={...e,originalEvent:t}}else if(e.source==="render"){const o=t.render;const s=t.event;const a=c=>{if(!c||typeof c!=="object")return c;const{hookChanges:p,...E}=c;return E};t={...t,render:o?{...o,renderHistory:void 0,lastRenderCause:a(o.lastRenderCause)}:o,event:s?{...s,capturedProps:void 0,capturedState:void 0,cause:a(s.cause)}:s};n={...e,originalEvent:t}}else if(isReactQuerySource(e.source)){const{query:o,mutation:s,...a}=t;t={...a,queryData:wireQueryPayload(a.queryData),mutationData:wireQueryPayload(a.mutationData),mutationVariables:wireQueryPayload(a.mutationVariables),queryError:wireError(a.queryError),mutationError:wireError(a.mutationError)};n={...e,originalEvent:t}}else if(e.source==="network"){const o=typeof t.requestSize==="number"?t.requestSize:void 0;const s=typeof t.responseSize==="number"?t.responseSize:void 0;t={...t,requestData:o!==void 0&&o>MAX_SYNC_ORIGINAL_EVENT_BYTES?{...NETWORK_BODY_OMITTED}:omitIfHeavy(t.requestData,NETWORK_BODY_OMITTED),responseData:s!==void 0&&s>MAX_SYNC_ORIGINAL_EVENT_BYTES?{...NETWORK_BODY_OMITTED}:omitIfHeavy(t.responseData,NETWORK_BODY_OMITTED),graphqlVariables:omitIfHeavy(t.graphqlVariables,GRAPHQL_VARS_OMITTED),requestHeaders:omitIfHeavy(t.requestHeaders,NETWORK_HEADERS_OMITTED),responseHeaders:omitIfHeavy(t.responseHeaders,NETWORK_HEADERS_OMITTED)};n={...e,originalEvent:t}}else if(e.source==="storage-async"||e.source==="storage-mmkv"){const o=t.data;if(o){t={...t,data:{...o,value:omitIfHeavy(o.value,STORAGE_VALUE_OMITTED),prevValue:omitIfHeavy(o.prevValue,STORAGE_VALUE_OMITTED),pairs:omitIfHeavy(o.pairs,STORAGE_VALUE_OMITTED)}};n={...e,originalEvent:t}}}else if(e.source==="route"){t={...t,params:omitIfHeavy(t.params,ROUTE_PARAMS_OMITTED)};n={...e,originalEvent:t}}const{bytes:u,sawRepeat:d,sawBigInt:l}=(0,_sharedUi.approxJsonSize)(t,MAX_SYNC_ORIGINAL_EVENT_BYTES);if(u>MAX_SYNC_ORIGINAL_EVENT_BYTES){n={...e,originalEvent:truncatedMarker(u)}}else if((d||l)&&!(0,_sharedUi.isJsonSerializable)(t)){n={...e,originalEvent:truncatedMarker(-1,"Payload is not JSON-serializable (cyclic or bigint) and stayed on the device.")}}compactionCache.set(e,n);return n}const eventsSyncAdapter=exports.eventsSyncAdapter={version:2,getSnapshot:()=>({events:_unifiedEventStore.unifiedEventStore.getEvents().map(compactEventForSync),availableSources:Array.from(_unifiedEventStore.unifiedEventStore.getAvailableEventSources())}),subscribe:e=>{_unifiedEventStore.unifiedEventStore.ensureRemoteSourcesDefault();const r=_unifiedEventStore.unifiedEventStore.subscribe(()=>e());return()=>{r();_unifiedEventStore.unifiedEventStore.clearRemoteSources()}},actions:{clearEvents:()=>{_unifiedEventStore.unifiedEventStore.clearEvents()},setEnabledSources:e=>{const r=e?.sources??[];_unifiedEventStore.unifiedEventStore.setRemoteEnabledSources(r);return{enabledSources:r}},exportEvents:e=>{const r=e??{};const i=r.preset&&_copySettings.COPY_PRESETS[r.preset]?_copySettings.COPY_PRESETS[r.preset]:_copySettings.DEFAULT_COPY_SETTINGS;const n={...i,...r.settings??{}};const t=(0,_eventExportFormatter.filterEvents)(_unifiedEventStore.unifiedEventStore.getEvents(),n);const u=typeof r.limit==="number"&&r.limit>0?r.limit:t.length;const d=t.slice(0,u);return{output:(0,_eventExportFormatter.generateExport)(d,n),returned:d.length,totalAvailable:t.length,includedData:n.includeEventData,format:n.format}}}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.autoDiscoverEventSources=autoDiscoverEventSources;exports.clearDiscoveryCache=clearDiscoveryCache;exports.getAggregatedSubscriberCounts=getAggregatedSubscriberCounts;exports.getCachedDiscovery=getCachedDiscovery;exports.getSourceDisplayConfig=getSourceDisplayConfig;exports.transformCapacitorCall=transformCapacitorCall;var _utils=require("@buoy-gg/shared-ui/utils");let eventIdCounter=0;function generateEventId(t){return`${t}-${Date.now()}-${++eventIdCounter}`}function tryLoadStorageSource(){try{const{storageEventStore:t}=(0,_utils.loadToolModule)("@buoy-gg/storage");return{id:"storage",name:"Storage",eventSources:["storage-async","storage-mmkv"],available:true,subscribe:e=>{return t.onEvent(n=>{const r=n?.data;if(r?.initialScan)return;const o=transformStorageEvent(n);e(o)})}}}catch{return null}}function transformStorageEvent(t){const e=t;const n=e.storageType==="async"?"storage-async":"storage-mmkv";let r=e.action;if(e.storageType==="async"){const s={setItem:"Set Item",removeItem:"Remove Item",mergeItem:"Merge Item",clear:"Clear All",multiSet:"Multi Set",multiRemove:"Multi Remove",multiMerge:"Multi Merge"};r=s[e.action]||e.action}let o="";if(e.storageType==="async"){switch(e.action){case"setItem":case"removeItem":case"mergeItem":o=e.data?.key||"unknown key";break;case"multiSet":case"multiMerge":{const s=e.data?.pairs?.length||0;o=`${s} key${s!==1?"s":""}`;break}case"multiRemove":{const s=e.data?.keys?.length||0;o=`${s} key${s!==1?"s":""}`;break}case"clear":o="all keys";break}}else{o=e.data?.key||e.data?.instanceId||"unknown"}let a="neutral";if(e.action.includes("set")||e.action.includes("Set")||e.action.includes("merge")||e.action.includes("Merge")){a="success"}return{id:generateEventId(n),source:n,timestamp:e.timestamp.getTime(),title:r,subtitle:o,status:a,originalEvent:t}}function tryLoadReduxSource(){try{const{reduxActionStore:t}=(0,_utils.loadToolModule)("@buoy-gg/redux");let e=null;return{id:"redux",name:"Redux",eventSources:["redux"],available:true,subscribe:n=>{return t.subscribe(r=>{if(r.length>0){const o=r[0];if(o.id!==e){e=o.id;const a=transformReduxAction(o);n(a)}}})}}}catch{return null}}function transformReduxAction(t){const e=t;let n="neutral";switch(e.category){case"fulfilled":n="success";break;case"rejected":n="error";break;case"pending":n="pending";break;default:n=e.hasStateChange?"success":"neutral"}let r="";if(e.payloadPreview){r=e.payloadPreview}else if(e.hasStateChange&&e.diffSummary){r=e.diffSummary}else if(e.duration!==void 0){r=`${e.duration.toFixed(1)}ms`}else{r=e.sliceName||""}return{id:generateEventId("redux"),source:"redux",timestamp:e.timestamp,title:e.type,subtitle:r,status:n,originalEvent:t}}function tryLoadNetworkSource(){try{const{networkEventStore:t,networkListener:e,addNetworkListener:n}=(0,_utils.loadToolModule)("@buoy-gg/network");const r=new Map;return{id:"network",name:"Network",eventSources:["network"],available:true,setup:()=>{const o=e();if(!o.isActive){o.startListening()}if(o.listenerCount===0){n(a=>{t.processNetworkEvent(a)})}},subscribe:o=>{const a=Date.now();return t.onEvent(s=>{const u=s;const i=r.get(u.id);if(!i){if(typeof u.timestamp==="number"&&u.timestamp<a){return}const c=transformNetworkEvent(s);r.set(u.id,c.id);o(c)}else{const c=transformNetworkEvent(s);c.id=i;o(c)}},false)}}}catch{return null}}function transformNetworkEvent(t){const e=t;let n="neutral";if(e.status===void 0){n="pending"}else if(e.error||e.status>=400){n="error"}else if(e.status>=200&&e.status<400){n="success"}const r=e.operationName||`${e.method} ${e.path||e.url}`;const o=[];if(e.status!==void 0){o.push(`${e.status}`)}else if(e.error){o.push("Error")}else{o.push("Pending")}if(e.duration!==void 0){o.push(`${e.duration.toFixed(0)}ms`)}if(e.host){o.push(e.host)}return{id:generateEventId("network"),source:"network",timestamp:e.timestamp,title:r,subtitle:o.join(" \xB7 "),status:n,originalEvent:t}}function tryLoadReactQuerySource(){try{const{reactQueryEventStore:t}=(0,_utils.loadToolModule)("@buoy-gg/react-query");let e=null;return{id:"react-query",name:"React Query",eventSources:["react-query","react-query-query","react-query-mutation"],available:true,subscribe:n=>{let r=true;const o=new Set;const a=s=>s.queryHash??(s.mutationId!==void 0?`m-${s.mutationId}`:null);return t.subscribe(s=>{if(r){r=false;if(s.length>0){e=s[0].id}return}if(s.length>0){const u=s[0];if(u.id!==e){e=u.id;const i=u.type??"";const c=a(u);if(i==="query-fetch-start"||i==="mutation-start"){if(c)o.add(c)}else if(i==="query-fetch-success"||i==="query-fetch-error"||i==="mutation-success"||i==="mutation-error"){if(c&&!o.has(c)){return}}const l=transformReactQueryEvent(u);n(l)}}})}}}catch{return null}}function formatQueryKey(t){if(!t||t.length===0)return"unknown";return t.map(e=>{if(typeof e==="string")return e;if(typeof e==="number")return String(e);if(typeof e==="object"&&e!==null){const n=e;const r=Object.values(n)[0];if(typeof r==="string"||typeof r==="number"){return String(r)}return JSON.stringify(e).slice(0,20)}return String(e)}).join(" \u203A ")}function transformReactQueryEvent(t){const e=t;const n=e.type.startsWith("mutation-");const r=n?"react-query-mutation":"react-query-query";let o="neutral";switch(e.type){case"query-fetch-start":case"mutation-start":o="pending";break;case"query-fetch-success":case"mutation-success":o="success";break;case"query-fetch-error":case"mutation-error":o="error";break}let a="";if(e.queryKey){a=formatQueryKey(e.queryKey)}else if(e.mutationKey){a=formatQueryKey(e.mutationKey)}else if(e.mutationId!==void 0){a=`Mutation #${e.mutationId}`}else{a=e.type.replace(/-/g," ")}const s=[];switch(e.type){case"query-fetch-start":s.push("Fetching");break;case"query-fetch-success":s.push("Success");break;case"query-fetch-error":s.push("Error");break;case"query-invalidated":s.push("Invalidated");break;case"mutation-start":s.push("Mutating");break;case"mutation-success":s.push("Success");break;case"mutation-error":s.push("Error");break}if(e.duration!==void 0){s.push(`${e.duration.toFixed(0)}ms`)}let u;if(e.queryHash){u=`rq-query-${e.queryHash}`}else if(e.mutationId!==void 0){u=`rq-mutation-${e.mutationId}`}let i=1;switch(e.type){case"query-fetch-start":case"mutation-start":i=1;break;case"query-fetch-success":case"query-fetch-error":case"mutation-success":case"mutation-error":i=2;break;case"query-invalidated":i=3;break}return{id:generateEventId(r),source:r,timestamp:e.timestamp,title:a,subtitle:s.join(" \xB7 "),status:o,originalEvent:t,correlationId:u,sequenceInGroup:i}}function tryLoadRouteEventsSource(){try{const{routeEventStore:t}=(0,_utils.loadToolModule)("@buoy-gg/route-events");return{id:"route-events",name:"Routes",eventSources:["route"],available:true,subscribe:e=>{return t.onEvent(n=>{const r=transformRouteEvent(n);e(r)})}}}catch{return null}}function transformRouteEvent(t){const e=t;let n="neutral";if(e.pathname==="/"){n="success"}else if(Object.keys(e.params).length>0){n="success"}const r=[];const o=Object.keys(e.params).length;if(o>0){r.push(`${o} param${o!==1?"s":""}`)}if(e.timeSincePrevious!==void 0&&e.timeSincePrevious>0){if(e.timeSincePrevious<1e3){r.push(`${e.timeSincePrevious}ms`)}else{r.push(`${(e.timeSincePrevious/1e3).toFixed(1)}s`)}}if(e.previousPathname&&e.previousPathname!==e.pathname){r.push(`from ${e.previousPathname}`)}return{id:generateEventId("route"),source:"route",timestamp:e.timestamp,title:e.pathname||"/",subtitle:r.join(" \xB7 ")||"navigation",status:n,originalEvent:t}}function tryLoadZustandSource(){try{const{zustandStateStore:t}=(0,_utils.loadToolModule)("@buoy-gg/zustand");let e=null;return{id:"zustand",name:"Zustand",eventSources:["zustand"],available:true,subscribe:n=>{return t.subscribe(r=>{if(r.length>0){const o=r[0];if(o.id!==e){e=o.id;const a=transformZustandChange(o);n(a)}}})}}}catch{return null}}function transformZustandChange(t){const e=t;let n="neutral";if(e.isSlowUpdate){n="pending"}else if(e.hasStateChange){n="success"}const r=[];if(e.changedKeys&&e.changedKeys.length>0){const o=e.changedKeys.slice(0,3).join(", ");const a=e.changedKeys.length>3?` +${e.changedKeys.length-3}`:"";r.push(`${o}${a}`)}else if(e.diffSummary){r.push(e.diffSummary)}if(e.duration!==void 0){r.push(`${e.duration.toFixed(1)}ms`)}if(e.category==="replace"){r.push("replace")}return{id:generateEventId("zustand"),source:"zustand",timestamp:e.timestamp,title:e.storeName,subtitle:r.join(" \xB7 ")||(e.hasStateChange?"state changed":"no change"),status:n,originalEvent:t}}function tryLoadJotaiSource(){try{const{jotaiStateStore:t}=(0,_utils.loadToolModule)("@buoy-gg/jotai");let e=null;return{id:"jotai",name:"Jotai",eventSources:["jotai"],available:true,subscribe:n=>{return t.subscribe(r=>{if(r.length>0){const o=r[0];if(o.id!==e){e=o.id;const a=transformJotaiChange(o);n(a)}}})}}}catch{return null}}function transformJotaiChange(t){const e=t;let n="neutral";if(e.category==="write"&&e.hasValueChange){n="success"}else if(e.category==="read"){n="neutral"}const r=[];if(e.valuePreview){r.push(e.valuePreview)}else if(e.diffSummary){r.push(e.diffSummary)}if(e.category){r.push(e.category)}return{id:generateEventId("jotai"),source:"jotai",timestamp:e.timestamp,title:e.atomLabel,subtitle:r.join(" \xB7 ")||(e.hasValueChange?"value changed":"no change"),status:n,originalEvent:t}}function tryLoadHighlightUpdatesSource(){let t;try{t=(0,_utils.loadToolModule)("@buoy-gg/highlight-updates")}catch{return null}try{if(!t.RenderTracker||!t.HighlightUpdatesController){return null}const{RenderTracker:e,HighlightUpdatesController:n}=t;return{id:"render",name:"Render",eventSources:["render"],available:true,setup:()=>{if(n){n.enableBackgroundTracking()}},subscribe:r=>{if(n&&!n.isBackgroundTrackingEnabled()){n.enableBackgroundTracking()}const o=e.onRenderEvent((a,s)=>{const u=transformRenderEvent(a,s);r(u)});return()=>{o();n.disableBackgroundTracking()}}}}catch{return null}}function transformRenderEvent(t,e){const n=t;const r=e;const o=r.componentName||r.displayName||r.viewType;const a=[];const s={mount:"mounted",props:"props changed",state:"state changed",hooks:"hooks changed",context:"context changed",parent:"parent re-rendered",unknown:"re-rendered"};a.push(s[n.cause.type]||n.cause.type);if(n.cause.type==="props"&&n.cause.changedKeys?.length){const i=n.cause.changedKeys.slice(0,3).join(", ");const c=n.cause.changedKeys.length>3?` +${n.cause.changedKeys.length-3}`:"";a.push(`[${i}${c}]`)}if(n.cause.hookChanges?.length){const i=n.cause.hookChanges[0];if(i.description){a.push(i.description)}}a.push(`#${n.renderNumber}`);let u="neutral";switch(n.cause.type){case"mount":u="neutral";break;case"props":case"state":case"hooks":case"context":u="success";break;case"parent":u="pending";break;default:u="neutral"}return{id:generateEventId("render"),source:"render",timestamp:n.timestamp,title:o,subtitle:a.join(" \xB7 "),status:u,originalEvent:{event:n,render:r}}}const CAPACITOR_SKIPPED_PLUGINS=new Set(["CapacitorHttp","CapacitorCookies","Console","WebView"]);const SECRET_NAME=/token|secret|password|passwd|auth|credential|api[-_]?key|session|cookie/i;function redactCapacitorValue(t,e=false,n=0){if(!t||typeof t!=="object"||n>4)return t;if(Array.isArray(t))return t.map(s=>redactCapacitorValue(s,e,n+1));const r={};const o=t;const a=e||typeof o.key==="string"&&SECRET_NAME.test(o.key);for(const[s,u]of Object.entries(o)){if((SECRET_NAME.test(s)||a&&s==="value")&&u!=null&&u!==""){r[s]="[hidden]"}else{r[s]=redactCapacitorValue(u,false,n+1)}}return r}function tryLoadCapacitorSource(){try{const t=(0,_utils.loadToolModule)("@buoy-gg/license");if(typeof t?.subscribeCapacitorCalls!=="function"||!t.isCapacitorBridgeInstalled?.())return null;return{id:"capacitor",name:"Capacitor",eventSources:["capacitor"],available:true,subscribe:e=>{const n=new Set;let r=0;const o=()=>{const s=t.getCapacitorCalls();for(const i of s){if(i.seq<=r||n.has(i.seq))continue;if(CAPACITOR_SKIPPED_PLUGINS.has(i.plugin)){n.add(i.seq);continue}const c=i.end!==void 0||i.kind==="event"||i.method==="addListener";if(!c)continue;n.add(i.seq);e(transformCapacitorCall(i))}const u=s[0]?.seq??0;if(u>r+1){r=u-1;for(const i of Array.from(n))if(i<=r)n.delete(i)}};const a=t.getCapacitorCalls();r=a.length?a[a.length-1].seq:0;return t.subscribeCapacitorCalls(o)}}}catch{return null}}function transformCapacitorCall(t){const e=[];if(t.kind==="event")e.push("event");else if(t.method==="addListener")e.push(`listening for ${String(t.options.eventName??"events")}`);if(t.end!==void 0&&t.kind!=="event")e.push(`${Math.max(0,t.end-t.start)}ms`);if(t.answeredByBuoy)e.push("answered by Buoy");if(t.ok===false){const n=t.error?.message;e.push(typeof n==="string"?n:"failed")}return{id:generateEventId("capacitor"),source:"capacitor",timestamp:t.kind==="event"?t.start:t.end??t.start,title:`${t.plugin}.${t.method}`,subtitle:e.join(" \xB7 ")||"call",status:t.ok===false?"error":t.kind==="event"?"neutral":"success",originalEvent:{plugin:t.plugin,method:t.method,kind:t.kind,options:redactCapacitorValue(t.options),result:redactCapacitorValue(t.result,typeof t.options.key==="string"&&SECRET_NAME.test(t.options.key)),error:t.error,durationMs:t.end!==void 0?t.end-t.start:void 0,answeredByBuoy:t.answeredByBuoy??false}}}function autoDiscoverEventSources(){const t=[];const e=new Set;const n=[tryLoadStorageSource,tryLoadReduxSource,tryLoadNetworkSource,tryLoadReactQuerySource,tryLoadRouteEventsSource,tryLoadZustandSource,tryLoadJotaiSource,tryLoadHighlightUpdatesSource,tryLoadCapacitorSource,()=>{try{const r=(0,_utils.loadToolModule)("@buoy-gg/three");return r?.onThreeLoad?{id:"three",name:"Scene loads",eventSources:["three"],available:true,subscribe:r.onThreeLoad}:null}catch{return null}}];for(const r of n){const o=r();if(o&&o.available){t.push(o);o.eventSources.forEach(a=>e.add(a))}}return{sources:t,availableEventSources:e}}function getSourceDisplayConfig(t){const e={"storage-async":{label:"Storage",color:"#8B5CF6",icon:"server-outline"},"storage-mmkv":{label:"MMKV",color:"#F59E0B",icon:"flash-outline"},redux:{label:"Redux",color:"#3B82F6",icon:"git-branch-outline"},network:{label:"Network",color:"#10B981",icon:"globe-outline"},"react-query":{label:"Query",color:"#EC4899",icon:"sync-outline"},"react-query-query":{label:"Query",color:"#EC4899",icon:"sync-outline"},"react-query-mutation":{label:"Mutation",color:"#F97316",icon:"flash-outline"},route:{label:"Route",color:"#06B6D4",icon:"navigate-outline"},zustand:{label:"Zustand",color:"#764ABC",icon:"cube-outline"},jotai:{label:"Jotai",color:"#14B8A6",icon:"ellipse-outline"},render:{label:"Render",color:"#F472B6",icon:"layers-outline"},three:{label:"Scene loads",color:"#F59E0B",icon:"cube-outline"},capacitor:{label:"Capacitor",color:"#119EFF",icon:"hardware-chip-outline"}};return e[t]||{label:t,color:"#6B7280",icon:"help-outline"}}let cachedDiscovery=null;let discoveryVersion=-1;function getCachedDiscovery(){if(!cachedDiscovery||discoveryVersion!==(0,_utils.getToolModuleVersion)()){discoveryVersion=(0,_utils.getToolModuleVersion)();cachedDiscovery=autoDiscoverEventSources()}return cachedDiscovery}function clearDiscoveryCache(){cachedDiscovery=null}function getAggregatedSubscriberCounts(){const t=[];let e=0;try{const{storageEventStore:n}=(0,_utils.loadToolModule)("@buoy-gg/storage");const r=n.getSubscriberCounts();t.push({sourceId:"storage",counts:r});e+=r.total}catch{}try{const{networkEventStore:n}=(0,_utils.loadToolModule)("@buoy-gg/network");const r=n.getSubscriberCounts();t.push({sourceId:"network",counts:r});e+=r.total}catch{}try{const{routeEventStore:n}=(0,_utils.loadToolModule)("@buoy-gg/route-events");const r=n.getSubscriberCounts();t.push({sourceId:"route-events",counts:r});e+=r.total}catch{}try{const{RenderTracker:n,HighlightUpdatesController:r}=(0,_utils.loadToolModule)("@buoy-gg/highlight-updates");const o=n.getRenderEventCallbackCount();const a=r?.isEnabled?.()?1:0;const s={eventCallbacks:o,arrayListeners:a,total:o+a};t.push({sourceId:"render",counts:s});e+=s.total}catch{}return{sources:t,totalSubscribers:e}}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.autoDiscoverEventSources=autoDiscoverEventSources;exports.clearDiscoveryCache=clearDiscoveryCache;exports.getAggregatedSubscriberCounts=getAggregatedSubscriberCounts;exports.getCachedDiscovery=getCachedDiscovery;exports.getSourceDisplayConfig=getSourceDisplayConfig;exports.transformCapacitorCall=transformCapacitorCall;var _utils=require("@buoy-gg/shared-ui/utils");let eventIdCounter=0;function generateEventId(t){return`${t}-${Date.now()}-${++eventIdCounter}`}function tryLoadStorageSource(){try{const{storageEventStore:t}=(0,_utils.loadToolModule)("@buoy-gg/storage");return{id:"storage",name:"Storage",eventSources:["storage-async","storage-mmkv"],available:true,subscribe:e=>{return t.onEvent(r=>{const n=r?.data;if(n?.initialScan)return;const o=transformStorageEvent(r);e(o)})}}}catch{return null}}function transformStorageEvent(t){const e=t;const r=e.storageType==="async"?"storage-async":"storage-mmkv";let n=e.action;if(e.storageType==="async"){const s={setItem:"Set Item",removeItem:"Remove Item",mergeItem:"Merge Item",clear:"Clear All",multiSet:"Multi Set",multiRemove:"Multi Remove",multiMerge:"Multi Merge"};n=s[e.action]||e.action}let o="";if(e.storageType==="async"){switch(e.action){case"setItem":case"removeItem":case"mergeItem":o=e.data?.key||"unknown key";break;case"multiSet":case"multiMerge":{const s=e.data?.pairs?.length||0;o=`${s} key${s!==1?"s":""}`;break}case"multiRemove":{const s=e.data?.keys?.length||0;o=`${s} key${s!==1?"s":""}`;break}case"clear":o="all keys";break}}else{o=e.data?.key||e.data?.instanceId||"unknown"}let a="neutral";if(e.action.includes("set")||e.action.includes("Set")||e.action.includes("merge")||e.action.includes("Merge")){a="success"}return{id:generateEventId(r),source:r,timestamp:e.timestamp.getTime(),title:n,subtitle:o,status:a,originalEvent:t}}function tryLoadReduxSource(){try{const{reduxActionStore:t}=(0,_utils.loadToolModule)("@buoy-gg/redux");let e=null;return{id:"redux",name:"Redux",eventSources:["redux"],available:true,subscribe:r=>{return t.subscribe(n=>{if(n.length>0){const o=n[0];if(o.id!==e){e=o.id;const a=transformReduxAction(o);r(a)}}})}}}catch{return null}}function transformReduxAction(t){const e=t;let r="neutral";switch(e.category){case"fulfilled":r="success";break;case"rejected":r="error";break;case"pending":r="pending";break;default:r=e.hasStateChange?"success":"neutral"}let n="";if(e.payloadPreview){n=e.payloadPreview}else if(e.hasStateChange&&e.diffSummary){n=e.diffSummary}else if(e.duration!==void 0){n=`${e.duration.toFixed(1)}ms`}else{n=e.sliceName||""}return{id:generateEventId("redux"),source:"redux",timestamp:e.timestamp,title:e.type,subtitle:n,status:r,originalEvent:t}}function tryLoadNetworkSource(){try{const{networkEventStore:t,networkListener:e,addNetworkListener:r}=(0,_utils.loadToolModule)("@buoy-gg/network");const n=new Map;return{id:"network",name:"Network",eventSources:["network"],available:true,setup:()=>{const o=e();if(!o.isActive){o.startListening()}if(o.listenerCount===0){r(a=>{t.processNetworkEvent(a)})}},subscribe:o=>{const a=Date.now();return t.onEvent(s=>{const u=s;const i=n.get(u.id);if(!i){if(typeof u.timestamp==="number"&&u.timestamp<a){return}const c=transformNetworkEvent(s);n.set(u.id,c.id);o(c)}else{const c=transformNetworkEvent(s);c.id=i;o(c)}},false)}}}catch{return null}}function transformNetworkEvent(t){const e=t;let r="neutral";if(e.status===void 0){r="pending"}else if(e.error||e.status>=400){r="error"}else if(e.status>=200&&e.status<400){r="success"}const n=e.operationName||`${e.method} ${e.path||e.url}`;const o=[];if(e.status!==void 0){o.push(`${e.status}`)}else if(e.error){o.push("Error")}else{o.push("Pending")}if(e.duration!==void 0){o.push(`${e.duration.toFixed(0)}ms`)}if(e.host){o.push(e.host)}return{id:generateEventId("network"),source:"network",timestamp:e.timestamp,title:n,subtitle:o.join(" \xB7 "),status:r,originalEvent:t}}function tryLoadReactQuerySource(){try{const{reactQueryEventStore:t}=(0,_utils.loadToolModule)("@buoy-gg/react-query");let e=null;return{id:"react-query",name:"React Query",eventSources:["react-query","react-query-query","react-query-mutation"],available:true,subscribe:r=>{let n=true;const o=new Set;const a=s=>s.queryHash??(s.mutationId!==void 0?`m-${s.mutationId}`:null);return t.subscribe(s=>{if(n){n=false;if(s.length>0){e=s[0].id}return}if(s.length>0){const u=s[0];if(u.id!==e){e=u.id;const i=u.type??"";const c=a(u);if(i==="query-fetch-start"||i==="mutation-start"){if(c)o.add(c)}else if(i==="query-fetch-success"||i==="query-fetch-error"||i==="mutation-success"||i==="mutation-error"){if(c&&!o.has(c)){return}}const l=transformReactQueryEvent(u);r(l)}}})}}}catch{return null}}function formatQueryKey(t){if(!t||t.length===0)return"unknown";return t.map(e=>{if(typeof e==="string")return e;if(typeof e==="number")return String(e);if(typeof e==="object"&&e!==null){const r=e;const n=Object.values(r)[0];if(typeof n==="string"||typeof n==="number"){return String(n)}return JSON.stringify(e).slice(0,20)}return String(e)}).join(" \u203A ")}function transformReactQueryEvent(t){const e=t;const r=e.type.startsWith("mutation-");const n=r?"react-query-mutation":"react-query-query";let o="neutral";switch(e.type){case"query-fetch-start":case"mutation-start":o="pending";break;case"query-fetch-success":case"mutation-success":o="success";break;case"query-fetch-error":case"mutation-error":o="error";break}let a="";if(e.queryKey){a=formatQueryKey(e.queryKey)}else if(e.mutationKey){a=formatQueryKey(e.mutationKey)}else if(e.mutationId!==void 0){a=`Mutation #${e.mutationId}`}else{a=e.type.replace(/-/g," ")}const s=[];switch(e.type){case"query-fetch-start":s.push("Fetching");break;case"query-fetch-success":s.push("Success");break;case"query-fetch-error":s.push("Error");break;case"query-invalidated":s.push("Invalidated");break;case"mutation-start":s.push("Mutating");break;case"mutation-success":s.push("Success");break;case"mutation-error":s.push("Error");break}if(e.duration!==void 0){s.push(`${e.duration.toFixed(0)}ms`)}let u;if(e.queryHash){u=`rq-query-${e.queryHash}`}else if(e.mutationId!==void 0){u=`rq-mutation-${e.mutationId}`}let i=1;switch(e.type){case"query-fetch-start":case"mutation-start":i=1;break;case"query-fetch-success":case"query-fetch-error":case"mutation-success":case"mutation-error":i=2;break;case"query-invalidated":i=3;break}return{id:generateEventId(n),source:n,timestamp:e.timestamp,title:a,subtitle:s.join(" \xB7 "),status:o,originalEvent:t,correlationId:u,sequenceInGroup:i}}function tryLoadRouteEventsSource(){try{const{routeEventStore:t}=(0,_utils.loadToolModule)("@buoy-gg/route-events");return{id:"route-events",name:"Routes",eventSources:["route"],available:true,subscribe:e=>{return t.onEvent(r=>{const n=transformRouteEvent(r);e(n)})}}}catch{return null}}function transformRouteEvent(t){const e=t;let r="neutral";if(e.pathname==="/"){r="success"}else if(Object.keys(e.params).length>0){r="success"}const n=[];const o=Object.keys(e.params).length;if(o>0){n.push(`${o} param${o!==1?"s":""}`)}if(e.timeSincePrevious!==void 0&&e.timeSincePrevious>0){if(e.timeSincePrevious<1e3){n.push(`${e.timeSincePrevious}ms`)}else{n.push(`${(e.timeSincePrevious/1e3).toFixed(1)}s`)}}if(e.previousPathname&&e.previousPathname!==e.pathname){n.push(`from ${e.previousPathname}`)}return{id:generateEventId("route"),source:"route",timestamp:e.timestamp,title:e.pathname||"/",subtitle:n.join(" \xB7 ")||"navigation",status:r,originalEvent:t}}function tryLoadZustandSource(){try{const{zustandStateStore:t}=(0,_utils.loadToolModule)("@buoy-gg/zustand");let e=null;return{id:"zustand",name:"Zustand",eventSources:["zustand"],available:true,subscribe:r=>{return t.subscribe(n=>{if(n.length>0){const o=n[0];if(o.id!==e){e=o.id;const a=transformZustandChange(o);r(a)}}})}}}catch{return null}}function transformZustandChange(t){const e=t;let r="neutral";if(e.isSlowUpdate){r="pending"}else if(e.hasStateChange){r="success"}const n=[];if(e.changedKeys&&e.changedKeys.length>0){const o=e.changedKeys.slice(0,3).join(", ");const a=e.changedKeys.length>3?` +${e.changedKeys.length-3}`:"";n.push(`${o}${a}`)}else if(e.diffSummary){n.push(e.diffSummary)}if(e.duration!==void 0){n.push(`${e.duration.toFixed(1)}ms`)}if(e.category==="replace"){n.push("replace")}return{id:generateEventId("zustand"),source:"zustand",timestamp:e.timestamp,title:e.storeName,subtitle:n.join(" \xB7 ")||(e.hasStateChange?"state changed":"no change"),status:r,originalEvent:t}}function tryLoadJotaiSource(){try{const{jotaiStateStore:t}=(0,_utils.loadToolModule)("@buoy-gg/jotai");let e=null;return{id:"jotai",name:"Jotai",eventSources:["jotai"],available:true,subscribe:r=>{return t.subscribe(n=>{if(n.length>0){const o=n[0];if(o.id!==e){e=o.id;const a=transformJotaiChange(o);r(a)}}})}}}catch{return null}}function transformJotaiChange(t){const e=t;let r="neutral";if(e.category==="write"&&e.hasValueChange){r="success"}else if(e.category==="read"){r="neutral"}const n=[];if(e.valuePreview){n.push(e.valuePreview)}else if(e.diffSummary){n.push(e.diffSummary)}if(e.category){n.push(e.category)}return{id:generateEventId("jotai"),source:"jotai",timestamp:e.timestamp,title:e.atomLabel,subtitle:n.join(" \xB7 ")||(e.hasValueChange?"value changed":"no change"),status:r,originalEvent:t}}function tryLoadHighlightUpdatesSource(){let t;try{t=(0,_utils.loadToolModule)("@buoy-gg/highlight-updates")}catch{return null}try{if(!t.RenderTracker||!t.HighlightUpdatesController){return null}const{RenderTracker:e,HighlightUpdatesController:r}=t;return{id:"render",name:"Render",eventSources:["render"],available:true,setup:()=>{if(r){r.enableBackgroundTracking()}},subscribe:n=>{if(r&&!r.isBackgroundTrackingEnabled()){r.enableBackgroundTracking()}const o=e.onRenderEvent((a,s)=>{const u=transformRenderEvent(a,s);n(u)});return()=>{o();r.disableBackgroundTracking()}}}}catch{return null}}function transformRenderEvent(t,e){const r=t;const n=e;const o=n.componentName||n.displayName||n.viewType;const a=[];const s={mount:"mounted",props:"props changed",state:"state changed",hooks:"hooks changed",context:"context changed",parent:"parent re-rendered",unknown:"re-rendered"};a.push(s[r.cause.type]||r.cause.type);if(r.cause.type==="props"&&r.cause.changedKeys?.length){const i=r.cause.changedKeys.slice(0,3).join(", ");const c=r.cause.changedKeys.length>3?` +${r.cause.changedKeys.length-3}`:"";a.push(`[${i}${c}]`)}if(r.cause.hookChanges?.length){const i=r.cause.hookChanges[0];if(i.description){a.push(i.description)}}a.push(`#${r.renderNumber}`);let u="neutral";switch(r.cause.type){case"mount":u="neutral";break;case"props":case"state":case"hooks":case"context":u="success";break;case"parent":u="pending";break;default:u="neutral"}return{id:generateEventId("render"),source:"render",timestamp:r.timestamp,title:o,subtitle:a.join(" \xB7 "),status:u,originalEvent:{event:r,render:n}}}const CAPACITOR_SKIPPED_PLUGINS=new Set(["CapacitorHttp","CapacitorCookies","Console","WebView"]);const SECRET_NAME=/token|secret|password|passwd|auth|credential|api[-_]?key|session|cookie/i;function redactCapacitorValue(t,e=false,r=0){if(!t||typeof t!=="object"||r>4)return t;if(Array.isArray(t))return t.map(s=>redactCapacitorValue(s,e,r+1));const n={};const o=t;const a=e||typeof o.key==="string"&&SECRET_NAME.test(o.key);for(const[s,u]of Object.entries(o)){if((SECRET_NAME.test(s)||a&&s==="value")&&u!=null&&u!==""){n[s]="[hidden]"}else{n[s]=redactCapacitorValue(u,false,r+1)}}return n}function tryLoadCapacitorSource(){try{const t=(0,_utils.loadToolModule)("@buoy-gg/license");if(typeof t?.subscribeCapacitorCalls!=="function"||!t.isCapacitorBridgeInstalled?.())return null;return{id:"capacitor",name:"Capacitor",eventSources:["capacitor"],available:true,subscribe:e=>{const r=new Set;let n=0;const o=()=>{const s=t.getCapacitorCalls();for(const i of s){if(i.seq<=n||r.has(i.seq))continue;if(CAPACITOR_SKIPPED_PLUGINS.has(i.plugin)){r.add(i.seq);continue}const c=i.end!==void 0||i.kind==="event"||i.method==="addListener";if(!c)continue;r.add(i.seq);e(transformCapacitorCall(i))}const u=s[0]?.seq??0;if(u>n+1){n=u-1;for(const i of Array.from(r))if(i<=n)r.delete(i)}};const a=t.getCapacitorCalls();n=a.length?a[a.length-1].seq:0;return t.subscribeCapacitorCalls(o)}}}catch{return null}}function transformCapacitorCall(t){const e=[];if(t.kind==="event")e.push("event");else if(t.method==="addListener")e.push(`listening for ${String(t.options.eventName??"events")}`);if(t.end!==void 0&&t.kind!=="event")e.push(`${Math.max(0,t.end-t.start)}ms`);if(t.answeredByBuoy)e.push("answered by Buoy");if(t.ok===false){const r=t.error?.message;e.push(typeof r==="string"?r:"failed")}return{id:generateEventId("capacitor"),source:"capacitor",timestamp:t.kind==="event"?t.start:t.end??t.start,title:`${t.plugin}.${t.method}`,subtitle:e.join(" \xB7 ")||"call",status:t.ok===false?"error":t.kind==="event"?"neutral":"success",originalEvent:{plugin:t.plugin,method:t.method,kind:t.kind,options:redactCapacitorValue(t.options),result:redactCapacitorValue(t.result,typeof t.options.key==="string"&&SECRET_NAME.test(t.options.key)),error:t.error,durationMs:t.end!==void 0?t.end-t.start:void 0,answeredByBuoy:t.answeredByBuoy??false}}}function autoDiscoverEventSources(){const t=[];const e=new Set;const r=[tryLoadStorageSource,tryLoadReduxSource,tryLoadNetworkSource,tryLoadReactQuerySource,tryLoadRouteEventsSource,tryLoadZustandSource,tryLoadJotaiSource,tryLoadHighlightUpdatesSource,tryLoadCapacitorSource,()=>{try{const n=(0,_utils.loadToolModule)("@buoy-gg/three");return n?.onThreeLoad?{id:"three",name:"Scene loads",eventSources:["three"],available:true,subscribe:n.onThreeLoad}:null}catch{return null}},()=>{try{const n=(0,_utils.loadToolModule)("@buoy-gg/network");return n?.onSocketMoment?{id:"socket",name:"Sockets",eventSources:["socket"],available:true,subscribe:n.onSocketMoment}:null}catch{return null}}];for(const n of r){const o=n();if(o&&o.available){t.push(o);o.eventSources.forEach(a=>e.add(a))}}return{sources:t,availableEventSources:e}}function getSourceDisplayConfig(t){const e={"storage-async":{label:"Storage",color:"#8B5CF6",icon:"server-outline"},"storage-mmkv":{label:"MMKV",color:"#F59E0B",icon:"flash-outline"},redux:{label:"Redux",color:"#3B82F6",icon:"git-branch-outline"},network:{label:"Network",color:"#10B981",icon:"globe-outline"},"react-query":{label:"Query",color:"#EC4899",icon:"sync-outline"},"react-query-query":{label:"Query",color:"#EC4899",icon:"sync-outline"},"react-query-mutation":{label:"Mutation",color:"#F97316",icon:"flash-outline"},route:{label:"Route",color:"#06B6D4",icon:"navigate-outline"},zustand:{label:"Zustand",color:"#764ABC",icon:"cube-outline"},jotai:{label:"Jotai",color:"#14B8A6",icon:"ellipse-outline"},render:{label:"Render",color:"#F472B6",icon:"layers-outline"},three:{label:"Scene loads",color:"#F59E0B",icon:"cube-outline"},socket:{label:"Sockets",color:"#20C997",icon:"pulse-outline"},capacitor:{label:"Capacitor",color:"#119EFF",icon:"hardware-chip-outline"}};return e[t]||{label:t,color:"#6B7280",icon:"help-outline"}}let cachedDiscovery=null;let discoveryVersion=-1;function getCachedDiscovery(){if(!cachedDiscovery||discoveryVersion!==(0,_utils.getToolModuleVersion)()){discoveryVersion=(0,_utils.getToolModuleVersion)();cachedDiscovery=autoDiscoverEventSources()}return cachedDiscovery}function clearDiscoveryCache(){cachedDiscovery=null}function getAggregatedSubscriberCounts(){const t=[];let e=0;try{const{storageEventStore:r}=(0,_utils.loadToolModule)("@buoy-gg/storage");const n=r.getSubscriberCounts();t.push({sourceId:"storage",counts:n});e+=n.total}catch{}try{const{networkEventStore:r}=(0,_utils.loadToolModule)("@buoy-gg/network");const n=r.getSubscriberCounts();t.push({sourceId:"network",counts:n});e+=n.total}catch{}try{const{routeEventStore:r}=(0,_utils.loadToolModule)("@buoy-gg/route-events");const n=r.getSubscriberCounts();t.push({sourceId:"route-events",counts:n});e+=n.total}catch{}try{const{RenderTracker:r,HighlightUpdatesController:n}=(0,_utils.loadToolModule)("@buoy-gg/highlight-updates");const o=r.getRenderEventCallbackCount();const a=n?.isEnabled?.()?1:0;const s={eventCallbacks:o,arrayListeners:a,total:o+a};t.push({sourceId:"render",counts:s});e+=s.total}catch{}return{sources:t,totalSubscribers:e}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.estimateExportSize=estimateExportSize;exports.filterEvents=filterEvents;exports.generateExport=generateExport;exports.generateJsonExport=generateJsonExport;exports.generateMarkdownExport=generateMarkdownExport;exports.generateMermaidExport=generateMermaidExport;exports.generatePlaintextExport=generatePlaintextExport;exports.getExportSummary=getExportSummary;var _sharedUi=require("@buoy-gg/shared-ui");const STATUS_ICONS={success:"\u2705",pending:"\u23F3",error:"\u274C",neutral:"\u2796"};const STATUS_ICONS_ASCII={success:"[OK]",pending:"[...]",error:"[ERR]",neutral:"[-]"};const SOURCE_LABELS={"storage-async":"Storage","storage-mmkv":"MMKV",redux:"Redux",network:"Network","react-query":"Query","react-query-query":"Query","react-query-mutation":"Mutation",route:"Route",zustand:"Zustand",jotai:"Jotai",render:"Render",capacitor:"Capacitor",three:"Scene loads"};function tryParseJson(e){if(typeof e!=="string")return e;const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return e;try{return JSON.parse(e)}catch{return e}}function deepParseJsonStrings(e){if(e===null||e===void 0)return e;if(typeof e==="string"){return tryParseJson(e)}if(Array.isArray(e)){return e.map(deepParseJsonStrings)}if(typeof e==="object"){const t={};for(const[n,r]of Object.entries(e)){t[n]=deepParseJsonStrings(r)}return t}return e}const VERBOSE_FIELDS=new Set(["image","imageUrl","imageURL","image_url","thumbnail","thumbnailUrl","thumbnail_url","icon","iconUrl","avatar","avatarUrl","photo","photoUrl","picture","pictureUrl","description","desc","longDescription","shortDescription","meta_description"]);function stripVerboseFieldsFromObject(e){if(e===null||e===void 0)return e;if(Array.isArray(e)){return e.map(stripVerboseFieldsFromObject)}if(typeof e==="object"){const t={};for(const[n,r]of Object.entries(e)){if(VERBOSE_FIELDS.has(n))continue;if(typeof r==="string"&&isImageUrl(r))continue;t[n]=stripVerboseFieldsFromObject(r)}return t}return e}function isImageUrl(e){if(!e.startsWith("http"))return false;const t=e.toLowerCase();return t.includes("/photo")||t.includes("/image")||t.includes("unsplash.com")||t.includes("cloudinary.com")||t.includes("imgur.com")||/\.(jpg|jpeg|png|gif|webp|svg|bmp)(\?|$)/i.test(e)}function formatTimestampValue(e){if(e instanceof Date){return e.toISOString()}if(e&&typeof e==="object"&&Object.keys(e).length===0){return void 0}return e}function computeArrayDiff(e,t){const n=s=>{if(typeof s!=="object"||s===null)return null;const c=s;if(typeof c.id==="string")return c.id;if(typeof c.orderId==="string")return c.orderId;if(typeof c.key==="string")return c.key;return null};const r=new Set(e.map(n).filter(Boolean));const u=new Set(t.map(n).filter(Boolean));if(r.size===0&&u.size===0)return null;const o=t.filter(s=>{const c=n(s);return c&&!r.has(c)});const a=e.filter(s=>{const c=n(s);return c&&!u.has(c)});const i=t.length-o.length;if(o.length+a.length<e.length&&o.length+a.length<t.length){return{added:o,removed:a,unchanged:i}}return null}function formatStorageData(e,t){const n={};if(e.action)n.action=e.action;if(e.storageType)n.storageType=e.storageType;if(e.timestamp!==void 0){const r=formatTimestampValue(e.timestamp);if(r!==void 0){n.timestamp=r}}if(e.data){const r={...e.data};if(t.smartJsonParsing){if(r.value!==void 0){r.value=tryParseJson(r.value)}if(r.prevValue!==void 0){r.prevValue=tryParseJson(r.prevValue)}}if(t.showStorageDiff&&Array.isArray(r.value)&&Array.isArray(r.prevValue)){const u=computeArrayDiff(r.prevValue,r.value);if(u){const o={key:r.key};if(u.added.length>0){o.added=u.added}if(u.removed.length>0){o.removed=u.removed}if(u.unchanged>0){o.unchangedCount=u.unchanged}n.data=o;return n}}n.data=r}return n}function formatReduxData(e,t){if(!t.reduxChangedOnly){return t.smartJsonParsing?deepParseJsonStrings(e):e}const n={};if(e.type)n.type=e.type;if(e.payload)n.payload=t.smartJsonParsing?deepParseJsonStrings(e.payload):e.payload;if(e.sliceName)n.sliceName=e.sliceName;if(e.actionName)n.actionName=e.actionName;if(e.duration)n.duration=e.duration;if(e.hasStateChange!==void 0)n.hasStateChange=e.hasStateChange;if(e.diffSummary)n.diffSummary=e.diffSummary;if(e.changedKeysCount!==void 0)n.changedKeysCount=e.changedKeysCount;if(e.hasStateChange===true){const r=e.sliceName;if(r&&e.prevState&&e.nextState){const u=e.prevState;const o=e.nextState;if(u[r]!==void 0||o[r]!==void 0){n.stateChange={slice:r,before:u[r],after:o[r]}}}}return n}function getItemIdentifier(e){if(typeof e!=="object"||e===null)return null;const t=e;if(typeof t.name==="string")return t.name;if(typeof t.id==="string")return t.id;if(typeof t.key==="string")return t.key;return null}function generateStorageDiffSummary(e,t){const n=typeof e==="string"?tryParseJson(e):e;const r=typeof t==="string"?tryParseJson(t):t;if((n===null||n===void 0)&&r!==null&&r!==void 0)return"Created";if(n!==null&&n!==void 0&&(r===null||r===void 0))return"Deleted";if(Array.isArray(n)&&Array.isArray(r)){const u=n.length;const o=r.length;const a=n.map(getItemIdentifier).filter(Boolean);const i=r.map(getItemIdentifier).filter(Boolean);if(u===o&&u>0){const s=new Set(a);const c=new Set(i);const l=a.filter(f=>c.has(f));if(l.length===0&&a.length>0&&i.length>0){return`\u26A0\uFE0F Replaced: [${a.join(", ")}] \u2192 [${i.join(", ")}]`}if(l.length<u){const f=a.filter(y=>!c.has(y));const d=i.filter(y=>!s.has(y));return`Changed: -${f.join(", ")} +${d.join(", ")}`}}if(u===0&&o>0){if(i.length>0){return`Added: [${i.join(", ")}]`}return`Added ${o} item${o>1?"s":""}`}if(u>0&&o===0){if(a.length>0){return`Removed all: [${a.join(", ")}]`}return`Removed all ${u} item${u>1?"s":""}`}if(o>u){const s=new Set(a);const c=i.filter(l=>!s.has(l));if(c.length>0){return`Added: [${c.join(", ")}] (${u} \u2192 ${o})`}return`Added ${o-u} item${o-u>1?"s":""} (${u} \u2192 ${o})`}if(o<u){const s=new Set(i);const c=a.filter(l=>!s.has(l));if(c.length>0){return`Removed: [${c.join(", ")}] (${u} \u2192 ${o})`}return`Removed ${u-o} item${u-o>1?"s":""} (${u} \u2192 ${o})`}return`Updated (${o} item${o>1?"s":""})`}if(typeof n==="object"&&typeof r==="object"&&n&&r){const u=Object.keys(n);const o=Object.keys(r);const a=o.filter(s=>!u.includes(s));const i=u.filter(s=>!o.includes(s));if(a.length>0&&i.length>0){return`+${a.length} -${i.length} keys`}if(a.length>0)return`Added: ${a.join(", ")}`;if(i.length>0)return`Removed: ${i.join(", ")}`;return"Updated"}return null}function formatReactQueryData(e,t){const n={};if(e.id)n.id=e.id;if(e.type)n.type=e.type;if(e.timestamp)n.timestamp=e.timestamp;if(e.queryKey)n.queryKey=e.queryKey;if(e.mutationKey)n.mutationKey=e.mutationKey;if(e.mutationId)n.mutationId=e.mutationId;if(e.duration)n.duration=e.duration;if(e.queryData!==void 0){n.data=t.smartJsonParsing?deepParseJsonStrings(e.queryData):e.queryData}if(e.variables!==void 0){n.variables=t.smartJsonParsing?deepParseJsonStrings(e.variables):e.variables}if(e.queryError!==void 0){const r=e.queryError;if(r&&typeof r==="object"){n.error=r.message||r.name||r}else{n.error=e.queryError}}if(e.mutationError!==void 0){const r=e.mutationError;if(r&&typeof r==="object"){n.error=r.message||r.name||r}else{n.error=e.mutationError}}if(e.query&&typeof e.query==="object"){const r=e.query;if(r.state&&typeof r.state==="object"){const u=r.state;if(u.status)n.status=u.status;if(u.fetchStatus)n.fetchStatus=u.fetchStatus;if(u.error){const o=u.error;if(o&&typeof o==="object"){n.error=o.message||o.name||o}}}}if(e.mutation&&typeof e.mutation==="object"){const r=e.mutation;if(r.state&&typeof r.state==="object"){const u=r.state;if(u.status)n.status=u.status;if(u.failureCount)n.failureCount=u.failureCount;if(u.error){const o=u.error;if(o&&typeof o==="object"){n.error=o.message||o.name||o}}if(u.failureReason){const o=u.failureReason;if(o&&typeof o==="object"){n.failureReason=o.message||o.name||o}}}}return n}function formatEventData(e,t){const n=e.originalEvent;if(!n)return null;let r;if(e.source==="storage-async"||e.source==="storage-mmkv"){r=formatStorageData(n,t)}else if(e.source==="redux"){r=formatReduxData(n,t)}else if(e.source==="react-query"||e.source==="react-query-query"||e.source==="react-query-mutation"){r=formatReactQueryData(n,t)}else if(t.smartJsonParsing){r=deepParseJsonStrings(n)}else{r=n}if(t.stripVerboseFields&&r){r=stripVerboseFieldsFromObject(r)}return r}function getExportSummary(e){const t={totalEvents:e.length,success:0,pending:0,error:0,neutral:0,durationMs:0,sources:new Set};if(e.length===0)return t;let n=Infinity;let r=-Infinity;for(const u of e){t[u.status]++;t.sources.add(u.source);if(u.timestamp<n)n=u.timestamp;if(u.timestamp>r)r=u.timestamp}t.durationMs=r-n;return t}function filterEvents(e,t){let n=[...e];if(t.filterMode!=="all"){n=n.filter(r=>{switch(t.filterMode){case"errors":return r.status==="error";case"success":return r.status==="success";case"pending":return r.status==="pending";default:return true}})}if(t.filterSources.length>0){const r=new Set(t.filterSources);n=n.filter(u=>r.has(u.source))}return n}function formatRelativeTime(e){if(e<1e3)return`+${e}ms`;if(e<6e4)return`+${(e/1e3).toFixed(1)}s`;return`+${(e/6e4).toFixed(1)}m`}function formatAbsoluteTime(e){const t=new Date(e);return t.toISOString()}function formatTimestamp(e,t,n){const r=formatRelativeTime(e-t);const u=formatAbsoluteTime(e);switch(n){case"relative":return r;case"absolute":return u;case"both":return`${r} (${u})`}}function approxJsonBytesOver(e,t){let n=0;const r=[e];const u=new Set;while(r.length>0){if(n>t)return{over:true,approxBytes:n};const o=r.pop();if(o===null||o===void 0)n+=4;else if(typeof o==="string")n+=o.length+2;else if(typeof o==="number")n+=8;else if(typeof o==="boolean")n+=5;else if(typeof o==="object"){if(u.has(o))continue;u.add(o);if(Array.isArray(o)){n+=2+o.length;for(let a=0;a<o.length;a++)r.push(o[a])}else{n+=2;for(const a in o){n+=a.length+4;r.push(o[a])}}}else n+=4}return{over:n>t,approxBytes:n}}function truncateData(e,t){if(t===-1){return{data:e,truncated:false}}const{over:n,approxBytes:r}=approxJsonBytesOver(e,t*1024);if(n){return{data:`[Data truncated - \u2265${(r/1024).toFixed(1)}KB exceeds ${t}KB limit]`,truncated:true}}try{JSON.stringify(e);return{data:e,truncated:false}}catch{return{data:"[Unable to serialize data]",truncated:true}}}function estimateExportSize(e,t){let n=0;for(const r of e){if(t.includeSource)n+=20;if(t.includeStatus)n+=10;if(t.includeTitle)n+=(r.title?.length||0)+10;if(t.includeSubtitle)n+=(r.subtitle?.length||0)+10;if(t.includeCorrelation)n+=20;if(t.includeDuration)n+=15;n+=30;if(t.includeEventData&&r.originalEvent){const u=t.dataSizeThreshold===-1?1024*1024:t.dataSizeThreshold*1024;const{approxBytes:o}=approxJsonBytesOver(r.originalEvent,u);n+=Math.min(o,u)}}if(t.includeSummaryHeader)n+=100;if(t.includeTotalDuration)n+=50;if(t.format==="markdown")n*=1.2;if(t.format==="json")n*=1.3;return Math.round(n)}function formatCompactEvent(e,t,n){const r=[];const u=formatTimestamp(e.timestamp,t,n.timestampFormat);r.push(`\`${u}\``);if(n.includeStatus){r.push(STATUS_ICONS[e.status])}if(n.includeSource){r.push(`**${SOURCE_LABELS[e.source]}**`)}if(n.includeTitle){r.push(e.title)}if(n.showStorageDiff&&(e.source==="storage-async"||e.source==="storage-mmkv")){const o=e.originalEvent;if(o?.data){const a=o.data;const i=generateStorageDiffSummary(a.prevValue,a.value);if(i){r.push(`\u2192 ${i}`)}}}if(e.source==="redux"){const o=e.originalEvent;if(o?.hasStateChange===false){r.push("(no state change)")}}if(n.includeSubtitle&&e.subtitle){r.push(`- ${e.subtitle}`)}return r.join(" ")}function generateStorageDiffBlock(e,t){const n=[];const r=e.originalEvent;if(!r?.data)return n;const u=r.data;const o=t.smartJsonParsing?tryParseJson(u.prevValue):u.prevValue;const a=t.smartJsonParsing?tryParseJson(u.value):u.value;const i=generateStorageDiffSummary(u.prevValue,u.value);if(i){n.push(` **Change:** ${i}`)}if(Array.isArray(o)&&Array.isArray(a)){const s=o.map(l=>{if(typeof l==="object"&&l&&"name"in l)return l.name;return null}).filter(Boolean);const c=a.map(l=>{if(typeof l==="object"&&l&&"name"in l)return l.name;return null}).filter(Boolean);if(s.length>0||c.length>0){if(s.length>0){n.push(` Before: [${s.join(", ")}]`)}n.push(` After: [${c.join(", ")}]`)}}return n}function generateMarkdownExport(e,t){const n=filterEvents(e,t);if(n.length===0)return"No events to export.";const r=[...n].sort((s,c)=>s.timestamp-c.timestamp);const u=r[0].timestamp;const o=getExportSummary(r);const a=[];a.push("## Event Flow");if(t.includeSummaryHeader||t.includeTotalDuration){const s=[];if(t.includeTotalDuration){s.push(`**Duration:** ${formatRelativeTime(o.durationMs).replace("+","")}`)}s.push(`**Events:** ${o.totalEvents}`);if(t.includeSummaryHeader){const c=[];if(o.success>0)c.push(`${o.success} ${STATUS_ICONS.success}`);if(o.pending>0)c.push(`${o.pending} ${STATUS_ICONS.pending}`);if(o.error>0)c.push(`${o.error} ${STATUS_ICONS.error}`);if(o.neutral>0)c.push(`${o.neutral} ${STATUS_ICONS.neutral}`);if(c.length>0){s.push(`**Status:** ${c.join(" ")}`)}}a.push(s.join(" | "))}a.push("");a.push("### Timeline");a.push("");if(t.compactMode){r.forEach((s,c)=>{a.push(`${c+1}. ${formatCompactEvent(s,u,t)}`)});return a.join("\n")}r.forEach((s,c)=>{const l=[];const f=formatTimestamp(s.timestamp,u,t.timestampFormat);l.push(`${c+1}. \`${f}\``);if(t.includeStatus){l.push(STATUS_ICONS[s.status])}if(t.includeSource){l.push(`**${SOURCE_LABELS[s.source]}**`)}if(t.includeTitle){l.push(s.title)}if(t.includeCorrelation&&s.correlationId&&s.sequenceInGroup){l.push(`(${s.sequenceInGroup})`)}a.push(l.join(" "));if(t.includeSubtitle&&s.subtitle){a.push(` \u2514\u2500 ${s.subtitle}`)}if(t.showStorageDiff&&!t.includeEventData){if(s.source==="storage-async"||s.source==="storage-mmkv"){const d=generateStorageDiffBlock(s,t);a.push(...d)}}if(t.includeEventData&&s.originalEvent){const d=formatEventData(s,t);const{data:y,truncated:$}=truncateData(d,t.dataSizeThreshold);if($){a.push(` \u2514\u2500 ${y}`)}else{if(t.showStorageDiff&&(s.source==="storage-async"||s.source==="storage-mmkv")){const p=s.originalEvent;if(p?.data){const g=p.data;const h=generateStorageDiffSummary(g.prevValue,g.value);if(h){a.push(` **Change:** ${h}`)}}}a.push(" ```json");a.push(` ${JSON.stringify(y,null,2).split("\n").join("\n ")}`);a.push(" ```")}}a.push("")});const i=r.filter(s=>s.status==="error");if(i.length>0&&t.includeEventData){a.push("---");a.push("");a.push("### Errors");a.push("");for(const s of i){const c=formatTimestamp(s.timestamp,u,t.timestampFormat);a.push(`**${s.title}** (${c})`);if(s.originalEvent){const l=formatEventData(s,t);const{data:f,truncated:d}=truncateData(l,t.dataSizeThreshold);if(!d){a.push("```json");a.push(JSON.stringify(f,null,2));a.push("```")}}a.push("")}}return a.join("\n")}function generateJsonExport(e,t){const n=filterEvents(e,t);if(n.length===0)return"[]";const r=[...n].sort((i,s)=>i.timestamp-s.timestamp);const u=r[0].timestamp;const o=getExportSummary(r);const a={exportedAt:new Date().toISOString()};if(t.includeSummaryHeader){a.summary={totalEvents:o.totalEvents,success:o.success,pending:o.pending,error:o.error,neutral:o.neutral,durationMs:o.durationMs,sources:Array.from(o.sources)}}a.events=r.map(i=>{const s={};s.timestamp=formatAbsoluteTime(i.timestamp);if(t.timestampFormat==="relative"||t.timestampFormat==="both"){s.relativeMs=i.timestamp-u}if(t.includeSource)s.source=i.source;if(t.includeStatus)s.status=i.status;if(t.includeTitle)s.title=i.title;if(t.includeSubtitle)s.subtitle=i.subtitle;if(t.includeCorrelation&&i.correlationId){s.correlationId=i.correlationId;s.sequenceInGroup=i.sequenceInGroup}if(t.includeEventData&&i.originalEvent){const c=formatEventData(i,t);const{data:l,truncated:f}=truncateData(c,t.dataSizeThreshold);s.data=l;if(f)s.dataTruncated=true;if(t.showStorageDiff&&(i.source==="storage-async"||i.source==="storage-mmkv")){const d=i.originalEvent;if(d?.data){const y=d.data;const $=generateStorageDiffSummary(y.prevValue,y.value);if($){s.changeSummary=$}}}}return s});return JSON.stringify(a,null,2)}function generatePlaintextExport(e,t){const n=filterEvents(e,t);if(n.length===0)return"No events to export.";const r=[...n].sort((i,s)=>i.timestamp-s.timestamp);const u=r[0].timestamp;const o=getExportSummary(r);const a=[];if(t.includeSummaryHeader||t.includeTotalDuration){const i=[`Event Flow (${o.totalEvents} events`];if(t.includeTotalDuration){i[0]+=`, ${formatRelativeTime(o.durationMs).replace("+","")}`}i[0]+=")";a.push(i[0]);if(t.includeSummaryHeader){const s=[];if(o.success>0)s.push(`${o.success} success`);if(o.pending>0)s.push(`${o.pending} pending`);if(o.error>0)s.push(`${o.error} error`);if(o.neutral>0)s.push(`${o.neutral} neutral`);if(s.length>0){a.push(s.join(", "))}}a.push("")}for(const i of r){const s=[];const c=formatTimestamp(i.timestamp,u,t.timestampFormat);s.push(c.padEnd(12));if(t.includeStatus){s.push(STATUS_ICONS_ASCII[i.status])}if(t.includeSource){s.push(`${SOURCE_LABELS[i.source]}:`)}if(t.includeTitle){s.push(i.title)}if(t.showStorageDiff&&(i.source==="storage-async"||i.source==="storage-mmkv")){const l=i.originalEvent;if(l?.data){const f=l.data;const d=generateStorageDiffSummary(f.prevValue,f.value);if(d){s.push(`-> ${d}`)}}}if(i.source==="redux"){const l=i.originalEvent;if(l?.hasStateChange===false){s.push("(no change)")}}if(t.includeSubtitle&&i.subtitle){s.push(`- ${i.subtitle}`)}a.push(s.join(" "));if(t.includeEventData&&i.originalEvent){const l=formatEventData(i,t);const{data:f,truncated:d}=truncateData(l,t.dataSizeThreshold);if(d){a.push(` ${f}`)}else{a.push(` Data: ${JSON.stringify(f)}`)}}}return a.join("\n")}const MERMAID_PARTICIPANTS=[{id:"U",icon:"\u{1F464}",label:"User",sources:[],group:"client"},{id:"App",icon:"\u{1F4F1}",label:"App",sources:["route","render"],group:"client"},{id:"Async",icon:"\u{1F4BE}",label:"AsyncStorage",sources:["storage-async"],group:"client"},{id:"MMKV",icon:"\u26A1",label:"MMKV",sources:["storage-mmkv"],group:"client"},{id:"Redux",icon:"\u{1F504}",label:"Redux",sources:["redux"],group:"client"},{id:"API",icon:"\u{1F310}",label:"API",sources:["network"],group:"server"},{id:"Cache",icon:"\u{1F4E6}",label:"QueryCache",sources:["react-query","react-query-query","react-query-mutation"],group:"server"}];function getParticipantId(e){const t=MERMAID_PARTICIPANTS.find(n=>n.sources.includes(e));return t?.id||"App"}function detectParticipants(e){const t=new Set;for(const r of e){t.add(r.source)}const n=[];n.push(MERMAID_PARTICIPANTS[0]);n.push(MERMAID_PARTICIPANTS[1]);for(const r of MERMAID_PARTICIPANTS.slice(2)){if(r.sources.some(u=>t.has(u))){n.push(r)}}return n}function shouldUseGroups(e){const t=e.some(r=>r.group==="client");const n=e.some(r=>r.group==="server");return t&&n&&e.length>=3}function formatMermaidDuration(e){if(e<1e3)return`${e}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;return`${(e/6e4).toFixed(1)}m`}function escapeMermaidText(e){return e.replace(/[#;:]/g," ").replace(/[\n\r]/g," ").replace(/"/g,"'").replace(/\s+/g," ").trim()}function isInternalStorageKey(e){if((0,_sharedUi.isDevToolsStorageKey)(e))return true;const t=["last-route","@dev/last","__debug","_persist","devtools/internal"];const n=e.toLowerCase();return t.some(r=>n.includes(r))}function formatBytes(e){if(e<1024)return`${e}B`;if(e<1024*1024)return`${(e/1024).toFixed(1)}KB`;return`${(e/(1024*1024)).toFixed(1)}MB`}function estimateDataSize(e){return approxJsonBytesOver(e,1024*1024).approxBytes}function getCanonicalUrl(e){try{const t=new URL(e,"http://localhost");const n=["timestamp","t","_t","debug","client","version","cache","_"];n.forEach(r=>t.searchParams.delete(r));return t.pathname+(t.searchParams.toString()?"?"+t.searchParams.toString():"")}catch{return e}}function getStorageKeyName(e){let t=e.replace(/^@[\w-]+\//,"").replace(/^devtools\//,"").replace(/^dev\//,"").replace(/^buoy\//,"").replace(/^pokemon\//,"");const n=t.split("/").filter(Boolean);if(n.length>1){t=n.slice(-1).join("/")}t=t.replace(/-/g," ").replace(/_/g," ");t=t.split(" ").map(r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join(" ");if(t.toLowerCase()==="saved")t="Favorites";return t.substring(0,20)}function extractEntityFromPath(e){let t=e;try{const r=new URL(e,"http://localhost");t=r.pathname}catch{const r=t.indexOf("?");if(r>0){t=t.substring(0,r)}}const n=t.split("/").filter(Boolean);if(n.length>=2){const r=n[n.length-1];if(/^\d+$/.test(r)||/^[a-f0-9-]{36}$/i.test(r)){return null}return r.charAt(0).toUpperCase()+r.slice(1)}if(n.length===1){return n[0].charAt(0).toUpperCase()+n[0].slice(1)}return null}function getHumanReadableApiAction(e,t){try{const n=new URL(t,"http://localhost");let r=n.pathname;if(r.includes("graphql")){return"GraphQL Request"}r=r.replace(/^\/api\/v\d+/,"").replace(/^\/api/,"");const u=extractEntityFromPath(r);const o=r.split("/").filter(Boolean);const a=o[0]?o[0].charAt(0).toUpperCase()+o[0].slice(1):"Data";const i=n.searchParams.has("q")||n.searchParams.has("query")||n.searchParams.has("search");switch(e.toUpperCase()){case"GET":if(i){const s=n.searchParams.get("q")||n.searchParams.get("query")||n.searchParams.get("search");if(s)return`Search "${s}"`;return`Search ${a}`}if(u)return`Fetch ${u}`;return`Fetch ${a}`;case"POST":if(r.includes("search"))return`Search ${a}`;if(u)return`Create ${u}`;return`Create ${a}`;case"PUT":case"PATCH":if(u)return`Update ${u}`;return`Update ${a}`;case"DELETE":if(u)return`Delete ${u}`;return`Delete ${a}`;default:return`${e} ${a}`}}catch{return`${e} request`}}function getHumanReadableRoute(e){if(e==="/"||e==="")return"Home";const t=e.split("/").filter(Boolean);if(t.length===0)return"Home";if(t.length===1){const n=t[0].charAt(0).toUpperCase()+t[0].slice(1);return`${n} List`}if(t.length>=2){const n=t[t.length-1];if(/^\d+$/.test(n)){const u=t[0].charAt(0).toUpperCase()+t[0].slice(1);return`${u} #${n}`}const r=n.charAt(0).toUpperCase()+n.slice(1);return`${r} Details`}return e}function formatMermaidEvent(e,t,n){const r=[];const u=[];const o=formatMermaidDuration(e.timestamp-n);switch(e.source){case"route":{const a=e.originalEvent;const i=String(a?.pathname||e.title);const s=a?.previousPathname;const c=a?.timeSincePrevious;const l=getHumanReadableRoute(i);const f=s?getHumanReadableRoute(s):null;if(f){r.push(`U->>App: ${f} \u2192 ${l}`);if(c&&c>0){u.push(`Note right of App: ${formatMermaidDuration(c)} on ${f}`)}}else{r.push(`U->>App: Open ${l}`)}break}case"network":{const a=e.originalEvent;const i=a?.method||"GET";const s=a?.url||"";const c=a?.status;const l=a?.duration;const f=a?.response||a?.data||a?.body;const d=a?.responseSize||a?.size||a?.contentLength;const y=getHumanReadableApiAction(i,s);const $=extractEntityFromPath(s);r.push(`App->>+API: ${y}`);if(e.status==="error"){const g=c?`${c} Error`:"Failed";r.push(`API--x-App: ${g}`)}else{let g=$?`\u2713 ${$}`:"\u2713 Success";r.push(`API-->>-App: ${g}`)}const p=[];if(l){p.push(formatMermaidDuration(l))}if(d&&d>0){p.push(formatBytes(d))}else if(f){const g=estimateDataSize(f);if(g>1024){p.push(formatBytes(g))}}if(p.length>0){u.push(`Note right of API: ${p.join(" \xB7 ")}`)}break}case"storage-async":case"storage-mmkv":{const a=e.originalEvent;const i=a?.data;const s=a?.action||"access";const c=i?.key||"data";if(isInternalStorageKey(c)){return{messages:[],notes:[],skip:true}}const l=getStorageKeyName(c);const f=e.source==="storage-mmkv"?"MMKV":"Async";const d=m=>{if(typeof m==="string")return m;if(typeof m==="number")return String(m);if(typeof m==="object"&&m){if("name"in m)return String(m.name);if("id"in m)return String(m.id)}return null};const y=m=>m.charAt(0).toUpperCase()+m.slice(1);let $="";let p="";let g="";let h="";const S=i?.prevValue;const A=i?.value;if(Array.isArray(S)&&Array.isArray(A)){const m=S.length;const D=A.length;h=`${m} \u2192 ${D} items`;if(D>m){$="\u2795";p="Add";const v=new Set(S.map(d).filter(Boolean));for(const E of A){const b=d(E);if(b&&!v.has(b)){g=y(b);break}}}else if(D<m){$="\u2796";p="Remove";const v=new Set(A.map(d).filter(Boolean));for(const E of S){const b=d(E);if(b&&!v.has(b)){g=y(b);break}}}else{$="\u{1F4DD}";p="Update"}}else if(Array.isArray(A)&&(!S||Array.isArray(S)&&S.length===0)){$="\u2795";p="Add";h=`\u2192 ${A.length} items`;if(A.length>0){const m=d(A[0]);if(m)g=y(m)}}else if(Array.isArray(S)&&(!A||Array.isArray(A)&&A.length===0)){$="\u2796";p="Clear";h=`${S.length} \u2192 0 items`}else if(s==="getItem"){$="\u{1F4D6}";p="Load"}else if(s==="removeItem"){$="\u2796";p="Remove"}else if(s==="clear"){$="\u{1F5D1}\uFE0F";p="Clear"}else{$="\u{1F4BE}";p="Save"}let x;if(g){x=`App->>${f}: ${$} ${p} ${g} \u2192 ${l}`}else{x=`App->>${f}: ${$} ${p} ${l}`}r.push(x);if(h){u.push(`Note right of ${f}: ${h}`)}break}case"react-query":case"react-query-query":{const a=e.originalEvent;const i=a?.type||"";const s=a?.queryKey;const c=a?.duration;let l="data";if(Array.isArray(s)&&s.length>0){const f=s[s.length-1];if(typeof f==="string"&&!/^\d+$/.test(f)){l=f.charAt(0).toUpperCase()+f.slice(1)}else if(s.length>1&&typeof s[0]==="string"){l=s[0].charAt(0).toUpperCase()+s[0].slice(1)}}if(i.includes("start")||i.includes("fetch")||e.status==="pending"){r.push(`App->>+Cache: Fetch ${l}`)}else if(e.status==="error"){r.push(`Cache--x-App: Failed to load`)}else if(e.status==="success"){let f=`\u2713 ${l} ready`;if(c){f+=` (${formatMermaidDuration(c)})`}r.push(`Cache-->>-App: ${f}`)}else if(i.includes("invalidate")){r.push(`App->>Cache: Refresh ${l}`)}else{r.push(`Cache-->>App: ${escapeMermaidText(i)}`)}break}case"react-query-mutation":{const a=e.originalEvent;const i=a?.type||"";const s=a?.mutationKey;const c=a?.duration;let l="Update";if(Array.isArray(s)&&s.length>0){const f=String(s[0]);if(f.includes("add")||f.includes("create"))l="Add";else if(f.includes("delete")||f.includes("remove"))l="Delete";else if(f.includes("update")||f.includes("edit"))l="Update";else l=f.charAt(0).toUpperCase()+f.slice(1)}if(i.includes("start")||i.includes("loading")||e.status==="pending"){r.push(`App->>+Cache: ${l}`)}else if(e.status==="error"){r.push(`Cache--x-App: ${l} failed`)}else if(e.status==="success"){let f=`\u2713 ${l} complete`;if(c){f+=` (${formatMermaidDuration(c)})`}r.push(`Cache-->>-App: ${f}`)}break}case"redux":{const a=e.originalEvent;const i=a?.type||e.title;const s=a?.hasStateChange;const c=a?.diffSummary;const l=i.split("/");let f;if(l.length>=2){const d=l[0].charAt(0).toUpperCase()+l[0].slice(1);let y=l[1].replace(/([A-Z])/g," $1").replace(/(pending|fulfilled|rejected)$/i,"").trim();y=y.charAt(0).toUpperCase()+y.slice(1);f=`${y} (${d})`}else{f=escapeMermaidText(i).substring(0,25)}r.push(`App->>Redux: ${f}`);if(s===false){u.push(`Note right of Redux: No change`)}else if(c){u.push(`Note right of Redux: ${escapeMermaidText(c).substring(0,35)}`)}break}case"render":{const a=e.originalEvent;const i=a?.renderData;const s=escapeMermaidText(e.title).substring(0,20);const c=i?.cause||"update";const l=c==="mount"?"mounted":c==="props"?"props changed":c==="state"?"state changed":c==="context"?"context changed":c==="parent"?"parent re-rendered":c==="hooks"?"hook changed":c;r.push(`App->>App: Render ${s}`);u.push(`Note right of App: ${l}`);break}default:{r.push(`App->>App: ${escapeMermaidText(e.title).substring(0,30)}`)}}return{messages:r,notes:u}}function generateMermaidExport(e,t){const n=filterEvents(e,t);if(n.length===0){return"sequenceDiagram\n participant U as \u{1F464} User\n participant App as \u{1F4F1} App\n Note over U,App: No events captured"}const r=[...n].sort((p,g)=>p.timestamp-g.timestamp);const u=r[0].timestamp;const o=detectParticipants(r);const a=shouldUseGroups(o);const i=["sequenceDiagram"];i.push(" autonumber");i.push("");if(a){const p=o.filter(h=>h.group==="client");const g=o.filter(h=>h.group==="server");if(p.length>0){i.push(" box rgb(240, 248, 255) Client");for(const h of p){i.push(` participant ${h.id} as ${h.icon} ${h.label}`)}i.push(" end")}if(g.length>0){i.push(" box rgb(255, 248, 240) External");for(const h of g){i.push(` participant ${h.id} as ${h.icon} ${h.label}`)}i.push(" end")}}else{for(const p of o){i.push(` participant ${p.id} as ${p.icon} ${p.label}`)}}i.push("");const s=r[r.length-1].timestamp-u;const c=r.filter(p=>p.source==="network");const l=c.reduce((p,g)=>{const h=g.originalEvent;const S=h?.responseSize||h?.size||0;return p+S},0);const f=r.filter(p=>p.status==="error").length;const d=[];d.push(`\u23F1\uFE0F ${formatMermaidDuration(s)}`);d.push(`\u{1F4CA} ${r.length} events`);if(c.length>0){d.push(`\u{1F310} ${c.length} API calls`)}if(l>0){d.push(`\u{1F4E6} ${formatBytes(l)}`)}if(f>0){d.push(`\u274C ${f} errors`)}i.push(` Note over U,API: ${d.join(" \xB7 ")}`);i.push("");const y=new Map;let $=0;for(const p of r){const g=formatMermaidEvent(p,t,u);if(g.skip){$++;continue}const{messages:h,notes:S}=g;let A=false;let x="";if(p.source==="network"){const m=p.originalEvent;const D=m?.url;if(D){const v=getCanonicalUrl(D);const E=y.get(v);if(E&&p.timestamp-E.timestamp<3e4){A=true;const b=p.timestamp-E.timestamp;const C=formatMermaidDuration(b);x=`\u26A0\uFE0F Already fetched ${C} ago`;y.set(v,{timestamp:p.timestamp,count:E.count+1})}else{y.set(v,{timestamp:p.timestamp,count:1})}}}if(A){i.push(" rect rgb(255, 245, 230)");i.push(` Note over App,API: ${x}`);for(const m of h){i.push(` ${m}`)}for(const m of S){i.push(` ${m}`)}i.push(" end")}else if(p.status==="error"){i.push(" rect rgb(255, 235, 235)");for(const m of h){i.push(` ${m}`)}for(const m of S){i.push(` ${m}`)}i.push(" end")}else{for(const m of h){i.push(` ${m}`)}for(const m of S){i.push(` ${m}`)}}}if($>0){i.push("");i.push(` Note over App: ${$} internal events hidden`)}return i.join("\n")}function generateExport(e,t){switch(t.format){case"markdown":return generateMarkdownExport(e,t);case"json":return generateJsonExport(e,t);case"plaintext":return generatePlaintextExport(e,t);case"mermaid":return generateMermaidExport(e,t);default:return generateMarkdownExport(e,t)}}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.estimateExportSize=estimateExportSize;exports.filterEvents=filterEvents;exports.generateExport=generateExport;exports.generateJsonExport=generateJsonExport;exports.generateMarkdownExport=generateMarkdownExport;exports.generateMermaidExport=generateMermaidExport;exports.generatePlaintextExport=generatePlaintextExport;exports.getExportSummary=getExportSummary;var _sharedUi=require("@buoy-gg/shared-ui");const STATUS_ICONS={success:"\u2705",pending:"\u23F3",error:"\u274C",neutral:"\u2796"};const STATUS_ICONS_ASCII={success:"[OK]",pending:"[...]",error:"[ERR]",neutral:"[-]"};const SOURCE_LABELS={"storage-async":"Storage","storage-mmkv":"MMKV",redux:"Redux",network:"Network","react-query":"Query","react-query-query":"Query","react-query-mutation":"Mutation",route:"Route",zustand:"Zustand",jotai:"Jotai",render:"Render",capacitor:"Capacitor",three:"Scene loads",socket:"Sockets"};function tryParseJson(e){if(typeof e!=="string")return e;const t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return e;try{return JSON.parse(e)}catch{return e}}function deepParseJsonStrings(e){if(e===null||e===void 0)return e;if(typeof e==="string"){return tryParseJson(e)}if(Array.isArray(e)){return e.map(deepParseJsonStrings)}if(typeof e==="object"){const t={};for(const[n,r]of Object.entries(e)){t[n]=deepParseJsonStrings(r)}return t}return e}const VERBOSE_FIELDS=new Set(["image","imageUrl","imageURL","image_url","thumbnail","thumbnailUrl","thumbnail_url","icon","iconUrl","avatar","avatarUrl","photo","photoUrl","picture","pictureUrl","description","desc","longDescription","shortDescription","meta_description"]);function stripVerboseFieldsFromObject(e){if(e===null||e===void 0)return e;if(Array.isArray(e)){return e.map(stripVerboseFieldsFromObject)}if(typeof e==="object"){const t={};for(const[n,r]of Object.entries(e)){if(VERBOSE_FIELDS.has(n))continue;if(typeof r==="string"&&isImageUrl(r))continue;t[n]=stripVerboseFieldsFromObject(r)}return t}return e}function isImageUrl(e){if(!e.startsWith("http"))return false;const t=e.toLowerCase();return t.includes("/photo")||t.includes("/image")||t.includes("unsplash.com")||t.includes("cloudinary.com")||t.includes("imgur.com")||/\.(jpg|jpeg|png|gif|webp|svg|bmp)(\?|$)/i.test(e)}function formatTimestampValue(e){if(e instanceof Date){return e.toISOString()}if(e&&typeof e==="object"&&Object.keys(e).length===0){return void 0}return e}function computeArrayDiff(e,t){const n=s=>{if(typeof s!=="object"||s===null)return null;const c=s;if(typeof c.id==="string")return c.id;if(typeof c.orderId==="string")return c.orderId;if(typeof c.key==="string")return c.key;return null};const r=new Set(e.map(n).filter(Boolean));const u=new Set(t.map(n).filter(Boolean));if(r.size===0&&u.size===0)return null;const o=t.filter(s=>{const c=n(s);return c&&!r.has(c)});const a=e.filter(s=>{const c=n(s);return c&&!u.has(c)});const i=t.length-o.length;if(o.length+a.length<e.length&&o.length+a.length<t.length){return{added:o,removed:a,unchanged:i}}return null}function formatStorageData(e,t){const n={};if(e.action)n.action=e.action;if(e.storageType)n.storageType=e.storageType;if(e.timestamp!==void 0){const r=formatTimestampValue(e.timestamp);if(r!==void 0){n.timestamp=r}}if(e.data){const r={...e.data};if(t.smartJsonParsing){if(r.value!==void 0){r.value=tryParseJson(r.value)}if(r.prevValue!==void 0){r.prevValue=tryParseJson(r.prevValue)}}if(t.showStorageDiff&&Array.isArray(r.value)&&Array.isArray(r.prevValue)){const u=computeArrayDiff(r.prevValue,r.value);if(u){const o={key:r.key};if(u.added.length>0){o.added=u.added}if(u.removed.length>0){o.removed=u.removed}if(u.unchanged>0){o.unchangedCount=u.unchanged}n.data=o;return n}}n.data=r}return n}function formatReduxData(e,t){if(!t.reduxChangedOnly){return t.smartJsonParsing?deepParseJsonStrings(e):e}const n={};if(e.type)n.type=e.type;if(e.payload)n.payload=t.smartJsonParsing?deepParseJsonStrings(e.payload):e.payload;if(e.sliceName)n.sliceName=e.sliceName;if(e.actionName)n.actionName=e.actionName;if(e.duration)n.duration=e.duration;if(e.hasStateChange!==void 0)n.hasStateChange=e.hasStateChange;if(e.diffSummary)n.diffSummary=e.diffSummary;if(e.changedKeysCount!==void 0)n.changedKeysCount=e.changedKeysCount;if(e.hasStateChange===true){const r=e.sliceName;if(r&&e.prevState&&e.nextState){const u=e.prevState;const o=e.nextState;if(u[r]!==void 0||o[r]!==void 0){n.stateChange={slice:r,before:u[r],after:o[r]}}}}return n}function getItemIdentifier(e){if(typeof e!=="object"||e===null)return null;const t=e;if(typeof t.name==="string")return t.name;if(typeof t.id==="string")return t.id;if(typeof t.key==="string")return t.key;return null}function generateStorageDiffSummary(e,t){const n=typeof e==="string"?tryParseJson(e):e;const r=typeof t==="string"?tryParseJson(t):t;if((n===null||n===void 0)&&r!==null&&r!==void 0)return"Created";if(n!==null&&n!==void 0&&(r===null||r===void 0))return"Deleted";if(Array.isArray(n)&&Array.isArray(r)){const u=n.length;const o=r.length;const a=n.map(getItemIdentifier).filter(Boolean);const i=r.map(getItemIdentifier).filter(Boolean);if(u===o&&u>0){const s=new Set(a);const c=new Set(i);const l=a.filter(f=>c.has(f));if(l.length===0&&a.length>0&&i.length>0){return`\u26A0\uFE0F Replaced: [${a.join(", ")}] \u2192 [${i.join(", ")}]`}if(l.length<u){const f=a.filter(y=>!c.has(y));const d=i.filter(y=>!s.has(y));return`Changed: -${f.join(", ")} +${d.join(", ")}`}}if(u===0&&o>0){if(i.length>0){return`Added: [${i.join(", ")}]`}return`Added ${o} item${o>1?"s":""}`}if(u>0&&o===0){if(a.length>0){return`Removed all: [${a.join(", ")}]`}return`Removed all ${u} item${u>1?"s":""}`}if(o>u){const s=new Set(a);const c=i.filter(l=>!s.has(l));if(c.length>0){return`Added: [${c.join(", ")}] (${u} \u2192 ${o})`}return`Added ${o-u} item${o-u>1?"s":""} (${u} \u2192 ${o})`}if(o<u){const s=new Set(i);const c=a.filter(l=>!s.has(l));if(c.length>0){return`Removed: [${c.join(", ")}] (${u} \u2192 ${o})`}return`Removed ${u-o} item${u-o>1?"s":""} (${u} \u2192 ${o})`}return`Updated (${o} item${o>1?"s":""})`}if(typeof n==="object"&&typeof r==="object"&&n&&r){const u=Object.keys(n);const o=Object.keys(r);const a=o.filter(s=>!u.includes(s));const i=u.filter(s=>!o.includes(s));if(a.length>0&&i.length>0){return`+${a.length} -${i.length} keys`}if(a.length>0)return`Added: ${a.join(", ")}`;if(i.length>0)return`Removed: ${i.join(", ")}`;return"Updated"}return null}function formatReactQueryData(e,t){const n={};if(e.id)n.id=e.id;if(e.type)n.type=e.type;if(e.timestamp)n.timestamp=e.timestamp;if(e.queryKey)n.queryKey=e.queryKey;if(e.mutationKey)n.mutationKey=e.mutationKey;if(e.mutationId)n.mutationId=e.mutationId;if(e.duration)n.duration=e.duration;if(e.queryData!==void 0){n.data=t.smartJsonParsing?deepParseJsonStrings(e.queryData):e.queryData}if(e.variables!==void 0){n.variables=t.smartJsonParsing?deepParseJsonStrings(e.variables):e.variables}if(e.queryError!==void 0){const r=e.queryError;if(r&&typeof r==="object"){n.error=r.message||r.name||r}else{n.error=e.queryError}}if(e.mutationError!==void 0){const r=e.mutationError;if(r&&typeof r==="object"){n.error=r.message||r.name||r}else{n.error=e.mutationError}}if(e.query&&typeof e.query==="object"){const r=e.query;if(r.state&&typeof r.state==="object"){const u=r.state;if(u.status)n.status=u.status;if(u.fetchStatus)n.fetchStatus=u.fetchStatus;if(u.error){const o=u.error;if(o&&typeof o==="object"){n.error=o.message||o.name||o}}}}if(e.mutation&&typeof e.mutation==="object"){const r=e.mutation;if(r.state&&typeof r.state==="object"){const u=r.state;if(u.status)n.status=u.status;if(u.failureCount)n.failureCount=u.failureCount;if(u.error){const o=u.error;if(o&&typeof o==="object"){n.error=o.message||o.name||o}}if(u.failureReason){const o=u.failureReason;if(o&&typeof o==="object"){n.failureReason=o.message||o.name||o}}}}return n}function formatEventData(e,t){const n=e.originalEvent;if(!n)return null;let r;if(e.source==="storage-async"||e.source==="storage-mmkv"){r=formatStorageData(n,t)}else if(e.source==="redux"){r=formatReduxData(n,t)}else if(e.source==="react-query"||e.source==="react-query-query"||e.source==="react-query-mutation"){r=formatReactQueryData(n,t)}else if(t.smartJsonParsing){r=deepParseJsonStrings(n)}else{r=n}if(t.stripVerboseFields&&r){r=stripVerboseFieldsFromObject(r)}return r}function getExportSummary(e){const t={totalEvents:e.length,success:0,pending:0,error:0,neutral:0,durationMs:0,sources:new Set};if(e.length===0)return t;let n=Infinity;let r=-Infinity;for(const u of e){t[u.status]++;t.sources.add(u.source);if(u.timestamp<n)n=u.timestamp;if(u.timestamp>r)r=u.timestamp}t.durationMs=r-n;return t}function filterEvents(e,t){let n=[...e];if(t.filterMode!=="all"){n=n.filter(r=>{switch(t.filterMode){case"errors":return r.status==="error";case"success":return r.status==="success";case"pending":return r.status==="pending";default:return true}})}if(t.filterSources.length>0){const r=new Set(t.filterSources);n=n.filter(u=>r.has(u.source))}return n}function formatRelativeTime(e){if(e<1e3)return`+${e}ms`;if(e<6e4)return`+${(e/1e3).toFixed(1)}s`;return`+${(e/6e4).toFixed(1)}m`}function formatAbsoluteTime(e){const t=new Date(e);return t.toISOString()}function formatTimestamp(e,t,n){const r=formatRelativeTime(e-t);const u=formatAbsoluteTime(e);switch(n){case"relative":return r;case"absolute":return u;case"both":return`${r} (${u})`}}function approxJsonBytesOver(e,t){let n=0;const r=[e];const u=new Set;while(r.length>0){if(n>t)return{over:true,approxBytes:n};const o=r.pop();if(o===null||o===void 0)n+=4;else if(typeof o==="string")n+=o.length+2;else if(typeof o==="number")n+=8;else if(typeof o==="boolean")n+=5;else if(typeof o==="object"){if(u.has(o))continue;u.add(o);if(Array.isArray(o)){n+=2+o.length;for(let a=0;a<o.length;a++)r.push(o[a])}else{n+=2;for(const a in o){n+=a.length+4;r.push(o[a])}}}else n+=4}return{over:n>t,approxBytes:n}}function truncateData(e,t){if(t===-1){return{data:e,truncated:false}}const{over:n,approxBytes:r}=approxJsonBytesOver(e,t*1024);if(n){return{data:`[Data truncated - \u2265${(r/1024).toFixed(1)}KB exceeds ${t}KB limit]`,truncated:true}}try{JSON.stringify(e);return{data:e,truncated:false}}catch{return{data:"[Unable to serialize data]",truncated:true}}}function estimateExportSize(e,t){let n=0;for(const r of e){if(t.includeSource)n+=20;if(t.includeStatus)n+=10;if(t.includeTitle)n+=(r.title?.length||0)+10;if(t.includeSubtitle)n+=(r.subtitle?.length||0)+10;if(t.includeCorrelation)n+=20;if(t.includeDuration)n+=15;n+=30;if(t.includeEventData&&r.originalEvent){const u=t.dataSizeThreshold===-1?1024*1024:t.dataSizeThreshold*1024;const{approxBytes:o}=approxJsonBytesOver(r.originalEvent,u);n+=Math.min(o,u)}}if(t.includeSummaryHeader)n+=100;if(t.includeTotalDuration)n+=50;if(t.format==="markdown")n*=1.2;if(t.format==="json")n*=1.3;return Math.round(n)}function formatCompactEvent(e,t,n){const r=[];const u=formatTimestamp(e.timestamp,t,n.timestampFormat);r.push(`\`${u}\``);if(n.includeStatus){r.push(STATUS_ICONS[e.status])}if(n.includeSource){r.push(`**${SOURCE_LABELS[e.source]}**`)}if(n.includeTitle){r.push(e.title)}if(n.showStorageDiff&&(e.source==="storage-async"||e.source==="storage-mmkv")){const o=e.originalEvent;if(o?.data){const a=o.data;const i=generateStorageDiffSummary(a.prevValue,a.value);if(i){r.push(`\u2192 ${i}`)}}}if(e.source==="redux"){const o=e.originalEvent;if(o?.hasStateChange===false){r.push("(no state change)")}}if(n.includeSubtitle&&e.subtitle){r.push(`- ${e.subtitle}`)}return r.join(" ")}function generateStorageDiffBlock(e,t){const n=[];const r=e.originalEvent;if(!r?.data)return n;const u=r.data;const o=t.smartJsonParsing?tryParseJson(u.prevValue):u.prevValue;const a=t.smartJsonParsing?tryParseJson(u.value):u.value;const i=generateStorageDiffSummary(u.prevValue,u.value);if(i){n.push(` **Change:** ${i}`)}if(Array.isArray(o)&&Array.isArray(a)){const s=o.map(l=>{if(typeof l==="object"&&l&&"name"in l)return l.name;return null}).filter(Boolean);const c=a.map(l=>{if(typeof l==="object"&&l&&"name"in l)return l.name;return null}).filter(Boolean);if(s.length>0||c.length>0){if(s.length>0){n.push(` Before: [${s.join(", ")}]`)}n.push(` After: [${c.join(", ")}]`)}}return n}function generateMarkdownExport(e,t){const n=filterEvents(e,t);if(n.length===0)return"No events to export.";const r=[...n].sort((s,c)=>s.timestamp-c.timestamp);const u=r[0].timestamp;const o=getExportSummary(r);const a=[];a.push("## Event Flow");if(t.includeSummaryHeader||t.includeTotalDuration){const s=[];if(t.includeTotalDuration){s.push(`**Duration:** ${formatRelativeTime(o.durationMs).replace("+","")}`)}s.push(`**Events:** ${o.totalEvents}`);if(t.includeSummaryHeader){const c=[];if(o.success>0)c.push(`${o.success} ${STATUS_ICONS.success}`);if(o.pending>0)c.push(`${o.pending} ${STATUS_ICONS.pending}`);if(o.error>0)c.push(`${o.error} ${STATUS_ICONS.error}`);if(o.neutral>0)c.push(`${o.neutral} ${STATUS_ICONS.neutral}`);if(c.length>0){s.push(`**Status:** ${c.join(" ")}`)}}a.push(s.join(" | "))}a.push("");a.push("### Timeline");a.push("");if(t.compactMode){r.forEach((s,c)=>{a.push(`${c+1}. ${formatCompactEvent(s,u,t)}`)});return a.join("\n")}r.forEach((s,c)=>{const l=[];const f=formatTimestamp(s.timestamp,u,t.timestampFormat);l.push(`${c+1}. \`${f}\``);if(t.includeStatus){l.push(STATUS_ICONS[s.status])}if(t.includeSource){l.push(`**${SOURCE_LABELS[s.source]}**`)}if(t.includeTitle){l.push(s.title)}if(t.includeCorrelation&&s.correlationId&&s.sequenceInGroup){l.push(`(${s.sequenceInGroup})`)}a.push(l.join(" "));if(t.includeSubtitle&&s.subtitle){a.push(` \u2514\u2500 ${s.subtitle}`)}if(t.showStorageDiff&&!t.includeEventData){if(s.source==="storage-async"||s.source==="storage-mmkv"){const d=generateStorageDiffBlock(s,t);a.push(...d)}}if(t.includeEventData&&s.originalEvent){const d=formatEventData(s,t);const{data:y,truncated:$}=truncateData(d,t.dataSizeThreshold);if($){a.push(` \u2514\u2500 ${y}`)}else{if(t.showStorageDiff&&(s.source==="storage-async"||s.source==="storage-mmkv")){const p=s.originalEvent;if(p?.data){const g=p.data;const h=generateStorageDiffSummary(g.prevValue,g.value);if(h){a.push(` **Change:** ${h}`)}}}a.push(" ```json");a.push(` ${JSON.stringify(y,null,2).split("\n").join("\n ")}`);a.push(" ```")}}a.push("")});const i=r.filter(s=>s.status==="error");if(i.length>0&&t.includeEventData){a.push("---");a.push("");a.push("### Errors");a.push("");for(const s of i){const c=formatTimestamp(s.timestamp,u,t.timestampFormat);a.push(`**${s.title}** (${c})`);if(s.originalEvent){const l=formatEventData(s,t);const{data:f,truncated:d}=truncateData(l,t.dataSizeThreshold);if(!d){a.push("```json");a.push(JSON.stringify(f,null,2));a.push("```")}}a.push("")}}return a.join("\n")}function generateJsonExport(e,t){const n=filterEvents(e,t);if(n.length===0)return"[]";const r=[...n].sort((i,s)=>i.timestamp-s.timestamp);const u=r[0].timestamp;const o=getExportSummary(r);const a={exportedAt:new Date().toISOString()};if(t.includeSummaryHeader){a.summary={totalEvents:o.totalEvents,success:o.success,pending:o.pending,error:o.error,neutral:o.neutral,durationMs:o.durationMs,sources:Array.from(o.sources)}}a.events=r.map(i=>{const s={};s.timestamp=formatAbsoluteTime(i.timestamp);if(t.timestampFormat==="relative"||t.timestampFormat==="both"){s.relativeMs=i.timestamp-u}if(t.includeSource)s.source=i.source;if(t.includeStatus)s.status=i.status;if(t.includeTitle)s.title=i.title;if(t.includeSubtitle)s.subtitle=i.subtitle;if(t.includeCorrelation&&i.correlationId){s.correlationId=i.correlationId;s.sequenceInGroup=i.sequenceInGroup}if(t.includeEventData&&i.originalEvent){const c=formatEventData(i,t);const{data:l,truncated:f}=truncateData(c,t.dataSizeThreshold);s.data=l;if(f)s.dataTruncated=true;if(t.showStorageDiff&&(i.source==="storage-async"||i.source==="storage-mmkv")){const d=i.originalEvent;if(d?.data){const y=d.data;const $=generateStorageDiffSummary(y.prevValue,y.value);if($){s.changeSummary=$}}}}return s});return JSON.stringify(a,null,2)}function generatePlaintextExport(e,t){const n=filterEvents(e,t);if(n.length===0)return"No events to export.";const r=[...n].sort((i,s)=>i.timestamp-s.timestamp);const u=r[0].timestamp;const o=getExportSummary(r);const a=[];if(t.includeSummaryHeader||t.includeTotalDuration){const i=[`Event Flow (${o.totalEvents} events`];if(t.includeTotalDuration){i[0]+=`, ${formatRelativeTime(o.durationMs).replace("+","")}`}i[0]+=")";a.push(i[0]);if(t.includeSummaryHeader){const s=[];if(o.success>0)s.push(`${o.success} success`);if(o.pending>0)s.push(`${o.pending} pending`);if(o.error>0)s.push(`${o.error} error`);if(o.neutral>0)s.push(`${o.neutral} neutral`);if(s.length>0){a.push(s.join(", "))}}a.push("")}for(const i of r){const s=[];const c=formatTimestamp(i.timestamp,u,t.timestampFormat);s.push(c.padEnd(12));if(t.includeStatus){s.push(STATUS_ICONS_ASCII[i.status])}if(t.includeSource){s.push(`${SOURCE_LABELS[i.source]}:`)}if(t.includeTitle){s.push(i.title)}if(t.showStorageDiff&&(i.source==="storage-async"||i.source==="storage-mmkv")){const l=i.originalEvent;if(l?.data){const f=l.data;const d=generateStorageDiffSummary(f.prevValue,f.value);if(d){s.push(`-> ${d}`)}}}if(i.source==="redux"){const l=i.originalEvent;if(l?.hasStateChange===false){s.push("(no change)")}}if(t.includeSubtitle&&i.subtitle){s.push(`- ${i.subtitle}`)}a.push(s.join(" "));if(t.includeEventData&&i.originalEvent){const l=formatEventData(i,t);const{data:f,truncated:d}=truncateData(l,t.dataSizeThreshold);if(d){a.push(` ${f}`)}else{a.push(` Data: ${JSON.stringify(f)}`)}}}return a.join("\n")}const MERMAID_PARTICIPANTS=[{id:"U",icon:"\u{1F464}",label:"User",sources:[],group:"client"},{id:"App",icon:"\u{1F4F1}",label:"App",sources:["route","render"],group:"client"},{id:"Async",icon:"\u{1F4BE}",label:"AsyncStorage",sources:["storage-async"],group:"client"},{id:"MMKV",icon:"\u26A1",label:"MMKV",sources:["storage-mmkv"],group:"client"},{id:"Redux",icon:"\u{1F504}",label:"Redux",sources:["redux"],group:"client"},{id:"API",icon:"\u{1F310}",label:"API",sources:["network"],group:"server"},{id:"Cache",icon:"\u{1F4E6}",label:"QueryCache",sources:["react-query","react-query-query","react-query-mutation"],group:"server"}];function getParticipantId(e){const t=MERMAID_PARTICIPANTS.find(n=>n.sources.includes(e));return t?.id||"App"}function detectParticipants(e){const t=new Set;for(const r of e){t.add(r.source)}const n=[];n.push(MERMAID_PARTICIPANTS[0]);n.push(MERMAID_PARTICIPANTS[1]);for(const r of MERMAID_PARTICIPANTS.slice(2)){if(r.sources.some(u=>t.has(u))){n.push(r)}}return n}function shouldUseGroups(e){const t=e.some(r=>r.group==="client");const n=e.some(r=>r.group==="server");return t&&n&&e.length>=3}function formatMermaidDuration(e){if(e<1e3)return`${e}ms`;if(e<6e4)return`${(e/1e3).toFixed(1)}s`;return`${(e/6e4).toFixed(1)}m`}function escapeMermaidText(e){return e.replace(/[#;:]/g," ").replace(/[\n\r]/g," ").replace(/"/g,"'").replace(/\s+/g," ").trim()}function isInternalStorageKey(e){if((0,_sharedUi.isDevToolsStorageKey)(e))return true;const t=["last-route","@dev/last","__debug","_persist","devtools/internal"];const n=e.toLowerCase();return t.some(r=>n.includes(r))}function formatBytes(e){if(e<1024)return`${e}B`;if(e<1024*1024)return`${(e/1024).toFixed(1)}KB`;return`${(e/(1024*1024)).toFixed(1)}MB`}function estimateDataSize(e){return approxJsonBytesOver(e,1024*1024).approxBytes}function getCanonicalUrl(e){try{const t=new URL(e,"http://localhost");const n=["timestamp","t","_t","debug","client","version","cache","_"];n.forEach(r=>t.searchParams.delete(r));return t.pathname+(t.searchParams.toString()?"?"+t.searchParams.toString():"")}catch{return e}}function getStorageKeyName(e){let t=e.replace(/^@[\w-]+\//,"").replace(/^devtools\//,"").replace(/^dev\//,"").replace(/^buoy\//,"").replace(/^pokemon\//,"");const n=t.split("/").filter(Boolean);if(n.length>1){t=n.slice(-1).join("/")}t=t.replace(/-/g," ").replace(/_/g," ");t=t.split(" ").map(r=>r.charAt(0).toUpperCase()+r.slice(1).toLowerCase()).join(" ");if(t.toLowerCase()==="saved")t="Favorites";return t.substring(0,20)}function extractEntityFromPath(e){let t=e;try{const r=new URL(e,"http://localhost");t=r.pathname}catch{const r=t.indexOf("?");if(r>0){t=t.substring(0,r)}}const n=t.split("/").filter(Boolean);if(n.length>=2){const r=n[n.length-1];if(/^\d+$/.test(r)||/^[a-f0-9-]{36}$/i.test(r)){return null}return r.charAt(0).toUpperCase()+r.slice(1)}if(n.length===1){return n[0].charAt(0).toUpperCase()+n[0].slice(1)}return null}function getHumanReadableApiAction(e,t){try{const n=new URL(t,"http://localhost");let r=n.pathname;if(r.includes("graphql")){return"GraphQL Request"}r=r.replace(/^\/api\/v\d+/,"").replace(/^\/api/,"");const u=extractEntityFromPath(r);const o=r.split("/").filter(Boolean);const a=o[0]?o[0].charAt(0).toUpperCase()+o[0].slice(1):"Data";const i=n.searchParams.has("q")||n.searchParams.has("query")||n.searchParams.has("search");switch(e.toUpperCase()){case"GET":if(i){const s=n.searchParams.get("q")||n.searchParams.get("query")||n.searchParams.get("search");if(s)return`Search "${s}"`;return`Search ${a}`}if(u)return`Fetch ${u}`;return`Fetch ${a}`;case"POST":if(r.includes("search"))return`Search ${a}`;if(u)return`Create ${u}`;return`Create ${a}`;case"PUT":case"PATCH":if(u)return`Update ${u}`;return`Update ${a}`;case"DELETE":if(u)return`Delete ${u}`;return`Delete ${a}`;default:return`${e} ${a}`}}catch{return`${e} request`}}function getHumanReadableRoute(e){if(e==="/"||e==="")return"Home";const t=e.split("/").filter(Boolean);if(t.length===0)return"Home";if(t.length===1){const n=t[0].charAt(0).toUpperCase()+t[0].slice(1);return`${n} List`}if(t.length>=2){const n=t[t.length-1];if(/^\d+$/.test(n)){const u=t[0].charAt(0).toUpperCase()+t[0].slice(1);return`${u} #${n}`}const r=n.charAt(0).toUpperCase()+n.slice(1);return`${r} Details`}return e}function formatMermaidEvent(e,t,n){const r=[];const u=[];const o=formatMermaidDuration(e.timestamp-n);switch(e.source){case"route":{const a=e.originalEvent;const i=String(a?.pathname||e.title);const s=a?.previousPathname;const c=a?.timeSincePrevious;const l=getHumanReadableRoute(i);const f=s?getHumanReadableRoute(s):null;if(f){r.push(`U->>App: ${f} \u2192 ${l}`);if(c&&c>0){u.push(`Note right of App: ${formatMermaidDuration(c)} on ${f}`)}}else{r.push(`U->>App: Open ${l}`)}break}case"network":{const a=e.originalEvent;const i=a?.method||"GET";const s=a?.url||"";const c=a?.status;const l=a?.duration;const f=a?.response||a?.data||a?.body;const d=a?.responseSize||a?.size||a?.contentLength;const y=getHumanReadableApiAction(i,s);const $=extractEntityFromPath(s);r.push(`App->>+API: ${y}`);if(e.status==="error"){const g=c?`${c} Error`:"Failed";r.push(`API--x-App: ${g}`)}else{let g=$?`\u2713 ${$}`:"\u2713 Success";r.push(`API-->>-App: ${g}`)}const p=[];if(l){p.push(formatMermaidDuration(l))}if(d&&d>0){p.push(formatBytes(d))}else if(f){const g=estimateDataSize(f);if(g>1024){p.push(formatBytes(g))}}if(p.length>0){u.push(`Note right of API: ${p.join(" \xB7 ")}`)}break}case"storage-async":case"storage-mmkv":{const a=e.originalEvent;const i=a?.data;const s=a?.action||"access";const c=i?.key||"data";if(isInternalStorageKey(c)){return{messages:[],notes:[],skip:true}}const l=getStorageKeyName(c);const f=e.source==="storage-mmkv"?"MMKV":"Async";const d=m=>{if(typeof m==="string")return m;if(typeof m==="number")return String(m);if(typeof m==="object"&&m){if("name"in m)return String(m.name);if("id"in m)return String(m.id)}return null};const y=m=>m.charAt(0).toUpperCase()+m.slice(1);let $="";let p="";let g="";let h="";const S=i?.prevValue;const A=i?.value;if(Array.isArray(S)&&Array.isArray(A)){const m=S.length;const D=A.length;h=`${m} \u2192 ${D} items`;if(D>m){$="\u2795";p="Add";const v=new Set(S.map(d).filter(Boolean));for(const E of A){const b=d(E);if(b&&!v.has(b)){g=y(b);break}}}else if(D<m){$="\u2796";p="Remove";const v=new Set(A.map(d).filter(Boolean));for(const E of S){const b=d(E);if(b&&!v.has(b)){g=y(b);break}}}else{$="\u{1F4DD}";p="Update"}}else if(Array.isArray(A)&&(!S||Array.isArray(S)&&S.length===0)){$="\u2795";p="Add";h=`\u2192 ${A.length} items`;if(A.length>0){const m=d(A[0]);if(m)g=y(m)}}else if(Array.isArray(S)&&(!A||Array.isArray(A)&&A.length===0)){$="\u2796";p="Clear";h=`${S.length} \u2192 0 items`}else if(s==="getItem"){$="\u{1F4D6}";p="Load"}else if(s==="removeItem"){$="\u2796";p="Remove"}else if(s==="clear"){$="\u{1F5D1}\uFE0F";p="Clear"}else{$="\u{1F4BE}";p="Save"}let x;if(g){x=`App->>${f}: ${$} ${p} ${g} \u2192 ${l}`}else{x=`App->>${f}: ${$} ${p} ${l}`}r.push(x);if(h){u.push(`Note right of ${f}: ${h}`)}break}case"react-query":case"react-query-query":{const a=e.originalEvent;const i=a?.type||"";const s=a?.queryKey;const c=a?.duration;let l="data";if(Array.isArray(s)&&s.length>0){const f=s[s.length-1];if(typeof f==="string"&&!/^\d+$/.test(f)){l=f.charAt(0).toUpperCase()+f.slice(1)}else if(s.length>1&&typeof s[0]==="string"){l=s[0].charAt(0).toUpperCase()+s[0].slice(1)}}if(i.includes("start")||i.includes("fetch")||e.status==="pending"){r.push(`App->>+Cache: Fetch ${l}`)}else if(e.status==="error"){r.push(`Cache--x-App: Failed to load`)}else if(e.status==="success"){let f=`\u2713 ${l} ready`;if(c){f+=` (${formatMermaidDuration(c)})`}r.push(`Cache-->>-App: ${f}`)}else if(i.includes("invalidate")){r.push(`App->>Cache: Refresh ${l}`)}else{r.push(`Cache-->>App: ${escapeMermaidText(i)}`)}break}case"react-query-mutation":{const a=e.originalEvent;const i=a?.type||"";const s=a?.mutationKey;const c=a?.duration;let l="Update";if(Array.isArray(s)&&s.length>0){const f=String(s[0]);if(f.includes("add")||f.includes("create"))l="Add";else if(f.includes("delete")||f.includes("remove"))l="Delete";else if(f.includes("update")||f.includes("edit"))l="Update";else l=f.charAt(0).toUpperCase()+f.slice(1)}if(i.includes("start")||i.includes("loading")||e.status==="pending"){r.push(`App->>+Cache: ${l}`)}else if(e.status==="error"){r.push(`Cache--x-App: ${l} failed`)}else if(e.status==="success"){let f=`\u2713 ${l} complete`;if(c){f+=` (${formatMermaidDuration(c)})`}r.push(`Cache-->>-App: ${f}`)}break}case"redux":{const a=e.originalEvent;const i=a?.type||e.title;const s=a?.hasStateChange;const c=a?.diffSummary;const l=i.split("/");let f;if(l.length>=2){const d=l[0].charAt(0).toUpperCase()+l[0].slice(1);let y=l[1].replace(/([A-Z])/g," $1").replace(/(pending|fulfilled|rejected)$/i,"").trim();y=y.charAt(0).toUpperCase()+y.slice(1);f=`${y} (${d})`}else{f=escapeMermaidText(i).substring(0,25)}r.push(`App->>Redux: ${f}`);if(s===false){u.push(`Note right of Redux: No change`)}else if(c){u.push(`Note right of Redux: ${escapeMermaidText(c).substring(0,35)}`)}break}case"render":{const a=e.originalEvent;const i=a?.renderData;const s=escapeMermaidText(e.title).substring(0,20);const c=i?.cause||"update";const l=c==="mount"?"mounted":c==="props"?"props changed":c==="state"?"state changed":c==="context"?"context changed":c==="parent"?"parent re-rendered":c==="hooks"?"hook changed":c;r.push(`App->>App: Render ${s}`);u.push(`Note right of App: ${l}`);break}default:{r.push(`App->>App: ${escapeMermaidText(e.title).substring(0,30)}`)}}return{messages:r,notes:u}}function generateMermaidExport(e,t){const n=filterEvents(e,t);if(n.length===0){return"sequenceDiagram\n participant U as \u{1F464} User\n participant App as \u{1F4F1} App\n Note over U,App: No events captured"}const r=[...n].sort((p,g)=>p.timestamp-g.timestamp);const u=r[0].timestamp;const o=detectParticipants(r);const a=shouldUseGroups(o);const i=["sequenceDiagram"];i.push(" autonumber");i.push("");if(a){const p=o.filter(h=>h.group==="client");const g=o.filter(h=>h.group==="server");if(p.length>0){i.push(" box rgb(240, 248, 255) Client");for(const h of p){i.push(` participant ${h.id} as ${h.icon} ${h.label}`)}i.push(" end")}if(g.length>0){i.push(" box rgb(255, 248, 240) External");for(const h of g){i.push(` participant ${h.id} as ${h.icon} ${h.label}`)}i.push(" end")}}else{for(const p of o){i.push(` participant ${p.id} as ${p.icon} ${p.label}`)}}i.push("");const s=r[r.length-1].timestamp-u;const c=r.filter(p=>p.source==="network");const l=c.reduce((p,g)=>{const h=g.originalEvent;const S=h?.responseSize||h?.size||0;return p+S},0);const f=r.filter(p=>p.status==="error").length;const d=[];d.push(`\u23F1\uFE0F ${formatMermaidDuration(s)}`);d.push(`\u{1F4CA} ${r.length} events`);if(c.length>0){d.push(`\u{1F310} ${c.length} API calls`)}if(l>0){d.push(`\u{1F4E6} ${formatBytes(l)}`)}if(f>0){d.push(`\u274C ${f} errors`)}i.push(` Note over U,API: ${d.join(" \xB7 ")}`);i.push("");const y=new Map;let $=0;for(const p of r){const g=formatMermaidEvent(p,t,u);if(g.skip){$++;continue}const{messages:h,notes:S}=g;let A=false;let x="";if(p.source==="network"){const m=p.originalEvent;const D=m?.url;if(D){const v=getCanonicalUrl(D);const E=y.get(v);if(E&&p.timestamp-E.timestamp<3e4){A=true;const b=p.timestamp-E.timestamp;const C=formatMermaidDuration(b);x=`\u26A0\uFE0F Already fetched ${C} ago`;y.set(v,{timestamp:p.timestamp,count:E.count+1})}else{y.set(v,{timestamp:p.timestamp,count:1})}}}if(A){i.push(" rect rgb(255, 245, 230)");i.push(` Note over App,API: ${x}`);for(const m of h){i.push(` ${m}`)}for(const m of S){i.push(` ${m}`)}i.push(" end")}else if(p.status==="error"){i.push(" rect rgb(255, 235, 235)");for(const m of h){i.push(` ${m}`)}for(const m of S){i.push(` ${m}`)}i.push(" end")}else{for(const m of h){i.push(` ${m}`)}for(const m of S){i.push(` ${m}`)}}}if($>0){i.push("");i.push(` Note over App: ${$} internal events hidden`)}return i.join("\n")}function generateExport(e,t){switch(t.format){case"markdown":return generateMarkdownExport(e,t);case"json":return generateJsonExport(e,t);case"plaintext":return generatePlaintextExport(e,t);case"mermaid":return generateMermaidExport(e,t);default:return generateMarkdownExport(e,t)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{loadToolModule as d,getToolModuleVersion as h}from"@buoy-gg/shared-ui/utils";import{View as a,Text as u,StyleSheet as B,ScrollView as D}from"react-native";import{memo as F,useMemo as x}from"react";import{night as c,formatRelativeTime as A,copyToClipboard as $,parseValue as j,useIgnoredPatterns as z,monoFont as N}from"@buoy-gg/shared-ui";import{DataViewer as P}from"@buoy-gg/shared-ui/dataViewer";import{ReactQueryEventDetail as q}from"./ReactQueryEventDetail";import{EVENTS_TEST_ID as i}from"../utils/testIDs";import{Fragment as L,jsx as e,jsxs as g}from"react/jsx-runtime";function M(){const r={StorageEventDetailContent:null,ReduxActionDetailContent:null,NetworkEventDetailView:null,RenderDetailView:null,ZustandStateDetailContent:null,JotaiAtomDetailContent:null,RouteEventDetail:null};try{const t=d("@buoy-gg/storage");r.StorageEventDetailContent=t.StorageEventDetailContent}catch{}try{const t=d("@buoy-gg/redux");r.ReduxActionDetailContent=t.ReduxActionDetailContent}catch{}try{const t=d("@buoy-gg/network");r.NetworkEventDetailView=t.NetworkEventDetailView}catch{}try{const t=d("@buoy-gg/highlight-updates");r.RenderDetailView=t.RenderDetailView}catch{}try{const t=d("@buoy-gg/zustand");r.ZustandStateDetailContent=t.ZustandStateDetailContent}catch{}try{const t=d("@buoy-gg/jotai");r.JotaiAtomDetailContent=t.JotaiAtomDetailContent}catch{}try{const t=d("@buoy-gg/route-events");r.RouteEventDetail=t.RouteEventDetail}catch{}return r}let p;let S=-1;function W(){if(!p||S!==h()){p=M();S=h()}return p}const J={"storage-async":{label:"AsyncStorage",color:"#8B5CF6"},"storage-mmkv":{label:"MMKV",color:"#F59E0B"},redux:{label:"Redux",color:"#3B82F6"},network:{label:"Network",color:"#10B981"},"react-query":{label:"React Query",color:"#EC4899"},"react-query-query":{label:"Query",color:"#EC4899"},"react-query-mutation":{label:"Mutation",color:"#F97316"},route:{label:"Route",color:"#06B6D4"},zustand:{label:"Zustand",color:"#764ABC"},jotai:{label:"Jotai",color:"#14B8A6"},render:{label:"Render",color:"#F472B6"},three:{label:"Scene loads",color:"#F59E0B"},capacitor:{label:"Capacitor",color:"#119EFF"}};function O(r){return r==="storage-async"||r==="storage-mmkv"}function Z(r){const t=j(r);if(t===null)return"null";if(t===void 0)return"undefined";if(Array.isArray(t))return"array";if(typeof t==="boolean")return"boolean";if(typeof t==="number")return"number";if(typeof t==="string")return"string";if(typeof t==="object")return"object";return"undefined"}function _({children:r}){return e(L,{children:r})}export const UnifiedEventDetail=F(function r({event:t,onBack:U,NetworkEventDetailViewComponent:I,networkDetailWrapper:R,RouteEventDetailComponent:
|
|
1
|
+
"use strict";import{loadToolModule as d,getToolModuleVersion as h}from"@buoy-gg/shared-ui/utils";import{View as a,Text as u,StyleSheet as B,ScrollView as D}from"react-native";import{memo as F,useMemo as x}from"react";import{night as c,formatRelativeTime as A,copyToClipboard as $,parseValue as j,useIgnoredPatterns as z,monoFont as N}from"@buoy-gg/shared-ui";import{DataViewer as P}from"@buoy-gg/shared-ui/dataViewer";import{ReactQueryEventDetail as q}from"./ReactQueryEventDetail";import{EVENTS_TEST_ID as i}from"../utils/testIDs";import{Fragment as L,jsx as e,jsxs as g}from"react/jsx-runtime";function M(){const r={StorageEventDetailContent:null,ReduxActionDetailContent:null,NetworkEventDetailView:null,RenderDetailView:null,ZustandStateDetailContent:null,JotaiAtomDetailContent:null,RouteEventDetail:null};try{const t=d("@buoy-gg/storage");r.StorageEventDetailContent=t.StorageEventDetailContent}catch{}try{const t=d("@buoy-gg/redux");r.ReduxActionDetailContent=t.ReduxActionDetailContent}catch{}try{const t=d("@buoy-gg/network");r.NetworkEventDetailView=t.NetworkEventDetailView}catch{}try{const t=d("@buoy-gg/highlight-updates");r.RenderDetailView=t.RenderDetailView}catch{}try{const t=d("@buoy-gg/zustand");r.ZustandStateDetailContent=t.ZustandStateDetailContent}catch{}try{const t=d("@buoy-gg/jotai");r.JotaiAtomDetailContent=t.JotaiAtomDetailContent}catch{}try{const t=d("@buoy-gg/route-events");r.RouteEventDetail=t.RouteEventDetail}catch{}return r}let p;let S=-1;function W(){if(!p||S!==h()){p=M();S=h()}return p}const J={"storage-async":{label:"AsyncStorage",color:"#8B5CF6"},"storage-mmkv":{label:"MMKV",color:"#F59E0B"},redux:{label:"Redux",color:"#3B82F6"},network:{label:"Network",color:"#10B981"},"react-query":{label:"React Query",color:"#EC4899"},"react-query-query":{label:"Query",color:"#EC4899"},"react-query-mutation":{label:"Mutation",color:"#F97316"},route:{label:"Route",color:"#06B6D4"},zustand:{label:"Zustand",color:"#764ABC"},jotai:{label:"Jotai",color:"#14B8A6"},render:{label:"Render",color:"#F472B6"},three:{label:"Scene loads",color:"#F59E0B"},socket:{label:"Sockets",color:"#20C997"},capacitor:{label:"Capacitor",color:"#119EFF"}};function O(r){return r==="storage-async"||r==="storage-mmkv"}function Z(r){const t=j(r);if(t===null)return"null";if(t===void 0)return"undefined";if(Array.isArray(t))return"array";if(typeof t==="boolean")return"boolean";if(typeof t==="number")return"number";if(typeof t==="string")return"string";if(typeof t==="object")return"object";return"undefined"}function _({children:r}){return e(L,{children:r})}export const UnifiedEventDetail=F(function r({event:t,onBack:U,NetworkEventDetailViewComponent:I,networkDetailWrapper:R,RouteEventDetailComponent:k,detailComponents:b,onNavigate:T}){const l=x(()=>({...W(),...b}),[b,h()]);const m=J[t.source];const y=new Date(t.timestamp);const{values:v,toggle:V}=z();const f=x(()=>{if(!O(t.source))return null;if(!l.StorageEventDetailContent)return null;const s=t.originalEvent;const n={...s,timestamp:new Date(s.timestamp)};return{key:n.data?.key||"unknown",lastEvent:n,events:[n],totalOperations:1,currentValue:n.data?.value,valueType:Z(n.data?.value),storageTypes:new Set([n.storageType||"async"])}},[t,l]);if(f&&l.StorageEventDetailContent){const{StorageEventDetailContent:s}=l;return e(a,{style:o.container,testID:`${i}-detail-storage`,children:e(s,{conversation:f,selectedEventIndex:0,onEventIndexChange:()=>{},disableInternalFooter:true})})}if(t.source==="redux"&&l.ReduxActionDetailContent){const{ReduxActionDetailContent:s}=l;const n=t.originalEvent;return e(a,{style:o.container,testID:`${i}-detail-redux`,children:e(s,{action:n,actions:[n],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}const C=I??l.NetworkEventDetailView;if(t.source==="network"&&C){const s=t.originalEvent;const n=R??_;return e(a,{style:o.container,children:e(n,{children:e(D,{keyboardShouldPersistTaps:"handled",style:o.content,testID:`${i}-detail-network`,children:e(C,{event:s,ignoredPatterns:v,onTogglePattern:V})})})})}if(t.source==="react-query"||t.source==="react-query-query"||t.source==="react-query-mutation"){return e(a,{style:o.container,testID:`${i}-detail-react-query`,children:e(q,{event:t})})}if(t.source==="zustand"&&l.ZustandStateDetailContent){const{ZustandStateDetailContent:s}=l;const n=t.originalEvent;return e(a,{style:o.container,testID:`${i}-detail-zustand`,children:e(s,{change:n,changes:[n],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}if(t.source==="jotai"&&l.JotaiAtomDetailContent){const{JotaiAtomDetailContent:s}=l;const n=t.originalEvent;return e(a,{style:o.container,testID:`${i}-detail-jotai`,children:e(s,{change:n,changes:[n],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}if(t.source==="render"&&l.RenderDetailView){const{RenderDetailView:s}=l;const n=t.originalEvent;return e(a,{style:o.container,children:e(D,{keyboardShouldPersistTaps:"handled",style:o.content,testID:`${i}-detail-render`,children:e(s,{render:n.render})})})}const w=k??l.RouteEventDetail;if(t.source==="route"&&w){return e(a,{style:o.container,children:e(a,{style:o.container,testID:`${i}-detail-route`,children:e(w,{event:t.originalEvent,onNavigate:T})})})}const E=()=>{return t.originalEvent};const Q=async()=>{await $({source:t.source,timestamp:y.toISOString(),title:t.title,subtitle:t.subtitle,data:E()})};return e(a,{style:o.container,testID:`${i}-detail`,children:g(D,{keyboardShouldPersistTaps:"handled",style:o.content,contentContainerStyle:o.contentContainer,testID:`${i}-detail-scroll`,children:[e(a,{style:o.sourceBadgeRow,children:g(a,{style:[o.sourceBadge,{backgroundColor:m.color+"20"}],children:[e(a,{style:[o.sourceDot,{backgroundColor:m.color}]}),e(u,{style:[o.sourceLabel,{color:m.color}],testID:`${i}-detail-source`,children:m.label})]})}),e(u,{style:o.title,testID:`${i}-detail-title`,children:t.title}),e(u,{style:o.subtitle,testID:`${i}-detail-subtitle`,children:t.subtitle}),g(a,{style:o.timestampRow,children:[e(u,{style:o.timestampLabel,children:"Timestamp"}),g(u,{style:o.timestampValue,testID:`${i}-detail-timestamp`,children:[y.toLocaleTimeString()," (",A(y),")"]})]}),g(a,{style:o.dataSection,children:[e(u,{style:o.sectionLabel,children:"Event Data"}),e(a,{style:o.dataContainer,testID:`${i}-detail-data`,children:e(P,{testIDPrefix:`${i}-detail-data`,data:E(),title:"",showTypeFilter:true,rawMode:true,initialExpanded:true})})]})]})})});const o=B.create({container:{flex:1,backgroundColor:"transparent"},content:{flex:1},contentContainer:{padding:16},sourceBadgeRow:{flexDirection:"row",marginBottom:12},sourceBadge:{flexDirection:"row",alignItems:"center",paddingHorizontal:10,paddingVertical:6,borderRadius:12,gap:6},sourceDot:{width:6,height:6,borderRadius:3},sourceLabel:{fontSize:12,fontWeight:"600"},title:{fontSize:24,fontWeight:"700",color:c.color.text,marginBottom:4},subtitle:{fontSize:16,color:c.color.textTertiary,marginBottom:16},timestampRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,borderTopWidth:1,borderTopColor:c.color.border,borderBottomWidth:1,borderBottomColor:c.color.border,marginBottom:16},timestampLabel:{fontSize:14,color:c.color.textTertiary},timestampValue:{fontSize:14,color:c.color.text,fontFamily:N},dataSection:{marginTop:8},sectionLabel:{fontSize:12,fontWeight:"600",color:c.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8},dataContainer:{backgroundColor:c.color.surface,borderRadius:8,borderWidth:1,borderColor:c.color.border,overflow:"hidden"}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{loadToolModule as s,getToolModuleVersion as
|
|
1
|
+
"use strict";import{loadToolModule as s,getToolModuleVersion as R}from"@buoy-gg/shared-ui/utils";import{memo as v}from"react";import{View as m,Text as N,StyleSheet as O}from"react-native";import{CompactRow as F,formatRelativeTime as U,Pill as V}from"@buoy-gg/shared-ui";import{eventRowTestID as j}from"../utils/testIDs";import{jsx as o,jsxs as z}from"react/jsx-runtime";function q(){const e={StorageEventCard:null,getValueType:null,ReduxActionItem:null,NetworkEventItemCompact:null,RouteEventItemCompact:null,ZustandStateChangeItem:null,JotaiAtomChangeItem:null};try{const t=s("@buoy-gg/storage");e.StorageEventCard=t.StorageEventCard;e.getValueType=t.getValueType}catch{}try{const t=s("@buoy-gg/redux");e.ReduxActionItem=t.ReduxActionItem}catch{}try{const t=s("@buoy-gg/network");e.NetworkEventItemCompact=t.NetworkEventItemCompact}catch{}try{const t=s("@buoy-gg/route-events");e.RouteEventItemCompact=t.RouteEventItemCompact}catch{}try{const t=s("@buoy-gg/zustand");e.ZustandStateChangeItem=t.ZustandStateChangeItem}catch{}try{const t=s("@buoy-gg/jotai");e.JotaiAtomChangeItem=t.JotaiAtomChangeItem}catch{}return e}let g;let x=-1;function M(){if(!g||x!==R()){g=q();x=R()}return g}const B={"storage-async":{label:"Storage",color:"#8B5CF6"},"storage-mmkv":{label:"MMKV",color:"#F59E0B"},redux:{label:"Redux",color:"#3B82F6"},network:{label:"Network",color:"#10B981"},"react-query":{label:"Query",color:"#EC4899"},"react-query-query":{label:"Query",color:"#EC4899"},"react-query-mutation":{label:"Mutation",color:"#F97316"},route:{label:"Route",color:"#06B6D4"},zustand:{label:"Zustand",color:"#764ABC"},jotai:{label:"Jotai",color:"#14B8A6"},render:{label:"Render",color:"#F472B6"},three:{label:"Scene loads",color:"#F59E0B"},socket:{label:"Sockets",color:"#20C997"},capacitor:{label:"Capacitor",color:"#119EFF"}};function J(e){switch(e){case"success":return"#10B981";case"error":return"#EF4444";case"pending":return"#F59E0B";case"neutral":default:return"#6B7280"}}function Z(e){return e==="storage-async"||e==="storage-mmkv"}function _({label:e,color:t,testID:r}){return o(V,{label:e,color:t,variant:"soft",size:"sm",style:{marginLeft:6},testID:r})}const Q={"storage-async":"STORAGE","storage-mmkv":"MMKV",redux:"REDUX",network:"NET","react-query":"QUERY","react-query-query":"QUERY","react-query-mutation":"MUTATION",route:"ROUTE",zustand:"ZUSTAND",jotai:"JOTAI",render:"RENDER",capacitor:"CAPACITOR",three:"SCENE",socket:"SOCKET"};function u({source:e,testID:t,children:r}){const c=B[e].color;const l=Q[e];return z(m,{style:p.badgeWrapper,testID:t,children:[r,o(m,{style:[p.sourceBadge,{backgroundColor:`${c}20`}],children:o(N,{style:[p.sourceBadgeText,{color:c}],testID:t?`${t}-badge`:void 0,children:l})})]})}export const UnifiedEventItem=v(function e({event:t,onPress:r,isSelected:c=false,isExpanded:l=false,onNavigate:k,correlationCount:E=1,correlationLabel:i,correlationColor:d}){const{StorageEventCard:y,getValueType:C,ReduxActionItem:I,NetworkEventItemCompact:b,RouteEventItemCompact:f,ZustandStateChangeItem:h,JotaiAtomChangeItem:T}=M();const S=B[t.source];const w=J(t.status);const n=j(t);if(Z(t.source)&&y&&C){const a=t.originalEvent;const D={key:a.data?.key||"unknown",lastAction:a.action,totalOperations:1,lastEventTimestamp:new Date(t.timestamp),storageTypes:new Set([a.storageType||"async"]),valueType:a.data?.value!==void 0?C(a.data.value):void 0};return o(u,{source:t.source,testID:n,children:o(y,{data:D,onPress:r,isSelected:c})})}if(t.source==="redux"&&I){const a=t.originalEvent;return o(u,{source:t.source,testID:n,children:o(I,{action:a,onPress:()=>r()})})}if(t.source==="network"&&b){const a=t.originalEvent;return o(m,{testID:n,children:o(b,{event:a,onPress:()=>r()})})}if(t.source==="route"&&f){const a=t.originalEvent;return o(u,{source:t.source,testID:n,children:o(f,{event:a,visitNumber:0,isExpanded:l,onPress:()=>r(),onNavigate:k})})}if(t.source==="zustand"&&h){return o(u,{source:t.source,testID:n,children:o(h,{change:t.originalEvent,onPress:()=>r()})})}if(t.source==="jotai"&&T){return o(u,{source:t.source,testID:n,children:o(T,{change:t.originalEvent,onPress:()=>r()})})}const A=i&&d?o(_,{label:i,color:d,testID:`${n}-correlation`}):null;return o(F,{statusDotColor:S.color,statusLabel:S.label,primaryText:t.title,secondaryText:t.subtitle,badgeText:E>1&&!i?`${E}`:"",badgeColor:d||w,customBadge:A,bottomRightText:U(new Date(t.timestamp)),showChevron:true,isSelected:c,onPress:r,testID:n})});const p=O.create({badgeWrapper:{position:"relative"},sourceBadge:{position:"absolute",top:4,right:12,paddingHorizontal:6,paddingVertical:2,borderRadius:4,zIndex:10},sourceBadgeText:{fontSize:8,fontWeight:"700",letterSpacing:.5}});
|