@buoy-gg/jotai 7.0.40 → 7.0.41

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/README.md CHANGED
@@ -90,3 +90,7 @@ Use a Free or Pro Buoy account. History limits and paid features vary by tool; s
90
90
  📚 [Full docs](https://buoy.gg/buoy/latest/docs/tools/jotai) · [All Buoy tools](https://github.com/Buoy-gg/buoy)
91
91
 
92
92
  Proprietary software. © Buoy LLC. [Terms](https://buoy.gg/terms)
93
+
94
+ ## Web support (unreleased)
95
+
96
+ Register the app’s atoms and store with watchAtoms. The shared panel and snapshot provider use those registrations. The browser build is available in this checkout and has not been published yet. See the [web setup guide](https://buoy.gg/buoy/latest/docs/web-preview) for registration, dependencies, and browser boundaries.
@@ -14,9 +14,14 @@ var _jsxRuntime = require("react/jsx-runtime");
14
14
  * Mirrors ZustandStateChangeItem.tsx — uses shared CompactRow for consistent styling
15
15
  */
16
16
 
17
- function getStatusLabel(category, atomLabel) {
18
- if (category === "initial") return "Initial";
19
- return atomLabel.charAt(0).toUpperCase() + atomLabel.slice(1);
17
+ /**
18
+ * The atom's name, exactly as registered. INIT rows used to read "Initial",
19
+ * so five registrations were five identical rows, and the name was
20
+ * capitalized ("VisibleCountAtom") into something the code doesn't contain.
21
+ * The INIT badge already says what kind of event it is.
22
+ */
23
+ function getStatusLabel(_category, atomLabel) {
24
+ return atomLabel;
20
25
  }
21
26
  function getCategoryColor(category, atomLabel) {
22
27
  if (category === "initial") return _sharedUi.night.color.textTertiary;
@@ -50,6 +55,11 @@ function getBadgeText(change) {
50
55
  return "WRITE";
51
56
  }
52
57
  function getPrimaryText(change) {
58
+ // Changed keys only mean something for a plain object. For an array they
59
+ // are indices ("15, 16 +18"), so show the new value instead.
60
+ const next = change.nextValue;
61
+ const isPlainObject = typeof next === "object" && next !== null && !Array.isArray(next);
62
+ if (!isPlainObject) return formatCompact(next);
53
63
  if (change.changedKeys.length > 0 && change.changedKeys.length <= 3) {
54
64
  return change.changedKeys.join(", ");
55
65
  }
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.isAtomWatched = isAtomWatched;
7
7
  exports.watchAtoms = watchAtoms;
8
8
  exports.watchDefaultStoreAtoms = watchDefaultStoreAtoms;
9
+ var _vanilla = require("jotai/vanilla");
9
10
  var _jotaiStateStore = require("./jotaiStateStore");
10
11
  var _writeSemantics = require("./writeSemantics");
11
12
  /**
@@ -130,27 +131,7 @@ function watchAtoms(store, atoms, options) {
130
131
  * ```
131
132
  */
132
133
  function watchDefaultStoreAtoms(atoms, options) {
133
- // Dynamic import to avoid bundling jotai internals when not needed
134
- let store;
135
- try {
136
- // eslint-disable-next-line @typescript-eslint/no-var-requires
137
- const {
138
- getDefaultStore
139
- } = require("jotai/vanilla");
140
- store = getDefaultStore();
141
- } catch {
142
- // Try the main jotai entry (React Native)
143
- try {
144
- // eslint-disable-next-line @typescript-eslint/no-var-requires
145
- const {
146
- getDefaultStore
147
- } = require("jotai");
148
- store = getDefaultStore();
149
- } catch {
150
- console.warn("[@buoy-gg/jotai] Could not find getDefaultStore from jotai. " + "Pass the store explicitly via watchAtoms(store, atoms) instead.");
151
- return () => {};
152
- }
153
- }
134
+ const store = (0, _vanilla.getDefaultStore)();
154
135
  return watchAtoms(store, atoms, options);
155
136
  }
156
137
 
@@ -10,9 +10,14 @@ import { memo } from "react";
10
10
  import { ChangeRow, night } from "@buoy-gg/shared-ui";
11
11
  import { jotaiStateStore } from "../utils/jotaiStateStore";
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- function getStatusLabel(category, atomLabel) {
14
- if (category === "initial") return "Initial";
15
- return atomLabel.charAt(0).toUpperCase() + atomLabel.slice(1);
13
+ /**
14
+ * The atom's name, exactly as registered. INIT rows used to read "Initial",
15
+ * so five registrations were five identical rows, and the name was
16
+ * capitalized ("VisibleCountAtom") into something the code doesn't contain.
17
+ * The INIT badge already says what kind of event it is.
18
+ */
19
+ function getStatusLabel(_category, atomLabel) {
20
+ return atomLabel;
16
21
  }
17
22
  function getCategoryColor(category, atomLabel) {
18
23
  if (category === "initial") return night.color.textTertiary;
@@ -46,6 +51,11 @@ function getBadgeText(change) {
46
51
  return "WRITE";
47
52
  }
48
53
  function getPrimaryText(change) {
54
+ // Changed keys only mean something for a plain object. For an array they
55
+ // are indices ("15, 16 +18"), so show the new value instead.
56
+ const next = change.nextValue;
57
+ const isPlainObject = typeof next === "object" && next !== null && !Array.isArray(next);
58
+ if (!isPlainObject) return formatCompact(next);
49
59
  if (change.changedKeys.length > 0 && change.changedKeys.length <= 3) {
50
60
  return change.changedKeys.join(", ");
51
61
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ import { getDefaultStore } from 'jotai/vanilla';
3
4
  /**
4
5
  * Buoy Jotai DevTools — Atom instrumentation
5
6
  *
@@ -125,27 +126,7 @@ export function watchAtoms(store, atoms, options) {
125
126
  * ```
126
127
  */
127
128
  export function watchDefaultStoreAtoms(atoms, options) {
128
- // Dynamic import to avoid bundling jotai internals when not needed
129
- let store;
130
- try {
131
- // eslint-disable-next-line @typescript-eslint/no-var-requires
132
- const {
133
- getDefaultStore
134
- } = require("jotai/vanilla");
135
- store = getDefaultStore();
136
- } catch {
137
- // Try the main jotai entry (React Native)
138
- try {
139
- // eslint-disable-next-line @typescript-eslint/no-var-requires
140
- const {
141
- getDefaultStore
142
- } = require("jotai");
143
- store = getDefaultStore();
144
- } catch {
145
- console.warn("[@buoy-gg/jotai] Could not find getDefaultStore from jotai. " + "Pass the store explicitly via watchAtoms(store, atoms) instead.");
146
- return () => {};
147
- }
148
- }
129
+ const store = getDefaultStore();
149
130
  return watchAtoms(store, atoms, options);
150
131
  }
151
132
 
@@ -1 +1 @@
1
- {"version":3,"file":"JotaiAtomChangeItem.d.ts","sourceRoot":"","sources":["../../../../src/jotai/components/JotaiAtomChangeItem.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,UAAU,CAAC;AAGpE,UAAU,wBAAwB;IAChC,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IAC3C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAsDD,eAAO,MAAM,mBAAmB,gEAwB9B,CAAC"}
1
+ {"version":3,"file":"JotaiAtomChangeItem.d.ts","sourceRoot":"","sources":["../../../../src/jotai/components/JotaiAtomChangeItem.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,eAAe,EAAsB,MAAM,UAAU,CAAC;AAGpE,UAAU,wBAAwB;IAChC,MAAM,EAAE,eAAe,CAAC;IACxB,OAAO,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IAC3C;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAgED,eAAO,MAAM,mBAAmB,gEAwB9B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"watchAtoms.d.ts","sourceRoot":"","sources":["../../../../src/jotai/utils/watchAtoms.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAGlC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,+DAA+D;AAC/D,KAAK,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;AAE7B,mFAAmF;AACnF,UAAU,aAAa;IACrB,GAAG,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC;IACzC,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IACzD;;;;;;OAMG;IACH,GAAG,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;CAClD;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,MAAM,IAAI,CAiFZ;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,MAAM,IAAI,CA2BZ;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,YAAY,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"watchAtoms.d.ts","sourceRoot":"","sources":["../../../../src/jotai/utils/watchAtoms.ts"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAGlC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD,+DAA+D;AAC/D,KAAK,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;AAE7B,mFAAmF;AACnF,UAAU,aAAa;IACrB,GAAG,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC;IACzC,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IACzD;;;;;;OAMG;IACH,GAAG,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;CAClD;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,UAAU,CACxB,KAAK,EAAE,aAAa,EACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,MAAM,IAAI,CAiFZ;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC9B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,MAAM,IAAI,CAGZ;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,YAAY,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ "use client";
2
+ var yt=Object.defineProperty;var po=Object.getOwnPropertyDescriptor;var ho=Object.getOwnPropertyNames;var yo=Object.prototype.hasOwnProperty;var bo=(e,o)=>{for(var t in o)yt(e,t,{get:o[t],enumerable:!0})},ht=(e,o,t,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of ho(o))!yo.call(e,n)&&n!==t&&yt(e,n,{get:()=>o[n],enumerable:!(a=po(o,n))||a.enumerable});return e},D=(e,o,t)=>(ht(e,o,"default"),t&&ht(t,o,"default"));typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{createRestoreScope as So,emptyRestoreResult as Io,failedRestore as Do,registerStateSnapshotProvider as ko,unionKeys as Jo}from"@buoy-gg/shared-ui/web";import{boundedDeepEqual as Lo}from"@buoy-gg/shared-ui/web/dataViewer";import{ChangeLog as wo,entityColor as Co,formatValuePreview as Ao,shallowDiffSummary as xo}from"@buoy-gg/shared-ui/web";var To={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 bt(e){return Co(e,To)}function Vo(e,o=40){return Ao(e,{maxLength:o,functionLabel:"(fn)"})}var vo=xo,Oe=class extends wo{constructor(){super(...arguments);this.atoms=new Map;this.atomListeners=new Set}addAtomChange(t){if(!this.canRecord())return;let{atomLabel:a,prevValue:n,nextValue:i,category:l="write"}=t,r=n!==i,{summary:c,changedKeys:m,changedCount:h}=vo(n,i),J=Vo(i),A={id:this.nextId(),atomLabel:a,timestamp:Date.now(),prevValue:n,nextValue:i,hasValueChange:r,category:l,changedKeys:m,changedKeysCount:h,diffSummary:c,valuePreview:J,isSlowUpdate:!1};this.push(A);let w=this.atoms.get(a);w&&w.changeCount++,this.notifyListeners(),this.notifyAtomListeners()}getAtomChanges(){return this.getAll()}getAtomChangeById(t){return this.getById(t)}clearAtomChanges(){for(let t of this.atoms.values())t.changeCount=0;this.clear(),this.notifyAtomListeners()}getAtomSnapshots(){return Array.from(this.atoms.values()).map(t=>{let a;try{a=t.getValue()}catch{a=void 0}return{label:t.label,changeCount:t.changeCount,color:t.color,currentValue:a,writeKind:t.writeKind}})}replaceFromSnapshot(t,a){if(!this.getEnabled())return;let n=new Map;for(let r of this.items){let c=r.prevValue;(!c||c.__buoyValueOnDevice!==!0)&&n.set(r.id,r)}let i=t.slice(0,this.max).map(r=>{let c=n.get(r.id),m=r.prevValue;return c&&m?.__buoyValueOnDevice===!0?{...r,prevValue:c.prevValue,nextValue:c.nextValue}:r}),l=new Map;for(let[r,c]of this.atoms)try{let m=c.getValue(),h=m;(!h||h.__buoyValueOnDevice!==!0)&&l.set(r,m)}catch{}this.atoms=new Map(a.map(r=>{let c=r.currentValue,m=l.get(r.label),h=m!==void 0&&c?.__buoyValueOnDevice===!0?m:r.currentValue;return[r.label,{label:r.label,changeCount:r.changeCount,color:r.color,getValue:()=>h,writeKind:r.writeKind}]})),this.setItems(i),this.notifyAtomListeners()}hydrateChange(t,a){this.hydrateById(t,a)}hydrateAtomValue(t,a){let n=this.atoms.get(t);n&&(this.atoms.set(t,{...n,getValue:()=>a}),this.notifyAtomListeners())}registerAtom(t,a,n,i){if(this.atoms.has(t))return;let l={label:t,changeCount:0,color:bt(t),getValue:a,setValue:n,writeKind:i};this.atoms.set(t,l),this.notifyAtomListeners()}setAtomValue(t,a){let n=this.atoms.get(t);if(!n)throw new Error(`Atom "${t}" is not registered`);if(!n.setValue)throw new Error(`Atom "${t}" is read-only (derived) \u2014 cannot set`);n.setValue(a)}unregisterAtom(t){this.atoms.delete(t),this.notifyAtomListeners()}getAtoms(){return Array.from(this.atoms.values())}getAtom(t){return this.atoms.get(t)}getAtomColor(t){return this.atoms.get(t)?.color??bt(t)}filterAtomChanges(t){let a=this.getAll();if(t.searchText){let n=t.searchText.toLowerCase();a=a.filter(i=>i.atomLabel.toLowerCase().includes(n)||i.valuePreview.toLowerCase().includes(n)||i.changedKeys.some(l=>l.toLowerCase().includes(n)))}return t.atomLabels&&t.atomLabels.length>0&&(a=a.filter(n=>t.atomLabels.includes(n.atomLabel))),t.onlyWithChanges&&(a=a.filter(n=>n.hasValueChange)),a}getStats(){let t=this.items.length,a=this.items.filter(n=>n.hasValueChange).length;return{totalChanges:t,changesWithValueChange:a,changesWithoutValueChange:t-a,atomCount:this.atoms.size}}getUniqueAtomLabels(){return Array.from(this.atoms.keys()).sort()}setMaxChanges(t){this.setMax(t)}subscribeToAtoms(t){return this.atomListeners.add(t),()=>this.atomListeners.delete(t)}notifyAtomListeners(){let t=this.getAtoms();this.atomListeners.forEach(a=>a(t))}},f=new Oe;function Bo(){let e=f.getAtoms();if(e.length===0)return{canCapture:!1,canRestore:!1,detail:"No Jotai atoms registered \u2014 pass your atoms to watchAtoms() / watchDefaultStoreAtoms()"};let o=e.filter(t=>t.setValue).length;return{canCapture:!0,canRestore:o>0,detail:o<e.length?`${e.length-o} derived atom(s) recompute automatically and are not restored`:void 0}}async function Po(){let e=[],o={},t=0;for(let a of f.getAtoms())try{let n=a.getValue();if(typeof n=="function"){e.push(`atom "${a.label}": function value not capturable`);continue}a.setValue||(t+=1),o[a.label]={value:n,writable:!!a.setValue}}catch(n){e.push(`atom "${a.label}": capture failed (${String(n)})`)}return t>0&&e.push(`${t} derived atom(s) captured for inspection only (recompute on restore)`),{data:{atoms:o},warnings:e}}async function Eo(e,o){let t=e,a=So(o),n=Io();if(!t?.atoms)return Do("empty jotai snapshot");let i=0;for(let[r,c]of Object.entries(t.atoms)){if(!a.allows(r))continue;if(!c.writable){i+=1;continue}let m=f.getAtom(r);if(!m){n.skipped.push({id:r,reason:"atom not registered (renamed, or unwatched since snapshot?)"});continue}if(!m.setValue){n.skipped.push({id:r,reason:"atom is now read-only (derived)"});continue}try{m.setValue(c.value),n.applied+=1}catch(h){n.skipped.push({id:r,reason:String(h)}),n.ok=!1}}i>0&&n.warnings.push(`${i} derived atom(s) left to recompute`);let l=a.excludedWarning("atom(s)");return l&&n.warnings.push(l),n}async function Ro(e,o){let t=e?.atoms??{},a=o===void 0,n={};if(a)for(let r of f.getAtoms())try{n[r.label]={value:r.getValue(),writable:!!r.setValue}}catch{}else Object.assign(n,o?.atoms??{});let i=[],l=[];for(let r of Jo(n,t)){if(!(r in t)){a?l.push(`atom "${r}" not in snapshot \u2014 untouched`):i.push({key:r,label:r,verdict:"removed",oldValue:n[r]?.value});continue}let m=t[r],h=r in n&&Lo(n[r].value,m.value);if(!m.writable){i.push({key:r,label:r,verdict:h?"unchanged":"recomputes",reason:h?void 0:"derived atom \u2014 recomputes from its sources",oldValue:n[r]?.value,newValue:m.value});continue}if(a){let J=f.getAtom(r);if(!J){i.push({key:r,label:r,verdict:"wont-apply",reason:"atom not registered (renamed, or unwatched since snapshot?)"});continue}if(!J.setValue){i.push({key:r,label:r,verdict:"wont-apply",reason:"atom is now read-only (derived)"});continue}}r in n?h?i.push({key:r,label:r,verdict:"unchanged"}):i.push({key:r,label:r,verdict:"changed",oldValue:n[r].value,newValue:m.value}):i.push({key:r,label:r,verdict:"added",newValue:m.value})}return{items:i,notes:l}}ko({id:"jotai",label:"Jotai",status:Bo,capture:Po,restore:Eo,previewItems:Ro});import{useState as Z,useMemo as ne,useRef as Le,useCallback as P,useEffect as Bt}from"react";var T={};bo(T,{AccessibilityInfo:()=>Yo,ActivityIndicator:()=>No,Alert:()=>Uo,Animated:()=>Xo,AppRegistry:()=>Qo,AppState:()=>en,Appearance:()=>Zo,BackHandler:()=>tn,Button:()=>jo,CheckBox:()=>bn,Clipboard:()=>on,DeviceEventEmitter:()=>Pn,Dimensions:()=>nn,Easing:()=>an,FlatList:()=>Ie,I18nManager:()=>rn,Image:()=>wn,ImageBackground:()=>Cn,InteractionManager:()=>ln,Keyboard:()=>sn,KeyboardAvoidingView:()=>An,LayoutAnimation:()=>cn,Linking:()=>dn,LogBox:()=>Bn,Modal:()=>zo,NativeEventEmitter:()=>un,NativeModules:()=>qo,PanResponder:()=>mn,Picker:()=>xn,PixelRatio:()=>gn,Platform:()=>fn,Pressable:()=>Ho,ProgressBar:()=>Tn,RefreshControl:()=>Vn,SafeAreaView:()=>vn,ScrollView:()=>oe,SectionList:()=>Sn,Share:()=>pn,StatusBar:()=>In,StyleSheet:()=>G,Switch:()=>_o,Text:()=>y,TextInput:()=>Mo,Touchable:()=>Dn,TouchableHighlight:()=>Oo,TouchableNativeFeedback:()=>kn,TouchableOpacity:()=>te,TouchableWithoutFeedback:()=>Fo,UIManager:()=>hn,Vibration:()=>yn,View:()=>d,VirtualizedList:()=>Jn,YellowBox:()=>Ln,findNodeHandle:()=>Ko,unstable_createElement:()=>Go,useColorScheme:()=>En,useLocaleContext:()=>Rn,useWindowDimensions:()=>$n});D(T,jr);import*as jr from"react-native-web";import{unstable_createElement as Go,NativeModules as qo,AccessibilityInfo as Yo,Animated as Xo,Appearance as Zo,AppRegistry as Qo,AppState as en,BackHandler as tn,Clipboard as on,Dimensions as nn,Easing as an,I18nManager as rn,Keyboard as sn,InteractionManager as ln,LayoutAnimation as cn,Linking as dn,NativeEventEmitter as un,PanResponder as mn,PixelRatio as gn,Platform as fn,Share as pn,StyleSheet as G,UIManager as hn,Vibration as yn,CheckBox as bn,FlatList as Ie,Image as wn,ImageBackground as Cn,KeyboardAvoidingView as An,Picker as xn,ProgressBar as Tn,RefreshControl as Vn,SafeAreaView as vn,SectionList as Sn,StatusBar as In,Touchable as Dn,TouchableNativeFeedback as kn,VirtualizedList as Jn,YellowBox as Ln,LogBox as Bn,DeviceEventEmitter as Pn,useColorScheme as En,useLocaleContext as Rn,useWindowDimensions as $n}from"react-native-web";import*as x from"react-native-web";import{createElement as $o,forwardRef as Wo}from"react";function N(e){let o=Wo((a,n)=>{let{accessibilityState:i,accessibilityValue:l,...r}=a;for(let c of["busy","checked","disabled","expanded","selected"])i?.[c]!==void 0&&r[`aria-${c}`]===void 0&&(r[`aria-${c}`]=i[c]);for(let[c,m]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))l?.[c]!==void 0&&r[`aria-${m}`]===void 0&&(r[`aria-${m}`]=l[c]);return $o(e,{...r,ref:n})}),t=e.State;return t&&Object.assign(o,{State:t}),o.displayName=e.displayName??e.name??"NativeWebView",o}var d=N(x.View),y=N(x.Text),Mo=N(x.TextInput),te=N(x.TouchableOpacity),Oo=N(x.TouchableHighlight),Fo=N(x.TouchableWithoutFeedback),Ho=N(x.Pressable),oe=N(x.ScrollView),zo=N(x.Modal),_o=N(x.Switch),No=N(x.ActivityIndicator),jo=N(x.Button),Ko=x.findNodeHandle,Uo={alert(e,o,t,a){if(typeof document>"u")return;let n=document.createElement("dialog");n.dataset.buoyRoot="",n.setAttribute("aria-label",e),n.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 i=document.createElement("h2");if(i.textContent=e,i.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(i),o){let m=document.createElement("p");m.textContent=o,m.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(m)}let l=document.createElement("div");l.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let r=t?.length?t:[{text:"OK"}],c=()=>{n.close?.(),n.remove()};for(let m of r){let h=document.createElement("button");h.type="button",h.textContent=m.text??"OK",h.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${m.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,h.onclick=()=>{c(),m.onPress?.()},l.appendChild(h)}n.addEventListener("cancel",m=>{m.preventDefault(),a?.cancelable!==!1&&(c(),a?.onDismiss?.())}),n.appendChild(l),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}};import{JsModal as Na,ModalHeader as E,TabSelector as ja,macOSColors as Ka,night as $,Search as Ua,Filter as Ga,Power as qa,ToolEmptyState as et,resolveListEmptyState as $t,devToolsStorageKeys as Ya,ProUpgradeModal as Xa,PowerToggleButton as Za,ToolbarCopyButton as Qe,ToolbarClearButton as Qa,truncatePayload as Ae,TickProvider as Pt,useLimit as er,windowDragProps as tr,EVENT_LIST_PRESET as Et}from"@buoy-gg/shared-ui/web";import{useIsPro as or}from"@buoy-gg/license/web";import{useCallback as Wn,useMemo as wt}from"react";import{useChangeLog as Mn,useSubscribedValue as On}from"@buoy-gg/shared-ui/web";function Fn(e,o){let t=e;if(o.searchText){let a=o.searchText.toLowerCase();t=t.filter(n=>n.atomLabel.toLowerCase().includes(a)||n.valuePreview.toLowerCase().includes(a)||n.changedKeys.some(i=>i.toLowerCase().includes(a)))}return o.atomLabels&&o.atomLabels.length>0&&(t=t.filter(a=>o.atomLabels.includes(a.atomLabel))),o.onlyWithChanges&&(t=t.filter(a=>a.hasValueChange)),t}var Hn=()=>f.getAtoms(),zn=e=>f.subscribeToAtoms(e);function Fe(){let e=Mn(f,{filterItems:Fn}),o=On(Hn,zn),t=wt(()=>{let i=e.items.length,l=e.items.filter(r=>r.hasValueChange).length;return{totalChanges:i,changesWithValueChange:l,changesWithoutValueChange:i-l,atomCount:o.length}},[e.items,o]),a=wt(()=>f.getUniqueAtomLabels(),[o]),n=Wn(i=>f.getAtomChangeById(i),[]);return{atomChanges:e.items,filteredChanges:e.filteredItems,filter:e.filter,setFilter:e.setFilter,stats:t,atoms:o,clearChanges:f.clearAtomChanges.bind(f),isEnabled:e.isEnabled,toggleCapture:e.toggleCapture,atomLabels:a,getChangeById:n}}import{memo as _n}from"react";import{ChangeRow as Nn,night as jn}from"@buoy-gg/shared-ui/web";import{jsx as Xn}from"react/jsx-runtime";function Kn(e,o){return o}function Un(e,o){return e==="initial"?jn.color.textTertiary:f.getAtomColor(o)}function He(e,o=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>o?e.slice(0,o-1)+"\u2026":e}"`;if(Array.isArray(e))return e.length===0?"[]":`[${e.length} item${e.length===1?"":"s"}]`;if(typeof e=="object"){let t=Object.keys(e);return t.length===0?"{}":`{${t.slice(0,2).join(", ")}${t.length>2?"\u2026":""}}`}return String(e).slice(0,o)}function Gn(e){return e.hasValueChange?`${He(e.prevValue)} \u2192 ${He(e.nextValue)}`:"no change"}function qn(e){return e.category==="initial"?"INIT":"WRITE"}function Yn(e){let o=e.nextValue;return typeof o=="object"&&o!==null&&!Array.isArray(o)?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()":He(o)}var ze=_n(function({change:o,onPress:t,testID:a}){let n=Un(o.category,o.atomLabel),i=Kn(o.category,o.atomLabel),l=Gn(o),r=Yn(o),c=qn(o);return Xn(Nn,{statusColor:n,statusLabel:i,sublabel:l,primaryText:r,timestamp:o.timestamp,badgeText:c,changed:o.hasValueChange,onPress:()=>t(o),testID:a})});import{memo as Qn,useState as _e,useCallback as be,useMemo as At}from"react";import{buoyColors as we,night as C,EventStepperFooter as vt,formatRelativeTime as Je,parseValue as ke,Info as ea,Zap as xt,FileText as ta,Database as oa,GitBranch as na,copyToClipboard as aa,ProUpgradeModal as ra,DiffModeTabs as ia,CompareBar as sa,DetailViewToggle as la,monoFont as q}from"@buoy-gg/shared-ui/web";import{DataViewer as ca,SplitDiffViewer as da,TreeDiffViewer as ua,diffThemes as ma}from"@buoy-gg/shared-ui/web/dataViewer";import{useIsPro as ga}from"@buoy-gg/license/web";var u="buoy-jotai";function de(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function Zn(e,o){return`${u}-row-${de(e)}-${o}`}function De(e){return`${u}-atom-${de(e)}`}function Ct(e){let o=new Map,t=new Map;for(let a of e){let n=(o.get(a.atomLabel)??0)+1;o.set(a.atomLabel,n),t.set(a.id,Zn(a.atomLabel,n))}return t}import{jsx as g,jsxs as M}from"react/jsx-runtime";var fa=[{key:"change",label:"CHANGE",icon:ta},{key:"value",label:"VALUE",icon:oa},{key:"diff",label:"DIFF",icon:na}],pa=["diff"];function ha(e){switch(e){case"initial":return{label:"INITIAL",color:C.color.textTertiary,bgColor:C.color.textTertiary+"26"};default:return{label:"WRITE",color:we.success,bgColor:we.success+"26"}}}function ya(e){let o=new Date(e),t=o.getHours().toString().padStart(2,"0"),a=o.getMinutes().toString().padStart(2,"0"),n=o.getSeconds().toString().padStart(2,"0"),i=o.getMilliseconds().toString().padStart(3,"0");return`${t}:${a}:${n}.${i}`}function Tt(e){return new Date(e).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function ba(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}function Vt(e){return e==="initial"?"INIT":"WRITE"}var wa=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}],Ca=Qn(function({change:o}){let t=ga(),[a,n]=_e(!1),i=ha(o.category),l=f.getAtomColor(o.atomLabel),r=be(async()=>{if(!t){n(!0);return}await aa(o.nextValue)},[o.nextValue,t]);return M(oe,{style:b.container,contentContainerStyle:b.content,showsVerticalScrollIndicator:!1,testID:`${u}-detail-scroll`,children:[M(d,{style:b.card,testID:`${u}-info-card`,children:[g(d,{style:b.sectionHeader,children:M(d,{style:b.sectionHeaderLeft,children:[g(ea,{size:14,color:C.color.accent}),g(y,{style:b.sectionTitle,children:"CHANGE INFO"})]})}),M(d,{style:b.cardContent,children:[M(d,{style:b.infoRow,children:[g(y,{style:b.infoLabel,children:"Atom"}),g(y,{style:[b.infoValue,b.infoValueMono,{color:l}],numberOfLines:1,ellipsizeMode:"middle",testID:`${u}-info-atom`,children:o.atomLabel})]}),M(d,{style:b.infoRow,children:[g(y,{style:b.infoLabel,children:"Time"}),g(y,{style:[b.infoValue,b.infoValueMono],testID:`${u}-info-time`,children:ya(o.timestamp)})]}),M(d,{style:b.badgeRow,children:[g(d,{style:[b.categoryBadge,{backgroundColor:i.bgColor}],children:g(y,{style:[b.categoryText,{color:i.color}],testID:`${u}-info-category`,children:i.label})}),o.hasValueChange?M(d,{style:b.changesBadge,children:[g(xt,{size:10,color:we.success}),g(y,{style:b.changesText,testID:`${u}-info-changes`,children:o.diffSummary||"changed"})]}):g(d,{style:b.noChangesBadge,children:g(y,{style:b.noChangesText,testID:`${u}-info-no-changes`,children:"no change"})})]})]})]}),o.changedKeys.length>0&&M(d,{style:b.card,testID:`${u}-keys-card`,children:[M(d,{style:b.sectionHeader,children:[M(d,{style:b.sectionHeaderLeft,children:[g(xt,{size:14,color:C.color.accent}),g(y,{style:b.sectionTitle,children:"CHANGED KEYS"})]}),g(d,{style:b.countBadge,children:g(y,{style:b.countText,testID:`${u}-keys-count`,children:o.changedKeys.length})})]}),g(d,{style:b.cardContent,children:g(d,{style:b.keysContainer,children:o.changedKeys.map(c=>g(d,{style:b.keyBadge,children:g(y,{style:b.keyText,testID:`${u}-key-${de(c)}`,children:c})},c))})})]}),g(d,{style:b.actionsRow,children:g(d,{style:[b.actionButton,b.actionButtonCopy],onTouchEnd:r,testID:`${u}-copy-value`,accessibilityRole:"button",accessibilityLabel:"Copy value",children:g(y,{style:[b.actionButtonText,{color:C.color.accent}],children:"COPY VALUE"})})}),g(ra,{visible:a,onClose:()=>n(!1),featureName:"Copy"})]})});function Ne({change:e,changes:o,selectedIndex:t,onIndexChange:a,disableInternalFooter:n=!1,initialView:i="change"}){let[l,r]=_e(i),[c,m]=_e("tree"),h=o.length,J=f.getAtomColor(e.atomLabel),A=Vt(e.category),w=ba(ke(e.nextValue)),I=h-t,k=t<h-1?t+1:null,z=k!==null?o[k]:null,O=I-1,ue=At(()=>({index:k??0,label:O>0?`#${O}`:"Initial",timestamp:z?Tt(z.timestamp):"",relativeTime:z?Je(new Date(z.timestamp)):"value",badge:z?g(d,{style:[B.changeBadgeSmall,{backgroundColor:`${f.getAtomColor(z.atomLabel)}20`}],children:g(y,{style:[B.changeTextSmall,{color:f.getAtomColor(z.atomLabel)}],children:Vt(z.category)})}):void 0}),[k,z,O]),ae=At(()=>({index:t,label:`#${I}`,timestamp:Tt(e.timestamp),relativeTime:Je(new Date(e.timestamp)),badge:g(d,{style:[B.changeBadgeSmall,{backgroundColor:`${J}20`}],children:g(y,{style:[B.changeTextSmall,{color:J}],children:A})})}),[t,e.timestamp,J,A,I]),xe=be(()=>{let Q=ke(e.nextValue);return M(d,{style:B.contentCard,testID:`${u}-value-card`,children:[M(d,{style:B.valueHeader,children:[g(y,{style:B.valueLabel,children:"VALUE AFTER CHANGE"}),M(d,{style:B.valueHeaderBadges,children:[g(d,{style:[B.changeBadge,{backgroundColor:`${J}20`}],children:g(y,{style:[B.changeText,{color:J}],children:A})}),g(d,{style:B.typeBadge,children:g(y,{style:B.typeText,testID:`${u}-value-type`,children:w.toUpperCase()})})]})]}),g(d,{style:b.dataViewerContainer,children:g(ca,{title:"",data:Q,showTypeFilter:!0,rawMode:!0,initialExpanded:!0})})]})},[e.nextValue,J,A,w]),me=be(()=>{let Q=ke(e.prevValue),Ve=ke(e.nextValue);return c==="split"?g(oe,{style:{flex:1},showsVerticalScrollIndicator:!0,children:g(da,{oldValue:Q,newValue:Ve,theme:ma.devToolsDefault,options:{hideLineNumbers:!1,disableWordDiff:!1,showDiffOnly:!1,compareMethod:"words",contextLines:3},showThemeName:!1})}):g(ua,{oldValue:Q,newValue:Ve})},[e.prevValue,e.nextValue,c]),ge=be(()=>{a(Math.min(h-1,t+1))},[t,h,a]),K=be(()=>{a(Math.max(0,t-1))},[t,a]),Te=e.prevValue===void 0,fe=!n&&h>1;return M(d,{style:B.container,children:[g(la,{views:fa,activeView:l,onViewChange:r,disabledKeys:Te?pa:void 0,testIDPrefix:u}),M(d,{style:[B.contentArea,fe&&B.contentAreaFooterPad],children:[l==="change"&&g(Ca,{change:e}),l==="value"&&g(d,{style:B.stateContainer,children:xe()}),l==="diff"&&M(d,{style:B.diffContainer,testID:`${u}-diff`,children:[g(ia,{tabs:wa,activeTab:c,onTabChange:m,testIDPrefix:`${u}-diff-tab`}),g(sa,{leftEvent:ue,rightEvent:ae}),g(d,{style:B.diffContent,testID:`${u}-diff-content`,children:me()})]})]}),fe&&g(vt,{currentIndex:I-1,totalItems:h,onPrevious:ge,onNext:K,itemLabel:"Change",subtitle:Je(new Date(e.timestamp)),absolute:!0})]})}function je({change:e,changes:o,selectedIndex:t,onIndexChange:a}){let n=o.length;if(n<=1)return null;let i=n-t;return g(vt,{currentIndex:i-1,totalItems:n,onPrevious:()=>a(Math.min(n-1,t+1)),onNext:()=>a(Math.max(0,t-1)),itemLabel:"Change",subtitle:Je(new Date(e.timestamp))})}var B=G.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:q,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:q,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:C.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:C.color.textTertiary,fontFamily:q},valueBox:{backgroundColor:C.color.bg,borderRadius:6,borderWidth:1,borderColor:C.color.border,padding:8},valueText:{fontSize:12,color:C.color.text,fontFamily:q,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:q}}),b=G.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:q},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:q},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:we.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:we.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:q},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:C.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:C.color.accent,fontFamily:q},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:q,letterSpacing:.3},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});import{useMemo as Aa}from"react";import{CompactRow as xa,night as Ke,ToolEmptyState as It,resolveListEmptyState as Ta,monoFont as St}from"@buoy-gg/shared-ui/web";import{jsx as X,jsxs as Ue}from"react/jsx-runtime";function Va(e){try{let o=e.getValue();if(o&&typeof o=="object"&&o.__buoyValueOnDevice===!0)return"on device";if(o===void 0)return"undefined";if(o===null)return"null";if(Array.isArray(o))return o.length===0?"[]":`[${o.length} item${o.length===1?"":"s"}]`;if(typeof o=="object"){let t=Object.keys(o);return t.length===0?"{}":t.length<=3?t.join(", "):`${t.slice(0,2).join(", ")} +${t.length-2}`}return String(o).slice(0,40)}catch{return""}}function va(e){return e.writeKind==="value"?"primitive":e.writeKind==="action"?"custom write":e.setValue?"writable":"derived"}function Sa(){return X(It,{testID:`${u}-atoms-empty`,otto:"scanning",title:"No atoms registered",message:`Use watchAtoms(store, { atomName }) to register your Jotai atoms.
3
+ They will appear here with their current value.`})}function Dt({atoms:e,searchQuery:o,onOpenAtom:t}){let a=Aa(()=>{if(!o)return e;let n=o.toLowerCase();return e.filter(i=>i.label.toLowerCase().includes(n))},[e,o]);return a.length===0&&!o?X(Sa,{}):a.length===0&&o?X(It,{testID:`${u}-atoms-no-match`,...Ta({subject:"atoms",verb:"registered",search:o,total:e.length,waiting:{otto:"scanning",title:"No atoms registered",message:"Use watchAtoms() to register your Jotai atoms."}})}):Ue(oe,{style:Y.container,contentContainerStyle:Y.scrollContent,showsVerticalScrollIndicator:!0,testID:`${u}-atoms-scroll`,children:[Ue(d,{style:Y.sectionHeader,children:[X(y,{style:Y.sectionTitle,children:"ATOMS"}),X(d,{style:Y.sectionCountBadge,children:X(y,{style:Y.sectionCountText,testID:`${u}-atoms-count`,children:a.length})})]}),a.map(n=>{let i=Va(n),l=f.getAtomColor(n.label),r=De(n.label);return Ue(d,{style:Y.atomRowWrapper,children:[X(xa,{statusDotColor:l,statusLabel:va(n),primaryText:n.label,secondaryText:i||void 0,showChevron:!0,onPress:()=>t(n.label),testID:r,statusTestID:`${r}-kind`,primaryTestID:`${r}-name`,secondaryTestID:`${r}-preview`}),n.changeCount>0&&X(d,{style:[Y.absCountBadge,{backgroundColor:l+"22",borderColor:l+"55"}],pointerEvents:"none",children:X(y,{style:[Y.absCountText,{color:l}],testID:`${r}-count`,children:String(n.changeCount)})})]},n.label)})]})}var Y=G.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:St},scrollContent:{paddingTop:8,paddingBottom:20},sectionHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:8,gap:8},sectionTitle:{fontSize:11,fontWeight:"700",letterSpacing:.5,color:Ke.color.textTertiary},sectionCountBadge:{backgroundColor:Ke.color.accentFill,paddingHorizontal:8,paddingVertical:2,borderRadius:4},sectionCountText:{fontSize:10,fontWeight:"700",color:Ke.color.accent,fontFamily:St}});import{useCallback as Ia,useEffect as Da,useMemo as Ge,useState as kt}from"react";import{buoyColors as qe,ExpandedInfoRow as Ye,FileJson as ka,night as L,PillBadge as Xe,parseValue as Jt,monoFont as Ce}from"@buoy-gg/shared-ui/web";import{DataViewer as Ja,LiveExplorer as La,ValueEditModal as Ba,updateNestedDataByPath as Pa,deleteNestedDataByPath as Ea}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as Oa,jsx as S,jsxs as j}from"react/jsx-runtime";var Ra=300,se=`${u}-atom-detail`;function $a(e){let o=t=>t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return e.length===0?`${se}-explorer-root`:`${se}-explorer-${e.map(o).filter(Boolean).join("-")}`}function Wa(e,o){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 o=="function")return"This atom holds a function \u2014 nothing here to edit as data.";if(o&&typeof o=="object"&&o.__buoyValueOnDevice===!0)return"The value stayed on the device (too large for the wire) \u2014 open the tool on-device to edit it.";if(o&&typeof o=="object"){let t=Object.getPrototypeOf(o);if(!(t===Object.prototype||t===null||Array.isArray(o)||o instanceof Map||o instanceof Set))return`This atom holds a ${o.constructor?.name??"class"} instance \u2014 rebuilding it from edited fields would drop its prototype. Edit via app code.`}return null}function Ma(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`array \xB7 ${e.length}`:typeof e}function Ze({atom:e,onViewHistory:o}){let t=De(e.label),[a,n]=kt(0);Da(()=>{let w=()=>n(z=>z+1),I=f.subscribe(w),k=f.subscribeToAtoms(w);return()=>{I(),k()}},[]);let i=Ge(()=>{try{return e.getValue()}catch{return}},[e,a]),l=Wa(e,i),[r,c]=kt(!1),m=Ge(()=>{if(l===null)return{update:(w,I)=>{let k=e.getValue();e.setValue?.(w.length===0?I:Pa(k,w,I))},remove:w=>{if(w.length===0)return;let I=e.getValue();e.setValue?.(Ea(I,w))},canRemove:w=>w.length>0}},[e,l]),h=Ge(()=>{if(i&&typeof i=="object"){let w={};for(let[I,k]of Object.entries(i))typeof k!="function"&&(w[I]=k);return Jt(w)}return Jt(i)},[i,a]),J=Ia(w=>{e.setValue?.(w),c(!1)},[e]),A=e.setValue===void 0?{color:L.color.textTertiary,label:"READ-ONLY (DERIVED)"}:e.writeKind==="action"?{color:qe.warning,label:"CUSTOM WRITE"}:{color:qe.success,label:"PRIMITIVE"};return j(d,{style:v.root,children:[j(oe,{testID:`${se}-scroll`,style:v.scroll,contentContainerStyle:v.scrollContent,keyboardShouldPersistTaps:"handled",children:[S(d,{style:v.section,children:j(d,{style:v.editorContainer,children:[j(d,{style:v.sectionHeaderRow,children:[S(y,{testID:`${se}-editor-header`,style:v.sectionHeaderText,children:"Value Editor"}),l===null?j(te,{onPress:()=>c(!0),testID:`${se}-raw`,accessibilityRole:"button",accessibilityLabel:"Edit raw JSON",style:v.rawButton,hitSlop:{top:6,bottom:6,left:6,right:6},children:[S(ka,{size:13,color:L.color.accent}),S(y,{style:v.rawButtonText,children:"Raw"})]}):null]}),S(d,{style:v.sectionBody,children:l===null?j(Oa,{children:[S(La,{editable:!0,label:e.label,value:i,defaultExpanded:[e.label],writer:m,dataVersion:a,testIDForPath:$a,debounceMs:Ra}),S(y,{style:v.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."})]}):S(y,{style:v.blockedText,testID:`${se}-edit-blocked`,children:l})})]})}),S(d,{style:v.section,children:j(d,{style:v.infoContainer,children:[S(y,{style:v.sectionHeaderTextPlain,children:"Atom Details"}),j(d,{style:v.infoBody,children:[j(Ye,{label:"Type",children:[S(Xe,{color:e.color,testID:`${t}-type`,children:"JOTAI"}),S(y,{style:v.valueTypeText,testID:`${t}-valuetype`,children:Ma(i)})]}),S(Ye,{label:"Write",children:S(Xe,{color:A.color,testID:`${se}-write`,children:A.label})}),e.changeCount>0&&j(Ye,{label:"Changes",children:[S(Xe,{color:qe.warning,testID:`${t}-changes`,children:String(e.changeCount)}),S(te,{onPress:()=>o(e.label),style:v.inlineLinkButton,hitSlop:{top:6,bottom:6,left:6,right:6},testID:`${t}-history`,accessibilityRole:"button",accessibilityLabel:`View ${e.label} history`,children:S(y,{style:[v.inlineLinkText,{color:e.color}],children:"view history \u2192"})})]})]})]})}),S(d,{style:v.section,children:j(d,{style:v.infoContainer,children:[S(y,{style:v.sectionHeaderTextPlain,children:"Value Explorer"}),S(d,{style:v.viewerBody,testID:`${t}-value`,children:h&&typeof h=="object"?S(Ja,{title:"",data:h,showTypeFilter:!0,rawMode:!0,initialExpanded:!1}):S(y,{style:v.primitiveText,testID:`${t}-primitive`,children:String(i??"undefined")})})]})})]}),r&&l===null?S(Ba,{path:[],value:i,onSave:J,onCancel:()=>c(!1),saveLabel:"Apply",testIDPrefix:`${u}-value`}):null]})}var v=G.create({root:{flex:1,minHeight:0},scroll:{flex:1},scrollContent:{paddingHorizontal:8,paddingTop:8,paddingBottom:24},section:{marginBottom:16},editorContainer:{minWidth:200,backgroundColor:L.color.surface,borderRadius:6,borderWidth:1,borderColor:L.color.accent+"4D",overflow:"hidden",shadowColor:L.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeaderRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:L.color.accent+"1A",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:L.color.accent+"33"},sectionHeaderText:{fontWeight:"600",fontSize:12,color:L.color.accent,letterSpacing:.5,textTransform:"uppercase",fontFamily:Ce},rawButton:{flexDirection:"row",alignItems:"center",gap:4},rawButtonText:{color:L.color.accent,fontSize:11,fontWeight:"700"},sectionBody:{padding:8},editorHint:{color:L.color.textTertiary,fontSize:10,paddingTop:8,paddingHorizontal:4,lineHeight:14},blockedText:{color:L.color.textSecondary,fontSize:12,padding:12,lineHeight:18},infoContainer:{minWidth:200,backgroundColor:L.color.surface,borderRadius:6,borderWidth:1,borderColor:L.color.border,overflow:"hidden"},sectionHeaderTextPlain:{backgroundColor:L.color.surfaceElevated,paddingHorizontal:12,paddingVertical:8,fontWeight:"600",fontSize:12,color:L.color.textSecondary,borderBottomWidth:1,borderBottomColor:L.color.border,letterSpacing:.5,textTransform:"uppercase",fontFamily:Ce},infoBody:{padding:12,gap:10},viewerBody:{backgroundColor:L.color.bg,minHeight:60},primitiveText:{color:L.color.text,fontSize:12,fontFamily:Ce,padding:14},valueTypeText:{color:L.color.textTertiary,fontSize:10,fontFamily:Ce,marginLeft:6},inlineLinkButton:{marginLeft:4},inlineLinkText:{fontSize:10,fontWeight:"600",fontFamily:Ce}});import{useMemo as Fa}from"react";import{EntityFilterView as Ha}from"@buoy-gg/shared-ui/web";import{jsx as _a}from"react/jsx-runtime";var za=["\u2022 count -> hides countAtom from atoms & events","\u2022 auth -> hides authAtom, authStatusAtom","\u2022 user -> hides userAtom from both tabs"];function Lt({ignoredPatterns:e,onTogglePattern:o,onAddPattern:t,atoms:a}){let n=Fa(()=>a.map(i=>({name:i.label,color:i.color})),[a]);return _a(Ha,{entities:n,ignoredPatterns:e,onTogglePattern:o,onAddPattern:t,entityNoun:"ATOMS",entitySingular:"atom",entityKey:"atom",testIDPrefix:u,slug:de,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:za,emptyMessage:"No atoms are being watched yet."})}import{Fragment as Rt,jsx as p,jsxs as H}from"react/jsx-runtime";function nr({isEnabled:e,searchText:o,totalChanges:t}){let a=$t({subject:"changes",search:o,total:t,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 p(et,{...a,testID:`${u}-empty`})}function Be({visible:e,onClose:o,onBack:t,onMinimize:a,enableSharedModalDimensions:n=!1,inline:i=!1,initialTab:l,initialSelectedChangeId:r,initialDetailView:c,onChangeSelect:m,onAtomExpand:h}){let J=or(),A=er("jotai.changes"),[w,I]=Z(!1),[k,z]=Z(l??"atoms"),[O,ue]=Z(null),[ae,xe]=Z(null),[me,ge]=Z(!1),[K,Te]=Z(new Set),{atomChanges:fe,filteredChanges:Q,stats:Ve,filter:Br,setFilter:pe,atoms:he,clearChanges:_t,isEnabled:ve,toggleCapture:Nt}=Fe(),U=ne(()=>K.size===0?Q:Q.filter(s=>!Array.from(K).some(V=>s.atomLabel.toLowerCase().includes(V.toLowerCase()))),[Q,K]),le=ne(()=>K.size===0?he:he.filter(s=>!Array.from(K).some(V=>s.label.toLowerCase().includes(V.toLowerCase()))),[he,K]),jt=ne(()=>O?fe.filter(s=>s.atomLabel===O).length:0,[fe,O]),ye=ne(()=>U.slice(0,A),[U,A]),$e=ne(()=>Math.max(0,U.length-A),[U.length,A]),Kt=$e>0,W=ne(()=>O?ye.filter(s=>s.atomLabel===O):ye,[ye,O]),[We,re]=Z(null),ie=ne(()=>{if(We===null)return null;let s=W.findIndex(V=>V.id===We);return s>=0?s:null},[We,W]),_=ie!==null?W[ie]:null,at=Le(null);Bt(()=>{if(!m)return;let s=_?.id??null;s===null||s===at.current||(at.current=s,m(_))},[_,m]);let rt=Le(null);Bt(()=>{!r||rt.current===r||!W.some(V=>V.id===r)||(rt.current=r,re(r))},[r,W]);let[ee,Me]=Z(""),[Ut,Se]=Z(!1),Pr=Le(null),Gt=Le(null),qt=P(s=>{},[]),Yt=s=>{Me(s),k==="events"&&pe(V=>({...V,searchText:s}))},Xt=P(()=>{Me(""),pe(s=>({...s,searchText:""})),Se(!1)},[pe]),it=P(s=>{re(s.id)},[]),Zt=P(()=>{I(!0)},[]),Qt=P(()=>{re(null)},[]),st=P(s=>{let V=W[s];V&&re(V.id)},[W]),eo=P(s=>{ue(s),re(null)},[]),to=P(()=>{ue(null),re(null)},[]),oo=P(s=>{xe(s),h?.(s)},[h]),no=P(()=>{xe(null)},[]),ao=P(()=>le.reduce((s,V)=>{try{let ce=V.getValue();s[V.label]=Ae(ce)}catch{s[V.label]=null}return s},{}),[le]),ro=P(()=>U.map(s=>({id:s.id,atomLabel:s.atomLabel,timestamp:s.timestamp,prevValue:Ae(s.prevValue),nextValue:Ae(s.nextValue),hasValueChange:s.hasValueChange,changedKeys:s.changedKeys})),[U]),io=P(()=>W.map(s=>({id:s.id,atomLabel:s.atomLabel,timestamp:s.timestamp,prevValue:Ae(s.prevValue),nextValue:Ae(s.nextValue),hasValueChange:s.hasValueChange,changedKeys:s.changedKeys})),[W]),so=P(s=>{Te(V=>{let ce=new Set(V);return ce.has(s)?ce.delete(s):ce.add(s),ce})},[]),lo=P(s=>{Te(V=>new Set([...V,s]))},[]),co=P(s=>{z(s),ue(null),re(null),ge(!1),ee&&(Me(""),pe(V=>({...V,searchText:""}))),Se(!1)},[ee,pe]),lt=P(s=>s.id,[]),ct=ne(()=>Ct(W),[W]),dt=P(({item:s})=>p(ze,{change:s,onPress:it,testID:ct.get(s.id)}),[it,ct]),ut=K.size>0,mt=()=>me?H(E,{children:[p(E.Navigation,{onBack:()=>ge(!1)}),p(E.Content,{title:"Filters",centered:!0,testID:`${u}-filters-title`})]}):_?H(E,{children:[p(E.Navigation,{onBack:Qt}),p(E.Content,{title:`${_.atomLabel}/${_.category}`,centered:!0,testID:`${u}-detail-title`})]}):O?H(E,{children:[p(E.Navigation,{onBack:to}),p(E.Content,{title:`${O} History`,centered:!0,testID:`${u}-history-title`}),p(E.Actions,{children:p(Qe,{value:io,disabled:W.length===0,buttonStyle:R.headerActionButton,testID:`${u}-copy`})})]}):ae?H(E,{children:[p(E.Navigation,{onBack:no}),p(E.Content,{title:ae,centered:!0,testID:`${u}-atom-detail-title`})]}):H(E,{children:[t&&p(E.Navigation,{onBack:t}),p(E.Content,{title:"",children:Ut?p(E.Search,{value:ee,onChangeText:Yt,onCancel:Xt,placeholder:k==="atoms"?"Search atoms...":"Search events...",accessibilityLabel:"Search Jotai atoms and events",iconSize:14,testID:`${u}-search-field`,containerTestID:`${u}-search`,clearTestID:`${u}-search-clear`,onBlur:()=>{ee.length===0&&Se(!1)}}):p(ja,{tabs:[{key:"atoms",label:`Atoms${le.length>0?` (${le.length})`:""}`},{key:"events",label:`Events${U.length>0?` (${U.length})`:""}`}],activeTab:k,onTabChange:co,testIDPrefix:`${u}-tab`})}),H(E.Actions,{children:[p(te,{onPress:()=>Se(!0),style:R.headerActionButton,testID:`${u}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:p(Ua,{size:14,color:$.color.textSecondary})}),p(te,{onPress:()=>ge(!0),style:[R.headerActionButton,ut&&R.headerActionButtonActive],testID:`${u}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:p(Ga,{size:14,color:ut?$.color.accent:$.color.textSecondary})}),k==="atoms"&&p(Qe,{value:ao,disabled:le.length===0,buttonStyle:R.headerActionButton,testID:`${u}-copy`}),k==="events"&&H(Rt,{children:[p(Qe,{value:ro,disabled:U.length===0,buttonStyle:R.headerActionButton,testID:`${u}-copy`}),p(Za,{isEnabled:ve,onToggle:Nt,accessibilityLabel:"Toggle Jotai atom capture",testID:`${u}-power`}),p(Qa,{onPress:_t,disabled:U.length===0,buttonStyle:R.headerActionButton,testID:`${u}-clear`})]})]})]}),uo=()=>{if(me)return p(Lt,{ignoredPatterns:K,onTogglePattern:so,onAddPattern:lo,atoms:he});if(_&&ie!==null)return p(Ne,{change:_,changes:W,selectedIndex:ie,onIndexChange:st,disableInternalFooter:!0,initialView:c});if(O)return W.length>0?p(Ie,{testID:`${u}-history-list`,data:W,renderItem:dt,keyExtractor:lt,contentContainerStyle:R.listContent,showsVerticalScrollIndicator:!0,...Et}):p(et,{testID:`${u}-history-empty`,...$t({subject:"changes",search:ee,total:ee.trim()?jt:0,capturing:ve,waiting:{otto:"waiting",title:"No history yet",message:`Changes for ${O} will appear here.`},paused:{title:"No history yet",message:`Capture is off, so nothing is being recorded for ${O}.`}})});if(ae){let s=he.find(V=>V.label===ae)??null;return s?p(Ze,{atom:s,onViewHistory:eo}):p(et,{testID:`${u}-atom-detail-gone`,otto:"ghost",title:"Atom no longer registered",message:`${ae} is not in the registry any more.`})}return k==="atoms"?p(Dt,{atoms:le,searchQuery:ee,onOpenAtom:oo}):H(Rt,{children:[!ve&&H(d,{style:R.disabledBanner,testID:`${u}-banner-disabled`,children:[p(qa,{size:14,color:$.color.warning}),p(y,{style:R.disabledText,children:"Atom capture is disabled"})]}),Kt&&H(te,{style:R.lockedBanner,onPress:Zt,activeOpacity:.8,testID:`${u}-locked`,accessibilityRole:"button",children:[H(y,{style:R.lockedText,testID:`${u}-locked-text`,children:[$e," older"," ",$e===1?"change":"changes"," locked"]}),p(d,{style:R.upgradeBadge,children:p(y,{style:R.upgradeBadgeText,children:"UPGRADE"})})]}),ye.length>0?p(Ie,{ref:Gt,testID:`${u}-list`,data:ye,renderItem:dt,keyExtractor:lt,contentContainerStyle:R.listContent,showsVerticalScrollIndicator:!0,...Et}):p(nr,{isEnabled:ve,searchText:ee,totalChanges:Ve.totalChanges})]})},mo=n?Ya.modal.root():"buoy-jotai-modal";if(!e)return null;let gt=_&&ie!==null?p(je,{change:_,changes:W,selectedIndex:ie,onIndexChange:st}):null,go=_&&W.length>1?68:0,fo=!me&&!(_&&ie!==null)&&(O!=null||k==="events"||k==="atoms"),ft=p(d,{style:R.container,children:uo()}),pt=p(Xa,{visible:w,onClose:()=>I(!1),featureName:"Full Atom History"});return i?H(Pt,{children:[H(d,{style:R.inlineRoot,children:[p(d,{style:R.inlineHeader,...tr,children:mt()}),ft,gt]}),pt]}):H(Pt,{children:[p(Na,{visible:e,onClose:o,onMinimize:a,persistenceKey:mo,header:{showToggleButton:!0,customContent:mt()},onModeChange:qt,enablePersistence:!0,initialMode:"bottomSheet",enableGlitchEffects:!0,disableScrollWrapper:fo,styles:{},footer:gt,footerHeight:go,children:ft}),pt]})}function ar(e={}){return p(Be,{...e,inline:!0,visible:!0,onClose:()=>{}})}var R=G.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:Ka.border.default,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:$.color.buttonSurface,borderWidth:1,borderColor:$.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonActive:{backgroundColor:$.color.accentSoft,borderColor:$.color.accentBorderStrong},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:$.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:$.color.warning+"20"},disabledText:{color:$.color.warning,fontSize:11,flex:1},listContent:{paddingTop:8,paddingBottom:20},emptyState:{alignItems:"center",paddingVertical:40},emptyTitle:{color:$.color.text,fontSize:14,fontWeight:"600",marginTop:12,marginBottom:6},emptyText:{color:$.color.textTertiary,fontSize:12,textAlign:"center",lineHeight:18},lockedBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:$.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:$.color.accentBorder},lockedText:{color:$.color.accent,fontSize:11,fontWeight:"500",flex:1},upgradeBadge:{backgroundColor:$.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},upgradeBadgeText:{color:$.color.onAccent,fontSize:9,fontWeight:"700",letterSpacing:.5}});import{JotaiIcon as Pe,JOTAI_ICON_COLOR as rr}from"@buoy-gg/shared-ui/web";import{createToolFactory as ir,defineToolPreset as sr}from"@buoy-gg/shared-ui/web";import{jsx as Mt}from"react/jsx-runtime";var Wt=sr({id:"jotai",name:"JOTAI",description:"Jotai atom & state inspector",slot:"both",icon:({size:e})=>Mt(Pe,{size:e}),component:Be,props:{enableSharedModalDimensions:!1}}),lr=ir(Wt,e=>({enableSharedModalDimensions:e.enableSharedModalDimensions??!1}),e=>({icon:({size:o})=>Mt(Pe,{size:o,color:e.iconColor})}));import{getDefaultStore as ur}from"jotai/vanilla";import{atom as cr}from"jotai/vanilla";var dr=cr(null),tt=dr.write,Ot=typeof tt=="function"?String(tt):null;function Ft(e){let o=e,t=o?.write;return typeof t!="function"?"action":t===tt||o!==null&&"init"in o&&Ot!==null&&String(t)===Ot?"value":"action"}function Ht(e,o,t){let a=t?.enabled!==!1,n=[];for(let[i,l]of Object.entries(o)){let r=l,c=Symbol.for(`@@buoy-jotai/watched/${i}`);if(r[c])continue;r[c]=!0;let m;try{m=e.get(l)}catch{m=void 0}let h=typeof l.write=="function",J=e.set&&h?w=>{e.set(l,w)}:void 0;f.registerAtom(i,()=>{try{return e.get(l)}catch{return}},J,h?Ft(l):void 0),a&&f.addAtomChange({atomLabel:i,prevValue:void 0,nextValue:m,category:"initial"});let A=e.sub(l,()=>{try{let w=e.get(l);f.addAtomChange({atomLabel:i,prevValue:m,nextValue:w,category:"write"}),m=w}catch{}});n.push(()=>{A(),delete r[c],f.unregisterAtom(i)})}return()=>n.forEach(i=>i())}function mr(e,o){let t=ur();return Ht(t,e,o)}function gr(e){return f.getAtom(e)!==void 0}import{WIRE_DETAIL_LIMIT_BYTES as fr,createSyncAdapter as pr,capDetail as hr,detailByIdAction as yr,expandKeyedArrays as br,memoByIdentity as wr,onDeviceMarker as Cr,patchFromPath as Ar,readParams as ot,readPath as xr,refusalText as Tr,shapeSummary as Ee,suggestedPatch as Vr,toWire as vr,typedEditViolations as Sr,unshapedLists as Ir}from"@buoy-gg/shared-ui/web";var Re=Cr("Value","Atom values stay on the device \u2014 fetched on demand via getChangeDetail / getAtomValue."),nt=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function zt(e,o){if(!nt(e)||!nt(o))return o;let t={...e};for(let[a,n]of Object.entries(o))t[a]=a in e?zt(e[a],n):n;return t}function Dr(e,o){let t=e;for(let a of o.split(".")){if(!nt(t)||!(a in t))return!1;t=t[a]}return Array.isArray(t)?t.length>0:!!t&&typeof t=="object"}var kr=wr(e=>({...e,prevValue:Re,nextValue:Re})),Jr=e=>vr(e,Re),Lr=pr({version:2,getSnapshot:()=>({changes:f.getAtomChanges().map(kr),atoms:f.getAtomSnapshots().map(e=>({...e,currentValue:Jr(e.currentValue)}))}),subscribe:[e=>f.subscribe(e),e=>f.subscribeToAtoms(e)],actions:{clearEvents:()=>{f.clearAtomChanges()},getChangeDetail:yr(e=>f.getAtomChangeById(e),(e,o)=>({prevValue:o(e.prevValue),nextValue:o(e.nextValue)})),getAtomValue:e=>{let{label:o,path:t}=ot(e);if(!o)return{found:!1,reason:"missing label"};let a=f.getAtom(o);if(!a)return{found:!1,reason:"unknown label"};let n;try{n=a.getValue()}catch{n=void 0}try{JSON.stringify(n)}catch{return{found:!0,label:o,currentValue:Re}}if(t){let i=xr(n,t);return i.ok?{found:!0,label:o,path:t,shape:Ee(i.value),currentValue:i.value}:{found:!1,reason:i.error}}return{found:!0,label:o,...Ee(n)?{shape:Ee(n)}:{},currentValue:hr(n,fr)}},listAtoms:e=>{let{includeValues:o=!1,limit:t}=ot(e),a=f.getAtoms(),i=(typeof t=="number"&&t>0?a.slice(0,t):a).map(l=>{let r;if(o)try{r=l.getValue()}catch{r=void 0}let c;try{c=Ee(l.getValue())}catch{c=void 0}return{label:l.label,changes:l.changeCount,writable:typeof l.setValue=="function",...c?{shape:c}:{},...o?{currentValue:r}:{}}});return{atoms:i,total:a.length,returned:i.length,includedValues:o}},setAtom:e=>{let{label:o,value:t,merge:a,path:n,force:i}=ot(e);if(!o)throw new Error("setAtom requires a `label`");let l=f.getAtom(o),r;try{r=l?.getValue()}catch{r=void 0}let c=t,m=[],h=[],J=a===!0||n!==void 0;if(n!==void 0){if(t===void 0)return{ok:!1,error:`Refused: sent \`path\` without \`value\`. Say what to set "${n}" to.`};let A=Ar(r,n,t);if(!A.ok)return{ok:!1,error:`Refused: ${A.error}`};c=A.patch}if(!i&&J&&r!==void 0){let A=br(r,c);if(A.error)return{ok:!1,error:`Refused: ${A.error}`};c=A.patch,m=A.notes,h=Ir(r).filter(I=>Dr(c,I));let w=Sr(r,c,{noun:"atom"});if(w.length){let I=Vr(c,w);return{ok:!1,error:Tr(w,"atom",I),violations:w,...I?{suggestedValue:I}:{}}}}return f.setAtomValue(o,J?zt(r,c):c),{ok:!0,...n!==void 0?{path:n}:{},...m.length?{keyed:m}:{},...h.length?{unchecked:h.map(A=>`\`${A}\` was empty, so nothing knows what its items look like and the shape of what you added was NOT checked.`)}:{}}}}});export{rr as JOTAI_ICON_COLOR,ze as JotaiAtomChangeItem,Ne as JotaiAtomDetailContent,je as JotaiAtomDetailFooter,Ze as JotaiAtomValueDetailContent,Pe as JotaiIcon,Be as JotaiModal,ar as JotaiToolView,lr as createJotaiTool,gr as isAtomWatched,f as jotaiStateStore,Lr as jotaiSyncAdapter,Wt as jotaiToolPreset,Fe as useJotaiAtomChanges,Ht as watchAtoms,mr as watchDefaultStoreAtoms};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/jotai",
3
- "version": "7.0.40",
3
+ "version": "7.0.41",
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",
@@ -10,32 +10,43 @@
10
10
  "exports": {
11
11
  ".": {
12
12
  "react-native": "./lib/module/index.js",
13
+ "browser": {
14
+ "types": "./lib/typescript/index.d.ts",
15
+ "default": "./lib/web/index.mjs"
16
+ },
13
17
  "import": {
14
- "default": "./lib/module/index.js",
15
- "types": "./lib/typescript/index.d.ts"
18
+ "types": "./lib/typescript/index.d.ts",
19
+ "default": "./lib/module/index.js"
16
20
  },
17
21
  "require": {
18
- "default": "./lib/commonjs/index.js",
19
- "types": "./lib/typescript/index.d.ts"
22
+ "types": "./lib/typescript/index.d.ts",
23
+ "default": "./lib/commonjs/index.js"
20
24
  }
21
25
  },
22
- "./package.json": "./package.json"
26
+ "./package.json": "./package.json",
27
+ "./web": {
28
+ "types": "./lib/typescript/index.d.ts",
29
+ "default": "./lib/web/index.mjs"
30
+ }
23
31
  },
24
32
  "files": [
25
33
  "lib"
26
34
  ],
27
35
  "sideEffects": [
28
36
  "**/snapshotProvider.js",
29
- "**/snapshotProvider.ts"
37
+ "**/snapshotProvider.ts",
38
+ "./lib/web/**/*.mjs"
30
39
  ],
31
40
  "dependencies": {
32
- "@buoy-gg/license": "^7.0.40",
33
- "@buoy-gg/shared-ui": "^7.0.40"
41
+ "@buoy-gg/shared-ui": "^7.0.41",
42
+ "@buoy-gg/license": "^7.0.41"
34
43
  },
35
44
  "peerDependencies": {
36
45
  "jotai": ">=2.0.0",
37
46
  "react": "*",
38
- "react-native": "*"
47
+ "react-native": "*",
48
+ "react-native-web": "^0.21.0",
49
+ "react-dom": ">=18"
39
50
  },
40
51
  "devDependencies": {
41
52
  "@types/react": "^19.1.0",
@@ -91,10 +102,22 @@
91
102
  "atoms",
92
103
  "state-management"
93
104
  ],
105
+ "peerDependenciesMeta": {
106
+ "react-native": {
107
+ "optional": true
108
+ },
109
+ "react-native-web": {
110
+ "optional": true
111
+ },
112
+ "react-dom": {
113
+ "optional": true
114
+ }
115
+ },
94
116
  "scripts": {
95
- "build": "bob build",
117
+ "build": "bob build && pnpm run build:web",
96
118
  "typecheck": "tsc --noEmit",
97
119
  "clean": "rimraf lib",
98
- "test": "pnpm run typecheck"
120
+ "test": "pnpm run typecheck",
121
+ "build:web": "node ../../scripts/build-web.mjs jotai"
99
122
  }
100
123
  }