@buoy-gg/assets 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.
Files changed (78) hide show
  1. package/README.md +4 -0
  2. package/bundlers/vite.d.ts +7 -0
  3. package/bundlers/vite.mjs +53 -0
  4. package/lib/commonjs/autoCapture.js +5 -0
  5. package/lib/commonjs/autoCapture.js.map +1 -0
  6. package/lib/commonjs/autoCapture.web.js +6 -0
  7. package/lib/commonjs/autoCapture.web.js.map +1 -0
  8. package/lib/commonjs/capture/assetLifecycle.js +11 -0
  9. package/lib/commonjs/capture/assetLifecycle.js.map +1 -0
  10. package/lib/commonjs/capture/assetLifecycle.web.js +20 -0
  11. package/lib/commonjs/capture/assetLifecycle.web.js.map +1 -0
  12. package/lib/commonjs/capture/browserAssets.js +83 -0
  13. package/lib/commonjs/capture/browserAssets.js.map +1 -0
  14. package/lib/commonjs/capture/expo.web.js +19 -0
  15. package/lib/commonjs/capture/expo.web.js.map +1 -0
  16. package/lib/commonjs/capture/install.web.js +75 -0
  17. package/lib/commonjs/capture/install.web.js.map +1 -0
  18. package/lib/commonjs/capture/measure.js +2 -1
  19. package/lib/commonjs/capture/measure.js.map +1 -1
  20. package/lib/commonjs/capture/metroGraph.web.js +27 -0
  21. package/lib/commonjs/capture/metroGraph.web.js.map +1 -0
  22. package/lib/commonjs/components/ScanNotice.js +1 -0
  23. package/lib/commonjs/components/ScanNotice.js.map +1 -1
  24. package/lib/commonjs/components/optionalExpoImage.web.js +0 -1
  25. package/lib/commonjs/components/optionalExpoImage.web.js.map +1 -1
  26. package/lib/commonjs/index.js +27 -46
  27. package/lib/commonjs/index.js.map +1 -1
  28. package/lib/module/autoCapture.js +5 -0
  29. package/lib/module/autoCapture.js.map +1 -0
  30. package/lib/module/autoCapture.web.js +5 -0
  31. package/lib/module/autoCapture.web.js.map +1 -0
  32. package/lib/module/capture/assetLifecycle.js +7 -0
  33. package/lib/module/capture/assetLifecycle.js.map +1 -0
  34. package/lib/module/capture/assetLifecycle.web.js +16 -0
  35. package/lib/module/capture/assetLifecycle.web.js.map +1 -0
  36. package/lib/module/capture/browserAssets.js +75 -0
  37. package/lib/module/capture/browserAssets.js.map +1 -0
  38. package/lib/module/capture/expo.web.js +14 -0
  39. package/lib/module/capture/expo.web.js.map +1 -0
  40. package/lib/module/capture/install.web.js +68 -0
  41. package/lib/module/capture/install.web.js.map +1 -0
  42. package/lib/module/capture/measure.js +2 -1
  43. package/lib/module/capture/measure.js.map +1 -1
  44. package/lib/module/capture/metroGraph.web.js +21 -0
  45. package/lib/module/capture/metroGraph.web.js.map +1 -0
  46. package/lib/module/components/ScanNotice.js +1 -0
  47. package/lib/module/components/ScanNotice.js.map +1 -1
  48. package/lib/module/components/optionalExpoImage.web.js +0 -1
  49. package/lib/module/components/optionalExpoImage.web.js.map +1 -1
  50. package/lib/module/index.js +3 -2
  51. package/lib/module/index.js.map +1 -1
  52. package/lib/typescript/autoCapture.d.ts +2 -0
  53. package/lib/typescript/autoCapture.d.ts.map +1 -0
  54. package/lib/typescript/autoCapture.web.d.ts +2 -0
  55. package/lib/typescript/autoCapture.web.d.ts.map +1 -0
  56. package/lib/typescript/capture/assetLifecycle.d.ts +3 -0
  57. package/lib/typescript/capture/assetLifecycle.d.ts.map +1 -0
  58. package/lib/typescript/capture/assetLifecycle.web.d.ts +2 -0
  59. package/lib/typescript/capture/assetLifecycle.web.d.ts.map +1 -0
  60. package/lib/typescript/capture/browserAssets.d.ts +13 -0
  61. package/lib/typescript/capture/browserAssets.d.ts.map +1 -0
  62. package/lib/typescript/capture/expo.web.d.ts +3 -0
  63. package/lib/typescript/capture/expo.web.d.ts.map +1 -0
  64. package/lib/typescript/capture/install.web.d.ts +6 -0
  65. package/lib/typescript/capture/install.web.d.ts.map +1 -0
  66. package/lib/typescript/capture/measure.d.ts +0 -10
  67. package/lib/typescript/capture/measure.d.ts.map +1 -1
  68. package/lib/typescript/capture/metroGraph.web.d.ts +12 -0
  69. package/lib/typescript/capture/metroGraph.web.d.ts.map +1 -0
  70. package/lib/typescript/components/ScanNotice.d.ts.map +1 -1
  71. package/lib/typescript/components/optionalExpoImage.web.d.ts +1 -1
  72. package/lib/typescript/components/optionalExpoImage.web.d.ts.map +1 -1
  73. package/lib/typescript/index.d.ts +3 -0
  74. package/lib/typescript/index.d.ts.map +1 -1
  75. package/lib/typescript/types.d.ts +2 -1
  76. package/lib/typescript/types.d.ts.map +1 -1
  77. package/lib/web/index.mjs +4 -0
  78. package/package.json +46 -7
@@ -0,0 +1,4 @@
1
+ "use client";
2
+ var Le=Object.defineProperty;var ns=Object.getOwnPropertyDescriptor;var rs=Object.getOwnPropertyNames;var is=Object.prototype.hasOwnProperty;var wt=(e,t)=>()=>(e&&(t=e(e=0)),t);var as=(e,t)=>{for(var s in t)Le(e,s,{get:t[s],enumerable:!0})},Ee=(e,t,s,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of rs(t))!is.call(e,n)&&n!==s&&Le(e,n,{get:()=>t[n],enumerable:!(o=ns(t,n))||o.enumerable});return e},x=(e,t,s)=>(Ee(e,t,"default"),s&&Ee(s,t,"default"));var It=e=>Ee(Le({},"__esModule",{value:!0}),e);var a=wt(()=>{"use strict";typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis)});var A={};as(A,{AccessibilityInfo:()=>As,ActivityIndicator:()=>We,Alert:()=>ys,Animated:()=>vs,AppRegistry:()=>ws,AppState:()=>Is,Appearance:()=>xs,BackHandler:()=>Rs,Button:()=>hs,CheckBox:()=>Ws,Clipboard:()=>Ts,DeviceEventEmitter:()=>eo,Dimensions:()=>Bs,Easing:()=>Ds,FlatList:()=>_e,I18nManager:()=>Cs,Image:()=>Ne,ImageBackground:()=>_s,InteractionManager:()=>zs,Keyboard:()=>ks,KeyboardAvoidingView:()=>Ns,LayoutAnimation:()=>Fs,Linking:()=>$s,LogBox:()=>Zs,Modal:()=>fs,NativeEventEmitter:()=>Es,NativeModules:()=>Ss,PanResponder:()=>Ls,Picker:()=>Hs,PixelRatio:()=>Ps,Platform:()=>se,Pressable:()=>ps,ProgressBar:()=>Ks,RefreshControl:()=>Us,SafeAreaView:()=>Gs,ScrollView:()=>Ve,SectionList:()=>js,Share:()=>Os,StatusBar:()=>qs,StyleSheet:()=>D,Switch:()=>ms,Text:()=>y,TextInput:()=>Me,Touchable:()=>Ys,TouchableHighlight:()=>us,TouchableNativeFeedback:()=>Js,TouchableOpacity:()=>P,TouchableWithoutFeedback:()=>ds,UIManager:()=>Ms,Vibration:()=>Vs,View:()=>g,VirtualizedList:()=>Qs,YellowBox:()=>Xs,findNodeHandle:()=>gs,unstable_createElement:()=>bs,useColorScheme:()=>to,useLocaleContext:()=>so,useWindowDimensions:()=>oo});import*as pn from"react-native-web";import{unstable_createElement as bs,NativeModules as Ss,AccessibilityInfo as As,Animated as vs,Appearance as xs,AppRegistry as ws,AppState as Is,BackHandler as Rs,Clipboard as Ts,Dimensions as Bs,Easing as Ds,I18nManager as Cs,Keyboard as ks,InteractionManager as zs,LayoutAnimation as Fs,Linking as $s,NativeEventEmitter as Es,PanResponder as Ls,PixelRatio as Ps,Platform as se,Share as Os,StyleSheet as D,UIManager as Ms,Vibration as Vs,CheckBox as Ws,FlatList as _e,Image as Ne,ImageBackground as _s,KeyboardAvoidingView as Ns,Picker as Hs,ProgressBar as Ks,RefreshControl as Us,SafeAreaView as Gs,SectionList as js,StatusBar as qs,Touchable as Ys,TouchableNativeFeedback as Js,VirtualizedList as Qs,YellowBox as Xs,LogBox as Zs,DeviceEventEmitter as eo,useColorScheme as to,useLocaleContext as so,useWindowDimensions as oo}from"react-native-web";import*as S from"react-native-web";import{createElement as ls,forwardRef as cs}from"react";function L(e){let t=cs((o,n)=>{let{accessibilityState:r,accessibilityValue:i,...l}=o;for(let u of["busy","checked","disabled","expanded","selected"])r?.[u]!==void 0&&l[`aria-${u}`]===void 0&&(l[`aria-${u}`]=r[u]);for(let[u,c]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))i?.[u]!==void 0&&l[`aria-${c}`]===void 0&&(l[`aria-${c}`]=i[u]);return ls(e,{...l,ref:n})}),s=e.State;return s&&Object.assign(t,{State:s}),t.displayName=e.displayName??e.name??"NativeWebView",t}var g,y,Me,P,us,ds,ps,Ve,fs,ms,We,hs,gs,ys,O=wt(()=>{a();x(A,pn);g=L(S.View),y=L(S.Text),Me=L(S.TextInput),P=L(S.TouchableOpacity),us=L(S.TouchableHighlight),ds=L(S.TouchableWithoutFeedback),ps=L(S.Pressable),Ve=L(S.ScrollView),fs=L(S.Modal),ms=L(S.Switch),We=L(S.ActivityIndicator),hs=L(S.Button),gs=S.findNodeHandle,ys={alert(e,t,s,o){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 r=document.createElement("h2");if(r.textContent=e,r.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(r),t){let c=document.createElement("p");c.textContent=t,c.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(c)}let i=document.createElement("div");i.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let l=s?.length?s:[{text:"OK"}],u=()=>{n.close?.(),n.remove()};for(let c of l){let m=document.createElement("button");m.type="button",m.textContent=c.text??"OK",m.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${c.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,m.onclick=()=>{u(),c.onPress?.()},i.appendChild(m)}n.addEventListener("cancel",c=>{c.preventDefault(),o?.cancelable!==!1&&(u(),o?.onDismiss?.())}),n.appendChild(i),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}}});a();a();a();import{AssetsIcon as Pe,ASSETS_ICON_COLOR as Oe}from"@buoy-gg/shared-ui/web";a();O();import{useEffect as Yt,useState as Ae}from"react";import{EventStepperFooter as _o,JsModal as No,macOSColors as Ho,night as W,windowDragProps as Ko,ToolEmptyState as Uo}from"@buoy-gg/shared-ui/web";a();a();var He=Symbol.for("buoy.assets.globalState.v1");function p(){let e=globalThis;return e[He]||(e[He]={records:[],byKey:new Map,byId:new Map,nextId:1,listeners:new Set,snapshot:[],emitScheduled:!1,installed:!1,patched:!1,registryAvailable:!1,graphSupported:!1,graphCount:null,graphError:null,graphFetchInFlight:!1,lastScanAt:null,measuring:!1,measuredCount:0,fontFamilies:[],localAssetCount:null,baseline:null,baselineLoaded:!1,captureDisabled:!1,remoteDispatch:null,mirrorScanStatus:null,mirrorPixelRatio:null,mirrorDiff:null}),e[He]}a();a();function Ke(e){if(!e)return!1;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 Rt(e){return[e.key,e.httpServerLocation,e.fileSystemLocation,...e.files??[]].some(Ke)}a();function xe(){let e=p().mirrorPixelRatio;if(e!=null)return e;try{return(O(),It(A)).PixelRatio.get()}catch{return 2}}function Tt(e,t){if(!e.length)return 1;let s=[...e].sort((o,n)=>o-n);for(let o of s)if(o>=t)return o;return s[s.length-1]}function no(){let e=p();e.emitScheduled||(e.emitScheduled=!0,requestAnimationFrame(()=>{e.emitScheduled=!1;for(let t of e.listeners)t()}))}function C(){let e=p();e.snapshot=[...e.records],no()}var ro={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 io(e){return ro[e.toLowerCase()]??"other"}function Bt(e){if(Rt(e))return;let t=p(),s=t.byKey.get(e.key);return s||(s={id:t.nextId++,key:e.key,name:e.name,type:e.type,kind:io(e.type),scales:e.scales??[],loaded:e.loaded??!1,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((o,n)=>o-n)),e.resolvedUri!=null&&(s.resolvedUri=e.resolvedUri),e.resolvedScale!=null&&(s.resolvedScale=e.resolvedScale),e.loaded&&(s.loaded=!0),e.fileSystemLocation!=null&&(s.fileSystemLocation=e.fileSystemLocation),e.files&&(s.files=e.files),e.fileHashes&&(s.fileHashes=e.fileHashes),C(),s}function oe(e,t){let o=p().byId.get(e);if(o)return Object.assign(o,t),C(),o}function he(e){return p().byId.get(e)}function T(){return p().snapshot}function G(e){return p().listeners.add(e),()=>p().listeners.delete(e)}function ge(){let e=p();e.records=[],e.byKey=new Map,e.byId=new Map,e.measuredCount=0,e.graphCount=null,C()}function I(e){if(e.kind!=="image"||!e.width||!e.height)return 0;let t=e.resolvedScale??Tt(e.scales,xe());return Math.round(e.width*t*e.height*t*4)}function ye(e){let t=p(),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}},o={total:e.length,loaded:0,neverLoaded:0,byKind:s,totalBytes:0,measuredCount:0,fontFamilies:t.fontFamilies.length};for(let n of e)n.loaded?o.loaded++:o.neverLoaded++,s[n.kind].count++,n.sizeBytes!=null&&n.sizeSource==="measured"&&(s[n.kind].bytes+=n.sizeBytes,o.totalBytes+=n.sizeBytes,o.measuredCount++);return o}a();var ne=[];function Dt(e){ne=e,typeof document<"u"&&re()}function Ge(){return ne}async function ao(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(o=>!o||typeof o.url!="string"))throw new Error("An asset manifest must contain an array of assets with URL strings.");Dt(s)}function Ue(e,t){let s;try{s=new URL(e.url,document.baseURI)}catch{return}let o=s.pathname.split("/").pop()??"",n=o.includes(".")?o.split(".").pop().toLowerCase():"other",r=Bt({key:s.href,name:o.slice(0,-(n.length+1))||o,type:n,origin:t?"browser":"graph",resolvedUri:s.href,resolvedScale:1,scales:[1],hash:e.hash,loaded:t,width:e.width,height:e.height});r&&e.bytes!==void 0&&e.bytes>=0&&oe(r.id,{sizeBytes:e.bytes,sizesByScale:{1:e.bytes},sizeSource:"measured"})}function je(e){e.initiatorType==="fetch"||e.initiatorType==="xmlhttprequest"||Ue({url:e.name,bytes:e.encodedBodySize>0?e.encodedBodySize:void 0},!0)}function re(){if(typeof document>"u"||p().captureDisabled)return;ne.forEach(t=>Ue(t,!1)),performance.getEntriesByType("resource").forEach(t=>je(t)),document.querySelectorAll("img").forEach(t=>{!t.closest("[data-buoy-root]")&&t.currentSrc&&Ue({url:t.currentSrc,width:t.naturalWidth||void 0,height:t.naturalHeight||void 0},t.complete&&t.naturalWidth>0)});let e=p();e.graphSupported=ne.length>0,e.graphCount=ne.length>0?ne.length:null,e.measuredCount=e.records.filter(t=>t.sizeBytes!==void 0).length,e.lastScanAt=Date.now()}a();function we(){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 lo(){return null}var ie;function ae(){let e=p();if(!(typeof document>"u"||e.captureDisabled||e.installed)){if(e.installed=!0,e.registryAvailable=!0,typeof PerformanceObserver<"u"){ie=new PerformanceObserver(t=>{if(p().captureDisabled){qe();return}t.getEntries().forEach(s=>je(s))});try{ie.observe({type:"resource",buffered:!0}),e.patched=!0}catch{ie.disconnect(),ie=void 0}}re(),e.fontFamilies=we(),C()}}function qe(){ie?.disconnect(),ie=void 0,p().installed=!1,p().patched=!1}async function le(){return ae(),re(),p().fontFamilies=we(),C(),_()}function _(){let e=p();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:!1,graphFetchStartedAt:null,lastScanAt:e.lastScanAt,measuring:!1,measuredCount:e.measuredCount,fontFamilies:e.fontFamilies,localAssetCount:null,browser:!0}}a();a();function k(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 j(e){let t=[...new Set(e)].sort((s,o)=>s-o);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 q(e){return e.width==null||e.height==null?"\u2014":`${Math.round(e.width)}\xD7${Math.round(e.height)}`}function Ct(e,t){return e.sizeBytes!=null&&e.sizeSource==="measured"?k(e.sizeBytes):t>0?`~${k(t)}`:"\u2014"}var Ie={image:"IMG",font:"FONT",video:"VID",audio:"AUD",data:"DATA",other:"MISC"},Re={image:"#2DD4BF",font:"#C084FC",video:"#FF9F1C",audio:"#FF3366",data:"#00D4FF",other:"#8E8E93"};function Ye(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: ${q(e)} (logical)`),e.scales.length&&t.push(`- Scales: ${j(e.scales)}`),e.sizeBytes!=null&&e.sizeSource==="measured"&&t.push(`- Size (all variants): ${k(e.sizeBytes)}`);let s=I(e);return s>0&&t.push(`- Decoded memory: ~${k(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(`
3
+ `)}function Je(e,t,s,o,n){let r=["# Asset inventory","",`${t.total} assets \xB7 ${t.loaded} loaded \xB7 ${t.neverLoaded} not observed`+(t.totalBytes>0?` \xB7 ${k(t.totalBytes)} measured (${t.measuredCount}/${t.total})`:"")];if(o.fontFamilies.length&&r.push(`Fonts loaded: ${o.fontFamilies.join(", ")}`),o.graphSupported||r.push(o.graphError?`_Metro bundle graph unavailable (${o.graphError}) \u2014 runtime-registered assets only._`:"_No Metro bundle graph \u2014 runtime-registered assets only (release build)._"),n){let l=n.netBytes!=null?`${n.netBytes>=0?"+":"\u2212"}${k(Math.abs(n.netBytes))} net`:"net size unknown";r.push("",`## Since baseline (${new Date(n.baselineSavedAt).toISOString()})`,`- ${n.added.length} added \xB7 ${n.removed.length} removed \xB7 ${n.grown.length} grew \xB7 ${l}`);for(let u of n.removed.slice(0,20))r.push(`- removed: ${u.name}.${u.type}`)}let i=[];s.neverLoaded.length&&i.push(`- ${s.neverLoaded.length} shipped but not observed`),s.duplicates.length&&i.push(`- ${s.duplicates.length} duplicate content groups`),s.webpCandidates.length&&i.push(`- ${s.webpCandidates.length} WebP conversion candidates`),s.scaleGaps.length&&i.push(`- ${s.scaleGaps.length} scale-coverage gaps`),s.overDecode.length&&i.push(`- ${s.overDecode.length} images decoding larger than 2\xD7 the screen`),s.heavyGifs.length&&i.push(`- ${s.heavyGifs.length} heavy GIFs (convert to video/Lottie)`),s.heavyFonts.length&&i.push(`- ${s.heavyFonts.length} heavy fonts (subset candidates)`),s.scaleAnomalies.length&&i.push(`- ${s.scaleAnomalies.length} scale-variant anomalies (check exports)`),i.length&&r.push("","## Findings",...i),r.push("","## Assets (largest first)","","| Asset | Kind | Dimensions | Scales | Size | Loaded |","| --- | --- | --- | --- | --- | --- |");for(let l of e){let u=l.sizeBytes!=null&&l.sizeSource==="measured"?k(l.sizeBytes):I(l)>0?`~${k(I(l))}`:"\u2014";r.push(`| ${l.name}.${l.type} | ${l.kind} | ${l.kind==="image"?q(l):"\u2014"} | ${j(l.scales)} | ${u} | ${l.loaded?"yes":"NO"} |`)}return r.join(`
4
+ `)}a();import{useMemo as bo,useSyncExternalStore as So}from"react";a();var co=50*1024,uo=100*1024,po=150*1024,fo=2,mo=.9,ho=4*1024;function go(){try{let{Dimensions:e,PixelRatio:t}=(O(),It(A)),s=e.get("screen"),o=t.get();return s.width*o*s.height*o}catch{return 1170*2532}}function yo(e){let t=e.sizesByScale;if(!t)return!1;let s=Object.entries(t).map(([o,n])=>({scale:Number(o),bytes:n})).filter(o=>Number.isFinite(o.scale)&&o.bytes>0).sort((o,n)=>o.scale-n.scale);for(let o=1;o<s.length;o++)if(s[o-1].bytes>=ho&&s[o].bytes<s[o-1].bytes*mo)return!0;return!1}function be(e){let t=xe(),s=new Map;for(let d of e){if(!d.hash)continue;let E=s.get(d.hash);E?E.push(d):s.set(d.hash,[d])}let o=[];for(let[d,E]of s){if(E.length<2)continue;let Z=E.find(z=>z.sizeBytes!=null);o.push({hash:d,ids:E.map(z=>z.id),wastedBytes:Z?.sizeBytes!=null?Z.sizeBytes*(E.length-1):null})}let n=go(),r=[],i=[],l=[],u=[],c=[],m=[],v=[];for(let d of e)d.loaded||l.push(d.id),d.kind==="image"&&d.scales.length>1&&!d.scales.some(E=>E>=t)&&r.push(d.id),(d.type==="png"||d.type==="jpg"||d.type==="jpeg")&&d.sizeBytes!=null&&d.sizeBytes>=co&&i.push(d.id),d.kind==="image"&&I(d)/4>n*fo&&u.push(d.id),d.type==="gif"&&(d.sizeBytes??0)>=uo&&c.push(d.id),d.kind==="font"&&(d.sizeBytes??0)>=po&&m.push(d.id),yo(d)&&v.push(d.id);return{duplicates:o,scaleGaps:r,webpCandidates:i,neverLoaded:l,overDecode:u,heavyGifs:c,heavyFonts:m,scaleAnomalies:v}}function Qe(){let e=So(G,T,T);return bo(()=>({records:e,stats:ye(e),insights:be(e)}),[e])}a();import{useSyncExternalStore as Ao}from"react";var kt,zt;function Ft(){let e=T();return e!==kt&&(kt=e,zt=_()),zt}function $t(){return Ao(G,Ft,Ft)}a();function vo(e){p().remoteDispatch=e}function ce(){return p().remoteDispatch}function xo(){p().captureDisabled=!0}function wo(e){let t=p(),s=e.records??[];t.records=s.map(o=>({id:o.id,key:o.key,registryId:o.registryId??void 0,name:o.name,type:o.type,kind:o.kind,hash:o.hash??void 0,httpServerLocation:o.location??void 0,width:o.width??void 0,height:o.height??void 0,scales:o.scales,resolvedUri:o.uri??void 0,loaded:o.loaded,origin:o.registryId!=null?"registry":"graph",sizeBytes:o.sizeBytes??void 0,sizeSource:o.sizeSource??void 0,firstSeenAt:Date.now()})),t.byKey=new Map(t.records.map(o=>[o.key,o])),t.byId=new Map(t.records.map(o=>[o.id,o])),e.scanStatus&&(t.fontFamilies=[...new Set(e.scanStatus.fontFamilies??[])],t.mirrorScanStatus={...e.scanStatus,fontFamilies:t.fontFamilies}),t.mirrorDiff=e.diff??null,C()}a();import{persistentStorage as Xe}from"@buoy-gg/shared-ui/web";var Ze="@react_buoy/assets/baseline",Io=1024;async function et(){let e=p();if(e.baselineLoaded)return e.baseline;e.baselineLoaded=!0;try{let t=await Xe.getItem(Ze);if(t){let s=JSON.parse(t);s&&typeof s.savedAt=="number"&&s.entries&&(e.baseline=s,C())}}catch{}return e.baseline}async function tt(){let e=ce();if(e)return await e("saveBaseline"),p().baseline??{savedAt:Date.now(),entries:{}};let t=p(),s={};for(let n of T())s[n.key]={hash:n.hash??null,sizeBytes:n.sizeSource==="measured"?n.sizeBytes??null:null,name:n.name,type:n.type};let o={savedAt:Date.now(),entries:s};t.baseline=o,t.baselineLoaded=!0,C();try{await Xe.setItem(Ze,JSON.stringify(o))}catch{}return o}async function st(){let e=ce();if(e){await e("clearBaseline");return}let t=p();t.baseline=null,t.baselineLoaded=!0,C();try{await Xe.removeItem(Ze)}catch{}}function Et(e,t){let s=[],o=[],n=new Set,r=0,i=0,l=!1;for(let c of e){n.add(c.key);let m=t.entries[c.key];if(!m){s.push(c.id);continue}let v=c.sizeSource==="measured"?c.sizeBytes??null:null;v!=null&&m.sizeBytes!=null&&(l=!0,r+=v,i+=m.sizeBytes,v-m.sizeBytes>=Io&&o.push({id:c.id,deltaBytes:v-m.sizeBytes}))}let u=[];for(let[c,m]of Object.entries(t.entries))Ke(c)||n.has(c)||(u.push({key:c,name:m.name,type:m.type}),m.sizeBytes!=null&&(l=!0,i+=m.sizeBytes));for(let c of s){let m=e.find(v=>v.id===c);m?.sizeSource==="measured"&&m.sizeBytes!=null&&(l=!0,r+=m.sizeBytes)}return{baselineSavedAt:t.savedAt,added:s,removed:u,grown:o.sort((c,m)=>m.deltaBytes-c.deltaBytes),netBytes:l?r-i:null}}function ue(){let e=p();return e.mirrorDiff?e.mirrorDiff:e.baseline?Et(T(),e.baseline):null}a();O();import{night as Y}from"@buoy-gg/shared-ui/web";a();O();import{useState as zo}from"react";import{night as Fo}from"@buoy-gg/shared-ui/web";a();O();a();function ot(){return null}async function Ro(){re();let e=Ge().length;return e?{ok:!0,count:e}:{ok:!1,message:"Register a browser asset manifest to inspect files that have not loaded yet."}}var To=4;function Bo(e){if(e.resolvedUri)return e.resolvedUri;let t=Pt(e);return t.length?t[0].url:null}function Lt(e){let t=p().captureDisabled;if(!t&&e.registryId!=null)return e.registryId;let s=Bo(e);return!s||t&&!/^https?:\/\//.test(s)?null:{uri:s}}function Pt(e){let t=e.scales.length?e.scales:[1],s=e.resolvedUri;if(s&&/^https?:\/\//.test(s)&&e.resolvedScale!=null){let n=e.resolvedScale===1?"":`@${e.resolvedScale}x`,r=`${n}.${e.type}`;if(s.includes(r)||n==="")return t.map(i=>{let l=i===1?"":`@${i}x`,u=(n===""?s.replace(`.${e.type}`,`${l}.${e.type}`):s.replace(r,`${l}.${e.type}`)).replace(/ /g,"%20");return{scale:i,url:u}})}let o=ot();return!o||!e.httpServerLocation?[]:t.map(n=>{let r=n===1?"":`@${n}x`,i=`${e.httpServerLocation}/${e.name}${r}.${e.type}`,l=i.includes("?")?"&":"?",u=`${o}${i}${l}platform=${Do()}${e.hash?`&hash=${e.hash}`:""}`.replace(/ /g,"%20");return{scale:n,url:u}})}function Do(){try{return se.OS}catch{return"ios"}}async function Co(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 ko(e){let t=Pt(e);if(!t.length){oe(e.id,{sizeSource:"estimate"});return}let s={},o=0;for(let{scale:n,url:r}of t){let i=await Co(r);i!=null&&(s[String(n)]=i,o+=i)}o>0?oe(e.id,{sizesByScale:s,sizeBytes:o,sizeSource:"measured"}):oe(e.id,{sizeSource:"estimate"})}async function nt(){let e=p();if(e.measuring)return{measured:e.measuredCount,total:T().length};let t=T().filter(s=>s.sizeSource!=="measured");e.measuring=!0,C();try{let s=0,o=async()=>{for(;;){let n=t[s++];if(!n)return;await ko(n),e.measuredCount=T().filter(r=>r.sizeSource==="measured").length}};await Promise.all(Array.from({length:Math.min(To,t.length)},o))}finally{e.measuring=!1,C()}return{measured:e.measuredCount,total:T().length}}a();function Ot(){return null}import{jsx as Te}from"react/jsx-runtime";function Be({record:e,style:t,testID:s,compact:o=!1}){let n=Lt(e),r=e.type.toLowerCase()==="svg",i=r&&se.OS!=="web"?Ot():null,l=`${e.key}:${e.hash??""}:${typeof n=="number"?n:n?.uri??""}`,[u,c]=zo(null);if(n==null||u===l||r&&se.OS!=="web"&&!i){let d=r?"SVG preview unavailable":"Image preview unavailable";return Te(g,{style:[t,Mt.fallback],accessibilityLabel:d,testID:`${s}-unavailable`,children:Te(y,{style:Mt.text,children:o?r?"SVG":"IMG":d})})}let v=()=>c(l);return i?Te(i,{source:n,style:t,contentFit:"contain",onError:v,testID:s}):Te(Ne,{source:n,style:t,resizeMode:"contain",onError:v,testID:s})}var Mt=D.create({fallback:{alignItems:"center",justifyContent:"center"},text:{color:Fo.color.textSecondary,fontSize:10,textAlign:"center"}});a();function de(e){return String(e).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function pe(e,t){return`buoy-assets-row-${de(`${e}.${t}`)}`}function rt(e,t,s){return`${pe(e,t)}-badge-${de(s)}`}function De(e){return`buoy-assets-filter-${de(e)}`}function it(e){return`buoy-assets-detail-row-${de(e)}`}function at(e){return`buoy-assets-font-${de(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 lt(e){return`buoy-assets-detail-finding-${e}`}import{jsx as w,jsxs as Wt}from"react/jsx-runtime";function $({label:e,value:t}){let s=it(e);return Wt(g,{style:M.kvRow,testID:s,children:[w(y,{style:M.kvLabel,children:e}),w(y,{style:M.kvValue,selectable:!0,testID:`${s}-value`,children:t})]})}function $o({record:e}){return e.kind==="image"?w(g,{style:M.previewBox,testID:b.detailPreview,children:w(Be,{testID:"buoy-internal-assets-preview",record:e,style:M.previewImage})}):e.kind==="font"?w(g,{style:M.previewBox,testID:b.detailFontPreview,children:w(y,{style:[M.fontPreview,{fontFamily:e.name}],children:"The quick brown fox jumps over the lazy dog 0123456789"})}):null}function Vt({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 o=t.duplicates.find(r=>r.ids.includes(e.id));o&&s.push(`Duplicate content \u2014 identical bytes shipped ${o.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 n=I(e);return Wt(Ve,{style:M.scroll,contentContainerStyle:M.content,testID:b.detailScroll,children:[w($o,{record:e}),s.length>0?w(g,{style:M.findings,testID:b.detailFindings,children:s.map((r,i)=>w(y,{style:M.findingText,testID:lt(i),children:r},r))}):null,w($,{label:"Name",value:`${e.name}.${e.type}`}),w($,{label:"Kind",value:e.kind}),w($,{label:"Status",value:e.loaded?"Loaded (registered at runtime)":"Not observed in the runtime registry"}),e.kind==="image"?w($,{label:"Dimensions",value:`${q(e)} (logical)`}):null,e.kind==="image"&&e.scales.length?w($,{label:"Scales",value:j(e.scales)}):null,e.sizesByScale?Object.entries(e.sizesByScale).map(([r,i])=>w($,{label:`Size @${r}x`,value:k(i)},r)):null,e.sizeBytes!=null&&e.sizeSource==="measured"?w($,{label:"Total size",value:k(e.sizeBytes)}):null,n>0?w($,{label:"Decoded memory",value:`~${k(n)} (RGBA)`}):null,e.registryId!=null?w($,{label:"Registry id",value:String(e.registryId)}):null,e.hash?w($,{label:"Hash",value:e.hash}):null,e.httpServerLocation?w($,{label:"Location",value:e.httpServerLocation}):null,e.fileSystemLocation?w($,{label:"Source dir",value:e.fileSystemLocation}):null,e.resolvedUri?w($,{label:"Resolved URI",value:e.resolvedUri}):null]})}var M=D.create({scroll:{flex:1},content:{padding:12,gap:8},previewBox:{borderRadius:8,backgroundColor:Y.color.bg,padding:12,alignItems:"center",justifyContent:"center",minHeight:96},previewImage:{width:"100%",height:140},fontPreview:{color:Y.color.text,fontSize:16,textAlign:"center"},findings:{borderRadius:8,borderWidth:1,borderColor:Y.color.border,backgroundColor:Y.color.surface,padding:10,gap:6},findingText:{color:Y.color.textSecondary,fontSize:11,lineHeight:15},kvRow:{gap:2},kvLabel:{color:Y.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,textTransform:"uppercase"},kvValue:{color:Y.color.text,fontSize:12}});a();O();import{macOSColors as ct,night as J,Pill as Eo}from"@buoy-gg/shared-ui/web";import{jsx as V,jsxs as Q}from"react/jsx-runtime";function Lo({label:e,color:t,testID:s}){return V(Eo,{label:e,color:t,variant:"quiet",dot:!!t,style:{paddingVertical:2.5},testID:s})}function _t({record:e,flags:t,sizeFraction:s,onPress:o}){let n=Re[e.kind],r=[];return e.loaded||r.push({label:"NOT OBSERVED"}),t.oversize&&r.push({label:"OVERSIZE",color:ct.semantic.error}),t.duplicate&&r.push({label:"DUP"}),t.heavy&&r.push({label:"HEAVY"}),t.scaleAnomaly?r.push({label:"BAD SCALE",color:ct.semantic.error}):t.scaleGap&&r.push({label:"LOW-RES"}),t.webp&&r.push({label:"WEBP",color:ct.semantic.info}),Q(P,{style:B.card,testID:pe(e.name,e.type),onPress:()=>o(e.id),activeOpacity:.7,children:[Q(g,{style:B.body,children:[V(g,{style:B.thumbBox,children:e.kind==="image"?V(Be,{testID:"buoy-internal-assets-thumb",record:e,style:B.thumb,compact:!0}):V(y,{style:[B.thumbFallback,{color:n}],children:Ie[e.kind]})}),Q(g,{style:B.main,children:[Q(y,{style:B.name,numberOfLines:1,testID:`${pe(e.name,e.type)}-name`,children:[e.name,Q(y,{style:B.ext,children:[".",e.type]})]}),Q(g,{style:B.metaRow,children:[e.kind==="image"&&e.width!=null?V(y,{style:B.meta,children:q(e)}):null,e.kind==="image"&&e.scales.length?V(y,{style:B.meta,children:j(e.scales)}):null]})]}),Q(g,{style:B.right,children:[V(y,{style:B.size,testID:`${pe(e.name,e.type)}-size`,children:Ct(e,I(e))}),r.length?V(g,{style:B.badgeRow,children:r.slice(0,3).map(i=>V(Lo,{label:i.label,color:i.color,testID:rt(e.name,e.type,i.label)},i.label))}):null]})]}),s>0?V(g,{style:B.sizeTrack,children:V(g,{style:[B.sizeFill,{backgroundColor:n,width:`${Math.max(2,Math.round(s*100))}%`}]})}):null]})}var B=D.create({card:{marginHorizontal:10,marginTop:6,borderRadius:10,backgroundColor:J.color.surface,borderWidth:1,borderColor:J.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:J.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:J.color.text,fontSize:12,fontWeight:"600"},ext:{color:J.color.textTertiary,fontWeight:"400"},metaRow:{flexDirection:"row",alignItems:"center",gap:8},meta:{color:J.color.textSecondary,fontSize:10,fontVariant:["tabular-nums"]},right:{alignItems:"flex-end",gap:4},size:{color:J.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}});a();O();import{night as Ce}from"@buoy-gg/shared-ui/web";import{jsx as dt}from"react/jsx-runtime";function Nt({stats:e,duplicateCount:t,filter:s,onChange:o}){let n=[{key:"all",label:`ALL ${e.total}`,accent:Ce.color.textSecondary},{key:"duplicates",label:`DUPLICATES ${t}`,accent:"#FF9F1C"}];for(let r of Object.keys(e.byKind)){let i=e.byKind[r];i.count>0&&n.push({key:r,label:`${Ie[r]} ${i.count}`,accent:Re[r]})}return e.neverLoaded>0&&n.push({key:"unused",label:`NOT OBSERVED ${e.neverLoaded}`,accent:"#FF9F1C"}),n.length<=1?null:dt(g,{style:ut.bar,testID:b.filterBar,children:n.map(r=>{let i=r.key===s;return dt(P,{accessibilityRole:"button",accessibilityState:{selected:i},testID:De(r.key),style:[ut.chip,i&&{borderColor:r.accent,backgroundColor:`${r.accent}1A`}],onPress:()=>o(i?"all":r.key),children:dt(y,{testID:`${De(r.key)}-label`,style:[ut.chipText,{color:i?r.accent:Ce.color.textSecondary}],children:r.label})},r.key)})})}var ut=D.create({bar:{flexDirection:"row",flexWrap:"wrap",gap:6,paddingHorizontal:10,paddingVertical:8},chip:{borderWidth:1,borderColor:Ce.color.border,backgroundColor:Ce.color.surface,borderRadius:999,paddingHorizontal:10,paddingVertical:5},chipText:{fontSize:10,fontWeight:"700",letterSpacing:.4,lineHeight:13}});a();import{ModalHeader as H,ToolbarClearButton as Po,ToolbarCopyButton as Ht}from"@buoy-gg/shared-ui/web";import{jsx as K,jsxs as pt}from"react/jsx-runtime";function Kt({stats:e,measuring:t,discovering:s=!1,detailOpen:o,detailIndex:n=-1,detailTotal:r=0,onCloseDetail:i,onClear:l,getReport:u,onBack:c}){if(o){let v=n>=0&&r>0?`${n+1} of ${r}`:void 0;return pt(H,{children:[K(H.Navigation,{onBack:i}),K(H.Content,{title:"Asset detail",subtitle:v,testID:b.title}),K(H.Actions,{children:K(Ht,{value:u,testID:b.copy})})]})}let m=[`${e.total} assets${s?" so far":""}`];if(e.totalBytes>0&&!t&&!s){let v=e.measuredCount<e.total?"+":"";m.push(`${k(e.totalBytes)}${v}`)}return e.neverLoaded>0&&m.push(`${e.neverLoaded} not observed`),e.fontFamilies>0&&m.push(`${e.fontFamilies} fonts`),pt(H,{children:[c?K(H.Navigation,{onBack:c}):null,K(H.Content,{title:"Assets",subtitle:m.join(" \xB7 "),testID:b.title}),pt(H.Actions,{children:[K(Ht,{value:u,testID:b.copy}),K(Po,{onPress:l,testID:b.clear})]})]})}a();O();import{night as X}from"@buoy-gg/shared-ui/web";import{jsx as Ut,jsxs as Gt}from"react/jsx-runtime";var Oo={size:"name",name:"type",type:"size"};function jt({query:e,onQueryChange:t,sort:s,onSortChange:o}){return Gt(g,{style:ke.row,children:[Ut(Me,{style:ke.input,value:e,onChangeText:t,placeholder:"Search assets\u2026",placeholderTextColor:X.color.placeholder,autoCapitalize:"none",autoCorrect:!1,testID:b.search}),Ut(P,{style:ke.button,onPress:()=>o(Oo[s]),testID:b.sort,children:Gt(y,{style:ke.buttonText,testID:`${b.sort}-label`,children:["\u2193 ",s.toUpperCase()]})})]})}var ke=D.create({row:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:10,paddingBottom:8},input:{flex:1,backgroundColor:X.color.surfaceElevated,borderWidth:1,borderColor:X.color.border,borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:X.color.text,fontSize:12},button:{backgroundColor:X.color.surface,borderWidth:1,borderColor:X.color.border,borderRadius:8,paddingHorizontal:10,paddingVertical:7},buttonText:{color:X.color.textSecondary,fontSize:10,fontWeight:"700",letterSpacing:.5}});a();O();import{useEffect as Mo,useState as Vo}from"react";import{night as Se}from"@buoy-gg/shared-ui/web";import{jsx as ze,jsxs as Wo}from"react/jsx-runtime";function qt({status:e,total:t,onRetry:s}){let[o,n]=Vo(!1);Mo(()=>{if(n(!1),!e.graphFetchInFlight)return;let l=e.graphFetchStartedAt==null?0:Math.max(0,Date.now()-e.graphFetchStartedAt),u=setTimeout(()=>n(!0),Math.max(0,8e3-l));return()=>clearTimeout(u)},[e.graphFetchInFlight,e.graphFetchStartedAt]);let r=[];e.browser&&!e.graphSupported&&r.push("Showing resources this page has loaded. Add an asset manifest to include files the page has not requested."),e.graphFetchInFlight&&(r.push(`Finding assets\u2026 ${t} found so far.`),o&&r.push("Still finding assets. This is taking longer than usual.")),e.registryAvailable||r.push("The asset registry is unavailable in this environment."),!e.graphFetchInFlight&&!e.graphSupported&&e.graphError&&r.push("Showing runtime-registered assets only. A development server is needed to find more assets and measure their sizes.");let i=!e.graphFetchInFlight&&e.graphSupported&&!!e.graphError;return i&&r.push(`Couldn't finish finding assets. Showing ${t} assets found so far.`),e.measuring&&!e.graphFetchInFlight&&r.push("Checking asset sizes\u2026"),r.length===0?null:Wo(g,{style:ft.notice,testID:b.notice,children:[e.graphFetchInFlight?ze(We,{size:"small",color:Se.color.textSecondary,accessibilityLabel:"Finding assets",testID:b.discoverySpinner}):null,r.map(l=>ze(y,{style:ft.noticeText,testID:b.noticeText,children:l},l)),i?ze(P,{accessibilityRole:"button",onPress:s,testID:b.retry,children:ze(y,{style:ft.retryText,children:"Retry"})}):null]})}var ft=D.create({notice:{marginHorizontal:10,marginBottom:8,padding:10,borderRadius:8,borderWidth:1,borderColor:Se.color.border,backgroundColor:Se.color.surface,gap:4},noticeText:{color:Se.color.textSecondary,fontSize:11},retryText:{color:Se.color.text,fontSize:12,paddingVertical:6}});import{jsx as R,jsxs as fe}from"react/jsx-runtime";function Go({names:e}){let t=[...new Set(e)];return t.length?fe(g,{style:F.fontsBox,testID:b.fonts,children:[fe(y,{style:F.fontsTitle,testID:b.fontsTitle,children:["LOADED FONT FAMILIES (",t.length,")"]}),R(g,{style:F.fontsWrap,children:t.map(s=>R(y,{style:F.fontChip,testID:at(s),children:s},s))})]}):null}function jo({duplicates:e=!1}){return R(Uo,{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 Jt(e,t){return(t.sizeBytes??I(t))-(e.sizeBytes??I(e))}var qo={size:Jt,name:(e,t)=>e.name.localeCompare(t.name)||e.type.localeCompare(t.type),type:(e,t)=>e.type.localeCompare(t.type)||Jt(e,t)};function Fe({visible:e,onClose:t,onBack:s,onMinimize:o,persistenceKey:n,inline:r=!1}){ae();let{records:i,stats:l,insights:u}=Qe(),c=$t(),[m,v]=Ae(!1);Yt(()=>{v(!1)},[c.graphFetchInFlight,c.lastScanAt]);let d=()=>{v(!1);let f=ce();f?f("rescan").catch(()=>v(!0)):le()},[E,Z]=Ae(null),[z,ts]=Ae("all"),[ht,gt]=Ae(""),[yt,ss]=Ae("size"),U=E!=null?he(E):void 0;Yt(()=>{if(!e)return;et(),v(!1);let f=ce();f?f("rescan").catch(()=>v(!0)):le()},[e]);let $e=new Set(u.duplicates.flatMap(f=>f.ids)),bt=[...i].sort(qo[yt]),St=ht.trim().toLowerCase(),ee=bt.filter(f=>!(z==="unused"&&f.loaded||z==="duplicates"&&!$e.has(f.id)||z!=="all"&&z!=="unused"&&z!=="duplicates"&&f.kind!==z||St&&!`${f.name}.${f.type}`.toLowerCase().includes(St))),me=U?ee.findIndex(f=>f.id===U.id):-1,At=f=>{let N=ee[f];N&&Z(N.id)},te={scaleGaps:new Set(u.scaleGaps),scaleAnomalies:new Set(u.scaleAnomalies),duplicates:$e,webpCandidates:new Set(u.webpCandidates),overDecode:new Set(u.overDecode),heavy:new Set([...u.heavyGifs,...u.heavyFonts])},ve=0;for(let f of ee){let N=f.sizeBytes??I(f);N>ve&&(ve=N)}let os=()=>U?Ye(U):Je(bt,l,u,_(),ue()),vt=R(Kt,{stats:l,measuring:c.measuring,discovering:c.graphFetchInFlight,detailOpen:U!=null,detailIndex:me,detailTotal:ee.length,onCloseDetail:()=>Z(null),onClear:ge,getReport:os,onBack:s}),xt=U?fe(g,{style:F.detailContainer,children:[R(Vt,{record:U,insights:u}),me>=0?R(_o,{currentIndex:me,totalItems:ee.length,itemLabel:"Asset",onPrevious:()=>At(me-1),onNext:()=>At(me+1)}):null]}):fe(g,{style:F.listContainer,children:[R(Nt,{stats:l,duplicateCount:$e.size,filter:z,onChange:f=>{ts(f),f==="duplicates"&&gt("")}}),R(jt,{query:ht,onQueryChange:gt,sort:yt,onSortChange:ss}),R(qt,{status:c,total:l.total,onRetry:d}),m&&!c.graphFetchInFlight?fe(g,{style:F.notice,children:[R(y,{style:F.noticeText,children:"Couldn't request an asset scan from the device."}),R(P,{accessibilityRole:"button",onPress:d,children:R(y,{style:F.retryText,children:"Retry"})})]}):null,z==="unused"?R(g,{style:F.notice,children:R(y,{style:F.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"?R(Go,{names:c.fontFamilies}):null,R(_e,{testID:b.list,data:ee,keyExtractor:f=>String(f.id),contentContainerStyle:F.listContent,renderItem:({item:f})=>R(_t,{record:f,flags:{scaleGap:te.scaleGaps.has(f.id),scaleAnomaly:te.scaleAnomalies.has(f.id),duplicate:te.duplicates.has(f.id),webp:te.webpCandidates.has(f.id),oversize:te.overDecode.has(f.id),heavy:te.heavy.has(f.id)},sizeFraction:ve>0?(f.sizeBytes??I(f))/ve:0,onPress:N=>Z(typeof N=="number"?N:null)}),ListEmptyComponent:c.graphFetchInFlight?null:R(jo,{duplicates:z==="duplicates"})})]});return r?fe(g,{style:F.inlineRoot,children:[R(g,{style:F.inlineHeader,...Ko,children:vt}),xt]}):R(No,{visible:e,onClose:t,onMinimize:o,persistenceKey:n,header:{showToggleButton:!0,customContent:vt},enablePersistence:!0,initialMode:"bottomSheet",disableScrollWrapper:!0,children:xt})}function Yo(e={}){return R(Fe,{...e,inline:!0,visible:!0,onClose:()=>{}})}var F=D.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:Ho.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:W.color.border,backgroundColor:W.color.surface,gap:4},noticeText:{color:W.color.textSecondary,fontSize:11},retryText:{color:W.color.text,fontSize:12,paddingVertical:6},fontsBox:{marginHorizontal:10,marginTop:8,padding:10,borderRadius:8,backgroundColor:W.color.surface,gap:6},fontsTitle:{color:W.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5},fontsWrap:{flexDirection:"row",flexWrap:"wrap",gap:6},fontChip:{color:W.color.textSecondary,fontSize:10,backgroundColor:W.color.bg,borderRadius:999,paddingHorizontal:8,paddingVertical:3,overflow:"hidden"},empty:{alignItems:"center",padding:32,gap:8},emptyTitle:{color:W.color.text,fontSize:13,fontWeight:"600"},emptyText:{color:W.color.textSecondary,fontSize:11,textAlign:"center",lineHeight:16}});import{createToolFactory as Jo,defineToolPreset as Qo}from"@buoy-gg/shared-ui/web";import{jsx as Zo}from"react/jsx-runtime";var Qt=Qo({id:"assets",name:"ASSETS",description:"Every bundled asset \u2014 sizes, scale coverage, unused detection",slot:"both",icon:({size:e,color:t})=>Zo(Pe,{size:e,color:t||Oe}),component:Fe}),Xo=Jo(Qt);a();var Xt=["image","font","video","audio","data","other"];function mt(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:I(e)||null,sizeSource:e.sizeSource??null}}function en(e){let t=e?.id;if(typeof t!="number")throw new Error("Missing numeric `id` param");let s=he(t);if(!s)throw new Error(`Asset record ${t} not found \u2014 re-run the list action for current ids.`);return s}function tn(e,t){return(t.sizeBytes??I(t))-(e.sizeBytes??I(e))}function Zt(){let e=T();return{stats:ye(e),scanStatus:_(),insights:be(e),diff:ue(),records:[...e].sort(tn)}}var sn={version:1,getSnapshot:()=>{let{records:e,...t}=Zt();return{...t,records:e.slice(0,200).map(mt)}},subscribe:e=>G(e),actions:{list:e=>{let t=e??{},s=Math.min(Math.max(t.limit??50,1),500),{records:o,...n}=Zt(),r=o;if(t.kind){if(!Xt.includes(t.kind))throw new Error(`kind must be one of: ${Xt.join(", ")}`);r=r.filter(i=>i.kind===t.kind)}return t.loadedOnly&&(r=r.filter(i=>i.loaded)),{...n,total:r.length,records:r.slice(0,s).map(mt)}},getDetail:e=>{let t=en(e);return{...mt(t),origin:t.origin,fileSystemLocation:t.fileSystemLocation??null,files:t.files??null,sizesByScale:t.sizesByScale??null,estDecodedBytes:I(t)||null}},rescan:async()=>({ok:!0,scanStatus:await le()}),measureSizes:async()=>{let e=await nt();return{ok:e.measured>0,...e}},saveBaseline:async()=>{let e=await tt();return{ok:!0,savedAt:e.savedAt,assets:Object.keys(e.entries).length}},clearBaseline:async()=>(await st(),{ok:!0,message:"Baseline cleared"}),getDiff:()=>ue(),clearRecords:()=>(ge(),{ok:!0,message:"Inventory cleared \u2014 rescan to rebuild"}),getScanStatus:()=>_()}};a();a();var es=0;function on(){if(typeof document>"u")return()=>{};++es===1&&ae();let e=!0;return()=>{e&&(e=!1,--es===0&&qe())}}export{Oe as ASSETS_ICON_COLOR,b as ASSETS_TEST_IDS,Pe as AssetsIcon,Fe as AssetsModal,Yo as AssetsToolView,rt as assetBadgeTestID,it as assetDetailRowTestID,De as assetFilterTestID,lt as assetFindingTestID,at as assetFontChipTestID,pe as assetRowTestID,de as assetSlug,sn as assetsSyncAdapter,Qt as assetsToolPreset,st as clearBaseline,ge as clearRecords,Et as computeDiff,be as computeInsights,ye as computeStats,Xo as createAssetsTool,xo as disableAssetsCapture,I as estDecodedBytes,Ro as fetchAssetGraph,Ye as formatAssetMarkdown,Je as formatInventoryMarkdown,Ge as getBrowserAssetManifest,ot as getDevServerOrigin,ue as getDiff,we as getLoadedFontFamilies,lo as getLocalAssets,he as getRecord,_ as getScanStatus,T as getSnapshot,ae as installAssetCapture,et as loadBaseline,ao as loadBrowserAssetManifest,nt as measureSizes,Dt as registerBrowserAssetManifest,wo as replaceAssetsFromSnapshot,le as rescan,tt as saveBaseline,vo as setRemoteAssetsHandler,on as startBrowserAssetCapture,G as subscribe,Qe as useAssetRecords};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/assets",
3
- "version": "7.0.40",
3
+ "version": "7.0.41",
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",
@@ -8,19 +8,24 @@
8
8
  "react-native": "lib/module/index.js",
9
9
  "source": "src/index.tsx",
10
10
  "files": [
11
- "lib"
11
+ "lib",
12
+ "bundlers"
12
13
  ],
13
14
  "sideEffects": [
14
- "**/index.*"
15
+ "**/index.*",
16
+ "./lib/web/**/*.mjs",
17
+ "**/autoCapture.*"
15
18
  ],
16
19
  "dependencies": {
17
- "@buoy-gg/shared-ui": "^7.0.40"
20
+ "@buoy-gg/shared-ui": "^7.0.41"
18
21
  },
19
22
  "peerDependencies": {
20
23
  "expo-asset": "*",
21
24
  "expo-image": "*",
22
25
  "react": "*",
23
- "react-native": "*"
26
+ "react-native": "*",
27
+ "react-native-web": "^0.21.0",
28
+ "react-dom": ">=18"
24
29
  },
25
30
  "peerDependenciesMeta": {
26
31
  "expo-image": {
@@ -28,6 +33,15 @@
28
33
  },
29
34
  "expo-asset": {
30
35
  "optional": true
36
+ },
37
+ "react-native": {
38
+ "optional": true
39
+ },
40
+ "react-native-web": {
41
+ "optional": true
42
+ },
43
+ "react-dom": {
44
+ "optional": true
31
45
  }
32
46
  },
33
47
  "devDependencies": {
@@ -75,11 +89,36 @@
75
89
  "fonts",
76
90
  "app-size"
77
91
  ],
92
+ "exports": {
93
+ ".": {
94
+ "browser": {
95
+ "types": "./lib/typescript/index.d.ts",
96
+ "default": "./lib/web/index.mjs"
97
+ },
98
+ "import": {
99
+ "types": "./lib/typescript/index.d.ts",
100
+ "default": "./lib/module/index.js"
101
+ },
102
+ "require": {
103
+ "types": "./lib/typescript/index.d.ts",
104
+ "default": "./lib/commonjs/index.js"
105
+ }
106
+ },
107
+ "./web": {
108
+ "types": "./lib/typescript/index.d.ts",
109
+ "default": "./lib/web/index.mjs"
110
+ },
111
+ "./vite": {
112
+ "types": "./bundlers/vite.d.ts",
113
+ "default": "./bundlers/vite.mjs"
114
+ }
115
+ },
78
116
  "scripts": {
79
- "build": "bob build",
117
+ "build": "bob build && pnpm run build:web",
80
118
  "typecheck": "tsc --noEmit",
81
119
  "clean": "rimraf lib",
82
120
  "test": "pnpm run typecheck",
83
- "postinstall": "echo \"Run pnpm build to compile this package\""
121
+ "postinstall": "echo \"Run pnpm build to compile this package\"",
122
+ "build:web": "node ../../scripts/build-web.mjs assets"
84
123
  }
85
124
  }