@buoy-gg/assets 7.0.56 → 7.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundlers/vite.mjs +1 -1
- package/lib/web/index.mjs +2 -2
- package/package.json +2 -2
package/bundlers/vite.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readdir as p,readFile as
|
|
1
|
+
import{readdir as p,readFile as m}from"node:fs/promises";import{createHash as h}from"node:crypto";import c from"node:path";const y=/\.(?:avif|gif|jpe?g|png|svg|webp|ico|woff2?|ttf|otf|eot|mp[34]|m4a|ogg|wav|webm|pdf)$/i;const u=a=>h("sha256").update(a).digest("hex");export function buoyAssets({filename:a="buoy-assets.json"}={}){let i;const f=async()=>{if(!i.publicDir)return[];const r=[];async function o(s){let e;try{e=await p(s,{withFileTypes:true})}catch(t){if(t.code==="ENOENT")return;throw t}for(const t of e){const n=c.join(s,t.name);if(t.isDirectory())await o(n);else if(t.isFile()&&y.test(t.name)){const l=await m(n);r.push({url:`${i.base}${c.relative(i.publicDir,n).split(c.sep).map(encodeURIComponent).join("/")}`,bytes:l.length,hash:u(l)})}}}await o(i.publicDir);return r};return{name:"buoy-asset-manifest",configResolved(r){i=r},configureServer(r){r.middlewares.use(async(o,s,e)=>{if(o.url?.split("?")[0]!==`${i.base}${a}`)return e();try{s.setHeader("Content-Type","application/json");s.setHeader("Cache-Control","no-store");s.end(JSON.stringify(await f()))}catch(t){e(t)}})},async generateBundle(r,o){const s=await f();for(const e of Object.values(o)){if(e.type!=="asset"||e.fileName===a||e.fileName.endsWith(".map"))continue;const t=typeof e.source==="string"?Buffer.from(e.source):e.source;s.push({url:`${i.base}${e.fileName}`,bytes:t.length,hash:u(t)})}this.emitFile({type:"asset",fileName:a,source:JSON.stringify(s)})}}}
|
package/lib/web/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use client";var we=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var Zt=Object.getOwnPropertyNames;var Xt=Object.prototype.hasOwnProperty;var Qe=(e,t)=>()=>(e&&(t=e(e=0)),t);var es=(e,t)=>{for(var s in t)we(e,s,{get:t[s],enumerable:true})},xe=(e,t,s,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Zt(t))!Xt.call(e,r)&&r!==s&&we(e,r,{get:()=>t[r],enumerable:!(a=Qt(t,r))||a.enumerable});return e},ts=(e,t,s)=>(xe(e,t,"default"),s&&xe(s,t,"default"));var Ze=e=>xe(we({},"__esModule",{value:true}),e);var p=Qe(()=>{"use strict";typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis)});var ne={};es(ne,{AccessibilityInfo:()=>ns,ActivityIndicator:()=>Ie,Alert:()=>lt,Animated:()=>os,AppRegistry:()=>ls,AppState:()=>ds,Appearance:()=>is,BackHandler:()=>cs,Button:()=>ot,CheckBox:()=>Is,Clipboard:()=>us,DeviceEventEmitter:()=>js,Dimensions:()=>hs,Easing:()=>ps,FlatList:()=>Xe,I18nManager:()=>gs,Image:()=>et,ImageBackground:()=>Bs,InteractionManager:()=>fs,Keyboard:()=>ys,KeyboardAvoidingView:()=>ks,LayoutAnimation:()=>ms,Linking:()=>bs,LogBox:()=>Ps,Modal:()=>rt,NativeEventEmitter:()=>vs,NativeModules:()=>rs,PanResponder:()=>Ss,Picker:()=>$s,PixelRatio:()=>ws,Platform:()=>oe,Pressable:()=>at,ProgressBar:()=>Ds,RefreshControl:()=>As,SafeAreaView:()=>Fs,ScrollView:()=>Ce,SectionList:()=>Ts,Share:()=>xs,StatusBar:()=>Ls,StyleSheet:()=>O,Switch:()=>nt,Text:()=>m,TextInput:()=>ze,Touchable:()=>Es,TouchableHighlight:()=>tt,TouchableNativeFeedback:()=>Rs,TouchableOpacity:()=>N,TouchableWithoutFeedback:()=>st,UIManager:()=>zs,Vibration:()=>Cs,View:()=>y,VirtualizedList:()=>Ms,YellowBox:()=>Os,findNodeHandle:()=>it,unstable_createElement:()=>as,useColorScheme:()=>Hs,useLocaleContext:()=>Ns,useWindowDimensions:()=>Vs});import*as ss from"react-native-web";import{unstable_createElement as as,NativeModules as rs,AccessibilityInfo as ns,Animated as os,Appearance as is,AppRegistry as ls,AppState as ds,BackHandler as cs,Clipboard as us,Dimensions as hs,Easing as ps,I18nManager as gs,Keyboard as ys,InteractionManager as fs,LayoutAnimation as ms,Linking as bs,NativeEventEmitter as vs,PanResponder as Ss,PixelRatio as ws,Platform as oe,Share as xs,StyleSheet as O,UIManager as zs,Vibration as Cs,CheckBox as Is,FlatList as Xe,Image as et,ImageBackground as Bs,KeyboardAvoidingView as ks,Picker as $s,ProgressBar as Ds,RefreshControl as As,SafeAreaView as Fs,SectionList as Ts,StatusBar as Ls,Touchable as Es,TouchableNativeFeedback as Rs,VirtualizedList as Ms,YellowBox as Os,LogBox as Ps,DeviceEventEmitter as js,useColorScheme as Hs,useLocaleContext as Ns,useWindowDimensions as Vs}from"react-native-web";import*as I from"react-native-web";import{createElement as Ws,forwardRef as Us}from"react";function $(e){let t=Us((a,r)=>{let{accessibilityState:n,accessibilityValue:o,...i}=a;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,l]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))o?.[d]!==void 0&&i[`aria-${l}`]===void 0&&(i[`aria-${l}`]=o[d]);return Ws(e,{...i,ref:r})}),s=e.State;return s&&Object.assign(t,{State:s}),t.displayName=e.displayName??e.name??"NativeWebView",t}var y,m,ze,N,tt,st,at,Ce,rt,nt,Ie,ot,it,lt,E=Qe(()=>{p();ts(ne,ss);y=$(I.View),m=$(I.Text),ze=$(I.TextInput),N=$(I.TouchableOpacity),tt=$(I.TouchableHighlight),st=$(I.TouchableWithoutFeedback),at=$(I.Pressable),Ce=$(I.ScrollView),rt=$(I.Modal),nt=$(I.Switch),Ie=$(I.ActivityIndicator),ot=$(I.Button),it=I.findNodeHandle,lt={alert(e,t,s,a){if(typeof document>"u")return;let r=document.createElement("dialog");r.dataset.buoyRoot="",r.setAttribute("aria-label",e),r.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",r.appendChild(n),t){let l=document.createElement("p");l.textContent=t,l.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",r.appendChild(l)}let o=document.createElement("div");o.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let i=s?.length?s:[{text:"OK"}],d=()=>{r.close?.(),r.remove()};for(let l of i){let c=document.createElement("button");c.type="button",c.textContent=l.text??"OK",c.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${l.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,c.onclick=()=>{d(),l.onPress?.()},o.appendChild(c)}r.addEventListener("cancel",l=>{l.preventDefault(),a?.cancelable!==false&&(d(),a?.onDismiss?.())}),r.appendChild(o),document.body.appendChild(r),r.showModal?r.showModal():r.setAttribute("open","")}}});p();p();p();import{AssetsIcon as dt,ASSETS_ICON_COLOR as ct}from"@buoy-gg/shared-ui/web";p();E();import{useEffect as ut,useState as te}from"react";import{EventStepperFooter as Gs,JsModal as Ks,macOSColors as _s,night as R,windowDragProps as qs,ToolEmptyState as Js}from"@buoy-gg/shared-ui/web";p();p();var Be=Symbol.for("buoy.assets.globalState.v1");function g(){let e=globalThis;return e[Be]||(e[Be]={records:[],byKey:new Map,byId:new Map,nextId:1,listeners:new Set,snapshot:[],emitScheduled:false,installed:false,patched:false,registryAvailable:false,graphSupported:false,graphCount:null,graphError:null,graphFetchInFlight:false,lastScanAt:null,measuring:false,measuredCount:0,fontFamilies:[],localAssetCount:null,baseline:null,baselineLoaded:false,captureDisabled:false,remoteDispatch:null,mirrorScanStatus:null,mirrorPixelRatio:null,mirrorDiff:null}),e[Be]}p();p();function ht(e){if(!e)return false;let t=e;try{t=decodeURIComponent(t)}catch{}return t=t.replace(/\\/g,"/"),/(?:^|\/)node_modules\/@buoy-gg\/[^/]+(?:\/|$)/.test(t)||/(?:^|\/)buoy-packages\/packages\/[^/]+(?:\/|$)/.test(t)||/(?:^|\/)packages\/floating-tools-core\/(?:src|lib\/(?:module|commonjs))\/icons\/assets(?:\/|$)/.test(t)}function Ys(e){return[e.key,e.httpServerLocation,e.fileSystemLocation,...e.files??[]].some(ht)}p();function pt(){let e=g().mirrorPixelRatio;if(e!=null)return e;try{return(E(),Ze(ne)).PixelRatio.get()}catch{return 2}}function Qs(e,t){if(!e.length)return 1;let s=[...e].sort((a,r)=>a-r);for(let a of s)if(a>=t)return a;return s[s.length-1]}function Zs(){let e=g();e.emitScheduled||(e.emitScheduled=true,requestAnimationFrame(()=>{e.emitScheduled=false;for(let t of e.listeners)t()}))}function A(){let e=g();e.snapshot=[...e.records],Zs()}var Xs={png:"image",jpg:"image",jpeg:"image",gif:"image",webp:"image",bmp:"image",psd:"image",svg:"image",tiff:"image",ktx:"image",heic:"image",heif:"image",avif:"image",ttf:"font",otf:"font",woff:"font",woff2:"font",ttc:"font",mp4:"video",m4v:"video",mov:"video",mpeg:"video",mpg:"video",webm:"video",avi:"video",mp3:"audio",wav:"audio",aac:"audio",aiff:"audio",caf:"audio",m4a:"audio",ogg:"audio",json:"data",db:"data",yaml:"data",yml:"data",xml:"data",html:"data",pdf:"data",zip:"data"};function ea(e){return Xs[e.toLowerCase()]??"other"}function ta(e){if(Ys(e))return;let t=g(),s=t.byKey.get(e.key);return s||(s={id:t.nextId++,key:e.key,name:e.name,type:e.type,kind:ea(e.type),scales:e.scales??[],loaded:e.loaded??false,origin:e.origin,firstSeenAt:Date.now()},t.records.push(s),t.byKey.set(s.key,s),t.byId.set(s.id,s)),e.registryId!=null&&(s.registryId=e.registryId),e.hash!=null&&(s.hash=e.hash),e.httpServerLocation!=null&&(s.httpServerLocation=e.httpServerLocation),e.width!=null&&(s.width=e.width),e.height!=null&&(s.height=e.height),e.scales&&e.scales.length&&(s.scales=[...new Set(e.scales)].sort((a,r)=>a-r)),e.resolvedUri!=null&&(s.resolvedUri=e.resolvedUri),e.resolvedScale!=null&&(s.resolvedScale=e.resolvedScale),e.loaded&&(s.loaded=true),e.fileSystemLocation!=null&&(s.fileSystemLocation=e.fileSystemLocation),e.files&&(s.files=e.files),e.fileHashes&&(s.fileHashes=e.fileHashes),A(),s}function ie(e,t){let s=g().byId.get(e);if(s)return Object.assign(s,t),A(),s}function ke(e){return g().byId.get(e)}function F(){return g().snapshot}function le(e){return g().listeners.add(e),()=>g().listeners.delete(e)}function $e(){let e=g();e.records=[],e.byKey=new Map,e.byId=new Map,e.measuredCount=0,e.graphCount=null,A()}function x(e){if(e.kind!=="image"||!e.width||!e.height)return 0;let t=e.resolvedScale??Qs(e.scales,pt());return Math.round(e.width*t*e.height*t*4)}function De(e){let t=g(),s={image:{count:0,bytes:0},font:{count:0,bytes:0},video:{count:0,bytes:0},audio:{count:0,bytes:0},data:{count:0,bytes:0},other:{count:0,bytes:0}},a={total:e.length,loaded:0,neverLoaded:0,byKind:s,totalBytes:0,measuredCount:0,fontFamilies:t.fontFamilies.length};for(let r of e)r.loaded?a.loaded++:a.neverLoaded++,s[r.kind].count++,r.sizeBytes!=null&&r.sizeSource==="measured"&&(s[r.kind].bytes+=r.sizeBytes,a.totalBytes+=r.sizeBytes,a.measuredCount++);return a}p();var J=[];function gt(e){J=e,typeof document<"u"&&de()}function yt(){return J}async function sa(e){let t=await fetch(e);if(!t.ok)throw new Error(`Asset manifest returned HTTP ${t.status}.`);let s=await t.json();if(!Array.isArray(s)||s.some(a=>!a||typeof a.url!="string"))throw new Error("An asset manifest must contain an array of assets with URL strings.");gt(s)}function Ae(e,t){let s;try{s=new URL(e.url,document.baseURI)}catch{return}let a=s.pathname.split("/").pop()??"",r=a.includes(".")?a.split(".").pop().toLowerCase():"other",n=ta({key:s.href,name:a.slice(0,-(r.length+1))||a,type:r,origin:t?"browser":"graph",resolvedUri:s.href,resolvedScale:1,scales:[1],hash:e.hash,loaded:t,width:e.width,height:e.height});n&&e.bytes!==void 0&&e.bytes>=0&&ie(n.id,{sizeBytes:e.bytes,sizesByScale:{1:e.bytes},sizeSource:"measured"})}function ft(e){e.initiatorType==="fetch"||e.initiatorType==="xmlhttprequest"||Ae({url:e.name,bytes:e.encodedBodySize>0?e.encodedBodySize:void 0},true)}function de(){if(typeof document>"u"||g().captureDisabled)return;J.forEach(t=>Ae(t,false)),performance.getEntriesByType("resource").forEach(t=>ft(t)),document.querySelectorAll("img").forEach(t=>{!t.closest("[data-buoy-root]")&&t.currentSrc&&Ae({url:t.currentSrc,width:t.naturalWidth||void 0,height:t.naturalHeight||void 0},t.complete&&t.naturalWidth>0)});let e=g();e.graphSupported=J.length>0,e.graphCount=J.length>0?J.length:null,e.measuredCount=e.records.filter(t=>t.sizeBytes!==void 0).length,e.lastScanAt=Date.now()}p();function Fe(){if(typeof document>"u"||!document.fonts)return[];let e=new Set;return document.fonts.forEach(t=>{t.status==="loaded"&&e.add(t.family.replace(/^['"]|['"]$/g,""))}),[...e].sort()}function aa(){return null}var Y;function ce(){let e=g();if(!(typeof document>"u"||e.captureDisabled||e.installed)){if(e.installed=true,e.registryAvailable=true,typeof PerformanceObserver<"u"){Y=new PerformanceObserver(t=>{if(g().captureDisabled){mt();return}t.getEntries().forEach(s=>ft(s))});try{Y.observe({type:"resource",buffered:true}),e.patched=true}catch{Y.disconnect(),Y=void 0}}de(),e.fontFamilies=Fe(),A()}}function mt(){Y?.disconnect(),Y=void 0,g().installed=false,g().patched=false}async function ue(){return ce(),de(),g().fontFamilies=Fe(),A(),Q()}function Q(){let e=g();return e.mirrorScanStatus??{registryAvailable:e.registryAvailable,patched:e.patched,registryCount:e.records.filter(t=>t.loaded).length,graphSupported:e.graphSupported,graphCount:e.graphCount,graphError:null,graphFetchInFlight:false,graphFetchStartedAt:null,lastScanAt:e.lastScanAt,measuring:false,measuredCount:e.measuredCount,fontFamilies:e.fontFamilies,localAssetCount:null,browser:true}}p();p();function D(e){return e==null||e<=0?"\u2014":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(2)} MB`}function he(e){let t=[...new Set(e)].sort((s,a)=>s-a);return t.length?t.length===1?`@${t[0]}x`:t.length<=3?t.map(s=>`@${s}x`).join(" "):`@${t[0]}x\u2013@${t[t.length-1]}x`:"\u2014"}function pe(e){return e.width==null||e.height==null?"\u2014":`${Math.round(e.width)}\xD7${Math.round(e.height)}`}function ra(e,t){return e.sizeBytes!=null&&e.sizeSource==="measured"?D(e.sizeBytes):t>0?`~${D(t)}`:"\u2014"}var bt={image:"IMG",font:"FONT",video:"VID",audio:"AUD",data:"DATA",other:"MISC"},vt={image:"#2DD4BF",font:"#C084FC",video:"#FF9F1C",audio:"#FF3366",data:"#00D4FF",other:"#8E8E93"};function St(e){let t=[`# Asset: ${e.name}.${e.type}`,"",`- Kind: ${e.kind}`,`- Status: ${e.loaded?"loaded at runtime":"not observed in the runtime registry"}`];e.kind==="image"&&t.push(`- Dimensions: ${pe(e)} (logical)`),e.scales.length&&t.push(`- Scales: ${he(e.scales)}`),e.sizeBytes!=null&&e.sizeSource==="measured"&&t.push(`- Size (all variants): ${D(e.sizeBytes)}`);let s=x(e);return s>0&&t.push(`- Decoded memory: ~${D(s)}`),e.hash&&t.push(`- Hash: ${e.hash}`),e.httpServerLocation&&t.push(`- Location: ${e.httpServerLocation}`),e.fileSystemLocation&&t.push(`- Source dir: ${e.fileSystemLocation}`),e.resolvedUri&&t.push(`- Resolved URI: ${e.resolvedUri}`),t.join(`
|
|
1
|
+
"use client";var we=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var Zt=Object.getOwnPropertyNames;var Xt=Object.prototype.hasOwnProperty;var Qe=(e,t)=>()=>(e&&(t=e(e=0)),t);var es=(e,t)=>{for(var s in t)we(e,s,{get:t[s],enumerable:true})},xe=(e,t,s,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Zt(t))!Xt.call(e,r)&&r!==s&&we(e,r,{get:()=>t[r],enumerable:!(a=Qt(t,r))||a.enumerable});return e},ts=(e,t,s)=>(xe(e,t,"default"),s&&xe(s,t,"default"));var Ze=e=>xe(we({},"__esModule",{value:true}),e);var ss,p=Qe(()=>{"use strict";ss=(()=>{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)});var ne={};es(ne,{AccessibilityInfo:()=>os,ActivityIndicator:()=>Be,Alert:()=>lt,Animated:()=>is,AppRegistry:()=>ds,AppState:()=>cs,Appearance:()=>ls,BackHandler:()=>us,Button:()=>ot,CheckBox:()=>Is,Clipboard:()=>hs,DeviceEventEmitter:()=>Ns,Dimensions:()=>ps,Easing:()=>gs,FlatList:()=>Xe,I18nManager:()=>ys,Image:()=>et,ImageBackground:()=>ks,InteractionManager:()=>ms,Keyboard:()=>fs,KeyboardAvoidingView:()=>$s,LayoutAnimation:()=>bs,Linking:()=>vs,LogBox:()=>js,Modal:()=>rt,NativeEventEmitter:()=>Ss,NativeModules:()=>ns,PanResponder:()=>ws,Picker:()=>Ds,PixelRatio:()=>xs,Platform:()=>oe,Pressable:()=>at,ProgressBar:()=>As,RefreshControl:()=>Fs,SafeAreaView:()=>Ts,ScrollView:()=>Ce,SectionList:()=>Ls,Share:()=>zs,StatusBar:()=>Es,StyleSheet:()=>O,Switch:()=>nt,Text:()=>m,TextInput:()=>ze,Touchable:()=>Rs,TouchableHighlight:()=>tt,TouchableNativeFeedback:()=>Ms,TouchableOpacity:()=>H,TouchableWithoutFeedback:()=>st,UIManager:()=>Cs,Vibration:()=>Bs,View:()=>y,VirtualizedList:()=>Os,YellowBox:()=>Ps,findNodeHandle:()=>it,unstable_createElement:()=>rs,useColorScheme:()=>Hs,useLocaleContext:()=>Vs,useWindowDimensions:()=>Ws});import*as as from"react-native-web";import{unstable_createElement as rs,NativeModules as ns,AccessibilityInfo as os,Animated as is,Appearance as ls,AppRegistry as ds,AppState as cs,BackHandler as us,Clipboard as hs,Dimensions as ps,Easing as gs,I18nManager as ys,Keyboard as fs,InteractionManager as ms,LayoutAnimation as bs,Linking as vs,NativeEventEmitter as Ss,PanResponder as ws,PixelRatio as xs,Platform as oe,Share as zs,StyleSheet as O,UIManager as Cs,Vibration as Bs,CheckBox as Is,FlatList as Xe,Image as et,ImageBackground as ks,KeyboardAvoidingView as $s,Picker as Ds,ProgressBar as As,RefreshControl as Fs,SafeAreaView as Ts,SectionList as Ls,StatusBar as Es,Touchable as Rs,TouchableNativeFeedback as Ms,VirtualizedList as Os,YellowBox as Ps,LogBox as js,DeviceEventEmitter as Ns,useColorScheme as Hs,useLocaleContext as Vs,useWindowDimensions as Ws}from"react-native-web";import*as B from"react-native-web";import{createElement as Us,forwardRef as Gs}from"react";function $(e){let t=Gs((a,r)=>{let{accessibilityState:n,accessibilityValue:o,...i}=a;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,l]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))o?.[d]!==void 0&&i[`aria-${l}`]===void 0&&(i[`aria-${l}`]=o[d]);return Us(e,{...i,ref:r})}),s=e.State;return s&&Object.assign(t,{State:s}),t.displayName=e.displayName??e.name??"NativeWebView",t}var y,m,ze,H,tt,st,at,Ce,rt,nt,Be,ot,it,lt,E=Qe(()=>{p();ts(ne,as);y=$(B.View),m=$(B.Text),ze=$(B.TextInput),H=$(B.TouchableOpacity),tt=$(B.TouchableHighlight),st=$(B.TouchableWithoutFeedback),at=$(B.Pressable),Ce=$(B.ScrollView),rt=$(B.Modal),nt=$(B.Switch),Be=$(B.ActivityIndicator),ot=$(B.Button),it=B.findNodeHandle,lt={alert(e,t,s,a){if(typeof document>"u")return;let r=document.createElement("dialog");r.dataset.buoyRoot="",r.setAttribute("aria-label",e),r.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",r.appendChild(n),t){let l=document.createElement("p");l.textContent=t,l.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",r.appendChild(l)}let o=document.createElement("div");o.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let i=s?.length?s:[{text:"OK"}],d=()=>{r.close?.(),r.remove()};for(let l of i){let c=document.createElement("button");c.type="button",c.textContent=l.text??"OK",c.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${l.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,c.onclick=()=>{d(),l.onPress?.()},o.appendChild(c)}r.addEventListener("cancel",l=>{l.preventDefault(),a?.cancelable!==false&&(d(),a?.onDismiss?.())}),r.appendChild(o),document.body.appendChild(r),r.showModal?r.showModal():r.setAttribute("open","")}}});p();p();p();import{AssetsIcon as dt,ASSETS_ICON_COLOR as ct}from"@buoy-gg/shared-ui/web";p();E();import{useEffect as ut,useState as te}from"react";import{EventStepperFooter as Ks,JsModal as _s,macOSColors as qs,night as R,windowDragProps as Js,ToolEmptyState as Ys}from"@buoy-gg/shared-ui/web";p();p();var Ie=Symbol.for("buoy.assets.globalState.v1");function g(){let e=globalThis;return e[Ie]||(e[Ie]={records:[],byKey:new Map,byId:new Map,nextId:1,listeners:new Set,snapshot:[],emitScheduled:false,installed:false,patched:false,registryAvailable:false,graphSupported:false,graphCount:null,graphError:null,graphFetchInFlight:false,lastScanAt:null,measuring:false,measuredCount:0,fontFamilies:[],localAssetCount:null,baseline:null,baselineLoaded:false,captureDisabled:false,remoteDispatch:null,mirrorScanStatus:null,mirrorPixelRatio:null,mirrorDiff:null}),e[Ie]}p();p();function ht(e){if(!e)return false;let t=e;try{t=decodeURIComponent(t)}catch{}return t=t.replace(/\\/g,"/"),/(?:^|\/)node_modules\/@buoy-gg\/[^/]+(?:\/|$)/.test(t)||/(?:^|\/)buoy-packages\/packages\/[^/]+(?:\/|$)/.test(t)||/(?:^|\/)packages\/floating-tools-core\/(?:src|lib\/(?:module|commonjs))\/icons\/assets(?:\/|$)/.test(t)}function Qs(e){return[e.key,e.httpServerLocation,e.fileSystemLocation,...e.files??[]].some(ht)}p();function pt(){let e=g().mirrorPixelRatio;if(e!=null)return e;try{return(E(),Ze(ne)).PixelRatio.get()}catch{return 2}}function Zs(e,t){if(!e.length)return 1;let s=[...e].sort((a,r)=>a-r);for(let a of s)if(a>=t)return a;return s[s.length-1]}function Xs(){let e=g();e.emitScheduled||(e.emitScheduled=true,requestAnimationFrame(()=>{e.emitScheduled=false;for(let t of e.listeners)t()}))}function A(){let e=g();e.snapshot=[...e.records],Xs()}var ea={png:"image",jpg:"image",jpeg:"image",gif:"image",webp:"image",bmp:"image",psd:"image",svg:"image",tiff:"image",ktx:"image",heic:"image",heif:"image",avif:"image",ttf:"font",otf:"font",woff:"font",woff2:"font",ttc:"font",mp4:"video",m4v:"video",mov:"video",mpeg:"video",mpg:"video",webm:"video",avi:"video",mp3:"audio",wav:"audio",aac:"audio",aiff:"audio",caf:"audio",m4a:"audio",ogg:"audio",json:"data",db:"data",yaml:"data",yml:"data",xml:"data",html:"data",pdf:"data",zip:"data"};function ta(e){return ea[e.toLowerCase()]??"other"}function sa(e){if(Qs(e))return;let t=g(),s=t.byKey.get(e.key);return s||(s={id:t.nextId++,key:e.key,name:e.name,type:e.type,kind:ta(e.type),scales:e.scales??[],loaded:e.loaded??false,origin:e.origin,firstSeenAt:Date.now()},t.records.push(s),t.byKey.set(s.key,s),t.byId.set(s.id,s)),e.registryId!=null&&(s.registryId=e.registryId),e.hash!=null&&(s.hash=e.hash),e.httpServerLocation!=null&&(s.httpServerLocation=e.httpServerLocation),e.width!=null&&(s.width=e.width),e.height!=null&&(s.height=e.height),e.scales&&e.scales.length&&(s.scales=[...new Set(e.scales)].sort((a,r)=>a-r)),e.resolvedUri!=null&&(s.resolvedUri=e.resolvedUri),e.resolvedScale!=null&&(s.resolvedScale=e.resolvedScale),e.loaded&&(s.loaded=true),e.fileSystemLocation!=null&&(s.fileSystemLocation=e.fileSystemLocation),e.files&&(s.files=e.files),e.fileHashes&&(s.fileHashes=e.fileHashes),A(),s}function ie(e,t){let s=g().byId.get(e);if(s)return Object.assign(s,t),A(),s}function ke(e){return g().byId.get(e)}function F(){return g().snapshot}function le(e){return g().listeners.add(e),()=>g().listeners.delete(e)}function $e(){let e=g();e.records=[],e.byKey=new Map,e.byId=new Map,e.measuredCount=0,e.graphCount=null,A()}function x(e){if(e.kind!=="image"||!e.width||!e.height)return 0;let t=e.resolvedScale??Zs(e.scales,pt());return Math.round(e.width*t*e.height*t*4)}function De(e){let t=g(),s={image:{count:0,bytes:0},font:{count:0,bytes:0},video:{count:0,bytes:0},audio:{count:0,bytes:0},data:{count:0,bytes:0},other:{count:0,bytes:0}},a={total:e.length,loaded:0,neverLoaded:0,byKind:s,totalBytes:0,measuredCount:0,fontFamilies:t.fontFamilies.length};for(let r of e)r.loaded?a.loaded++:a.neverLoaded++,s[r.kind].count++,r.sizeBytes!=null&&r.sizeSource==="measured"&&(s[r.kind].bytes+=r.sizeBytes,a.totalBytes+=r.sizeBytes,a.measuredCount++);return a}p();var J=[];function gt(e){J=e,typeof document<"u"&&de()}function yt(){return J}async function aa(e){let t=await fetch(e);if(!t.ok)throw new Error(`Asset manifest returned HTTP ${t.status}.`);let s=await t.json();if(!Array.isArray(s)||s.some(a=>!a||typeof a.url!="string"))throw new Error("An asset manifest must contain an array of assets with URL strings.");gt(s)}function Ae(e,t){let s;try{s=new URL(e.url,document.baseURI)}catch{return}let a=s.pathname.split("/").pop()??"",r=a.includes(".")?a.split(".").pop().toLowerCase():"other",n=sa({key:s.href,name:a.slice(0,-(r.length+1))||a,type:r,origin:t?"browser":"graph",resolvedUri:s.href,resolvedScale:1,scales:[1],hash:e.hash,loaded:t,width:e.width,height:e.height});n&&e.bytes!==void 0&&e.bytes>=0&&ie(n.id,{sizeBytes:e.bytes,sizesByScale:{1:e.bytes},sizeSource:"measured"})}function ft(e){e.initiatorType==="fetch"||e.initiatorType==="xmlhttprequest"||Ae({url:e.name,bytes:e.encodedBodySize>0?e.encodedBodySize:void 0},true)}function de(){if(typeof document>"u"||g().captureDisabled)return;J.forEach(t=>Ae(t,false)),performance.getEntriesByType("resource").forEach(t=>ft(t)),document.querySelectorAll("img").forEach(t=>{!t.closest("[data-buoy-root]")&&t.currentSrc&&Ae({url:t.currentSrc,width:t.naturalWidth||void 0,height:t.naturalHeight||void 0},t.complete&&t.naturalWidth>0)});let e=g();e.graphSupported=J.length>0,e.graphCount=J.length>0?J.length:null,e.measuredCount=e.records.filter(t=>t.sizeBytes!==void 0).length,e.lastScanAt=Date.now()}p();function Fe(){if(typeof document>"u"||!document.fonts)return[];let e=new Set;return document.fonts.forEach(t=>{t.status==="loaded"&&e.add(t.family.replace(/^['"]|['"]$/g,""))}),[...e].sort()}function ra(){return null}var Y;function ce(){let e=g();if(!(typeof document>"u"||e.captureDisabled||e.installed)){if(e.installed=true,e.registryAvailable=true,typeof PerformanceObserver<"u"){Y=new PerformanceObserver(t=>{if(g().captureDisabled){mt();return}t.getEntries().forEach(s=>ft(s))});try{Y.observe({type:"resource",buffered:true}),e.patched=true}catch{Y.disconnect(),Y=void 0}}de(),e.fontFamilies=Fe(),A()}}function mt(){Y?.disconnect(),Y=void 0,g().installed=false,g().patched=false}async function ue(){return ce(),de(),g().fontFamilies=Fe(),A(),Q()}function Q(){let e=g();return e.mirrorScanStatus??{registryAvailable:e.registryAvailable,patched:e.patched,registryCount:e.records.filter(t=>t.loaded).length,graphSupported:e.graphSupported,graphCount:e.graphCount,graphError:null,graphFetchInFlight:false,graphFetchStartedAt:null,lastScanAt:e.lastScanAt,measuring:false,measuredCount:e.measuredCount,fontFamilies:e.fontFamilies,localAssetCount:null,browser:true}}p();p();function D(e){return e==null||e<=0?"\u2014":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(2)} MB`}function he(e){let t=[...new Set(e)].sort((s,a)=>s-a);return t.length?t.length===1?`@${t[0]}x`:t.length<=3?t.map(s=>`@${s}x`).join(" "):`@${t[0]}x\u2013@${t[t.length-1]}x`:"\u2014"}function pe(e){return e.width==null||e.height==null?"\u2014":`${Math.round(e.width)}\xD7${Math.round(e.height)}`}function na(e,t){return e.sizeBytes!=null&&e.sizeSource==="measured"?D(e.sizeBytes):t>0?`~${D(t)}`:"\u2014"}var bt={image:"IMG",font:"FONT",video:"VID",audio:"AUD",data:"DATA",other:"MISC"},vt={image:"#2DD4BF",font:"#C084FC",video:"#FF9F1C",audio:"#FF3366",data:"#00D4FF",other:"#8E8E93"};function St(e){let t=[`# Asset: ${e.name}.${e.type}`,"",`- Kind: ${e.kind}`,`- Status: ${e.loaded?"loaded at runtime":"not observed in the runtime registry"}`];e.kind==="image"&&t.push(`- Dimensions: ${pe(e)} (logical)`),e.scales.length&&t.push(`- Scales: ${he(e.scales)}`),e.sizeBytes!=null&&e.sizeSource==="measured"&&t.push(`- Size (all variants): ${D(e.sizeBytes)}`);let s=x(e);return s>0&&t.push(`- Decoded memory: ~${D(s)}`),e.hash&&t.push(`- Hash: ${e.hash}`),e.httpServerLocation&&t.push(`- Location: ${e.httpServerLocation}`),e.fileSystemLocation&&t.push(`- Source dir: ${e.fileSystemLocation}`),e.resolvedUri&&t.push(`- Resolved URI: ${e.resolvedUri}`),t.join(`
|
|
2
2
|
`)}function wt(e,t,s,a,r){let n=["# Asset inventory","",`${t.total} assets \xB7 ${t.loaded} loaded \xB7 ${t.neverLoaded} not observed`+(t.totalBytes>0?` \xB7 ${D(t.totalBytes)} measured (${t.measuredCount}/${t.total})`:"")];if(a.fontFamilies.length&&n.push(`Fonts loaded: ${a.fontFamilies.join(", ")}`),a.graphSupported||n.push(a.graphError?`_Metro bundle graph unavailable (${a.graphError}) \u2014 runtime-registered assets only._`:"_No Metro bundle graph \u2014 runtime-registered assets only (release build)._"),r){let i=r.netBytes!=null?`${r.netBytes>=0?"+":"\u2212"}${D(Math.abs(r.netBytes))} net`:"net size unknown";n.push("",`## Since baseline (${new Date(r.baselineSavedAt).toISOString()})`,`- ${r.added.length} added \xB7 ${r.removed.length} removed \xB7 ${r.grown.length} grew \xB7 ${i}`);for(let d of r.removed.slice(0,20))n.push(`- removed: ${d.name}.${d.type}`)}let o=[];s.neverLoaded.length&&o.push(`- ${s.neverLoaded.length} shipped but not observed`),s.duplicates.length&&o.push(`- ${s.duplicates.length} duplicate content groups`),s.webpCandidates.length&&o.push(`- ${s.webpCandidates.length} WebP conversion candidates`),s.scaleGaps.length&&o.push(`- ${s.scaleGaps.length} scale-coverage gaps`),s.overDecode.length&&o.push(`- ${s.overDecode.length} images decoding larger than 2\xD7 the screen`),s.heavyGifs.length&&o.push(`- ${s.heavyGifs.length} heavy GIFs (convert to video/Lottie)`),s.heavyFonts.length&&o.push(`- ${s.heavyFonts.length} heavy fonts (subset candidates)`),s.scaleAnomalies.length&&o.push(`- ${s.scaleAnomalies.length} scale-variant anomalies (check exports)`),o.length&&n.push("","## Findings",...o),n.push("","## Assets (largest first)","","| Asset | Kind | Dimensions | Scales | Size | Loaded |","| --- | --- | --- | --- | --- | --- |");for(let i of e){let d=i.sizeBytes!=null&&i.sizeSource==="measured"?D(i.sizeBytes):x(i)>0?`~${D(x(i))}`:"\u2014";n.push(`| ${i.name}.${i.type} | ${i.kind} | ${i.kind==="image"?pe(i):"\u2014"} | ${he(i.scales)} | ${d} | ${i.loaded?"yes":"NO"} |`)}return n.join(`
|
|
3
|
-
`)}p();import{useMemo as na,useSyncExternalStore as oa}from"react";p();var ia=50*1024,la=100*1024,da=150*1024,ca=2,ua=.9,ha=4*1024;function pa(){try{let{Dimensions:e,PixelRatio:t}=(E(),Ze(ne)),s=e.get("screen"),a=t.get();return s.width*a*s.height*a}catch{return 1170*2532}}function ga(e){let t=e.sizesByScale;if(!t)return false;let s=Object.entries(t).map(([a,r])=>({scale:Number(a),bytes:r})).filter(a=>Number.isFinite(a.scale)&&a.bytes>0).sort((a,r)=>a.scale-r.scale);for(let a=1;a<s.length;a++)if(s[a-1].bytes>=ha&&s[a].bytes<s[a-1].bytes*ua)return true;return false}function Te(e){let t=pt(),s=new Map;for(let h of e){if(!h.hash)continue;let k=s.get(h.hash);k?k.push(h):s.set(h.hash,[h])}let a=[];for(let[h,k]of s){if(k.length<2)continue;let K=k.find(z=>z.sizeBytes!=null);a.push({hash:h,ids:k.map(z=>z.id),wastedBytes:K?.sizeBytes!=null?K.sizeBytes*(k.length-1):null})}let r=pa(),n=[],o=[],i=[],d=[],l=[],c=[],f=[];for(let h of e)h.loaded||i.push(h.id),h.kind==="image"&&h.scales.length>1&&!h.scales.some(k=>k>=t)&&n.push(h.id),(h.type==="png"||h.type==="jpg"||h.type==="jpeg")&&h.sizeBytes!=null&&h.sizeBytes>=ia&&o.push(h.id),h.kind==="image"&&x(h)/4>r*ca&&d.push(h.id),h.type==="gif"&&(h.sizeBytes??0)>=la&&l.push(h.id),h.kind==="font"&&(h.sizeBytes??0)>=da&&c.push(h.id),ga(h)&&f.push(h.id);return{duplicates:a,scaleGaps:n,webpCandidates:o,neverLoaded:i,overDecode:d,heavyGifs:l,heavyFonts:c,scaleAnomalies:f}}function xt(){let e=oa(le,F,F);return na(()=>({records:e,stats:De(e),insights:Te(e)}),[e])}p();import{useSyncExternalStore as ya}from"react";var zt,Ct;function It(){let e=F();return e!==zt&&(zt=e,Ct=Q()),Ct}function fa(){return ya(le,It,It)}p();function ma(e){g().remoteDispatch=e}function ge(){return g().remoteDispatch}function ba(){g().captureDisabled=true}function va(e){let t=g(),s=e.records??[];t.records=s.map(a=>({id:a.id,key:a.key,registryId:a.registryId??void 0,name:a.name,type:a.type,kind:a.kind,hash:a.hash??void 0,httpServerLocation:a.location??void 0,width:a.width??void 0,height:a.height??void 0,scales:a.scales,resolvedUri:a.uri??void 0,loaded:a.loaded,origin:a.registryId!=null?"registry":"graph",sizeBytes:a.sizeBytes??void 0,sizeSource:a.sizeSource??void 0,firstSeenAt:Date.now()})),t.byKey=new Map(t.records.map(a=>[a.key,a])),t.byId=new Map(t.records.map(a=>[a.id,a])),e.scanStatus&&(t.fontFamilies=[...new Set(e.scanStatus.fontFamilies??[])],t.mirrorScanStatus={...e.scanStatus,fontFamilies:t.fontFamilies}),t.mirrorDiff=e.diff??null,A()}p();import{persistentStorage as Le}from"@buoy-gg/shared-ui/web";var Ee="@react_buoy/assets/baseline",Sa=1024;async function Bt(){let e=g();if(e.baselineLoaded)return e.baseline;e.baselineLoaded=true;try{let t=await Le.getItem(Ee);if(t){let s=JSON.parse(t);s&&typeof s.savedAt=="number"&&s.entries&&(e.baseline=s,A())}}catch{}return e.baseline}async function kt(){let e=ge();if(e)return await e("saveBaseline"),g().baseline??{savedAt:Date.now(),entries:{}};let t=g(),s={};for(let r of F())s[r.key]={hash:r.hash??null,sizeBytes:r.sizeSource==="measured"?r.sizeBytes??null:null,name:r.name,type:r.type};let a={savedAt:Date.now(),entries:s};t.baseline=a,t.baselineLoaded=true,A();try{await Le.setItem(Ee,JSON.stringify(a))}catch{}return a}async function $t(){let e=ge();if(e){await e("clearBaseline");return}let t=g();t.baseline=null,t.baselineLoaded=true,A();try{await Le.removeItem(Ee)}catch{}}function Dt(e,t){let s=[],a=[],r=new Set,n=0,o=0,i=false;for(let l of e){r.add(l.key);let c=t.entries[l.key];if(!c){s.push(l.id);continue}let f=l.sizeSource==="measured"?l.sizeBytes??null:null;f!=null&&c.sizeBytes!=null&&(i=true,n+=f,o+=c.sizeBytes,f-c.sizeBytes>=Sa&&a.push({id:l.id,deltaBytes:f-c.sizeBytes}))}let d=[];for(let[l,c]of Object.entries(t.entries))ht(l)||r.has(l)||(d.push({key:l,name:c.name,type:c.type}),c.sizeBytes!=null&&(i=true,o+=c.sizeBytes));for(let l of s){let c=e.find(f=>f.id===l);c?.sizeSource==="measured"&&c.sizeBytes!=null&&(i=true,n+=c.sizeBytes)}return{baselineSavedAt:t.savedAt,added:s,removed:d,grown:a.sort((l,c)=>c.deltaBytes-l.deltaBytes),netBytes:i?n-o:null}}function ye(){let e=g();return e.mirrorDiff?e.mirrorDiff:e.baseline?Dt(F(),e.baseline):null}p();E();import{night as V}from"@buoy-gg/shared-ui/web";p();E();import{useState as wa}from"react";import{night as xa}from"@buoy-gg/shared-ui/web";p();E();p();function At(){return null}async function za(){de();let e=yt().length;return e?{ok:true,count:e}:{ok:false,message:"Register a browser asset manifest to inspect files that have not loaded yet."}}var Ca=4;function Ia(e){if(e.resolvedUri)return e.resolvedUri;let t=Ft(e);return t.length?t[0].url:null}function Ba(e){let t=g().captureDisabled;if(!t&&e.registryId!=null)return e.registryId;let s=Ia(e);return!s||t&&!/^https?:\/\//.test(s)?null:{uri:s}}function Ft(e){let t=e.scales.length?e.scales:[1],s=e.resolvedUri;if(s&&/^https?:\/\//.test(s)&&e.resolvedScale!=null){let r=e.resolvedScale===1?"":`@${e.resolvedScale}x`,n=`${r}.${e.type}`;if(s.includes(n)||r==="")return t.map(o=>{let i=o===1?"":`@${o}x`,d=(r===""?s.replace(`.${e.type}`,`${i}.${e.type}`):s.replace(n,`${i}.${e.type}`)).replace(/ /g,"%20");return{scale:o,url:d}})}let a=At();return!a||!e.httpServerLocation?[]:t.map(r=>{let n=r===1?"":`@${r}x`,o=`${e.httpServerLocation}/${e.name}${n}.${e.type}`,i=o.includes("?")?"&":"?",d=`${a}${o}${i}platform=${ka()}${e.hash?`&hash=${e.hash}`:""}`.replace(/ /g,"%20");return{scale:r,url:d}})}function ka(){try{return oe.OS}catch{return"ios"}}async function $a(e){try{let t=await fetch(e,{method:"HEAD"});if(t.ok){let s=Number(t.headers.get("content-length"));if(Number.isFinite(s)&&s>0)return s}}catch{}try{let t=await fetch(e);if(!t.ok)return null;let s=await t.blob();return s.size>0?s.size:null}catch{return null}}async function Da(e){let t=Ft(e);if(!t.length){ie(e.id,{sizeSource:"estimate"});return}let s={},a=0;for(let{scale:r,url:n}of t){let o=await $a(n);o!=null&&(s[String(r)]=o,a+=o)}a>0?ie(e.id,{sizesByScale:s,sizeBytes:a,sizeSource:"measured"}):ie(e.id,{sizeSource:"estimate"})}async function Tt(){let e=g();if(e.measuring)return{measured:e.measuredCount,total:F().length};let t=F().filter(s=>s.sizeSource!=="measured");e.measuring=true,A();try{let s=0,a=async()=>{for(;;){let r=t[s++];if(!r)return;await Da(r),e.measuredCount=F().filter(n=>n.sizeSource==="measured").length}};await Promise.all(Array.from({length:Math.min(Ca,t.length)},a))}finally{e.measuring=false,A()}return{measured:e.measuredCount,total:F().length}}p();function Aa(){return null}import{jsx as fe}from"react/jsx-runtime";function Lt({record:e,style:t,testID:s,compact:a=false}){let r=Ba(e),n=e.type.toLowerCase()==="svg",o=n&&oe.OS!=="web"?Aa():null,i=`${e.key}:${e.hash??""}:${typeof r=="number"?r:r?.uri??""}`,[d,l]=wa(null);if(r==null||d===i||n&&oe.OS!=="web"&&!o){let f=n?"SVG preview unavailable":"Image preview unavailable";return fe(y,{style:[t,Et.fallback],accessibilityLabel:f,testID:`${s}-unavailable`,children:fe(m,{style:Et.text,children:a?n?"SVG":"IMG":f})})}let c=()=>l(i);return o?fe(o,{source:r,style:t,contentFit:"contain",onError:c,testID:s}):fe(et,{source:r,style:t,resizeMode:"contain",onError:c,testID:s})}var Et=O.create({fallback:{alignItems:"center",justifyContent:"center"},text:{color:xa.color.textSecondary,fontSize:10,textAlign:"center"}});p();function Z(e){return String(e).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function se(e,t){return`buoy-assets-row-${Z(`${e}.${t}`)}`}function Rt(e,t,s){return`${se(e,t)}-badge-${Z(s)}`}function Re(e){return`buoy-assets-filter-${Z(e)}`}function Mt(e){return`buoy-assets-detail-row-${Z(e)}`}function Ot(e){return`buoy-assets-font-${Z(e)}`}var b={title:"buoy-assets-title",copy:"buoy-assets-copy",clear:"buoy-assets-clear",list:"buoy-assets-list",search:"buoy-assets-search",sort:"buoy-assets-sort",filterBar:"buoy-assets-filter-bar",notice:"buoy-assets-notice",noticeText:"buoy-assets-notice-text",discoverySpinner:"buoy-assets-discovery-spinner",retry:"buoy-assets-retry",fonts:"buoy-assets-fonts",fontsTitle:"buoy-assets-fonts-title",empty:"buoy-assets-empty",emptyTitle:"buoy-assets-empty-title",emptyText:"buoy-assets-empty-text",detail:"buoy-assets-detail",detailScroll:"buoy-assets-detail-scroll",detailPreview:"buoy-assets-detail-preview",detailFontPreview:"buoy-assets-detail-font-preview",detailFindings:"buoy-assets-detail-findings"};function Pt(e){return`buoy-assets-detail-finding-${e}`}import{jsx as v,jsxs as jt}from"react/jsx-runtime";function B({label:e,value:t}){let s=Mt(e);return jt(y,{style:T.kvRow,testID:s,children:[v(m,{style:T.kvLabel,children:e}),v(m,{style:T.kvValue,selectable:true,testID:`${s}-value`,children:t})]})}function Fa({record:e}){return e.kind==="image"?v(y,{style:T.previewBox,testID:b.detailPreview,children:v(Lt,{testID:"buoy-internal-assets-preview",record:e,style:T.previewImage})}):e.kind==="font"?v(y,{style:T.previewBox,testID:b.detailFontPreview,children:v(m,{style:[T.fontPreview,{fontFamily:e.name}],children:"The quick brown fox jumps over the lazy dog 0123456789"})}):null}function Ta({record:e,insights:t}){let s=[];t.neverLoaded.includes(e.id)&&s.push("Not observed in the runtime registry this app run. This does not prove the asset is unused."),t.scaleGaps.includes(e.id)&&s.push("Scale gap \u2014 no variant covers this device's pixel ratio"),t.webpCandidates.includes(e.id)&&s.push("WebP candidate \u2014 large png/jpeg, converting typically saves 20\u201340%");let a=t.duplicates.find(n=>n.ids.includes(e.id));a&&s.push(`Duplicate content \u2014 identical bytes shipped ${a.ids.length} times`),t.overDecode.includes(e.id)&&s.push("Decodes larger than 2\xD7 this entire screen \u2014 resize the source, no view can need this many pixels"),t.heavyGifs.includes(e.id)&&s.push("Heavy GIF \u2014 every frame decodes into memory; a video or Lottie is typically ~90% smaller"),t.heavyFonts.includes(e.id)&&s.push("Heavy font \u2014 likely an unsubset icon font; subsetting to used glyphs usually saves most of it"),t.scaleAnomalies.includes(e.id)&&s.push("Scale anomaly \u2014 a higher-resolution variant is smaller in bytes than a lower one; check the exports");let r=x(e);return jt(Ce,{style:T.scroll,contentContainerStyle:T.content,testID:b.detailScroll,children:[v(Fa,{record:e}),s.length>0?v(y,{style:T.findings,testID:b.detailFindings,children:s.map((n,o)=>v(m,{style:T.findingText,testID:Pt(o),children:n},n))}):null,v(B,{label:"Name",value:`${e.name}.${e.type}`}),v(B,{label:"Kind",value:e.kind}),v(B,{label:"Status",value:e.loaded?"Loaded (registered at runtime)":"Not observed in the runtime registry"}),e.kind==="image"?v(B,{label:"Dimensions",value:`${pe(e)} (logical)`}):null,e.kind==="image"&&e.scales.length?v(B,{label:"Scales",value:he(e.scales)}):null,e.sizesByScale?Object.entries(e.sizesByScale).map(([n,o])=>v(B,{label:`Size @${n}x`,value:D(o)},n)):null,e.sizeBytes!=null&&e.sizeSource==="measured"?v(B,{label:"Total size",value:D(e.sizeBytes)}):null,r>0?v(B,{label:"Decoded memory",value:`~${D(r)} (RGBA)`}):null,e.registryId!=null?v(B,{label:"Registry id",value:String(e.registryId)}):null,e.hash?v(B,{label:"Hash",value:e.hash}):null,e.httpServerLocation?v(B,{label:"Location",value:e.httpServerLocation}):null,e.fileSystemLocation?v(B,{label:"Source dir",value:e.fileSystemLocation}):null,e.resolvedUri?v(B,{label:"Resolved URI",value:e.resolvedUri}):null]})}var T=O.create({scroll:{flex:1},content:{padding:12,gap:8},previewBox:{borderRadius:8,backgroundColor:V.color.bg,padding:12,alignItems:"center",justifyContent:"center",minHeight:96},previewImage:{width:"100%",height:140},fontPreview:{color:V.color.text,fontSize:16,textAlign:"center"},findings:{borderRadius:8,borderWidth:1,borderColor:V.color.border,backgroundColor:V.color.surface,padding:10,gap:6},findingText:{color:V.color.textSecondary,fontSize:11,lineHeight:15},kvRow:{gap:2},kvLabel:{color:V.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,textTransform:"uppercase"},kvValue:{color:V.color.text,fontSize:12}});p();E();import{macOSColors as Me,night as W,Pill as La}from"@buoy-gg/shared-ui/web";import{jsx as L,jsxs as U}from"react/jsx-runtime";function Ea({label:e,color:t,testID:s}){return L(La,{label:e,color:t,variant:"quiet",dot:!!t,style:{paddingVertical:2.5},testID:s})}function Ra({record:e,flags:t,sizeFraction:s,onPress:a}){let r=vt[e.kind],n=[];return e.loaded||n.push({label:"NOT OBSERVED"}),t.oversize&&n.push({label:"OVERSIZE",color:Me.semantic.error}),t.duplicate&&n.push({label:"DUP"}),t.heavy&&n.push({label:"HEAVY"}),t.scaleAnomaly?n.push({label:"BAD SCALE",color:Me.semantic.error}):t.scaleGap&&n.push({label:"LOW-RES"}),t.webp&&n.push({label:"WEBP",color:Me.semantic.info}),U(N,{style:w.card,testID:se(e.name,e.type),onPress:()=>a(e.id),activeOpacity:.7,children:[U(y,{style:w.body,children:[L(y,{style:w.thumbBox,children:e.kind==="image"?L(Lt,{testID:"buoy-internal-assets-thumb",record:e,style:w.thumb,compact:true}):L(m,{style:[w.thumbFallback,{color:r}],children:bt[e.kind]})}),U(y,{style:w.main,children:[U(m,{style:w.name,numberOfLines:1,testID:`${se(e.name,e.type)}-name`,children:[e.name,U(m,{style:w.ext,children:[".",e.type]})]}),U(y,{style:w.metaRow,children:[e.kind==="image"&&e.width!=null?L(m,{style:w.meta,children:pe(e)}):null,e.kind==="image"&&e.scales.length?L(m,{style:w.meta,children:he(e.scales)}):null]})]}),U(y,{style:w.right,children:[L(m,{style:w.size,testID:`${se(e.name,e.type)}-size`,children:ra(e,x(e))}),n.length?L(y,{style:w.badgeRow,children:n.slice(0,3).map(o=>L(Ea,{label:o.label,color:o.color,testID:Rt(e.name,e.type,o.label)},o.label))}):null]})]}),s>0?L(y,{style:w.sizeTrack,children:L(y,{style:[w.sizeFill,{backgroundColor:r,width:`${Math.max(2,Math.round(s*100))}%`}]})}):null]})}var w=O.create({card:{marginHorizontal:10,marginTop:6,borderRadius:10,backgroundColor:W.color.surface,borderWidth:1,borderColor:W.color.border,overflow:"hidden"},body:{flexDirection:"row",alignItems:"center",paddingVertical:8,paddingHorizontal:12,gap:10},thumbBox:{width:40,height:40,borderRadius:8,backgroundColor:"rgba(255,255,255,0.10)",borderWidth:1,borderColor:W.color.border,alignItems:"center",justifyContent:"center",overflow:"hidden"},thumb:{width:34,height:34},thumbFallback:{fontSize:9,fontWeight:"700",letterSpacing:.5},main:{flex:1,gap:3},name:{color:W.color.text,fontSize:12,fontWeight:"600"},ext:{color:W.color.textTertiary,fontWeight:"400"},metaRow:{flexDirection:"row",alignItems:"center",gap:8},meta:{color:W.color.textSecondary,fontSize:10,fontVariant:["tabular-nums"]},right:{alignItems:"flex-end",gap:4},size:{color:W.color.text,fontSize:12,fontWeight:"700",fontVariant:["tabular-nums"]},badgeRow:{flexDirection:"row",gap:4},sizeTrack:{height:2,backgroundColor:"transparent"},sizeFill:{height:2,opacity:.45,borderTopRightRadius:2}});p();E();import{night as me}from"@buoy-gg/shared-ui/web";import{jsx as Oe}from"react/jsx-runtime";function Ma({stats:e,duplicateCount:t,filter:s,onChange:a}){let r=[{key:"all",label:`ALL ${e.total}`,accent:me.color.textSecondary},{key:"duplicates",label:`DUPLICATES ${t}`,accent:"#FF9F1C"}];for(let n of Object.keys(e.byKind)){let o=e.byKind[n];o.count>0&&r.push({key:n,label:`${bt[n]} ${o.count}`,accent:vt[n]})}return e.neverLoaded>0&&r.push({key:"unused",label:`NOT OBSERVED ${e.neverLoaded}`,accent:"#FF9F1C"}),r.length<=1?null:Oe(y,{style:Pe.bar,testID:b.filterBar,children:r.map(n=>{let o=n.key===s;return Oe(N,{accessibilityRole:"button",accessibilityState:{selected:o},testID:Re(n.key),style:[Pe.chip,o&&{borderColor:n.accent,backgroundColor:`${n.accent}1A`}],onPress:()=>a(o?"all":n.key),children:Oe(m,{testID:`${Re(n.key)}-label`,style:[Pe.chipText,{color:o?n.accent:me.color.textSecondary}],children:n.label})},n.key)})})}var Pe=O.create({bar:{flexDirection:"row",flexWrap:"wrap",gap:6,paddingHorizontal:10,paddingVertical:8},chip:{borderWidth:1,borderColor:me.color.border,backgroundColor:me.color.surface,borderRadius:999,paddingHorizontal:10,paddingVertical:5},chipText:{fontSize:10,fontWeight:"700",letterSpacing:.4,lineHeight:13}});p();import{ModalHeader as P,ToolbarClearButton as Oa,ToolbarCopyButton as Ht}from"@buoy-gg/shared-ui/web";import{jsx as j,jsxs as je}from"react/jsx-runtime";function Pa({stats:e,measuring:t,discovering:s=false,detailOpen:a,detailIndex:r=-1,detailTotal:n=0,onCloseDetail:o,onClear:i,getReport:d,onBack:l}){if(a){let f=r>=0&&n>0?`${r+1} of ${n}`:void 0;return je(P,{children:[j(P.Navigation,{onBack:o}),j(P.Content,{title:"Asset detail",subtitle:f,testID:b.title}),j(P.Actions,{children:j(Ht,{value:d,testID:b.copy})})]})}let c=[`${e.total} assets${s?" so far":""}`];if(e.totalBytes>0&&!t&&!s){let f=e.measuredCount<e.total?"+":"";c.push(`${D(e.totalBytes)}${f}`)}return e.neverLoaded>0&&c.push(`${e.neverLoaded} not observed`),e.fontFamilies>0&&c.push(`${e.fontFamilies} fonts`),je(P,{children:[l?j(P.Navigation,{onBack:l}):null,j(P.Content,{title:"Assets",subtitle:c.join(" \xB7 "),testID:b.title}),je(P.Actions,{children:[j(Ht,{value:d,testID:b.copy}),j(Oa,{onPress:i,testID:b.clear})]})]})}p();E();import{night as G}from"@buoy-gg/shared-ui/web";import{jsx as Nt,jsxs as Vt}from"react/jsx-runtime";var ja={size:"name",name:"type",type:"size"};function Ha({query:e,onQueryChange:t,sort:s,onSortChange:a}){return Vt(y,{style:be.row,children:[Nt(ze,{style:be.input,value:e,onChangeText:t,placeholder:"Search assets\u2026",placeholderTextColor:G.color.placeholder,autoCapitalize:"none",autoCorrect:false,testID:b.search}),Nt(N,{style:be.button,onPress:()=>a(ja[s]),testID:b.sort,children:Vt(m,{style:be.buttonText,testID:`${b.sort}-label`,children:["\u2193 ",s.toUpperCase()]})})]})}var be=O.create({row:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:10,paddingBottom:8},input:{flex:1,backgroundColor:G.color.surfaceElevated,borderWidth:1,borderColor:G.color.border,borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:G.color.text,fontSize:12},button:{backgroundColor:G.color.surface,borderWidth:1,borderColor:G.color.border,borderRadius:8,paddingHorizontal:10,paddingVertical:7},buttonText:{color:G.color.textSecondary,fontSize:10,fontWeight:"700",letterSpacing:.5}});p();E();import{useEffect as Na,useState as Va}from"react";import{night as ae}from"@buoy-gg/shared-ui/web";import{jsx as ve,jsxs as Wa}from"react/jsx-runtime";function Ua({status:e,total:t,onRetry:s}){let[a,r]=Va(false);Na(()=>{if(r(false),!e.graphFetchInFlight)return;let i=e.graphFetchStartedAt==null?0:Math.max(0,Date.now()-e.graphFetchStartedAt),d=setTimeout(()=>r(true),Math.max(0,8e3-i));return()=>clearTimeout(d)},[e.graphFetchInFlight,e.graphFetchStartedAt]);let n=[];e.browser&&!e.graphSupported&&n.push("Showing resources this page has loaded. Add an asset manifest to include files the page has not requested."),e.graphFetchInFlight&&(n.push(`Finding assets\u2026 ${t} found so far.`),a&&n.push("Still finding assets. This is taking longer than usual.")),e.registryAvailable||n.push("The asset registry is unavailable in this environment."),!e.graphFetchInFlight&&!e.graphSupported&&e.graphError&&n.push("Showing runtime-registered assets only. A development server is needed to find more assets and measure their sizes.");let o=!e.graphFetchInFlight&&e.graphSupported&&!!e.graphError;return o&&n.push(`Couldn't finish finding assets. Showing ${t} assets found so far.`),e.measuring&&!e.graphFetchInFlight&&n.push("Checking asset sizes\u2026"),n.length===0?null:Wa(y,{style:He.notice,testID:b.notice,children:[e.graphFetchInFlight?ve(Ie,{size:"small",color:ae.color.textSecondary,accessibilityLabel:"Finding assets",testID:b.discoverySpinner}):null,n.map(i=>ve(m,{style:He.noticeText,testID:b.noticeText,children:i},i)),o?ve(N,{accessibilityRole:"button",onPress:s,testID:b.retry,children:ve(m,{style:He.retryText,children:"Retry"})}):null]})}var He=O.create({notice:{marginHorizontal:10,marginBottom:8,padding:10,borderRadius:8,borderWidth:1,borderColor:ae.color.border,backgroundColor:ae.color.surface,gap:4},noticeText:{color:ae.color.textSecondary,fontSize:11},retryText:{color:ae.color.text,fontSize:12,paddingVertical:6}});import{jsx as S,jsxs as X}from"react/jsx-runtime";function Ga({names:e}){let t=[...new Set(e)];return t.length?X(y,{style:C.fontsBox,testID:b.fonts,children:[X(m,{style:C.fontsTitle,testID:b.fontsTitle,children:["LOADED FONT FAMILIES (",t.length,")"]}),S(y,{style:C.fontsWrap,children:t.map(s=>S(m,{style:C.fontChip,testID:Ot(s),children:s},s))})]}):null}function Ka({duplicates:e=false}){return S(Js,{testID:b.empty,otto:"scanning",title:e?"No duplicates found":"No assets found yet",message:e?"No assets in this view share a content hash.":"Every bundled asset \u2014 images, fonts, video, audio \u2014 appears here with sizes, scale coverage, and runtime registration status. Try Rescan after navigating around the app."})}function Wt(e,t){return(t.sizeBytes??x(t))-(e.sizeBytes??x(e))}var _a={size:Wt,name:(e,t)=>e.name.localeCompare(t.name)||e.type.localeCompare(t.type),type:(e,t)=>e.type.localeCompare(t.type)||Wt(e,t)};function Ne({visible:e,onClose:t,onBack:s,onMinimize:a,persistenceKey:r,inline:n=false}){ce();let{records:o,stats:i,insights:d}=xt(),l=fa(),[c,f]=te(false);ut(()=>{f(false)},[l.graphFetchInFlight,l.lastScanAt]);let h=()=>{f(false);let u=ge();u?u("rescan").catch(()=>f(true)):ue()},[k,K]=te(null),[z,qt]=te("all"),[We,Ue]=te(""),[Ge,Jt]=te("size"),H=k!=null?ke(k):void 0;ut(()=>{if(!e)return;Bt(),f(false);let u=ge();u?u("rescan").catch(()=>f(true)):ue()},[e]);let Se=new Set(d.duplicates.flatMap(u=>u.ids)),Ke=[...o].sort(_a[Ge]),_e=We.trim().toLowerCase(),_=Ke.filter(u=>!(z==="unused"&&u.loaded||z==="duplicates"&&!Se.has(u.id)||z!=="all"&&z!=="unused"&&z!=="duplicates"&&u.kind!==z||_e&&!`${u.name}.${u.type}`.toLowerCase().includes(_e))),ee=H?_.findIndex(u=>u.id===H.id):-1,qe=u=>{let M=_[u];M&&K(M.id)},q={scaleGaps:new Set(d.scaleGaps),scaleAnomalies:new Set(d.scaleAnomalies),duplicates:Se,webpCandidates:new Set(d.webpCandidates),overDecode:new Set(d.overDecode),heavy:new Set([...d.heavyGifs,...d.heavyFonts])},re=0;for(let u of _){let M=u.sizeBytes??x(u);M>re&&(re=M)}let Yt=()=>H?St(H):wt(Ke,i,d,Q(),ye()),Je=S(Pa,{stats:i,measuring:l.measuring,discovering:l.graphFetchInFlight,detailOpen:H!=null,detailIndex:ee,detailTotal:_.length,onCloseDetail:()=>K(null),onClear:$e,getReport:Yt,onBack:s}),Ye=H?X(y,{style:C.detailContainer,children:[S(Ta,{record:H,insights:d}),ee>=0?S(Gs,{currentIndex:ee,totalItems:_.length,itemLabel:"Asset",onPrevious:()=>qe(ee-1),onNext:()=>qe(ee+1)}):null]}):X(y,{style:C.listContainer,children:[S(Ma,{stats:i,duplicateCount:Se.size,filter:z,onChange:u=>{qt(u),u==="duplicates"&&Ue("")}}),S(Ha,{query:We,onQueryChange:Ue,sort:Ge,onSortChange:Jt}),S(Ua,{status:l,total:i.total,onRetry:h}),c&&!l.graphFetchInFlight?X(y,{style:C.notice,children:[S(m,{style:C.noticeText,children:"Couldn't request an asset scan from the device."}),S(N,{accessibilityRole:"button",onPress:h,children:S(m,{style:C.retryText,children:"Retry"})})]}):null,z==="unused"?S(y,{style:C.notice,children:S(m,{style:C.noticeText,children:"Not seen in React Native's asset registry this app run. Assets loaded through other paths may appear here; this does not prove they are unused."})}):null,z==="font"?S(Ga,{names:l.fontFamilies}):null,S(Xe,{testID:b.list,data:_,keyExtractor:u=>String(u.id),contentContainerStyle:C.listContent,renderItem:({item:u})=>S(Ra,{record:u,flags:{scaleGap:q.scaleGaps.has(u.id),scaleAnomaly:q.scaleAnomalies.has(u.id),duplicate:q.duplicates.has(u.id),webp:q.webpCandidates.has(u.id),oversize:q.overDecode.has(u.id),heavy:q.heavy.has(u.id)},sizeFraction:re>0?(u.sizeBytes??x(u))/re:0,onPress:M=>K(typeof M=="number"?M:null)}),ListEmptyComponent:l.graphFetchInFlight?null:S(Ka,{duplicates:z==="duplicates"})})]});return n?X(y,{style:C.inlineRoot,children:[S(y,{style:C.inlineHeader,...qs,children:Je}),Ye]}):S(Ks,{visible:e,onClose:t,onMinimize:a,persistenceKey:r,header:{showToggleButton:true,customContent:Je},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:Ye})}function qa(e={}){return S(Ne,{...e,inline:true,visible:true,onClose:()=>{}})}var C=O.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:_s.border.default,backgroundColor:"transparent"},listContainer:{flex:1},listContent:{paddingBottom:16},detailContainer:{flex:1},notice:{marginHorizontal:10,marginBottom:8,padding:10,borderRadius:8,borderWidth:1,borderColor:R.color.border,backgroundColor:R.color.surface,gap:4},noticeText:{color:R.color.textSecondary,fontSize:11},retryText:{color:R.color.text,fontSize:12,paddingVertical:6},fontsBox:{marginHorizontal:10,marginTop:8,padding:10,borderRadius:8,backgroundColor:R.color.surface,gap:6},fontsTitle:{color:R.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5},fontsWrap:{flexDirection:"row",flexWrap:"wrap",gap:6},fontChip:{color:R.color.textSecondary,fontSize:10,backgroundColor:R.color.bg,borderRadius:999,paddingHorizontal:8,paddingVertical:3,overflow:"hidden"},empty:{alignItems:"center",padding:32,gap:8},emptyTitle:{color:R.color.text,fontSize:13,fontWeight:"600"},emptyText:{color:R.color.textSecondary,fontSize:11,textAlign:"center",lineHeight:16}});import{createToolFactory as Ja,defineToolPreset as Ya}from"@buoy-gg/shared-ui/web";import{jsx as Qa}from"react/jsx-runtime";var Ut=Ya({id:"assets",name:"ASSETS",description:"Every bundled asset \u2014 sizes, scale coverage, unused detection",slot:"both",icon:({size:e,color:t})=>Qa(dt,{size:e,color:t||ct}),component:Ne}),Za=Ja(Ut);p();var Gt=["image","font","video","audio","data","other"];function Ve(e){return{id:e.id,key:e.key,registryId:e.registryId??null,name:e.name,type:e.type,kind:e.kind,hash:e.hash??null,location:e.httpServerLocation??null,width:e.width??null,height:e.height??null,scales:e.scales,uri:e.resolvedUri??null,loaded:e.loaded,sizeBytes:e.sizeSource==="measured"?e.sizeBytes??null:x(e)||null,sizeSource:e.sizeSource??null}}function Xa(e){let t=e?.id;if(typeof t!="number")throw new Error("Missing numeric `id` param");let s=ke(t);if(!s)throw new Error(`Asset record ${t} not found \u2014 re-run the list action for current ids.`);return s}function er(e,t){return(t.sizeBytes??x(t))-(e.sizeBytes??x(e))}function Kt(){let e=F();return{stats:De(e),scanStatus:Q(),insights:Te(e),diff:ye(),records:[...e].sort(er)}}var tr={version:1,getSnapshot:()=>{let{records:e,...t}=Kt();return{...t,records:e.slice(0,200).map(Ve)}},subscribe:e=>le(e),actions:{list:e=>{let t=e??{},s=Math.min(Math.max(t.limit??50,1),500),{records:a,...r}=Kt(),n=a;if(t.kind){if(!Gt.includes(t.kind))throw new Error(`kind must be one of: ${Gt.join(", ")}`);n=n.filter(o=>o.kind===t.kind)}return t.loadedOnly&&(n=n.filter(o=>o.loaded)),{...r,total:n.length,records:n.slice(0,s).map(Ve)}},getDetail:e=>{let t=Xa(e);return{...Ve(t),origin:t.origin,fileSystemLocation:t.fileSystemLocation??null,files:t.files??null,sizesByScale:t.sizesByScale??null,estDecodedBytes:x(t)||null}},rescan:async()=>({ok:true,scanStatus:await ue()}),measureSizes:async()=>{let e=await Tt();return{ok:e.measured>0,...e}},saveBaseline:async()=>{let e=await kt();return{ok:true,savedAt:e.savedAt,assets:Object.keys(e.entries).length}},clearBaseline:async()=>(await $t(),{ok:true,message:"Baseline cleared"}),getDiff:()=>ye(),clearRecords:()=>($e(),{ok:true,message:"Inventory cleared \u2014 rescan to rebuild"}),getScanStatus:()=>Q()}};p();p();var _t=0;function sr(){if(typeof document>"u")return()=>{};++_t===1&&ce();let e=true;return()=>{e&&(e=false,--_t===0&&mt())}}export{ct as ASSETS_ICON_COLOR,b as ASSETS_TEST_IDS,dt as AssetsIcon,Ne as AssetsModal,qa as AssetsToolView,Rt as assetBadgeTestID,Mt as assetDetailRowTestID,Re as assetFilterTestID,Pt as assetFindingTestID,Ot as assetFontChipTestID,se as assetRowTestID,Z as assetSlug,tr as assetsSyncAdapter,Ut as assetsToolPreset,$t as clearBaseline,$e as clearRecords,Dt as computeDiff,Te as computeInsights,De as computeStats,Za as createAssetsTool,ba as disableAssetsCapture,x as estDecodedBytes,za as fetchAssetGraph,St as formatAssetMarkdown,wt as formatInventoryMarkdown,yt as getBrowserAssetManifest,At as getDevServerOrigin,ye as getDiff,Fe as getLoadedFontFamilies,aa as getLocalAssets,ke as getRecord,Q as getScanStatus,F as getSnapshot,ce as installAssetCapture,Bt as loadBaseline,sa as loadBrowserAssetManifest,Tt as measureSizes,gt as registerBrowserAssetManifest,va as replaceAssetsFromSnapshot,ue as rescan,kt as saveBaseline,ma as setRemoteAssetsHandler,sr as startBrowserAssetCapture,le as subscribe,xt as useAssetRecords};
|
|
3
|
+
`)}p();import{useMemo as oa,useSyncExternalStore as ia}from"react";p();var la=50*1024,da=100*1024,ca=150*1024,ua=2,ha=.9,pa=4*1024;function ga(){try{let{Dimensions:e,PixelRatio:t}=(E(),Ze(ne)),s=e.get("screen"),a=t.get();return s.width*a*s.height*a}catch{return 1170*2532}}function ya(e){let t=e.sizesByScale;if(!t)return false;let s=Object.entries(t).map(([a,r])=>({scale:Number(a),bytes:r})).filter(a=>Number.isFinite(a.scale)&&a.bytes>0).sort((a,r)=>a.scale-r.scale);for(let a=1;a<s.length;a++)if(s[a-1].bytes>=pa&&s[a].bytes<s[a-1].bytes*ha)return true;return false}function Te(e){let t=pt(),s=new Map;for(let h of e){if(!h.hash)continue;let k=s.get(h.hash);k?k.push(h):s.set(h.hash,[h])}let a=[];for(let[h,k]of s){if(k.length<2)continue;let K=k.find(z=>z.sizeBytes!=null);a.push({hash:h,ids:k.map(z=>z.id),wastedBytes:K?.sizeBytes!=null?K.sizeBytes*(k.length-1):null})}let r=ga(),n=[],o=[],i=[],d=[],l=[],c=[],f=[];for(let h of e)h.loaded||i.push(h.id),h.kind==="image"&&h.scales.length>1&&!h.scales.some(k=>k>=t)&&n.push(h.id),(h.type==="png"||h.type==="jpg"||h.type==="jpeg")&&h.sizeBytes!=null&&h.sizeBytes>=la&&o.push(h.id),h.kind==="image"&&x(h)/4>r*ua&&d.push(h.id),h.type==="gif"&&(h.sizeBytes??0)>=da&&l.push(h.id),h.kind==="font"&&(h.sizeBytes??0)>=ca&&c.push(h.id),ya(h)&&f.push(h.id);return{duplicates:a,scaleGaps:n,webpCandidates:o,neverLoaded:i,overDecode:d,heavyGifs:l,heavyFonts:c,scaleAnomalies:f}}function xt(){let e=ia(le,F,F);return oa(()=>({records:e,stats:De(e),insights:Te(e)}),[e])}p();import{useSyncExternalStore as fa}from"react";var zt,Ct;function Bt(){let e=F();return e!==zt&&(zt=e,Ct=Q()),Ct}function ma(){return fa(le,Bt,Bt)}p();function ba(e){g().remoteDispatch=e}function ge(){return g().remoteDispatch}function va(){g().captureDisabled=true}function Sa(e){let t=g(),s=e.records??[];t.records=s.map(a=>({id:a.id,key:a.key,registryId:a.registryId??void 0,name:a.name,type:a.type,kind:a.kind,hash:a.hash??void 0,httpServerLocation:a.location??void 0,width:a.width??void 0,height:a.height??void 0,scales:a.scales,resolvedUri:a.uri??void 0,loaded:a.loaded,origin:a.registryId!=null?"registry":"graph",sizeBytes:a.sizeBytes??void 0,sizeSource:a.sizeSource??void 0,firstSeenAt:Date.now()})),t.byKey=new Map(t.records.map(a=>[a.key,a])),t.byId=new Map(t.records.map(a=>[a.id,a])),e.scanStatus&&(t.fontFamilies=[...new Set(e.scanStatus.fontFamilies??[])],t.mirrorScanStatus={...e.scanStatus,fontFamilies:t.fontFamilies}),t.mirrorDiff=e.diff??null,A()}p();import{persistentStorage as Le}from"@buoy-gg/shared-ui/web";var Ee="@react_buoy/assets/baseline",wa=1024;async function It(){let e=g();if(e.baselineLoaded)return e.baseline;e.baselineLoaded=true;try{let t=await Le.getItem(Ee);if(t){let s=JSON.parse(t);s&&typeof s.savedAt=="number"&&s.entries&&(e.baseline=s,A())}}catch{}return e.baseline}async function kt(){let e=ge();if(e)return await e("saveBaseline"),g().baseline??{savedAt:Date.now(),entries:{}};let t=g(),s={};for(let r of F())s[r.key]={hash:r.hash??null,sizeBytes:r.sizeSource==="measured"?r.sizeBytes??null:null,name:r.name,type:r.type};let a={savedAt:Date.now(),entries:s};t.baseline=a,t.baselineLoaded=true,A();try{await Le.setItem(Ee,JSON.stringify(a))}catch{}return a}async function $t(){let e=ge();if(e){await e("clearBaseline");return}let t=g();t.baseline=null,t.baselineLoaded=true,A();try{await Le.removeItem(Ee)}catch{}}function Dt(e,t){let s=[],a=[],r=new Set,n=0,o=0,i=false;for(let l of e){r.add(l.key);let c=t.entries[l.key];if(!c){s.push(l.id);continue}let f=l.sizeSource==="measured"?l.sizeBytes??null:null;f!=null&&c.sizeBytes!=null&&(i=true,n+=f,o+=c.sizeBytes,f-c.sizeBytes>=wa&&a.push({id:l.id,deltaBytes:f-c.sizeBytes}))}let d=[];for(let[l,c]of Object.entries(t.entries))ht(l)||r.has(l)||(d.push({key:l,name:c.name,type:c.type}),c.sizeBytes!=null&&(i=true,o+=c.sizeBytes));for(let l of s){let c=e.find(f=>f.id===l);c?.sizeSource==="measured"&&c.sizeBytes!=null&&(i=true,n+=c.sizeBytes)}return{baselineSavedAt:t.savedAt,added:s,removed:d,grown:a.sort((l,c)=>c.deltaBytes-l.deltaBytes),netBytes:i?n-o:null}}function ye(){let e=g();return e.mirrorDiff?e.mirrorDiff:e.baseline?Dt(F(),e.baseline):null}p();E();import{night as V}from"@buoy-gg/shared-ui/web";p();E();import{useState as xa}from"react";import{night as za}from"@buoy-gg/shared-ui/web";p();E();p();function At(){return null}async function Ca(){de();let e=yt().length;return e?{ok:true,count:e}:{ok:false,message:"Register a browser asset manifest to inspect files that have not loaded yet."}}var Ba=4;function Ia(e){if(e.resolvedUri)return e.resolvedUri;let t=Ft(e);return t.length?t[0].url:null}function ka(e){let t=g().captureDisabled;if(!t&&e.registryId!=null)return e.registryId;let s=Ia(e);return!s||t&&!/^https?:\/\//.test(s)?null:{uri:s}}function Ft(e){let t=e.scales.length?e.scales:[1],s=e.resolvedUri;if(s&&/^https?:\/\//.test(s)&&e.resolvedScale!=null){let r=e.resolvedScale===1?"":`@${e.resolvedScale}x`,n=`${r}.${e.type}`;if(s.includes(n)||r==="")return t.map(o=>{let i=o===1?"":`@${o}x`,d=(r===""?s.replace(`.${e.type}`,`${i}.${e.type}`):s.replace(n,`${i}.${e.type}`)).replace(/ /g,"%20");return{scale:o,url:d}})}let a=At();return!a||!e.httpServerLocation?[]:t.map(r=>{let n=r===1?"":`@${r}x`,o=`${e.httpServerLocation}/${e.name}${n}.${e.type}`,i=o.includes("?")?"&":"?",d=`${a}${o}${i}platform=${$a()}${e.hash?`&hash=${e.hash}`:""}`.replace(/ /g,"%20");return{scale:r,url:d}})}function $a(){try{return oe.OS}catch{return"ios"}}async function Da(e){try{let t=await fetch(e,{method:"HEAD"});if(t.ok){let s=Number(t.headers.get("content-length"));if(Number.isFinite(s)&&s>0)return s}}catch{}try{let t=await fetch(e);if(!t.ok)return null;let s=await t.blob();return s.size>0?s.size:null}catch{return null}}async function Aa(e){let t=Ft(e);if(!t.length){ie(e.id,{sizeSource:"estimate"});return}let s={},a=0;for(let{scale:r,url:n}of t){let o=await Da(n);o!=null&&(s[String(r)]=o,a+=o)}a>0?ie(e.id,{sizesByScale:s,sizeBytes:a,sizeSource:"measured"}):ie(e.id,{sizeSource:"estimate"})}async function Tt(){let e=g();if(e.measuring)return{measured:e.measuredCount,total:F().length};let t=F().filter(s=>s.sizeSource!=="measured");e.measuring=true,A();try{let s=0,a=async()=>{for(;;){let r=t[s++];if(!r)return;await Aa(r),e.measuredCount=F().filter(n=>n.sizeSource==="measured").length}};await Promise.all(Array.from({length:Math.min(Ba,t.length)},a))}finally{e.measuring=false,A()}return{measured:e.measuredCount,total:F().length}}p();function Fa(){return null}import{jsx as fe}from"react/jsx-runtime";function Lt({record:e,style:t,testID:s,compact:a=false}){let r=ka(e),n=e.type.toLowerCase()==="svg",o=n&&oe.OS!=="web"?Fa():null,i=`${e.key}:${e.hash??""}:${typeof r=="number"?r:r?.uri??""}`,[d,l]=xa(null);if(r==null||d===i||n&&oe.OS!=="web"&&!o){let f=n?"SVG preview unavailable":"Image preview unavailable";return fe(y,{style:[t,Et.fallback],accessibilityLabel:f,testID:`${s}-unavailable`,children:fe(m,{style:Et.text,children:a?n?"SVG":"IMG":f})})}let c=()=>l(i);return o?fe(o,{source:r,style:t,contentFit:"contain",onError:c,testID:s}):fe(et,{source:r,style:t,resizeMode:"contain",onError:c,testID:s})}var Et=O.create({fallback:{alignItems:"center",justifyContent:"center"},text:{color:za.color.textSecondary,fontSize:10,textAlign:"center"}});p();function Z(e){return String(e).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function se(e,t){return`buoy-assets-row-${Z(`${e}.${t}`)}`}function Rt(e,t,s){return`${se(e,t)}-badge-${Z(s)}`}function Re(e){return`buoy-assets-filter-${Z(e)}`}function Mt(e){return`buoy-assets-detail-row-${Z(e)}`}function Ot(e){return`buoy-assets-font-${Z(e)}`}var b={title:"buoy-assets-title",copy:"buoy-assets-copy",clear:"buoy-assets-clear",list:"buoy-assets-list",search:"buoy-assets-search",sort:"buoy-assets-sort",filterBar:"buoy-assets-filter-bar",notice:"buoy-assets-notice",noticeText:"buoy-assets-notice-text",discoverySpinner:"buoy-assets-discovery-spinner",retry:"buoy-assets-retry",fonts:"buoy-assets-fonts",fontsTitle:"buoy-assets-fonts-title",empty:"buoy-assets-empty",emptyTitle:"buoy-assets-empty-title",emptyText:"buoy-assets-empty-text",detail:"buoy-assets-detail",detailScroll:"buoy-assets-detail-scroll",detailPreview:"buoy-assets-detail-preview",detailFontPreview:"buoy-assets-detail-font-preview",detailFindings:"buoy-assets-detail-findings"};function Pt(e){return`buoy-assets-detail-finding-${e}`}import{jsx as v,jsxs as jt}from"react/jsx-runtime";function I({label:e,value:t}){let s=Mt(e);return jt(y,{style:T.kvRow,testID:s,children:[v(m,{style:T.kvLabel,children:e}),v(m,{style:T.kvValue,selectable:true,testID:`${s}-value`,children:t})]})}function Ta({record:e}){return e.kind==="image"?v(y,{style:T.previewBox,testID:b.detailPreview,children:v(Lt,{testID:"buoy-internal-assets-preview",record:e,style:T.previewImage})}):e.kind==="font"?v(y,{style:T.previewBox,testID:b.detailFontPreview,children:v(m,{style:[T.fontPreview,{fontFamily:e.name}],children:"The quick brown fox jumps over the lazy dog 0123456789"})}):null}function La({record:e,insights:t}){let s=[];t.neverLoaded.includes(e.id)&&s.push("Not observed in the runtime registry this app run. This does not prove the asset is unused."),t.scaleGaps.includes(e.id)&&s.push("Scale gap \u2014 no variant covers this device's pixel ratio"),t.webpCandidates.includes(e.id)&&s.push("WebP candidate \u2014 large png/jpeg, converting typically saves 20\u201340%");let a=t.duplicates.find(n=>n.ids.includes(e.id));a&&s.push(`Duplicate content \u2014 identical bytes shipped ${a.ids.length} times`),t.overDecode.includes(e.id)&&s.push("Decodes larger than 2\xD7 this entire screen \u2014 resize the source, no view can need this many pixels"),t.heavyGifs.includes(e.id)&&s.push("Heavy GIF \u2014 every frame decodes into memory; a video or Lottie is typically ~90% smaller"),t.heavyFonts.includes(e.id)&&s.push("Heavy font \u2014 likely an unsubset icon font; subsetting to used glyphs usually saves most of it"),t.scaleAnomalies.includes(e.id)&&s.push("Scale anomaly \u2014 a higher-resolution variant is smaller in bytes than a lower one; check the exports");let r=x(e);return jt(Ce,{style:T.scroll,contentContainerStyle:T.content,testID:b.detailScroll,children:[v(Ta,{record:e}),s.length>0?v(y,{style:T.findings,testID:b.detailFindings,children:s.map((n,o)=>v(m,{style:T.findingText,testID:Pt(o),children:n},n))}):null,v(I,{label:"Name",value:`${e.name}.${e.type}`}),v(I,{label:"Kind",value:e.kind}),v(I,{label:"Status",value:e.loaded?"Loaded (registered at runtime)":"Not observed in the runtime registry"}),e.kind==="image"?v(I,{label:"Dimensions",value:`${pe(e)} (logical)`}):null,e.kind==="image"&&e.scales.length?v(I,{label:"Scales",value:he(e.scales)}):null,e.sizesByScale?Object.entries(e.sizesByScale).map(([n,o])=>v(I,{label:`Size @${n}x`,value:D(o)},n)):null,e.sizeBytes!=null&&e.sizeSource==="measured"?v(I,{label:"Total size",value:D(e.sizeBytes)}):null,r>0?v(I,{label:"Decoded memory",value:`~${D(r)} (RGBA)`}):null,e.registryId!=null?v(I,{label:"Registry id",value:String(e.registryId)}):null,e.hash?v(I,{label:"Hash",value:e.hash}):null,e.httpServerLocation?v(I,{label:"Location",value:e.httpServerLocation}):null,e.fileSystemLocation?v(I,{label:"Source dir",value:e.fileSystemLocation}):null,e.resolvedUri?v(I,{label:"Resolved URI",value:e.resolvedUri}):null]})}var T=O.create({scroll:{flex:1},content:{padding:12,gap:8},previewBox:{borderRadius:8,backgroundColor:V.color.bg,padding:12,alignItems:"center",justifyContent:"center",minHeight:96},previewImage:{width:"100%",height:140},fontPreview:{color:V.color.text,fontSize:16,textAlign:"center"},findings:{borderRadius:8,borderWidth:1,borderColor:V.color.border,backgroundColor:V.color.surface,padding:10,gap:6},findingText:{color:V.color.textSecondary,fontSize:11,lineHeight:15},kvRow:{gap:2},kvLabel:{color:V.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,textTransform:"uppercase"},kvValue:{color:V.color.text,fontSize:12}});p();E();import{macOSColors as Me,night as W,Pill as Ea}from"@buoy-gg/shared-ui/web";import{jsx as L,jsxs as U}from"react/jsx-runtime";function Ra({label:e,color:t,testID:s}){return L(Ea,{label:e,color:t,variant:"quiet",dot:!!t,style:{paddingVertical:2.5},testID:s})}function Ma({record:e,flags:t,sizeFraction:s,onPress:a}){let r=vt[e.kind],n=[];return e.loaded||n.push({label:"NOT OBSERVED"}),t.oversize&&n.push({label:"OVERSIZE",color:Me.semantic.error}),t.duplicate&&n.push({label:"DUP"}),t.heavy&&n.push({label:"HEAVY"}),t.scaleAnomaly?n.push({label:"BAD SCALE",color:Me.semantic.error}):t.scaleGap&&n.push({label:"LOW-RES"}),t.webp&&n.push({label:"WEBP",color:Me.semantic.info}),U(H,{style:w.card,testID:se(e.name,e.type),onPress:()=>a(e.id),activeOpacity:.7,children:[U(y,{style:w.body,children:[L(y,{style:w.thumbBox,children:e.kind==="image"?L(Lt,{testID:"buoy-internal-assets-thumb",record:e,style:w.thumb,compact:true}):L(m,{style:[w.thumbFallback,{color:r}],children:bt[e.kind]})}),U(y,{style:w.main,children:[U(m,{style:w.name,numberOfLines:1,testID:`${se(e.name,e.type)}-name`,children:[e.name,U(m,{style:w.ext,children:[".",e.type]})]}),U(y,{style:w.metaRow,children:[e.kind==="image"&&e.width!=null?L(m,{style:w.meta,children:pe(e)}):null,e.kind==="image"&&e.scales.length?L(m,{style:w.meta,children:he(e.scales)}):null]})]}),U(y,{style:w.right,children:[L(m,{style:w.size,testID:`${se(e.name,e.type)}-size`,children:na(e,x(e))}),n.length?L(y,{style:w.badgeRow,children:n.slice(0,3).map(o=>L(Ra,{label:o.label,color:o.color,testID:Rt(e.name,e.type,o.label)},o.label))}):null]})]}),s>0?L(y,{style:w.sizeTrack,children:L(y,{style:[w.sizeFill,{backgroundColor:r,width:`${Math.max(2,Math.round(s*100))}%`}]})}):null]})}var w=O.create({card:{marginHorizontal:10,marginTop:6,borderRadius:10,backgroundColor:W.color.surface,borderWidth:1,borderColor:W.color.border,overflow:"hidden"},body:{flexDirection:"row",alignItems:"center",paddingVertical:8,paddingHorizontal:12,gap:10},thumbBox:{width:40,height:40,borderRadius:8,backgroundColor:"rgba(255,255,255,0.10)",borderWidth:1,borderColor:W.color.border,alignItems:"center",justifyContent:"center",overflow:"hidden"},thumb:{width:34,height:34},thumbFallback:{fontSize:9,fontWeight:"700",letterSpacing:.5},main:{flex:1,gap:3},name:{color:W.color.text,fontSize:12,fontWeight:"600"},ext:{color:W.color.textTertiary,fontWeight:"400"},metaRow:{flexDirection:"row",alignItems:"center",gap:8},meta:{color:W.color.textSecondary,fontSize:10,fontVariant:["tabular-nums"]},right:{alignItems:"flex-end",gap:4},size:{color:W.color.text,fontSize:12,fontWeight:"700",fontVariant:["tabular-nums"]},badgeRow:{flexDirection:"row",gap:4},sizeTrack:{height:2,backgroundColor:"transparent"},sizeFill:{height:2,opacity:.45,borderTopRightRadius:2}});p();E();import{night as me}from"@buoy-gg/shared-ui/web";import{jsx as Oe}from"react/jsx-runtime";function Oa({stats:e,duplicateCount:t,filter:s,onChange:a}){let r=[{key:"all",label:`ALL ${e.total}`,accent:me.color.textSecondary},{key:"duplicates",label:`DUPLICATES ${t}`,accent:"#FF9F1C"}];for(let n of Object.keys(e.byKind)){let o=e.byKind[n];o.count>0&&r.push({key:n,label:`${bt[n]} ${o.count}`,accent:vt[n]})}return e.neverLoaded>0&&r.push({key:"unused",label:`NOT OBSERVED ${e.neverLoaded}`,accent:"#FF9F1C"}),r.length<=1?null:Oe(y,{style:Pe.bar,testID:b.filterBar,children:r.map(n=>{let o=n.key===s;return Oe(H,{accessibilityRole:"button",accessibilityState:{selected:o},testID:Re(n.key),style:[Pe.chip,o&&{borderColor:n.accent,backgroundColor:`${n.accent}1A`}],onPress:()=>a(o?"all":n.key),children:Oe(m,{testID:`${Re(n.key)}-label`,style:[Pe.chipText,{color:o?n.accent:me.color.textSecondary}],children:n.label})},n.key)})})}var Pe=O.create({bar:{flexDirection:"row",flexWrap:"wrap",gap:6,paddingHorizontal:10,paddingVertical:8},chip:{borderWidth:1,borderColor:me.color.border,backgroundColor:me.color.surface,borderRadius:999,paddingHorizontal:10,paddingVertical:5},chipText:{fontSize:10,fontWeight:"700",letterSpacing:.4,lineHeight:13}});p();import{ModalHeader as P,ToolbarClearButton as Pa,ToolbarCopyButton as Nt}from"@buoy-gg/shared-ui/web";import{jsx as j,jsxs as je}from"react/jsx-runtime";function ja({stats:e,measuring:t,discovering:s=false,detailOpen:a,detailIndex:r=-1,detailTotal:n=0,onCloseDetail:o,onClear:i,getReport:d,onBack:l}){if(a){let f=r>=0&&n>0?`${r+1} of ${n}`:void 0;return je(P,{children:[j(P.Navigation,{onBack:o}),j(P.Content,{title:"Asset detail",subtitle:f,testID:b.title}),j(P.Actions,{children:j(Nt,{value:d,testID:b.copy})})]})}let c=[`${e.total} assets${s?" so far":""}`];if(e.totalBytes>0&&!t&&!s){let f=e.measuredCount<e.total?"+":"";c.push(`${D(e.totalBytes)}${f}`)}return e.neverLoaded>0&&c.push(`${e.neverLoaded} not observed`),e.fontFamilies>0&&c.push(`${e.fontFamilies} fonts`),je(P,{children:[l?j(P.Navigation,{onBack:l}):null,j(P.Content,{title:"Assets",subtitle:c.join(" \xB7 "),testID:b.title}),je(P.Actions,{children:[j(Nt,{value:d,testID:b.copy}),j(Pa,{onPress:i,testID:b.clear})]})]})}p();E();import{night as G}from"@buoy-gg/shared-ui/web";import{jsx as Ht,jsxs as Vt}from"react/jsx-runtime";var Na={size:"name",name:"type",type:"size"};function Ha({query:e,onQueryChange:t,sort:s,onSortChange:a}){return Vt(y,{style:be.row,children:[Ht(ze,{style:be.input,value:e,onChangeText:t,placeholder:"Search assets\u2026",placeholderTextColor:G.color.placeholder,autoCapitalize:"none",autoCorrect:false,testID:b.search}),Ht(H,{style:be.button,onPress:()=>a(Na[s]),testID:b.sort,children:Vt(m,{style:be.buttonText,testID:`${b.sort}-label`,children:["\u2193 ",s.toUpperCase()]})})]})}var be=O.create({row:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:10,paddingBottom:8},input:{flex:1,backgroundColor:G.color.surfaceElevated,borderWidth:1,borderColor:G.color.border,borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:G.color.text,fontSize:12},button:{backgroundColor:G.color.surface,borderWidth:1,borderColor:G.color.border,borderRadius:8,paddingHorizontal:10,paddingVertical:7},buttonText:{color:G.color.textSecondary,fontSize:10,fontWeight:"700",letterSpacing:.5}});p();E();import{useEffect as Va,useState as Wa}from"react";import{night as ae}from"@buoy-gg/shared-ui/web";import{jsx as ve,jsxs as Ua}from"react/jsx-runtime";function Ga({status:e,total:t,onRetry:s}){let[a,r]=Wa(false);Va(()=>{if(r(false),!e.graphFetchInFlight)return;let i=e.graphFetchStartedAt==null?0:Math.max(0,Date.now()-e.graphFetchStartedAt),d=setTimeout(()=>r(true),Math.max(0,8e3-i));return()=>clearTimeout(d)},[e.graphFetchInFlight,e.graphFetchStartedAt]);let n=[];e.browser&&!e.graphSupported&&n.push("Showing resources this page has loaded. Add an asset manifest to include files the page has not requested."),e.graphFetchInFlight&&(n.push(`Finding assets\u2026 ${t} found so far.`),a&&n.push("Still finding assets. This is taking longer than usual.")),e.registryAvailable||n.push("The asset registry is unavailable in this environment."),!e.graphFetchInFlight&&!e.graphSupported&&e.graphError&&n.push("Showing runtime-registered assets only. A development server is needed to find more assets and measure their sizes.");let o=!e.graphFetchInFlight&&e.graphSupported&&!!e.graphError;return o&&n.push(`Couldn't finish finding assets. Showing ${t} assets found so far.`),e.measuring&&!e.graphFetchInFlight&&n.push("Checking asset sizes\u2026"),n.length===0?null:Ua(y,{style:Ne.notice,testID:b.notice,children:[e.graphFetchInFlight?ve(Be,{size:"small",color:ae.color.textSecondary,accessibilityLabel:"Finding assets",testID:b.discoverySpinner}):null,n.map(i=>ve(m,{style:Ne.noticeText,testID:b.noticeText,children:i},i)),o?ve(H,{accessibilityRole:"button",onPress:s,testID:b.retry,children:ve(m,{style:Ne.retryText,children:"Retry"})}):null]})}var Ne=O.create({notice:{marginHorizontal:10,marginBottom:8,padding:10,borderRadius:8,borderWidth:1,borderColor:ae.color.border,backgroundColor:ae.color.surface,gap:4},noticeText:{color:ae.color.textSecondary,fontSize:11},retryText:{color:ae.color.text,fontSize:12,paddingVertical:6}});import{jsx as S,jsxs as X}from"react/jsx-runtime";function Ka({names:e}){let t=[...new Set(e)];return t.length?X(y,{style:C.fontsBox,testID:b.fonts,children:[X(m,{style:C.fontsTitle,testID:b.fontsTitle,children:["LOADED FONT FAMILIES (",t.length,")"]}),S(y,{style:C.fontsWrap,children:t.map(s=>S(m,{style:C.fontChip,testID:Ot(s),children:s},s))})]}):null}function _a({duplicates:e=false}){return S(Ys,{testID:b.empty,otto:"scanning",title:e?"No duplicates found":"No assets found yet",message:e?"No assets in this view share a content hash.":"Every bundled asset \u2014 images, fonts, video, audio \u2014 appears here with sizes, scale coverage, and runtime registration status. Try Rescan after navigating around the app."})}function Wt(e,t){return(t.sizeBytes??x(t))-(e.sizeBytes??x(e))}var qa={size:Wt,name:(e,t)=>e.name.localeCompare(t.name)||e.type.localeCompare(t.type),type:(e,t)=>e.type.localeCompare(t.type)||Wt(e,t)};function He({visible:e,onClose:t,onBack:s,onMinimize:a,persistenceKey:r,inline:n=false}){ce();let{records:o,stats:i,insights:d}=xt(),l=ma(),[c,f]=te(false);ut(()=>{f(false)},[l.graphFetchInFlight,l.lastScanAt]);let h=()=>{f(false);let u=ge();u?u("rescan").catch(()=>f(true)):ue()},[k,K]=te(null),[z,qt]=te("all"),[We,Ue]=te(""),[Ge,Jt]=te("size"),N=k!=null?ke(k):void 0;ut(()=>{if(!e)return;It(),f(false);let u=ge();u?u("rescan").catch(()=>f(true)):ue()},[e]);let Se=new Set(d.duplicates.flatMap(u=>u.ids)),Ke=[...o].sort(qa[Ge]),_e=We.trim().toLowerCase(),_=Ke.filter(u=>!(z==="unused"&&u.loaded||z==="duplicates"&&!Se.has(u.id)||z!=="all"&&z!=="unused"&&z!=="duplicates"&&u.kind!==z||_e&&!`${u.name}.${u.type}`.toLowerCase().includes(_e))),ee=N?_.findIndex(u=>u.id===N.id):-1,qe=u=>{let M=_[u];M&&K(M.id)},q={scaleGaps:new Set(d.scaleGaps),scaleAnomalies:new Set(d.scaleAnomalies),duplicates:Se,webpCandidates:new Set(d.webpCandidates),overDecode:new Set(d.overDecode),heavy:new Set([...d.heavyGifs,...d.heavyFonts])},re=0;for(let u of _){let M=u.sizeBytes??x(u);M>re&&(re=M)}let Yt=()=>N?St(N):wt(Ke,i,d,Q(),ye()),Je=S(ja,{stats:i,measuring:l.measuring,discovering:l.graphFetchInFlight,detailOpen:N!=null,detailIndex:ee,detailTotal:_.length,onCloseDetail:()=>K(null),onClear:$e,getReport:Yt,onBack:s}),Ye=N?X(y,{style:C.detailContainer,children:[S(La,{record:N,insights:d}),ee>=0?S(Ks,{currentIndex:ee,totalItems:_.length,itemLabel:"Asset",onPrevious:()=>qe(ee-1),onNext:()=>qe(ee+1)}):null]}):X(y,{style:C.listContainer,children:[S(Oa,{stats:i,duplicateCount:Se.size,filter:z,onChange:u=>{qt(u),u==="duplicates"&&Ue("")}}),S(Ha,{query:We,onQueryChange:Ue,sort:Ge,onSortChange:Jt}),S(Ga,{status:l,total:i.total,onRetry:h}),c&&!l.graphFetchInFlight?X(y,{style:C.notice,children:[S(m,{style:C.noticeText,children:"Couldn't request an asset scan from the device."}),S(H,{accessibilityRole:"button",onPress:h,children:S(m,{style:C.retryText,children:"Retry"})})]}):null,z==="unused"?S(y,{style:C.notice,children:S(m,{style:C.noticeText,children:"Not seen in React Native's asset registry this app run. Assets loaded through other paths may appear here; this does not prove they are unused."})}):null,z==="font"?S(Ka,{names:l.fontFamilies}):null,S(Xe,{testID:b.list,data:_,keyExtractor:u=>String(u.id),contentContainerStyle:C.listContent,renderItem:({item:u})=>S(Ma,{record:u,flags:{scaleGap:q.scaleGaps.has(u.id),scaleAnomaly:q.scaleAnomalies.has(u.id),duplicate:q.duplicates.has(u.id),webp:q.webpCandidates.has(u.id),oversize:q.overDecode.has(u.id),heavy:q.heavy.has(u.id)},sizeFraction:re>0?(u.sizeBytes??x(u))/re:0,onPress:M=>K(typeof M=="number"?M:null)}),ListEmptyComponent:l.graphFetchInFlight?null:S(_a,{duplicates:z==="duplicates"})})]});return n?X(y,{style:C.inlineRoot,children:[S(y,{style:C.inlineHeader,...Js,children:Je}),Ye]}):S(_s,{visible:e,onClose:t,onMinimize:a,persistenceKey:r,header:{showToggleButton:true,customContent:Je},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:Ye})}function Ja(e={}){return S(He,{...e,inline:true,visible:true,onClose:()=>{}})}var C=O.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:qs.border.default,backgroundColor:"transparent"},listContainer:{flex:1},listContent:{paddingBottom:16},detailContainer:{flex:1},notice:{marginHorizontal:10,marginBottom:8,padding:10,borderRadius:8,borderWidth:1,borderColor:R.color.border,backgroundColor:R.color.surface,gap:4},noticeText:{color:R.color.textSecondary,fontSize:11},retryText:{color:R.color.text,fontSize:12,paddingVertical:6},fontsBox:{marginHorizontal:10,marginTop:8,padding:10,borderRadius:8,backgroundColor:R.color.surface,gap:6},fontsTitle:{color:R.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5},fontsWrap:{flexDirection:"row",flexWrap:"wrap",gap:6},fontChip:{color:R.color.textSecondary,fontSize:10,backgroundColor:R.color.bg,borderRadius:999,paddingHorizontal:8,paddingVertical:3,overflow:"hidden"},empty:{alignItems:"center",padding:32,gap:8},emptyTitle:{color:R.color.text,fontSize:13,fontWeight:"600"},emptyText:{color:R.color.textSecondary,fontSize:11,textAlign:"center",lineHeight:16}});import{createToolFactory as Ya,defineToolPreset as Qa}from"@buoy-gg/shared-ui/web";import{jsx as Za}from"react/jsx-runtime";var Ut=Qa({id:"assets",name:"ASSETS",description:"Every bundled asset \u2014 sizes, scale coverage, unused detection",slot:"both",icon:({size:e,color:t})=>Za(dt,{size:e,color:t||ct}),component:He}),Xa=Ya(Ut);p();var Gt=["image","font","video","audio","data","other"];function Ve(e){return{id:e.id,key:e.key,registryId:e.registryId??null,name:e.name,type:e.type,kind:e.kind,hash:e.hash??null,location:e.httpServerLocation??null,width:e.width??null,height:e.height??null,scales:e.scales,uri:e.resolvedUri??null,loaded:e.loaded,sizeBytes:e.sizeSource==="measured"?e.sizeBytes??null:x(e)||null,sizeSource:e.sizeSource??null}}function er(e){let t=e?.id;if(typeof t!="number")throw new Error("Missing numeric `id` param");let s=ke(t);if(!s)throw new Error(`Asset record ${t} not found \u2014 re-run the list action for current ids.`);return s}function tr(e,t){return(t.sizeBytes??x(t))-(e.sizeBytes??x(e))}function Kt(){let e=F();return{stats:De(e),scanStatus:Q(),insights:Te(e),diff:ye(),records:[...e].sort(tr)}}var sr={version:1,getSnapshot:()=>{let{records:e,...t}=Kt();return{...t,records:e.slice(0,200).map(Ve)}},subscribe:e=>le(e),actions:{list:e=>{let t=e??{},s=Math.min(Math.max(t.limit??50,1),500),{records:a,...r}=Kt(),n=a;if(t.kind){if(!Gt.includes(t.kind))throw new Error(`kind must be one of: ${Gt.join(", ")}`);n=n.filter(o=>o.kind===t.kind)}return t.loadedOnly&&(n=n.filter(o=>o.loaded)),{...r,total:n.length,records:n.slice(0,s).map(Ve)}},getDetail:e=>{let t=er(e);return{...Ve(t),origin:t.origin,fileSystemLocation:t.fileSystemLocation??null,files:t.files??null,sizesByScale:t.sizesByScale??null,estDecodedBytes:x(t)||null}},rescan:async()=>({ok:true,scanStatus:await ue()}),measureSizes:async()=>{let e=await Tt();return{ok:e.measured>0,...e}},saveBaseline:async()=>{let e=await kt();return{ok:true,savedAt:e.savedAt,assets:Object.keys(e.entries).length}},clearBaseline:async()=>(await $t(),{ok:true,message:"Baseline cleared"}),getDiff:()=>ye(),clearRecords:()=>($e(),{ok:true,message:"Inventory cleared \u2014 rescan to rebuild"}),getScanStatus:()=>Q()}};p();p();var _t=0;function ar(){if(typeof document>"u")return()=>{};++_t===1&&ce();let e=true;return()=>{e&&(e=false,--_t===0&&mt())}}export{ct as ASSETS_ICON_COLOR,b as ASSETS_TEST_IDS,dt as AssetsIcon,He as AssetsModal,Ja as AssetsToolView,Rt as assetBadgeTestID,Mt as assetDetailRowTestID,Re as assetFilterTestID,Pt as assetFindingTestID,Ot as assetFontChipTestID,se as assetRowTestID,Z as assetSlug,sr as assetsSyncAdapter,Ut as assetsToolPreset,$t as clearBaseline,$e as clearRecords,Dt as computeDiff,Te as computeInsights,De as computeStats,Xa as createAssetsTool,va as disableAssetsCapture,x as estDecodedBytes,Ca as fetchAssetGraph,St as formatAssetMarkdown,wt as formatInventoryMarkdown,yt as getBrowserAssetManifest,At as getDevServerOrigin,ye as getDiff,Fe as getLoadedFontFamilies,ra as getLocalAssets,ke as getRecord,Q as getScanStatus,F as getSnapshot,ce as installAssetCapture,It as loadBaseline,aa as loadBrowserAssetManifest,Tt as measureSizes,gt as registerBrowserAssetManifest,Sa as replaceAssetsFromSnapshot,ue as rescan,kt as saveBaseline,ba as setRemoteAssetsHandler,ar as startBrowserAssetCapture,le as subscribe,xt as useAssetRecords};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/assets",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.57",
|
|
4
4
|
"description": "Inspect assets reported by a manifest and runtime hooks, including available sizes, scale variants, duplicates and baseline changes.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"**/autoCapture.*"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@buoy-gg/shared-ui": "^7.0.
|
|
20
|
+
"@buoy-gg/shared-ui": "^7.0.57"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": "*"
|