@buoy-gg/jotai 7.0.76 → 7.0.78
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/jotai/components/JotaiAtomBrowser.js +1 -1
- package/lib/commonjs/jotai/components/JotaiAtomDetailContent.js +1 -1
- package/lib/commonjs/jotai/components/JotaiModal.js +1 -1
- package/lib/module/jotai/components/JotaiAtomBrowser.js +1 -1
- package/lib/module/jotai/components/JotaiAtomDetailContent.js +1 -1
- package/lib/module/jotai/components/JotaiModal.js +1 -1
- package/lib/web/index.mjs +2 -2
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.JotaiAtomBrowser=JotaiAtomBrowser;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _jotaiStateStore=require("../utils/jotaiStateStore");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function getValuePreview(r){try{const e=r.getValue();if(e&&typeof e==="object"&&e.__buoyValueOnDevice===true){return"on device"}if(e===void 0)return"undefined";if(e===null)return"null";if(Array.isArray(e)){if(e.length===0)return"[]";return`[${e.length} item${e.length===1?"":"s"}]`}if(typeof e==="object"){const o=Object.keys(e);if(o.length===0)return"{}";if(o.length<=3)return o.join(", ");return`${o.slice(0,2).join(", ")} +${o.length-2}`}return String(e).slice(0,40)}catch{return""}}function getWriteKindLabel(r){if(r.writeKind==="value")return"primitive";if(r.writeKind==="action")return"custom write";return r.setValue?"writable":"derived"}function EmptyBrowserState(){return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.JOTAI_TEST_ID}-atoms-empty`,otto:"scanning",title:"No atoms registered",message:"Use watchAtoms(store, { atomName }) to register your Jotai atoms.\nThey will appear here with their current value."})}function JotaiAtomBrowser({atoms:r,searchQuery:e,onOpenAtom:o}){const i=(0,_react.useMemo)(()=>{if(!e)return r;const t=e.toLowerCase();return r.filter(a=>a.label.toLowerCase().includes(t))},[r,e]);if(i.length===0&&!e){return(0,_jsxRuntime.jsx)(EmptyBrowserState,{})}if(i.length===0&&e){return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.JOTAI_TEST_ID}-atoms-no-match`,...(0,_sharedUi.resolveListEmptyState)({subject:"atoms",verb:"registered",search:e,total:r.length,waiting:{otto:"scanning",title:"No atoms registered",message:"Use watchAtoms() to register your Jotai atoms."}})})}return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.container,contentContainerStyle:styles.scrollContent,showsVerticalScrollIndicator:true,testID:`${_testIDs.JOTAI_TEST_ID}-atoms-scroll`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionHeader,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionTitle,children:"ATOMS"}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.sectionCountBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionCountText,testID:`${_testIDs.JOTAI_TEST_ID}-atoms-count`,children:i.length})})]}),i.map(t=>{const a=getValuePreview(t);const s=_jotaiStateStore.jotaiStateStore.getAtomColor(t.label);const n=(0,_testIDs.atomRowTestID)(t.label);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.atomRowWrapper,children:[(0,_jsxRuntime.jsx)(_sharedUi.CompactRow,{statusDotColor:s,statusLabel:getWriteKindLabel(t),primaryText:t.label,secondaryText:a||void 0,showChevron:true,onPress:()=>o(t.label),testID:n,statusTestID:`${n}-kind`,primaryTestID:`${n}-name`,secondaryTestID:`${n}-preview`}),t.changeCount>0&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.absCountBadge,{backgroundColor:s+"22",borderColor:s+"55"}],pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.absCountText,{color:s}],testID:`${n}-count`,children:String(t.changeCount)})})]},t.label)})]})}const styles=_reactNative.StyleSheet.create({container:{flex:1},atomRowWrapper:{position:"relative"},absCountBadge:{position:"absolute",top:4,right:10,paddingHorizontal:5,paddingVertical:1,borderRadius:4,borderWidth:1,zIndex:1},absCountText:{fontSize:9,fontWeight:"700",fontFamily:_sharedUi.monoFont},scrollContent:{paddingTop:8,paddingBottom:20},sectionHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:8,gap:8},sectionTitle:{fontSize:11,fontWeight:"700",letterSpacing:.5,color:_sharedUi.night.color.textTertiary},sectionCountBadge:{backgroundColor:_sharedUi.night.color.accentFill,paddingHorizontal:8,paddingVertical:2,borderRadius:4},sectionCountText:{fontSize:10,fontWeight:"700",color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont}});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.JotaiAtomBrowser=JotaiAtomBrowser;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _jotaiStateStore=require("../utils/jotaiStateStore");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function getValuePreview(r){try{const e=r.getValue();if(e&&typeof e==="object"&&e.__buoyValueOnDevice===true){return"on device"}if(e===void 0)return"undefined";if(e===null)return"null";if(Array.isArray(e)){if(e.length===0)return"[]";return`[${e.length} item${e.length===1?"":"s"}]`}if(typeof e==="object"){const o=Object.keys(e);if(o.length===0)return"{}";if(o.length<=3)return o.join(", ");return`${o.slice(0,2).join(", ")} +${o.length-2}`}return String(e).slice(0,40)}catch{return""}}function getWriteKindLabel(r){if(r.writeKind==="value")return"primitive";if(r.writeKind==="action")return"custom write";return r.setValue?"writable":"derived"}function EmptyBrowserState(){return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.JOTAI_TEST_ID}-atoms-empty`,otto:"scanning",title:"No atoms registered",message:"Use watchAtoms(store, { atomName }) to register your Jotai atoms.\nThey will appear here with their current value."})}function JotaiAtomBrowser({atoms:r,searchQuery:e,onOpenAtom:o}){const i=(0,_react.useMemo)(()=>{if(!e)return r;const t=e.toLowerCase();return r.filter(a=>a.label.toLowerCase().includes(t))},[r,e]);if(i.length===0&&!e){return(0,_jsxRuntime.jsx)(EmptyBrowserState,{})}if(i.length===0&&e){return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.JOTAI_TEST_ID}-atoms-no-match`,...(0,_sharedUi.resolveListEmptyState)({subject:"atoms",verb:"registered",search:e,total:r.length,waiting:{otto:"scanning",title:"No atoms registered",message:"Use watchAtoms() to register your Jotai atoms."}})})}return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",style:styles.container,contentContainerStyle:styles.scrollContent,showsVerticalScrollIndicator:true,testID:`${_testIDs.JOTAI_TEST_ID}-atoms-scroll`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionHeader,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionTitle,children:"ATOMS"}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.sectionCountBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionCountText,testID:`${_testIDs.JOTAI_TEST_ID}-atoms-count`,children:i.length})})]}),i.map(t=>{const a=getValuePreview(t);const s=_jotaiStateStore.jotaiStateStore.getAtomColor(t.label);const n=(0,_testIDs.atomRowTestID)(t.label);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.atomRowWrapper,children:[(0,_jsxRuntime.jsx)(_sharedUi.CompactRow,{statusDotColor:s,statusLabel:getWriteKindLabel(t),primaryText:t.label,secondaryText:a||void 0,showChevron:true,onPress:()=>o(t.label),testID:n,statusTestID:`${n}-kind`,primaryTestID:`${n}-name`,secondaryTestID:`${n}-preview`}),t.changeCount>0&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.absCountBadge,{backgroundColor:s+"22",borderColor:s+"55"}],pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.absCountText,{color:s}],testID:`${n}-count`,children:String(t.changeCount)})})]},t.label)})]})}const styles=_reactNative.StyleSheet.create({container:{flex:1},atomRowWrapper:{position:"relative"},absCountBadge:{position:"absolute",top:4,right:10,paddingHorizontal:5,paddingVertical:1,borderRadius:4,borderWidth:1,zIndex:1},absCountText:{fontSize:9,fontWeight:"700",fontFamily:_sharedUi.monoFont},scrollContent:{paddingTop:8,paddingBottom:20},sectionHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:8,gap:8},sectionTitle:{fontSize:11,fontWeight:"700",letterSpacing:.5,color:_sharedUi.night.color.textTertiary},sectionCountBadge:{backgroundColor:_sharedUi.night.color.accentFill,paddingHorizontal:8,paddingVertical:2,borderRadius:4},sectionCountText:{fontSize:10,fontWeight:"700",color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.JotaiAtomDetailContent=JotaiAtomDetailContent;exports.JotaiAtomDetailFooter=JotaiAtomDetailFooter;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _dataViewer=require("@buoy-gg/shared-ui/dataViewer");var _license=require("@buoy-gg/license");var _jotaiStateStore=require("../utils/jotaiStateStore");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,o){if("function"==typeof WeakMap)var n=new WeakMap,r=new WeakMap;return(_interopRequireWildcard=function(t,l){if(!l&&t&&t.__esModule)return t;var i,c,a={__proto__:null,default:t};if(null===t||"object"!=typeof t&&"function"!=typeof t)return a;if(i=l?r:n){if(i.has(t))return i.get(t);i.set(t,a)}for(const d in t)"default"!==d&&{}.hasOwnProperty.call(t,d)&&((c=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(t,d))&&(c.get||c.set)?i(a,d,c):a[d]=t[d]);return a})(e,o)}const VIEW_CONFIGS=[{key:"change",label:"CHANGE",icon:_sharedUi.FileText},{key:"value",label:"VALUE",icon:_sharedUi.Database},{key:"diff",label:"DIFF",icon:_sharedUi.GitBranch}];const DIFF_DISABLED=["diff"];function getCategoryInfo(e){switch(e){case"initial":return{label:"INITIAL",color:_sharedUi.night.color.textTertiary,bgColor:_sharedUi.night.color.textTertiary+"26"};default:return{label:"WRITE",color:_sharedUi.buoyColors.success,bgColor:_sharedUi.buoyColors.success+"26"}}}function formatTime(e){const o=new Date(e);const n=o.getHours().toString().padStart(2,"0");const r=o.getMinutes().toString().padStart(2,"0");const t=o.getSeconds().toString().padStart(2,"0");const l=o.getMilliseconds().toString().padStart(3,"0");return`${n}:${r}:${t}.${l}`}function formatTimestamp(e){return new Date(e).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function getValueType(e){if(e===null)return"null";if(e===void 0)return"undefined";if(Array.isArray(e))return"array";return typeof e}function getChangeLabel(e){return e==="initial"?"INIT":"WRITE"}const DIFF_MODE_TABS=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}];const JotaiAtomInfoView=(0,_react.memo)(function e({change:o}){const n=(0,_license.useIsPro)();const[r,t]=(0,_react.useState)(false);const l=getCategoryInfo(o.category);const i=_jotaiStateStore.jotaiStateStore.getAtomColor(o.atomLabel);const c=(0,_react.useCallback)(async()=>{if(!n){t(true);return}await(0,_sharedUi.copyToClipboard)(o.nextValue)},[o.nextValue,n]);return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:infoStyles.container,contentContainerStyle:infoStyles.content,showsVerticalScrollIndicator:false,testID:`${_testIDs.JOTAI_TEST_ID}-detail-scroll`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.card,testID:`${_testIDs.JOTAI_TEST_ID}-info-card`,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:infoStyles.sectionHeader,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.sectionHeaderLeft,children:[(0,_jsxRuntime.jsx)(_sharedUi.Info,{size:14,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:infoStyles.sectionTitle,children:"CHANGE INFO"})]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.cardContent,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.infoRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:infoStyles.infoLabel,children:"Atom"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[infoStyles.infoValue,infoStyles.infoValueMono,{color:i}],numberOfLines:1,ellipsizeMode:"middle",testID:`${_testIDs.JOTAI_TEST_ID}-info-atom`,children:o.atomLabel})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.infoRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:infoStyles.infoLabel,children:"Time"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[infoStyles.infoValue,infoStyles.infoValueMono],testID:`${_testIDs.JOTAI_TEST_ID}-info-time`,children:formatTime(o.timestamp)})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.badgeRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[infoStyles.categoryBadge,{backgroundColor:l.bgColor}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[infoStyles.categoryText,{color:l.color}],testID:`${_testIDs.JOTAI_TEST_ID}-info-category`,children:l.label})}),o.hasValueChange?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.changesBadge,children:[(0,_jsxRuntime.jsx)(_sharedUi.Zap,{size:10,color:_sharedUi.buoyColors.success}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:infoStyles.changesText,testID:`${_testIDs.JOTAI_TEST_ID}-info-changes`,children:o.diffSummary||"changed"})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:infoStyles.noChangesBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:infoStyles.noChangesText,testID:`${_testIDs.JOTAI_TEST_ID}-info-no-changes`,children:"no change"})})]})]})]}),o.changedKeys.length>0&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.card,testID:`${_testIDs.JOTAI_TEST_ID}-keys-card`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.sectionHeader,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.sectionHeaderLeft,children:[(0,_jsxRuntime.jsx)(_sharedUi.Zap,{size:14,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:infoStyles.sectionTitle,children:"CHANGED KEYS"})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:infoStyles.countBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:infoStyles.countText,testID:`${_testIDs.JOTAI_TEST_ID}-keys-count`,children:o.changedKeys.length})})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:infoStyles.cardContent,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:infoStyles.keysContainer,children:o.changedKeys.map(a=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:infoStyles.keyBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:infoStyles.keyText,testID:`${_testIDs.JOTAI_TEST_ID}-key-${(0,_testIDs.slugForTestID)(a)}`,children:a})},a))})})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:infoStyles.actionsRow,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[infoStyles.actionButton,infoStyles.actionButtonCopy],onTouchEnd:c,testID:`${_testIDs.JOTAI_TEST_ID}-copy-value`,accessibilityRole:"button",accessibilityLabel:"Copy value",children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[infoStyles.actionButtonText,{color:_sharedUi.night.color.accent}],children:"COPY VALUE"})})}),(0,_jsxRuntime.jsx)(_sharedUi.ProUpgradeModal,{visible:r,onClose:()=>t(false),featureName:"Copy"})]})});function JotaiAtomDetailContent({change:e,changes:o,selectedIndex:n,onIndexChange:r,disableInternalFooter:t=false,initialView:l="change"}){const[i,c]=(0,_react.useState)(l);const[a,d]=(0,_react.useState)("tree");const u=o.length;const g=_jotaiStateStore.jotaiStateStore.getAtomColor(e.atomLabel);const f=getChangeLabel(e.category);const T=getValueType((0,_sharedUi.parseValue)(e.nextValue));const h=u-n;const x=n<u-1?n+1:null;const s=x!==null?o[x]:null;const m=h-1;const w=(0,_react.useMemo)(()=>({index:x??0,label:m>0?`#${m}`:"Initial",timestamp:s?formatTimestamp(s.timestamp):"",relativeTime:s?(0,_sharedUi.formatRelativeTime)(new Date(s.timestamp)):"value",badge:s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.changeBadgeSmall,{backgroundColor:`${_jotaiStateStore.jotaiStateStore.getAtomColor(s.atomLabel)}20`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.changeTextSmall,{color:_jotaiStateStore.jotaiStateStore.getAtomColor(s.atomLabel)}],children:getChangeLabel(s.category)})}):void 0}),[x,s,m]);const V=(0,_react.useMemo)(()=>({index:n,label:`#${h}`,timestamp:formatTimestamp(e.timestamp),relativeTime:(0,_sharedUi.formatRelativeTime)(new Date(e.timestamp)),badge:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.changeBadgeSmall,{backgroundColor:`${g}20`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.changeTextSmall,{color:g}],children:f})})}),[n,e.timestamp,g,f,h]);const S=(0,_react.useCallback)(()=>{const y=(0,_sharedUi.parseValue)(e.nextValue);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.contentCard,testID:`${_testIDs.JOTAI_TEST_ID}-value-card`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.valueHeader,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.valueLabel,children:"VALUE AFTER CHANGE"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.valueHeaderBadges,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.changeBadge,{backgroundColor:`${g}20`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.changeText,{color:g}],children:f})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.typeBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.typeText,testID:`${_testIDs.JOTAI_TEST_ID}-value-type`,children:T.toUpperCase()})})]})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:infoStyles.dataViewerContainer,children:(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{title:"",data:y,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})},[e.nextValue,g,f,T]);const C=(0,_react.useCallback)(()=>{const y=(0,_sharedUi.parseValue)(e.prevValue);const b=(0,_sharedUi.parseValue)(e.nextValue);if(a==="split"){return(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{style:{flex:1},showsVerticalScrollIndicator:true,children:(0,_jsxRuntime.jsx)(_dataViewer.SplitDiffViewer,{oldValue:y,newValue:b,theme:_dataViewer.diffThemes.devToolsDefault,options:{hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3},showThemeName:false})})}return(0,_jsxRuntime.jsx)(_dataViewer.TreeDiffViewer,{oldValue:y,newValue:b})},[e.prevValue,e.nextValue,a]);const j=(0,_react.useCallback)(()=>{r(Math.min(u-1,n+1))},[n,u,r]);const I=(0,_react.useCallback)(()=>{r(Math.max(0,n-1))},[n,r]);const D=e.prevValue===void 0;const p=!t&&u>1;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsx)(_sharedUi.DetailViewToggle,{views:VIEW_CONFIGS,activeView:i,onViewChange:c,disabledKeys:D?DIFF_DISABLED:void 0,testIDPrefix:_testIDs.JOTAI_TEST_ID}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.contentArea,p&&styles.contentAreaFooterPad],children:[i==="change"&&(0,_jsxRuntime.jsx)(JotaiAtomInfoView,{change:e}),i==="value"&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.stateContainer,children:S()}),i==="diff"&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.diffContainer,testID:`${_testIDs.JOTAI_TEST_ID}-diff`,children:[(0,_jsxRuntime.jsx)(_sharedUi.DiffModeTabs,{tabs:DIFF_MODE_TABS,activeTab:a,onTabChange:d,testIDPrefix:`${_testIDs.JOTAI_TEST_ID}-diff-tab`}),(0,_jsxRuntime.jsx)(_sharedUi.CompareBar,{leftEvent:w,rightEvent:V}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.diffContent,testID:`${_testIDs.JOTAI_TEST_ID}-diff-content`,children:C()})]})]}),p&&(0,_jsxRuntime.jsx)(_sharedUi.EventStepperFooter,{currentIndex:h-1,totalItems:u,onPrevious:j,onNext:I,itemLabel:"Change",subtitle:(0,_sharedUi.formatRelativeTime)(new Date(e.timestamp)),absolute:true})]})}function JotaiAtomDetailFooter({change:e,changes:o,selectedIndex:n,onIndexChange:r}){const t=o.length;if(t<=1)return null;const l=t-n;return(0,_jsxRuntime.jsx)(_sharedUi.EventStepperFooter,{currentIndex:l-1,totalItems:t,onPrevious:()=>r(Math.min(t-1,n+1)),onNext:()=>r(Math.max(0,n-1)),itemLabel:"Change",subtitle:(0,_sharedUi.formatRelativeTime)(new Date(e.timestamp))})}const styles=_reactNative.StyleSheet.create({container:{flex:1,backgroundColor:"transparent"},contentArea:{flex:1},contentAreaFooterPad:{paddingBottom:96},stateContainer:{flex:1,padding:14},contentCard:{backgroundColor:_sharedUi.night.color.surface,borderRadius:14,padding:14,borderWidth:1,borderColor:_sharedUi.night.color.border},valueHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},valueLabel:{fontSize:10,color:_sharedUi.night.color.textSecondary,fontFamily:_sharedUi.monoFont,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:_sharedUi.monoFont,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:_sharedUi.night.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:_sharedUi.night.color.textTertiary,fontFamily:_sharedUi.monoFont},valueBox:{backgroundColor:_sharedUi.night.color.bg,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.border,padding:8},valueText:{fontSize:12,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:_sharedUi.monoFont}});const infoStyles=_reactNative.StyleSheet.create({container:{flex:1},content:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:_sharedUi.night.color.surface,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.accentBorderStrong,overflow:"hidden",shadowColor:_sharedUi.night.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:_sharedUi.night.color.accentBorder,backgroundColor:_sharedUi.night.color.accentSoft},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont},cardContent:{padding:14,gap:10},infoRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},infoLabel:{fontSize:11,color:_sharedUi.night.color.textTertiary,fontWeight:"500"},infoValue:{fontSize:11,color:_sharedUi.night.color.text,fontWeight:"500",flex:1,textAlign:"right",marginLeft:12},infoValueMono:{fontFamily:_sharedUi.monoFont},badgeRow:{flexDirection:"row",flexWrap:"wrap",gap:8,marginTop:6},categoryBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4},categoryText:{fontSize:9,fontWeight:"700",letterSpacing:.3},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.buoyColors.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:_sharedUi.buoyColors.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.night.color.surfaceElevated},noChangesText:{fontSize:9,fontWeight:"600",color:_sharedUi.night.color.textTertiary},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:_sharedUi.night.color.accentSoft,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder},keyText:{fontSize:11,fontWeight:"600",color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.night.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont},actionsRow:{flexDirection:"row",gap:12},actionButton:{paddingHorizontal:14,paddingVertical:8,borderRadius:8,borderWidth:1},actionButtonCopy:{borderColor:_sharedUi.night.color.accentBorder,backgroundColor:_sharedUi.night.color.accentSoft},actionButtonText:{fontSize:10,fontWeight:"700",fontFamily:_sharedUi.monoFont,letterSpacing:.3},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.JotaiAtomDetailContent=JotaiAtomDetailContent;exports.JotaiAtomDetailFooter=JotaiAtomDetailFooter;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _dataViewer=require("@buoy-gg/shared-ui/dataViewer");var _license=require("@buoy-gg/license");var _jotaiStateStore=require("../utils/jotaiStateStore");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(e,o){if("function"==typeof WeakMap)var n=new WeakMap,r=new WeakMap;return(_interopRequireWildcard=function(t,l){if(!l&&t&&t.__esModule)return t;var i,c,a={__proto__:null,default:t};if(null===t||"object"!=typeof t&&"function"!=typeof t)return a;if(i=l?r:n){if(i.has(t))return i.get(t);i.set(t,a)}for(const d in t)"default"!==d&&{}.hasOwnProperty.call(t,d)&&((c=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(t,d))&&(c.get||c.set)?i(a,d,c):a[d]=t[d]);return a})(e,o)}const VIEW_CONFIGS=[{key:"change",label:"CHANGE",icon:_sharedUi.FileText},{key:"value",label:"VALUE",icon:_sharedUi.Database},{key:"diff",label:"DIFF",icon:_sharedUi.GitBranch}];const DIFF_DISABLED=["diff"];function getCategoryInfo(e){switch(e){case"initial":return{label:"INITIAL",color:_sharedUi.night.color.textTertiary,bgColor:_sharedUi.night.color.textTertiary+"26"};default:return{label:"WRITE",color:_sharedUi.buoyColors.success,bgColor:_sharedUi.buoyColors.success+"26"}}}function formatTime(e){const o=new Date(e);const n=o.getHours().toString().padStart(2,"0");const r=o.getMinutes().toString().padStart(2,"0");const t=o.getSeconds().toString().padStart(2,"0");const l=o.getMilliseconds().toString().padStart(3,"0");return`${n}:${r}:${t}.${l}`}function formatTimestamp(e){return new Date(e).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function getValueType(e){if(e===null)return"null";if(e===void 0)return"undefined";if(Array.isArray(e))return"array";return typeof e}function getChangeLabel(e){return e==="initial"?"INIT":"WRITE"}const DIFF_MODE_TABS=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}];const JotaiAtomInfoView=(0,_react.memo)(function e({change:o}){const n=(0,_license.useIsPro)();const[r,t]=(0,_react.useState)(false);const l=getCategoryInfo(o.category);const i=_jotaiStateStore.jotaiStateStore.getAtomColor(o.atomLabel);const c=(0,_react.useCallback)(async()=>{if(!n){t(true);return}await(0,_sharedUi.copyToClipboard)(o.nextValue)},[o.nextValue,n]);return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",style:infoStyles.container,contentContainerStyle:infoStyles.content,showsVerticalScrollIndicator:false,testID:`${_testIDs.JOTAI_TEST_ID}-detail-scroll`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.card,testID:`${_testIDs.JOTAI_TEST_ID}-info-card`,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:infoStyles.sectionHeader,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.sectionHeaderLeft,children:[(0,_jsxRuntime.jsx)(_sharedUi.Info,{size:14,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:infoStyles.sectionTitle,children:"CHANGE INFO"})]})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.cardContent,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.infoRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:infoStyles.infoLabel,children:"Atom"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[infoStyles.infoValue,infoStyles.infoValueMono,{color:i}],numberOfLines:1,ellipsizeMode:"middle",testID:`${_testIDs.JOTAI_TEST_ID}-info-atom`,children:o.atomLabel})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.infoRow,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:infoStyles.infoLabel,children:"Time"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[infoStyles.infoValue,infoStyles.infoValueMono],testID:`${_testIDs.JOTAI_TEST_ID}-info-time`,children:formatTime(o.timestamp)})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.badgeRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[infoStyles.categoryBadge,{backgroundColor:l.bgColor}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[infoStyles.categoryText,{color:l.color}],testID:`${_testIDs.JOTAI_TEST_ID}-info-category`,children:l.label})}),o.hasValueChange?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.changesBadge,children:[(0,_jsxRuntime.jsx)(_sharedUi.Zap,{size:10,color:_sharedUi.buoyColors.success}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:infoStyles.changesText,testID:`${_testIDs.JOTAI_TEST_ID}-info-changes`,children:o.diffSummary||"changed"})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:infoStyles.noChangesBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:infoStyles.noChangesText,testID:`${_testIDs.JOTAI_TEST_ID}-info-no-changes`,children:"no change"})})]})]})]}),o.changedKeys.length>0&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.card,testID:`${_testIDs.JOTAI_TEST_ID}-keys-card`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.sectionHeader,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:infoStyles.sectionHeaderLeft,children:[(0,_jsxRuntime.jsx)(_sharedUi.Zap,{size:14,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:infoStyles.sectionTitle,children:"CHANGED KEYS"})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:infoStyles.countBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:infoStyles.countText,testID:`${_testIDs.JOTAI_TEST_ID}-keys-count`,children:o.changedKeys.length})})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:infoStyles.cardContent,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:infoStyles.keysContainer,children:o.changedKeys.map(a=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:infoStyles.keyBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:infoStyles.keyText,testID:`${_testIDs.JOTAI_TEST_ID}-key-${(0,_testIDs.slugForTestID)(a)}`,children:a})},a))})})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:infoStyles.actionsRow,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[infoStyles.actionButton,infoStyles.actionButtonCopy],onTouchEnd:c,testID:`${_testIDs.JOTAI_TEST_ID}-copy-value`,accessibilityRole:"button",accessibilityLabel:"Copy value",children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[infoStyles.actionButtonText,{color:_sharedUi.night.color.accent}],children:"COPY VALUE"})})}),(0,_jsxRuntime.jsx)(_sharedUi.ProUpgradeModal,{visible:r,onClose:()=>t(false),featureName:"Copy"})]})});function JotaiAtomDetailContent({change:e,changes:o,selectedIndex:n,onIndexChange:r,disableInternalFooter:t=false,initialView:l="change"}){const[i,c]=(0,_react.useState)(l);const[a,d]=(0,_react.useState)("tree");const u=o.length;const g=_jotaiStateStore.jotaiStateStore.getAtomColor(e.atomLabel);const f=getChangeLabel(e.category);const T=getValueType((0,_sharedUi.parseValue)(e.nextValue));const h=u-n;const x=n<u-1?n+1:null;const s=x!==null?o[x]:null;const m=h-1;const w=(0,_react.useMemo)(()=>({index:x??0,label:m>0?`#${m}`:"Initial",timestamp:s?formatTimestamp(s.timestamp):"",relativeTime:s?(0,_sharedUi.formatRelativeTime)(new Date(s.timestamp)):"value",badge:s?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.changeBadgeSmall,{backgroundColor:`${_jotaiStateStore.jotaiStateStore.getAtomColor(s.atomLabel)}20`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.changeTextSmall,{color:_jotaiStateStore.jotaiStateStore.getAtomColor(s.atomLabel)}],children:getChangeLabel(s.category)})}):void 0}),[x,s,m]);const V=(0,_react.useMemo)(()=>({index:n,label:`#${h}`,timestamp:formatTimestamp(e.timestamp),relativeTime:(0,_sharedUi.formatRelativeTime)(new Date(e.timestamp)),badge:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.changeBadgeSmall,{backgroundColor:`${g}20`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.changeTextSmall,{color:g}],children:f})})}),[n,e.timestamp,g,f,h]);const S=(0,_react.useCallback)(()=>{const y=(0,_sharedUi.parseValue)(e.nextValue);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.contentCard,testID:`${_testIDs.JOTAI_TEST_ID}-value-card`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.valueHeader,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.valueLabel,children:"VALUE AFTER CHANGE"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.valueHeaderBadges,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.changeBadge,{backgroundColor:`${g}20`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.changeText,{color:g}],children:f})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.typeBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.typeText,testID:`${_testIDs.JOTAI_TEST_ID}-value-type`,children:T.toUpperCase()})})]})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:infoStyles.dataViewerContainer,children:(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{title:"",data:y,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})},[e.nextValue,g,f,T]);const C=(0,_react.useCallback)(()=>{const y=(0,_sharedUi.parseValue)(e.prevValue);const b=(0,_sharedUi.parseValue)(e.nextValue);if(a==="split"){return(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",style:{flex:1},showsVerticalScrollIndicator:true,children:(0,_jsxRuntime.jsx)(_dataViewer.SplitDiffViewer,{oldValue:y,newValue:b,theme:_dataViewer.diffThemes.devToolsDefault,options:{hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3},showThemeName:false})})}return(0,_jsxRuntime.jsx)(_dataViewer.TreeDiffViewer,{oldValue:y,newValue:b})},[e.prevValue,e.nextValue,a]);const j=(0,_react.useCallback)(()=>{r(Math.min(u-1,n+1))},[n,u,r]);const I=(0,_react.useCallback)(()=>{r(Math.max(0,n-1))},[n,r]);const D=e.prevValue===void 0;const p=!t&&u>1;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsx)(_sharedUi.DetailViewToggle,{views:VIEW_CONFIGS,activeView:i,onViewChange:c,disabledKeys:D?DIFF_DISABLED:void 0,testIDPrefix:_testIDs.JOTAI_TEST_ID}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.contentArea,p&&styles.contentAreaFooterPad],children:[i==="change"&&(0,_jsxRuntime.jsx)(JotaiAtomInfoView,{change:e}),i==="value"&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.stateContainer,children:S()}),i==="diff"&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.diffContainer,testID:`${_testIDs.JOTAI_TEST_ID}-diff`,children:[(0,_jsxRuntime.jsx)(_sharedUi.DiffModeTabs,{tabs:DIFF_MODE_TABS,activeTab:a,onTabChange:d,testIDPrefix:`${_testIDs.JOTAI_TEST_ID}-diff-tab`}),(0,_jsxRuntime.jsx)(_sharedUi.CompareBar,{leftEvent:w,rightEvent:V}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.diffContent,testID:`${_testIDs.JOTAI_TEST_ID}-diff-content`,children:C()})]})]}),p&&(0,_jsxRuntime.jsx)(_sharedUi.EventStepperFooter,{currentIndex:h-1,totalItems:u,onPrevious:j,onNext:I,itemLabel:"Change",subtitle:(0,_sharedUi.formatRelativeTime)(new Date(e.timestamp)),absolute:true})]})}function JotaiAtomDetailFooter({change:e,changes:o,selectedIndex:n,onIndexChange:r}){const t=o.length;if(t<=1)return null;const l=t-n;return(0,_jsxRuntime.jsx)(_sharedUi.EventStepperFooter,{currentIndex:l-1,totalItems:t,onPrevious:()=>r(Math.min(t-1,n+1)),onNext:()=>r(Math.max(0,n-1)),itemLabel:"Change",subtitle:(0,_sharedUi.formatRelativeTime)(new Date(e.timestamp))})}const styles=_reactNative.StyleSheet.create({container:{flex:1,backgroundColor:"transparent"},contentArea:{flex:1},contentAreaFooterPad:{paddingBottom:96},stateContainer:{flex:1,padding:14},contentCard:{backgroundColor:_sharedUi.night.color.surface,borderRadius:14,padding:14,borderWidth:1,borderColor:_sharedUi.night.color.border},valueHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},valueLabel:{fontSize:10,color:_sharedUi.night.color.textSecondary,fontFamily:_sharedUi.monoFont,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:_sharedUi.monoFont,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:_sharedUi.night.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:_sharedUi.night.color.textTertiary,fontFamily:_sharedUi.monoFont},valueBox:{backgroundColor:_sharedUi.night.color.bg,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.border,padding:8},valueText:{fontSize:12,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:_sharedUi.monoFont}});const infoStyles=_reactNative.StyleSheet.create({container:{flex:1},content:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:_sharedUi.night.color.surface,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.accentBorderStrong,overflow:"hidden",shadowColor:_sharedUi.night.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:_sharedUi.night.color.accentBorder,backgroundColor:_sharedUi.night.color.accentSoft},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont},cardContent:{padding:14,gap:10},infoRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},infoLabel:{fontSize:11,color:_sharedUi.night.color.textTertiary,fontWeight:"500"},infoValue:{fontSize:11,color:_sharedUi.night.color.text,fontWeight:"500",flex:1,textAlign:"right",marginLeft:12},infoValueMono:{fontFamily:_sharedUi.monoFont},badgeRow:{flexDirection:"row",flexWrap:"wrap",gap:8,marginTop:6},categoryBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4},categoryText:{fontSize:9,fontWeight:"700",letterSpacing:.3},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.buoyColors.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:_sharedUi.buoyColors.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.night.color.surfaceElevated},noChangesText:{fontSize:9,fontWeight:"600",color:_sharedUi.night.color.textTertiary},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:_sharedUi.night.color.accentSoft,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder},keyText:{fontSize:11,fontWeight:"600",color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.night.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont},actionsRow:{flexDirection:"row",gap:12},actionButton:{paddingHorizontal:14,paddingVertical:8,borderRadius:8,borderWidth:1},actionButtonCopy:{borderColor:_sharedUi.night.color.accentBorder,backgroundColor:_sharedUi.night.color.accentSoft},actionButtonText:{fontSize:10,fontWeight:"700",fontFamily:_sharedUi.monoFont,letterSpacing:.3},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.JotaiModal=JotaiModal;exports.JotaiToolView=JotaiToolView;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _license=require("@buoy-gg/license");var _useJotaiAtomChanges=require("../hooks/useJotaiAtomChanges");var _JotaiAtomChangeItem=require("./JotaiAtomChangeItem");var _JotaiAtomDetailContent=require("./JotaiAtomDetailContent");var _JotaiAtomBrowser=require("./JotaiAtomBrowser");var _JotaiAtomValueDetailContent=require("./JotaiAtomValueDetailContent");var _JotaiEventFilterView=require("./JotaiEventFilterView");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function EventsEmptyState({isEnabled:u,searchText:S,totalChanges:f}){const A=(0,_sharedUi.resolveListEmptyState)({subject:"changes",search:S,total:f,capturing:u,waiting:{otto:"waiting",title:"No atom changes",message:"Atom changes will appear here as values update."},paused:{title:"No atom changes",message:"Enable capture to start recording atom changes"}});return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{...A,testID:`${_testIDs.JOTAI_TEST_ID}-empty`})}function JotaiModal({visible:u,onClose:S,onBack:f,onMinimize:A,enableSharedModalDimensions:X=false,inline:Y=false,initialTab:Z,initialSelectedChangeId:h,initialDetailView:ee,onChangeSelect:j,onAtomExpand:M}){const Ee=(0,_license.useIsPro)();const y=(0,_sharedUi.useLimit)("jotai.changes");const[te,H]=(0,_react.useState)(false);const[s,oe]=(0,_react.useState)(Z??"atoms");const[a,_]=(0,_react.useState)(null);const[T,V]=(0,_react.useState)(null);const[D,v]=(0,_react.useState)(false);const[l,P]=(0,_react.useState)(new Set);const{atomChanges:$,filteredChanges:E,stats:ae,filter:we,setFilter:b,atoms:x,clearChanges:ne,isEnabled:I,toggleCapture:re}=(0,_useJotaiAtomChanges.useJotaiAtomChanges)();const r=(0,_react.useMemo)(()=>{if(l.size===0)return E;return E.filter(e=>!Array.from(l).some(t=>e.atomLabel.toLowerCase().includes(t.toLowerCase())))},[E,l]);const g=(0,_react.useMemo)(()=>{if(l.size===0)return x;return x.filter(e=>!Array.from(l).some(t=>e.label.toLowerCase().includes(t.toLowerCase())))},[x,l]);const se=(0,_react.useMemo)(()=>{if(!a)return 0;return $.filter(e=>e.atomLabel===a).length},[$,a]);const C=(0,_react.useMemo)(()=>a?r.filter(e=>e.atomLabel===a):r,[r,a]);const w=(0,_react.useMemo)(()=>C.slice(0,y),[C,y]);const k=(0,_react.useMemo)(()=>Math.max(0,C.length-y),[C.length,y]);const le=k>0;const o=w;const[J,c]=(0,_react.useState)(null);const d=(0,_react.useMemo)(()=>{if(J===null)return null;const e=o.findIndex(t=>t.id===J);return e>=0?e:null},[J,o]);const n=d!==null?o[d]:null;const O=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(!j)return;const e=n?.id??null;if(e===null||e===O.current)return;O.current=e;j(n)},[n,j]);const L=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(!h)return;if(L.current===h)return;const e=o.some(t=>t.id===h);if(!e)return;L.current=h;c(h)},[h,o]);const[i,B]=(0,_react.useState)("");const[ie,p]=(0,_react.useState)(false);const ke=(0,_react.useRef)(null);const ce=(0,_react.useRef)(null);const de=(0,_react.useCallback)(e=>{},[]);const ue=e=>{B(e);if(s==="events"){b(t=>({...t,searchText:e}))}};const he=(0,_react.useCallback)(()=>{B("");b(e=>({...e,searchText:""}));p(false)},[b]);const R=(0,_react.useCallback)(e=>{c(e.id)},[]);const ge=(0,_react.useCallback)(()=>{H(true)},[]);const me=(0,_react.useCallback)(()=>{c(null)},[]);const F=(0,_react.useCallback)(e=>{const t=o[e];if(t)c(t.id)},[o]);const Te=(0,_react.useCallback)(e=>{_(e);c(null)},[]);const be=(0,_react.useCallback)(()=>{_(null);c(null)},[]);const xe=(0,_react.useCallback)(e=>{V(e);M?.(e)},[M]);const fe=(0,_react.useCallback)(()=>{V(null)},[]);const ye=(0,_react.useCallback)(()=>{return g.reduce((e,t)=>{try{const m=t.getValue();e[t.label]=(0,_sharedUi.truncatePayload)(m)}catch{e[t.label]=null}return e},{})},[g]);const Ie=(0,_react.useCallback)(()=>{return r.map(e=>({id:e.id,atomLabel:e.atomLabel,timestamp:e.timestamp,prevValue:(0,_sharedUi.truncatePayload)(e.prevValue),nextValue:(0,_sharedUi.truncatePayload)(e.nextValue),hasValueChange:e.hasValueChange,changedKeys:e.changedKeys}))},[r]);const Ce=(0,_react.useCallback)(()=>{return o.map(e=>({id:e.id,atomLabel:e.atomLabel,timestamp:e.timestamp,prevValue:(0,_sharedUi.truncatePayload)(e.prevValue),nextValue:(0,_sharedUi.truncatePayload)(e.nextValue),hasValueChange:e.hasValueChange,changedKeys:e.changedKeys}))},[o]);const pe=(0,_react.useCallback)(e=>{P(t=>{const m=new Set(t);if(m.has(e))m.delete(e);else m.add(e);return m})},[]);const Se=(0,_react.useCallback)(e=>{P(t=>new Set([...t,e]))},[]);const Ae=(0,_react.useCallback)(e=>{oe(e);_(null);c(null);v(false);if(i){B("");b(t=>({...t,searchText:""}))}p(false)},[i,b]);const z=(0,_react.useCallback)(e=>e.id,[]);const N=(0,_react.useMemo)(()=>(0,_testIDs.buildChangeRowTestIDs)(o),[o]);const q=(0,_react.useCallback)(({item:e})=>(0,_jsxRuntime.jsx)(_JotaiAtomChangeItem.JotaiAtomChangeItem,{change:e,onPress:R,testID:N.get(e.id)}),[R,N]);const W=l.size>0;const K=()=>{if(D){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:()=>v(false)}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"Filters",centered:true,testID:`${_testIDs.JOTAI_TEST_ID}-filters-title`})]})}if(n){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:me}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:`${n.atomLabel}/${n.category}`,centered:true,testID:`${_testIDs.JOTAI_TEST_ID}-detail-title`})]})}if(a){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:be}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:`${a} History`,centered:true,testID:`${_testIDs.JOTAI_TEST_ID}-history-title`}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Actions,{children:(0,_jsxRuntime.jsx)(_sharedUi.ToolbarCopyButton,{value:Ce,disabled:o.length===0,buttonStyle:styles.headerActionButton,testID:`${_testIDs.JOTAI_TEST_ID}-copy`})})]})}if(T){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:fe}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:T,centered:true,testID:`${_testIDs.JOTAI_TEST_ID}-atom-detail-title`})]})}return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[f&&(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:f}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"",children:ie?(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Search,{value:i,onChangeText:ue,onCancel:he,placeholder:s==="atoms"?"Search atoms...":"Search events...",accessibilityLabel:"Search Jotai atoms and events",iconSize:14,testID:`${_testIDs.JOTAI_TEST_ID}-search-field`,containerTestID:`${_testIDs.JOTAI_TEST_ID}-search`,clearTestID:`${_testIDs.JOTAI_TEST_ID}-search-clear`,onBlur:()=>{if(i.length===0)p(false)}}):(0,_jsxRuntime.jsx)(_sharedUi.TabSelector,{tabs:[{key:"atoms",label:`Atoms${g.length>0?` (${g.length})`:""}`},{key:"events",label:`Events${r.length>0?` (${r.length})`:""}`}],activeTab:s,onTabChange:Ae,testIDPrefix:`${_testIDs.JOTAI_TEST_ID}-tab`})}),(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader.Actions,{children:[(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>p(true),style:styles.headerActionButton,testID:`${_testIDs.JOTAI_TEST_ID}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:(0,_jsxRuntime.jsx)(_sharedUi.Search,{size:14,color:_sharedUi.night.color.textSecondary})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>v(true),style:[styles.headerActionButton,W&&styles.headerActionButtonActive],testID:`${_testIDs.JOTAI_TEST_ID}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:(0,_jsxRuntime.jsx)(_sharedUi.Filter,{size:14,color:W?_sharedUi.night.color.accent:_sharedUi.night.color.textSecondary})}),s==="atoms"&&(0,_jsxRuntime.jsx)(_sharedUi.ToolbarCopyButton,{value:ye,disabled:g.length===0,buttonStyle:styles.headerActionButton,testID:`${_testIDs.JOTAI_TEST_ID}-copy`}),s==="events"&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ToolbarCopyButton,{value:Ie,disabled:r.length===0,buttonStyle:styles.headerActionButton,testID:`${_testIDs.JOTAI_TEST_ID}-copy`}),(0,_jsxRuntime.jsx)(_sharedUi.PowerToggleButton,{isEnabled:I,onToggle:re,accessibilityLabel:"Toggle Jotai atom capture",testID:`${_testIDs.JOTAI_TEST_ID}-power`}),(0,_jsxRuntime.jsx)(_sharedUi.ToolbarClearButton,{onPress:ne,disabled:r.length===0,buttonStyle:styles.headerActionButton,testID:`${_testIDs.JOTAI_TEST_ID}-clear`})]})]})]})};const je=()=>{if(D){return(0,_jsxRuntime.jsx)(_JotaiEventFilterView.JotaiEventFilterView,{ignoredPatterns:l,onTogglePattern:pe,onAddPattern:Se,atoms:x})}if(n&&d!==null){return(0,_jsxRuntime.jsx)(_JotaiAtomDetailContent.JotaiAtomDetailContent,{change:n,changes:o,selectedIndex:d,onIndexChange:F,disableInternalFooter:true,initialView:ee})}if(a){return o.length>0?(0,_jsxRuntime.jsx)(_reactNative.FlatList,{testID:`${_testIDs.JOTAI_TEST_ID}-history-list`,data:o,renderItem:q,keyExtractor:z,contentContainerStyle:styles.listContent,showsVerticalScrollIndicator:true,..._sharedUi.EVENT_LIST_PRESET}):(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.JOTAI_TEST_ID}-history-empty`,...(0,_sharedUi.resolveListEmptyState)({subject:"changes",search:i,total:i.trim()?se:0,capturing:I,waiting:{otto:"waiting",title:"No history yet",message:`Changes for ${a} will appear here.`},paused:{title:"No history yet",message:`Capture is off, so nothing is being recorded for ${a}.`}})})}if(T){const e=x.find(t=>t.label===T)??null;return e?(0,_jsxRuntime.jsx)(_JotaiAtomValueDetailContent.JotaiAtomValueDetailContent,{atom:e,onViewHistory:Te}):(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.JOTAI_TEST_ID}-atom-detail-gone`,otto:"ghost",title:"Atom no longer registered",message:`${T} is not in the registry any more.`})}if(s==="atoms"){return(0,_jsxRuntime.jsx)(_JotaiAtomBrowser.JotaiAtomBrowser,{atoms:g,searchQuery:i,onOpenAtom:xe})}return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[!I&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.disabledBanner,testID:`${_testIDs.JOTAI_TEST_ID}-banner-disabled`,children:[(0,_jsxRuntime.jsx)(_sharedUi.Power,{size:14,color:_sharedUi.night.color.warning}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.disabledText,children:"Atom capture is disabled"})]}),le&&(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{style:styles.lockedBanner,onPress:ge,activeOpacity:.8,testID:`${_testIDs.JOTAI_TEST_ID}-locked`,accessibilityRole:"button",children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.lockedText,testID:`${_testIDs.JOTAI_TEST_ID}-locked-text`,children:[k," older"," ",k===1?"change":"changes"," locked"]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.upgradeBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.upgradeBadgeText,children:"UPGRADE"})})]}),w.length>0?(0,_jsxRuntime.jsx)(_reactNative.FlatList,{ref:ce,testID:`${_testIDs.JOTAI_TEST_ID}-list`,data:w,renderItem:q,keyExtractor:z,contentContainerStyle:styles.listContent,showsVerticalScrollIndicator:true,..._sharedUi.EVENT_LIST_PRESET}):(0,_jsxRuntime.jsx)(EventsEmptyState,{isEnabled:I,searchText:i,totalChanges:ae.totalChanges})]})};const _e=X?_sharedUi.devToolsStorageKeys.modal.root():"buoy-jotai-modal";if(!u)return null;const U=n&&d!==null?(0,_jsxRuntime.jsx)(_JotaiAtomDetailContent.JotaiAtomDetailFooter,{change:n,changes:o,selectedIndex:d,onIndexChange:F}):null;const De=n&&o.length>1?68:0;const ve=!D&&!(n&&d!==null)&&(a!=null||s==="events"||s==="atoms");const G=(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,children:je()});const Q=(0,_jsxRuntime.jsx)(_sharedUi.ProUpgradeModal,{visible:te,onClose:()=>H(false),featureName:"Full Atom History"});if(Y){return(0,_jsxRuntime.jsxs)(_sharedUi.TickProvider,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.inlineRoot,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.inlineHeader,..._sharedUi.windowDragProps,children:K()}),G,U]}),Q]})}return(0,_jsxRuntime.jsxs)(_sharedUi.TickProvider,{children:[(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:u,onClose:S,onMinimize:A,persistenceKey:_e,header:{showToggleButton:true,customContent:K()},onModeChange:de,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:ve,styles:{},footer:U,footerHeight:De,children:G}),Q]})}function JotaiToolView(u={}){return(0,_jsxRuntime.jsx)(JotaiModal,{...u,inline:true,visible:true,onClose:()=>{}})}const styles=_reactNative.StyleSheet.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:_sharedUi.macOSColors.border.default,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:_sharedUi.night.color.buttonSurface,borderWidth:1,borderColor:_sharedUi.night.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonActive:{backgroundColor:_sharedUi.night.color.accentSoft,borderColor:_sharedUi.night.color.accentBorderStrong},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:_sharedUi.night.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.warning+"20"},disabledText:{color:_sharedUi.night.color.warning,fontSize:11,flex:1},listContent:{paddingTop:8,paddingBottom:20},emptyState:{alignItems:"center",paddingVertical:40},emptyTitle:{color:_sharedUi.night.color.text,fontSize:14,fontWeight:"600",marginTop:12,marginBottom:6},emptyText:{color:_sharedUi.night.color.textTertiary,fontSize:12,textAlign:"center",lineHeight:18},lockedBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:_sharedUi.night.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder},lockedText:{color:_sharedUi.night.color.accent,fontSize:11,fontWeight:"500",flex:1},upgradeBadge:{backgroundColor:_sharedUi.night.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},upgradeBadgeText:{color:_sharedUi.night.color.onAccent,fontSize:9,fontWeight:"700",letterSpacing:.5}});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.JotaiModal=JotaiModal;exports.JotaiToolView=JotaiToolView;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _license=require("@buoy-gg/license");var _useJotaiAtomChanges=require("../hooks/useJotaiAtomChanges");var _JotaiAtomChangeItem=require("./JotaiAtomChangeItem");var _JotaiAtomDetailContent=require("./JotaiAtomDetailContent");var _JotaiAtomBrowser=require("./JotaiAtomBrowser");var _JotaiAtomValueDetailContent=require("./JotaiAtomValueDetailContent");var _JotaiEventFilterView=require("./JotaiEventFilterView");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function EventsEmptyState({isEnabled:u,searchText:S,totalChanges:f}){const A=(0,_sharedUi.resolveListEmptyState)({subject:"changes",search:S,total:f,capturing:u,waiting:{otto:"waiting",title:"No atom changes",message:"Atom changes will appear here as values update."},paused:{title:"No atom changes",message:"Enable capture to start recording atom changes"}});return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{...A,testID:`${_testIDs.JOTAI_TEST_ID}-empty`})}function JotaiModal({visible:u,onClose:S,onBack:f,onMinimize:A,enableSharedModalDimensions:X=false,inline:Y=false,initialTab:Z,initialSelectedChangeId:h,initialDetailView:ee,onChangeSelect:j,onAtomExpand:M}){const Ee=(0,_license.useIsPro)();const y=(0,_sharedUi.useLimit)("jotai.changes");const[te,H]=(0,_react.useState)(false);const[s,oe]=(0,_react.useState)(Z??"atoms");const[a,_]=(0,_react.useState)(null);const[T,P]=(0,_react.useState)(null);const[D,v]=(0,_react.useState)(false);const[l,V]=(0,_react.useState)(new Set);const{atomChanges:$,filteredChanges:E,stats:ae,filter:ke,setFilter:b,atoms:x,clearChanges:ne,isEnabled:I,toggleCapture:re}=(0,_useJotaiAtomChanges.useJotaiAtomChanges)();const r=(0,_react.useMemo)(()=>{if(l.size===0)return E;return E.filter(e=>!Array.from(l).some(t=>e.atomLabel.toLowerCase().includes(t.toLowerCase())))},[E,l]);const g=(0,_react.useMemo)(()=>{if(l.size===0)return x;return x.filter(e=>!Array.from(l).some(t=>e.label.toLowerCase().includes(t.toLowerCase())))},[x,l]);const se=(0,_react.useMemo)(()=>{if(!a)return 0;return $.filter(e=>e.atomLabel===a).length},[$,a]);const C=(0,_react.useMemo)(()=>a?r.filter(e=>e.atomLabel===a):r,[r,a]);const k=(0,_react.useMemo)(()=>C.slice(0,y),[C,y]);const w=(0,_react.useMemo)(()=>Math.max(0,C.length-y),[C.length,y]);const le=w>0;const o=k;const[J,c]=(0,_react.useState)(null);const d=(0,_react.useMemo)(()=>{if(J===null)return null;const e=o.findIndex(t=>t.id===J);return e>=0?e:null},[J,o]);const n=d!==null?o[d]:null;const O=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(!j)return;const e=n?.id??null;if(e===null||e===O.current)return;O.current=e;j(n)},[n,j]);const L=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(!h)return;if(L.current===h)return;const e=o.some(t=>t.id===h);if(!e)return;L.current=h;c(h)},[h,o]);const[i,B]=(0,_react.useState)("");const[ie,p]=(0,_react.useState)(false);const we=(0,_react.useRef)(null);const ce=(0,_react.useRef)(null);const de=(0,_react.useCallback)(e=>{},[]);const ue=e=>{B(e);if(s==="events"){b(t=>({...t,searchText:e}))}};const he=(0,_react.useCallback)(()=>{B("");b(e=>({...e,searchText:""}));p(false)},[b]);const R=(0,_react.useCallback)(e=>{c(e.id)},[]);const ge=(0,_react.useCallback)(()=>{H(true)},[]);const me=(0,_react.useCallback)(()=>{c(null)},[]);const F=(0,_react.useCallback)(e=>{const t=o[e];if(t)c(t.id)},[o]);const Te=(0,_react.useCallback)(e=>{_(e);c(null)},[]);const be=(0,_react.useCallback)(()=>{_(null);c(null)},[]);const xe=(0,_react.useCallback)(e=>{P(e);M?.(e)},[M]);const fe=(0,_react.useCallback)(()=>{P(null)},[]);const ye=(0,_react.useCallback)(()=>{return g.reduce((e,t)=>{try{const m=t.getValue();e[t.label]=(0,_sharedUi.truncatePayload)(m)}catch{e[t.label]=null}return e},{})},[g]);const Ie=(0,_react.useCallback)(()=>{return r.map(e=>({id:e.id,atomLabel:e.atomLabel,timestamp:e.timestamp,prevValue:(0,_sharedUi.truncatePayload)(e.prevValue),nextValue:(0,_sharedUi.truncatePayload)(e.nextValue),hasValueChange:e.hasValueChange,changedKeys:e.changedKeys}))},[r]);const Ce=(0,_react.useCallback)(()=>{return o.map(e=>({id:e.id,atomLabel:e.atomLabel,timestamp:e.timestamp,prevValue:(0,_sharedUi.truncatePayload)(e.prevValue),nextValue:(0,_sharedUi.truncatePayload)(e.nextValue),hasValueChange:e.hasValueChange,changedKeys:e.changedKeys}))},[o]);const pe=(0,_react.useCallback)(e=>{V(t=>{const m=new Set(t);if(m.has(e))m.delete(e);else m.add(e);return m})},[]);const Se=(0,_react.useCallback)(e=>{V(t=>new Set([...t,e]))},[]);const Ae=(0,_react.useCallback)(e=>{oe(e);_(null);c(null);v(false);if(i){B("");b(t=>({...t,searchText:""}))}p(false)},[i,b]);const z=(0,_react.useCallback)(e=>e.id,[]);const N=(0,_react.useMemo)(()=>(0,_testIDs.buildChangeRowTestIDs)(o),[o]);const q=(0,_react.useCallback)(({item:e})=>(0,_jsxRuntime.jsx)(_JotaiAtomChangeItem.JotaiAtomChangeItem,{change:e,onPress:R,testID:N.get(e.id)}),[R,N]);const W=l.size>0;const K=()=>{if(D){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:()=>v(false)}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"Filters",centered:true,testID:`${_testIDs.JOTAI_TEST_ID}-filters-title`})]})}if(n){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:me}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:`${n.atomLabel}/${n.category}`,centered:true,testID:`${_testIDs.JOTAI_TEST_ID}-detail-title`})]})}if(a){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:be}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:`${a} History`,centered:true,testID:`${_testIDs.JOTAI_TEST_ID}-history-title`}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Actions,{children:(0,_jsxRuntime.jsx)(_sharedUi.ToolbarCopyButton,{value:Ce,disabled:o.length===0,buttonStyle:styles.headerActionButton,testID:`${_testIDs.JOTAI_TEST_ID}-copy`})})]})}if(T){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:fe}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:T,centered:true,testID:`${_testIDs.JOTAI_TEST_ID}-atom-detail-title`})]})}return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[f&&(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:f}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"",children:ie?(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Search,{value:i,onChangeText:ue,onCancel:he,placeholder:s==="atoms"?"Search atoms...":"Search events...",accessibilityLabel:"Search Jotai atoms and events",iconSize:14,testID:`${_testIDs.JOTAI_TEST_ID}-search-field`,containerTestID:`${_testIDs.JOTAI_TEST_ID}-search`,clearTestID:`${_testIDs.JOTAI_TEST_ID}-search-clear`,onBlur:()=>{if(i.length===0)p(false)}}):(0,_jsxRuntime.jsx)(_sharedUi.TabSelector,{tabs:[{key:"atoms",label:`Atoms${g.length>0?` (${g.length})`:""}`},{key:"events",label:`Events${r.length>0?` (${r.length})`:""}`}],activeTab:s,onTabChange:Ae,testIDPrefix:`${_testIDs.JOTAI_TEST_ID}-tab`})}),(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader.Actions,{children:[(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>p(true),style:styles.headerActionButton,testID:`${_testIDs.JOTAI_TEST_ID}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:(0,_jsxRuntime.jsx)(_sharedUi.Search,{size:14,color:_sharedUi.night.color.textSecondary})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>v(true),style:[styles.headerActionButton,W&&styles.headerActionButtonActive],testID:`${_testIDs.JOTAI_TEST_ID}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:(0,_jsxRuntime.jsx)(_sharedUi.Filter,{size:14,color:W?_sharedUi.night.color.accent:_sharedUi.night.color.textSecondary})}),s==="atoms"&&(0,_jsxRuntime.jsx)(_sharedUi.ToolbarCopyButton,{value:ye,disabled:g.length===0,buttonStyle:styles.headerActionButton,testID:`${_testIDs.JOTAI_TEST_ID}-copy`}),s==="events"&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ToolbarCopyButton,{value:Ie,disabled:r.length===0,buttonStyle:styles.headerActionButton,testID:`${_testIDs.JOTAI_TEST_ID}-copy`}),(0,_jsxRuntime.jsx)(_sharedUi.PowerToggleButton,{isEnabled:I,onToggle:re,accessibilityLabel:"Toggle Jotai atom capture",testID:`${_testIDs.JOTAI_TEST_ID}-power`}),(0,_jsxRuntime.jsx)(_sharedUi.ToolbarClearButton,{onPress:ne,disabled:r.length===0,buttonStyle:styles.headerActionButton,testID:`${_testIDs.JOTAI_TEST_ID}-clear`})]})]})]})};const je=()=>{if(D){return(0,_jsxRuntime.jsx)(_JotaiEventFilterView.JotaiEventFilterView,{ignoredPatterns:l,onTogglePattern:pe,onAddPattern:Se,atoms:x})}if(n&&d!==null){return(0,_jsxRuntime.jsx)(_JotaiAtomDetailContent.JotaiAtomDetailContent,{change:n,changes:o,selectedIndex:d,onIndexChange:F,disableInternalFooter:true,initialView:ee})}if(a){return o.length>0?(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",testID:`${_testIDs.JOTAI_TEST_ID}-history-list`,data:o,renderItem:q,keyExtractor:z,contentContainerStyle:styles.listContent,showsVerticalScrollIndicator:true,..._sharedUi.EVENT_LIST_PRESET}):(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.JOTAI_TEST_ID}-history-empty`,...(0,_sharedUi.resolveListEmptyState)({subject:"changes",search:i,total:i.trim()?se:0,capturing:I,waiting:{otto:"waiting",title:"No history yet",message:`Changes for ${a} will appear here.`},paused:{title:"No history yet",message:`Capture is off, so nothing is being recorded for ${a}.`}})})}if(T){const e=x.find(t=>t.label===T)??null;return e?(0,_jsxRuntime.jsx)(_JotaiAtomValueDetailContent.JotaiAtomValueDetailContent,{atom:e,onViewHistory:Te}):(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.JOTAI_TEST_ID}-atom-detail-gone`,otto:"ghost",title:"Atom no longer registered",message:`${T} is not in the registry any more.`})}if(s==="atoms"){return(0,_jsxRuntime.jsx)(_JotaiAtomBrowser.JotaiAtomBrowser,{atoms:g,searchQuery:i,onOpenAtom:xe})}return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[!I&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.disabledBanner,testID:`${_testIDs.JOTAI_TEST_ID}-banner-disabled`,children:[(0,_jsxRuntime.jsx)(_sharedUi.Power,{size:14,color:_sharedUi.night.color.warning}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.disabledText,children:"Atom capture is disabled"})]}),le&&(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{style:styles.lockedBanner,onPress:ge,activeOpacity:.8,testID:`${_testIDs.JOTAI_TEST_ID}-locked`,accessibilityRole:"button",children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.lockedText,testID:`${_testIDs.JOTAI_TEST_ID}-locked-text`,children:[w," older"," ",w===1?"change":"changes"," locked"]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.upgradeBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.upgradeBadgeText,children:"UPGRADE"})})]}),k.length>0?(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",ref:ce,testID:`${_testIDs.JOTAI_TEST_ID}-list`,data:k,renderItem:q,keyExtractor:z,contentContainerStyle:styles.listContent,showsVerticalScrollIndicator:true,..._sharedUi.EVENT_LIST_PRESET}):(0,_jsxRuntime.jsx)(EventsEmptyState,{isEnabled:I,searchText:i,totalChanges:ae.totalChanges})]})};const _e=X?_sharedUi.devToolsStorageKeys.modal.root():"buoy-jotai-modal";if(!u)return null;const U=n&&d!==null?(0,_jsxRuntime.jsx)(_JotaiAtomDetailContent.JotaiAtomDetailFooter,{change:n,changes:o,selectedIndex:d,onIndexChange:F}):null;const De=n&&o.length>1?68:0;const ve=!D&&!(n&&d!==null)&&(a!=null||s==="events"||s==="atoms");const G=(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,children:je()});const Q=(0,_jsxRuntime.jsx)(_sharedUi.ProUpgradeModal,{visible:te,onClose:()=>H(false),featureName:"Full Atom History"});if(Y){return(0,_jsxRuntime.jsxs)(_sharedUi.TickProvider,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.inlineRoot,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.inlineHeader,..._sharedUi.windowDragProps,children:K()}),G,U]}),Q]})}return(0,_jsxRuntime.jsxs)(_sharedUi.TickProvider,{children:[(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:u,onClose:S,onMinimize:A,persistenceKey:_e,header:{showToggleButton:true,customContent:K()},onModeChange:de,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:ve,styles:{},footer:U,footerHeight:De,children:G}),Q]})}function JotaiToolView(u={}){return(0,_jsxRuntime.jsx)(JotaiModal,{...u,inline:true,visible:true,onClose:()=>{}})}const styles=_reactNative.StyleSheet.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:_sharedUi.macOSColors.border.default,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:_sharedUi.night.color.buttonSurface,borderWidth:1,borderColor:_sharedUi.night.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonActive:{backgroundColor:_sharedUi.night.color.accentSoft,borderColor:_sharedUi.night.color.accentBorderStrong},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:_sharedUi.night.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.warning+"20"},disabledText:{color:_sharedUi.night.color.warning,fontSize:11,flex:1},listContent:{paddingTop:8,paddingBottom:20},emptyState:{alignItems:"center",paddingVertical:40},emptyTitle:{color:_sharedUi.night.color.text,fontSize:14,fontWeight:"600",marginTop:12,marginBottom:6},emptyText:{color:_sharedUi.night.color.textTertiary,fontSize:12,textAlign:"center",lineHeight:18},lockedBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:_sharedUi.night.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder},lockedText:{color:_sharedUi.night.color.accent,fontSize:11,fontWeight:"500",flex:1},upgradeBadge:{backgroundColor:_sharedUi.night.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},upgradeBadgeText:{color:_sharedUi.night.color.onAccent,fontSize:9,fontWeight:"700",letterSpacing:.5}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useMemo as y}from"react";import{View as c,Text as g,StyleSheet as b,ScrollView as w}from"react-native";import{CompactRow as C,night as
|
|
1
|
+
"use strict";import{useMemo as y}from"react";import{View as c,Text as g,StyleSheet as b,ScrollView as w}from"react-native";import{CompactRow as C,night as p,ToolEmptyState as m,resolveListEmptyState as T,monoFont as h}from"@buoy-gg/shared-ui";import{jotaiStateStore as S}from"../utils/jotaiStateStore";import{JOTAI_TEST_ID as d,atomRowTestID as v}from"../utils/testIDs";import{jsx as r,jsxs as f}from"react/jsx-runtime";function x(o){try{const t=o.getValue();if(t&&typeof t==="object"&&t.__buoyValueOnDevice===true){return"on device"}if(t===void 0)return"undefined";if(t===null)return"null";if(Array.isArray(t)){if(t.length===0)return"[]";return`[${t.length} item${t.length===1?"":"s"}]`}if(typeof t==="object"){const i=Object.keys(t);if(i.length===0)return"{}";if(i.length<=3)return i.join(", ");return`${i.slice(0,2).join(", ")} +${i.length-2}`}return String(t).slice(0,40)}catch{return""}}function I(o){if(o.writeKind==="value")return"primitive";if(o.writeKind==="action")return"custom write";return o.setValue?"writable":"derived"}function D(){return r(m,{testID:`${d}-atoms-empty`,otto:"scanning",title:"No atoms registered",message:"Use watchAtoms(store, { atomName }) to register your Jotai atoms.\nThey will appear here with their current value."})}export function JotaiAtomBrowser({atoms:o,searchQuery:t,onOpenAtom:i}){const l=y(()=>{if(!t)return o;const e=t.toLowerCase();return o.filter(u=>u.label.toLowerCase().includes(e))},[o,t]);if(l.length===0&&!t){return r(D,{})}if(l.length===0&&t){return r(m,{testID:`${d}-atoms-no-match`,...T({subject:"atoms",verb:"registered",search:t,total:o.length,waiting:{otto:"scanning",title:"No atoms registered",message:"Use watchAtoms() to register your Jotai atoms."}})})}return f(w,{keyboardShouldPersistTaps:"handled",style:n.container,contentContainerStyle:n.scrollContent,showsVerticalScrollIndicator:true,testID:`${d}-atoms-scroll`,children:[f(c,{style:n.sectionHeader,children:[r(g,{style:n.sectionTitle,children:"ATOMS"}),r(c,{style:n.sectionCountBadge,children:r(g,{style:n.sectionCountText,testID:`${d}-atoms-count`,children:l.length})})]}),l.map(e=>{const u=x(e);const a=S.getAtomColor(e.label);const s=v(e.label);return f(c,{style:n.atomRowWrapper,children:[r(C,{statusDotColor:a,statusLabel:I(e),primaryText:e.label,secondaryText:u||void 0,showChevron:true,onPress:()=>i(e.label),testID:s,statusTestID:`${s}-kind`,primaryTestID:`${s}-name`,secondaryTestID:`${s}-preview`}),e.changeCount>0&&r(c,{style:[n.absCountBadge,{backgroundColor:a+"22",borderColor:a+"55"}],pointerEvents:"none",children:r(g,{style:[n.absCountText,{color:a}],testID:`${s}-count`,children:String(e.changeCount)})})]},e.label)})]})}const n=b.create({container:{flex:1},atomRowWrapper:{position:"relative"},absCountBadge:{position:"absolute",top:4,right:10,paddingHorizontal:5,paddingVertical:1,borderRadius:4,borderWidth:1,zIndex:1},absCountText:{fontSize:9,fontWeight:"700",fontFamily:h},scrollContent:{paddingTop:8,paddingBottom:20},sectionHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:8,gap:8},sectionTitle:{fontSize:11,fontWeight:"700",letterSpacing:.5,color:p.color.textTertiary},sectionCountBadge:{backgroundColor:p.color.accentFill,paddingHorizontal:8,paddingVertical:2,borderRadius:4},sectionCountText:{fontSize:10,fontWeight:"700",color:p.color.accent,fontFamily:h}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import xe,{memo as Z,useState as A,useCallback as x,useMemo as H}from"react";import{View as o,Text as c,StyleSheet as R,ScrollView as W}from"react-native";import{buoyColors as T,night as n,EventStepperFooter as $,formatRelativeTime as I,parseValue as v,Info as q,Zap as M,FileText as Q,Database as X,GitBranch as ee,copyToClipboard as te,ProUpgradeModal as oe,DiffModeTabs as re,CompareBar as ne,DetailViewToggle as ae,monoFont as u}from"@buoy-gg/shared-ui";import{DataViewer as ie,SplitDiffViewer as le,TreeDiffViewer as ce,diffThemes as de}from"@buoy-gg/shared-ui/dataViewer";import{useIsPro as se}from"@buoy-gg/license";import{jotaiStateStore as B}from"../utils/jotaiStateStore";import{JOTAI_TEST_ID as d,slugForTestID as fe}from"../utils/testIDs";import{jsx as e,jsxs as s}from"react/jsx-runtime";const ge=[{key:"change",label:"CHANGE",icon:Q},{key:"value",label:"VALUE",icon:X},{key:"diff",label:"DIFF",icon:ee}];const ue=["diff"];function me(r){switch(r){case"initial":return{label:"INITIAL",color:n.color.textTertiary,bgColor:n.color.textTertiary+"26"};default:return{label:"WRITE",color:T.success,bgColor:T.success+"26"}}}function he(r){const a=new Date(r);const i=a.getHours().toString().padStart(2,"0");const f=a.getMinutes().toString().padStart(2,"0");const g=a.getSeconds().toString().padStart(2,"0");const m=a.getMilliseconds().toString().padStart(3,"0");return`${i}:${f}:${g}.${m}`}function N(r){return new Date(r).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ye(r){if(r===null)return"null";if(r===void 0)return"undefined";if(Array.isArray(r))return"array";return typeof r}function P(r){return r==="initial"?"INIT":"WRITE"}const pe=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}];const be=Z(function r({change:a}){const i=se();const[f,g]=A(false);const m=me(a.category);const p=B.getAtomColor(a.atomLabel);const F=x(async()=>{if(!i){g(true);return}await te(a.nextValue)},[a.nextValue,i]);return s(W,{style:t.container,contentContainerStyle:t.content,showsVerticalScrollIndicator:false,testID:`${d}-detail-scroll`,children:[s(o,{style:t.card,testID:`${d}-info-card`,children:[e(o,{style:t.sectionHeader,children:s(o,{style:t.sectionHeaderLeft,children:[e(q,{size:14,color:n.color.accent}),e(c,{style:t.sectionTitle,children:"CHANGE INFO"})]})}),s(o,{style:t.cardContent,children:[s(o,{style:t.infoRow,children:[e(c,{style:t.infoLabel,children:"Atom"}),e(c,{style:[t.infoValue,t.infoValueMono,{color:p}],numberOfLines:1,ellipsizeMode:"middle",testID:`${d}-info-atom`,children:a.atomLabel})]}),s(o,{style:t.infoRow,children:[e(c,{style:t.infoLabel,children:"Time"}),e(c,{style:[t.infoValue,t.infoValueMono],testID:`${d}-info-time`,children:he(a.timestamp)})]}),s(o,{style:t.badgeRow,children:[e(o,{style:[t.categoryBadge,{backgroundColor:m.bgColor}],children:e(c,{style:[t.categoryText,{color:m.color}],testID:`${d}-info-category`,children:m.label})}),a.hasValueChange?s(o,{style:t.changesBadge,children:[e(M,{size:10,color:T.success}),e(c,{style:t.changesText,testID:`${d}-info-changes`,children:a.diffSummary||"changed"})]}):e(o,{style:t.noChangesBadge,children:e(c,{style:t.noChangesText,testID:`${d}-info-no-changes`,children:"no change"})})]})]})]}),a.changedKeys.length>0&&s(o,{style:t.card,testID:`${d}-keys-card`,children:[s(o,{style:t.sectionHeader,children:[s(o,{style:t.sectionHeaderLeft,children:[e(M,{size:14,color:n.color.accent}),e(c,{style:t.sectionTitle,children:"CHANGED KEYS"})]}),e(o,{style:t.countBadge,children:e(c,{style:t.countText,testID:`${d}-keys-count`,children:a.changedKeys.length})})]}),e(o,{style:t.cardContent,children:e(o,{style:t.keysContainer,children:a.changedKeys.map(y=>e(o,{style:t.keyBadge,children:e(c,{style:t.keyText,testID:`${d}-key-${fe(y)}`,children:y})},y))})})]}),e(o,{style:t.actionsRow,children:e(o,{style:[t.actionButton,t.actionButtonCopy],onTouchEnd:F,testID:`${d}-copy-value`,accessibilityRole:"button",accessibilityLabel:"Copy value",children:e(c,{style:[t.actionButtonText,{color:n.color.accent}],children:"COPY VALUE"})})}),e(oe,{visible:f,onClose:()=>g(false),featureName:"Copy"})]})});export function JotaiAtomDetailContent({change:r,changes:a,selectedIndex:i,onIndexChange:f,disableInternalFooter:g=false,initialView:m="change"}){const[p,F]=A(m);const[y,O]=A("tree");const b=a.length;const C=B.getAtomColor(r.atomLabel);const w=P(r.category);const L=ye(v(r.nextValue));const S=b-i;const V=i<b-1?i+1:null;const h=V!==null?a[V]:null;const z=S-1;const j=H(()=>({index:V??0,label:z>0?`#${z}`:"Initial",timestamp:h?N(h.timestamp):"",relativeTime:h?I(new Date(h.timestamp)):"value",badge:h?e(o,{style:[l.changeBadgeSmall,{backgroundColor:`${B.getAtomColor(h.atomLabel)}20`}],children:e(c,{style:[l.changeTextSmall,{color:B.getAtomColor(h.atomLabel)}],children:P(h.category)})}):void 0}),[V,h,z]);const _=H(()=>({index:i,label:`#${S}`,timestamp:N(r.timestamp),relativeTime:I(new Date(r.timestamp)),badge:e(o,{style:[l.changeBadgeSmall,{backgroundColor:`${C}20`}],children:e(c,{style:[l.changeTextSmall,{color:C}],children:w})})}),[i,r.timestamp,C,w,S]);const G=x(()=>{const D=v(r.nextValue);return s(o,{style:l.contentCard,testID:`${d}-value-card`,children:[s(o,{style:l.valueHeader,children:[e(c,{style:l.valueLabel,children:"VALUE AFTER CHANGE"}),s(o,{style:l.valueHeaderBadges,children:[e(o,{style:[l.changeBadge,{backgroundColor:`${C}20`}],children:e(c,{style:[l.changeText,{color:C}],children:w})}),e(o,{style:l.typeBadge,children:e(c,{style:l.typeText,testID:`${d}-value-type`,children:L.toUpperCase()})})]})]}),e(o,{style:t.dataViewerContainer,children:e(ie,{title:"",data:D,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})},[r.nextValue,C,w,L]);const U=x(()=>{const D=v(r.prevValue);const E=v(r.nextValue);if(y==="split"){return e(W,{style:{flex:1},showsVerticalScrollIndicator:true,children:e(le,{oldValue:D,newValue:E,theme:de.devToolsDefault,options:{hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3},showThemeName:false})})}return e(ce,{oldValue:D,newValue:E})},[r.prevValue,r.nextValue,y]);const J=x(()=>{f(Math.min(b-1,i+1))},[i,b,f]);const K=x(()=>{f(Math.max(0,i-1))},[i,f]);const Y=r.prevValue===void 0;const k=!g&&b>1;return s(o,{style:l.container,children:[e(ae,{views:ge,activeView:p,onViewChange:F,disabledKeys:Y?ue:void 0,testIDPrefix:d}),s(o,{style:[l.contentArea,k&&l.contentAreaFooterPad],children:[p==="change"&&e(be,{change:r}),p==="value"&&e(o,{style:l.stateContainer,children:G()}),p==="diff"&&s(o,{style:l.diffContainer,testID:`${d}-diff`,children:[e(re,{tabs:pe,activeTab:y,onTabChange:O,testIDPrefix:`${d}-diff-tab`}),e(ne,{leftEvent:j,rightEvent:_}),e(o,{style:l.diffContent,testID:`${d}-diff-content`,children:U()})]})]}),k&&e($,{currentIndex:S-1,totalItems:b,onPrevious:J,onNext:K,itemLabel:"Change",subtitle:I(new Date(r.timestamp)),absolute:true})]})}export function JotaiAtomDetailFooter({change:r,changes:a,selectedIndex:i,onIndexChange:f}){const g=a.length;if(g<=1)return null;const m=g-i;return e($,{currentIndex:m-1,totalItems:g,onPrevious:()=>f(Math.min(g-1,i+1)),onNext:()=>f(Math.max(0,i-1)),itemLabel:"Change",subtitle:I(new Date(r.timestamp))})}const l=R.create({container:{flex:1,backgroundColor:"transparent"},contentArea:{flex:1},contentAreaFooterPad:{paddingBottom:96},stateContainer:{flex:1,padding:14},contentCard:{backgroundColor:n.color.surface,borderRadius:14,padding:14,borderWidth:1,borderColor:n.color.border},valueHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},valueLabel:{fontSize:10,color:n.color.textSecondary,fontFamily:u,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:u,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:n.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:n.color.textTertiary,fontFamily:u},valueBox:{backgroundColor:n.color.bg,borderRadius:6,borderWidth:1,borderColor:n.color.border,padding:8},valueText:{fontSize:12,color:n.color.text,fontFamily:u,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:u}});const t=R.create({container:{flex:1},content:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:n.color.surface,borderRadius:6,borderWidth:1,borderColor:n.color.accentBorderStrong,overflow:"hidden",shadowColor:n.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:n.color.accentBorder,backgroundColor:n.color.accentSoft},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:n.color.accent,fontFamily:u},cardContent:{padding:14,gap:10},infoRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},infoLabel:{fontSize:11,color:n.color.textTertiary,fontWeight:"500"},infoValue:{fontSize:11,color:n.color.text,fontWeight:"500",flex:1,textAlign:"right",marginLeft:12},infoValueMono:{fontFamily:u},badgeRow:{flexDirection:"row",flexWrap:"wrap",gap:8,marginTop:6},categoryBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4},categoryText:{fontSize:9,fontWeight:"700",letterSpacing:.3},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:T.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:T.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:n.color.surfaceElevated},noChangesText:{fontSize:9,fontWeight:"600",color:n.color.textTertiary},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:n.color.accentSoft,borderWidth:1,borderColor:n.color.accentBorder},keyText:{fontSize:11,fontWeight:"600",color:n.color.accent,fontFamily:u},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:n.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:n.color.accent,fontFamily:u},actionsRow:{flexDirection:"row",gap:12},actionButton:{paddingHorizontal:14,paddingVertical:8,borderRadius:8,borderWidth:1},actionButtonCopy:{borderColor:n.color.accentBorder,backgroundColor:n.color.accentSoft},actionButtonText:{fontSize:10,fontWeight:"700",fontFamily:u,letterSpacing:.3},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});
|
|
1
|
+
"use strict";import Te,{memo as Z,useState as z,useCallback as T,useMemo as H}from"react";import{View as o,Text as c,StyleSheet as R,ScrollView as W}from"react-native";import{buoyColors as x,night as n,EventStepperFooter as $,formatRelativeTime as I,parseValue as v,Info as q,Zap as M,FileText as Q,Database as X,GitBranch as ee,copyToClipboard as te,ProUpgradeModal as oe,DiffModeTabs as re,CompareBar as ne,DetailViewToggle as ae,monoFont as u}from"@buoy-gg/shared-ui";import{DataViewer as ie,SplitDiffViewer as le,TreeDiffViewer as ce,diffThemes as de}from"@buoy-gg/shared-ui/dataViewer";import{useIsPro as se}from"@buoy-gg/license";import{jotaiStateStore as B}from"../utils/jotaiStateStore";import{JOTAI_TEST_ID as d,slugForTestID as fe}from"../utils/testIDs";import{jsx as e,jsxs as s}from"react/jsx-runtime";const ge=[{key:"change",label:"CHANGE",icon:Q},{key:"value",label:"VALUE",icon:X},{key:"diff",label:"DIFF",icon:ee}];const ue=["diff"];function he(r){switch(r){case"initial":return{label:"INITIAL",color:n.color.textTertiary,bgColor:n.color.textTertiary+"26"};default:return{label:"WRITE",color:x.success,bgColor:x.success+"26"}}}function me(r){const a=new Date(r);const i=a.getHours().toString().padStart(2,"0");const f=a.getMinutes().toString().padStart(2,"0");const g=a.getSeconds().toString().padStart(2,"0");const h=a.getMilliseconds().toString().padStart(3,"0");return`${i}:${f}:${g}.${h}`}function N(r){return new Date(r).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ye(r){if(r===null)return"null";if(r===void 0)return"undefined";if(Array.isArray(r))return"array";return typeof r}function P(r){return r==="initial"?"INIT":"WRITE"}const pe=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}];const be=Z(function r({change:a}){const i=se();const[f,g]=z(false);const h=he(a.category);const p=B.getAtomColor(a.atomLabel);const F=T(async()=>{if(!i){g(true);return}await te(a.nextValue)},[a.nextValue,i]);return s(W,{keyboardShouldPersistTaps:"handled",style:t.container,contentContainerStyle:t.content,showsVerticalScrollIndicator:false,testID:`${d}-detail-scroll`,children:[s(o,{style:t.card,testID:`${d}-info-card`,children:[e(o,{style:t.sectionHeader,children:s(o,{style:t.sectionHeaderLeft,children:[e(q,{size:14,color:n.color.accent}),e(c,{style:t.sectionTitle,children:"CHANGE INFO"})]})}),s(o,{style:t.cardContent,children:[s(o,{style:t.infoRow,children:[e(c,{style:t.infoLabel,children:"Atom"}),e(c,{style:[t.infoValue,t.infoValueMono,{color:p}],numberOfLines:1,ellipsizeMode:"middle",testID:`${d}-info-atom`,children:a.atomLabel})]}),s(o,{style:t.infoRow,children:[e(c,{style:t.infoLabel,children:"Time"}),e(c,{style:[t.infoValue,t.infoValueMono],testID:`${d}-info-time`,children:me(a.timestamp)})]}),s(o,{style:t.badgeRow,children:[e(o,{style:[t.categoryBadge,{backgroundColor:h.bgColor}],children:e(c,{style:[t.categoryText,{color:h.color}],testID:`${d}-info-category`,children:h.label})}),a.hasValueChange?s(o,{style:t.changesBadge,children:[e(M,{size:10,color:x.success}),e(c,{style:t.changesText,testID:`${d}-info-changes`,children:a.diffSummary||"changed"})]}):e(o,{style:t.noChangesBadge,children:e(c,{style:t.noChangesText,testID:`${d}-info-no-changes`,children:"no change"})})]})]})]}),a.changedKeys.length>0&&s(o,{style:t.card,testID:`${d}-keys-card`,children:[s(o,{style:t.sectionHeader,children:[s(o,{style:t.sectionHeaderLeft,children:[e(M,{size:14,color:n.color.accent}),e(c,{style:t.sectionTitle,children:"CHANGED KEYS"})]}),e(o,{style:t.countBadge,children:e(c,{style:t.countText,testID:`${d}-keys-count`,children:a.changedKeys.length})})]}),e(o,{style:t.cardContent,children:e(o,{style:t.keysContainer,children:a.changedKeys.map(y=>e(o,{style:t.keyBadge,children:e(c,{style:t.keyText,testID:`${d}-key-${fe(y)}`,children:y})},y))})})]}),e(o,{style:t.actionsRow,children:e(o,{style:[t.actionButton,t.actionButtonCopy],onTouchEnd:F,testID:`${d}-copy-value`,accessibilityRole:"button",accessibilityLabel:"Copy value",children:e(c,{style:[t.actionButtonText,{color:n.color.accent}],children:"COPY VALUE"})})}),e(oe,{visible:f,onClose:()=>g(false),featureName:"Copy"})]})});export function JotaiAtomDetailContent({change:r,changes:a,selectedIndex:i,onIndexChange:f,disableInternalFooter:g=false,initialView:h="change"}){const[p,F]=z(h);const[y,O]=z("tree");const b=a.length;const C=B.getAtomColor(r.atomLabel);const w=P(r.category);const A=ye(v(r.nextValue));const S=b-i;const V=i<b-1?i+1:null;const m=V!==null?a[V]:null;const k=S-1;const j=H(()=>({index:V??0,label:k>0?`#${k}`:"Initial",timestamp:m?N(m.timestamp):"",relativeTime:m?I(new Date(m.timestamp)):"value",badge:m?e(o,{style:[l.changeBadgeSmall,{backgroundColor:`${B.getAtomColor(m.atomLabel)}20`}],children:e(c,{style:[l.changeTextSmall,{color:B.getAtomColor(m.atomLabel)}],children:P(m.category)})}):void 0}),[V,m,k]);const _=H(()=>({index:i,label:`#${S}`,timestamp:N(r.timestamp),relativeTime:I(new Date(r.timestamp)),badge:e(o,{style:[l.changeBadgeSmall,{backgroundColor:`${C}20`}],children:e(c,{style:[l.changeTextSmall,{color:C}],children:w})})}),[i,r.timestamp,C,w,S]);const G=T(()=>{const D=v(r.nextValue);return s(o,{style:l.contentCard,testID:`${d}-value-card`,children:[s(o,{style:l.valueHeader,children:[e(c,{style:l.valueLabel,children:"VALUE AFTER CHANGE"}),s(o,{style:l.valueHeaderBadges,children:[e(o,{style:[l.changeBadge,{backgroundColor:`${C}20`}],children:e(c,{style:[l.changeText,{color:C}],children:w})}),e(o,{style:l.typeBadge,children:e(c,{style:l.typeText,testID:`${d}-value-type`,children:A.toUpperCase()})})]})]}),e(o,{style:t.dataViewerContainer,children:e(ie,{title:"",data:D,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})},[r.nextValue,C,w,A]);const U=T(()=>{const D=v(r.prevValue);const E=v(r.nextValue);if(y==="split"){return e(W,{keyboardShouldPersistTaps:"handled",style:{flex:1},showsVerticalScrollIndicator:true,children:e(le,{oldValue:D,newValue:E,theme:de.devToolsDefault,options:{hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3},showThemeName:false})})}return e(ce,{oldValue:D,newValue:E})},[r.prevValue,r.nextValue,y]);const J=T(()=>{f(Math.min(b-1,i+1))},[i,b,f]);const K=T(()=>{f(Math.max(0,i-1))},[i,f]);const Y=r.prevValue===void 0;const L=!g&&b>1;return s(o,{style:l.container,children:[e(ae,{views:ge,activeView:p,onViewChange:F,disabledKeys:Y?ue:void 0,testIDPrefix:d}),s(o,{style:[l.contentArea,L&&l.contentAreaFooterPad],children:[p==="change"&&e(be,{change:r}),p==="value"&&e(o,{style:l.stateContainer,children:G()}),p==="diff"&&s(o,{style:l.diffContainer,testID:`${d}-diff`,children:[e(re,{tabs:pe,activeTab:y,onTabChange:O,testIDPrefix:`${d}-diff-tab`}),e(ne,{leftEvent:j,rightEvent:_}),e(o,{style:l.diffContent,testID:`${d}-diff-content`,children:U()})]})]}),L&&e($,{currentIndex:S-1,totalItems:b,onPrevious:J,onNext:K,itemLabel:"Change",subtitle:I(new Date(r.timestamp)),absolute:true})]})}export function JotaiAtomDetailFooter({change:r,changes:a,selectedIndex:i,onIndexChange:f}){const g=a.length;if(g<=1)return null;const h=g-i;return e($,{currentIndex:h-1,totalItems:g,onPrevious:()=>f(Math.min(g-1,i+1)),onNext:()=>f(Math.max(0,i-1)),itemLabel:"Change",subtitle:I(new Date(r.timestamp))})}const l=R.create({container:{flex:1,backgroundColor:"transparent"},contentArea:{flex:1},contentAreaFooterPad:{paddingBottom:96},stateContainer:{flex:1,padding:14},contentCard:{backgroundColor:n.color.surface,borderRadius:14,padding:14,borderWidth:1,borderColor:n.color.border},valueHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},valueLabel:{fontSize:10,color:n.color.textSecondary,fontFamily:u,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:u,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:n.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:n.color.textTertiary,fontFamily:u},valueBox:{backgroundColor:n.color.bg,borderRadius:6,borderWidth:1,borderColor:n.color.border,padding:8},valueText:{fontSize:12,color:n.color.text,fontFamily:u,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:u}});const t=R.create({container:{flex:1},content:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:n.color.surface,borderRadius:6,borderWidth:1,borderColor:n.color.accentBorderStrong,overflow:"hidden",shadowColor:n.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:n.color.accentBorder,backgroundColor:n.color.accentSoft},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:n.color.accent,fontFamily:u},cardContent:{padding:14,gap:10},infoRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},infoLabel:{fontSize:11,color:n.color.textTertiary,fontWeight:"500"},infoValue:{fontSize:11,color:n.color.text,fontWeight:"500",flex:1,textAlign:"right",marginLeft:12},infoValueMono:{fontFamily:u},badgeRow:{flexDirection:"row",flexWrap:"wrap",gap:8,marginTop:6},categoryBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4},categoryText:{fontSize:9,fontWeight:"700",letterSpacing:.3},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:x.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:x.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:n.color.surfaceElevated},noChangesText:{fontSize:9,fontWeight:"600",color:n.color.textTertiary},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:n.color.accentSoft,borderWidth:1,borderColor:n.color.accentBorder},keyText:{fontSize:11,fontWeight:"600",color:n.color.accent,fontFamily:u},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:n.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:n.color.accent,fontFamily:u},actionsRow:{flexDirection:"row",gap:12},actionButton:{paddingHorizontal:14,paddingVertical:8,borderRadius:8,borderWidth:1},actionButtonCopy:{borderColor:n.color.accentBorder,backgroundColor:n.color.accentSoft},actionButtonText:{fontSize:10,fontWeight:"700",fontFamily:u,letterSpacing:.3},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{useState as g,useMemo as p,useRef as E,useCallback as r,useEffect as ge}from"react";import{View as B,Text as O,StyleSheet as Xe,FlatList as me,TouchableOpacity as U}from"react-native";import{JsModal as Ye,ModalHeader as a,TabSelector as Ze,macOSColors as et,night as l,Search as tt,Filter as ot,Power as nt,ToolEmptyState as G,resolveListEmptyState as fe,devToolsStorageKeys as rt,ProUpgradeModal as at,PowerToggleButton as lt,ToolbarCopyButton as Q,ToolbarClearButton as st,truncatePayload as D,TickProvider as be,useLimit as it,windowDragProps as ct,EVENT_LIST_PRESET as pe}from"@buoy-gg/shared-ui";import{useIsPro as dt}from"@buoy-gg/license";import{useJotaiAtomChanges as ut}from"../hooks/useJotaiAtomChanges";import{JotaiAtomChangeItem as ht}from"./JotaiAtomChangeItem";import{JotaiAtomDetailContent as gt,JotaiAtomDetailFooter as mt}from"./JotaiAtomDetailContent";import{JotaiAtomBrowser as ft}from"./JotaiAtomBrowser";import{JotaiAtomValueDetailContent as bt}from"./JotaiAtomValueDetailContent";import{JotaiEventFilterView as pt}from"./JotaiEventFilterView";import{JOTAI_TEST_ID as n,buildChangeRowTestIDs as yt}from"../utils/testIDs";import{jsx as t,jsxs as c,Fragment as ye}from"react/jsx-runtime";function Ct({isEnabled:S,searchText:H,totalChanges:$}){const z=fe({subject:"changes",search:H,total:$,capturing:S,waiting:{otto:"waiting",title:"No atom changes",message:"Atom changes will appear here as values update."},paused:{title:"No atom changes",message:"Enable capture to start recording atom changes"}});return t(G,{...z,testID:`${n}-empty`})}export function JotaiModal({visible:S,onClose:H,onBack:$,onMinimize:z,enableSharedModalDimensions:Ce=false,inline:Se=false,initialTab:Te,initialSelectedChangeId:T,initialDetailView:xe,onChangeSelect:F,onAtomExpand:q}){const St=dt();const k=it("jotai.changes");const[Ie,X]=g(false);const[m,Ae]=g(Te??"atoms");const[d,R]=g(null);const[A,Y]=g(null);const[J,M]=g(false);const[f,Z]=g(new Set);const{atomChanges:ee,filteredChanges:N,stats:we,filter:Tt,setFilter:w,atoms:v,clearChanges:ve,isEnabled:P,toggleCapture:Be}=ut();const h=p(()=>{if(f.size===0)return N;return N.filter(e=>!Array.from(f).some(o=>e.atomLabel.toLowerCase().includes(o.toLowerCase())))},[N,f]);const x=p(()=>{if(f.size===0)return v;return v.filter(e=>!Array.from(f).some(o=>e.label.toLowerCase().includes(o.toLowerCase())))},[v,f]);const De=p(()=>{if(!d)return 0;return ee.filter(e=>e.atomLabel===d).length},[ee,d]);const V=p(()=>d?h.filter(e=>e.atomLabel===d):h,[h,d]);const j=p(()=>V.slice(0,k),[V,k]);const W=p(()=>Math.max(0,V.length-k),[V.length,k]);const $e=W>0;const i=j;const[_,y]=g(null);const C=p(()=>{if(_===null)return null;const e=i.findIndex(o=>o.id===_);return e>=0?e:null},[_,i]);const u=C!==null?i[C]:null;const te=E(null);ge(()=>{if(!F)return;const e=u?.id??null;if(e===null||e===te.current)return;te.current=e;F(u)},[u,F]);const oe=E(null);ge(()=>{if(!T)return;if(oe.current===T)return;const e=i.some(o=>o.id===T);if(!e)return;oe.current=T;y(T)},[T,i]);const[b,K]=g("");const[ke,L]=g(false);const xt=E(null);const Pe=E(null);const Ve=r(e=>{},[]);const Le=e=>{K(e);if(m==="events"){w(o=>({...o,searchText:e}))}};const Ee=r(()=>{K("");w(e=>({...e,searchText:""}));L(false)},[w]);const ne=r(e=>{y(e.id)},[]);const He=r(()=>{X(true)},[]);const ze=r(()=>{y(null)},[]);const re=r(e=>{const o=i[e];if(o)y(o.id)},[i]);const Fe=r(e=>{R(e);y(null)},[]);const Re=r(()=>{R(null);y(null)},[]);const Je=r(e=>{Y(e);q?.(e)},[q]);const Me=r(()=>{Y(null)},[]);const Ne=r(()=>{return x.reduce((e,o)=>{try{const I=o.getValue();e[o.label]=D(I)}catch{e[o.label]=null}return e},{})},[x]);const je=r(()=>{return h.map(e=>({id:e.id,atomLabel:e.atomLabel,timestamp:e.timestamp,prevValue:D(e.prevValue),nextValue:D(e.nextValue),hasValueChange:e.hasValueChange,changedKeys:e.changedKeys}))},[h]);const We=r(()=>{return i.map(e=>({id:e.id,atomLabel:e.atomLabel,timestamp:e.timestamp,prevValue:D(e.prevValue),nextValue:D(e.nextValue),hasValueChange:e.hasValueChange,changedKeys:e.changedKeys}))},[i]);const _e=r(e=>{Z(o=>{const I=new Set(o);if(I.has(e))I.delete(e);else I.add(e);return I})},[]);const Ke=r(e=>{Z(o=>new Set([...o,e]))},[]);const Oe=r(e=>{Ae(e);R(null);y(null);M(false);if(b){K("");w(o=>({...o,searchText:""}))}L(false)},[b,w]);const ae=r(e=>e.id,[]);const le=p(()=>yt(i),[i]);const se=r(({item:e})=>t(ht,{change:e,onPress:ne,testID:le.get(e.id)}),[ne,le]);const ie=f.size>0;const ce=()=>{if(J){return c(a,{children:[t(a.Navigation,{onBack:()=>M(false)}),t(a.Content,{title:"Filters",centered:true,testID:`${n}-filters-title`})]})}if(u){return c(a,{children:[t(a.Navigation,{onBack:ze}),t(a.Content,{title:`${u.atomLabel}/${u.category}`,centered:true,testID:`${n}-detail-title`})]})}if(d){return c(a,{children:[t(a.Navigation,{onBack:Re}),t(a.Content,{title:`${d} History`,centered:true,testID:`${n}-history-title`}),t(a.Actions,{children:t(Q,{value:We,disabled:i.length===0,buttonStyle:s.headerActionButton,testID:`${n}-copy`})})]})}if(A){return c(a,{children:[t(a.Navigation,{onBack:Me}),t(a.Content,{title:A,centered:true,testID:`${n}-atom-detail-title`})]})}return c(a,{children:[$&&t(a.Navigation,{onBack:$}),t(a.Content,{title:"",children:ke?t(a.Search,{value:b,onChangeText:Le,onCancel:Ee,placeholder:m==="atoms"?"Search atoms...":"Search events...",accessibilityLabel:"Search Jotai atoms and events",iconSize:14,testID:`${n}-search-field`,containerTestID:`${n}-search`,clearTestID:`${n}-search-clear`,onBlur:()=>{if(b.length===0)L(false)}}):t(Ze,{tabs:[{key:"atoms",label:`Atoms${x.length>0?` (${x.length})`:""}`},{key:"events",label:`Events${h.length>0?` (${h.length})`:""}`}],activeTab:m,onTabChange:Oe,testIDPrefix:`${n}-tab`})}),c(a.Actions,{children:[t(U,{onPress:()=>L(true),style:s.headerActionButton,testID:`${n}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:t(tt,{size:14,color:l.color.textSecondary})}),t(U,{onPress:()=>M(true),style:[s.headerActionButton,ie&&s.headerActionButtonActive],testID:`${n}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:t(ot,{size:14,color:ie?l.color.accent:l.color.textSecondary})}),m==="atoms"&&t(Q,{value:Ne,disabled:x.length===0,buttonStyle:s.headerActionButton,testID:`${n}-copy`}),m==="events"&&c(ye,{children:[t(Q,{value:je,disabled:h.length===0,buttonStyle:s.headerActionButton,testID:`${n}-copy`}),t(lt,{isEnabled:P,onToggle:Be,accessibilityLabel:"Toggle Jotai atom capture",testID:`${n}-power`}),t(st,{onPress:ve,disabled:h.length===0,buttonStyle:s.headerActionButton,testID:`${n}-clear`})]})]})]})};const Ue=()=>{if(J){return t(pt,{ignoredPatterns:f,onTogglePattern:_e,onAddPattern:Ke,atoms:v})}if(u&&C!==null){return t(gt,{change:u,changes:i,selectedIndex:C,onIndexChange:re,disableInternalFooter:true,initialView:xe})}if(d){return i.length>0?t(me,{testID:`${n}-history-list`,data:i,renderItem:se,keyExtractor:ae,contentContainerStyle:s.listContent,showsVerticalScrollIndicator:true,...pe}):t(G,{testID:`${n}-history-empty`,...fe({subject:"changes",search:b,total:b.trim()?De:0,capturing:P,waiting:{otto:"waiting",title:"No history yet",message:`Changes for ${d} will appear here.`},paused:{title:"No history yet",message:`Capture is off, so nothing is being recorded for ${d}.`}})})}if(A){const e=v.find(o=>o.label===A)??null;return e?t(bt,{atom:e,onViewHistory:Fe}):t(G,{testID:`${n}-atom-detail-gone`,otto:"ghost",title:"Atom no longer registered",message:`${A} is not in the registry any more.`})}if(m==="atoms"){return t(ft,{atoms:x,searchQuery:b,onOpenAtom:Je})}return c(ye,{children:[!P&&c(B,{style:s.disabledBanner,testID:`${n}-banner-disabled`,children:[t(nt,{size:14,color:l.color.warning}),t(O,{style:s.disabledText,children:"Atom capture is disabled"})]}),$e&&c(U,{style:s.lockedBanner,onPress:He,activeOpacity:.8,testID:`${n}-locked`,accessibilityRole:"button",children:[c(O,{style:s.lockedText,testID:`${n}-locked-text`,children:[W," older"," ",W===1?"change":"changes"," locked"]}),t(B,{style:s.upgradeBadge,children:t(O,{style:s.upgradeBadgeText,children:"UPGRADE"})})]}),j.length>0?t(me,{ref:Pe,testID:`${n}-list`,data:j,renderItem:se,keyExtractor:ae,contentContainerStyle:s.listContent,showsVerticalScrollIndicator:true,...pe}):t(Ct,{isEnabled:P,searchText:b,totalChanges:we.totalChanges})]})};const Ge=Ce?rt.modal.root():"buoy-jotai-modal";if(!S)return null;const de=u&&C!==null?t(mt,{change:u,changes:i,selectedIndex:C,onIndexChange:re}):null;const Qe=u&&i.length>1?68:0;const qe=!J&&!(u&&C!==null)&&(d!=null||m==="events"||m==="atoms");const ue=t(B,{style:s.container,children:Ue()});const he=t(at,{visible:Ie,onClose:()=>X(false),featureName:"Full Atom History"});if(Se){return c(be,{children:[c(B,{style:s.inlineRoot,children:[t(B,{style:s.inlineHeader,...ct,children:ce()}),ue,de]}),he]})}return c(be,{children:[t(Ye,{visible:S,onClose:H,onMinimize:z,persistenceKey:Ge,header:{showToggleButton:true,customContent:ce()},onModeChange:Ve,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:qe,styles:{},footer:de,footerHeight:Qe,children:ue}),he]})}export function JotaiToolView(S={}){return t(JotaiModal,{...S,inline:true,visible:true,onClose:()=>{}})}const s=Xe.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:et.border.default,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:l.color.buttonSurface,borderWidth:1,borderColor:l.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonActive:{backgroundColor:l.color.accentSoft,borderColor:l.color.accentBorderStrong},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:l.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:l.color.warning+"20"},disabledText:{color:l.color.warning,fontSize:11,flex:1},listContent:{paddingTop:8,paddingBottom:20},emptyState:{alignItems:"center",paddingVertical:40},emptyTitle:{color:l.color.text,fontSize:14,fontWeight:"600",marginTop:12,marginBottom:6},emptyText:{color:l.color.textTertiary,fontSize:12,textAlign:"center",lineHeight:18},lockedBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:l.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:l.color.accentBorder},lockedText:{color:l.color.accent,fontSize:11,fontWeight:"500",flex:1},upgradeBadge:{backgroundColor:l.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},upgradeBadgeText:{color:l.color.onAccent,fontSize:9,fontWeight:"700",letterSpacing:.5}});
|
|
1
|
+
"use strict";import{useState as g,useMemo as p,useRef as E,useCallback as r,useEffect as ge}from"react";import{View as B,Text as O,StyleSheet as Xe,FlatList as me,TouchableOpacity as U}from"react-native";import{JsModal as Ye,ModalHeader as a,TabSelector as Ze,macOSColors as et,night as l,Search as tt,Filter as ot,Power as nt,ToolEmptyState as G,resolveListEmptyState as fe,devToolsStorageKeys as rt,ProUpgradeModal as at,PowerToggleButton as lt,ToolbarCopyButton as Q,ToolbarClearButton as st,truncatePayload as D,TickProvider as be,useLimit as it,windowDragProps as ct,EVENT_LIST_PRESET as pe}from"@buoy-gg/shared-ui";import{useIsPro as dt}from"@buoy-gg/license";import{useJotaiAtomChanges as ut}from"../hooks/useJotaiAtomChanges";import{JotaiAtomChangeItem as ht}from"./JotaiAtomChangeItem";import{JotaiAtomDetailContent as gt,JotaiAtomDetailFooter as mt}from"./JotaiAtomDetailContent";import{JotaiAtomBrowser as ft}from"./JotaiAtomBrowser";import{JotaiAtomValueDetailContent as bt}from"./JotaiAtomValueDetailContent";import{JotaiEventFilterView as pt}from"./JotaiEventFilterView";import{JOTAI_TEST_ID as n,buildChangeRowTestIDs as yt}from"../utils/testIDs";import{jsx as t,jsxs as c,Fragment as ye}from"react/jsx-runtime";function Ct({isEnabled:S,searchText:H,totalChanges:k}){const z=fe({subject:"changes",search:H,total:k,capturing:S,waiting:{otto:"waiting",title:"No atom changes",message:"Atom changes will appear here as values update."},paused:{title:"No atom changes",message:"Enable capture to start recording atom changes"}});return t(G,{...z,testID:`${n}-empty`})}export function JotaiModal({visible:S,onClose:H,onBack:k,onMinimize:z,enableSharedModalDimensions:Ce=false,inline:Se=false,initialTab:Te,initialSelectedChangeId:T,initialDetailView:xe,onChangeSelect:F,onAtomExpand:q}){const St=dt();const $=it("jotai.changes");const[Ie,X]=g(false);const[m,Ae]=g(Te??"atoms");const[d,R]=g(null);const[A,Y]=g(null);const[J,M]=g(false);const[f,Z]=g(new Set);const{atomChanges:ee,filteredChanges:N,stats:we,filter:Tt,setFilter:w,atoms:v,clearChanges:ve,isEnabled:P,toggleCapture:Be}=ut();const h=p(()=>{if(f.size===0)return N;return N.filter(e=>!Array.from(f).some(o=>e.atomLabel.toLowerCase().includes(o.toLowerCase())))},[N,f]);const x=p(()=>{if(f.size===0)return v;return v.filter(e=>!Array.from(f).some(o=>e.label.toLowerCase().includes(o.toLowerCase())))},[v,f]);const De=p(()=>{if(!d)return 0;return ee.filter(e=>e.atomLabel===d).length},[ee,d]);const V=p(()=>d?h.filter(e=>e.atomLabel===d):h,[h,d]);const j=p(()=>V.slice(0,$),[V,$]);const W=p(()=>Math.max(0,V.length-$),[V.length,$]);const ke=W>0;const i=j;const[_,y]=g(null);const C=p(()=>{if(_===null)return null;const e=i.findIndex(o=>o.id===_);return e>=0?e:null},[_,i]);const u=C!==null?i[C]:null;const te=E(null);ge(()=>{if(!F)return;const e=u?.id??null;if(e===null||e===te.current)return;te.current=e;F(u)},[u,F]);const oe=E(null);ge(()=>{if(!T)return;if(oe.current===T)return;const e=i.some(o=>o.id===T);if(!e)return;oe.current=T;y(T)},[T,i]);const[b,K]=g("");const[$e,L]=g(false);const xt=E(null);const Pe=E(null);const Ve=r(e=>{},[]);const Le=e=>{K(e);if(m==="events"){w(o=>({...o,searchText:e}))}};const Ee=r(()=>{K("");w(e=>({...e,searchText:""}));L(false)},[w]);const ne=r(e=>{y(e.id)},[]);const He=r(()=>{X(true)},[]);const ze=r(()=>{y(null)},[]);const re=r(e=>{const o=i[e];if(o)y(o.id)},[i]);const Fe=r(e=>{R(e);y(null)},[]);const Re=r(()=>{R(null);y(null)},[]);const Je=r(e=>{Y(e);q?.(e)},[q]);const Me=r(()=>{Y(null)},[]);const Ne=r(()=>{return x.reduce((e,o)=>{try{const I=o.getValue();e[o.label]=D(I)}catch{e[o.label]=null}return e},{})},[x]);const je=r(()=>{return h.map(e=>({id:e.id,atomLabel:e.atomLabel,timestamp:e.timestamp,prevValue:D(e.prevValue),nextValue:D(e.nextValue),hasValueChange:e.hasValueChange,changedKeys:e.changedKeys}))},[h]);const We=r(()=>{return i.map(e=>({id:e.id,atomLabel:e.atomLabel,timestamp:e.timestamp,prevValue:D(e.prevValue),nextValue:D(e.nextValue),hasValueChange:e.hasValueChange,changedKeys:e.changedKeys}))},[i]);const _e=r(e=>{Z(o=>{const I=new Set(o);if(I.has(e))I.delete(e);else I.add(e);return I})},[]);const Ke=r(e=>{Z(o=>new Set([...o,e]))},[]);const Oe=r(e=>{Ae(e);R(null);y(null);M(false);if(b){K("");w(o=>({...o,searchText:""}))}L(false)},[b,w]);const ae=r(e=>e.id,[]);const le=p(()=>yt(i),[i]);const se=r(({item:e})=>t(ht,{change:e,onPress:ne,testID:le.get(e.id)}),[ne,le]);const ie=f.size>0;const ce=()=>{if(J){return c(a,{children:[t(a.Navigation,{onBack:()=>M(false)}),t(a.Content,{title:"Filters",centered:true,testID:`${n}-filters-title`})]})}if(u){return c(a,{children:[t(a.Navigation,{onBack:ze}),t(a.Content,{title:`${u.atomLabel}/${u.category}`,centered:true,testID:`${n}-detail-title`})]})}if(d){return c(a,{children:[t(a.Navigation,{onBack:Re}),t(a.Content,{title:`${d} History`,centered:true,testID:`${n}-history-title`}),t(a.Actions,{children:t(Q,{value:We,disabled:i.length===0,buttonStyle:s.headerActionButton,testID:`${n}-copy`})})]})}if(A){return c(a,{children:[t(a.Navigation,{onBack:Me}),t(a.Content,{title:A,centered:true,testID:`${n}-atom-detail-title`})]})}return c(a,{children:[k&&t(a.Navigation,{onBack:k}),t(a.Content,{title:"",children:$e?t(a.Search,{value:b,onChangeText:Le,onCancel:Ee,placeholder:m==="atoms"?"Search atoms...":"Search events...",accessibilityLabel:"Search Jotai atoms and events",iconSize:14,testID:`${n}-search-field`,containerTestID:`${n}-search`,clearTestID:`${n}-search-clear`,onBlur:()=>{if(b.length===0)L(false)}}):t(Ze,{tabs:[{key:"atoms",label:`Atoms${x.length>0?` (${x.length})`:""}`},{key:"events",label:`Events${h.length>0?` (${h.length})`:""}`}],activeTab:m,onTabChange:Oe,testIDPrefix:`${n}-tab`})}),c(a.Actions,{children:[t(U,{onPress:()=>L(true),style:s.headerActionButton,testID:`${n}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:t(tt,{size:14,color:l.color.textSecondary})}),t(U,{onPress:()=>M(true),style:[s.headerActionButton,ie&&s.headerActionButtonActive],testID:`${n}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:t(ot,{size:14,color:ie?l.color.accent:l.color.textSecondary})}),m==="atoms"&&t(Q,{value:Ne,disabled:x.length===0,buttonStyle:s.headerActionButton,testID:`${n}-copy`}),m==="events"&&c(ye,{children:[t(Q,{value:je,disabled:h.length===0,buttonStyle:s.headerActionButton,testID:`${n}-copy`}),t(lt,{isEnabled:P,onToggle:Be,accessibilityLabel:"Toggle Jotai atom capture",testID:`${n}-power`}),t(st,{onPress:ve,disabled:h.length===0,buttonStyle:s.headerActionButton,testID:`${n}-clear`})]})]})]})};const Ue=()=>{if(J){return t(pt,{ignoredPatterns:f,onTogglePattern:_e,onAddPattern:Ke,atoms:v})}if(u&&C!==null){return t(gt,{change:u,changes:i,selectedIndex:C,onIndexChange:re,disableInternalFooter:true,initialView:xe})}if(d){return i.length>0?t(me,{keyboardShouldPersistTaps:"handled",testID:`${n}-history-list`,data:i,renderItem:se,keyExtractor:ae,contentContainerStyle:s.listContent,showsVerticalScrollIndicator:true,...pe}):t(G,{testID:`${n}-history-empty`,...fe({subject:"changes",search:b,total:b.trim()?De:0,capturing:P,waiting:{otto:"waiting",title:"No history yet",message:`Changes for ${d} will appear here.`},paused:{title:"No history yet",message:`Capture is off, so nothing is being recorded for ${d}.`}})})}if(A){const e=v.find(o=>o.label===A)??null;return e?t(bt,{atom:e,onViewHistory:Fe}):t(G,{testID:`${n}-atom-detail-gone`,otto:"ghost",title:"Atom no longer registered",message:`${A} is not in the registry any more.`})}if(m==="atoms"){return t(ft,{atoms:x,searchQuery:b,onOpenAtom:Je})}return c(ye,{children:[!P&&c(B,{style:s.disabledBanner,testID:`${n}-banner-disabled`,children:[t(nt,{size:14,color:l.color.warning}),t(O,{style:s.disabledText,children:"Atom capture is disabled"})]}),ke&&c(U,{style:s.lockedBanner,onPress:He,activeOpacity:.8,testID:`${n}-locked`,accessibilityRole:"button",children:[c(O,{style:s.lockedText,testID:`${n}-locked-text`,children:[W," older"," ",W===1?"change":"changes"," locked"]}),t(B,{style:s.upgradeBadge,children:t(O,{style:s.upgradeBadgeText,children:"UPGRADE"})})]}),j.length>0?t(me,{keyboardShouldPersistTaps:"handled",ref:Pe,testID:`${n}-list`,data:j,renderItem:se,keyExtractor:ae,contentContainerStyle:s.listContent,showsVerticalScrollIndicator:true,...pe}):t(Ct,{isEnabled:P,searchText:b,totalChanges:we.totalChanges})]})};const Ge=Ce?rt.modal.root():"buoy-jotai-modal";if(!S)return null;const de=u&&C!==null?t(mt,{change:u,changes:i,selectedIndex:C,onIndexChange:re}):null;const Qe=u&&i.length>1?68:0;const qe=!J&&!(u&&C!==null)&&(d!=null||m==="events"||m==="atoms");const ue=t(B,{style:s.container,children:Ue()});const he=t(at,{visible:Ie,onClose:()=>X(false),featureName:"Full Atom History"});if(Se){return c(be,{children:[c(B,{style:s.inlineRoot,children:[t(B,{style:s.inlineHeader,...ct,children:ce()}),ue,de]}),he]})}return c(be,{children:[t(Ye,{visible:S,onClose:H,onMinimize:z,persistenceKey:Ge,header:{showToggleButton:true,customContent:ce()},onModeChange:Ve,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:qe,styles:{},footer:de,footerHeight:Qe,children:ue}),he]})}export function JotaiToolView(S={}){return t(JotaiModal,{...S,inline:true,visible:true,onClose:()=>{}})}const s=Xe.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:et.border.default,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:l.color.buttonSurface,borderWidth:1,borderColor:l.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonActive:{backgroundColor:l.color.accentSoft,borderColor:l.color.accentBorderStrong},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:l.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:l.color.warning+"20"},disabledText:{color:l.color.warning,fontSize:11,flex:1},listContent:{paddingTop:8,paddingBottom:20},emptyState:{alignItems:"center",paddingVertical:40},emptyTitle:{color:l.color.text,fontSize:14,fontWeight:"600",marginTop:12,marginBottom:6},emptyText:{color:l.color.textTertiary,fontSize:12,textAlign:"center",lineHeight:18},lockedBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:l.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:l.color.accentBorder},lockedText:{color:l.color.accent,fontSize:11,fontWeight:"500",flex:1},upgradeBadge:{backgroundColor:l.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},upgradeBadgeText:{color:l.color.onAccent,fontSize:9,fontWeight:"700",letterSpacing:.5}});
|
package/lib/web/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";var ht=Object.defineProperty;var vo=Object.getOwnPropertyDescriptor;var Co=Object.getOwnPropertyNames;var wo=Object.prototype.hasOwnProperty;var xo=(e,t)=>{for(var o in t)ht(e,o,{get:t[o],enumerable:true})},gt=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Co(t))!wo.call(e,a)&&a!==o&&ht(e,a,{get:()=>t[a],enumerable:!(n=vo(t,a))||n.enumerable});return e},So=(e,t,o)=>(gt(e,t,"default"),o&>(o,t,"default"));var Xr=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{createRestoreScope as Vo,emptyRestoreResult as To,failedRestore as Ao,registerStateSnapshotProvider as Io,unionKeys as Do}from"@buoy-gg/shared-ui/web";import{boundedDeepEqual as ko}from"@buoy-gg/shared-ui/web/dataViewer";import{ChangeLog as Lo,entityColor as Eo,formatValuePreview as $o,shallowDiffSummary as Bo}from"@buoy-gg/shared-ui/web";var Po={count:"#10B981",auth:"#8B5CF6",user:"#3B82F6",cart:"#EC4899",app:"#6366F1",ui:"#F59E0B",settings:"#14B8A6",theme:"#06B6D4",nav:"#F97316",form:"#EF4444",modal:"#A855F7",filter:"#84CC16"};function mt(e){return Eo(e,Po)}function Ro(e,t=40){return $o(e,{maxLength:t,functionLabel:"(fn)"})}var zo=Bo,Ho=class extends Lo{constructor(){super(...arguments);this.atoms=new Map;this.atomListeners=new Set}addAtomChange(e){if(!this.canRecord())return;let{atomLabel:t,prevValue:o,nextValue:n,category:a="write"}=e,r=o!==n,{summary:s,changedKeys:i,changedCount:d}=zo(o,n),m=Ro(n),l={id:this.nextId(),atomLabel:t,timestamp:Date.now(),prevValue:o,nextValue:n,hasValueChange:r,category:a,changedKeys:i,changedKeysCount:d,diffSummary:s,valuePreview:m,isSlowUpdate:false};this.push(l);let y=this.atoms.get(t);y&&y.changeCount++,this.notifyListeners(),this.notifyAtomListeners()}getAtomChanges(){return this.getAll()}getAtomChangeById(e){return this.getById(e)}clearAtomChanges(){for(let e of this.atoms.values())e.changeCount=0;this.clear(),this.notifyAtomListeners()}getAtomSnapshots(){return Array.from(this.atoms.values()).map(e=>{let t;try{t=e.getValue()}catch{t=void 0}return{label:e.label,changeCount:e.changeCount,color:e.color,currentValue:t,writeKind:e.writeKind}})}replaceFromSnapshot(e,t){if(!this.getEnabled())return;let o=new Map;for(let r of this.items){let s=r.prevValue;(!s||s.__buoyValueOnDevice!==true)&&o.set(r.id,r)}let n=e.slice(0,this.max).map(r=>{let s=o.get(r.id),i=r.prevValue;return s&&i?.__buoyValueOnDevice===true?{...r,prevValue:s.prevValue,nextValue:s.nextValue}:r}),a=new Map;for(let[r,s]of this.atoms)try{let i=s.getValue(),d=i;(!d||d.__buoyValueOnDevice!==true)&&a.set(r,i)}catch{}this.atoms=new Map(t.map(r=>{let s=r.currentValue,i=a.get(r.label),d=i!==void 0&&s?.__buoyValueOnDevice===true?i:r.currentValue;return[r.label,{label:r.label,changeCount:r.changeCount,color:r.color,getValue:()=>d,writeKind:r.writeKind}]})),this.setItems(n),this.notifyAtomListeners()}hydrateChange(e,t){this.hydrateById(e,t)}hydrateAtomValue(e,t){let o=this.atoms.get(e);o&&(this.atoms.set(e,{...o,getValue:()=>t}),this.notifyAtomListeners())}registerAtom(e,t,o,n){if(this.atoms.has(e))return;let a={label:e,changeCount:0,color:mt(e),getValue:t,setValue:o,writeKind:n};this.atoms.set(e,a),this.notifyAtomListeners()}setAtomValue(e,t){let o=this.atoms.get(e);if(!o)throw new Error(`Atom "${e}" is not registered`);if(!o.setValue)throw new Error(`Atom "${e}" is read-only (derived) \u2014 cannot set`);o.setValue(t)}unregisterAtom(e){this.atoms.delete(e),this.notifyAtomListeners()}getAtoms(){return Array.from(this.atoms.values())}getAtom(e){return this.atoms.get(e)}getAtomColor(e){return this.atoms.get(e)?.color??mt(e)}filterAtomChanges(e){let t=this.getAll();if(e.searchText){let o=e.searchText.toLowerCase();t=t.filter(n=>n.atomLabel.toLowerCase().includes(o)||n.valuePreview.toLowerCase().includes(o)||n.changedKeys.some(a=>a.toLowerCase().includes(o)))}return e.atomLabels&&e.atomLabels.length>0&&(t=t.filter(o=>e.atomLabels.includes(o.atomLabel))),e.onlyWithChanges&&(t=t.filter(o=>o.hasValueChange)),t}getStats(){let e=this.items.length,t=this.items.filter(o=>o.hasValueChange).length;return{totalChanges:e,changesWithValueChange:t,changesWithoutValueChange:e-t,atomCount:this.atoms.size}}getUniqueAtomLabels(){return Array.from(this.atoms.keys()).sort()}setMaxChanges(e){this.setMax(e)}subscribeToAtoms(e){return this.atomListeners.add(e),()=>this.atomListeners.delete(e)}notifyAtomListeners(){let e=this.getAtoms();this.atomListeners.forEach(t=>t(e))}},b=new Ho;function Oo(){let e=b.getAtoms();if(e.length===0)return{canCapture:false,canRestore:false,detail:"No Jotai atoms registered \u2014 pass your atoms to watchAtoms() / watchDefaultStoreAtoms()"};let t=e.filter(o=>o.setValue).length;return{canCapture:true,canRestore:t>0,detail:t<e.length?`${e.length-t} derived atom(s) recompute automatically and are not restored`:void 0}}async function Wo(){let e=[],t={},o=0;for(let n of b.getAtoms())try{let a=n.getValue();if(typeof a=="function"){e.push(`atom "${n.label}": function value not capturable`);continue}n.setValue||(o+=1),t[n.label]={value:a,writable:!!n.setValue}}catch(a){e.push(`atom "${n.label}": capture failed (${String(a)})`)}return o>0&&e.push(`${o} derived atom(s) captured for inspection only (recompute on restore)`),{data:{atoms:t},warnings:e}}async function jo(e,t){let o=e,n=Vo(t),a=To();if(!o?.atoms)return Ao("empty jotai snapshot");let r=0;for(let[i,d]of Object.entries(o.atoms)){if(!n.allows(i))continue;if(!d.writable){r+=1;continue}let m=b.getAtom(i);if(!m){a.skipped.push({id:i,reason:"atom not registered (renamed, or unwatched since snapshot?)"});continue}if(!m.setValue){a.skipped.push({id:i,reason:"atom is now read-only (derived)"});continue}try{m.setValue(d.value),a.applied+=1}catch(l){a.skipped.push({id:i,reason:String(l)}),a.ok=false}}r>0&&a.warnings.push(`${r} derived atom(s) left to recompute`);let s=n.excludedWarning("atom(s)");return s&&a.warnings.push(s),a}async function Mo(e,t){let o=e?.atoms??{},n=t===void 0,a={};if(n)for(let i of b.getAtoms())try{a[i.label]={value:i.getValue(),writable:!!i.setValue}}catch{}else Object.assign(a,t?.atoms??{});let r=[],s=[];for(let i of Do(a,o)){if(!(i in o)){n?s.push(`atom "${i}" not in snapshot \u2014 untouched`):r.push({key:i,label:i,verdict:"removed",oldValue:a[i]?.value});continue}let d=o[i],m=i in a&&ko(a[i].value,d.value);if(!d.writable){r.push({key:i,label:i,verdict:m?"unchanged":"recomputes",reason:m?void 0:"derived atom \u2014 recomputes from its sources",oldValue:a[i]?.value,newValue:d.value});continue}if(n){let l=b.getAtom(i);if(!l){r.push({key:i,label:i,verdict:"wont-apply",reason:"atom not registered (renamed, or unwatched since snapshot?)"});continue}if(!l.setValue){r.push({key:i,label:i,verdict:"wont-apply",reason:"atom is now read-only (derived)"});continue}}i in a?m?r.push({key:i,label:i,verdict:"unchanged"}):r.push({key:i,label:i,verdict:"changed",oldValue:a[i].value,newValue:d.value}):r.push({key:i,label:i,verdict:"added",newValue:d.value})}return{items:r,notes:s}}Io({id:"jotai",label:"Jotai",status:Oo,capture:Wo,restore:jo,previewItems:Mo});import{useState as _,useMemo as Q,useRef as Ae,useCallback as k,useEffect as ft}from"react";var pt={};xo(pt,{AccessibilityInfo:()=>Jo,ActivityIndicator:()=>Ua,Alert:()=>qa,Animated:()=>ja,AppRegistry:()=>Uo,AppState:()=>Go,Appearance:()=>_o,BackHandler:()=>Yo,Button:()=>Ga,CheckBox:()=>ua,Clipboard:()=>qo,DeviceEventEmitter:()=>Aa,Dimensions:()=>Qo,Easing:()=>Zo,FlatList:()=>ze,I18nManager:()=>Xo,Image:()=>ha,ImageBackground:()=>ga,InteractionManager:()=>ta,Keyboard:()=>ea,KeyboardAvoidingView:()=>ma,LayoutAnimation:()=>oa,Linking:()=>aa,LogBox:()=>Ta,Modal:()=>Ja,NativeEventEmitter:()=>na,NativeModules:()=>Ko,PanResponder:()=>ra,Picker:()=>fa,PixelRatio:()=>ia,Platform:()=>la,Pressable:()=>Ka,ProgressBar:()=>pa,RefreshControl:()=>ya,SafeAreaView:()=>ba,ScrollView:()=>fe,SectionList:()=>va,Share:()=>sa,StatusBar:()=>Ca,StyleSheet:()=>ie,Switch:()=>_a,Text:()=>C,TextInput:()=>Ma,Touchable:()=>wa,TouchableHighlight:()=>Fa,TouchableNativeFeedback:()=>xa,TouchableOpacity:()=>le,TouchableWithoutFeedback:()=>Na,UIManager:()=>ca,Vibration:()=>da,View:()=>u,VirtualizedList:()=>Sa,YellowBox:()=>Va,findNodeHandle:()=>Ya,unstable_createElement:()=>No,useColorScheme:()=>Ia,useLocaleContext:()=>Da,useWindowDimensions:()=>ka});So(pt,Fo);import*as Fo from"react-native-web";import{unstable_createElement as No,NativeModules as Ko,AccessibilityInfo as Jo,Appearance as _o,AppRegistry as Uo,AppState as Go,BackHandler as Yo,Clipboard as qo,Dimensions as Qo,Easing as Zo,I18nManager as Xo,Keyboard as ea,InteractionManager as ta,LayoutAnimation as oa,Linking as aa,NativeEventEmitter as na,PanResponder as ra,PixelRatio as ia,Platform as la,Share as sa,UIManager as ca,Vibration as da,CheckBox as ua,FlatList as ze,Image as ha,ImageBackground as ga,KeyboardAvoidingView as ma,Picker as fa,ProgressBar as pa,RefreshControl as ya,SafeAreaView as ba,SectionList as va,StatusBar as Ca,Touchable as wa,TouchableNativeFeedback as xa,VirtualizedList as Sa,YellowBox as Va,LogBox as Ta,DeviceEventEmitter as Aa,useColorScheme as Ia,useLocaleContext as Da,useWindowDimensions as ka}from"react-native-web";import*as H from"react-native-web";import{createElement as He,forwardRef as yt,useCallback as La,useRef as Ea}from"react";import{useEffect as $a,useState as Ba}from"react";import{createPortal as Pa}from"react-dom";var Ra='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as za}from"react/jsx-runtime";var me=Symbol.for("@buoy-gg/portal-host"),bt=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function vt(){let e=document;if(e[me])return e[me].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:Ra});let o=()=>{let l=document.fullscreenElement,y=l&&l.tagName!=="CANVAS"?l:document.body;t.parentElement!==y&&y.appendChild(t)},n=new Map,a=l=>{(!t.contains(l.target)||!bt(l.target))&&n.set(l.code||l.key,{key:l.key,code:l.code,location:l.location,keyCode:l.keyCode,which:l.which,altKey:l.altKey,ctrlKey:l.ctrlKey,metaKey:l.metaKey,shiftKey:l.shiftKey})},r=l=>{n.delete(l.code||l.key)},s=()=>n.clear(),i=()=>{let l=[...n.values()];n.clear();for(let y of l)document.dispatchEvent(new KeyboardEvent("keyup",{...y,bubbles:true}))},d=l=>{bt(l.target)&&l.stopPropagation()},m=l=>l.stopPropagation();return o(),document.addEventListener("fullscreenchange",o),document.addEventListener("keydown",a,true),document.addEventListener("keyup",r,true),window.addEventListener("blur",s),t.addEventListener("focusin",i),t.addEventListener("keydown",d),t.addEventListener("keyup",d),t.addEventListener("keypress",d),t.addEventListener("wheel",m,{passive:true}),e[me]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",o),document.removeEventListener("keydown",a,true),document.removeEventListener("keyup",r,true),window.removeEventListener("blur",s),t.remove(),delete e[me]}},t}function Ha({children:e}){let[t,o]=Ba(null);return $a(()=>{let n=vt(),a=document[me];return a.users++,o(n),()=>{--a.users===0&&a.dispose()}},[]),t?Pa(za("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var ne=H,Oa=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],re=e=>typeof e=="number"?`${e}px`:e;function Oe(e){if(Array.isArray(e)){let y=e.map(Oe);return y.some((x,v)=>x!==e[v])?y:e}if(!e||typeof e!="object"||!Oa.some(y=>e[y]!=null))return e;let{shadowColor:t,shadowOffset:o,shadowOpacity:n,shadowRadius:a,textShadowColor:r,textShadowOffset:s,textShadowRadius:i,...d}=e;if(t!=null||o!=null||n!=null||a!=null){let y=t??"black",x=n==null?y:`color-mix(in srgb, ${y} ${Math.min(n,1)*100}%, transparent)`,v=`${re(o?.width??0)} ${re(o?.height??0)} ${re(a??0)} ${x}`;d.boxShadow=typeof d.boxShadow=="string"?`${d.boxShadow}, ${v}`:d.boxShadow??v}let{width:m=0,height:l=0}=s??{};if(r&&(m||l||i)){let y=`${re(m)} ${re(l)} ${re(i??0)} ${r}`;d.textShadow=d.textShadow?`${d.textShadow}, ${y}`:y}return d}var Wa=ne.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function Ct(e,t){if(typeof e=="function")return n=>Ct(e(n),t);let o=Oe(e);return t?[o,Wa[t]]:o}var ie={...ne.StyleSheet,create:e=>ne.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,o])=>[t,Oe(o)])))};function M(e){let t=yt((n,a)=>{let{accessibilityState:r,accessibilityValue:s,pointerEvents:i,...d}=n;for(let l of["busy","checked","disabled","expanded","selected"])r?.[l]!==void 0&&d[`aria-${l}`]===void 0&&(d[`aria-${l}`]=r[l]);for(let[l,y]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))s?.[l]!==void 0&&d[`aria-${y}`]===void 0&&(d[`aria-${y}`]=s[l]);let m=Ct(d.style,i);return m!==d.style&&(d.style=m),He(e,{...d,ref:a})}),o=e.State;return o&&Object.assign(t,{State:o}),t.displayName=e.displayName??e.name??"NativeWebView",t}var u=M(H.View),C=M(H.Text),ja={...ne.Animated,View:ne.Animated.createAnimatedComponent(u),Text:ne.Animated.createAnimatedComponent(C)},Ma=M(H.TextInput),le=M(H.TouchableOpacity),Fa=M(H.TouchableHighlight),Na=M(H.TouchableWithoutFeedback),Ka=M(H.Pressable),fe=M(H.ScrollView),wt=yt((e,t)=>{let o=Ea(null),n=La(a=>{if(a){let r=a;for(;r.parentElement&&r.parentElement!==document.body;)r=r.parentElement;r.parentElement===document.body&&(o.current=r,Object.assign(r.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),vt().appendChild(r))}else o.current&&(document.body.appendChild(o.current),o.current=null);typeof t=="function"?t(a):t&&(t.current=a)},[t]);return He(Ha,null,He(H.Modal,{...e,ref:n}))});wt.displayName="Modal";var Ja=M(wt),_a=M(H.Switch),Ua=M(H.ActivityIndicator),Ga=M(H.Button),Ya=H.findNodeHandle,qa={alert(e,t,o,n){if(typeof document>"u")return;let a=document.createElement("dialog");a.dataset.buoyRoot="",a.setAttribute("aria-label",e),a.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let r=document.createElement("h2");if(r.textContent=e,r.style.cssText="font-size:18px;margin:0 0 12px",a.appendChild(r),t){let m=document.createElement("p");m.textContent=t,m.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",a.appendChild(m)}let s=document.createElement("div");s.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let i=o?.length?o:[{text:"OK"}],d=()=>{a.close?.(),a.remove()};for(let m of i){let l=document.createElement("button");l.type="button",l.textContent=m.text??"OK",l.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${m.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,l.onclick=()=>{d(),m.onPress?.()},s.appendChild(l)}a.addEventListener("cancel",m=>{m.preventDefault(),n?.cancelable!==false&&(d(),n?.onDismiss?.())}),a.appendChild(s),document.body.appendChild(a),a.showModal?a.showModal():a.setAttribute("open","")}};import{JsModal as Qa,ModalHeader as L,TabSelector as Za,macOSColors as Xa,night as E,Search as en,Filter as tn,Power as on,ToolEmptyState as We,resolveListEmptyState as xt,devToolsStorageKeys as an,ProUpgradeModal as nn,PowerToggleButton as rn,ToolbarCopyButton as je,ToolbarClearButton as ln,truncatePayload as pe,TickProvider as St,useLimit as sn,windowDragProps as cn,EVENT_LIST_PRESET as Vt}from"@buoy-gg/shared-ui/web";import{useIsPro as dn}from"@buoy-gg/license/web";import{useCallback as un,useMemo as Tt}from"react";import{useChangeLog as hn,useSubscribedValue as gn}from"@buoy-gg/shared-ui/web";function mn(e,t){let o=e;if(t.searchText){let n=t.searchText.toLowerCase();o=o.filter(a=>a.atomLabel.toLowerCase().includes(n)||a.valuePreview.toLowerCase().includes(n)||a.changedKeys.some(r=>r.toLowerCase().includes(n)))}return t.atomLabels&&t.atomLabels.length>0&&(o=o.filter(n=>t.atomLabels.includes(n.atomLabel))),t.onlyWithChanges&&(o=o.filter(n=>n.hasValueChange)),o}var fn=()=>b.getAtoms(),pn=e=>b.subscribeToAtoms(e);function At(){let e=hn(b,{filterItems:mn}),t=gn(fn,pn),o=Tt(()=>{let r=e.items.length,s=e.items.filter(i=>i.hasValueChange).length;return{totalChanges:r,changesWithValueChange:s,changesWithoutValueChange:r-s,atomCount:t.length}},[e.items,t]),n=Tt(()=>b.getUniqueAtomLabels(),[t]),a=un(r=>b.getAtomChangeById(r),[]);return{atomChanges:e.items,filteredChanges:e.filteredItems,filter:e.filter,setFilter:e.setFilter,stats:o,atoms:t,clearChanges:b.clearAtomChanges.bind(b),isEnabled:e.isEnabled,toggleCapture:e.toggleCapture,atomLabels:n,getChangeById:a}}import{memo as yn}from"react";import{ChangeRow as bn,night as vn}from"@buoy-gg/shared-ui/web";import{jsx as Cn}from"react/jsx-runtime";function wn(e,t){return t}function xn(e,t){return e==="initial"?vn.color.textTertiary:b.getAtomColor(t)}function Me(e,t=20){if(e===void 0)return"undefined";if(e===null)return"null";if(typeof e=="boolean"||typeof e=="number")return String(e);if(typeof e=="string")return`"${e.length>t?e.slice(0,t-1)+"\u2026":e}"`;if(Array.isArray(e))return e.length===0?"[]":`[${e.length} item${e.length===1?"":"s"}]`;if(typeof e=="object"){let o=Object.keys(e);return o.length===0?"{}":`{${o.slice(0,2).join(", ")}${o.length>2?"\u2026":""}}`}return String(e).slice(0,t)}function Sn(e){return e.hasValueChange?`${Me(e.prevValue)} \u2192 ${Me(e.nextValue)}`:"no change"}function Vn(e){return e.category==="initial"?"INIT":"WRITE"}function Tn(e){let t=e.nextValue;return typeof t=="object"&&t!==null&&!Array.isArray(t)?e.changedKeys.length>0&&e.changedKeys.length<=3?e.changedKeys.join(", "):e.changedKeys.length>3?`${e.changedKeys.slice(0,2).join(", ")} +${e.changedKeys.length-2}`:e.valuePreview||"atom()":Me(t)}var It=yn(function({change:e,onPress:t,testID:o}){let n=xn(e.category,e.atomLabel),a=wn(e.category,e.atomLabel),r=Sn(e),s=Tn(e),i=Vn(e);return Cn(bn,{statusColor:n,statusLabel:a,sublabel:r,primaryText:s,timestamp:e.timestamp,badgeText:i,changed:e.hasValueChange,onPress:()=>t(e),testID:o})});import{memo as An,useState as Fe,useCallback as ye,useMemo as Dt}from"react";import{buoyColors as be,night as w,EventStepperFooter as kt,formatRelativeTime as Ie,parseValue as De,Info as In,Zap as Lt,FileText as Dn,Database as kn,GitBranch as Ln,copyToClipboard as En,ProUpgradeModal as $n,DiffModeTabs as Bn,CompareBar as Pn,DetailViewToggle as Rn,monoFont as K}from"@buoy-gg/shared-ui/web";import{DataViewer as zn,SplitDiffViewer as Hn,TreeDiffViewer as On,diffThemes as Wn}from"@buoy-gg/shared-ui/web/dataViewer";import{useIsPro as jn}from"@buoy-gg/license/web";var h="buoy-jotai";function ke(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function Mn(e,t){return`${h}-row-${ke(e)}-${t}`}function Et(e){return`${h}-atom-${ke(e)}`}function Fn(e){let t=new Map,o=new Map;for(let n of e){let a=(t.get(n.atomLabel)??0)+1;t.set(n.atomLabel,a),o.set(n.id,Mn(n.atomLabel,a))}return o}import{jsx as g,jsxs as R}from"react/jsx-runtime";var Nn=[{key:"change",label:"CHANGE",icon:Dn},{key:"value",label:"VALUE",icon:kn},{key:"diff",label:"DIFF",icon:Ln}],Kn=["diff"];function Jn(e){switch(e){case"initial":return{label:"INITIAL",color:w.color.textTertiary,bgColor:w.color.textTertiary+"26"};default:return{label:"WRITE",color:be.success,bgColor:be.success+"26"}}}function _n(e){let t=new Date(e),o=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),a=t.getSeconds().toString().padStart(2,"0"),r=t.getMilliseconds().toString().padStart(3,"0");return`${o}:${n}:${a}.${r}`}function $t(e){return new Date(e).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Un(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}function Bt(e){return e==="initial"?"INIT":"WRITE"}var Gn=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}],Yn=An(function({change:e}){let t=jn(),[o,n]=Fe(false),a=Jn(e.category),r=b.getAtomColor(e.atomLabel),s=ye(async()=>{if(!t){n(true);return}await En(e.nextValue)},[e.nextValue,t]);return R(fe,{style:p.container,contentContainerStyle:p.content,showsVerticalScrollIndicator:false,testID:`${h}-detail-scroll`,children:[R(u,{style:p.card,testID:`${h}-info-card`,children:[g(u,{style:p.sectionHeader,children:R(u,{style:p.sectionHeaderLeft,children:[g(In,{size:14,color:w.color.accent}),g(C,{style:p.sectionTitle,children:"CHANGE INFO"})]})}),R(u,{style:p.cardContent,children:[R(u,{style:p.infoRow,children:[g(C,{style:p.infoLabel,children:"Atom"}),g(C,{style:[p.infoValue,p.infoValueMono,{color:r}],numberOfLines:1,ellipsizeMode:"middle",testID:`${h}-info-atom`,children:e.atomLabel})]}),R(u,{style:p.infoRow,children:[g(C,{style:p.infoLabel,children:"Time"}),g(C,{style:[p.infoValue,p.infoValueMono],testID:`${h}-info-time`,children:_n(e.timestamp)})]}),R(u,{style:p.badgeRow,children:[g(u,{style:[p.categoryBadge,{backgroundColor:a.bgColor}],children:g(C,{style:[p.categoryText,{color:a.color}],testID:`${h}-info-category`,children:a.label})}),e.hasValueChange?R(u,{style:p.changesBadge,children:[g(Lt,{size:10,color:be.success}),g(C,{style:p.changesText,testID:`${h}-info-changes`,children:e.diffSummary||"changed"})]}):g(u,{style:p.noChangesBadge,children:g(C,{style:p.noChangesText,testID:`${h}-info-no-changes`,children:"no change"})})]})]})]}),e.changedKeys.length>0&&R(u,{style:p.card,testID:`${h}-keys-card`,children:[R(u,{style:p.sectionHeader,children:[R(u,{style:p.sectionHeaderLeft,children:[g(Lt,{size:14,color:w.color.accent}),g(C,{style:p.sectionTitle,children:"CHANGED KEYS"})]}),g(u,{style:p.countBadge,children:g(C,{style:p.countText,testID:`${h}-keys-count`,children:e.changedKeys.length})})]}),g(u,{style:p.cardContent,children:g(u,{style:p.keysContainer,children:e.changedKeys.map(i=>g(u,{style:p.keyBadge,children:g(C,{style:p.keyText,testID:`${h}-key-${ke(i)}`,children:i})},i))})})]}),g(u,{style:p.actionsRow,children:g(u,{style:[p.actionButton,p.actionButtonCopy],onTouchEnd:s,testID:`${h}-copy-value`,accessibilityRole:"button",accessibilityLabel:"Copy value",children:g(C,{style:[p.actionButtonText,{color:w.color.accent}],children:"COPY VALUE"})})}),g($n,{visible:o,onClose:()=>n(false),featureName:"Copy"})]})});function Pt({change:e,changes:t,selectedIndex:o,onIndexChange:n,disableInternalFooter:a=false,initialView:r="change"}){let[s,i]=Fe(r),[d,m]=Fe("tree"),l=t.length,y=b.getAtomColor(e.atomLabel),x=Bt(e.category),v=Un(De(e.nextValue)),T=l-o,I=o<l-1?o+1:null,W=I!==null?t[I]:null,z=T-1,se=Dt(()=>({index:I??0,label:z>0?`#${z}`:"Initial",timestamp:W?$t(W.timestamp):"",relativeTime:W?Ie(new Date(W.timestamp)):"value",badge:W?g(u,{style:[$.changeBadgeSmall,{backgroundColor:`${b.getAtomColor(W.atomLabel)}20`}],children:g(C,{style:[$.changeTextSmall,{color:b.getAtomColor(W.atomLabel)}],children:Bt(W.category)})}):void 0}),[I,W,z]),Z=Dt(()=>({index:o,label:`#${T}`,timestamp:$t(e.timestamp),relativeTime:Ie(new Date(e.timestamp)),badge:g(u,{style:[$.changeBadgeSmall,{backgroundColor:`${y}20`}],children:g(C,{style:[$.changeTextSmall,{color:y}],children:x})})}),[o,e.timestamp,y,x,T]),Ce=ye(()=>{let Y=De(e.nextValue);return R(u,{style:$.contentCard,testID:`${h}-value-card`,children:[R(u,{style:$.valueHeader,children:[g(C,{style:$.valueLabel,children:"VALUE AFTER CHANGE"}),R(u,{style:$.valueHeaderBadges,children:[g(u,{style:[$.changeBadge,{backgroundColor:`${y}20`}],children:g(C,{style:[$.changeText,{color:y}],children:x})}),g(u,{style:$.typeBadge,children:g(C,{style:$.typeText,testID:`${h}-value-type`,children:v.toUpperCase()})})]})]}),g(u,{style:p.dataViewerContainer,children:g(zn,{title:"",data:Y,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})},[e.nextValue,y,x,v]),ce=ye(()=>{let Y=De(e.prevValue),xe=De(e.nextValue);return d==="split"?g(fe,{style:{flex:1},showsVerticalScrollIndicator:true,children:g(Hn,{oldValue:Y,newValue:xe,theme:Wn.devToolsDefault,options:{hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3},showThemeName:false})}):g(On,{oldValue:Y,newValue:xe})},[e.prevValue,e.nextValue,d]),de=ye(()=>{n(Math.min(l-1,o+1))},[o,l,n]),N=ye(()=>{n(Math.max(0,o-1))},[o,n]),we=e.prevValue===void 0,ue=!a&&l>1;return R(u,{style:$.container,children:[g(Rn,{views:Nn,activeView:s,onViewChange:i,disabledKeys:we?Kn:void 0,testIDPrefix:h}),R(u,{style:[$.contentArea,ue&&$.contentAreaFooterPad],children:[s==="change"&&g(Yn,{change:e}),s==="value"&&g(u,{style:$.stateContainer,children:Ce()}),s==="diff"&&R(u,{style:$.diffContainer,testID:`${h}-diff`,children:[g(Bn,{tabs:Gn,activeTab:d,onTabChange:m,testIDPrefix:`${h}-diff-tab`}),g(Pn,{leftEvent:se,rightEvent:Z}),g(u,{style:$.diffContent,testID:`${h}-diff-content`,children:ce()})]})]}),ue&&g(kt,{currentIndex:T-1,totalItems:l,onPrevious:de,onNext:N,itemLabel:"Change",subtitle:Ie(new Date(e.timestamp)),absolute:true})]})}function Rt({change:e,changes:t,selectedIndex:o,onIndexChange:n}){let a=t.length;if(a<=1)return null;let r=a-o;return g(kt,{currentIndex:r-1,totalItems:a,onPrevious:()=>n(Math.min(a-1,o+1)),onNext:()=>n(Math.max(0,o-1)),itemLabel:"Change",subtitle:Ie(new Date(e.timestamp))})}var $=ie.create({container:{flex:1,backgroundColor:"transparent"},contentArea:{flex:1},contentAreaFooterPad:{paddingBottom:96},stateContainer:{flex:1,padding:14},contentCard:{backgroundColor:w.color.surface,borderRadius:14,padding:14,borderWidth:1,borderColor:w.color.border},valueHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},valueLabel:{fontSize:10,color:w.color.textSecondary,fontFamily:K,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:K,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:w.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:w.color.textTertiary,fontFamily:K},valueBox:{backgroundColor:w.color.bg,borderRadius:6,borderWidth:1,borderColor:w.color.border,padding:8},valueText:{fontSize:12,color:w.color.text,fontFamily:K,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:K}}),p=ie.create({container:{flex:1},content:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:w.color.surface,borderRadius:6,borderWidth:1,borderColor:w.color.accentBorderStrong,overflow:"hidden",shadowColor:w.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:w.color.accentBorder,backgroundColor:w.color.accentSoft},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:w.color.accent,fontFamily:K},cardContent:{padding:14,gap:10},infoRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},infoLabel:{fontSize:11,color:w.color.textTertiary,fontWeight:"500"},infoValue:{fontSize:11,color:w.color.text,fontWeight:"500",flex:1,textAlign:"right",marginLeft:12},infoValueMono:{fontFamily:K},badgeRow:{flexDirection:"row",flexWrap:"wrap",gap:8,marginTop:6},categoryBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4},categoryText:{fontSize:9,fontWeight:"700",letterSpacing:.3},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:be.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:be.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:w.color.surfaceElevated},noChangesText:{fontSize:9,fontWeight:"600",color:w.color.textTertiary},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:w.color.accentSoft,borderWidth:1,borderColor:w.color.accentBorder},keyText:{fontSize:11,fontWeight:"600",color:w.color.accent,fontFamily:K},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:w.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:w.color.accent,fontFamily:K},actionsRow:{flexDirection:"row",gap:12},actionButton:{paddingHorizontal:14,paddingVertical:8,borderRadius:8,borderWidth:1},actionButtonCopy:{borderColor:w.color.accentBorder,backgroundColor:w.color.accentSoft},actionButtonText:{fontSize:10,fontWeight:"700",fontFamily:K,letterSpacing:.3},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});import{useMemo as qn}from"react";import{CompactRow as Qn,night as Ne,ToolEmptyState as zt,resolveListEmptyState as Zn,monoFont as Ht}from"@buoy-gg/shared-ui/web";import{jsx as U,jsxs as Ke}from"react/jsx-runtime";function Xn(e){try{let t=e.getValue();if(t&&typeof t=="object"&&t.__buoyValueOnDevice===true)return"on device";if(t===void 0)return"undefined";if(t===null)return"null";if(Array.isArray(t))return t.length===0?"[]":`[${t.length} item${t.length===1?"":"s"}]`;if(typeof t=="object"){let o=Object.keys(t);return o.length===0?"{}":o.length<=3?o.join(", "):`${o.slice(0,2).join(", ")} +${o.length-2}`}return String(t).slice(0,40)}catch{return""}}function er(e){return e.writeKind==="value"?"primitive":e.writeKind==="action"?"custom write":e.setValue?"writable":"derived"}function tr(){return U(zt,{testID:`${h}-atoms-empty`,otto:"scanning",title:"No atoms registered",message:`Use watchAtoms(store, { atomName }) to register your Jotai atoms.
|
|
2
|
-
They will appear here with their current value.`})}function or({atoms:e,searchQuery:t,onOpenAtom:o}){let n=qn(()=>{if(!t)return e;let a=t.toLowerCase();return e.filter(r=>r.label.toLowerCase().includes(a))},[e,t]);return n.length===0&&!t?U(tr,{}):n.length===0&&t?U(zt,{testID:`${h}-atoms-no-match`,...Zn({subject:"atoms",verb:"registered",search:t,total:e.length,waiting:{otto:"scanning",title:"No atoms registered",message:"Use watchAtoms() to register your Jotai atoms."}})}):Ke(fe,{style:G.container,contentContainerStyle:G.scrollContent,showsVerticalScrollIndicator:true,testID:`${h}-atoms-scroll`,children:[Ke(u,{style:G.sectionHeader,children:[U(C,{style:G.sectionTitle,children:"ATOMS"}),U(u,{style:G.sectionCountBadge,children:U(C,{style:G.sectionCountText,testID:`${h}-atoms-count`,children:n.length})})]}),n.map(a=>{let r=Xn(a),s=b.getAtomColor(a.label),i=Et(a.label);return Ke(u,{style:G.atomRowWrapper,children:[U(Qn,{statusDotColor:s,statusLabel:er(a),primaryText:a.label,secondaryText:r||void 0,showChevron:true,onPress:()=>o(a.label),testID:i,statusTestID:`${i}-kind`,primaryTestID:`${i}-name`,secondaryTestID:`${i}-preview`}),a.changeCount>0&&U(u,{style:[G.absCountBadge,{backgroundColor:s+"22",borderColor:s+"55"}],pointerEvents:"none",children:U(C,{style:[G.absCountText,{color:s}],testID:`${i}-count`,children:String(a.changeCount)})})]},a.label)})]})}var G=ie.create({container:{flex:1},atomRowWrapper:{position:"relative"},absCountBadge:{position:"absolute",top:4,right:10,paddingHorizontal:5,paddingVertical:1,borderRadius:4,borderWidth:1,zIndex:1},absCountText:{fontSize:9,fontWeight:"700",fontFamily:Ht},scrollContent:{paddingTop:8,paddingBottom:20},sectionHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:8,gap:8},sectionTitle:{fontSize:11,fontWeight:"700",letterSpacing:.5,color:Ne.color.textTertiary},sectionCountBadge:{backgroundColor:Ne.color.accentFill,paddingHorizontal:8,paddingVertical:2,borderRadius:4},sectionCountText:{fontSize:10,fontWeight:"700",color:Ne.color.accent,fontFamily:Ht}});import{useCallback as ar,useEffect as nr,useMemo as Je,useState as Ot}from"react";import{buoyColors as _e,ExpandedInfoRow as Ue,FileJson as rr,night as D,PillBadge as Ge,parseValue as Wt,monoFont as ve}from"@buoy-gg/shared-ui/web";import{DataViewer as ir,LiveExplorer as lr,ValueEditModal as sr,updateNestedDataByPath as cr,deleteNestedDataByPath as dr}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as ur,jsx as V,jsxs as F}from"react/jsx-runtime";var hr=300,te=`${h}-atom-detail`;function gr(e){let t=o=>o.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return e.length===0?`${te}-explorer-root`:`${te}-explorer-${e.map(t).filter(Boolean).join("-")}`}function mr(e,t){if(!e.setValue)return"Derived atom \u2014 its value recomputes from other atoms and has no setter. Edit the atoms it reads from instead.";if(typeof t=="function")return"This atom holds a function \u2014 nothing here to edit as data.";if(t&&typeof t=="object"&&t.__buoyValueOnDevice===true)return"The value stayed on the device (too large for the wire) \u2014 open the tool on-device to edit it.";if(t&&typeof t=="object"){let o=Object.getPrototypeOf(t);if(!(o===Object.prototype||o===null||Array.isArray(t)||t instanceof Map||t instanceof Set))return`This atom holds a ${t.constructor?.name??"class"} instance \u2014 rebuilding it from edited fields would drop its prototype. Edit via app code.`}return null}function fr(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`array \xB7 ${e.length}`:typeof e}function jt({atom:e,onViewHistory:t}){let o=Et(e.label),[n,a]=Ot(0);nr(()=>{let v=()=>a(W=>W+1),T=b.subscribe(v),I=b.subscribeToAtoms(v);return()=>{T(),I()}},[]);let r=Je(()=>{try{return e.getValue()}catch{return}},[e,n]),s=mr(e,r),[i,d]=Ot(false),m=Je(()=>{if(s===null)return{update:(v,T)=>{let I=e.getValue();e.setValue?.(v.length===0?T:cr(I,v,T))},remove:v=>{if(v.length===0)return;let T=e.getValue();e.setValue?.(dr(T,v))},canRemove:v=>v.length>0}},[e,s]),l=Je(()=>{if(r&&typeof r=="object"){let v={};for(let[T,I]of Object.entries(r))typeof I!="function"&&(v[T]=I);return Wt(v)}return Wt(r)},[r,n]),y=ar(v=>{e.setValue?.(v),d(false)},[e]),x=e.setValue===void 0?{color:D.color.textTertiary,label:"READ-ONLY (DERIVED)"}:e.writeKind==="action"?{color:_e.warning,label:"CUSTOM WRITE"}:{color:_e.success,label:"PRIMITIVE"};return F(u,{style:S.root,children:[F(fe,{testID:`${te}-scroll`,style:S.scroll,contentContainerStyle:S.scrollContent,keyboardShouldPersistTaps:"handled",children:[V(u,{style:S.section,children:F(u,{style:S.editorContainer,children:[F(u,{style:S.sectionHeaderRow,children:[V(C,{testID:`${te}-editor-header`,style:S.sectionHeaderText,children:"Value Editor"}),s===null?F(le,{onPress:()=>d(true),testID:`${te}-raw`,accessibilityRole:"button",accessibilityLabel:"Edit raw JSON",style:S.rawButton,hitSlop:{top:6,bottom:6,left:6,right:6},children:[V(rr,{size:13,color:D.color.accent}),V(C,{style:S.rawButtonText,children:"Raw"})]}):null]}),V(u,{style:S.sectionBody,children:s===null?F(ur,{children:[V(lr,{editable:true,label:e.label,value:r,defaultExpanded:[e.label],writer:m,dataVersion:n,testIDForPath:gr,debounceMs:hr}),V(C,{style:S.editorHint,children:e.writeKind==="action"?"This atom has a custom write \u2014 the edited value is handed to it as its argument (a set for atomWithStorage, an ACTION for a reducer atom).":"Edits write into the live atom as you make them \u2014 the whole value is replaced, jotai's own semantics."})]}):V(C,{style:S.blockedText,testID:`${te}-edit-blocked`,children:s})})]})}),V(u,{style:S.section,children:F(u,{style:S.infoContainer,children:[V(C,{style:S.sectionHeaderTextPlain,children:"Atom Details"}),F(u,{style:S.infoBody,children:[F(Ue,{label:"Type",children:[V(Ge,{color:e.color,testID:`${o}-type`,children:"JOTAI"}),V(C,{style:S.valueTypeText,testID:`${o}-valuetype`,children:fr(r)})]}),V(Ue,{label:"Write",children:V(Ge,{color:x.color,testID:`${te}-write`,children:x.label})}),e.changeCount>0&&F(Ue,{label:"Changes",children:[V(Ge,{color:_e.warning,testID:`${o}-changes`,children:String(e.changeCount)}),V(le,{onPress:()=>t(e.label),style:S.inlineLinkButton,hitSlop:{top:6,bottom:6,left:6,right:6},testID:`${o}-history`,accessibilityRole:"button",accessibilityLabel:`View ${e.label} history`,children:V(C,{style:[S.inlineLinkText,{color:e.color}],children:"view history \u2192"})})]})]})]})}),V(u,{style:S.section,children:F(u,{style:S.infoContainer,children:[V(C,{style:S.sectionHeaderTextPlain,children:"Value Explorer"}),V(u,{style:S.viewerBody,testID:`${o}-value`,children:l&&typeof l=="object"?V(ir,{title:"",data:l,showTypeFilter:true,rawMode:true,initialExpanded:false}):V(C,{style:S.primitiveText,testID:`${o}-primitive`,children:String(r??"undefined")})})]})})]}),i&&s===null?V(sr,{path:[],value:r,onSave:y,onCancel:()=>d(false),saveLabel:"Apply",testIDPrefix:`${h}-value`}):null]})}var S=ie.create({root:{flex:1,minHeight:0},scroll:{flex:1},scrollContent:{paddingHorizontal:8,paddingTop:8,paddingBottom:24},section:{marginBottom:16},editorContainer:{minWidth:200,backgroundColor:D.color.surface,borderRadius:6,borderWidth:1,borderColor:D.color.accent+"4D",overflow:"hidden",shadowColor:D.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeaderRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:D.color.accent+"1A",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:D.color.accent+"33"},sectionHeaderText:{fontWeight:"600",fontSize:12,color:D.color.accent,letterSpacing:.5,textTransform:"uppercase",fontFamily:ve},rawButton:{flexDirection:"row",alignItems:"center",gap:4},rawButtonText:{color:D.color.accent,fontSize:11,fontWeight:"700"},sectionBody:{padding:8},editorHint:{color:D.color.textTertiary,fontSize:10,paddingTop:8,paddingHorizontal:4,lineHeight:14},blockedText:{color:D.color.textSecondary,fontSize:12,padding:12,lineHeight:18},infoContainer:{minWidth:200,backgroundColor:D.color.surface,borderRadius:6,borderWidth:1,borderColor:D.color.border,overflow:"hidden"},sectionHeaderTextPlain:{backgroundColor:D.color.surfaceElevated,paddingHorizontal:12,paddingVertical:8,fontWeight:"600",fontSize:12,color:D.color.textSecondary,borderBottomWidth:1,borderBottomColor:D.color.border,letterSpacing:.5,textTransform:"uppercase",fontFamily:ve},infoBody:{padding:12,gap:10},viewerBody:{backgroundColor:D.color.bg,minHeight:60},primitiveText:{color:D.color.text,fontSize:12,fontFamily:ve,padding:14},valueTypeText:{color:D.color.textTertiary,fontSize:10,fontFamily:ve,marginLeft:6},inlineLinkButton:{marginLeft:4},inlineLinkText:{fontSize:10,fontWeight:"600",fontFamily:ve}});import{useMemo as pr}from"react";import{EntityFilterView as yr}from"@buoy-gg/shared-ui/web";import{jsx as br}from"react/jsx-runtime";var vr=["\u2022 count -> hides countAtom from atoms & events","\u2022 auth -> hides authAtom, authStatusAtom","\u2022 user -> hides userAtom from both tabs"];function Cr({ignoredPatterns:e,onTogglePattern:t,onAddPattern:o,atoms:n}){let a=pr(()=>n.map(r=>({name:r.label,color:r.color})),[n]);return br(yr,{entities:a,ignoredPatterns:e,onTogglePattern:t,onAddPattern:o,entityNoun:"ATOMS",entitySingular:"atom",entityKey:"atom",testIDPrefix:h,slug:ke,howItWorks:"Patterns hide matching atoms from both the Atoms tab and the Events tab. Tap an atom above to quickly add it as a filter.",examples:vr,emptyMessage:"No atoms are being watched yet."})}import{Fragment as Mt,jsx as f,jsxs as O}from"react/jsx-runtime";function wr({isEnabled:e,searchText:t,totalChanges:o}){let n=xt({subject:"changes",search:t,total:o,capturing:e,waiting:{otto:"waiting",title:"No atom changes",message:"Atom changes will appear here as values update."},paused:{title:"No atom changes",message:"Enable capture to start recording atom changes"}});return f(We,{...n,testID:`${h}-empty`})}function Ye({visible:e,onClose:t,onBack:o,onMinimize:n,enableSharedModalDimensions:a=false,inline:r=false,initialTab:s,initialSelectedChangeId:i,initialDetailView:d,onChangeSelect:m,onAtomExpand:l}){let y=dn(),x=sn("jotai.changes"),[v,T]=_(false),[I,W]=_(s??"atoms"),[z,se]=_(null),[Z,Ce]=_(null),[ce,de]=_(false),[N,we]=_(new Set),{atomChanges:ue,filteredChanges:Y,stats:xe,filter:Qr,setFilter:he,atoms:ge,clearChanges:Ut,isEnabled:Se,toggleCapture:Gt}=At(),J=Q(()=>N.size===0?Y:Y.filter(c=>!Array.from(N).some(A=>c.atomLabel.toLowerCase().includes(A.toLowerCase()))),[Y,N]),oe=Q(()=>N.size===0?ge:ge.filter(c=>!Array.from(N).some(A=>c.label.toLowerCase().includes(A.toLowerCase()))),[ge,N]),Yt=Q(()=>z?ue.filter(c=>c.atomLabel===z).length:0,[ue,z]),Ve=Q(()=>z?J.filter(c=>c.atomLabel===z):J,[J,z]),$e=Q(()=>Ve.slice(0,x),[Ve,x]),Be=Q(()=>Math.max(0,Ve.length-x),[Ve.length,x]),qt=Be>0,P=$e,[Pe,X]=_(null),ee=Q(()=>{if(Pe===null)return null;let c=P.findIndex(A=>A.id===Pe);return c>=0?c:null},[Pe,P]),j=ee!==null?P[ee]:null,et=Ae(null);ft(()=>{if(!m)return;let c=j?.id??null;c===null||c===et.current||(et.current=c,m(j))},[j,m]);let tt=Ae(null);ft(()=>{!i||tt.current===i||!P.some(c=>c.id===i)||(tt.current=i,X(i))},[i,P]);let[q,Re]=_(""),[Qt,Te]=_(false),Zr=Ae(null),Zt=Ae(null),Xt=k(c=>{},[]),eo=c=>{Re(c),I==="events"&&he(A=>({...A,searchText:c}))},to=k(()=>{Re(""),he(c=>({...c,searchText:""})),Te(false)},[he]),ot=k(c=>{X(c.id)},[]),oo=k(()=>{T(true)},[]),ao=k(()=>{X(null)},[]),at=k(c=>{let A=P[c];A&&X(A.id)},[P]),no=k(c=>{se(c),X(null)},[]),ro=k(()=>{se(null),X(null)},[]),io=k(c=>{Ce(c),l?.(c)},[l]),lo=k(()=>{Ce(null)},[]),so=k(()=>oe.reduce((c,A)=>{try{let ae=A.getValue();c[A.label]=pe(ae)}catch{c[A.label]=null}return c},{}),[oe]),co=k(()=>J.map(c=>({id:c.id,atomLabel:c.atomLabel,timestamp:c.timestamp,prevValue:pe(c.prevValue),nextValue:pe(c.nextValue),hasValueChange:c.hasValueChange,changedKeys:c.changedKeys})),[J]),uo=k(()=>P.map(c=>({id:c.id,atomLabel:c.atomLabel,timestamp:c.timestamp,prevValue:pe(c.prevValue),nextValue:pe(c.nextValue),hasValueChange:c.hasValueChange,changedKeys:c.changedKeys})),[P]),ho=k(c=>{we(A=>{let ae=new Set(A);return ae.has(c)?ae.delete(c):ae.add(c),ae})},[]),go=k(c=>{we(A=>new Set([...A,c]))},[]),mo=k(c=>{W(c),se(null),X(null),de(false),q&&(Re(""),he(A=>({...A,searchText:""}))),Te(false)},[q,he]),nt=k(c=>c.id,[]),rt=Q(()=>Fn(P),[P]),it=k(({item:c})=>f(It,{change:c,onPress:ot,testID:rt.get(c.id)}),[ot,rt]),lt=N.size>0,st=()=>ce?O(L,{children:[f(L.Navigation,{onBack:()=>de(false)}),f(L.Content,{title:"Filters",centered:true,testID:`${h}-filters-title`})]}):j?O(L,{children:[f(L.Navigation,{onBack:ao}),f(L.Content,{title:`${j.atomLabel}/${j.category}`,centered:true,testID:`${h}-detail-title`})]}):z?O(L,{children:[f(L.Navigation,{onBack:ro}),f(L.Content,{title:`${z} History`,centered:true,testID:`${h}-history-title`}),f(L.Actions,{children:f(je,{value:uo,disabled:P.length===0,buttonStyle:B.headerActionButton,testID:`${h}-copy`})})]}):Z?O(L,{children:[f(L.Navigation,{onBack:lo}),f(L.Content,{title:Z,centered:true,testID:`${h}-atom-detail-title`})]}):O(L,{children:[o&&f(L.Navigation,{onBack:o}),f(L.Content,{title:"",children:Qt?f(L.Search,{value:q,onChangeText:eo,onCancel:to,placeholder:I==="atoms"?"Search atoms...":"Search events...",accessibilityLabel:"Search Jotai atoms and events",iconSize:14,testID:`${h}-search-field`,containerTestID:`${h}-search`,clearTestID:`${h}-search-clear`,onBlur:()=>{q.length===0&&Te(false)}}):f(Za,{tabs:[{key:"atoms",label:`Atoms${oe.length>0?` (${oe.length})`:""}`},{key:"events",label:`Events${J.length>0?` (${J.length})`:""}`}],activeTab:I,onTabChange:mo,testIDPrefix:`${h}-tab`})}),O(L.Actions,{children:[f(le,{onPress:()=>Te(true),style:B.headerActionButton,testID:`${h}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:f(en,{size:14,color:E.color.textSecondary})}),f(le,{onPress:()=>de(true),style:[B.headerActionButton,lt&&B.headerActionButtonActive],testID:`${h}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:f(tn,{size:14,color:lt?E.color.accent:E.color.textSecondary})}),I==="atoms"&&f(je,{value:so,disabled:oe.length===0,buttonStyle:B.headerActionButton,testID:`${h}-copy`}),I==="events"&&O(Mt,{children:[f(je,{value:co,disabled:J.length===0,buttonStyle:B.headerActionButton,testID:`${h}-copy`}),f(rn,{isEnabled:Se,onToggle:Gt,accessibilityLabel:"Toggle Jotai atom capture",testID:`${h}-power`}),f(ln,{onPress:Ut,disabled:J.length===0,buttonStyle:B.headerActionButton,testID:`${h}-clear`})]})]})]}),fo=()=>{if(ce)return f(Cr,{ignoredPatterns:N,onTogglePattern:ho,onAddPattern:go,atoms:ge});if(j&&ee!==null)return f(Pt,{change:j,changes:P,selectedIndex:ee,onIndexChange:at,disableInternalFooter:true,initialView:d});if(z)return P.length>0?f(ze,{testID:`${h}-history-list`,data:P,renderItem:it,keyExtractor:nt,contentContainerStyle:B.listContent,showsVerticalScrollIndicator:true,...Vt}):f(We,{testID:`${h}-history-empty`,...xt({subject:"changes",search:q,total:q.trim()?Yt:0,capturing:Se,waiting:{otto:"waiting",title:"No history yet",message:`Changes for ${z} will appear here.`},paused:{title:"No history yet",message:`Capture is off, so nothing is being recorded for ${z}.`}})});if(Z){let c=ge.find(A=>A.label===Z)??null;return c?f(jt,{atom:c,onViewHistory:no}):f(We,{testID:`${h}-atom-detail-gone`,otto:"ghost",title:"Atom no longer registered",message:`${Z} is not in the registry any more.`})}return I==="atoms"?f(or,{atoms:oe,searchQuery:q,onOpenAtom:io}):O(Mt,{children:[!Se&&O(u,{style:B.disabledBanner,testID:`${h}-banner-disabled`,children:[f(on,{size:14,color:E.color.warning}),f(C,{style:B.disabledText,children:"Atom capture is disabled"})]}),qt&&O(le,{style:B.lockedBanner,onPress:oo,activeOpacity:.8,testID:`${h}-locked`,accessibilityRole:"button",children:[O(C,{style:B.lockedText,testID:`${h}-locked-text`,children:[Be," older"," ",Be===1?"change":"changes"," locked"]}),f(u,{style:B.upgradeBadge,children:f(C,{style:B.upgradeBadgeText,children:"UPGRADE"})})]}),$e.length>0?f(ze,{ref:Zt,testID:`${h}-list`,data:$e,renderItem:it,keyExtractor:nt,contentContainerStyle:B.listContent,showsVerticalScrollIndicator:true,...Vt}):f(wr,{isEnabled:Se,searchText:q,totalChanges:xe.totalChanges})]})},po=a?an.modal.root():"buoy-jotai-modal";if(!e)return null;let ct=j&&ee!==null?f(Rt,{change:j,changes:P,selectedIndex:ee,onIndexChange:at}):null,yo=j&&P.length>1?68:0,bo=!ce&&!(j&&ee!==null)&&(z!=null||I==="events"||I==="atoms"),dt=f(u,{style:B.container,children:fo()}),ut=f(nn,{visible:v,onClose:()=>T(false),featureName:"Full Atom History"});return r?O(St,{children:[O(u,{style:B.inlineRoot,children:[f(u,{style:B.inlineHeader,...cn,children:st()}),dt,ct]}),ut]}):O(St,{children:[f(Qa,{visible:e,onClose:t,onMinimize:n,persistenceKey:po,header:{showToggleButton:true,customContent:st()},onModeChange:Xt,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:bo,styles:{},footer:ct,footerHeight:yo,children:dt}),ut]})}function xr(e={}){return f(Ye,{...e,inline:true,visible:true,onClose:()=>{}})}var B=ie.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:Xa.border.default,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:E.color.buttonSurface,borderWidth:1,borderColor:E.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonActive:{backgroundColor:E.color.accentSoft,borderColor:E.color.accentBorderStrong},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:E.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:E.color.warning+"20"},disabledText:{color:E.color.warning,fontSize:11,flex:1},listContent:{paddingTop:8,paddingBottom:20},emptyState:{alignItems:"center",paddingVertical:40},emptyTitle:{color:E.color.text,fontSize:14,fontWeight:"600",marginTop:12,marginBottom:6},emptyText:{color:E.color.textTertiary,fontSize:12,textAlign:"center",lineHeight:18},lockedBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:E.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:E.color.accentBorder},lockedText:{color:E.color.accent,fontSize:11,fontWeight:"500",flex:1},upgradeBadge:{backgroundColor:E.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},upgradeBadgeText:{color:E.color.onAccent,fontSize:9,fontWeight:"700",letterSpacing:.5}});import{JotaiIcon as qe,JOTAI_ICON_COLOR as Sr}from"@buoy-gg/shared-ui/web";import{createToolFactory as Vr,defineToolPreset as Tr}from"@buoy-gg/shared-ui/web";import{jsx as Ft}from"react/jsx-runtime";var Nt=Tr({id:"jotai",name:"JOTAI",description:"Jotai atom & state inspector",slot:"both",icon:({size:e})=>Ft(qe,{size:e}),component:Ye,props:{enableSharedModalDimensions:false}}),Ar=Vr(Nt,e=>({enableSharedModalDimensions:e.enableSharedModalDimensions??false}),e=>({icon:({size:t})=>Ft(qe,{size:t,color:e.iconColor})}));import{getDefaultStore as Ir}from"jotai/vanilla";import{atom as Dr}from"jotai/vanilla";var kr=Dr(null),Qe=kr.write,Kt=typeof Qe=="function"?String(Qe):null;function Lr(e){let t=e,o=t?.write;return typeof o!="function"?"action":o===Qe||t!==null&&"init"in t&&Kt!==null&&String(o)===Kt?"value":"action"}function Jt(e,t,o){let n=o?.enabled!==false,a=[];for(let[r,s]of Object.entries(t)){let i=s,d=Symbol.for(`@@buoy-jotai/watched/${r}`);if(i[d])continue;i[d]=true;let m;try{m=e.get(s)}catch{m=void 0}let l=typeof s.write=="function",y=e.set&&l?v=>{e.set(s,v)}:void 0;b.registerAtom(r,()=>{try{return e.get(s)}catch{return}},y,l?Lr(s):void 0),n&&b.addAtomChange({atomLabel:r,prevValue:void 0,nextValue:m,category:"initial"});let x=e.sub(s,()=>{try{let v=e.get(s);b.addAtomChange({atomLabel:r,prevValue:m,nextValue:v,category:"write"}),m=v}catch{}});a.push(()=>{x(),delete i[d],b.unregisterAtom(r)})}return()=>a.forEach(r=>r())}function Er(e,t){let o=Ir();return Jt(o,e,t)}function $r(e){return b.getAtom(e)!==void 0}import{WIRE_DETAIL_LIMIT_BYTES as Br,createSyncAdapter as Pr,capDetail as Rr,detailByIdAction as zr,expandKeyedArrays as Hr,memoByIdentity as Or,onDeviceMarker as Wr,patchFromPath as jr,readParams as Ze,readPath as Mr,refusalText as Fr,shapeSummary as Le,suggestedPatch as Nr,toWire as Kr,typedEditViolations as Jr,unshapedLists as _r}from"@buoy-gg/shared-ui/web";var Ee=Wr("Value","Atom values stay on the device \u2014 fetched on demand via getChangeDetail / getAtomValue."),Xe=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function _t(e,t){if(!Xe(e)||!Xe(t))return t;let o={...e};for(let[n,a]of Object.entries(t))o[n]=n in e?_t(e[n],a):a;return o}function Ur(e,t){let o=e;for(let n of t.split(".")){if(!Xe(o)||!(n in o))return false;o=o[n]}return Array.isArray(o)?o.length>0:!!o&&typeof o=="object"}var Gr=Or(e=>({...e,prevValue:Ee,nextValue:Ee})),Yr=e=>Kr(e,Ee),qr=Pr({version:2,getSnapshot:()=>({changes:b.getAtomChanges().map(Gr),atoms:b.getAtomSnapshots().map(e=>({...e,currentValue:Yr(e.currentValue)}))}),subscribe:[e=>b.subscribe(e),e=>b.subscribeToAtoms(e)],actions:{clearEvents:()=>{b.clearAtomChanges()},getChangeDetail:zr(e=>b.getAtomChangeById(e),(e,t)=>({prevValue:t(e.prevValue),nextValue:t(e.nextValue)})),getAtomValue:e=>{let{label:t,path:o}=Ze(e);if(!t)return{found:false,reason:"missing label"};let n=b.getAtom(t);if(!n)return{found:false,reason:"unknown label"};let a;try{a=n.getValue()}catch{a=void 0}try{JSON.stringify(a)}catch{return{found:true,label:t,currentValue:Ee}}if(o){let r=Mr(a,o);return r.ok?{found:true,label:t,path:o,shape:Le(r.value),currentValue:r.value}:{found:false,reason:r.error}}return{found:true,label:t,...Le(a)?{shape:Le(a)}:{},currentValue:Rr(a,Br)}},listAtoms:e=>{let{includeValues:t=false,limit:o}=Ze(e),n=b.getAtoms(),a=(typeof o=="number"&&o>0?n.slice(0,o):n).map(r=>{let s;if(t)try{s=r.getValue()}catch{s=void 0}let i;try{i=Le(r.getValue())}catch{i=void 0}return{label:r.label,changes:r.changeCount,writable:typeof r.setValue=="function",...i?{shape:i}:{},...t?{currentValue:s}:{}}});return{atoms:a,total:n.length,returned:a.length,includedValues:t}},setAtom:e=>{let{label:t,value:o,merge:n,path:a,force:r}=Ze(e);if(!t)throw new Error("setAtom requires a `label`");let s=b.getAtom(t),i;try{i=s?.getValue()}catch{i=void 0}let d=o,m=[],l=[],y=n===true||a!==void 0;if(a!==void 0){if(o===void 0)return{ok:false,error:`Refused: sent \`path\` without \`value\`. Say what to set "${a}" to.`};let x=jr(i,a,o);if(!x.ok)return{ok:false,error:`Refused: ${x.error}`};d=x.patch}if(!r&&y&&i!==void 0){let x=Hr(i,d);if(x.error)return{ok:false,error:`Refused: ${x.error}`};d=x.patch,m=x.notes,l=_r(i).filter(T=>Ur(d,T));let v=Jr(i,d,{noun:"atom"});if(v.length){let T=Nr(d,v);return{ok:false,error:Fr(v,"atom",T),violations:v,...T?{suggestedValue:T}:{}}}}return b.setAtomValue(t,y?_t(i,d):d),{ok:true,...a!==void 0?{path:a}:{},...m.length?{keyed:m}:{},...l.length?{unchecked:l.map(x=>`\`${x}\` was empty, so nothing knows what its items look like and the shape of what you added was NOT checked.`)}:{}}}}});export{Sr as JOTAI_ICON_COLOR,It as JotaiAtomChangeItem,Pt as JotaiAtomDetailContent,Rt as JotaiAtomDetailFooter,jt as JotaiAtomValueDetailContent,qe as JotaiIcon,Ye as JotaiModal,xr as JotaiToolView,Ar as createJotaiTool,$r as isAtomWatched,b as jotaiStateStore,qr as jotaiSyncAdapter,Nt as jotaiToolPreset,At as useJotaiAtomChanges,Jt as watchAtoms,Er as watchDefaultStoreAtoms};
|
|
1
|
+
"use client";var ht=Object.defineProperty;var vo=Object.getOwnPropertyDescriptor;var Co=Object.getOwnPropertyNames;var wo=Object.prototype.hasOwnProperty;var xo=(e,t)=>{for(var o in t)ht(e,o,{get:t[o],enumerable:true})},gt=(e,t,o,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Co(t))!wo.call(e,a)&&a!==o&&ht(e,a,{get:()=>t[a],enumerable:!(n=vo(t,a))||n.enumerable});return e},So=(e,t,o)=>(gt(e,t,"default"),o&>(o,t,"default"));var Xr=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{createRestoreScope as To,emptyRestoreResult as Vo,failedRestore as Ao,registerStateSnapshotProvider as Io,unionKeys as Do}from"@buoy-gg/shared-ui/web";import{boundedDeepEqual as ko}from"@buoy-gg/shared-ui/web/dataViewer";import{ChangeLog as Lo,entityColor as Eo,formatValuePreview as $o,shallowDiffSummary as Bo}from"@buoy-gg/shared-ui/web";var Po={count:"#10B981",auth:"#8B5CF6",user:"#3B82F6",cart:"#EC4899",app:"#6366F1",ui:"#F59E0B",settings:"#14B8A6",theme:"#06B6D4",nav:"#F97316",form:"#EF4444",modal:"#A855F7",filter:"#84CC16"};function mt(e){return Eo(e,Po)}function Ro(e,t=40){return $o(e,{maxLength:t,functionLabel:"(fn)"})}var zo=Bo,Ho=class extends Lo{constructor(){super(...arguments);this.atoms=new Map;this.atomListeners=new Set}addAtomChange(e){if(!this.canRecord())return;let{atomLabel:t,prevValue:o,nextValue:n,category:a="write"}=e,r=o!==n,{summary:s,changedKeys:i,changedCount:d}=zo(o,n),m=Ro(n),l={id:this.nextId(),atomLabel:t,timestamp:Date.now(),prevValue:o,nextValue:n,hasValueChange:r,category:a,changedKeys:i,changedKeysCount:d,diffSummary:s,valuePreview:m,isSlowUpdate:false};this.push(l);let y=this.atoms.get(t);y&&y.changeCount++,this.notifyListeners(),this.notifyAtomListeners()}getAtomChanges(){return this.getAll()}getAtomChangeById(e){return this.getById(e)}clearAtomChanges(){for(let e of this.atoms.values())e.changeCount=0;this.clear(),this.notifyAtomListeners()}getAtomSnapshots(){return Array.from(this.atoms.values()).map(e=>{let t;try{t=e.getValue()}catch{t=void 0}return{label:e.label,changeCount:e.changeCount,color:e.color,currentValue:t,writeKind:e.writeKind}})}replaceFromSnapshot(e,t){if(!this.getEnabled())return;let o=new Map;for(let r of this.items){let s=r.prevValue;(!s||s.__buoyValueOnDevice!==true)&&o.set(r.id,r)}let n=e.slice(0,this.max).map(r=>{let s=o.get(r.id),i=r.prevValue;return s&&i?.__buoyValueOnDevice===true?{...r,prevValue:s.prevValue,nextValue:s.nextValue}:r}),a=new Map;for(let[r,s]of this.atoms)try{let i=s.getValue(),d=i;(!d||d.__buoyValueOnDevice!==true)&&a.set(r,i)}catch{}this.atoms=new Map(t.map(r=>{let s=r.currentValue,i=a.get(r.label),d=i!==void 0&&s?.__buoyValueOnDevice===true?i:r.currentValue;return[r.label,{label:r.label,changeCount:r.changeCount,color:r.color,getValue:()=>d,writeKind:r.writeKind}]})),this.setItems(n),this.notifyAtomListeners()}hydrateChange(e,t){this.hydrateById(e,t)}hydrateAtomValue(e,t){let o=this.atoms.get(e);o&&(this.atoms.set(e,{...o,getValue:()=>t}),this.notifyAtomListeners())}registerAtom(e,t,o,n){if(this.atoms.has(e))return;let a={label:e,changeCount:0,color:mt(e),getValue:t,setValue:o,writeKind:n};this.atoms.set(e,a),this.notifyAtomListeners()}setAtomValue(e,t){let o=this.atoms.get(e);if(!o)throw new Error(`Atom "${e}" is not registered`);if(!o.setValue)throw new Error(`Atom "${e}" is read-only (derived) \u2014 cannot set`);o.setValue(t)}unregisterAtom(e){this.atoms.delete(e),this.notifyAtomListeners()}getAtoms(){return Array.from(this.atoms.values())}getAtom(e){return this.atoms.get(e)}getAtomColor(e){return this.atoms.get(e)?.color??mt(e)}filterAtomChanges(e){let t=this.getAll();if(e.searchText){let o=e.searchText.toLowerCase();t=t.filter(n=>n.atomLabel.toLowerCase().includes(o)||n.valuePreview.toLowerCase().includes(o)||n.changedKeys.some(a=>a.toLowerCase().includes(o)))}return e.atomLabels&&e.atomLabels.length>0&&(t=t.filter(o=>e.atomLabels.includes(o.atomLabel))),e.onlyWithChanges&&(t=t.filter(o=>o.hasValueChange)),t}getStats(){let e=this.items.length,t=this.items.filter(o=>o.hasValueChange).length;return{totalChanges:e,changesWithValueChange:t,changesWithoutValueChange:e-t,atomCount:this.atoms.size}}getUniqueAtomLabels(){return Array.from(this.atoms.keys()).sort()}setMaxChanges(e){this.setMax(e)}subscribeToAtoms(e){return this.atomListeners.add(e),()=>this.atomListeners.delete(e)}notifyAtomListeners(){let e=this.getAtoms();this.atomListeners.forEach(t=>t(e))}},b=new Ho;function Oo(){let e=b.getAtoms();if(e.length===0)return{canCapture:false,canRestore:false,detail:"No Jotai atoms registered \u2014 pass your atoms to watchAtoms() / watchDefaultStoreAtoms()"};let t=e.filter(o=>o.setValue).length;return{canCapture:true,canRestore:t>0,detail:t<e.length?`${e.length-t} derived atom(s) recompute automatically and are not restored`:void 0}}async function Wo(){let e=[],t={},o=0;for(let n of b.getAtoms())try{let a=n.getValue();if(typeof a=="function"){e.push(`atom "${n.label}": function value not capturable`);continue}n.setValue||(o+=1),t[n.label]={value:a,writable:!!n.setValue}}catch(a){e.push(`atom "${n.label}": capture failed (${String(a)})`)}return o>0&&e.push(`${o} derived atom(s) captured for inspection only (recompute on restore)`),{data:{atoms:t},warnings:e}}async function jo(e,t){let o=e,n=To(t),a=Vo();if(!o?.atoms)return Ao("empty jotai snapshot");let r=0;for(let[i,d]of Object.entries(o.atoms)){if(!n.allows(i))continue;if(!d.writable){r+=1;continue}let m=b.getAtom(i);if(!m){a.skipped.push({id:i,reason:"atom not registered (renamed, or unwatched since snapshot?)"});continue}if(!m.setValue){a.skipped.push({id:i,reason:"atom is now read-only (derived)"});continue}try{m.setValue(d.value),a.applied+=1}catch(l){a.skipped.push({id:i,reason:String(l)}),a.ok=false}}r>0&&a.warnings.push(`${r} derived atom(s) left to recompute`);let s=n.excludedWarning("atom(s)");return s&&a.warnings.push(s),a}async function Mo(e,t){let o=e?.atoms??{},n=t===void 0,a={};if(n)for(let i of b.getAtoms())try{a[i.label]={value:i.getValue(),writable:!!i.setValue}}catch{}else Object.assign(a,t?.atoms??{});let r=[],s=[];for(let i of Do(a,o)){if(!(i in o)){n?s.push(`atom "${i}" not in snapshot \u2014 untouched`):r.push({key:i,label:i,verdict:"removed",oldValue:a[i]?.value});continue}let d=o[i],m=i in a&&ko(a[i].value,d.value);if(!d.writable){r.push({key:i,label:i,verdict:m?"unchanged":"recomputes",reason:m?void 0:"derived atom \u2014 recomputes from its sources",oldValue:a[i]?.value,newValue:d.value});continue}if(n){let l=b.getAtom(i);if(!l){r.push({key:i,label:i,verdict:"wont-apply",reason:"atom not registered (renamed, or unwatched since snapshot?)"});continue}if(!l.setValue){r.push({key:i,label:i,verdict:"wont-apply",reason:"atom is now read-only (derived)"});continue}}i in a?m?r.push({key:i,label:i,verdict:"unchanged"}):r.push({key:i,label:i,verdict:"changed",oldValue:a[i].value,newValue:d.value}):r.push({key:i,label:i,verdict:"added",newValue:d.value})}return{items:r,notes:s}}Io({id:"jotai",label:"Jotai",status:Oo,capture:Wo,restore:jo,previewItems:Mo});import{useState as _,useMemo as Q,useRef as Ae,useCallback as k,useEffect as ft}from"react";var pt={};xo(pt,{AccessibilityInfo:()=>Jo,ActivityIndicator:()=>Ua,Alert:()=>qa,Animated:()=>ja,AppRegistry:()=>Uo,AppState:()=>Go,Appearance:()=>_o,BackHandler:()=>Yo,Button:()=>Ga,CheckBox:()=>ua,Clipboard:()=>qo,DeviceEventEmitter:()=>Aa,Dimensions:()=>Qo,Easing:()=>Zo,FlatList:()=>ze,I18nManager:()=>Xo,Image:()=>ha,ImageBackground:()=>ga,InteractionManager:()=>ta,Keyboard:()=>ea,KeyboardAvoidingView:()=>ma,LayoutAnimation:()=>oa,Linking:()=>aa,LogBox:()=>Va,Modal:()=>Ja,NativeEventEmitter:()=>na,NativeModules:()=>Ko,PanResponder:()=>ra,Picker:()=>fa,PixelRatio:()=>ia,Platform:()=>la,Pressable:()=>Ka,ProgressBar:()=>pa,RefreshControl:()=>ya,SafeAreaView:()=>ba,ScrollView:()=>fe,SectionList:()=>va,Share:()=>sa,StatusBar:()=>Ca,StyleSheet:()=>ie,Switch:()=>_a,Text:()=>C,TextInput:()=>Ma,Touchable:()=>wa,TouchableHighlight:()=>Fa,TouchableNativeFeedback:()=>xa,TouchableOpacity:()=>le,TouchableWithoutFeedback:()=>Na,UIManager:()=>ca,Vibration:()=>da,View:()=>u,VirtualizedList:()=>Sa,YellowBox:()=>Ta,findNodeHandle:()=>Ya,unstable_createElement:()=>No,useColorScheme:()=>Ia,useLocaleContext:()=>Da,useWindowDimensions:()=>ka});So(pt,Fo);import*as Fo from"react-native-web";import{unstable_createElement as No,NativeModules as Ko,AccessibilityInfo as Jo,Appearance as _o,AppRegistry as Uo,AppState as Go,BackHandler as Yo,Clipboard as qo,Dimensions as Qo,Easing as Zo,I18nManager as Xo,Keyboard as ea,InteractionManager as ta,LayoutAnimation as oa,Linking as aa,NativeEventEmitter as na,PanResponder as ra,PixelRatio as ia,Platform as la,Share as sa,UIManager as ca,Vibration as da,CheckBox as ua,FlatList as ze,Image as ha,ImageBackground as ga,KeyboardAvoidingView as ma,Picker as fa,ProgressBar as pa,RefreshControl as ya,SafeAreaView as ba,SectionList as va,StatusBar as Ca,Touchable as wa,TouchableNativeFeedback as xa,VirtualizedList as Sa,YellowBox as Ta,LogBox as Va,DeviceEventEmitter as Aa,useColorScheme as Ia,useLocaleContext as Da,useWindowDimensions as ka}from"react-native-web";import*as H from"react-native-web";import{createElement as He,forwardRef as yt,useCallback as La,useRef as Ea}from"react";import{useEffect as $a,useState as Ba}from"react";import{createPortal as Pa}from"react-dom";var Ra='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as za}from"react/jsx-runtime";var me=Symbol.for("@buoy-gg/portal-host"),bt=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function vt(){let e=document;if(e[me])return e[me].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:Ra});let o=()=>{let l=document.fullscreenElement,y=l&&l.tagName!=="CANVAS"?l:document.body;t.parentElement!==y&&y.appendChild(t)},n=new Map,a=l=>{(!t.contains(l.target)||!bt(l.target))&&n.set(l.code||l.key,{key:l.key,code:l.code,location:l.location,keyCode:l.keyCode,which:l.which,altKey:l.altKey,ctrlKey:l.ctrlKey,metaKey:l.metaKey,shiftKey:l.shiftKey})},r=l=>{n.delete(l.code||l.key)},s=()=>n.clear(),i=()=>{let l=[...n.values()];n.clear();for(let y of l)document.dispatchEvent(new KeyboardEvent("keyup",{...y,bubbles:true}))},d=l=>{bt(l.target)&&l.stopPropagation()},m=l=>l.stopPropagation();return o(),document.addEventListener("fullscreenchange",o),document.addEventListener("keydown",a,true),document.addEventListener("keyup",r,true),window.addEventListener("blur",s),t.addEventListener("focusin",i),t.addEventListener("keydown",d),t.addEventListener("keyup",d),t.addEventListener("keypress",d),t.addEventListener("wheel",m,{passive:true}),e[me]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",o),document.removeEventListener("keydown",a,true),document.removeEventListener("keyup",r,true),window.removeEventListener("blur",s),t.remove(),delete e[me]}},t}function Ha({children:e}){let[t,o]=Ba(null);return $a(()=>{let n=vt(),a=document[me];return a.users++,o(n),()=>{--a.users===0&&a.dispose()}},[]),t?Pa(za("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var ne=H,Oa=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],re=e=>typeof e=="number"?`${e}px`:e;function Oe(e){if(Array.isArray(e)){let y=e.map(Oe);return y.some((x,v)=>x!==e[v])?y:e}if(!e||typeof e!="object"||!Oa.some(y=>e[y]!=null))return e;let{shadowColor:t,shadowOffset:o,shadowOpacity:n,shadowRadius:a,textShadowColor:r,textShadowOffset:s,textShadowRadius:i,...d}=e;if(t!=null||o!=null||n!=null||a!=null){let y=t??"black",x=n==null?y:`color-mix(in srgb, ${y} ${Math.min(n,1)*100}%, transparent)`,v=`${re(o?.width??0)} ${re(o?.height??0)} ${re(a??0)} ${x}`;d.boxShadow=typeof d.boxShadow=="string"?`${d.boxShadow}, ${v}`:d.boxShadow??v}let{width:m=0,height:l=0}=s??{};if(r&&(m||l||i)){let y=`${re(m)} ${re(l)} ${re(i??0)} ${r}`;d.textShadow=d.textShadow?`${d.textShadow}, ${y}`:y}return d}var Wa=ne.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function Ct(e,t){if(typeof e=="function")return n=>Ct(e(n),t);let o=Oe(e);return t?[o,Wa[t]]:o}var ie={...ne.StyleSheet,create:e=>ne.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,o])=>[t,Oe(o)])))};function M(e){let t=yt((n,a)=>{let{accessibilityState:r,accessibilityValue:s,pointerEvents:i,...d}=n;for(let l of["busy","checked","disabled","expanded","selected"])r?.[l]!==void 0&&d[`aria-${l}`]===void 0&&(d[`aria-${l}`]=r[l]);for(let[l,y]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))s?.[l]!==void 0&&d[`aria-${y}`]===void 0&&(d[`aria-${y}`]=s[l]);let m=Ct(d.style,i);return m!==d.style&&(d.style=m),He(e,{...d,ref:a})}),o=e.State;return o&&Object.assign(t,{State:o}),t.displayName=e.displayName??e.name??"NativeWebView",t}var u=M(H.View),C=M(H.Text),ja={...ne.Animated,View:ne.Animated.createAnimatedComponent(u),Text:ne.Animated.createAnimatedComponent(C)},Ma=M(H.TextInput),le=M(H.TouchableOpacity),Fa=M(H.TouchableHighlight),Na=M(H.TouchableWithoutFeedback),Ka=M(H.Pressable),fe=M(H.ScrollView),wt=yt((e,t)=>{let o=Ea(null),n=La(a=>{if(a){let r=a;for(;r.parentElement&&r.parentElement!==document.body;)r=r.parentElement;r.parentElement===document.body&&(o.current=r,Object.assign(r.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),vt().appendChild(r))}else o.current&&(document.body.appendChild(o.current),o.current=null);typeof t=="function"?t(a):t&&(t.current=a)},[t]);return He(Ha,null,He(H.Modal,{...e,ref:n}))});wt.displayName="Modal";var Ja=M(wt),_a=M(H.Switch),Ua=M(H.ActivityIndicator),Ga=M(H.Button),Ya=H.findNodeHandle,qa={alert(e,t,o,n){if(typeof document>"u")return;let a=document.createElement("dialog");a.dataset.buoyRoot="",a.setAttribute("aria-label",e),a.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let r=document.createElement("h2");if(r.textContent=e,r.style.cssText="font-size:18px;margin:0 0 12px",a.appendChild(r),t){let m=document.createElement("p");m.textContent=t,m.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",a.appendChild(m)}let s=document.createElement("div");s.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let i=o?.length?o:[{text:"OK"}],d=()=>{a.close?.(),a.remove()};for(let m of i){let l=document.createElement("button");l.type="button",l.textContent=m.text??"OK",l.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${m.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,l.onclick=()=>{d(),m.onPress?.()},s.appendChild(l)}a.addEventListener("cancel",m=>{m.preventDefault(),n?.cancelable!==false&&(d(),n?.onDismiss?.())}),a.appendChild(s),document.body.appendChild(a),a.showModal?a.showModal():a.setAttribute("open","")}};import{JsModal as Qa,ModalHeader as L,TabSelector as Za,macOSColors as Xa,night as E,Search as en,Filter as tn,Power as on,ToolEmptyState as We,resolveListEmptyState as xt,devToolsStorageKeys as an,ProUpgradeModal as nn,PowerToggleButton as rn,ToolbarCopyButton as je,ToolbarClearButton as ln,truncatePayload as pe,TickProvider as St,useLimit as sn,windowDragProps as cn,EVENT_LIST_PRESET as Tt}from"@buoy-gg/shared-ui/web";import{useIsPro as dn}from"@buoy-gg/license/web";import{useCallback as un,useMemo as Vt}from"react";import{useChangeLog as hn,useSubscribedValue as gn}from"@buoy-gg/shared-ui/web";function mn(e,t){let o=e;if(t.searchText){let n=t.searchText.toLowerCase();o=o.filter(a=>a.atomLabel.toLowerCase().includes(n)||a.valuePreview.toLowerCase().includes(n)||a.changedKeys.some(r=>r.toLowerCase().includes(n)))}return t.atomLabels&&t.atomLabels.length>0&&(o=o.filter(n=>t.atomLabels.includes(n.atomLabel))),t.onlyWithChanges&&(o=o.filter(n=>n.hasValueChange)),o}var fn=()=>b.getAtoms(),pn=e=>b.subscribeToAtoms(e);function At(){let e=hn(b,{filterItems:mn}),t=gn(fn,pn),o=Vt(()=>{let r=e.items.length,s=e.items.filter(i=>i.hasValueChange).length;return{totalChanges:r,changesWithValueChange:s,changesWithoutValueChange:r-s,atomCount:t.length}},[e.items,t]),n=Vt(()=>b.getUniqueAtomLabels(),[t]),a=un(r=>b.getAtomChangeById(r),[]);return{atomChanges:e.items,filteredChanges:e.filteredItems,filter:e.filter,setFilter:e.setFilter,stats:o,atoms:t,clearChanges:b.clearAtomChanges.bind(b),isEnabled:e.isEnabled,toggleCapture:e.toggleCapture,atomLabels:n,getChangeById:a}}import{memo as yn}from"react";import{ChangeRow as bn,night as vn}from"@buoy-gg/shared-ui/web";import{jsx as Cn}from"react/jsx-runtime";function wn(e,t){return t}function xn(e,t){return e==="initial"?vn.color.textTertiary:b.getAtomColor(t)}function Me(e,t=20){if(e===void 0)return"undefined";if(e===null)return"null";if(typeof e=="boolean"||typeof e=="number")return String(e);if(typeof e=="string")return`"${e.length>t?e.slice(0,t-1)+"\u2026":e}"`;if(Array.isArray(e))return e.length===0?"[]":`[${e.length} item${e.length===1?"":"s"}]`;if(typeof e=="object"){let o=Object.keys(e);return o.length===0?"{}":`{${o.slice(0,2).join(", ")}${o.length>2?"\u2026":""}}`}return String(e).slice(0,t)}function Sn(e){return e.hasValueChange?`${Me(e.prevValue)} \u2192 ${Me(e.nextValue)}`:"no change"}function Tn(e){return e.category==="initial"?"INIT":"WRITE"}function Vn(e){let t=e.nextValue;return typeof t=="object"&&t!==null&&!Array.isArray(t)?e.changedKeys.length>0&&e.changedKeys.length<=3?e.changedKeys.join(", "):e.changedKeys.length>3?`${e.changedKeys.slice(0,2).join(", ")} +${e.changedKeys.length-2}`:e.valuePreview||"atom()":Me(t)}var It=yn(function({change:e,onPress:t,testID:o}){let n=xn(e.category,e.atomLabel),a=wn(e.category,e.atomLabel),r=Sn(e),s=Vn(e),i=Tn(e);return Cn(bn,{statusColor:n,statusLabel:a,sublabel:r,primaryText:s,timestamp:e.timestamp,badgeText:i,changed:e.hasValueChange,onPress:()=>t(e),testID:o})});import{memo as An,useState as Fe,useCallback as ye,useMemo as Dt}from"react";import{buoyColors as be,night as w,EventStepperFooter as kt,formatRelativeTime as Ie,parseValue as De,Info as In,Zap as Lt,FileText as Dn,Database as kn,GitBranch as Ln,copyToClipboard as En,ProUpgradeModal as $n,DiffModeTabs as Bn,CompareBar as Pn,DetailViewToggle as Rn,monoFont as K}from"@buoy-gg/shared-ui/web";import{DataViewer as zn,SplitDiffViewer as Hn,TreeDiffViewer as On,diffThemes as Wn}from"@buoy-gg/shared-ui/web/dataViewer";import{useIsPro as jn}from"@buoy-gg/license/web";var h="buoy-jotai";function ke(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function Mn(e,t){return`${h}-row-${ke(e)}-${t}`}function Et(e){return`${h}-atom-${ke(e)}`}function Fn(e){let t=new Map,o=new Map;for(let n of e){let a=(t.get(n.atomLabel)??0)+1;t.set(n.atomLabel,a),o.set(n.id,Mn(n.atomLabel,a))}return o}import{jsx as g,jsxs as R}from"react/jsx-runtime";var Nn=[{key:"change",label:"CHANGE",icon:Dn},{key:"value",label:"VALUE",icon:kn},{key:"diff",label:"DIFF",icon:Ln}],Kn=["diff"];function Jn(e){switch(e){case"initial":return{label:"INITIAL",color:w.color.textTertiary,bgColor:w.color.textTertiary+"26"};default:return{label:"WRITE",color:be.success,bgColor:be.success+"26"}}}function _n(e){let t=new Date(e),o=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0"),a=t.getSeconds().toString().padStart(2,"0"),r=t.getMilliseconds().toString().padStart(3,"0");return`${o}:${n}:${a}.${r}`}function $t(e){return new Date(e).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function Un(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}function Bt(e){return e==="initial"?"INIT":"WRITE"}var Gn=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}],Yn=An(function({change:e}){let t=jn(),[o,n]=Fe(false),a=Jn(e.category),r=b.getAtomColor(e.atomLabel),s=ye(async()=>{if(!t){n(true);return}await En(e.nextValue)},[e.nextValue,t]);return R(fe,{keyboardShouldPersistTaps:"handled",style:p.container,contentContainerStyle:p.content,showsVerticalScrollIndicator:false,testID:`${h}-detail-scroll`,children:[R(u,{style:p.card,testID:`${h}-info-card`,children:[g(u,{style:p.sectionHeader,children:R(u,{style:p.sectionHeaderLeft,children:[g(In,{size:14,color:w.color.accent}),g(C,{style:p.sectionTitle,children:"CHANGE INFO"})]})}),R(u,{style:p.cardContent,children:[R(u,{style:p.infoRow,children:[g(C,{style:p.infoLabel,children:"Atom"}),g(C,{style:[p.infoValue,p.infoValueMono,{color:r}],numberOfLines:1,ellipsizeMode:"middle",testID:`${h}-info-atom`,children:e.atomLabel})]}),R(u,{style:p.infoRow,children:[g(C,{style:p.infoLabel,children:"Time"}),g(C,{style:[p.infoValue,p.infoValueMono],testID:`${h}-info-time`,children:_n(e.timestamp)})]}),R(u,{style:p.badgeRow,children:[g(u,{style:[p.categoryBadge,{backgroundColor:a.bgColor}],children:g(C,{style:[p.categoryText,{color:a.color}],testID:`${h}-info-category`,children:a.label})}),e.hasValueChange?R(u,{style:p.changesBadge,children:[g(Lt,{size:10,color:be.success}),g(C,{style:p.changesText,testID:`${h}-info-changes`,children:e.diffSummary||"changed"})]}):g(u,{style:p.noChangesBadge,children:g(C,{style:p.noChangesText,testID:`${h}-info-no-changes`,children:"no change"})})]})]})]}),e.changedKeys.length>0&&R(u,{style:p.card,testID:`${h}-keys-card`,children:[R(u,{style:p.sectionHeader,children:[R(u,{style:p.sectionHeaderLeft,children:[g(Lt,{size:14,color:w.color.accent}),g(C,{style:p.sectionTitle,children:"CHANGED KEYS"})]}),g(u,{style:p.countBadge,children:g(C,{style:p.countText,testID:`${h}-keys-count`,children:e.changedKeys.length})})]}),g(u,{style:p.cardContent,children:g(u,{style:p.keysContainer,children:e.changedKeys.map(i=>g(u,{style:p.keyBadge,children:g(C,{style:p.keyText,testID:`${h}-key-${ke(i)}`,children:i})},i))})})]}),g(u,{style:p.actionsRow,children:g(u,{style:[p.actionButton,p.actionButtonCopy],onTouchEnd:s,testID:`${h}-copy-value`,accessibilityRole:"button",accessibilityLabel:"Copy value",children:g(C,{style:[p.actionButtonText,{color:w.color.accent}],children:"COPY VALUE"})})}),g($n,{visible:o,onClose:()=>n(false),featureName:"Copy"})]})});function Pt({change:e,changes:t,selectedIndex:o,onIndexChange:n,disableInternalFooter:a=false,initialView:r="change"}){let[s,i]=Fe(r),[d,m]=Fe("tree"),l=t.length,y=b.getAtomColor(e.atomLabel),x=Bt(e.category),v=Un(De(e.nextValue)),V=l-o,I=o<l-1?o+1:null,W=I!==null?t[I]:null,z=V-1,se=Dt(()=>({index:I??0,label:z>0?`#${z}`:"Initial",timestamp:W?$t(W.timestamp):"",relativeTime:W?Ie(new Date(W.timestamp)):"value",badge:W?g(u,{style:[$.changeBadgeSmall,{backgroundColor:`${b.getAtomColor(W.atomLabel)}20`}],children:g(C,{style:[$.changeTextSmall,{color:b.getAtomColor(W.atomLabel)}],children:Bt(W.category)})}):void 0}),[I,W,z]),Z=Dt(()=>({index:o,label:`#${V}`,timestamp:$t(e.timestamp),relativeTime:Ie(new Date(e.timestamp)),badge:g(u,{style:[$.changeBadgeSmall,{backgroundColor:`${y}20`}],children:g(C,{style:[$.changeTextSmall,{color:y}],children:x})})}),[o,e.timestamp,y,x,V]),Ce=ye(()=>{let Y=De(e.nextValue);return R(u,{style:$.contentCard,testID:`${h}-value-card`,children:[R(u,{style:$.valueHeader,children:[g(C,{style:$.valueLabel,children:"VALUE AFTER CHANGE"}),R(u,{style:$.valueHeaderBadges,children:[g(u,{style:[$.changeBadge,{backgroundColor:`${y}20`}],children:g(C,{style:[$.changeText,{color:y}],children:x})}),g(u,{style:$.typeBadge,children:g(C,{style:$.typeText,testID:`${h}-value-type`,children:v.toUpperCase()})})]})]}),g(u,{style:p.dataViewerContainer,children:g(zn,{title:"",data:Y,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})},[e.nextValue,y,x,v]),ce=ye(()=>{let Y=De(e.prevValue),xe=De(e.nextValue);return d==="split"?g(fe,{keyboardShouldPersistTaps:"handled",style:{flex:1},showsVerticalScrollIndicator:true,children:g(Hn,{oldValue:Y,newValue:xe,theme:Wn.devToolsDefault,options:{hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3},showThemeName:false})}):g(On,{oldValue:Y,newValue:xe})},[e.prevValue,e.nextValue,d]),de=ye(()=>{n(Math.min(l-1,o+1))},[o,l,n]),N=ye(()=>{n(Math.max(0,o-1))},[o,n]),we=e.prevValue===void 0,ue=!a&&l>1;return R(u,{style:$.container,children:[g(Rn,{views:Nn,activeView:s,onViewChange:i,disabledKeys:we?Kn:void 0,testIDPrefix:h}),R(u,{style:[$.contentArea,ue&&$.contentAreaFooterPad],children:[s==="change"&&g(Yn,{change:e}),s==="value"&&g(u,{style:$.stateContainer,children:Ce()}),s==="diff"&&R(u,{style:$.diffContainer,testID:`${h}-diff`,children:[g(Bn,{tabs:Gn,activeTab:d,onTabChange:m,testIDPrefix:`${h}-diff-tab`}),g(Pn,{leftEvent:se,rightEvent:Z}),g(u,{style:$.diffContent,testID:`${h}-diff-content`,children:ce()})]})]}),ue&&g(kt,{currentIndex:V-1,totalItems:l,onPrevious:de,onNext:N,itemLabel:"Change",subtitle:Ie(new Date(e.timestamp)),absolute:true})]})}function Rt({change:e,changes:t,selectedIndex:o,onIndexChange:n}){let a=t.length;if(a<=1)return null;let r=a-o;return g(kt,{currentIndex:r-1,totalItems:a,onPrevious:()=>n(Math.min(a-1,o+1)),onNext:()=>n(Math.max(0,o-1)),itemLabel:"Change",subtitle:Ie(new Date(e.timestamp))})}var $=ie.create({container:{flex:1,backgroundColor:"transparent"},contentArea:{flex:1},contentAreaFooterPad:{paddingBottom:96},stateContainer:{flex:1,padding:14},contentCard:{backgroundColor:w.color.surface,borderRadius:14,padding:14,borderWidth:1,borderColor:w.color.border},valueHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},valueLabel:{fontSize:10,color:w.color.textSecondary,fontFamily:K,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:K,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:w.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:w.color.textTertiary,fontFamily:K},valueBox:{backgroundColor:w.color.bg,borderRadius:6,borderWidth:1,borderColor:w.color.border,padding:8},valueText:{fontSize:12,color:w.color.text,fontFamily:K,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:K}}),p=ie.create({container:{flex:1},content:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:w.color.surface,borderRadius:6,borderWidth:1,borderColor:w.color.accentBorderStrong,overflow:"hidden",shadowColor:w.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:w.color.accentBorder,backgroundColor:w.color.accentSoft},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:w.color.accent,fontFamily:K},cardContent:{padding:14,gap:10},infoRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},infoLabel:{fontSize:11,color:w.color.textTertiary,fontWeight:"500"},infoValue:{fontSize:11,color:w.color.text,fontWeight:"500",flex:1,textAlign:"right",marginLeft:12},infoValueMono:{fontFamily:K},badgeRow:{flexDirection:"row",flexWrap:"wrap",gap:8,marginTop:6},categoryBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4},categoryText:{fontSize:9,fontWeight:"700",letterSpacing:.3},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:be.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:be.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:w.color.surfaceElevated},noChangesText:{fontSize:9,fontWeight:"600",color:w.color.textTertiary},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:w.color.accentSoft,borderWidth:1,borderColor:w.color.accentBorder},keyText:{fontSize:11,fontWeight:"600",color:w.color.accent,fontFamily:K},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:w.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:w.color.accent,fontFamily:K},actionsRow:{flexDirection:"row",gap:12},actionButton:{paddingHorizontal:14,paddingVertical:8,borderRadius:8,borderWidth:1},actionButtonCopy:{borderColor:w.color.accentBorder,backgroundColor:w.color.accentSoft},actionButtonText:{fontSize:10,fontWeight:"700",fontFamily:K,letterSpacing:.3},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});import{useMemo as qn}from"react";import{CompactRow as Qn,night as Ne,ToolEmptyState as zt,resolveListEmptyState as Zn,monoFont as Ht}from"@buoy-gg/shared-ui/web";import{jsx as U,jsxs as Ke}from"react/jsx-runtime";function Xn(e){try{let t=e.getValue();if(t&&typeof t=="object"&&t.__buoyValueOnDevice===true)return"on device";if(t===void 0)return"undefined";if(t===null)return"null";if(Array.isArray(t))return t.length===0?"[]":`[${t.length} item${t.length===1?"":"s"}]`;if(typeof t=="object"){let o=Object.keys(t);return o.length===0?"{}":o.length<=3?o.join(", "):`${o.slice(0,2).join(", ")} +${o.length-2}`}return String(t).slice(0,40)}catch{return""}}function er(e){return e.writeKind==="value"?"primitive":e.writeKind==="action"?"custom write":e.setValue?"writable":"derived"}function tr(){return U(zt,{testID:`${h}-atoms-empty`,otto:"scanning",title:"No atoms registered",message:`Use watchAtoms(store, { atomName }) to register your Jotai atoms.
|
|
2
|
+
They will appear here with their current value.`})}function or({atoms:e,searchQuery:t,onOpenAtom:o}){let n=qn(()=>{if(!t)return e;let a=t.toLowerCase();return e.filter(r=>r.label.toLowerCase().includes(a))},[e,t]);return n.length===0&&!t?U(tr,{}):n.length===0&&t?U(zt,{testID:`${h}-atoms-no-match`,...Zn({subject:"atoms",verb:"registered",search:t,total:e.length,waiting:{otto:"scanning",title:"No atoms registered",message:"Use watchAtoms() to register your Jotai atoms."}})}):Ke(fe,{keyboardShouldPersistTaps:"handled",style:G.container,contentContainerStyle:G.scrollContent,showsVerticalScrollIndicator:true,testID:`${h}-atoms-scroll`,children:[Ke(u,{style:G.sectionHeader,children:[U(C,{style:G.sectionTitle,children:"ATOMS"}),U(u,{style:G.sectionCountBadge,children:U(C,{style:G.sectionCountText,testID:`${h}-atoms-count`,children:n.length})})]}),n.map(a=>{let r=Xn(a),s=b.getAtomColor(a.label),i=Et(a.label);return Ke(u,{style:G.atomRowWrapper,children:[U(Qn,{statusDotColor:s,statusLabel:er(a),primaryText:a.label,secondaryText:r||void 0,showChevron:true,onPress:()=>o(a.label),testID:i,statusTestID:`${i}-kind`,primaryTestID:`${i}-name`,secondaryTestID:`${i}-preview`}),a.changeCount>0&&U(u,{style:[G.absCountBadge,{backgroundColor:s+"22",borderColor:s+"55"}],pointerEvents:"none",children:U(C,{style:[G.absCountText,{color:s}],testID:`${i}-count`,children:String(a.changeCount)})})]},a.label)})]})}var G=ie.create({container:{flex:1},atomRowWrapper:{position:"relative"},absCountBadge:{position:"absolute",top:4,right:10,paddingHorizontal:5,paddingVertical:1,borderRadius:4,borderWidth:1,zIndex:1},absCountText:{fontSize:9,fontWeight:"700",fontFamily:Ht},scrollContent:{paddingTop:8,paddingBottom:20},sectionHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:8,gap:8},sectionTitle:{fontSize:11,fontWeight:"700",letterSpacing:.5,color:Ne.color.textTertiary},sectionCountBadge:{backgroundColor:Ne.color.accentFill,paddingHorizontal:8,paddingVertical:2,borderRadius:4},sectionCountText:{fontSize:10,fontWeight:"700",color:Ne.color.accent,fontFamily:Ht}});import{useCallback as ar,useEffect as nr,useMemo as Je,useState as Ot}from"react";import{buoyColors as _e,ExpandedInfoRow as Ue,FileJson as rr,night as D,PillBadge as Ge,parseValue as Wt,monoFont as ve}from"@buoy-gg/shared-ui/web";import{DataViewer as ir,LiveExplorer as lr,ValueEditModal as sr,updateNestedDataByPath as cr,deleteNestedDataByPath as dr}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as ur,jsx as T,jsxs as F}from"react/jsx-runtime";var hr=300,te=`${h}-atom-detail`;function gr(e){let t=o=>o.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return e.length===0?`${te}-explorer-root`:`${te}-explorer-${e.map(t).filter(Boolean).join("-")}`}function mr(e,t){if(!e.setValue)return"Derived atom \u2014 its value recomputes from other atoms and has no setter. Edit the atoms it reads from instead.";if(typeof t=="function")return"This atom holds a function \u2014 nothing here to edit as data.";if(t&&typeof t=="object"&&t.__buoyValueOnDevice===true)return"The value stayed on the device (too large for the wire) \u2014 open the tool on-device to edit it.";if(t&&typeof t=="object"){let o=Object.getPrototypeOf(t);if(!(o===Object.prototype||o===null||Array.isArray(t)||t instanceof Map||t instanceof Set))return`This atom holds a ${t.constructor?.name??"class"} instance \u2014 rebuilding it from edited fields would drop its prototype. Edit via app code.`}return null}function fr(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`array \xB7 ${e.length}`:typeof e}function jt({atom:e,onViewHistory:t}){let o=Et(e.label),[n,a]=Ot(0);nr(()=>{let v=()=>a(W=>W+1),V=b.subscribe(v),I=b.subscribeToAtoms(v);return()=>{V(),I()}},[]);let r=Je(()=>{try{return e.getValue()}catch{return}},[e,n]),s=mr(e,r),[i,d]=Ot(false),m=Je(()=>{if(s===null)return{update:(v,V)=>{let I=e.getValue();e.setValue?.(v.length===0?V:cr(I,v,V))},remove:v=>{if(v.length===0)return;let V=e.getValue();e.setValue?.(dr(V,v))},canRemove:v=>v.length>0}},[e,s]),l=Je(()=>{if(r&&typeof r=="object"){let v={};for(let[V,I]of Object.entries(r))typeof I!="function"&&(v[V]=I);return Wt(v)}return Wt(r)},[r,n]),y=ar(v=>{e.setValue?.(v),d(false)},[e]),x=e.setValue===void 0?{color:D.color.textTertiary,label:"READ-ONLY (DERIVED)"}:e.writeKind==="action"?{color:_e.warning,label:"CUSTOM WRITE"}:{color:_e.success,label:"PRIMITIVE"};return F(u,{style:S.root,children:[F(fe,{testID:`${te}-scroll`,style:S.scroll,contentContainerStyle:S.scrollContent,keyboardShouldPersistTaps:"handled",children:[T(u,{style:S.section,children:F(u,{style:S.editorContainer,children:[F(u,{style:S.sectionHeaderRow,children:[T(C,{testID:`${te}-editor-header`,style:S.sectionHeaderText,children:"Value Editor"}),s===null?F(le,{onPress:()=>d(true),testID:`${te}-raw`,accessibilityRole:"button",accessibilityLabel:"Edit raw JSON",style:S.rawButton,hitSlop:{top:6,bottom:6,left:6,right:6},children:[T(rr,{size:13,color:D.color.accent}),T(C,{style:S.rawButtonText,children:"Raw"})]}):null]}),T(u,{style:S.sectionBody,children:s===null?F(ur,{children:[T(lr,{editable:true,label:e.label,value:r,defaultExpanded:[e.label],writer:m,dataVersion:n,testIDForPath:gr,debounceMs:hr}),T(C,{style:S.editorHint,children:e.writeKind==="action"?"This atom has a custom write \u2014 the edited value is handed to it as its argument (a set for atomWithStorage, an ACTION for a reducer atom).":"Edits write into the live atom as you make them \u2014 the whole value is replaced, jotai's own semantics."})]}):T(C,{style:S.blockedText,testID:`${te}-edit-blocked`,children:s})})]})}),T(u,{style:S.section,children:F(u,{style:S.infoContainer,children:[T(C,{style:S.sectionHeaderTextPlain,children:"Atom Details"}),F(u,{style:S.infoBody,children:[F(Ue,{label:"Type",children:[T(Ge,{color:e.color,testID:`${o}-type`,children:"JOTAI"}),T(C,{style:S.valueTypeText,testID:`${o}-valuetype`,children:fr(r)})]}),T(Ue,{label:"Write",children:T(Ge,{color:x.color,testID:`${te}-write`,children:x.label})}),e.changeCount>0&&F(Ue,{label:"Changes",children:[T(Ge,{color:_e.warning,testID:`${o}-changes`,children:String(e.changeCount)}),T(le,{onPress:()=>t(e.label),style:S.inlineLinkButton,hitSlop:{top:6,bottom:6,left:6,right:6},testID:`${o}-history`,accessibilityRole:"button",accessibilityLabel:`View ${e.label} history`,children:T(C,{style:[S.inlineLinkText,{color:e.color}],children:"view history \u2192"})})]})]})]})}),T(u,{style:S.section,children:F(u,{style:S.infoContainer,children:[T(C,{style:S.sectionHeaderTextPlain,children:"Value Explorer"}),T(u,{style:S.viewerBody,testID:`${o}-value`,children:l&&typeof l=="object"?T(ir,{title:"",data:l,showTypeFilter:true,rawMode:true,initialExpanded:false}):T(C,{style:S.primitiveText,testID:`${o}-primitive`,children:String(r??"undefined")})})]})})]}),i&&s===null?T(sr,{path:[],value:r,onSave:y,onCancel:()=>d(false),saveLabel:"Apply",testIDPrefix:`${h}-value`}):null]})}var S=ie.create({root:{flex:1,minHeight:0},scroll:{flex:1},scrollContent:{paddingHorizontal:8,paddingTop:8,paddingBottom:24},section:{marginBottom:16},editorContainer:{minWidth:200,backgroundColor:D.color.surface,borderRadius:6,borderWidth:1,borderColor:D.color.accent+"4D",overflow:"hidden",shadowColor:D.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeaderRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:D.color.accent+"1A",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:D.color.accent+"33"},sectionHeaderText:{fontWeight:"600",fontSize:12,color:D.color.accent,letterSpacing:.5,textTransform:"uppercase",fontFamily:ve},rawButton:{flexDirection:"row",alignItems:"center",gap:4},rawButtonText:{color:D.color.accent,fontSize:11,fontWeight:"700"},sectionBody:{padding:8},editorHint:{color:D.color.textTertiary,fontSize:10,paddingTop:8,paddingHorizontal:4,lineHeight:14},blockedText:{color:D.color.textSecondary,fontSize:12,padding:12,lineHeight:18},infoContainer:{minWidth:200,backgroundColor:D.color.surface,borderRadius:6,borderWidth:1,borderColor:D.color.border,overflow:"hidden"},sectionHeaderTextPlain:{backgroundColor:D.color.surfaceElevated,paddingHorizontal:12,paddingVertical:8,fontWeight:"600",fontSize:12,color:D.color.textSecondary,borderBottomWidth:1,borderBottomColor:D.color.border,letterSpacing:.5,textTransform:"uppercase",fontFamily:ve},infoBody:{padding:12,gap:10},viewerBody:{backgroundColor:D.color.bg,minHeight:60},primitiveText:{color:D.color.text,fontSize:12,fontFamily:ve,padding:14},valueTypeText:{color:D.color.textTertiary,fontSize:10,fontFamily:ve,marginLeft:6},inlineLinkButton:{marginLeft:4},inlineLinkText:{fontSize:10,fontWeight:"600",fontFamily:ve}});import{useMemo as pr}from"react";import{EntityFilterView as yr}from"@buoy-gg/shared-ui/web";import{jsx as br}from"react/jsx-runtime";var vr=["\u2022 count -> hides countAtom from atoms & events","\u2022 auth -> hides authAtom, authStatusAtom","\u2022 user -> hides userAtom from both tabs"];function Cr({ignoredPatterns:e,onTogglePattern:t,onAddPattern:o,atoms:n}){let a=pr(()=>n.map(r=>({name:r.label,color:r.color})),[n]);return br(yr,{entities:a,ignoredPatterns:e,onTogglePattern:t,onAddPattern:o,entityNoun:"ATOMS",entitySingular:"atom",entityKey:"atom",testIDPrefix:h,slug:ke,howItWorks:"Patterns hide matching atoms from both the Atoms tab and the Events tab. Tap an atom above to quickly add it as a filter.",examples:vr,emptyMessage:"No atoms are being watched yet."})}import{Fragment as Mt,jsx as f,jsxs as O}from"react/jsx-runtime";function wr({isEnabled:e,searchText:t,totalChanges:o}){let n=xt({subject:"changes",search:t,total:o,capturing:e,waiting:{otto:"waiting",title:"No atom changes",message:"Atom changes will appear here as values update."},paused:{title:"No atom changes",message:"Enable capture to start recording atom changes"}});return f(We,{...n,testID:`${h}-empty`})}function Ye({visible:e,onClose:t,onBack:o,onMinimize:n,enableSharedModalDimensions:a=false,inline:r=false,initialTab:s,initialSelectedChangeId:i,initialDetailView:d,onChangeSelect:m,onAtomExpand:l}){let y=dn(),x=sn("jotai.changes"),[v,V]=_(false),[I,W]=_(s??"atoms"),[z,se]=_(null),[Z,Ce]=_(null),[ce,de]=_(false),[N,we]=_(new Set),{atomChanges:ue,filteredChanges:Y,stats:xe,filter:Qr,setFilter:he,atoms:ge,clearChanges:Ut,isEnabled:Se,toggleCapture:Gt}=At(),J=Q(()=>N.size===0?Y:Y.filter(c=>!Array.from(N).some(A=>c.atomLabel.toLowerCase().includes(A.toLowerCase()))),[Y,N]),oe=Q(()=>N.size===0?ge:ge.filter(c=>!Array.from(N).some(A=>c.label.toLowerCase().includes(A.toLowerCase()))),[ge,N]),Yt=Q(()=>z?ue.filter(c=>c.atomLabel===z).length:0,[ue,z]),Te=Q(()=>z?J.filter(c=>c.atomLabel===z):J,[J,z]),$e=Q(()=>Te.slice(0,x),[Te,x]),Be=Q(()=>Math.max(0,Te.length-x),[Te.length,x]),qt=Be>0,P=$e,[Pe,X]=_(null),ee=Q(()=>{if(Pe===null)return null;let c=P.findIndex(A=>A.id===Pe);return c>=0?c:null},[Pe,P]),j=ee!==null?P[ee]:null,et=Ae(null);ft(()=>{if(!m)return;let c=j?.id??null;c===null||c===et.current||(et.current=c,m(j))},[j,m]);let tt=Ae(null);ft(()=>{!i||tt.current===i||!P.some(c=>c.id===i)||(tt.current=i,X(i))},[i,P]);let[q,Re]=_(""),[Qt,Ve]=_(false),Zr=Ae(null),Zt=Ae(null),Xt=k(c=>{},[]),eo=c=>{Re(c),I==="events"&&he(A=>({...A,searchText:c}))},to=k(()=>{Re(""),he(c=>({...c,searchText:""})),Ve(false)},[he]),ot=k(c=>{X(c.id)},[]),oo=k(()=>{V(true)},[]),ao=k(()=>{X(null)},[]),at=k(c=>{let A=P[c];A&&X(A.id)},[P]),no=k(c=>{se(c),X(null)},[]),ro=k(()=>{se(null),X(null)},[]),io=k(c=>{Ce(c),l?.(c)},[l]),lo=k(()=>{Ce(null)},[]),so=k(()=>oe.reduce((c,A)=>{try{let ae=A.getValue();c[A.label]=pe(ae)}catch{c[A.label]=null}return c},{}),[oe]),co=k(()=>J.map(c=>({id:c.id,atomLabel:c.atomLabel,timestamp:c.timestamp,prevValue:pe(c.prevValue),nextValue:pe(c.nextValue),hasValueChange:c.hasValueChange,changedKeys:c.changedKeys})),[J]),uo=k(()=>P.map(c=>({id:c.id,atomLabel:c.atomLabel,timestamp:c.timestamp,prevValue:pe(c.prevValue),nextValue:pe(c.nextValue),hasValueChange:c.hasValueChange,changedKeys:c.changedKeys})),[P]),ho=k(c=>{we(A=>{let ae=new Set(A);return ae.has(c)?ae.delete(c):ae.add(c),ae})},[]),go=k(c=>{we(A=>new Set([...A,c]))},[]),mo=k(c=>{W(c),se(null),X(null),de(false),q&&(Re(""),he(A=>({...A,searchText:""}))),Ve(false)},[q,he]),nt=k(c=>c.id,[]),rt=Q(()=>Fn(P),[P]),it=k(({item:c})=>f(It,{change:c,onPress:ot,testID:rt.get(c.id)}),[ot,rt]),lt=N.size>0,st=()=>ce?O(L,{children:[f(L.Navigation,{onBack:()=>de(false)}),f(L.Content,{title:"Filters",centered:true,testID:`${h}-filters-title`})]}):j?O(L,{children:[f(L.Navigation,{onBack:ao}),f(L.Content,{title:`${j.atomLabel}/${j.category}`,centered:true,testID:`${h}-detail-title`})]}):z?O(L,{children:[f(L.Navigation,{onBack:ro}),f(L.Content,{title:`${z} History`,centered:true,testID:`${h}-history-title`}),f(L.Actions,{children:f(je,{value:uo,disabled:P.length===0,buttonStyle:B.headerActionButton,testID:`${h}-copy`})})]}):Z?O(L,{children:[f(L.Navigation,{onBack:lo}),f(L.Content,{title:Z,centered:true,testID:`${h}-atom-detail-title`})]}):O(L,{children:[o&&f(L.Navigation,{onBack:o}),f(L.Content,{title:"",children:Qt?f(L.Search,{value:q,onChangeText:eo,onCancel:to,placeholder:I==="atoms"?"Search atoms...":"Search events...",accessibilityLabel:"Search Jotai atoms and events",iconSize:14,testID:`${h}-search-field`,containerTestID:`${h}-search`,clearTestID:`${h}-search-clear`,onBlur:()=>{q.length===0&&Ve(false)}}):f(Za,{tabs:[{key:"atoms",label:`Atoms${oe.length>0?` (${oe.length})`:""}`},{key:"events",label:`Events${J.length>0?` (${J.length})`:""}`}],activeTab:I,onTabChange:mo,testIDPrefix:`${h}-tab`})}),O(L.Actions,{children:[f(le,{onPress:()=>Ve(true),style:B.headerActionButton,testID:`${h}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:f(en,{size:14,color:E.color.textSecondary})}),f(le,{onPress:()=>de(true),style:[B.headerActionButton,lt&&B.headerActionButtonActive],testID:`${h}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:f(tn,{size:14,color:lt?E.color.accent:E.color.textSecondary})}),I==="atoms"&&f(je,{value:so,disabled:oe.length===0,buttonStyle:B.headerActionButton,testID:`${h}-copy`}),I==="events"&&O(Mt,{children:[f(je,{value:co,disabled:J.length===0,buttonStyle:B.headerActionButton,testID:`${h}-copy`}),f(rn,{isEnabled:Se,onToggle:Gt,accessibilityLabel:"Toggle Jotai atom capture",testID:`${h}-power`}),f(ln,{onPress:Ut,disabled:J.length===0,buttonStyle:B.headerActionButton,testID:`${h}-clear`})]})]})]}),fo=()=>{if(ce)return f(Cr,{ignoredPatterns:N,onTogglePattern:ho,onAddPattern:go,atoms:ge});if(j&&ee!==null)return f(Pt,{change:j,changes:P,selectedIndex:ee,onIndexChange:at,disableInternalFooter:true,initialView:d});if(z)return P.length>0?f(ze,{keyboardShouldPersistTaps:"handled",testID:`${h}-history-list`,data:P,renderItem:it,keyExtractor:nt,contentContainerStyle:B.listContent,showsVerticalScrollIndicator:true,...Tt}):f(We,{testID:`${h}-history-empty`,...xt({subject:"changes",search:q,total:q.trim()?Yt:0,capturing:Se,waiting:{otto:"waiting",title:"No history yet",message:`Changes for ${z} will appear here.`},paused:{title:"No history yet",message:`Capture is off, so nothing is being recorded for ${z}.`}})});if(Z){let c=ge.find(A=>A.label===Z)??null;return c?f(jt,{atom:c,onViewHistory:no}):f(We,{testID:`${h}-atom-detail-gone`,otto:"ghost",title:"Atom no longer registered",message:`${Z} is not in the registry any more.`})}return I==="atoms"?f(or,{atoms:oe,searchQuery:q,onOpenAtom:io}):O(Mt,{children:[!Se&&O(u,{style:B.disabledBanner,testID:`${h}-banner-disabled`,children:[f(on,{size:14,color:E.color.warning}),f(C,{style:B.disabledText,children:"Atom capture is disabled"})]}),qt&&O(le,{style:B.lockedBanner,onPress:oo,activeOpacity:.8,testID:`${h}-locked`,accessibilityRole:"button",children:[O(C,{style:B.lockedText,testID:`${h}-locked-text`,children:[Be," older"," ",Be===1?"change":"changes"," locked"]}),f(u,{style:B.upgradeBadge,children:f(C,{style:B.upgradeBadgeText,children:"UPGRADE"})})]}),$e.length>0?f(ze,{keyboardShouldPersistTaps:"handled",ref:Zt,testID:`${h}-list`,data:$e,renderItem:it,keyExtractor:nt,contentContainerStyle:B.listContent,showsVerticalScrollIndicator:true,...Tt}):f(wr,{isEnabled:Se,searchText:q,totalChanges:xe.totalChanges})]})},po=a?an.modal.root():"buoy-jotai-modal";if(!e)return null;let ct=j&&ee!==null?f(Rt,{change:j,changes:P,selectedIndex:ee,onIndexChange:at}):null,yo=j&&P.length>1?68:0,bo=!ce&&!(j&&ee!==null)&&(z!=null||I==="events"||I==="atoms"),dt=f(u,{style:B.container,children:fo()}),ut=f(nn,{visible:v,onClose:()=>V(false),featureName:"Full Atom History"});return r?O(St,{children:[O(u,{style:B.inlineRoot,children:[f(u,{style:B.inlineHeader,...cn,children:st()}),dt,ct]}),ut]}):O(St,{children:[f(Qa,{visible:e,onClose:t,onMinimize:n,persistenceKey:po,header:{showToggleButton:true,customContent:st()},onModeChange:Xt,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:bo,styles:{},footer:ct,footerHeight:yo,children:dt}),ut]})}function xr(e={}){return f(Ye,{...e,inline:true,visible:true,onClose:()=>{}})}var B=ie.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:Xa.border.default,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:E.color.buttonSurface,borderWidth:1,borderColor:E.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonActive:{backgroundColor:E.color.accentSoft,borderColor:E.color.accentBorderStrong},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:E.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:E.color.warning+"20"},disabledText:{color:E.color.warning,fontSize:11,flex:1},listContent:{paddingTop:8,paddingBottom:20},emptyState:{alignItems:"center",paddingVertical:40},emptyTitle:{color:E.color.text,fontSize:14,fontWeight:"600",marginTop:12,marginBottom:6},emptyText:{color:E.color.textTertiary,fontSize:12,textAlign:"center",lineHeight:18},lockedBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:E.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:E.color.accentBorder},lockedText:{color:E.color.accent,fontSize:11,fontWeight:"500",flex:1},upgradeBadge:{backgroundColor:E.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},upgradeBadgeText:{color:E.color.onAccent,fontSize:9,fontWeight:"700",letterSpacing:.5}});import{JotaiIcon as qe,JOTAI_ICON_COLOR as Sr}from"@buoy-gg/shared-ui/web";import{createToolFactory as Tr,defineToolPreset as Vr}from"@buoy-gg/shared-ui/web";import{jsx as Ft}from"react/jsx-runtime";var Nt=Vr({id:"jotai",name:"JOTAI",description:"Jotai atom & state inspector",slot:"both",icon:({size:e})=>Ft(qe,{size:e}),component:Ye,props:{enableSharedModalDimensions:false}}),Ar=Tr(Nt,e=>({enableSharedModalDimensions:e.enableSharedModalDimensions??false}),e=>({icon:({size:t})=>Ft(qe,{size:t,color:e.iconColor})}));import{getDefaultStore as Ir}from"jotai/vanilla";import{atom as Dr}from"jotai/vanilla";var kr=Dr(null),Qe=kr.write,Kt=typeof Qe=="function"?String(Qe):null;function Lr(e){let t=e,o=t?.write;return typeof o!="function"?"action":o===Qe||t!==null&&"init"in t&&Kt!==null&&String(o)===Kt?"value":"action"}function Jt(e,t,o){let n=o?.enabled!==false,a=[];for(let[r,s]of Object.entries(t)){let i=s,d=Symbol.for(`@@buoy-jotai/watched/${r}`);if(i[d])continue;i[d]=true;let m;try{m=e.get(s)}catch{m=void 0}let l=typeof s.write=="function",y=e.set&&l?v=>{e.set(s,v)}:void 0;b.registerAtom(r,()=>{try{return e.get(s)}catch{return}},y,l?Lr(s):void 0),n&&b.addAtomChange({atomLabel:r,prevValue:void 0,nextValue:m,category:"initial"});let x=e.sub(s,()=>{try{let v=e.get(s);b.addAtomChange({atomLabel:r,prevValue:m,nextValue:v,category:"write"}),m=v}catch{}});a.push(()=>{x(),delete i[d],b.unregisterAtom(r)})}return()=>a.forEach(r=>r())}function Er(e,t){let o=Ir();return Jt(o,e,t)}function $r(e){return b.getAtom(e)!==void 0}import{WIRE_DETAIL_LIMIT_BYTES as Br,createSyncAdapter as Pr,capDetail as Rr,detailByIdAction as zr,expandKeyedArrays as Hr,memoByIdentity as Or,onDeviceMarker as Wr,patchFromPath as jr,readParams as Ze,readPath as Mr,refusalText as Fr,shapeSummary as Le,suggestedPatch as Nr,toWire as Kr,typedEditViolations as Jr,unshapedLists as _r}from"@buoy-gg/shared-ui/web";var Ee=Wr("Value","Atom values stay on the device \u2014 fetched on demand via getChangeDetail / getAtomValue."),Xe=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function _t(e,t){if(!Xe(e)||!Xe(t))return t;let o={...e};for(let[n,a]of Object.entries(t))o[n]=n in e?_t(e[n],a):a;return o}function Ur(e,t){let o=e;for(let n of t.split(".")){if(!Xe(o)||!(n in o))return false;o=o[n]}return Array.isArray(o)?o.length>0:!!o&&typeof o=="object"}var Gr=Or(e=>({...e,prevValue:Ee,nextValue:Ee})),Yr=e=>Kr(e,Ee),qr=Pr({version:2,getSnapshot:()=>({changes:b.getAtomChanges().map(Gr),atoms:b.getAtomSnapshots().map(e=>({...e,currentValue:Yr(e.currentValue)}))}),subscribe:[e=>b.subscribe(e),e=>b.subscribeToAtoms(e)],actions:{clearEvents:()=>{b.clearAtomChanges()},getChangeDetail:zr(e=>b.getAtomChangeById(e),(e,t)=>({prevValue:t(e.prevValue),nextValue:t(e.nextValue)})),getAtomValue:e=>{let{label:t,path:o}=Ze(e);if(!t)return{found:false,reason:"missing label"};let n=b.getAtom(t);if(!n)return{found:false,reason:"unknown label"};let a;try{a=n.getValue()}catch{a=void 0}try{JSON.stringify(a)}catch{return{found:true,label:t,currentValue:Ee}}if(o){let r=Mr(a,o);return r.ok?{found:true,label:t,path:o,shape:Le(r.value),currentValue:r.value}:{found:false,reason:r.error}}return{found:true,label:t,...Le(a)?{shape:Le(a)}:{},currentValue:Rr(a,Br)}},listAtoms:e=>{let{includeValues:t=false,limit:o}=Ze(e),n=b.getAtoms(),a=(typeof o=="number"&&o>0?n.slice(0,o):n).map(r=>{let s;if(t)try{s=r.getValue()}catch{s=void 0}let i;try{i=Le(r.getValue())}catch{i=void 0}return{label:r.label,changes:r.changeCount,writable:typeof r.setValue=="function",...i?{shape:i}:{},...t?{currentValue:s}:{}}});return{atoms:a,total:n.length,returned:a.length,includedValues:t}},setAtom:e=>{let{label:t,value:o,merge:n,path:a,force:r}=Ze(e);if(!t)throw new Error("setAtom requires a `label`");let s=b.getAtom(t),i;try{i=s?.getValue()}catch{i=void 0}let d=o,m=[],l=[],y=n===true||a!==void 0;if(a!==void 0){if(o===void 0)return{ok:false,error:`Refused: sent \`path\` without \`value\`. Say what to set "${a}" to.`};let x=jr(i,a,o);if(!x.ok)return{ok:false,error:`Refused: ${x.error}`};d=x.patch}if(!r&&y&&i!==void 0){let x=Hr(i,d);if(x.error)return{ok:false,error:`Refused: ${x.error}`};d=x.patch,m=x.notes,l=_r(i).filter(V=>Ur(d,V));let v=Jr(i,d,{noun:"atom"});if(v.length){let V=Nr(d,v);return{ok:false,error:Fr(v,"atom",V),violations:v,...V?{suggestedValue:V}:{}}}}return b.setAtomValue(t,y?_t(i,d):d),{ok:true,...a!==void 0?{path:a}:{},...m.length?{keyed:m}:{},...l.length?{unchecked:l.map(x=>`\`${x}\` was empty, so nothing knows what its items look like and the shape of what you added was NOT checked.`)}:{}}}}});export{Sr as JOTAI_ICON_COLOR,It as JotaiAtomChangeItem,Pt as JotaiAtomDetailContent,Rt as JotaiAtomDetailFooter,jt as JotaiAtomValueDetailContent,qe as JotaiIcon,Ye as JotaiModal,xr as JotaiToolView,Ar as createJotaiTool,$r as isAtomWatched,b as jotaiStateStore,qr as jotaiSyncAdapter,Nt as jotaiToolPreset,At as useJotaiAtomChanges,Jt as watchAtoms,Er as watchDefaultStoreAtoms};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/jotai",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.78",
|
|
4
4
|
"description": "Inspect registered Jotai atoms, observed writes, retained history and current values in a React Native app.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"./lib/web/**/*.mjs"
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@buoy-gg/shared-ui": "^7.0.
|
|
42
|
-
"@buoy-gg/license": "^7.0.
|
|
41
|
+
"@buoy-gg/shared-ui": "^7.0.78",
|
|
42
|
+
"@buoy-gg/license": "^7.0.78"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"jotai": ">=2.0.0",
|