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