@buoy-gg/events 7.0.55 → 7.0.57
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/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/utils/autoDiscoverEventSources.js +1 -1
- package/lib/module/utils/eventExportFormatter.js +1 -1
- package/lib/typescript/types/index.d.ts +1 -1
- package/lib/typescript/utils/autoDiscoverEventSources.d.ts +16 -0
- 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"}};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:h,NetworkEventDetailViewComponent:g,networkDetailWrapper:E,RouteEventDetailComponent:D,detailComponents:l,onNavigate:y}){const n=(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:x}=(0,_sharedUi.useIgnoredPatterns)();const s=(0,_react.useMemo)(()=>{if(!isStorageEvent(e.source))return null;if(!n.StorageEventDetailContent)return null;const r=e.originalEvent;const t={...r,timestamp:new Date(r.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,n]);if(s&&n.StorageEventDetailContent){const{StorageEventDetailContent:r}=n;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-storage`,children:(0,_jsxRuntime.jsx)(r,{conversation:s,selectedEventIndex:0,onEventIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="redux"&&n.ReduxActionDetailContent){const{ReduxActionDetailContent:r}=n;const t=e.originalEvent;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-redux`,children:(0,_jsxRuntime.jsx)(r,{action:t,actions:[t],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}const c=g??n.NetworkEventDetailView;if(e.source==="network"&&c){const r=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,{style:styles.content,testID:`${_testIDs.EVENTS_TEST_ID}-detail-network`,children:(0,_jsxRuntime.jsx)(c,{event:r,ignoredPatterns:T,onTogglePattern:x})})})})}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"&&n.ZustandStateDetailContent){const{ZustandStateDetailContent:r}=n;const t=e.originalEvent;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-zustand`,children:(0,_jsxRuntime.jsx)(r,{change:t,changes:[t],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="jotai"&&n.JotaiAtomDetailContent){const{JotaiAtomDetailContent:r}=n;const t=e.originalEvent;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-jotai`,children:(0,_jsxRuntime.jsx)(r,{change:t,changes:[t],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="render"&&n.RenderDetailView){const{RenderDetailView:r}=n;const t=e.originalEvent;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{style:styles.content,testID:`${_testIDs.EVENTS_TEST_ID}-detail-render`,children:(0,_jsxRuntime.jsx)(r,{render:t.render})})})}const u=D??n.RouteEventDetail;if(e.source==="route"&&u){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)(u,{event:e.originalEvent,onNavigate:y})})})}const d=()=>{return e.originalEvent};const m=async()=>{await(0,_sharedUi.copyToClipboard)({source:e.source,timestamp:i.toISOString(),title:e.title,subtitle:e.subtitle,data:d()})};return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail`,children:(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{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:d(),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"},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:h,NetworkEventDetailViewComponent:g,networkDetailWrapper:E,RouteEventDetailComponent:D,detailComponents:l,onNavigate:y}){const n=(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:x}=(0,_sharedUi.useIgnoredPatterns)();const s=(0,_react.useMemo)(()=>{if(!isStorageEvent(e.source))return null;if(!n.StorageEventDetailContent)return null;const r=e.originalEvent;const t={...r,timestamp:new Date(r.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,n]);if(s&&n.StorageEventDetailContent){const{StorageEventDetailContent:r}=n;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-storage`,children:(0,_jsxRuntime.jsx)(r,{conversation:s,selectedEventIndex:0,onEventIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="redux"&&n.ReduxActionDetailContent){const{ReduxActionDetailContent:r}=n;const t=e.originalEvent;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-redux`,children:(0,_jsxRuntime.jsx)(r,{action:t,actions:[t],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}const c=g??n.NetworkEventDetailView;if(e.source==="network"&&c){const r=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,{style:styles.content,testID:`${_testIDs.EVENTS_TEST_ID}-detail-network`,children:(0,_jsxRuntime.jsx)(c,{event:r,ignoredPatterns:T,onTogglePattern:x})})})})}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"&&n.ZustandStateDetailContent){const{ZustandStateDetailContent:r}=n;const t=e.originalEvent;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-zustand`,children:(0,_jsxRuntime.jsx)(r,{change:t,changes:[t],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="jotai"&&n.JotaiAtomDetailContent){const{JotaiAtomDetailContent:r}=n;const t=e.originalEvent;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail-jotai`,children:(0,_jsxRuntime.jsx)(r,{change:t,changes:[t],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="render"&&n.RenderDetailView){const{RenderDetailView:r}=n;const t=e.originalEvent;return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,children:(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{style:styles.content,testID:`${_testIDs.EVENTS_TEST_ID}-detail-render`,children:(0,_jsxRuntime.jsx)(r,{render:t.render})})})}const u=D??n.RouteEventDetail;if(e.source==="route"&&u){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)(u,{event:e.originalEvent,onNavigate:y})})})}const d=()=>{return e.originalEvent};const m=async()=>{await(0,_sharedUi.copyToClipboard)({source:e.source,timestamp:i.toISOString(),title:e.title,subtitle:e.subtitle,data:d()})};return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,testID:`${_testIDs.EVENTS_TEST_ID}-detail`,children:(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{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:d(),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"}};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"};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:I,correlationCount:
|
|
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"},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"};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:I,correlationCount:l=1,correlationLabel:u,correlationColor:c}){const{StorageEventCard:i,getValueType:d,ReduxActionItem:g,NetworkEventItemCompact:m,RouteEventItemCompact:p,ZustandStateChangeItem:y,JotaiAtomChangeItem:E}=getOptionalComponents();const x=SOURCE_CONFIG[e.source];const C=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"&&p){const r=e.originalEvent;return(0,_jsxRuntime.jsx)(SourceBadgeWrapper,{source:e.source,testID:a,children:(0,_jsxRuntime.jsx)(p,{event:r,visitNumber:0,isExpanded:s,onPress:()=>o(),onNavigate:I})})}if(e.source==="zustand"&&y){return(0,_jsxRuntime.jsx)(SourceBadgeWrapper,{source:e.source,testID:a,children:(0,_jsxRuntime.jsx)(y,{change:e.originalEvent,onPress:()=>o()})})}if(e.source==="jotai"&&E){return(0,_jsxRuntime.jsx)(SourceBadgeWrapper,{source:e.source,testID:a,children:(0,_jsxRuntime.jsx)(E,{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||C,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"];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"]};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
|
|
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"]};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[q,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=>q.has(r))})},[q]);(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 h=(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 A=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(h.size===0){return[]}return b.filter(e=>h.has(e.source)&&(A===""||matchesSearch(e,A)))},[b,h,A]);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"};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 k=u[t];const J=k&&k in r?r[k]: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:q,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"};
|
|
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"};
|
|
@@ -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 _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 o=r===null&&s===null||!!r&&!!s&&r.size===s.size&&[...s].every(t=>r.has(t));this.remoteAvailableSources=s;if(!o){this.notifyListeners()}}replaceEvents(e){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 o=await e.subscribe(t=>{this.addEvent(t)});if(o){r.unsubscribe=o}}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){if(e.source==="network"){const s=e.originalEvent;if(s?.id){const r=this.networkEventIdMap.get(s.id);if(r){const o=this.items.findIndex(t=>t.id===r);if(o>=0){e.id=r;this.items=[...this.items.slice(0,o),e,...this.items.slice(o+1)];this.notifyListeners();return}}this.networkEventIdMap.set(s.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};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 o=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:c}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const i=[];for(const n of t){const b=c.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&&o.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 c of e){const i=_sourceIds.EVENT_SOURCE_TO_DISCOVERY_ID[c];if(i)r.add(i)}const o=this.localDiscoveryIds;this.localDiscoveryIds=r;const{sources:t}=(0,_autoDiscoverEventSources.getCachedDiscovery)();for(const c of r){if(!o.has(c)){const i=t.find(a=>a.id===c);if(i)await this.subscribeToSource(i)}}for(const c of o){if(!r.has(c)){this.unsubscribeFromSource(c)}}};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 c=_sourceIds.EVENT_SOURCE_TO_DISCOVERY_ID[t];if(c)r.add(c)}}const o=this.remoteDiscoveryIds;this.remoteDiscoveryIds=r;for(const t of r){if(!o.has(t)){const c=s.find(i=>i.id===t);if(c)await this.subscribeToSource(c)}}for(const t of o){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");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")}}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 _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 o=r===null&&s===null||!!r&&!!s&&r.size===s.size&&[...s].every(t=>r.has(t));this.remoteAvailableSources=s;if(!o){this.notifyListeners()}}replaceEvents(e){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 o=await e.subscribe(t=>{this.addEvent(t)});if(o){r.unsubscribe=o}}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){if(e.source==="network"){const s=e.originalEvent;if(s?.id){const r=this.networkEventIdMap.get(s.id);if(r){const o=this.items.findIndex(t=>t.id===r);if(o>=0){e.id=r;this.items=[...this.items.slice(0,o),e,...this.items.slice(o+1)];this.notifyListeners();return}}this.networkEventIdMap.set(s.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};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 o=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:c}=(0,_autoDiscoverEventSources.getCachedDiscovery)();const i=[];for(const n of t){const b=c.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&&o.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 c of e){const i=_sourceIds.EVENT_SOURCE_TO_DISCOVERY_ID[c];if(i)r.add(i)}const o=this.localDiscoveryIds;this.localDiscoveryIds=r;const{sources:t}=(0,_autoDiscoverEventSources.getCachedDiscovery)();for(const c of r){if(!o.has(c)){const i=t.find(a=>a.id===c);if(i)await this.subscribeToSource(i)}}for(const c of o){if(!r.has(c)){this.unsubscribeFromSource(c)}}};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 c=_sourceIds.EVENT_SOURCE_TO_DISCOVERY_ID[t];if(c)r.add(c)}}const o=this.remoteDiscoveryIds;this.remoteDiscoveryIds=r;for(const t of r){if(!o.has(t)){const c=s.find(i=>i.id===t);if(c)await this.subscribeToSource(c)}}for(const t of o){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"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")}}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.autoDiscoverEventSources=autoDiscoverEventSources;exports.clearDiscoveryCache=clearDiscoveryCache;exports.getAggregatedSubscriberCounts=getAggregatedSubscriberCounts;exports.getCachedDiscovery=getCachedDiscovery;exports.getSourceDisplayConfig=getSourceDisplayConfig;var _utils=require("@buoy-gg/shared-ui/utils");let eventIdCounter=0;function generateEventId(r){return`${r}-${Date.now()}-${++eventIdCounter}`}function tryLoadStorageSource(){try{const{storageEventStore:r}=(0,_utils.loadToolModule)("@buoy-gg/storage");return{id:"storage",name:"Storage",eventSources:["storage-async","storage-mmkv"],available:true,subscribe:e=>{return r.onEvent(t=>{const n=t?.data;if(n?.initialScan)return;const s=transformStorageEvent(t);e(s)})}}}catch{return null}}function transformStorageEvent(r){const e=r;const t=e.storageType==="async"?"storage-async":"storage-mmkv";let n=e.action;if(e.storageType==="async"){const o={setItem:"Set Item",removeItem:"Remove Item",mergeItem:"Merge Item",clear:"Clear All",multiSet:"Multi Set",multiRemove:"Multi Remove",multiMerge:"Multi Merge"};n=o[e.action]||e.action}let s="";if(e.storageType==="async"){switch(e.action){case"setItem":case"removeItem":case"mergeItem":s=e.data?.key||"unknown key";break;case"multiSet":case"multiMerge":{const o=e.data?.pairs?.length||0;s=`${o} key${o!==1?"s":""}`;break}case"multiRemove":{const o=e.data?.keys?.length||0;s=`${o} key${o!==1?"s":""}`;break}case"clear":s="all keys";break}}else{s=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(t),source:t,timestamp:e.timestamp.getTime(),title:n,subtitle:s,status:a,originalEvent:r}}function tryLoadReduxSource(){try{const{reduxActionStore:r}=(0,_utils.loadToolModule)("@buoy-gg/redux");let e=null;return{id:"redux",name:"Redux",eventSources:["redux"],available:true,subscribe:t=>{return r.subscribe(n=>{if(n.length>0){const s=n[0];if(s.id!==e){e=s.id;const a=transformReduxAction(s);t(a)}}})}}}catch{return null}}function transformReduxAction(r){const e=r;let t="neutral";switch(e.category){case"fulfilled":t="success";break;case"rejected":t="error";break;case"pending":t="pending";break;default:t=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:t,originalEvent:r}}function tryLoadNetworkSource(){try{const{networkEventStore:r,networkListener:e,addNetworkListener:t}=(0,_utils.loadToolModule)("@buoy-gg/network");const n=new Map;return{id:"network",name:"Network",eventSources:["network"],available:true,setup:()=>{const s=e();if(!s.isActive){s.startListening()}if(s.listenerCount===0){t(a=>{r.processNetworkEvent(a)})}},subscribe:s=>{const a=Date.now();return r.onEvent(o=>{const u=o;const i=n.get(u.id);if(!i){if(typeof u.timestamp==="number"&&u.timestamp<a){return}const c=transformNetworkEvent(o);n.set(u.id,c.id);s(c)}else{const c=transformNetworkEvent(o);c.id=i;s(c)}},false)}}}catch{return null}}function transformNetworkEvent(r){const e=r;let t="neutral";if(e.status===void 0){t="pending"}else if(e.error||e.status>=400){t="error"}else if(e.status>=200&&e.status<400){t="success"}const n=e.operationName||`${e.method} ${e.path||e.url}`;const s=[];if(e.status!==void 0){s.push(`${e.status}`)}else if(e.error){s.push("Error")}else{s.push("Pending")}if(e.duration!==void 0){s.push(`${e.duration.toFixed(0)}ms`)}if(e.host){s.push(e.host)}return{id:generateEventId("network"),source:"network",timestamp:e.timestamp,title:n,subtitle:s.join(" \xB7 "),status:t,originalEvent:r}}function tryLoadReactQuerySource(){try{const{reactQueryEventStore:r}=(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:t=>{let n=true;const s=new Set;const a=o=>o.queryHash??(o.mutationId!==void 0?`m-${o.mutationId}`:null);return r.subscribe(o=>{if(n){n=false;if(o.length>0){e=o[0].id}return}if(o.length>0){const u=o[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)s.add(c)}else if(i==="query-fetch-success"||i==="query-fetch-error"||i==="mutation-success"||i==="mutation-error"){if(c&&!s.has(c)){return}}const l=transformReactQueryEvent(u);t(l)}}})}}}catch{return null}}function formatQueryKey(r){if(!r||r.length===0)return"unknown";return r.map(e=>{if(typeof e==="string")return e;if(typeof e==="number")return String(e);if(typeof e==="object"&&e!==null){const t=e;const n=Object.values(t)[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(r){const e=r;const t=e.type.startsWith("mutation-");const n=t?"react-query-mutation":"react-query-query";let s="neutral";switch(e.type){case"query-fetch-start":case"mutation-start":s="pending";break;case"query-fetch-success":case"mutation-success":s="success";break;case"query-fetch-error":case"mutation-error":s="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 o=[];switch(e.type){case"query-fetch-start":o.push("Fetching");break;case"query-fetch-success":o.push("Success");break;case"query-fetch-error":o.push("Error");break;case"query-invalidated":o.push("Invalidated");break;case"mutation-start":o.push("Mutating");break;case"mutation-success":o.push("Success");break;case"mutation-error":o.push("Error");break}if(e.duration!==void 0){o.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:o.join(" \xB7 "),status:s,originalEvent:r,correlationId:u,sequenceInGroup:i}}function tryLoadRouteEventsSource(){try{const{routeEventStore:r}=(0,_utils.loadToolModule)("@buoy-gg/route-events");return{id:"route-events",name:"Routes",eventSources:["route"],available:true,subscribe:e=>{return r.onEvent(t=>{const n=transformRouteEvent(t);e(n)})}}}catch{return null}}function transformRouteEvent(r){const e=r;let t="neutral";if(e.pathname==="/"){t="success"}else if(Object.keys(e.params).length>0){t="success"}const n=[];const s=Object.keys(e.params).length;if(s>0){n.push(`${s} param${s!==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:t,originalEvent:r}}function tryLoadZustandSource(){try{const{zustandStateStore:r}=(0,_utils.loadToolModule)("@buoy-gg/zustand");let e=null;return{id:"zustand",name:"Zustand",eventSources:["zustand"],available:true,subscribe:t=>{return r.subscribe(n=>{if(n.length>0){const s=n[0];if(s.id!==e){e=s.id;const a=transformZustandChange(s);t(a)}}})}}}catch{return null}}function transformZustandChange(r){const e=r;let t="neutral";if(e.isSlowUpdate){t="pending"}else if(e.hasStateChange){t="success"}const n=[];if(e.changedKeys&&e.changedKeys.length>0){const s=e.changedKeys.slice(0,3).join(", ");const a=e.changedKeys.length>3?` +${e.changedKeys.length-3}`:"";n.push(`${s}${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:t,originalEvent:r}}function tryLoadJotaiSource(){try{const{jotaiStateStore:r}=(0,_utils.loadToolModule)("@buoy-gg/jotai");let e=null;return{id:"jotai",name:"Jotai",eventSources:["jotai"],available:true,subscribe:t=>{return r.subscribe(n=>{if(n.length>0){const s=n[0];if(s.id!==e){e=s.id;const a=transformJotaiChange(s);t(a)}}})}}}catch{return null}}function transformJotaiChange(r){const e=r;let t="neutral";if(e.category==="write"&&e.hasValueChange){t="success"}else if(e.category==="read"){t="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:t,originalEvent:r}}function tryLoadHighlightUpdatesSource(){let r;try{r=(0,_utils.loadToolModule)("@buoy-gg/highlight-updates")}catch{return null}try{if(!r.RenderTracker||!r.HighlightUpdatesController){return null}const{RenderTracker:e,HighlightUpdatesController:t}=r;return{id:"render",name:"Render",eventSources:["render"],available:true,setup:()=>{if(t){t.enableBackgroundTracking()}},subscribe:n=>{if(t&&!t.isBackgroundTrackingEnabled()){t.enableBackgroundTracking()}const s=e.onRenderEvent((a,o)=>{const u=transformRenderEvent(a,o);n(u)});return()=>{s();t.disableBackgroundTracking()}}}}catch{return null}}function transformRenderEvent(r,e){const t=r;const n=e;const s=n.componentName||n.displayName||n.viewType;const a=[];const o={mount:"mounted",props:"props changed",state:"state changed",hooks:"hooks changed",context:"context changed",parent:"parent re-rendered",unknown:"re-rendered"};a.push(o[t.cause.type]||t.cause.type);if(t.cause.type==="props"&&t.cause.changedKeys?.length){const i=t.cause.changedKeys.slice(0,3).join(", ");const c=t.cause.changedKeys.length>3?` +${t.cause.changedKeys.length-3}`:"";a.push(`[${i}${c}]`)}if(t.cause.hookChanges?.length){const i=t.cause.hookChanges[0];if(i.description){a.push(i.description)}}a.push(`#${t.renderNumber}`);let u="neutral";switch(t.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:t.timestamp,title:s,subtitle:a.join(" \xB7 "),status:u,originalEvent:{event:t,render:n}}}function autoDiscoverEventSources(){const r=[];const e=new Set;const t=[tryLoadStorageSource,tryLoadReduxSource,tryLoadNetworkSource,tryLoadReactQuerySource,tryLoadRouteEventsSource,tryLoadZustandSource,tryLoadJotaiSource,tryLoadHighlightUpdatesSource];for(const n of t){const s=n();if(s&&s.available){r.push(s);s.eventSources.forEach(a=>e.add(a))}}return{sources:r,availableEventSources:e}}function getSourceDisplayConfig(r){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"}};return e[r]||{label:r,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 r=[];let e=0;try{const{storageEventStore:t}=(0,_utils.loadToolModule)("@buoy-gg/storage");const n=t.getSubscriberCounts();r.push({sourceId:"storage",counts:n});e+=n.total}catch{}try{const{networkEventStore:t}=(0,_utils.loadToolModule)("@buoy-gg/network");const n=t.getSubscriberCounts();r.push({sourceId:"network",counts:n});e+=n.total}catch{}try{const{routeEventStore:t}=(0,_utils.loadToolModule)("@buoy-gg/route-events");const n=t.getSubscriberCounts();r.push({sourceId:"route-events",counts:n});e+=n.total}catch{}try{const{RenderTracker:t,HighlightUpdatesController:n}=(0,_utils.loadToolModule)("@buoy-gg/highlight-updates");const s=t.getRenderEventCallbackCount();const a=n?.isEnabled?.()?1:0;const o={eventCallbacks:s,arrayListeners:a,total:s+a};r.push({sourceId:"render",counts:o});e+=o.total}catch{}return{sources:r,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(n=>{const r=n?.data;if(r?.initialScan)return;const s=transformStorageEvent(n);e(s)})}}}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 o={setItem:"Set Item",removeItem:"Remove Item",mergeItem:"Merge Item",clear:"Clear All",multiSet:"Multi Set",multiRemove:"Multi Remove",multiMerge:"Multi Merge"};r=o[e.action]||e.action}let s="";if(e.storageType==="async"){switch(e.action){case"setItem":case"removeItem":case"mergeItem":s=e.data?.key||"unknown key";break;case"multiSet":case"multiMerge":{const o=e.data?.pairs?.length||0;s=`${o} key${o!==1?"s":""}`;break}case"multiRemove":{const o=e.data?.keys?.length||0;s=`${o} key${o!==1?"s":""}`;break}case"clear":s="all keys";break}}else{s=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:s,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 s=r[0];if(s.id!==e){e=s.id;const a=transformReduxAction(s);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 s=e();if(!s.isActive){s.startListening()}if(s.listenerCount===0){n(a=>{t.processNetworkEvent(a)})}},subscribe:s=>{const a=Date.now();return t.onEvent(o=>{const u=o;const i=r.get(u.id);if(!i){if(typeof u.timestamp==="number"&&u.timestamp<a){return}const c=transformNetworkEvent(o);r.set(u.id,c.id);s(c)}else{const c=transformNetworkEvent(o);c.id=i;s(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 s=[];if(e.status!==void 0){s.push(`${e.status}`)}else if(e.error){s.push("Error")}else{s.push("Pending")}if(e.duration!==void 0){s.push(`${e.duration.toFixed(0)}ms`)}if(e.host){s.push(e.host)}return{id:generateEventId("network"),source:"network",timestamp:e.timestamp,title:r,subtitle:s.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 s=new Set;const a=o=>o.queryHash??(o.mutationId!==void 0?`m-${o.mutationId}`:null);return t.subscribe(o=>{if(r){r=false;if(o.length>0){e=o[0].id}return}if(o.length>0){const u=o[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)s.add(c)}else if(i==="query-fetch-success"||i==="query-fetch-error"||i==="mutation-success"||i==="mutation-error"){if(c&&!s.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 s="neutral";switch(e.type){case"query-fetch-start":case"mutation-start":s="pending";break;case"query-fetch-success":case"mutation-success":s="success";break;case"query-fetch-error":case"mutation-error":s="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 o=[];switch(e.type){case"query-fetch-start":o.push("Fetching");break;case"query-fetch-success":o.push("Success");break;case"query-fetch-error":o.push("Error");break;case"query-invalidated":o.push("Invalidated");break;case"mutation-start":o.push("Mutating");break;case"mutation-success":o.push("Success");break;case"mutation-error":o.push("Error");break}if(e.duration!==void 0){o.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:o.join(" \xB7 "),status:s,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 s=Object.keys(e.params).length;if(s>0){r.push(`${s} param${s!==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 s=r[0];if(s.id!==e){e=s.id;const a=transformZustandChange(s);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 s=e.changedKeys.slice(0,3).join(", ");const a=e.changedKeys.length>3?` +${e.changedKeys.length-3}`:"";r.push(`${s}${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 s=r[0];if(s.id!==e){e=s.id;const a=transformJotaiChange(s);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 s=e.onRenderEvent((a,o)=>{const u=transformRenderEvent(a,o);r(u)});return()=>{s();n.disableBackgroundTracking()}}}}catch{return null}}function transformRenderEvent(t,e){const n=t;const r=e;const s=r.componentName||r.displayName||r.viewType;const a=[];const o={mount:"mounted",props:"props changed",state:"state changed",hooks:"hooks changed",context:"context changed",parent:"parent re-rendered",unknown:"re-rendered"};a.push(o[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:s,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(o=>redactCapacitorValue(o,e,n+1));const r={};const s=t;const a=e||typeof s.key==="string"&&SECRET_NAME.test(s.key);for(const[o,u]of Object.entries(s)){if((SECRET_NAME.test(o)||a&&o==="value")&&u!=null&&u!==""){r[o]="[hidden]"}else{r[o]=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 s=()=>{const o=t.getCapacitorCalls();for(const i of o){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=o[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(s)}}}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];for(const r of n){const s=r();if(s&&s.available){t.push(s);s.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"},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 s=n.getRenderEventCallbackCount();const a=r?.isEnabled?.()?1:0;const o={eventCallbacks:s,arrayListeners:a,total:s+a};t.push({sourceId:"render",counts:o});e+=o.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;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"};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){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 x=new Set(S.map(d).filter(Boolean));for(const E of A){const b=d(E);if(b&&!x.has(b)){g=y(b);break}}}else if(D<m){$="\u2796";p="Remove";const x=new Set(A.map(d).filter(Boolean));for(const E of S){const b=d(E);if(b&&!x.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 v;if(g){v=`App->>${f}: ${$} ${p} ${g} \u2192 ${l}`}else{v=`App->>${f}: ${$} ${p} ${l}`}r.push(v);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 v="";if(p.source==="network"){const m=p.originalEvent;const D=m?.url;if(D){const x=getCanonicalUrl(D);const E=y.get(x);if(E&&p.timestamp-E.timestamp<3e4){A=true;const b=p.timestamp-E.timestamp;const C=formatMermaidDuration(b);v=`\u26A0\uFE0F Already fetched ${C} ago`;y.set(x,{timestamp:p.timestamp,count:E.count+1})}else{y.set(x,{timestamp:p.timestamp,count:1})}}}if(A){i.push(" rect rgb(255, 245, 230)");i.push(` Note over App,API: ${v}`);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;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"};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){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 x=new Set(S.map(d).filter(Boolean));for(const E of A){const b=d(E);if(b&&!x.has(b)){g=y(b);break}}}else if(D<m){$="\u2796";p="Remove";const x=new Set(A.map(d).filter(Boolean));for(const E of S){const b=d(E);if(b&&!x.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 v;if(g){v=`App->>${f}: ${$} ${p} ${g} \u2192 ${l}`}else{v=`App->>${f}: ${$} ${p} ${l}`}r.push(v);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 v="";if(p.source==="network"){const m=p.originalEvent;const D=m?.url;if(D){const x=getCanonicalUrl(D);const E=y.get(x);if(E&&p.timestamp-E.timestamp<3e4){A=true;const b=p.timestamp-E.timestamp;const C=formatMermaidDuration(b);v=`\u26A0\uFE0F Already fetched ${C} ago`;y.set(x,{timestamp:p.timestamp,count:E.count+1})}else{y.set(x,{timestamp:p.timestamp,count:1})}}}if(A){i.push(" rect rgb(255, 245, 230)");i.push(` Note over App,API: ${v}`);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 u,getToolModuleVersion as D}from"@buoy-gg/shared-ui/utils";import{View as a,Text as d,StyleSheet as B,ScrollView as h}from"react-native";import{memo as
|
|
1
|
+
"use strict";import{loadToolModule as u,getToolModuleVersion as D}from"@buoy-gg/shared-ui/utils";import{View as a,Text as d,StyleSheet as B,ScrollView as h}from"react-native";import{memo as F,useMemo as x}from"react";import{night as s,formatRelativeTime as A,copyToClipboard as $,parseValue as j,useIgnoredPatterns as z,monoFont as N}from"@buoy-gg/shared-ui";import{DataViewer as q}from"@buoy-gg/shared-ui/dataViewer";import{ReactQueryEventDetail as L}from"./ReactQueryEventDetail";import{EVENTS_TEST_ID as i}from"../utils/testIDs";import{Fragment as M,jsx as e,jsxs as g}from"react/jsx-runtime";function P(){const r={StorageEventDetailContent:null,ReduxActionDetailContent:null,NetworkEventDetailView:null,RenderDetailView:null,ZustandStateDetailContent:null,JotaiAtomDetailContent:null,RouteEventDetail:null};try{const t=u("@buoy-gg/storage");r.StorageEventDetailContent=t.StorageEventDetailContent}catch{}try{const t=u("@buoy-gg/redux");r.ReduxActionDetailContent=t.ReduxActionDetailContent}catch{}try{const t=u("@buoy-gg/network");r.NetworkEventDetailView=t.NetworkEventDetailView}catch{}try{const t=u("@buoy-gg/highlight-updates");r.RenderDetailView=t.RenderDetailView}catch{}try{const t=u("@buoy-gg/zustand");r.ZustandStateDetailContent=t.ZustandStateDetailContent}catch{}try{const t=u("@buoy-gg/jotai");r.JotaiAtomDetailContent=t.JotaiAtomDetailContent}catch{}try{const t=u("@buoy-gg/route-events");r.RouteEventDetail=t.RouteEventDetail}catch{}return r}let p;let I=-1;function W(){if(!p||I!==D()){p=P();I=D()}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"},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(M,{children:r})}export const UnifiedEventDetail=F(function r({event:t,onBack:U,NetworkEventDetailViewComponent:S,networkDetailWrapper:R,RouteEventDetailComponent:v,detailComponents:f,onNavigate:V}){const l=x(()=>({...W(),...f}),[f,D()]);const m=J[t.source];const y=new Date(t.timestamp);const{values:T,toggle:k}=z();const b=x(()=>{if(!O(t.source))return null;if(!l.StorageEventDetailContent)return null;const c=t.originalEvent;const n={...c,timestamp:new Date(c.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(b&&l.StorageEventDetailContent){const{StorageEventDetailContent:c}=l;return e(a,{style:o.container,testID:`${i}-detail-storage`,children:e(c,{conversation:b,selectedEventIndex:0,onEventIndexChange:()=>{},disableInternalFooter:true})})}if(t.source==="redux"&&l.ReduxActionDetailContent){const{ReduxActionDetailContent:c}=l;const n=t.originalEvent;return e(a,{style:o.container,testID:`${i}-detail-redux`,children:e(c,{action:n,actions:[n],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}const C=S??l.NetworkEventDetailView;if(t.source==="network"&&C){const c=t.originalEvent;const n=R??_;return e(a,{style:o.container,children:e(n,{children:e(h,{style:o.content,testID:`${i}-detail-network`,children:e(C,{event:c,ignoredPatterns:T,onTogglePattern:k})})})})}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(L,{event:t})})}if(t.source==="zustand"&&l.ZustandStateDetailContent){const{ZustandStateDetailContent:c}=l;const n=t.originalEvent;return e(a,{style:o.container,testID:`${i}-detail-zustand`,children:e(c,{change:n,changes:[n],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}if(t.source==="jotai"&&l.JotaiAtomDetailContent){const{JotaiAtomDetailContent:c}=l;const n=t.originalEvent;return e(a,{style:o.container,testID:`${i}-detail-jotai`,children:e(c,{change:n,changes:[n],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}if(t.source==="render"&&l.RenderDetailView){const{RenderDetailView:c}=l;const n=t.originalEvent;return e(a,{style:o.container,children:e(h,{style:o.content,testID:`${i}-detail-render`,children:e(c,{render:n.render})})})}const w=v??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:V})})})}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(h,{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(d,{style:[o.sourceLabel,{color:m.color}],testID:`${i}-detail-source`,children:m.label})]})}),e(d,{style:o.title,testID:`${i}-detail-title`,children:t.title}),e(d,{style:o.subtitle,testID:`${i}-detail-subtitle`,children:t.subtitle}),g(a,{style:o.timestampRow,children:[e(d,{style:o.timestampLabel,children:"Timestamp"}),g(d,{style:o.timestampValue,testID:`${i}-detail-timestamp`,children:[y.toLocaleTimeString()," (",A(y),")"]})]}),g(a,{style:o.dataSection,children:[e(d,{style:o.sectionLabel,children:"Event Data"}),e(a,{style:o.dataContainer,testID:`${i}-detail-data`,children:e(q,{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:s.color.text,marginBottom:4},subtitle:{fontSize:16,color:s.color.textTertiary,marginBottom:16},timestampRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,borderTopWidth:1,borderTopColor:s.color.border,borderBottomWidth:1,borderBottomColor:s.color.border,marginBottom:16},timestampLabel:{fontSize:14,color:s.color.textTertiary},timestampValue:{fontSize:14,color:s.color.text,fontFamily:N},dataSection:{marginTop:8},sectionLabel:{fontSize:12,fontWeight:"600",color:s.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8},dataContainer:{backgroundColor:s.color.surface,borderRadius:8,borderWidth:1,borderColor:s.color.border,overflow:"hidden"}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{loadToolModule as s,getToolModuleVersion as
|
|
1
|
+
"use strict";import{loadToolModule as s,getToolModuleVersion as x}from"@buoy-gg/shared-ui/utils";import{memo as k}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 S=-1;function M(){if(!g||S!==x()){g=q();S=x()}return g}const w={"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"},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"};function u({source:e,testID:t,children:r}){const c=w[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=k(function e({event:t,onPress:r,isSelected:c=false,isExpanded:l=false,onNavigate:B,correlationCount:E=1,correlationLabel:i,correlationColor:d}){const{StorageEventCard:y,getValueType:C,ReduxActionItem:I,NetworkEventItemCompact:f,RouteEventItemCompact:b,ZustandStateChangeItem:h,JotaiAtomChangeItem:T}=M();const R=w[t.source];const A=J(t.status);const n=j(t);if(Z(t.source)&&y&&C){const a=t.originalEvent;const v={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:v,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"&&f){const a=t.originalEvent;return o(m,{testID:n,children:o(f,{event:a,onPress:()=>r()})})}if(t.source==="route"&&b){const a=t.originalEvent;return o(u,{source:t.source,testID:n,children:o(b,{event:a,visitNumber:0,isExpanded:l,onPress:()=>r(),onNavigate:B})})}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 D=i&&d?o(_,{label:i,color:d,testID:`${n}-correlation`}):null;return o(F,{statusDotColor:R.color,statusLabel:R.label,primaryText:t.title,secondaryText:t.subtitle,badgeText:E>1&&!i?`${E}`:"",badgeColor:d||A,customBadge:D,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}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useState as f,useEffect as S,useCallback as b,useMemo as g,useRef as D}from"react";import{useFeatureGate as ie,subscribeToSubscriberCountChanges as le,useIgnoredPatterns as de,useLimit as fe}from"@buoy-gg/shared-ui";import{subscribe as Se,setLocalEnabledSources as j,clearEvents as be,getAvailableEventSources as F,getEvents as ge,getSubscriberCounts as V}from"../stores/unifiedEventStore";import{saveEnabledSources as me,loadEnabledSources as ve,saveCapturingState as ye,loadCapturingState as
|
|
1
|
+
"use strict";import{useState as f,useEffect as S,useCallback as b,useMemo as g,useRef as D}from"react";import{useFeatureGate as ie,subscribeToSubscriberCountChanges as le,useIgnoredPatterns as de,useLimit as fe}from"@buoy-gg/shared-ui";import{subscribe as Se,setLocalEnabledSources as j,clearEvents as be,getAvailableEventSources as F,getEvents as ge,getSubscriberCounts as V}from"../stores/unifiedEventStore";import{saveEnabledSources as me,loadEnabledSources as ve,saveCapturingState as ye,loadCapturingState as pe,savePausedAt as B,loadPausedAt as Ce}from"../utils/badgeSelectionStorage";import{getSourceDisplayConfig as Ee}from"../utils/autoDiscoverEventSources";import{isBuoyInternalEvent as we,isNetworkEventIgnored as he}from"../utils/eventVisibility";function qe(i,v){if(i.title.toLowerCase().includes(v))return true;if(i.subtitle.toLowerCase().includes(v))return true;const l=i.originalEvent?.url;return typeof l==="string"&&l.toLowerCase().includes(v)}const N=["storage-async","redux","network","react-query-query","react-query-mutation","route","zustand","jotai","render","capacitor"];const G=N.filter(i=>i!=="render");const P={"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"]};export function useUnifiedEvents(i){const{isPro:v}=ie();const l=fe("events.entries");const{patterns:R}=de();const[h,M]=f([]);const[u,q]=f(()=>new Set(G));const[m,C]=f(true);const[T,W]=f("");const E=D(false);const _=i?.capturingOverride??m;const a=D(null);const A=D([]);const[Y,L]=f(0);S(()=>{if(_){if(a.current!==null){A.current=[...A.current,[a.current,Date.now()]];a.current=null;L(e=>e+1);B(null)}}else if(a.current===null){a.current=Date.now();L(e=>e+1);B(a.current)}},[_]);const O=b(e=>{const n=a.current;if(n!==null&&e>n)return true;for(const[r,o]of A.current){if(e>r&&e<=o)return true}return false},[]);const[k,H]=f(()=>F());const[J,K]=f(0);S(()=>{return le(()=>{K(e=>e+1)})},[]);const d=g(()=>{return N.filter(e=>{const n=P[e]||[e];return n.some(r=>k.has(r))})},[k]);S(()=>{let e=null;const n=Se(()=>{if(e!=null)return;e=requestAnimationFrame(()=>{e=null;r()})});const r=()=>{const o=ge();M(o);H(c=>{const t=F();if(c.size===t.size&&[...t].every(s=>c.has(s))){return c}return new Set(t)})};return()=>{n();if(e!=null)cancelAnimationFrame(e)}},[]);S(()=>{const e=async()=>{const n=await ve();let r;const o=d.filter(s=>G.includes(s));if(n&&n.length>0){const s=n.filter(p=>d.includes(p));if(s.length>0){r=new Set(s)}else{r=new Set(o)}}else{r=new Set(o)}q(r);const c=await pe();const t=c!==null?c:true;if(!t&&a.current===null){const s=await Ce();a.current=s??Date.now();L(p=>p+1)}C(t);E.current=true;void j(t?Array.from(r):[])};e()},[d]);S(()=>{if(!E.current){return}void j(m?Array.from(u):[])},[u,m]);S(()=>{if(!E.current){return}me(Array.from(u))},[u]);S(()=>{if(!E.current){return}ye(m)},[m]);const x=g(()=>{const e=new Set;u.forEach(n=>{const r=P[n];if(r){r.forEach(o=>e.add(o))}});return e},[u]);const I=T.trim().toLowerCase();const y=g(()=>h.filter(e=>!O(e.timestamp)&&!we(e)&&!he(e,R)),[h,R,O,Y]);const w=g(()=>{if(x.size===0){return[]}return y.filter(e=>x.has(e.source)&&(I===""||qe(e,I)))},[y,x,I]);const U=g(()=>w.slice(0,l),[w,l]);const Q=g(()=>Math.max(0,w.length-l),[w,l]);const X=g(()=>{const e=y.reduce((t,s)=>{t[s.source]=(t[s.source]??0)+1;return t},{});const n=V();const r={};for(const t of n.sources){r[t.sourceId]=t.counts.total}const o={"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"};const c=d.map(t=>{const s=P[t]||[t];const p=s.reduce((ae,ce)=>ae+(e[ce]||0),0);const oe=Ee(t);const z=o[t];const ue=z&&z in r?r[z]:void 0;return{source:t,...oe,count:p,enabled:u.has(t),subscriberCount:ue}});return c.sort((t,s)=>{if(t.enabled&&!s.enabled)return-1;if(!t.enabled&&s.enabled)return 1;return 0})},[y,u,d,J]);const Z=b(e=>{q(n=>{const r=new Set(n);if(r.has(e)){r.delete(e)}else{r.add(e)}return r})},[]);const $=b(()=>{q(new Set(d))},[d]);const ee=b(()=>{be()},[]);const te=b(()=>{C(true)},[]);const re=b(()=>{C(false)},[]);const ne=b(()=>{C(e=>!e)},[]);const se=V().totalSubscribers;return{events:h,filteredEvents:U,availableSources:X,enabledSources:u,searchText:T,setSearchText:W,toggleSource:Z,enableAllSources:$,clearEvents:ee,totalCount:y.length,filteredCount:U.length,isCapturing:m,startCapturing:te,stopCapturing:re,toggleCapturing:ne,discoveredSources:k,hiddenEventsCount:Q,isPro:v,totalSubscriberCount:se}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";export const 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"};
|
|
1
|
+
"use strict";export const 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"};
|