@buoy-gg/assets 7.0.62 → 7.0.64

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 (36) hide show
  1. package/README.md +6 -0
  2. package/lib/commonjs/capture/browserAssets.js +1 -1
  3. package/lib/commonjs/capture/install.web.js +1 -1
  4. package/lib/commonjs/capture/isBuoyAsset.js +1 -1
  5. package/lib/commonjs/capture/measure.js +1 -1
  6. package/lib/commonjs/capture/metroGraph.js +1 -1
  7. package/lib/commonjs/capture/toolPreview.js +1 -0
  8. package/lib/commonjs/capture/toolPreview.web.js +1 -0
  9. package/lib/commonjs/components/AssetDetail.js +1 -1
  10. package/lib/commonjs/components/AssetImage.js +1 -1
  11. package/lib/commonjs/index.js +1 -1
  12. package/lib/commonjs/remote.js +1 -1
  13. package/lib/commonjs/sync/assetsSyncAdapter.js +1 -1
  14. package/lib/module/capture/browserAssets.js +1 -1
  15. package/lib/module/capture/install.web.js +1 -1
  16. package/lib/module/capture/isBuoyAsset.js +1 -1
  17. package/lib/module/capture/measure.js +1 -1
  18. package/lib/module/capture/metroGraph.js +1 -1
  19. package/lib/module/capture/toolPreview.js +1 -0
  20. package/lib/module/capture/toolPreview.web.js +1 -0
  21. package/lib/module/components/AssetDetail.js +1 -1
  22. package/lib/module/components/AssetImage.js +1 -1
  23. package/lib/module/index.js +1 -1
  24. package/lib/module/remote.js +1 -1
  25. package/lib/module/sync/assetsSyncAdapter.js +1 -1
  26. package/lib/typescript/capture/browserAssets.d.ts +10 -0
  27. package/lib/typescript/capture/isBuoyAsset.d.ts +3 -2
  28. package/lib/typescript/capture/metroGraph.d.ts +0 -13
  29. package/lib/typescript/capture/toolPreview.d.ts +4 -0
  30. package/lib/typescript/capture/toolPreview.web.d.ts +4 -0
  31. package/lib/typescript/index.d.ts +1 -0
  32. package/lib/typescript/remote.d.ts +0 -8
  33. package/lib/typescript/sync/assetsSyncAdapter.d.ts +3 -0
  34. package/lib/typescript/types.d.ts +6 -0
  35. package/lib/web/index.mjs +3 -3
  36. package/package.json +2 -2
package/README.md CHANGED
@@ -20,8 +20,14 @@ npm install @buoy-gg/core @buoy-gg/assets
20
20
 
21
21
  Assets appears in the menu once installed. SVG previews use `expo-image` when it's available.
22
22
 
23
+ On web, tool image previews do not count as app loads.
24
+
23
25
  The [Assets guide](https://buoy.gg/buoy/latest/docs/tools/assets) covers setup, what it captures and its limits. New to Buoy? Start with the [Quick start](https://buoy.gg/buoy/latest/docs/quick-start).
24
26
 
25
27
  ---
26
28
 
27
29
  <sub>Part of <a href="https://buoy.gg">Buoy</a>, developer tools that live inside your app. Proprietary software. © Buoy LLC. <a href="https://buoy.gg/terms">Terms</a></sub>
30
+
31
+ Cached images count when the app loads them too.
32
+
33
+ Buoy keeps its own files and tool previews out of this view.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.captureBrowserResource=captureBrowserResource;exports.getBrowserAssetManifest=getBrowserAssetManifest;exports.loadBrowserAssetManifest=loadBrowserAssetManifest;exports.registerBrowserAssetManifest=registerBrowserAssetManifest;exports.scanBrowserAssets=scanBrowserAssets;var _state=require("../state");var _assetStore=require("../store/assetStore");let manifest=[];function registerBrowserAssetManifest(e){manifest=e;if(typeof document!=="undefined")scanBrowserAssets()}function getBrowserAssetManifest(){return manifest}async function loadBrowserAssetManifest(e){const t=await fetch(e);if(!t.ok)throw new Error(`Asset manifest returned HTTP ${t.status}.`);const r=await t.json();if(!Array.isArray(r)||r.some(s=>!s||typeof s.url!=="string"))throw new Error("An asset manifest must contain an array of assets with URL strings.");registerBrowserAssetManifest(r)}function upsert(e,t){let r;try{r=new URL(e.url,document.baseURI)}catch{return}const s=r.pathname.split("/").pop()??"";const n=s.includes(".")?s.split(".").pop().toLowerCase():"other";const o=(0,_assetStore.upsertRecord)({key:r.href,name:s.slice(0,-(n.length+1))||s,type:n,origin:t?"browser":"graph",resolvedUri:r.href,resolvedScale:1,scales:[1],hash:e.hash,loaded:t,width:e.width,height:e.height});if(o&&e.bytes!==void 0&&e.bytes>=0)(0,_assetStore.updateRecord)(o.id,{sizeBytes:e.bytes,sizesByScale:{"1":e.bytes},sizeSource:"measured"})}function captureBrowserResource(e){if(e.initiatorType==="fetch"||e.initiatorType==="xmlhttprequest")return;upsert({url:e.name,bytes:e.encodedBodySize>0?e.encodedBodySize:void 0},true)}function scanBrowserAssets(){if(typeof document==="undefined"||(0,_state.assetsState)().captureDisabled)return;manifest.forEach(t=>upsert(t,false));performance.getEntriesByType("resource").forEach(t=>captureBrowserResource(t));document.querySelectorAll("img").forEach(t=>{if(!t.closest("[data-buoy-root]")&&t.currentSrc)upsert({url:t.currentSrc,width:t.naturalWidth||void 0,height:t.naturalHeight||void 0},t.complete&&t.naturalWidth>0)});const e=(0,_state.assetsState)();e.graphSupported=manifest.length>0;e.graphCount=manifest.length>0?manifest.length:null;e.measuredCount=e.records.filter(t=>t.sizeBytes!==void 0).length;e.lastScanAt=Date.now()}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.captureBrowserImage=captureBrowserImage;exports.captureBrowserResource=captureBrowserResource;exports.getBrowserAssetManifest=getBrowserAssetManifest;exports.loadBrowserAssetManifest=loadBrowserAssetManifest;exports.markBrowserToolImage=markBrowserToolImage;exports.recordBrowserAssetLoad=recordBrowserAssetLoad;exports.registerBrowserAssetManifest=registerBrowserAssetManifest;exports.scanBrowserAssets=scanBrowserAssets;var _sharedUi=require("@buoy-gg/shared-ui");var _state=require("../state");var _assetStore=require("../store/assetStore");let manifest=[];const toolImageUrls=new Set;function markBrowserToolImage(e){if(typeof document==="undefined")return;try{toolImageUrls.add(new URL(e,document.baseURI).href)}catch{}}function browserImages(e=document){const t=Array.from(e.querySelectorAll("img"));for(const r of Array.from(e.querySelectorAll("*"))){if(r.shadowRoot)t.push(...browserImages(r.shadowRoot))}return t}function registerBrowserAssetManifest(e){manifest=e.filter(t=>!(0,_sharedUi.isBuoyAssetPath)(t.url));if(typeof document!=="undefined")scanBrowserAssets()}function getBrowserAssetManifest(){return manifest}async function loadBrowserAssetManifest(e){const t=await(0,_sharedUi.buoyFetch)(e);if(!t.ok)throw new Error(`Asset manifest returned HTTP ${t.status}.`);const r=await t.json();if(!Array.isArray(r)||r.some(s=>!s||typeof s.url!=="string"))throw new Error("An asset manifest must contain an array of assets with URL strings.");registerBrowserAssetManifest(r)}function upsert(e,t){let r;try{r=new URL(e.url,document.baseURI)}catch{return}const s=r.pathname.split("/").pop()??"";const n=s.includes(".")?s.split(".").pop().toLowerCase():"other";const o=(0,_assetStore.upsertRecord)({key:r.href,name:s.slice(0,-(n.length+1))||s,type:n,origin:t?"browser":"graph",resolvedUri:r.href,resolvedScale:1,scales:[1],hash:e.hash,loaded:t,width:e.width,height:e.height});if(o&&e.bytes!==void 0&&e.bytes>=0)(0,_assetStore.updateRecord)(o.id,{sizeBytes:e.bytes,sizesByScale:{"1":e.bytes},sizeSource:"measured"});return o}function captureBrowserResource(e){if(e.initiatorType==="fetch"||e.initiatorType==="xmlhttprequest")return;if(e.initiatorType==="img"){const t=browserImages().filter(r=>(r.currentSrc||r.src)===e.name);if(t.length){if(t.every(_sharedUi.isBuoyElement))toolImageUrls.add(e.name);else toolImageUrls.delete(e.name)}}if(toolImageUrls.has(e.name))return;upsert({url:e.name,bytes:e.encodedBodySize>0?e.encodedBodySize:void 0},true)}function captureBrowserImage(e){if((0,_state.assetsState)().captureDisabled)return;const t=e.currentSrc||e.src;if((0,_sharedUi.isBuoyElement)(e)){if(t)toolImageUrls.add(t);return}toolImageUrls.delete(t);if(!t||!e.complete||e.naturalWidth<=0)return;upsert({url:t,width:e.naturalWidth,height:e.naturalHeight},true)}function scanBrowserAssets(){if(typeof document==="undefined"||(0,_state.assetsState)().captureDisabled)return;manifest.forEach(t=>upsert(t,false));performance.getEntriesByType("resource").forEach(t=>captureBrowserResource(t));browserImages().forEach(captureBrowserImage);const e=(0,_state.assetsState)();e.graphSupported=manifest.length>0;e.graphCount=manifest.length>0?manifest.length:null;e.measuredCount=e.records.filter(t=>t.sizeBytes!==void 0).length;e.lastScanAt=Date.now()}function recordBrowserAssetLoad(e){if(typeof document==="undefined"||(0,_state.assetsState)().captureDisabled)return;const t=upsert({url:e.url,bytes:e.bytes??void 0},e.status==="success");if(t)(0,_assetStore.updateRecord)(t.id,{loadStatus:e.status,durationMs:e.durationMs,cacheHit:e.cacheHit})}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getScanStatus=getScanStatus;exports.installAssetCapture=installAssetCapture;exports.rescan=rescan;exports.stopBrowserAssetCapture=stopBrowserAssetCapture;var _state=require("../state");var _assetStore=require("../store/assetStore");var _browserAssets=require("./browserAssets");var _expo=require("./expo");let observer;function installAssetCapture(){const e=(0,_state.assetsState)();if(typeof document==="undefined"||e.captureDisabled||e.installed)return;e.installed=true;e.registryAvailable=true;if(typeof PerformanceObserver!=="undefined"){observer=new PerformanceObserver(t=>{if((0,_state.assetsState)().captureDisabled){stopBrowserAssetCapture();return}t.getEntries().forEach(s=>(0,_browserAssets.captureBrowserResource)(s))});try{observer.observe({type:"resource",buffered:true});e.patched=true}catch{observer.disconnect();observer=void 0}}(0,_browserAssets.scanBrowserAssets)();e.fontFamilies=(0,_expo.getLoadedFontFamilies)();(0,_assetStore.invalidate)()}function stopBrowserAssetCapture(){observer?.disconnect();observer=void 0;(0,_state.assetsState)().installed=false;(0,_state.assetsState)().patched=false}async function rescan(){installAssetCapture();(0,_browserAssets.scanBrowserAssets)();(0,_state.assetsState)().fontFamilies=(0,_expo.getLoadedFontFamilies)();(0,_assetStore.invalidate)();return getScanStatus()}function getScanStatus(){const e=(0,_state.assetsState)();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}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getScanStatus=getScanStatus;exports.installAssetCapture=installAssetCapture;exports.rescan=rescan;exports.stopBrowserAssetCapture=stopBrowserAssetCapture;var _state=require("../state");var _assetStore=require("../store/assetStore");var _browserAssets=require("./browserAssets");var _expo=require("./expo");let observer;const onImageLoad=e=>{const t=e.target;if(t?.tagName==="IMG")(0,_browserAssets.captureBrowserImage)(t)};function installAssetCapture(){const e=(0,_state.assetsState)();if(typeof document==="undefined"||e.captureDisabled||e.installed)return;e.installed=true;e.registryAvailable=true;document.addEventListener("load",onImageLoad,true);if(typeof PerformanceObserver!=="undefined"){observer=new PerformanceObserver(t=>{if((0,_state.assetsState)().captureDisabled){stopBrowserAssetCapture();return}t.getEntries().forEach(r=>(0,_browserAssets.captureBrowserResource)(r))});try{observer.observe({type:"resource",buffered:true});e.patched=true}catch{observer.disconnect();observer=void 0}}(0,_browserAssets.scanBrowserAssets)();e.fontFamilies=(0,_expo.getLoadedFontFamilies)();(0,_assetStore.invalidate)()}function stopBrowserAssetCapture(){observer?.disconnect();observer=void 0;if(typeof document!=="undefined")document.removeEventListener("load",onImageLoad,true);(0,_state.assetsState)().installed=false;(0,_state.assetsState)().patched=false}async function rescan(){installAssetCapture();(0,_browserAssets.scanBrowserAssets)();(0,_state.assetsState)().fontFamilies=(0,_expo.getLoadedFontFamilies)();(0,_assetStore.invalidate)();return getScanStatus()}function getScanStatus(){const e=(0,_state.assetsState)();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}}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isBuoyAsset=isBuoyAsset;exports.isBuoyAssetPath=isBuoyAssetPath;function isBuoyAssetPath(e){if(!e)return false;let t=e;try{t=decodeURIComponent(t)}catch{}t=t.replace(/\\/g,"/");return/(?:^|\/)node_modules\/@buoy-gg\/[^/]+(?:\/|$)/.test(t)||/(?:^|\/)buoy-packages\/packages\/[^/]+(?:\/|$)/.test(t)||/(?:^|\/)packages\/floating-tools-core\/(?:src|lib\/(?:module|commonjs))\/icons\/assets(?:\/|$)/.test(t)}function isBuoyAsset(e){return[e.key,e.httpServerLocation,e.fileSystemLocation,...e.files??[]].some(isBuoyAssetPath)}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isBuoyAsset=isBuoyAsset;Object.defineProperty(exports,"isBuoyAssetPath",{enumerable:true,get:function(){return _sharedUi.isBuoyAssetPath}});var _sharedUi=require("@buoy-gg/shared-ui");function isBuoyAsset(e){return[e.key,e.resolvedUri,e.httpServerLocation,e.fileSystemLocation,...e.files??[]].some(_sharedUi.isBuoyAssetPath)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.displaySource=displaySource;exports.measureSizes=measureSizes;exports.previewURL=previewURL;exports.variantURLs=variantURLs;var _reactNative=require("react-native");var _state=require("../state");var _assetStore=require("../store/assetStore");var _metroGraph=require("./metroGraph");const CONCURRENCY=4;function previewURL(e){if(e.resolvedUri)return e.resolvedUri;const s=variantURLs(e);return s.length?s[0].url:null}function displaySource(e){const s=(0,_state.assetsState)().captureDisabled;if(!s&&e.registryId!=null)return e.registryId;const t=previewURL(e);if(!t)return null;if(s&&!/^https?:\/\//.test(t))return null;return{uri:t}}function variantURLs(e){const s=e.scales.length?e.scales:[1];const t=e.resolvedUri;if(t&&/^https?:\/\//.test(t)&&e.resolvedScale!=null){const n=e.resolvedScale===1?"":`@${e.resolvedScale}x`;const i=`${n}.${e.type}`;if(t.includes(i)||n===""){return s.map(r=>{const u=r===1?"":`@${r}x`;const o=(n===""?t.replace(`.${e.type}`,`${u}.${e.type}`):t.replace(i,`${u}.${e.type}`)).replace(/ /g,"%20");return{scale:r,url:o}})}}const a=(0,_metroGraph.getDevServerOrigin)();if(!a||!e.httpServerLocation)return[];return s.map(n=>{const i=n===1?"":`@${n}x`;const r=`${e.httpServerLocation}/${e.name}${i}.${e.type}`;const u=r.includes("?")?"&":"?";const o=`${a}${r}${u}platform=${platformName()}${e.hash?`&hash=${e.hash}`:""}`.replace(/ /g,"%20");return{scale:n,url:o}})}function platformName(){try{return _reactNative.Platform.OS}catch{return"ios"}}async function fetchSize(e){try{const s=await fetch(e,{method:"HEAD"});if(s.ok){const t=Number(s.headers.get("content-length"));if(Number.isFinite(t)&&t>0)return t}}catch{}try{const s=await fetch(e);if(!s.ok)return null;const t=await s.blob();return t.size>0?t.size:null}catch{return null}}async function measureRecord(e){const s=variantURLs(e);if(!s.length){(0,_assetStore.updateRecord)(e.id,{sizeSource:"estimate"});return}const t={};let a=0;for(const{scale:n,url:i}of s){const r=await fetchSize(i);if(r!=null){t[String(n)]=r;a+=r}}if(a>0){(0,_assetStore.updateRecord)(e.id,{sizesByScale:t,sizeBytes:a,sizeSource:"measured"})}else{(0,_assetStore.updateRecord)(e.id,{sizeSource:"estimate"})}}async function measureSizes(){const e=(0,_state.assetsState)();if(e.measuring)return{measured:e.measuredCount,total:(0,_assetStore.getSnapshot)().length};const s=(0,_assetStore.getSnapshot)().filter(t=>t.sizeSource!=="measured");e.measuring=true;(0,_assetStore.invalidate)();try{let t=0;const a=async()=>{for(;;){const n=s[t++];if(!n)return;await measureRecord(n);e.measuredCount=(0,_assetStore.getSnapshot)().filter(i=>i.sizeSource==="measured").length}};await Promise.all(Array.from({length:Math.min(CONCURRENCY,s.length)},a))}finally{e.measuring=false;(0,_assetStore.invalidate)()}return{measured:e.measuredCount,total:(0,_assetStore.getSnapshot)().length}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.displaySource=displaySource;exports.measureSizes=measureSizes;exports.previewURL=previewURL;exports.variantURLs=variantURLs;var _sharedUi=require("@buoy-gg/shared-ui");var _reactNative=require("react-native");var _state=require("../state");var _assetStore=require("../store/assetStore");var _metroGraph=require("./metroGraph");const CONCURRENCY=4;function previewURL(e){if(e.resolvedUri)return e.resolvedUri;const s=variantURLs(e);return s.length?s[0].url:null}function displaySource(e){const s=(0,_state.assetsState)().captureDisabled;if(!s&&e.registryId!=null)return e.registryId;const t=previewURL(e);if(!t)return null;if(s&&!/^https?:\/\//.test(t))return null;return{uri:t}}function variantURLs(e){const s=e.scales.length?e.scales:[1];const t=e.resolvedUri;if(t&&/^https?:\/\//.test(t)&&e.resolvedScale!=null){const r=e.resolvedScale===1?"":`@${e.resolvedScale}x`;const i=`${r}.${e.type}`;if(t.includes(i)||r===""){return s.map(n=>{const u=n===1?"":`@${n}x`;const o=(r===""?t.replace(`.${e.type}`,`${u}.${e.type}`):t.replace(i,`${u}.${e.type}`)).replace(/ /g,"%20");return{scale:n,url:o}})}}const a=(0,_metroGraph.getDevServerOrigin)();if(!a||!e.httpServerLocation)return[];return s.map(r=>{const i=r===1?"":`@${r}x`;const n=`${e.httpServerLocation}/${e.name}${i}.${e.type}`;const u=n.includes("?")?"&":"?";const o=`${a}${n}${u}platform=${platformName()}${e.hash?`&hash=${e.hash}`:""}`.replace(/ /g,"%20");return{scale:r,url:o}})}function platformName(){try{return _reactNative.Platform.OS}catch{return"ios"}}async function fetchSize(e){try{const s=await(0,_sharedUi.buoyFetch)(e,{method:"HEAD"});if(s.ok){const t=Number(s.headers.get("content-length"));if(Number.isFinite(t)&&t>0)return t}}catch{}try{const s=await(0,_sharedUi.buoyFetch)(e);if(!s.ok)return null;const t=await s.blob();return t.size>0?t.size:null}catch{return null}}async function measureRecord(e){const s=variantURLs(e);if(!s.length){(0,_assetStore.updateRecord)(e.id,{sizeSource:"estimate"});return}const t={};let a=0;for(const{scale:r,url:i}of s){const n=await fetchSize(i);if(n!=null){t[String(r)]=n;a+=n}}if(a>0){(0,_assetStore.updateRecord)(e.id,{sizesByScale:t,sizeBytes:a,sizeSource:"measured"})}else{(0,_assetStore.updateRecord)(e.id,{sizeSource:"estimate"})}}async function measureSizes(){const e=(0,_state.assetsState)();if(e.measuring)return{measured:e.measuredCount,total:(0,_assetStore.getSnapshot)().length};const s=(0,_assetStore.getSnapshot)().filter(t=>t.sizeSource!=="measured");e.measuring=true;(0,_assetStore.invalidate)();try{let t=0;const a=async()=>{for(;;){const r=s[t++];if(!r)return;await measureRecord(r);e.measuredCount=(0,_assetStore.getSnapshot)().filter(i=>i.sizeSource==="measured").length}};await Promise.all(Array.from({length:Math.min(CONCURRENCY,s.length)},a))}finally{e.measuring=false;(0,_assetStore.invalidate)()}return{measured:e.measuredCount,total:(0,_assetStore.getSnapshot)().length}}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.fetchAssetGraph=fetchAssetGraph;exports.getDevServerOrigin=getDevServerOrigin;exports.getGraphURLCandidates=getGraphURLCandidates;exports.getScriptURL=getScriptURL;var _state=require("../state");var _assetStore=require("../store/assetStore");const GRAPH_TIMEOUT_MS=9e4;async function fetchGraphPayload(e,r){const n=new AbortController;let s;try{return await Promise.race([(async()=>{const a=await fetch(e,{signal:n.signal});if(!a.ok)throw new Error(`Metro responded ${a.status} for ${e}`);return a.json()})(),new Promise((a,i)=>{s=setTimeout(()=>{i(new Error("Asset discovery timed out. Try again."));n.abort()},Math.max(0,r))})])}finally{clearTimeout(s)}}function getScriptURL(){try{const{NativeModules:e}=require("react-native");const r=e?.SourceCode;const n=r?.getConstants?.().scriptURL??r?.scriptURL;return typeof n==="string"?n:null}catch{return null}}function getDevServerOrigin(){const e=getScriptURL();const r=e?.match(/^https?:\/\/[^/]+/);return r?r[0]:null}function getGraphURLCandidates(){const e=getScriptURL();if(!e||!/^https?:\/\//.test(e))return[];const r=getDevServerOrigin();const n=e.indexOf("?");const s=n>=0?e.slice(n):"?platform=ios&dev=true";const a=[];if(e.includes(".bundle")){a.push(e.replace(".bundle",".assets"))}if(r){a.push(`${r}/node_modules/expo-router/entry.assets${s}`,`${r}/node_modules/expo/AppEntry.assets${s}`,`${r}/index.assets${s}`)}return a}async function fetchAssetGraph(){const e=(0,_state.assetsState)();const r=getGraphURLCandidates();if(!r.length){e.graphSupported=false;e.graphError="No Metro dev server (embedded bundle)";(0,_assetStore.invalidate)();return{ok:false,message:e.graphError}}if(e.graphFetchInFlight)return{ok:false,message:"Graph fetch already running"};e.graphFetchInFlight=true;e.graphFetchStartedAt=Date.now();e.graphError=null;(0,_assetStore.invalidate)();const n=e.graphFetchStartedAt+GRAPH_TIMEOUT_MS;try{let s=null;let a="";for(const t of r){try{const o=await fetchGraphPayload(t,n-Date.now());if(Array.isArray(o)){s=o;break}a="Unexpected .assets payload shape"}catch(o){a=String(o?.message??o);if(Date.now()>=n)break}}if(!Array.isArray(s))throw new Error(a||"No graph endpoint answered");const i=s;let c=0;for(const t of i){if(!t||typeof t.name!=="string"||typeof t.type!=="string"){continue}const o=(0,_assetStore.upsertRecord)({key:(0,_assetStore.assetKey)(t.httpServerLocation,t.name,t.type),name:t.name,type:t.type,origin:"graph",hash:t.hash,httpServerLocation:t.httpServerLocation,width:t.width??void 0,height:t.height??void 0,scales:t.scales,fileSystemLocation:t.fileSystemLocation,files:t.files,fileHashes:t.fileHashes});if(o)c++}e.graphSupported=true;e.graphCount=c;e.graphError=null;(0,_assetStore.invalidate)();return{ok:true,count:c}}catch(s){e.graphSupported=getDevServerOrigin()!=null;e.graphError=String(s?.message??s);(0,_assetStore.invalidate)();return{ok:false,message:e.graphError}}finally{e.graphFetchInFlight=false;e.graphFetchStartedAt=null;(0,_assetStore.invalidate)()}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.fetchAssetGraph=fetchAssetGraph;exports.getDevServerOrigin=getDevServerOrigin;exports.getGraphURLCandidates=getGraphURLCandidates;exports.getScriptURL=getScriptURL;var _sharedUi=require("@buoy-gg/shared-ui");var _state=require("../state");var _assetStore=require("../store/assetStore");const GRAPH_TIMEOUT_MS=9e4;async function fetchGraphPayload(e,r){const n=new AbortController;let a;try{return await Promise.race([(async()=>{const s=await(0,_sharedUi.buoyFetch)(e,{signal:n.signal});if(!s.ok)throw new Error(`Metro responded ${s.status} for ${e}`);return s.json()})(),new Promise((s,i)=>{a=setTimeout(()=>{i(new Error("Asset discovery timed out. Try again."));n.abort()},Math.max(0,r))})])}finally{clearTimeout(a)}}function getScriptURL(){try{const{NativeModules:e}=require("react-native");const r=e?.SourceCode;const n=r?.getConstants?.().scriptURL??r?.scriptURL;return typeof n==="string"?n:null}catch{return null}}function getDevServerOrigin(){const e=getScriptURL();const r=e?.match(/^https?:\/\/[^/]+/);return r?r[0]:null}function getGraphURLCandidates(){const e=getScriptURL();if(!e||!/^https?:\/\//.test(e))return[];const r=getDevServerOrigin();const n=e.indexOf("?");const a=n>=0?e.slice(n):"?platform=ios&dev=true";const s=[];if(e.includes(".bundle")){s.push(e.replace(".bundle",".assets"))}if(r){s.push(`${r}/node_modules/expo-router/entry.assets${a}`,`${r}/node_modules/expo/AppEntry.assets${a}`,`${r}/index.assets${a}`)}return s}async function fetchAssetGraph(){const e=(0,_state.assetsState)();const r=getGraphURLCandidates();if(!r.length){e.graphSupported=false;e.graphError="No Metro dev server (embedded bundle)";(0,_assetStore.invalidate)();return{ok:false,message:e.graphError}}if(e.graphFetchInFlight)return{ok:false,message:"Graph fetch already running"};e.graphFetchInFlight=true;e.graphFetchStartedAt=Date.now();e.graphError=null;(0,_assetStore.invalidate)();const n=e.graphFetchStartedAt+GRAPH_TIMEOUT_MS;try{let a=null;let s="";for(const t of r){try{const o=await fetchGraphPayload(t,n-Date.now());if(Array.isArray(o)){a=o;break}s="Unexpected .assets payload shape"}catch(o){s=String(o?.message??o);if(Date.now()>=n)break}}if(!Array.isArray(a))throw new Error(s||"No graph endpoint answered");const i=a;let c=0;for(const t of i){if(!t||typeof t.name!=="string"||typeof t.type!=="string"){continue}const o=(0,_assetStore.upsertRecord)({key:(0,_assetStore.assetKey)(t.httpServerLocation,t.name,t.type),name:t.name,type:t.type,origin:"graph",hash:t.hash,httpServerLocation:t.httpServerLocation,width:t.width??void 0,height:t.height??void 0,scales:t.scales,fileSystemLocation:t.fileSystemLocation,files:t.files,fileHashes:t.fileHashes});if(o)c++}e.graphSupported=true;e.graphCount=c;e.graphError=null;(0,_assetStore.invalidate)();return{ok:true,count:c}}catch(a){e.graphSupported=getDevServerOrigin()!=null;e.graphError=String(a?.message??a);(0,_assetStore.invalidate)();return{ok:false,message:e.graphError}}finally{e.graphFetchInFlight=false;e.graphFetchStartedAt=null;(0,_assetStore.invalidate)()}}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.markToolPreviewSource=markToolPreviewSource;function markToolPreviewSource(e){}
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.markToolPreviewSource=markToolPreviewSource;var _browserAssets=require("./browserAssets");function markToolPreviewSource(e){if(e&&typeof e==="object")(0,_browserAssets.markBrowserToolImage)(e.uri)}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.AssetDetail=AssetDetail;var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _AssetImage=require("./AssetImage");var _format=require("../format");var _assetStore=require("../store/assetStore");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function Row({label:e,value:s}){const t=(0,_testIDs.assetDetailRowTestID)(e);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.kvRow,testID:t,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.kvLabel,children:e}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.kvValue,selectable:true,testID:`${t}-value`,children:s})]})}function Preview({record:e}){if(e.kind==="image"){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.previewBox,testID:_testIDs.ASSETS_TEST_IDS.detailPreview,children:(0,_jsxRuntime.jsx)(_AssetImage.AssetImage,{testID:"buoy-internal-assets-preview",record:e,style:styles.previewImage})})}if(e.kind==="font"){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.previewBox,testID:_testIDs.ASSETS_TEST_IDS.detailFontPreview,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.fontPreview,{fontFamily:e.name}],children:"The quick brown fox jumps over the lazy dog 0123456789"})})}return null}function AssetDetail({record:e,insights:s}){const t=[];if(s.neverLoaded.includes(e.id)){t.push("Not observed in the runtime registry this app run. This does not prove the asset is unused.")}if(s.scaleGaps.includes(e.id)){t.push("Scale gap \u2014 no variant covers this device's pixel ratio")}if(s.webpCandidates.includes(e.id)){t.push("WebP candidate \u2014 large png/jpeg, converting typically saves 20\u201340%")}const a=s.duplicates.find(i=>i.ids.includes(e.id));if(a){t.push(`Duplicate content \u2014 identical bytes shipped ${a.ids.length} times`)}if(s.overDecode.includes(e.id)){t.push("Decodes larger than 2\xD7 this entire screen \u2014 resize the source, no view can need this many pixels")}if(s.heavyGifs.includes(e.id)){t.push("Heavy GIF \u2014 every frame decodes into memory; a video or Lottie is typically ~90% smaller")}if(s.heavyFonts.includes(e.id)){t.push("Heavy font \u2014 likely an unsubset icon font; subsetting to used glyphs usually saves most of it")}if(s.scaleAnomalies.includes(e.id)){t.push("Scale anomaly \u2014 a higher-resolution variant is smaller in bytes than a lower one; check the exports")}const n=(0,_assetStore.estDecodedBytes)(e);return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.scroll,contentContainerStyle:styles.content,testID:_testIDs.ASSETS_TEST_IDS.detailScroll,children:[(0,_jsxRuntime.jsx)(Preview,{record:e}),t.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.findings,testID:_testIDs.ASSETS_TEST_IDS.detailFindings,children:t.map((i,l)=>(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.findingText,testID:(0,_testIDs.assetFindingTestID)(l),children:i},i))}):null,(0,_jsxRuntime.jsx)(Row,{label:"Name",value:`${e.name}.${e.type}`}),(0,_jsxRuntime.jsx)(Row,{label:"Kind",value:e.kind}),(0,_jsxRuntime.jsx)(Row,{label:"Status",value:e.loaded?"Loaded (registered at runtime)":"Not observed in the runtime registry"}),e.kind==="image"?(0,_jsxRuntime.jsx)(Row,{label:"Dimensions",value:`${(0,_format.formatDimensions)(e)} (logical)`}):null,e.kind==="image"&&e.scales.length?(0,_jsxRuntime.jsx)(Row,{label:"Scales",value:(0,_format.formatScales)(e.scales)}):null,e.sizesByScale?Object.entries(e.sizesByScale).map(([i,l])=>(0,_jsxRuntime.jsx)(Row,{label:`Size @${i}x`,value:(0,_format.formatBytes)(l)},i)):null,e.sizeBytes!=null&&e.sizeSource==="measured"?(0,_jsxRuntime.jsx)(Row,{label:"Total size",value:(0,_format.formatBytes)(e.sizeBytes)}):null,n>0?(0,_jsxRuntime.jsx)(Row,{label:"Decoded memory",value:`~${(0,_format.formatBytes)(n)} (RGBA)`}):null,e.registryId!=null?(0,_jsxRuntime.jsx)(Row,{label:"Registry id",value:String(e.registryId)}):null,e.hash?(0,_jsxRuntime.jsx)(Row,{label:"Hash",value:e.hash}):null,e.httpServerLocation?(0,_jsxRuntime.jsx)(Row,{label:"Location",value:e.httpServerLocation}):null,e.fileSystemLocation?(0,_jsxRuntime.jsx)(Row,{label:"Source dir",value:e.fileSystemLocation}):null,e.resolvedUri?(0,_jsxRuntime.jsx)(Row,{label:"Resolved URI",value:e.resolvedUri}):null]})}const styles=_reactNative.StyleSheet.create({scroll:{flex:1},content:{padding:12,gap:8},previewBox:{borderRadius:8,backgroundColor:_sharedUi.night.color.bg,padding:12,alignItems:"center",justifyContent:"center",minHeight:96},previewImage:{width:"100%",height:140},fontPreview:{color:_sharedUi.night.color.text,fontSize:16,textAlign:"center"},findings:{borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,backgroundColor:_sharedUi.night.color.surface,padding:10,gap:6},findingText:{color:_sharedUi.night.color.textSecondary,fontSize:11,lineHeight:15},kvRow:{gap:2},kvLabel:{color:_sharedUi.night.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,textTransform:"uppercase"},kvValue:{color:_sharedUi.night.color.text,fontSize:12}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.AssetDetail=AssetDetail;var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _AssetImage=require("./AssetImage");var _format=require("../format");var _assetStore=require("../store/assetStore");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function Row({label:e,value:s}){const t=(0,_testIDs.assetDetailRowTestID)(e);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.kvRow,testID:t,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.kvLabel,children:e}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.kvValue,selectable:true,testID:`${t}-value`,children:s})]})}function Preview({record:e}){if(e.kind==="image"){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.previewBox,testID:_testIDs.ASSETS_TEST_IDS.detailPreview,children:(0,_jsxRuntime.jsx)(_AssetImage.AssetImage,{testID:"buoy-internal-assets-preview",record:e,style:styles.previewImage})})}if(e.kind==="font"){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.previewBox,testID:_testIDs.ASSETS_TEST_IDS.detailFontPreview,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.fontPreview,{fontFamily:e.name}],children:"The quick brown fox jumps over the lazy dog 0123456789"})})}return null}function AssetDetail({record:e,insights:s}){const t=[];if(s.neverLoaded.includes(e.id)){t.push("Not observed in the runtime registry this app run. This does not prove the asset is unused.")}if(s.scaleGaps.includes(e.id)){t.push("Scale gap \u2014 no variant covers this device's pixel ratio")}if(s.webpCandidates.includes(e.id)){t.push("WebP candidate \u2014 large png/jpeg, converting typically saves 20\u201340%")}const a=s.duplicates.find(l=>l.ids.includes(e.id));if(a){t.push(`Duplicate content \u2014 identical bytes shipped ${a.ids.length} times`)}if(s.overDecode.includes(e.id)){t.push("Decodes larger than 2\xD7 this entire screen \u2014 resize the source, no view can need this many pixels")}if(s.heavyGifs.includes(e.id)){t.push("Heavy GIF \u2014 every frame decodes into memory; a video or Lottie is typically ~90% smaller")}if(s.heavyFonts.includes(e.id)){t.push("Heavy font \u2014 likely an unsubset icon font; subsetting to used glyphs usually saves most of it")}if(s.scaleAnomalies.includes(e.id)){t.push("Scale anomaly \u2014 a higher-resolution variant is smaller in bytes than a lower one; check the exports")}const n=(0,_assetStore.estDecodedBytes)(e);return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.scroll,contentContainerStyle:styles.content,testID:_testIDs.ASSETS_TEST_IDS.detailScroll,children:[(0,_jsxRuntime.jsx)(Preview,{record:e}),t.length>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.findings,testID:_testIDs.ASSETS_TEST_IDS.detailFindings,children:t.map((l,i)=>(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.findingText,testID:(0,_testIDs.assetFindingTestID)(i),children:l},l))}):null,(0,_jsxRuntime.jsx)(Row,{label:"Name",value:`${e.name}.${e.type}`}),e.loadStatus&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(Row,{label:"Load",value:e.loadStatus==="error"?"Failed":"Loaded"}),(0,_jsxRuntime.jsx)(Row,{label:"Load time",value:e.durationMs==null?"Unknown":`${e.durationMs.toFixed(1)} ms`}),(0,_jsxRuntime.jsx)(Row,{label:"Load size",value:e.sizeBytes==null?"Unknown":(0,_format.formatBytes)(e.sizeBytes)}),(0,_jsxRuntime.jsx)(Row,{label:"Cache",value:e.cacheHit==null?"Unknown":e.cacheHit?"Cache hit":"Web load"})]}),(0,_jsxRuntime.jsx)(Row,{label:"Kind",value:e.kind}),(0,_jsxRuntime.jsx)(Row,{label:"Status",value:e.loaded?"Loaded (registered at runtime)":"Not observed in the runtime registry"}),e.kind==="image"?(0,_jsxRuntime.jsx)(Row,{label:"Dimensions",value:`${(0,_format.formatDimensions)(e)} (logical)`}):null,e.kind==="image"&&e.scales.length?(0,_jsxRuntime.jsx)(Row,{label:"Scales",value:(0,_format.formatScales)(e.scales)}):null,e.sizesByScale?Object.entries(e.sizesByScale).map(([l,i])=>(0,_jsxRuntime.jsx)(Row,{label:`Size @${l}x`,value:(0,_format.formatBytes)(i)},l)):null,e.sizeBytes!=null&&e.sizeSource==="measured"?(0,_jsxRuntime.jsx)(Row,{label:"Total size",value:(0,_format.formatBytes)(e.sizeBytes)}):null,n>0?(0,_jsxRuntime.jsx)(Row,{label:"Decoded memory",value:`~${(0,_format.formatBytes)(n)} (RGBA)`}):null,e.registryId!=null?(0,_jsxRuntime.jsx)(Row,{label:"Registry id",value:String(e.registryId)}):null,e.hash?(0,_jsxRuntime.jsx)(Row,{label:"Hash",value:e.hash}):null,e.httpServerLocation?(0,_jsxRuntime.jsx)(Row,{label:"Location",value:e.httpServerLocation}):null,e.fileSystemLocation?(0,_jsxRuntime.jsx)(Row,{label:"Source dir",value:e.fileSystemLocation}):null,e.resolvedUri?(0,_jsxRuntime.jsx)(Row,{label:"Resolved URI",value:e.resolvedUri}):null]})}const styles=_reactNative.StyleSheet.create({scroll:{flex:1},content:{padding:12,gap:8},previewBox:{borderRadius:8,backgroundColor:_sharedUi.night.color.bg,padding:12,alignItems:"center",justifyContent:"center",minHeight:96},previewImage:{width:"100%",height:140},fontPreview:{color:_sharedUi.night.color.text,fontSize:16,textAlign:"center"},findings:{borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,backgroundColor:_sharedUi.night.color.surface,padding:10,gap:6},findingText:{color:_sharedUi.night.color.textSecondary,fontSize:11,lineHeight:15},kvRow:{gap:2},kvLabel:{color:_sharedUi.night.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,textTransform:"uppercase"},kvValue:{color:_sharedUi.night.color.text,fontSize:12}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.AssetImage=AssetImage;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _measure=require("../capture/measure");var _optionalExpoImage=require("./optionalExpoImage");var _jsxRuntime=require("react/jsx-runtime");function AssetImage({record:t,style:a,testID:s,compact:u=false}){const e=(0,_measure.displaySource)(t);const r=t.type.toLowerCase()==="svg";const n=r&&_reactNative.Platform.OS!=="web"?(0,_optionalExpoImage.getExpoPreviewImage)():null;const o=`${t.key}:${t.hash??""}:${typeof e==="number"?e:e?.uri??""}`;const[c,v]=(0,_react.useState)(null);const x=e==null||c===o||r&&_reactNative.Platform.OS!=="web"&&!n;if(x){const l=r?"SVG preview unavailable":"Image preview unavailable";return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[a,styles.fallback],accessibilityLabel:l,testID:`${s}-unavailable`,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.text,children:u?r?"SVG":"IMG":l})})}const i=()=>v(o);if(n){return(0,_jsxRuntime.jsx)(n,{source:e,style:a,contentFit:"contain",onError:i,testID:s})}return(0,_jsxRuntime.jsx)(_reactNative.Image,{source:e,style:a,resizeMode:"contain",onError:i,testID:s})}const styles=_reactNative.StyleSheet.create({fallback:{alignItems:"center",justifyContent:"center"},text:{color:_sharedUi.night.color.textSecondary,fontSize:10,textAlign:"center"}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.AssetImage=AssetImage;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _measure=require("../capture/measure");var _toolPreview=require("../capture/toolPreview");var _optionalExpoImage=require("./optionalExpoImage");var _jsxRuntime=require("react/jsx-runtime");function AssetImage({record:r,style:a,testID:o,compact:u=false}){const e=(0,_measure.displaySource)(r);(0,_toolPreview.markToolPreviewSource)(e);const t=r.type.toLowerCase()==="svg";const s=t&&_reactNative.Platform.OS!=="web"?(0,_optionalExpoImage.getExpoPreviewImage)():null;const i=`${r.key}:${r.hash??""}:${typeof e==="number"?e:e?.uri??""}`;const[c,v]=(0,_react.useState)(null);const m=e==null||c===i||t&&_reactNative.Platform.OS!=="web"&&!s;if(m){const l=t?"SVG preview unavailable":"Image preview unavailable";return(0,_jsxRuntime.jsx)(_reactNative.View,{style:[a,styles.fallback],accessibilityLabel:l,testID:`${o}-unavailable`,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.text,children:u?t?"SVG":"IMG":l})})}const n=()=>v(i);if(s){return(0,_jsxRuntime.jsx)(s,{source:e,style:a,contentFit:"contain",onError:n,testID:o})}return(0,_jsxRuntime.jsx)(_reactNative.Image,{source:e,style:a,resizeMode:"contain",onError:n,testID:o})}const styles=_reactNative.StyleSheet.create({fallback:{alignItems:"center",justifyContent:"center"},text:{color:_sharedUi.night.color.textSecondary,fontSize:10,textAlign:"center"}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"ASSETS_ICON_COLOR",{enumerable:true,get:function(){return _AssetsIcon.ASSETS_ICON_COLOR}});Object.defineProperty(exports,"ASSETS_TEST_IDS",{enumerable:true,get:function(){return _testIDs.ASSETS_TEST_IDS}});Object.defineProperty(exports,"AssetsIcon",{enumerable:true,get:function(){return _AssetsIcon.AssetsIcon}});Object.defineProperty(exports,"AssetsModal",{enumerable:true,get:function(){return _AssetsModal.AssetsModal}});Object.defineProperty(exports,"AssetsToolView",{enumerable:true,get:function(){return _AssetsModal.AssetsToolView}});Object.defineProperty(exports,"assetBadgeTestID",{enumerable:true,get:function(){return _testIDs.assetBadgeTestID}});Object.defineProperty(exports,"assetDetailRowTestID",{enumerable:true,get:function(){return _testIDs.assetDetailRowTestID}});Object.defineProperty(exports,"assetFilterTestID",{enumerable:true,get:function(){return _testIDs.assetFilterTestID}});Object.defineProperty(exports,"assetFindingTestID",{enumerable:true,get:function(){return _testIDs.assetFindingTestID}});Object.defineProperty(exports,"assetFontChipTestID",{enumerable:true,get:function(){return _testIDs.assetFontChipTestID}});Object.defineProperty(exports,"assetRowTestID",{enumerable:true,get:function(){return _testIDs.assetRowTestID}});Object.defineProperty(exports,"assetSlug",{enumerable:true,get:function(){return _testIDs.assetSlug}});Object.defineProperty(exports,"assetsSyncAdapter",{enumerable:true,get:function(){return _assetsSyncAdapter.assetsSyncAdapter}});Object.defineProperty(exports,"assetsToolPreset",{enumerable:true,get:function(){return _preset.assetsToolPreset}});Object.defineProperty(exports,"clearBaseline",{enumerable:true,get:function(){return _baseline.clearBaseline}});Object.defineProperty(exports,"clearRecords",{enumerable:true,get:function(){return _assetStore.clearRecords}});Object.defineProperty(exports,"computeDiff",{enumerable:true,get:function(){return _baseline.computeDiff}});Object.defineProperty(exports,"computeInsights",{enumerable:true,get:function(){return _insights.computeInsights}});Object.defineProperty(exports,"computeStats",{enumerable:true,get:function(){return _assetStore.computeStats}});Object.defineProperty(exports,"createAssetsTool",{enumerable:true,get:function(){return _preset.createAssetsTool}});Object.defineProperty(exports,"disableAssetsCapture",{enumerable:true,get:function(){return _remote.disableAssetsCapture}});Object.defineProperty(exports,"estDecodedBytes",{enumerable:true,get:function(){return _assetStore.estDecodedBytes}});Object.defineProperty(exports,"fetchAssetGraph",{enumerable:true,get:function(){return _metroGraph.fetchAssetGraph}});Object.defineProperty(exports,"formatAssetMarkdown",{enumerable:true,get:function(){return _export.formatAssetMarkdown}});Object.defineProperty(exports,"formatInventoryMarkdown",{enumerable:true,get:function(){return _export.formatInventoryMarkdown}});Object.defineProperty(exports,"getBrowserAssetManifest",{enumerable:true,get:function(){return _browserAssets.getBrowserAssetManifest}});Object.defineProperty(exports,"getDevServerOrigin",{enumerable:true,get:function(){return _metroGraph.getDevServerOrigin}});Object.defineProperty(exports,"getDiff",{enumerable:true,get:function(){return _baseline.getDiff}});Object.defineProperty(exports,"getLoadedFontFamilies",{enumerable:true,get:function(){return _expo.getLoadedFontFamilies}});Object.defineProperty(exports,"getLocalAssets",{enumerable:true,get:function(){return _expo.getLocalAssets}});Object.defineProperty(exports,"getRecord",{enumerable:true,get:function(){return _assetStore.getRecord}});Object.defineProperty(exports,"getScanStatus",{enumerable:true,get:function(){return _install.getScanStatus}});Object.defineProperty(exports,"getSnapshot",{enumerable:true,get:function(){return _assetStore.getSnapshot}});Object.defineProperty(exports,"installAssetCapture",{enumerable:true,get:function(){return _install.installAssetCapture}});Object.defineProperty(exports,"loadBaseline",{enumerable:true,get:function(){return _baseline.loadBaseline}});Object.defineProperty(exports,"loadBrowserAssetManifest",{enumerable:true,get:function(){return _browserAssets.loadBrowserAssetManifest}});Object.defineProperty(exports,"measureSizes",{enumerable:true,get:function(){return _measure.measureSizes}});Object.defineProperty(exports,"registerBrowserAssetManifest",{enumerable:true,get:function(){return _browserAssets.registerBrowserAssetManifest}});Object.defineProperty(exports,"replaceAssetsFromSnapshot",{enumerable:true,get:function(){return _remote.replaceAssetsFromSnapshot}});Object.defineProperty(exports,"rescan",{enumerable:true,get:function(){return _install.rescan}});Object.defineProperty(exports,"saveBaseline",{enumerable:true,get:function(){return _baseline.saveBaseline}});Object.defineProperty(exports,"setRemoteAssetsHandler",{enumerable:true,get:function(){return _remote.setRemoteAssetsHandler}});Object.defineProperty(exports,"startBrowserAssetCapture",{enumerable:true,get:function(){return _assetLifecycle.startBrowserAssetCapture}});Object.defineProperty(exports,"subscribe",{enumerable:true,get:function(){return _assetStore.subscribe}});Object.defineProperty(exports,"useAssetRecords",{enumerable:true,get:function(){return _useAssetRecords.useAssetRecords}});var _preset=require("./preset");var _AssetsModal=require("./components/AssetsModal");var _AssetsIcon=require("./components/AssetsIcon");var _install=require("./capture/install");var _measure=require("./capture/measure");var _metroGraph=require("./capture/metroGraph");var _expo=require("./capture/expo");var _assetStore=require("./store/assetStore");var _insights=require("./store/insights");var _baseline=require("./store/baseline");var _useAssetRecords=require("./hooks/useAssetRecords");var _export=require("./export");var _assetsSyncAdapter=require("./sync/assetsSyncAdapter");var _remote=require("./remote");var _testIDs=require("./utils/testIDs");require("./autoCapture");var _browserAssets=require("./capture/browserAssets");var _assetLifecycle=require("./capture/assetLifecycle");
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});Object.defineProperty(exports,"ASSETS_ICON_COLOR",{enumerable:true,get:function(){return _AssetsIcon.ASSETS_ICON_COLOR}});Object.defineProperty(exports,"ASSETS_TEST_IDS",{enumerable:true,get:function(){return _testIDs.ASSETS_TEST_IDS}});Object.defineProperty(exports,"AssetsIcon",{enumerable:true,get:function(){return _AssetsIcon.AssetsIcon}});Object.defineProperty(exports,"AssetsModal",{enumerable:true,get:function(){return _AssetsModal.AssetsModal}});Object.defineProperty(exports,"AssetsToolView",{enumerable:true,get:function(){return _AssetsModal.AssetsToolView}});Object.defineProperty(exports,"assetBadgeTestID",{enumerable:true,get:function(){return _testIDs.assetBadgeTestID}});Object.defineProperty(exports,"assetDetailRowTestID",{enumerable:true,get:function(){return _testIDs.assetDetailRowTestID}});Object.defineProperty(exports,"assetFilterTestID",{enumerable:true,get:function(){return _testIDs.assetFilterTestID}});Object.defineProperty(exports,"assetFindingTestID",{enumerable:true,get:function(){return _testIDs.assetFindingTestID}});Object.defineProperty(exports,"assetFontChipTestID",{enumerable:true,get:function(){return _testIDs.assetFontChipTestID}});Object.defineProperty(exports,"assetRowTestID",{enumerable:true,get:function(){return _testIDs.assetRowTestID}});Object.defineProperty(exports,"assetSlug",{enumerable:true,get:function(){return _testIDs.assetSlug}});Object.defineProperty(exports,"assetsSyncAdapter",{enumerable:true,get:function(){return _assetsSyncAdapter.assetsSyncAdapter}});Object.defineProperty(exports,"assetsToolPreset",{enumerable:true,get:function(){return _preset.assetsToolPreset}});Object.defineProperty(exports,"clearBaseline",{enumerable:true,get:function(){return _baseline.clearBaseline}});Object.defineProperty(exports,"clearRecords",{enumerable:true,get:function(){return _assetStore.clearRecords}});Object.defineProperty(exports,"computeDiff",{enumerable:true,get:function(){return _baseline.computeDiff}});Object.defineProperty(exports,"computeInsights",{enumerable:true,get:function(){return _insights.computeInsights}});Object.defineProperty(exports,"computeStats",{enumerable:true,get:function(){return _assetStore.computeStats}});Object.defineProperty(exports,"createAssetsTool",{enumerable:true,get:function(){return _preset.createAssetsTool}});Object.defineProperty(exports,"disableAssetsCapture",{enumerable:true,get:function(){return _remote.disableAssetsCapture}});Object.defineProperty(exports,"estDecodedBytes",{enumerable:true,get:function(){return _assetStore.estDecodedBytes}});Object.defineProperty(exports,"fetchAssetGraph",{enumerable:true,get:function(){return _metroGraph.fetchAssetGraph}});Object.defineProperty(exports,"formatAssetMarkdown",{enumerable:true,get:function(){return _export.formatAssetMarkdown}});Object.defineProperty(exports,"formatInventoryMarkdown",{enumerable:true,get:function(){return _export.formatInventoryMarkdown}});Object.defineProperty(exports,"getBrowserAssetManifest",{enumerable:true,get:function(){return _browserAssets.getBrowserAssetManifest}});Object.defineProperty(exports,"getDevServerOrigin",{enumerable:true,get:function(){return _metroGraph.getDevServerOrigin}});Object.defineProperty(exports,"getDiff",{enumerable:true,get:function(){return _baseline.getDiff}});Object.defineProperty(exports,"getLoadedFontFamilies",{enumerable:true,get:function(){return _expo.getLoadedFontFamilies}});Object.defineProperty(exports,"getLocalAssets",{enumerable:true,get:function(){return _expo.getLocalAssets}});Object.defineProperty(exports,"getRecord",{enumerable:true,get:function(){return _assetStore.getRecord}});Object.defineProperty(exports,"getScanStatus",{enumerable:true,get:function(){return _install.getScanStatus}});Object.defineProperty(exports,"getSnapshot",{enumerable:true,get:function(){return _assetStore.getSnapshot}});Object.defineProperty(exports,"installAssetCapture",{enumerable:true,get:function(){return _install.installAssetCapture}});Object.defineProperty(exports,"loadBaseline",{enumerable:true,get:function(){return _baseline.loadBaseline}});Object.defineProperty(exports,"loadBrowserAssetManifest",{enumerable:true,get:function(){return _browserAssets.loadBrowserAssetManifest}});Object.defineProperty(exports,"measureSizes",{enumerable:true,get:function(){return _measure.measureSizes}});Object.defineProperty(exports,"recordBrowserAssetLoad",{enumerable:true,get:function(){return _browserAssets.recordBrowserAssetLoad}});Object.defineProperty(exports,"registerBrowserAssetManifest",{enumerable:true,get:function(){return _browserAssets.registerBrowserAssetManifest}});Object.defineProperty(exports,"replaceAssetsFromSnapshot",{enumerable:true,get:function(){return _remote.replaceAssetsFromSnapshot}});Object.defineProperty(exports,"rescan",{enumerable:true,get:function(){return _install.rescan}});Object.defineProperty(exports,"saveBaseline",{enumerable:true,get:function(){return _baseline.saveBaseline}});Object.defineProperty(exports,"setRemoteAssetsHandler",{enumerable:true,get:function(){return _remote.setRemoteAssetsHandler}});Object.defineProperty(exports,"startBrowserAssetCapture",{enumerable:true,get:function(){return _assetLifecycle.startBrowserAssetCapture}});Object.defineProperty(exports,"subscribe",{enumerable:true,get:function(){return _assetStore.subscribe}});Object.defineProperty(exports,"useAssetRecords",{enumerable:true,get:function(){return _useAssetRecords.useAssetRecords}});var _preset=require("./preset");var _AssetsModal=require("./components/AssetsModal");var _AssetsIcon=require("./components/AssetsIcon");var _install=require("./capture/install");var _measure=require("./capture/measure");var _metroGraph=require("./capture/metroGraph");var _expo=require("./capture/expo");var _assetStore=require("./store/assetStore");var _insights=require("./store/insights");var _baseline=require("./store/baseline");var _useAssetRecords=require("./hooks/useAssetRecords");var _export=require("./export");var _assetsSyncAdapter=require("./sync/assetsSyncAdapter");var _remote=require("./remote");var _testIDs=require("./utils/testIDs");require("./autoCapture");var _browserAssets=require("./capture/browserAssets");var _assetLifecycle=require("./capture/assetLifecycle");
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.disableAssetsCapture=disableAssetsCapture;exports.remoteAssetsDispatch=remoteAssetsDispatch;exports.replaceAssetsFromSnapshot=replaceAssetsFromSnapshot;exports.setRemoteAssetsHandler=setRemoteAssetsHandler;var _state=require("./state");var _assetStore=require("./store/assetStore");function setRemoteAssetsHandler(t){(0,_state.assetsState)().remoteDispatch=t}function remoteAssetsDispatch(){return(0,_state.assetsState)().remoteDispatch}function disableAssetsCapture(){(0,_state.assetsState)().captureDisabled=true}function replaceAssetsFromSnapshot(t){const s=(0,_state.assetsState)();const r=t.records??[];s.records=r.map(e=>({id:e.id,key:e.key,registryId:e.registryId??void 0,name:e.name,type:e.type,kind:e.kind,hash:e.hash??void 0,httpServerLocation:e.location??void 0,width:e.width??void 0,height:e.height??void 0,scales:e.scales,resolvedUri:e.uri??void 0,loaded:e.loaded,origin:e.registryId!=null?"registry":"graph",sizeBytes:e.sizeBytes??void 0,sizeSource:e.sizeSource??void 0,firstSeenAt:Date.now()}));s.byKey=new Map(s.records.map(e=>[e.key,e]));s.byId=new Map(s.records.map(e=>[e.id,e]));if(t.scanStatus){s.fontFamilies=[...new Set(t.scanStatus.fontFamilies??[])];s.mirrorScanStatus={...t.scanStatus,fontFamilies:s.fontFamilies}}s.mirrorDiff=t.diff??null;(0,_assetStore.invalidate)()}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.disableAssetsCapture=disableAssetsCapture;exports.remoteAssetsDispatch=remoteAssetsDispatch;exports.replaceAssetsFromSnapshot=replaceAssetsFromSnapshot;exports.setRemoteAssetsHandler=setRemoteAssetsHandler;var _isBuoyAsset=require("./capture/isBuoyAsset");var _state=require("./state");var _assetStore=require("./store/assetStore");function setRemoteAssetsHandler(t){(0,_state.assetsState)().remoteDispatch=t}function remoteAssetsDispatch(){return(0,_state.assetsState)().remoteDispatch}function disableAssetsCapture(){(0,_state.assetsState)().captureDisabled=true}function replaceAssetsFromSnapshot(t){const s=(0,_state.assetsState)();const i=t.records??[];s.records=i.map(e=>({id:e.id,key:e.key,loadStatus:e.loadStatus,durationMs:e.durationMs,cacheHit:e.cacheHit,registryId:e.registryId??void 0,name:e.name,type:e.type,kind:e.kind,hash:e.hash??void 0,httpServerLocation:e.location??void 0,width:e.width??void 0,height:e.height??void 0,scales:e.scales,resolvedUri:e.uri??void 0,loaded:e.loaded,origin:e.registryId!=null?"registry":"graph",sizeBytes:e.sizeBytes??void 0,sizeSource:e.sizeSource??void 0,firstSeenAt:Date.now()})).filter(e=>!(0,_isBuoyAsset.isBuoyAsset)(e));s.byKey=new Map(s.records.map(e=>[e.key,e]));s.byId=new Map(s.records.map(e=>[e.id,e]));if(t.scanStatus){s.fontFamilies=[...new Set(t.scanStatus.fontFamilies??[])];s.mirrorScanStatus={...t.scanStatus,fontFamilies:s.fontFamilies}}s.mirrorDiff=t.diff??null;(0,_assetStore.invalidate)()}
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.assetsSyncAdapter=void 0;var _install=require("../capture/install");var _measure=require("../capture/measure");var _assetStore=require("../store/assetStore");var _baseline=require("../store/baseline");var _insights=require("../store/insights");const KINDS=["image","font","video","audio","data","other"];function toWire(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:(0,_assetStore.estDecodedBytes)(e)||null,sizeSource:e.sizeSource??null}}function requireRecord(e){const t=e?.id;if(typeof t!=="number")throw new Error("Missing numeric `id` param");const i=(0,_assetStore.getRecord)(t);if(!i){throw new Error(`Asset record ${t} not found \u2014 re-run the list action for current ids.`)}return i}function bySizeDesc(e,t){return(t.sizeBytes??(0,_assetStore.estDecodedBytes)(t))-(e.sizeBytes??(0,_assetStore.estDecodedBytes)(e))}function overview(){const e=(0,_assetStore.getSnapshot)();return{stats:(0,_assetStore.computeStats)(e),scanStatus:(0,_install.getScanStatus)(),insights:(0,_insights.computeInsights)(e),diff:(0,_baseline.getDiff)(),records:[...e].sort(bySizeDesc)}}const assetsSyncAdapter=exports.assetsSyncAdapter={version:1,getSnapshot:()=>{const{records:e,...t}=overview();return{...t,records:e.slice(0,200).map(toWire)}},subscribe:e=>(0,_assetStore.subscribe)(e),actions:{list:e=>{const t=e??{};const i=Math.min(Math.max(t.limit??50,1),500);const{records:r,...a}=overview();let s=r;if(t.kind){if(!KINDS.includes(t.kind)){throw new Error(`kind must be one of: ${KINDS.join(", ")}`)}s=s.filter(n=>n.kind===t.kind)}if(t.loadedOnly)s=s.filter(n=>n.loaded);return{...a,total:s.length,records:s.slice(0,i).map(toWire)}},getDetail:e=>{const t=requireRecord(e);return{...toWire(t),origin:t.origin,fileSystemLocation:t.fileSystemLocation??null,files:t.files??null,sizesByScale:t.sizesByScale??null,estDecodedBytes:(0,_assetStore.estDecodedBytes)(t)||null}},rescan:async()=>{const e=await(0,_install.rescan)();return{ok:true,scanStatus:e}},measureSizes:async()=>{const e=await(0,_measure.measureSizes)();return{ok:e.measured>0,...e}},saveBaseline:async()=>{const e=await(0,_baseline.saveBaseline)();return{ok:true,savedAt:e.savedAt,assets:Object.keys(e.entries).length}},clearBaseline:async()=>{await(0,_baseline.clearBaseline)();return{ok:true,message:"Baseline cleared"}},getDiff:()=>(0,_baseline.getDiff)(),clearRecords:()=>{(0,_assetStore.clearRecords)();return{ok:true,message:"Inventory cleared \u2014 rescan to rebuild"}},getScanStatus:()=>(0,_install.getScanStatus)()}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.assetsSyncAdapter=void 0;var _install=require("../capture/install");var _measure=require("../capture/measure");var _assetStore=require("../store/assetStore");var _baseline=require("../store/baseline");var _insights=require("../store/insights");const KINDS=["image","font","video","audio","data","other"];function toWire(e){return{loadStatus:e.loadStatus,durationMs:e.durationMs,cacheHit:e.cacheHit,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:(0,_assetStore.estDecodedBytes)(e)||null,sizeSource:e.sizeSource??null}}function requireRecord(e){const t=e?.id;if(typeof t!=="number")throw new Error("Missing numeric `id` param");const i=(0,_assetStore.getRecord)(t);if(!i){throw new Error(`Asset record ${t} not found \u2014 re-run the list action for current ids.`)}return i}function bySizeDesc(e,t){return(t.sizeBytes??(0,_assetStore.estDecodedBytes)(t))-(e.sizeBytes??(0,_assetStore.estDecodedBytes)(e))}function overview(){const e=(0,_assetStore.getSnapshot)();return{stats:(0,_assetStore.computeStats)(e),scanStatus:(0,_install.getScanStatus)(),insights:(0,_insights.computeInsights)(e),diff:(0,_baseline.getDiff)(),records:[...e].sort(bySizeDesc)}}const assetsSyncAdapter=exports.assetsSyncAdapter={version:1,getSnapshot:()=>{const{records:e,...t}=overview();return{...t,records:e.slice(0,200).map(toWire)}},subscribe:e=>(0,_assetStore.subscribe)(e),actions:{list:e=>{const t=e??{};const i=Math.min(Math.max(t.limit??50,1),500);const{records:a,...r}=overview();let s=a;if(t.kind){if(!KINDS.includes(t.kind)){throw new Error(`kind must be one of: ${KINDS.join(", ")}`)}s=s.filter(n=>n.kind===t.kind)}if(t.loadedOnly)s=s.filter(n=>n.loaded);return{...r,total:s.length,records:s.slice(0,i).map(toWire)}},getDetail:e=>{const t=requireRecord(e);return{...toWire(t),origin:t.origin,fileSystemLocation:t.fileSystemLocation??null,files:t.files??null,sizesByScale:t.sizesByScale??null,estDecodedBytes:(0,_assetStore.estDecodedBytes)(t)||null}},rescan:async()=>{const e=await(0,_install.rescan)();return{ok:true,scanStatus:e}},measureSizes:async()=>{const e=await(0,_measure.measureSizes)();return{ok:e.measured>0,...e}},saveBaseline:async()=>{const e=await(0,_baseline.saveBaseline)();return{ok:true,savedAt:e.savedAt,assets:Object.keys(e.entries).length}},clearBaseline:async()=>{await(0,_baseline.clearBaseline)();return{ok:true,message:"Baseline cleared"}},getDiff:()=>(0,_baseline.getDiff)(),clearRecords:()=>{(0,_assetStore.clearRecords)();return{ok:true,message:"Inventory cleared \u2014 rescan to rebuild"}},getScanStatus:()=>(0,_install.getScanStatus)()}};
@@ -1 +1 @@
1
- "use strict";import{assetsState as c}from"../state";import{upsertRecord as a,updateRecord as d}from"../store/assetStore";let o=[];export function registerBrowserAssetManifest(e){o=e;if(typeof document!=="undefined")scanBrowserAssets()}export function getBrowserAssetManifest(){return o}export async function loadBrowserAssetManifest(e){const t=await fetch(e);if(!t.ok)throw new Error(`Asset manifest returned HTTP ${t.status}.`);const r=await t.json();if(!Array.isArray(r)||r.some(n=>!n||typeof n.url!=="string"))throw new Error("An asset manifest must contain an array of assets with URL strings.");registerBrowserAssetManifest(r)}function s(e,t){let r;try{r=new URL(e.url,document.baseURI)}catch{return}const n=r.pathname.split("/").pop()??"";const i=n.includes(".")?n.split(".").pop().toLowerCase():"other";const u=a({key:r.href,name:n.slice(0,-(i.length+1))||n,type:i,origin:t?"browser":"graph",resolvedUri:r.href,resolvedScale:1,scales:[1],hash:e.hash,loaded:t,width:e.width,height:e.height});if(u&&e.bytes!==void 0&&e.bytes>=0)d(u.id,{sizeBytes:e.bytes,sizesByScale:{"1":e.bytes},sizeSource:"measured"})}export function captureBrowserResource(e){if(e.initiatorType==="fetch"||e.initiatorType==="xmlhttprequest")return;s({url:e.name,bytes:e.encodedBodySize>0?e.encodedBodySize:void 0},true)}export function scanBrowserAssets(){if(typeof document==="undefined"||c().captureDisabled)return;o.forEach(t=>s(t,false));performance.getEntriesByType("resource").forEach(t=>captureBrowserResource(t));document.querySelectorAll("img").forEach(t=>{if(!t.closest("[data-buoy-root]")&&t.currentSrc)s({url:t.currentSrc,width:t.naturalWidth||void 0,height:t.naturalHeight||void 0},t.complete&&t.naturalWidth>0)});const e=c();e.graphSupported=o.length>0;e.graphCount=o.length>0?o.length:null;e.measuredCount=e.records.filter(t=>t.sizeBytes!==void 0).length;e.lastScanAt=Date.now()}
1
+ "use strict";import{buoyFetch as h,isBuoyElement as d,isBuoyAssetPath as p}from"@buoy-gg/shared-ui";import{assetsState as i}from"../state";import{upsertRecord as m,updateRecord as l}from"../store/assetStore";let n=[];const o=new Set;export function markBrowserToolImage(e){if(typeof document==="undefined")return;try{o.add(new URL(e,document.baseURI).href)}catch{}}function c(e=document){const t=Array.from(e.querySelectorAll("img"));for(const r of Array.from(e.querySelectorAll("*"))){if(r.shadowRoot)t.push(...c(r.shadowRoot))}return t}export function registerBrowserAssetManifest(e){n=e.filter(t=>!p(t.url));if(typeof document!=="undefined")scanBrowserAssets()}export function getBrowserAssetManifest(){return n}export async function loadBrowserAssetManifest(e){const t=await h(e);if(!t.ok)throw new Error(`Asset manifest returned HTTP ${t.status}.`);const r=await t.json();if(!Array.isArray(r)||r.some(s=>!s||typeof s.url!=="string"))throw new Error("An asset manifest must contain an array of assets with URL strings.");registerBrowserAssetManifest(r)}function u(e,t){let r;try{r=new URL(e.url,document.baseURI)}catch{return}const s=r.pathname.split("/").pop()??"";const f=s.includes(".")?s.split(".").pop().toLowerCase():"other";const a=m({key:r.href,name:s.slice(0,-(f.length+1))||s,type:f,origin:t?"browser":"graph",resolvedUri:r.href,resolvedScale:1,scales:[1],hash:e.hash,loaded:t,width:e.width,height:e.height});if(a&&e.bytes!==void 0&&e.bytes>=0)l(a.id,{sizeBytes:e.bytes,sizesByScale:{"1":e.bytes},sizeSource:"measured"});return a}export function captureBrowserResource(e){if(e.initiatorType==="fetch"||e.initiatorType==="xmlhttprequest")return;if(e.initiatorType==="img"){const t=c().filter(r=>(r.currentSrc||r.src)===e.name);if(t.length){if(t.every(d))o.add(e.name);else o.delete(e.name)}}if(o.has(e.name))return;u({url:e.name,bytes:e.encodedBodySize>0?e.encodedBodySize:void 0},true)}export function captureBrowserImage(e){if(i().captureDisabled)return;const t=e.currentSrc||e.src;if(d(e)){if(t)o.add(t);return}o.delete(t);if(!t||!e.complete||e.naturalWidth<=0)return;u({url:t,width:e.naturalWidth,height:e.naturalHeight},true)}export function scanBrowserAssets(){if(typeof document==="undefined"||i().captureDisabled)return;n.forEach(t=>u(t,false));performance.getEntriesByType("resource").forEach(t=>captureBrowserResource(t));c().forEach(captureBrowserImage);const e=i();e.graphSupported=n.length>0;e.graphCount=n.length>0?n.length:null;e.measuredCount=e.records.filter(t=>t.sizeBytes!==void 0).length;e.lastScanAt=Date.now()}export function recordBrowserAssetLoad(e){if(typeof document==="undefined"||i().captureDisabled)return;const t=u({url:e.url,bytes:e.bytes??void 0},e.status==="success");if(t)l(t.id,{loadStatus:e.status,durationMs:e.durationMs,cacheHit:e.cacheHit})}
@@ -1 +1 @@
1
- "use strict";import{assetsState as t}from"../state";import{invalidate as s}from"../store/assetStore";import{captureBrowserResource as u,scanBrowserAssets as n}from"./browserAssets";import{getLoadedFontFamilies as o}from"./expo";let r;export function installAssetCapture(){const e=t();if(typeof document==="undefined"||e.captureDisabled||e.installed)return;e.installed=true;e.registryAvailable=true;if(typeof PerformanceObserver!=="undefined"){r=new PerformanceObserver(a=>{if(t().captureDisabled){stopBrowserAssetCapture();return}a.getEntries().forEach(i=>u(i))});try{r.observe({type:"resource",buffered:true});e.patched=true}catch{r.disconnect();r=void 0}}n();e.fontFamilies=o();s()}export function stopBrowserAssetCapture(){r?.disconnect();r=void 0;t().installed=false;t().patched=false}export async function rescan(){installAssetCapture();n();t().fontFamilies=o();s();return getScanStatus()}export function getScanStatus(){const e=t();return e.mirrorScanStatus??{registryAvailable:e.registryAvailable,patched:e.patched,registryCount:e.records.filter(a=>a.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}}
1
+ "use strict";import{assetsState as r}from"../state";import{invalidate as n}from"../store/assetStore";import{captureBrowserImage as c,captureBrowserResource as l,scanBrowserAssets as s}from"./browserAssets";import{getLoadedFontFamilies as o}from"./expo";let a;const i=e=>{const t=e.target;if(t?.tagName==="IMG")c(t)};export function installAssetCapture(){const e=r();if(typeof document==="undefined"||e.captureDisabled||e.installed)return;e.installed=true;e.registryAvailable=true;document.addEventListener("load",i,true);if(typeof PerformanceObserver!=="undefined"){a=new PerformanceObserver(t=>{if(r().captureDisabled){stopBrowserAssetCapture();return}t.getEntries().forEach(u=>l(u))});try{a.observe({type:"resource",buffered:true});e.patched=true}catch{a.disconnect();a=void 0}}s();e.fontFamilies=o();n()}export function stopBrowserAssetCapture(){a?.disconnect();a=void 0;if(typeof document!=="undefined")document.removeEventListener("load",i,true);r().installed=false;r().patched=false}export async function rescan(){installAssetCapture();s();r().fontFamilies=o();n();return getScanStatus()}export function getScanStatus(){const e=r();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}}
@@ -1 +1 @@
1
- "use strict";export function isBuoyAssetPath(e){if(!e)return false;let t=e;try{t=decodeURIComponent(t)}catch{}t=t.replace(/\\/g,"/");return/(?:^|\/)node_modules\/@buoy-gg\/[^/]+(?:\/|$)/.test(t)||/(?:^|\/)buoy-packages\/packages\/[^/]+(?:\/|$)/.test(t)||/(?:^|\/)packages\/floating-tools-core\/(?:src|lib\/(?:module|commonjs))\/icons\/assets(?:\/|$)/.test(t)}export function isBuoyAsset(e){return[e.key,e.httpServerLocation,e.fileSystemLocation,...e.files??[]].some(isBuoyAssetPath)}
1
+ "use strict";import{isBuoyAssetPath as e}from"@buoy-gg/shared-ui";export{e as isBuoyAssetPath};export function isBuoyAsset(o){return[o.key,o.resolvedUri,o.httpServerLocation,o.fileSystemLocation,...o.files??[]].some(e)}
@@ -1 +1 @@
1
- "use strict";import{Platform as p}from"react-native";import{assetsState as f}from"../state";import{getSnapshot as l,invalidate as m,updateRecord as c}from"../store/assetStore";import{getDevServerOrigin as h}from"./metroGraph";const g=4;export function previewURL(t){if(t.resolvedUri)return t.resolvedUri;const n=variantURLs(t);return n.length?n[0].url:null}export function displaySource(t){const n=f().captureDisabled;if(!n&&t.registryId!=null)return t.registryId;const e=previewURL(t);if(!e)return null;if(n&&!/^https?:\/\//.test(e))return null;return{uri:e}}export function variantURLs(t){const n=t.scales.length?t.scales:[1];const e=t.resolvedUri;if(e&&/^https?:\/\//.test(e)&&t.resolvedScale!=null){const s=t.resolvedScale===1?"":`@${t.resolvedScale}x`;const a=`${s}.${t.type}`;if(e.includes(a)||s===""){return n.map(r=>{const u=r===1?"":`@${r}x`;const o=(s===""?e.replace(`.${t.type}`,`${u}.${t.type}`):e.replace(a,`${u}.${t.type}`)).replace(/ /g,"%20");return{scale:r,url:o}})}}const i=h();if(!i||!t.httpServerLocation)return[];return n.map(s=>{const a=s===1?"":`@${s}x`;const r=`${t.httpServerLocation}/${t.name}${a}.${t.type}`;const u=r.includes("?")?"&":"?";const o=`${i}${r}${u}platform=${y()}${t.hash?`&hash=${t.hash}`:""}`.replace(/ /g,"%20");return{scale:s,url:o}})}function y(){try{return p.OS}catch{return"ios"}}async function S(t){try{const n=await fetch(t,{method:"HEAD"});if(n.ok){const e=Number(n.headers.get("content-length"));if(Number.isFinite(e)&&e>0)return e}}catch{}try{const n=await fetch(t);if(!n.ok)return null;const e=await n.blob();return e.size>0?e.size:null}catch{return null}}async function $(t){const n=variantURLs(t);if(!n.length){c(t.id,{sizeSource:"estimate"});return}const e={};let i=0;for(const{scale:s,url:a}of n){const r=await S(a);if(r!=null){e[String(s)]=r;i+=r}}if(i>0){c(t.id,{sizesByScale:e,sizeBytes:i,sizeSource:"measured"})}else{c(t.id,{sizeSource:"estimate"})}}export async function measureSizes(){const t=f();if(t.measuring)return{measured:t.measuredCount,total:l().length};const n=l().filter(e=>e.sizeSource!=="measured");t.measuring=true;m();try{let e=0;const i=async()=>{for(;;){const s=n[e++];if(!s)return;await $(s);t.measuredCount=l().filter(a=>a.sizeSource==="measured").length}};await Promise.all(Array.from({length:Math.min(g,n.length)},i))}finally{t.measuring=false;m()}return{measured:t.measuredCount,total:l().length}}
1
+ "use strict";import{buoyFetch as f}from"@buoy-gg/shared-ui";import{Platform as h}from"react-native";import{assetsState as m}from"../state";import{getSnapshot as o,invalidate as p,updateRecord as c}from"../store/assetStore";import{getDevServerOrigin as g}from"./metroGraph";const y=4;export function previewURL(t){if(t.resolvedUri)return t.resolvedUri;const n=variantURLs(t);return n.length?n[0].url:null}export function displaySource(t){const n=m().captureDisabled;if(!n&&t.registryId!=null)return t.registryId;const e=previewURL(t);if(!e)return null;if(n&&!/^https?:\/\//.test(e))return null;return{uri:e}}export function variantURLs(t){const n=t.scales.length?t.scales:[1];const e=t.resolvedUri;if(e&&/^https?:\/\//.test(e)&&t.resolvedScale!=null){const s=t.resolvedScale===1?"":`@${t.resolvedScale}x`;const a=`${s}.${t.type}`;if(e.includes(a)||s===""){return n.map(r=>{const u=r===1?"":`@${r}x`;const l=(s===""?e.replace(`.${t.type}`,`${u}.${t.type}`):e.replace(a,`${u}.${t.type}`)).replace(/ /g,"%20");return{scale:r,url:l}})}}const i=g();if(!i||!t.httpServerLocation)return[];return n.map(s=>{const a=s===1?"":`@${s}x`;const r=`${t.httpServerLocation}/${t.name}${a}.${t.type}`;const u=r.includes("?")?"&":"?";const l=`${i}${r}${u}platform=${S()}${t.hash?`&hash=${t.hash}`:""}`.replace(/ /g,"%20");return{scale:s,url:l}})}function S(){try{return h.OS}catch{return"ios"}}async function $(t){try{const n=await f(t,{method:"HEAD"});if(n.ok){const e=Number(n.headers.get("content-length"));if(Number.isFinite(e)&&e>0)return e}}catch{}try{const n=await f(t);if(!n.ok)return null;const e=await n.blob();return e.size>0?e.size:null}catch{return null}}async function v(t){const n=variantURLs(t);if(!n.length){c(t.id,{sizeSource:"estimate"});return}const e={};let i=0;for(const{scale:s,url:a}of n){const r=await $(a);if(r!=null){e[String(s)]=r;i+=r}}if(i>0){c(t.id,{sizesByScale:e,sizeBytes:i,sizeSource:"measured"})}else{c(t.id,{sizeSource:"estimate"})}}export async function measureSizes(){const t=m();if(t.measuring)return{measured:t.measuredCount,total:o().length};const n=o().filter(e=>e.sizeSource!=="measured");t.measuring=true;p();try{let e=0;const i=async()=>{for(;;){const s=n[e++];if(!s)return;await v(s);t.measuredCount=o().filter(a=>a.sizeSource==="measured").length}};await Promise.all(Array.from({length:Math.min(y,n.length)},i))}finally{t.measuring=false;p()}return{measured:t.measuredCount,total:o().length}}
@@ -1 +1 @@
1
- "use strict";import{assetsState as h}from"../state";import{assetKey as l,invalidate as i,upsertRecord as u}from"../store/assetStore";const d=9e4;async function f(e,r){const a=new AbortController;let n;try{return await Promise.race([(async()=>{const s=await fetch(e,{signal:a.signal});if(!s.ok)throw new Error(`Metro responded ${s.status} for ${e}`);return s.json()})(),new Promise((s,c)=>{n=setTimeout(()=>{c(new Error("Asset discovery timed out. Try again."));a.abort()},Math.max(0,r))})])}finally{clearTimeout(n)}}export function getScriptURL(){try{const{NativeModules:e}=require("react-native");const r=e?.SourceCode;const a=r?.getConstants?.().scriptURL??r?.scriptURL;return typeof a==="string"?a:null}catch{return null}}export function getDevServerOrigin(){const e=getScriptURL();const r=e?.match(/^https?:\/\/[^/]+/);return r?r[0]:null}export function getGraphURLCandidates(){const e=getScriptURL();if(!e||!/^https?:\/\//.test(e))return[];const r=getDevServerOrigin();const a=e.indexOf("?");const n=a>=0?e.slice(a):"?platform=ios&dev=true";const s=[];if(e.includes(".bundle")){s.push(e.replace(".bundle",".assets"))}if(r){s.push(`${r}/node_modules/expo-router/entry.assets${n}`,`${r}/node_modules/expo/AppEntry.assets${n}`,`${r}/index.assets${n}`)}return s}export async function fetchAssetGraph(){const e=h();const r=getGraphURLCandidates();if(!r.length){e.graphSupported=false;e.graphError="No Metro dev server (embedded bundle)";i();return{ok:false,message:e.graphError}}if(e.graphFetchInFlight)return{ok:false,message:"Graph fetch already running"};e.graphFetchInFlight=true;e.graphFetchStartedAt=Date.now();e.graphError=null;i();const a=e.graphFetchStartedAt+d;try{let n=null;let s="";for(const t of r){try{const o=await f(t,a-Date.now());if(Array.isArray(o)){n=o;break}s="Unexpected .assets payload shape"}catch(o){s=String(o?.message??o);if(Date.now()>=a)break}}if(!Array.isArray(n))throw new Error(s||"No graph endpoint answered");const c=n;let p=0;for(const t of c){if(!t||typeof t.name!=="string"||typeof t.type!=="string"){continue}const o=u({key:l(t.httpServerLocation,t.name,t.type),name:t.name,type:t.type,origin:"graph",hash:t.hash,httpServerLocation:t.httpServerLocation,width:t.width??void 0,height:t.height??void 0,scales:t.scales,fileSystemLocation:t.fileSystemLocation,files:t.files,fileHashes:t.fileHashes});if(o)p++}e.graphSupported=true;e.graphCount=p;e.graphError=null;i();return{ok:true,count:p}}catch(n){e.graphSupported=getDevServerOrigin()!=null;e.graphError=String(n?.message??n);i();return{ok:false,message:e.graphError}}finally{e.graphFetchInFlight=false;e.graphFetchStartedAt=null;i()}}
1
+ "use strict";import{buoyFetch as h}from"@buoy-gg/shared-ui";import{assetsState as l}from"../state";import{assetKey as u,invalidate as i,upsertRecord as d}from"../store/assetStore";const f=9e4;async function g(e,r){const o=new AbortController;let n;try{return await Promise.race([(async()=>{const s=await h(e,{signal:o.signal});if(!s.ok)throw new Error(`Metro responded ${s.status} for ${e}`);return s.json()})(),new Promise((s,c)=>{n=setTimeout(()=>{c(new Error("Asset discovery timed out. Try again."));o.abort()},Math.max(0,r))})])}finally{clearTimeout(n)}}export function getScriptURL(){try{const{NativeModules:e}=require("react-native");const r=e?.SourceCode;const o=r?.getConstants?.().scriptURL??r?.scriptURL;return typeof o==="string"?o:null}catch{return null}}export function getDevServerOrigin(){const e=getScriptURL();const r=e?.match(/^https?:\/\/[^/]+/);return r?r[0]:null}export function getGraphURLCandidates(){const e=getScriptURL();if(!e||!/^https?:\/\//.test(e))return[];const r=getDevServerOrigin();const o=e.indexOf("?");const n=o>=0?e.slice(o):"?platform=ios&dev=true";const s=[];if(e.includes(".bundle")){s.push(e.replace(".bundle",".assets"))}if(r){s.push(`${r}/node_modules/expo-router/entry.assets${n}`,`${r}/node_modules/expo/AppEntry.assets${n}`,`${r}/index.assets${n}`)}return s}export async function fetchAssetGraph(){const e=l();const r=getGraphURLCandidates();if(!r.length){e.graphSupported=false;e.graphError="No Metro dev server (embedded bundle)";i();return{ok:false,message:e.graphError}}if(e.graphFetchInFlight)return{ok:false,message:"Graph fetch already running"};e.graphFetchInFlight=true;e.graphFetchStartedAt=Date.now();e.graphError=null;i();const o=e.graphFetchStartedAt+f;try{let n=null;let s="";for(const t of r){try{const a=await g(t,o-Date.now());if(Array.isArray(a)){n=a;break}s="Unexpected .assets payload shape"}catch(a){s=String(a?.message??a);if(Date.now()>=o)break}}if(!Array.isArray(n))throw new Error(s||"No graph endpoint answered");const c=n;let p=0;for(const t of c){if(!t||typeof t.name!=="string"||typeof t.type!=="string"){continue}const a=d({key:u(t.httpServerLocation,t.name,t.type),name:t.name,type:t.type,origin:"graph",hash:t.hash,httpServerLocation:t.httpServerLocation,width:t.width??void 0,height:t.height??void 0,scales:t.scales,fileSystemLocation:t.fileSystemLocation,files:t.files,fileHashes:t.fileHashes});if(a)p++}e.graphSupported=true;e.graphCount=p;e.graphError=null;i();return{ok:true,count:p}}catch(n){e.graphSupported=getDevServerOrigin()!=null;e.graphError=String(n?.message??n);i();return{ok:false,message:e.graphError}}finally{e.graphFetchInFlight=false;e.graphFetchStartedAt=null;i()}}
@@ -0,0 +1 @@
1
+ "use strict";export function markToolPreviewSource(e){}
@@ -0,0 +1 @@
1
+ "use strict";import{markBrowserToolImage as r}from"./browserAssets";export function markToolPreviewSource(o){if(o&&typeof o==="object")r(o.uri)}
@@ -1 +1 @@
1
- "use strict";import{ScrollView as h,StyleSheet as f,Text as u,View as r}from"react-native";import{night as o}from"@buoy-gg/shared-ui";import{AssetImage as g}from"./AssetImage";import{formatBytes as p,formatDimensions as b,formatScales as S}from"../format";import{estDecodedBytes as x}from"../store/assetStore";import{ASSETS_TEST_IDS as d,assetDetailRowTestID as w,assetFindingTestID as D}from"../utils/testIDs";import{jsx as t,jsxs as y}from"react/jsx-runtime";function i({label:e,value:n}){const l=w(e);return y(r,{style:s.kvRow,testID:l,children:[t(u,{style:s.kvLabel,children:e}),t(u,{style:s.kvValue,selectable:true,testID:`${l}-value`,children:n})]})}function I({record:e}){if(e.kind==="image"){return t(r,{style:s.previewBox,testID:d.detailPreview,children:t(g,{testID:"buoy-internal-assets-preview",record:e,style:s.previewImage})})}if(e.kind==="font"){return t(r,{style:s.previewBox,testID:d.detailFontPreview,children:t(u,{style:[s.fontPreview,{fontFamily:e.name}],children:"The quick brown fox jumps over the lazy dog 0123456789"})})}return null}export function AssetDetail({record:e,insights:n}){const l=[];if(n.neverLoaded.includes(e.id)){l.push("Not observed in the runtime registry this app run. This does not prove the asset is unused.")}if(n.scaleGaps.includes(e.id)){l.push("Scale gap \u2014 no variant covers this device's pixel ratio")}if(n.webpCandidates.includes(e.id)){l.push("WebP candidate \u2014 large png/jpeg, converting typically saves 20\u201340%")}const v=n.duplicates.find(a=>a.ids.includes(e.id));if(v){l.push(`Duplicate content \u2014 identical bytes shipped ${v.ids.length} times`)}if(n.overDecode.includes(e.id)){l.push("Decodes larger than 2\xD7 this entire screen \u2014 resize the source, no view can need this many pixels")}if(n.heavyGifs.includes(e.id)){l.push("Heavy GIF \u2014 every frame decodes into memory; a video or Lottie is typically ~90% smaller")}if(n.heavyFonts.includes(e.id)){l.push("Heavy font \u2014 likely an unsubset icon font; subsetting to used glyphs usually saves most of it")}if(n.scaleAnomalies.includes(e.id)){l.push("Scale anomaly \u2014 a higher-resolution variant is smaller in bytes than a lower one; check the exports")}const m=x(e);return y(h,{style:s.scroll,contentContainerStyle:s.content,testID:d.detailScroll,children:[t(I,{record:e}),l.length>0?t(r,{style:s.findings,testID:d.detailFindings,children:l.map((a,c)=>t(u,{style:s.findingText,testID:D(c),children:a},a))}):null,t(i,{label:"Name",value:`${e.name}.${e.type}`}),t(i,{label:"Kind",value:e.kind}),t(i,{label:"Status",value:e.loaded?"Loaded (registered at runtime)":"Not observed in the runtime registry"}),e.kind==="image"?t(i,{label:"Dimensions",value:`${b(e)} (logical)`}):null,e.kind==="image"&&e.scales.length?t(i,{label:"Scales",value:S(e.scales)}):null,e.sizesByScale?Object.entries(e.sizesByScale).map(([a,c])=>t(i,{label:`Size @${a}x`,value:p(c)},a)):null,e.sizeBytes!=null&&e.sizeSource==="measured"?t(i,{label:"Total size",value:p(e.sizeBytes)}):null,m>0?t(i,{label:"Decoded memory",value:`~${p(m)} (RGBA)`}):null,e.registryId!=null?t(i,{label:"Registry id",value:String(e.registryId)}):null,e.hash?t(i,{label:"Hash",value:e.hash}):null,e.httpServerLocation?t(i,{label:"Location",value:e.httpServerLocation}):null,e.fileSystemLocation?t(i,{label:"Source dir",value:e.fileSystemLocation}):null,e.resolvedUri?t(i,{label:"Resolved URI",value:e.resolvedUri}):null]})}const s=f.create({scroll:{flex:1},content:{padding:12,gap:8},previewBox:{borderRadius:8,backgroundColor:o.color.bg,padding:12,alignItems:"center",justifyContent:"center",minHeight:96},previewImage:{width:"100%",height:140},fontPreview:{color:o.color.text,fontSize:16,textAlign:"center"},findings:{borderRadius:8,borderWidth:1,borderColor:o.color.border,backgroundColor:o.color.surface,padding:10,gap:6},findingText:{color:o.color.textSecondary,fontSize:11,lineHeight:15},kvRow:{gap:2},kvLabel:{color:o.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,textTransform:"uppercase"},kvValue:{color:o.color.text,fontSize:12}});
1
+ "use strict";import{ScrollView as y,StyleSheet as f,Text as u,View as r}from"react-native";import{night as o}from"@buoy-gg/shared-ui";import{AssetImage as g}from"./AssetImage";import{formatBytes as d,formatDimensions as b,formatScales as S}from"../format";import{estDecodedBytes as w}from"../store/assetStore";import{ASSETS_TEST_IDS as c,assetDetailRowTestID as x,assetFindingTestID as D}from"../utils/testIDs";import{jsx as t,jsxs as m,Fragment as I}from"react/jsx-runtime";function l({label:e,value:n}){const i=x(e);return m(r,{style:a.kvRow,testID:i,children:[t(u,{style:a.kvLabel,children:e}),t(u,{style:a.kvValue,selectable:true,testID:`${i}-value`,children:n})]})}function k({record:e}){if(e.kind==="image"){return t(r,{style:a.previewBox,testID:c.detailPreview,children:t(g,{testID:"buoy-internal-assets-preview",record:e,style:a.previewImage})})}if(e.kind==="font"){return t(r,{style:a.previewBox,testID:c.detailFontPreview,children:t(u,{style:[a.fontPreview,{fontFamily:e.name}],children:"The quick brown fox jumps over the lazy dog 0123456789"})})}return null}export function AssetDetail({record:e,insights:n}){const i=[];if(n.neverLoaded.includes(e.id)){i.push("Not observed in the runtime registry this app run. This does not prove the asset is unused.")}if(n.scaleGaps.includes(e.id)){i.push("Scale gap \u2014 no variant covers this device's pixel ratio")}if(n.webpCandidates.includes(e.id)){i.push("WebP candidate \u2014 large png/jpeg, converting typically saves 20\u201340%")}const h=n.duplicates.find(s=>s.ids.includes(e.id));if(h){i.push(`Duplicate content \u2014 identical bytes shipped ${h.ids.length} times`)}if(n.overDecode.includes(e.id)){i.push("Decodes larger than 2\xD7 this entire screen \u2014 resize the source, no view can need this many pixels")}if(n.heavyGifs.includes(e.id)){i.push("Heavy GIF \u2014 every frame decodes into memory; a video or Lottie is typically ~90% smaller")}if(n.heavyFonts.includes(e.id)){i.push("Heavy font \u2014 likely an unsubset icon font; subsetting to used glyphs usually saves most of it")}if(n.scaleAnomalies.includes(e.id)){i.push("Scale anomaly \u2014 a higher-resolution variant is smaller in bytes than a lower one; check the exports")}const p=w(e);return m(y,{style:a.scroll,contentContainerStyle:a.content,testID:c.detailScroll,children:[t(k,{record:e}),i.length>0?t(r,{style:a.findings,testID:c.detailFindings,children:i.map((s,v)=>t(u,{style:a.findingText,testID:D(v),children:s},s))}):null,t(l,{label:"Name",value:`${e.name}.${e.type}`}),e.loadStatus&&m(I,{children:[t(l,{label:"Load",value:e.loadStatus==="error"?"Failed":"Loaded"}),t(l,{label:"Load time",value:e.durationMs==null?"Unknown":`${e.durationMs.toFixed(1)} ms`}),t(l,{label:"Load size",value:e.sizeBytes==null?"Unknown":d(e.sizeBytes)}),t(l,{label:"Cache",value:e.cacheHit==null?"Unknown":e.cacheHit?"Cache hit":"Web load"})]}),t(l,{label:"Kind",value:e.kind}),t(l,{label:"Status",value:e.loaded?"Loaded (registered at runtime)":"Not observed in the runtime registry"}),e.kind==="image"?t(l,{label:"Dimensions",value:`${b(e)} (logical)`}):null,e.kind==="image"&&e.scales.length?t(l,{label:"Scales",value:S(e.scales)}):null,e.sizesByScale?Object.entries(e.sizesByScale).map(([s,v])=>t(l,{label:`Size @${s}x`,value:d(v)},s)):null,e.sizeBytes!=null&&e.sizeSource==="measured"?t(l,{label:"Total size",value:d(e.sizeBytes)}):null,p>0?t(l,{label:"Decoded memory",value:`~${d(p)} (RGBA)`}):null,e.registryId!=null?t(l,{label:"Registry id",value:String(e.registryId)}):null,e.hash?t(l,{label:"Hash",value:e.hash}):null,e.httpServerLocation?t(l,{label:"Location",value:e.httpServerLocation}):null,e.fileSystemLocation?t(l,{label:"Source dir",value:e.fileSystemLocation}):null,e.resolvedUri?t(l,{label:"Resolved URI",value:e.resolvedUri}):null]})}const a=f.create({scroll:{flex:1},content:{padding:12,gap:8},previewBox:{borderRadius:8,backgroundColor:o.color.bg,padding:12,alignItems:"center",justifyContent:"center",minHeight:96},previewImage:{width:"100%",height:140},fontPreview:{color:o.color.text,fontSize:16,textAlign:"center"},findings:{borderRadius:8,borderWidth:1,borderColor:o.color.border,backgroundColor:o.color.surface,padding:10,gap:6},findingText:{color:o.color.textSecondary,fontSize:11,lineHeight:15},kvRow:{gap:2},kvLabel:{color:o.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.5,textTransform:"uppercase"},kvValue:{color:o.color.text,fontSize:12}});
@@ -1 +1 @@
1
- "use strict";import{useState as S}from"react";import{Image as g,Platform as u,StyleSheet as x,Text as v,View as I}from"react-native";import{night as w}from"@buoy-gg/shared-ui";import{displaySource as h}from"../capture/measure";import{getExpoPreviewImage as E}from"./optionalExpoImage";import{jsx as r}from"react/jsx-runtime";export function AssetImage({record:t,style:n,testID:a,compact:f=false}){const e=h(t);const o=t.type.toLowerCase()==="svg";const s=o&&u.OS!=="web"?E():null;const l=`${t.key}:${t.hash??""}:${typeof e==="number"?e:e?.uri??""}`;const[p,b]=S(null);const y=e==null||p===l||o&&u.OS!=="web"&&!s;if(y){const c=o?"SVG preview unavailable":"Image preview unavailable";return r(I,{style:[n,m.fallback],accessibilityLabel:c,testID:`${a}-unavailable`,children:r(v,{style:m.text,children:f?o?"SVG":"IMG":c})})}const i=()=>b(l);if(s){return r(s,{source:e,style:n,contentFit:"contain",onError:i,testID:a})}return r(g,{source:e,style:n,resizeMode:"contain",onError:i,testID:a})}const m=x.create({fallback:{alignItems:"center",justifyContent:"center"},text:{color:w.color.textSecondary,fontSize:10,textAlign:"center"}});
1
+ "use strict";import{useState as y}from"react";import{Image as g,Platform as u,StyleSheet as v,Text as x,View as w}from"react-native";import{night as I}from"@buoy-gg/shared-ui";import{displaySource as h}from"../capture/measure";import{markToolPreviewSource as E}from"../capture/toolPreview";import{getExpoPreviewImage as d}from"./optionalExpoImage";import{jsx as r}from"react/jsx-runtime";export function AssetImage({record:t,style:n,testID:a,compact:f=false}){const e=h(t);E(e);const o=t.type.toLowerCase()==="svg";const i=o&&u.OS!=="web"?d():null;const l=`${t.key}:${t.hash??""}:${typeof e==="number"?e:e?.uri??""}`;const[p,S]=y(null);const b=e==null||p===l||o&&u.OS!=="web"&&!i;if(b){const c=o?"SVG preview unavailable":"Image preview unavailable";return r(w,{style:[n,m.fallback],accessibilityLabel:c,testID:`${a}-unavailable`,children:r(x,{style:m.text,children:f?o?"SVG":"IMG":c})})}const s=()=>S(l);if(i){return r(i,{source:e,style:n,contentFit:"contain",onError:s,testID:a})}return r(g,{source:e,style:n,resizeMode:"contain",onError:s,testID:a})}const m=v.create({fallback:{alignItems:"center",justifyContent:"center"},text:{color:I.color.textSecondary,fontSize:10,textAlign:"center"}});
@@ -1 +1 @@
1
- "use strict";export{assetsToolPreset,createAssetsTool}from"./preset";export{AssetsModal,AssetsToolView}from"./components/AssetsModal";export{AssetsIcon,ASSETS_ICON_COLOR}from"./components/AssetsIcon";export{installAssetCapture,rescan,getScanStatus}from"./capture/install";export{measureSizes}from"./capture/measure";export{fetchAssetGraph,getDevServerOrigin}from"./capture/metroGraph";export{getLoadedFontFamilies,getLocalAssets}from"./capture/expo";export{clearRecords,computeStats,estDecodedBytes,getRecord,getSnapshot,subscribe}from"./store/assetStore";export{computeInsights}from"./store/insights";export{clearBaseline,computeDiff,getDiff,loadBaseline,saveBaseline}from"./store/baseline";export{useAssetRecords}from"./hooks/useAssetRecords";export{formatAssetMarkdown,formatInventoryMarkdown}from"./export";export{assetsSyncAdapter}from"./sync/assetsSyncAdapter";export{disableAssetsCapture,replaceAssetsFromSnapshot,setRemoteAssetsHandler}from"./remote";export{ASSETS_TEST_IDS,assetBadgeTestID,assetDetailRowTestID,assetFilterTestID,assetFindingTestID,assetFontChipTestID,assetRowTestID,assetSlug}from"./utils/testIDs";import"./autoCapture";export{registerBrowserAssetManifest,loadBrowserAssetManifest,getBrowserAssetManifest}from"./capture/browserAssets";export{startBrowserAssetCapture}from"./capture/assetLifecycle";
1
+ "use strict";export{assetsToolPreset,createAssetsTool}from"./preset";export{AssetsModal,AssetsToolView}from"./components/AssetsModal";export{AssetsIcon,ASSETS_ICON_COLOR}from"./components/AssetsIcon";export{installAssetCapture,rescan,getScanStatus}from"./capture/install";export{measureSizes}from"./capture/measure";export{fetchAssetGraph,getDevServerOrigin}from"./capture/metroGraph";export{getLoadedFontFamilies,getLocalAssets}from"./capture/expo";export{clearRecords,computeStats,estDecodedBytes,getRecord,getSnapshot,subscribe}from"./store/assetStore";export{computeInsights}from"./store/insights";export{clearBaseline,computeDiff,getDiff,loadBaseline,saveBaseline}from"./store/baseline";export{useAssetRecords}from"./hooks/useAssetRecords";export{formatAssetMarkdown,formatInventoryMarkdown}from"./export";export{assetsSyncAdapter}from"./sync/assetsSyncAdapter";export{disableAssetsCapture,replaceAssetsFromSnapshot,setRemoteAssetsHandler}from"./remote";export{ASSETS_TEST_IDS,assetBadgeTestID,assetDetailRowTestID,assetFilterTestID,assetFindingTestID,assetFontChipTestID,assetRowTestID,assetSlug}from"./utils/testIDs";import"./autoCapture";export{registerBrowserAssetManifest,loadBrowserAssetManifest,getBrowserAssetManifest}from"./capture/browserAssets";export{startBrowserAssetCapture}from"./capture/assetLifecycle";export{recordBrowserAssetLoad}from"./capture/browserAssets";
@@ -1 +1 @@
1
- "use strict";import{assetsState as s}from"./state";import{invalidate as r}from"./store/assetStore";export function setRemoteAssetsHandler(i){s().remoteDispatch=i}export function remoteAssetsDispatch(){return s().remoteDispatch}export function disableAssetsCapture(){s().captureDisabled=true}export function replaceAssetsFromSnapshot(i){const t=s();const n=i.records??[];t.records=n.map(e=>({id:e.id,key:e.key,registryId:e.registryId??void 0,name:e.name,type:e.type,kind:e.kind,hash:e.hash??void 0,httpServerLocation:e.location??void 0,width:e.width??void 0,height:e.height??void 0,scales:e.scales,resolvedUri:e.uri??void 0,loaded:e.loaded,origin:e.registryId!=null?"registry":"graph",sizeBytes:e.sizeBytes??void 0,sizeSource:e.sizeSource??void 0,firstSeenAt:Date.now()}));t.byKey=new Map(t.records.map(e=>[e.key,e]));t.byId=new Map(t.records.map(e=>[e.id,e]));if(i.scanStatus){t.fontFamilies=[...new Set(i.scanStatus.fontFamilies??[])];t.mirrorScanStatus={...i.scanStatus,fontFamilies:t.fontFamilies}}t.mirrorDiff=i.diff??null;r()}
1
+ "use strict";import{isBuoyAsset as n}from"./capture/isBuoyAsset";import{assetsState as s}from"./state";import{invalidate as o}from"./store/assetStore";export function setRemoteAssetsHandler(i){s().remoteDispatch=i}export function remoteAssetsDispatch(){return s().remoteDispatch}export function disableAssetsCapture(){s().captureDisabled=true}export function replaceAssetsFromSnapshot(i){const t=s();const r=i.records??[];t.records=r.map(e=>({id:e.id,key:e.key,loadStatus:e.loadStatus,durationMs:e.durationMs,cacheHit:e.cacheHit,registryId:e.registryId??void 0,name:e.name,type:e.type,kind:e.kind,hash:e.hash??void 0,httpServerLocation:e.location??void 0,width:e.width??void 0,height:e.height??void 0,scales:e.scales,resolvedUri:e.uri??void 0,loaded:e.loaded,origin:e.registryId!=null?"registry":"graph",sizeBytes:e.sizeBytes??void 0,sizeSource:e.sizeSource??void 0,firstSeenAt:Date.now()})).filter(e=>!n(e));t.byKey=new Map(t.records.map(e=>[e.key,e]));t.byId=new Map(t.records.map(e=>[e.id,e]));if(i.scanStatus){t.fontFamilies=[...new Set(i.scanStatus.fontFamilies??[])];t.mirrorScanStatus={...i.scanStatus,fontFamilies:t.fontFamilies}}t.mirrorDiff=i.diff??null;o()}
@@ -1 +1 @@
1
- "use strict";import{getScanStatus as o,rescan as f}from"../capture/install";import{measureSizes as y}from"../capture/measure";import{clearRecords as h,computeStats as g,estDecodedBytes as i,getRecord as S,getSnapshot as p,subscribe as k}from"../store/assetStore";import{clearBaseline as w,getDiff as l,saveBaseline as B}from"../store/baseline";import{computeInsights as z}from"../store/insights";const u=["image","font","video","audio","data","other"];function a(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 v(e){const t=e?.id;if(typeof t!=="number")throw new Error("Missing numeric `id` param");const n=S(t);if(!n){throw new Error(`Asset record ${t} not found \u2014 re-run the list action for current ids.`)}return n}function b(e,t){return(t.sizeBytes??i(t))-(e.sizeBytes??i(e))}function c(){const e=p();return{stats:g(e),scanStatus:o(),insights:z(e),diff:l(),records:[...e].sort(b)}}export const assetsSyncAdapter={version:1,getSnapshot:()=>{const{records:e,...t}=c();return{...t,records:e.slice(0,200).map(a)}},subscribe:e=>k(e),actions:{list:e=>{const t=e??{};const n=Math.min(Math.max(t.limit??50,1),500);const{records:d,...m}=c();let s=d;if(t.kind){if(!u.includes(t.kind)){throw new Error(`kind must be one of: ${u.join(", ")}`)}s=s.filter(r=>r.kind===t.kind)}if(t.loadedOnly)s=s.filter(r=>r.loaded);return{...m,total:s.length,records:s.slice(0,n).map(a)}},getDetail:e=>{const t=v(e);return{...a(t),origin:t.origin,fileSystemLocation:t.fileSystemLocation??null,files:t.files??null,sizesByScale:t.sizesByScale??null,estDecodedBytes:i(t)||null}},rescan:async()=>{const e=await f();return{ok:true,scanStatus:e}},measureSizes:async()=>{const e=await y();return{ok:e.measured>0,...e}},saveBaseline:async()=>{const e=await B();return{ok:true,savedAt:e.savedAt,assets:Object.keys(e.entries).length}},clearBaseline:async()=>{await w();return{ok:true,message:"Baseline cleared"}},getDiff:()=>l(),clearRecords:()=>{h();return{ok:true,message:"Inventory cleared \u2014 rescan to rebuild"}},getScanStatus:()=>o()}};
1
+ "use strict";import{getScanStatus as o,rescan as f}from"../capture/install";import{measureSizes as h}from"../capture/measure";import{clearRecords as y,computeStats as S,estDecodedBytes as n,getRecord as g,getSnapshot as p,subscribe as k}from"../store/assetStore";import{clearBaseline as w,getDiff as l,saveBaseline as B}from"../store/baseline";import{computeInsights as z}from"../store/insights";const u=["image","font","video","audio","data","other"];function r(e){return{loadStatus:e.loadStatus,durationMs:e.durationMs,cacheHit:e.cacheHit,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:n(e)||null,sizeSource:e.sizeSource??null}}function v(e){const t=e?.id;if(typeof t!=="number")throw new Error("Missing numeric `id` param");const i=g(t);if(!i){throw new Error(`Asset record ${t} not found \u2014 re-run the list action for current ids.`)}return i}function b(e,t){return(t.sizeBytes??n(t))-(e.sizeBytes??n(e))}function c(){const e=p();return{stats:S(e),scanStatus:o(),insights:z(e),diff:l(),records:[...e].sort(b)}}export const assetsSyncAdapter={version:1,getSnapshot:()=>{const{records:e,...t}=c();return{...t,records:e.slice(0,200).map(r)}},subscribe:e=>k(e),actions:{list:e=>{const t=e??{};const i=Math.min(Math.max(t.limit??50,1),500);const{records:d,...m}=c();let s=d;if(t.kind){if(!u.includes(t.kind)){throw new Error(`kind must be one of: ${u.join(", ")}`)}s=s.filter(a=>a.kind===t.kind)}if(t.loadedOnly)s=s.filter(a=>a.loaded);return{...m,total:s.length,records:s.slice(0,i).map(r)}},getDetail:e=>{const t=v(e);return{...r(t),origin:t.origin,fileSystemLocation:t.fileSystemLocation??null,files:t.files??null,sizesByScale:t.sizesByScale??null,estDecodedBytes:n(t)||null}},rescan:async()=>{const e=await f();return{ok:true,scanStatus:e}},measureSizes:async()=>{const e=await h();return{ok:e.measured>0,...e}},saveBaseline:async()=>{const e=await B();return{ok:true,savedAt:e.savedAt,assets:Object.keys(e.entries).length}},clearBaseline:async()=>{await w();return{ok:true,message:"Baseline cleared"}},getDiff:()=>l(),clearRecords:()=>{y();return{ok:true,message:"Inventory cleared \u2014 rescan to rebuild"}},getScanStatus:()=>o()}};
@@ -5,9 +5,19 @@ export interface BrowserAsset {
5
5
  width?: number;
6
6
  height?: number;
7
7
  }
8
+ export declare function markBrowserToolImage(url: string): void;
8
9
  export declare function registerBrowserAssetManifest(assets: readonly BrowserAsset[]): void;
9
10
  export declare function getBrowserAssetManifest(): readonly BrowserAsset[];
10
11
  export declare function loadBrowserAssetManifest(url: string): Promise<void>;
11
12
  export declare function captureBrowserResource(entry: PerformanceResourceTiming): void;
13
+ export declare function captureBrowserImage(image: HTMLImageElement): void;
12
14
  export declare function scanBrowserAssets(): void;
15
+ /** Record a loader result with browser timing, when it is known. */
16
+ export declare function recordBrowserAssetLoad(load: {
17
+ url: string;
18
+ status: 'success' | 'error';
19
+ bytes: number | null;
20
+ durationMs: number | null;
21
+ cacheHit: boolean | null;
22
+ }): void;
13
23
  //# sourceMappingURL=browserAssets.d.ts.map
@@ -1,9 +1,10 @@
1
- /** Identify Buoy-owned resources by package location, never by asset name. */
2
- export declare function isBuoyAssetPath(value: string | undefined): boolean;
1
+ import { isBuoyAssetPath } from "@buoy-gg/shared-ui";
2
+ export { isBuoyAssetPath };
3
3
  export declare function isBuoyAsset(asset: {
4
4
  key: string;
5
5
  httpServerLocation?: string;
6
6
  fileSystemLocation?: string;
7
+ resolvedUri?: string;
7
8
  files?: string[];
8
9
  }): boolean;
9
10
  //# sourceMappingURL=isBuoyAsset.d.ts.map
@@ -1,16 +1,3 @@
1
- /**
2
- * Metro dev-server graph fetch.
3
- *
4
- * The dev server serves `<entry>.assets` next to `<entry>.bundle` — the full
5
- * dependency graph's AssetData[], INCLUDING assets never required at runtime
6
- * and the `fileSystemLocation`/`files` fields Metro strips from runtime
7
- * records. Deriving the URL by swapping `.bundle` → `.assets` on the running
8
- * bundle's scriptURL keeps the entry path and platform/dev query params
9
- * intact for both RN CLI (index.bundle) and Expo (…/entry.bundle) layouts.
10
- *
11
- * Graph-only records (in the graph, not the registry) are exactly the
12
- * "shipped but never loaded" set. Dev-only: no server, no graph.
13
- */
14
1
  export declare function getScriptURL(): string | null;
15
2
  /** http(s) origin of the Metro dev server, or null when running embedded. */
16
3
  export declare function getDevServerOrigin(): string | null;
@@ -0,0 +1,4 @@
1
+ export declare function markToolPreviewSource(_source: number | {
2
+ uri: string;
3
+ } | null): void;
4
+ //# sourceMappingURL=toolPreview.d.ts.map
@@ -0,0 +1,4 @@
1
+ export declare function markToolPreviewSource(source: number | {
2
+ uri: string;
3
+ } | null): void;
4
+ //# sourceMappingURL=toolPreview.web.d.ts.map
@@ -27,4 +27,5 @@ export type { AssetKind, AssetOrigin, AssetRecord, AssetRecordWire, AssetsBaseli
27
27
  import "./autoCapture";
28
28
  export { registerBrowserAssetManifest, loadBrowserAssetManifest, getBrowserAssetManifest, type BrowserAsset } from "./capture/browserAssets";
29
29
  export { startBrowserAssetCapture } from "./capture/assetLifecycle";
30
+ export { recordBrowserAssetLoad } from "./capture/browserAssets";
30
31
  //# sourceMappingURL=index.d.ts.map
@@ -1,11 +1,3 @@
1
- /**
2
- * Remote-dispatch seam for dashboard mirrors (Buoy Desktop).
3
- *
4
- * On device this stays null and every action runs locally. A dashboard sets
5
- * a handler that forwards action name + params over external-sync to the
6
- * SAME adapter actions the MCP uses (sync/assetsSyncAdapter.ts), so one
7
- * action vocabulary serves phone UI, desktop UI, and LLM automation.
8
- */
9
1
  import type { AssetsSnapshotPayload } from "./types";
10
2
  export type AssetsRemoteDispatch = (action: string, params?: Record<string, unknown>) => Promise<unknown>;
11
3
  export declare function setRemoteAssetsHandler(handler: AssetsRemoteDispatch | null): void;
@@ -32,6 +32,9 @@ export declare const assetsSyncAdapter: {
32
32
  files: string[] | null;
33
33
  sizesByScale: Record<string, number> | null;
34
34
  estDecodedBytes: number | null;
35
+ loadStatus?: "success" | "error";
36
+ durationMs?: number | null;
37
+ cacheHit?: boolean | null;
35
38
  id: number;
36
39
  key: string;
37
40
  registryId: number | null;
@@ -15,6 +15,9 @@
15
15
  export type AssetKind = "image" | "font" | "video" | "audio" | "data" | "other";
16
16
  export type AssetOrigin = "registry" | "graph" | "browser";
17
17
  export interface AssetRecord {
18
+ loadStatus?: "success" | "error";
19
+ durationMs?: number | null;
20
+ cacheHit?: boolean | null;
18
21
  id: number;
19
22
  /** Stable identity across sources: `${httpServerLocation}/${name}.${type}`. */
20
23
  key: string;
@@ -139,6 +142,9 @@ export interface AssetsDiff {
139
142
  }
140
143
  /** Slim wire form of a record (desktop dashboard + MCP). */
141
144
  export interface AssetRecordWire {
145
+ loadStatus?: "success" | "error";
146
+ durationMs?: number | null;
147
+ cacheHit?: boolean | null;
142
148
  id: number;
143
149
  key: string;
144
150
  registryId: number | null;
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 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
- `)}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 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};
1
+ "use client";var ze=Object.defineProperty;var us=Object.getOwnPropertyDescriptor;var hs=Object.getOwnPropertyNames;var ps=Object.prototype.hasOwnProperty;var le=(e,t)=>()=>(e&&(t=e(e=0)),t);var fs=(e,t)=>{for(var s in t)ze(e,s,{get:t[s],enumerable:true})},Be=(e,t,s,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of hs(t))!ps.call(e,n)&&n!==s&&ze(e,n,{get:()=>t[n],enumerable:!(a=us(t,n))||a.enumerable});return e},ys=(e,t,s)=>(Be(e,t,"default"),s&&Be(s,t,"default"));var rt=e=>Be(ze({},"__esModule",{value:true}),e);var ms,u=le(()=>{"use strict";ms=(()=>{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 ot,gs=le(()=>{"use strict";u();ot='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'});import{useEffect as bs,useState as vs}from"react";import{createPortal as Ss}from"react-dom";import{jsx as ws}from"react/jsx-runtime";function it(){let e=document;if(e[J])return e[J].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:ot});let s=()=>{let i=document.fullscreenElement,y=i&&i.tagName!=="CANVAS"?i:document.body;t.parentElement!==y&&y.appendChild(t)},a=new Map,n=i=>{(!t.contains(i.target)||!Ie(i.target))&&a.set(i.code||i.key,{key:i.key,code:i.code,location:i.location,keyCode:i.keyCode,which:i.which,altKey:i.altKey,ctrlKey:i.ctrlKey,metaKey:i.metaKey,shiftKey:i.shiftKey})},r=i=>{a.delete(i.code||i.key)},o=()=>a.clear(),l=()=>{let i=[...a.values()];a.clear();for(let y of i)document.dispatchEvent(new KeyboardEvent("keyup",{...y,bubbles:true}))},d=i=>{Ie(i.target)&&i.stopPropagation()},c=i=>i.stopPropagation();return s(),document.addEventListener("fullscreenchange",s),document.addEventListener("keydown",n,true),document.addEventListener("keyup",r,true),window.addEventListener("blur",o),t.addEventListener("focusin",l),t.addEventListener("keydown",d),t.addEventListener("keyup",d),t.addEventListener("keypress",d),t.addEventListener("wheel",c,{passive:true}),e[J]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",s),document.removeEventListener("keydown",n,true),document.removeEventListener("keyup",r,true),window.removeEventListener("blur",o),t.remove(),delete e[J]}},t}function xs({children:e}){let[t,s]=vs(null);return bs(()=>{let a=it(),n=document[J];return n.users++,s(a),()=>{--n.users===0&&n.dispose()}},[]),t?Ss(ws("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var J,Ie,Cs=le(()=>{"use strict";u();gs();J=Symbol.for("@buoy-gg/portal-host"),Ie=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"}});var de={};fs(de,{AccessibilityInfo:()=>Is,ActivityIndicator:()=>Le,Alert:()=>bt,Animated:()=>Ds,AppRegistry:()=>As,AppState:()=>Fs,Appearance:()=>$s,BackHandler:()=>Ls,Button:()=>mt,CheckBox:()=>_s,Clipboard:()=>Es,DeviceEventEmitter:()=>ia,Dimensions:()=>Ts,Easing:()=>Rs,FlatList:()=>lt,I18nManager:()=>Ms,Image:()=>dt,ImageBackground:()=>qs,InteractionManager:()=>Os,Keyboard:()=>Ps,KeyboardAvoidingView:()=>Js,LayoutAnimation:()=>js,Linking:()=>Hs,LogBox:()=>oa,Modal:()=>ft,NativeEventEmitter:()=>Ns,NativeModules:()=>Bs,PanResponder:()=>Vs,Picker:()=>Ys,PixelRatio:()=>Ws,Platform:()=>ce,Pressable:()=>pt,ProgressBar:()=>Qs,RefreshControl:()=>Zs,SafeAreaView:()=>Xs,ScrollView:()=>Ae,SectionList:()=>ea,Share:()=>Us,StatusBar:()=>ta,StyleSheet:()=>P,Switch:()=>yt,Text:()=>b,TextInput:()=>$e,Touchable:()=>sa,TouchableHighlight:()=>ut,TouchableNativeFeedback:()=>aa,TouchableOpacity:()=>N,TouchableWithoutFeedback:()=>ht,UIManager:()=>Ks,Vibration:()=>Gs,View:()=>m,VirtualizedList:()=>na,YellowBox:()=>ra,findNodeHandle:()=>gt,unstable_createElement:()=>zs,useColorScheme:()=>la,useLocaleContext:()=>da,useWindowDimensions:()=>ca});import*as ks from"react-native-web";import{unstable_createElement as zs,NativeModules as Bs,AccessibilityInfo as Is,Animated as Ds,Appearance as $s,AppRegistry as As,AppState as Fs,BackHandler as Ls,Clipboard as Es,Dimensions as Ts,Easing as Rs,I18nManager as Ms,Keyboard as Ps,InteractionManager as Os,LayoutAnimation as js,Linking as Hs,NativeEventEmitter as Ns,PanResponder as Vs,PixelRatio as Ws,Platform as ce,Share as Us,StyleSheet as P,UIManager as Ks,Vibration as Gs,CheckBox as _s,FlatList as lt,Image as dt,ImageBackground as qs,KeyboardAvoidingView as Js,Picker as Ys,ProgressBar as Qs,RefreshControl as Zs,SafeAreaView as Xs,SectionList as ea,StatusBar as ta,Touchable as sa,TouchableNativeFeedback as aa,VirtualizedList as na,YellowBox as ra,LogBox as oa,DeviceEventEmitter as ia,useColorScheme as la,useLocaleContext as da,useWindowDimensions as ca}from"react-native-web";import*as B from"react-native-web";import{createElement as De,forwardRef as ct,useCallback as ua,useRef as ha}from"react";function $(e){let t=ct((a,n)=>{let{accessibilityState:r,accessibilityValue:o,...l}=a;for(let d of["busy","checked","disabled","expanded","selected"])r?.[d]!==void 0&&l[`aria-${d}`]===void 0&&(l[`aria-${d}`]=r[d]);for(let[d,c]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))o?.[d]!==void 0&&l[`aria-${c}`]===void 0&&(l[`aria-${c}`]=o[d]);return De(e,{...l,ref:n})}),s=e.State;return s&&Object.assign(t,{State:s}),t.displayName=e.displayName??e.name??"NativeWebView",t}var m,b,$e,N,ut,ht,pt,Ae,Fe,ft,yt,Le,mt,gt,bt,T=le(()=>{u();ys(de,ks);Cs();m=$(B.View),b=$(B.Text),$e=$(B.TextInput),N=$(B.TouchableOpacity),ut=$(B.TouchableHighlight),ht=$(B.TouchableWithoutFeedback),pt=$(B.Pressable),Ae=$(B.ScrollView),Fe=ct((e,t)=>{let s=ha(null),a=ua(n=>{if(n){let r=n;for(;r.parentElement&&r.parentElement!==document.body;)r=r.parentElement;r.parentElement===document.body&&(s.current=r,Object.assign(r.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),it().appendChild(r))}else s.current&&(document.body.appendChild(s.current),s.current=null);typeof t=="function"?t(n):t&&(t.current=n)},[t]);return De(xs,null,De(B.Modal,{...e,ref:a}))});Fe.displayName="Modal";ft=$(Fe),yt=$(B.Switch),Le=$(B.ActivityIndicator),mt=$(B.Button),gt=B.findNodeHandle,bt={alert(e,t,s,a){if(typeof document>"u")return;let n=document.createElement("dialog");n.dataset.buoyRoot="",n.setAttribute("aria-label",e),n.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let 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 o=document.createElement("div");o.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let l=s?.length?s:[{text:"OK"}],d=()=>{n.close?.(),n.remove()};for(let c of l){let i=document.createElement("button");i.type="button",i.textContent=c.text??"OK",i.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${c.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,i.onclick=()=>{d(),c.onPress?.()},o.appendChild(i)}n.addEventListener("cancel",c=>{c.preventDefault(),a?.cancelable!==false&&(d(),a?.onDismiss?.())}),n.appendChild(o),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}}});u();u();u();import{AssetsIcon as vt,ASSETS_ICON_COLOR as St}from"@buoy-gg/shared-ui/web";u();T();import{useEffect as wt,useState as ae}from"react";import{EventStepperFooter as pa,JsModal as fa,macOSColors as ya,night as R,windowDragProps as ma,ToolEmptyState as ga}from"@buoy-gg/shared-ui/web";u();u();var Ee=Symbol.for("buoy.assets.globalState.v1");function f(){let e=globalThis;return e[Ee]||(e[Ee]={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[Ee]}u();u();import{isBuoyAssetPath as xt}from"@buoy-gg/shared-ui/web";function Ct(e){return[e.key,e.resolvedUri,e.httpServerLocation,e.fileSystemLocation,...e.files??[]].some(xt)}u();function kt(){let e=f().mirrorPixelRatio;if(e!=null)return e;try{return(T(),rt(de)).PixelRatio.get()}catch{return 2}}function ba(e,t){if(!e.length)return 1;let s=[...e].sort((a,n)=>a-n);for(let a of s)if(a>=t)return a;return s[s.length-1]}function va(){let e=f();e.emitScheduled||(e.emitScheduled=true,requestAnimationFrame(()=>{e.emitScheduled=false;for(let t of e.listeners)t()}))}function A(){let e=f();e.snapshot=[...e.records],va()}var Sa={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 wa(e){return Sa[e.toLowerCase()]??"other"}function xa(e){if(Ct(e))return;let t=f(),s=t.byKey.get(e.key);return s||(s={id:t.nextId++,key:e.key,name:e.name,type:e.type,kind:wa(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,n)=>a-n)),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 ne(e,t){let s=f().byId.get(e);if(s)return Object.assign(s,t),A(),s}function Te(e){return f().byId.get(e)}function F(){return f().snapshot}function ue(e){return f().listeners.add(e),()=>f().listeners.delete(e)}function Re(){let e=f();e.records=[],e.byKey=new Map,e.byId=new Map,e.measuredCount=0,e.graphCount=null,A()}function C(e){if(e.kind!=="image"||!e.width||!e.height)return 0;let t=e.resolvedScale??ba(e.scales,kt());return Math.round(e.width*t*e.height*t*4)}function Me(e){let t=f(),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 n of e)n.loaded?a.loaded++:a.neverLoaded++,s[n.kind].count++,n.sizeBytes!=null&&n.sizeSource==="measured"&&(s[n.kind].bytes+=n.sizeBytes,a.totalBytes+=n.sizeBytes,a.measuredCount++);return a}u();import{buoyFetch as Ca,isBuoyElement as zt,isBuoyAssetPath as ka}from"@buoy-gg/shared-ui/web";var Y=[],Q=new Set;function za(e){if(!(typeof document>"u"))try{Q.add(new URL(e,document.baseURI).href)}catch{}}function Pe(e=document){let t=Array.from(e.querySelectorAll("img"));for(let s of Array.from(e.querySelectorAll("*")))s.shadowRoot&&t.push(...Pe(s.shadowRoot));return t}function Bt(e){Y=e.filter(t=>!ka(t.url)),typeof document<"u"&&pe()}function It(){return Y}async function Ba(e){let t=await Ca(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.");Bt(s)}function he(e,t){let s;try{s=new URL(e.url,document.baseURI)}catch{return}let a=s.pathname.split("/").pop()??"",n=a.includes(".")?a.split(".").pop().toLowerCase():"other",r=xa({key:s.href,name:a.slice(0,-(n.length+1))||a,type:n,origin:t?"browser":"graph",resolvedUri:s.href,resolvedScale:1,scales:[1],hash:e.hash,loaded:t,width:e.width,height:e.height});return r&&e.bytes!==void 0&&e.bytes>=0&&ne(r.id,{sizeBytes:e.bytes,sizesByScale:{1:e.bytes},sizeSource:"measured"}),r}function Dt(e){if(!(e.initiatorType==="fetch"||e.initiatorType==="xmlhttprequest")){if(e.initiatorType==="img"){let t=Pe().filter(s=>(s.currentSrc||s.src)===e.name);t.length&&(t.every(zt)?Q.add(e.name):Q.delete(e.name))}Q.has(e.name)||he({url:e.name,bytes:e.encodedBodySize>0?e.encodedBodySize:void 0},true)}}function $t(e){if(f().captureDisabled)return;let t=e.currentSrc||e.src;if(zt(e)){t&&Q.add(t);return}Q.delete(t),!(!t||!e.complete||e.naturalWidth<=0)&&he({url:t,width:e.naturalWidth,height:e.naturalHeight},true)}function pe(){if(typeof document>"u"||f().captureDisabled)return;Y.forEach(t=>he(t,false)),performance.getEntriesByType("resource").forEach(t=>Dt(t)),Pe().forEach($t);let e=f();e.graphSupported=Y.length>0,e.graphCount=Y.length>0?Y.length:null,e.measuredCount=e.records.filter(t=>t.sizeBytes!==void 0).length,e.lastScanAt=Date.now()}function Ia(e){if(typeof document>"u"||f().captureDisabled)return;let t=he({url:e.url,bytes:e.bytes??void 0},e.status==="success");t&&ne(t.id,{loadStatus:e.status,durationMs:e.durationMs,cacheHit:e.cacheHit})}u();function Oe(){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 Da(){return null}var Z,At=e=>{let t=e.target;t?.tagName==="IMG"&&$t(t)};function fe(){let e=f();if(!(typeof document>"u"||e.captureDisabled||e.installed)){if(e.installed=true,e.registryAvailable=true,document.addEventListener("load",At,true),typeof PerformanceObserver<"u"){Z=new PerformanceObserver(t=>{if(f().captureDisabled){Ft();return}t.getEntries().forEach(s=>Dt(s))});try{Z.observe({type:"resource",buffered:true}),e.patched=true}catch{Z.disconnect(),Z=void 0}}pe(),e.fontFamilies=Oe(),A()}}function Ft(){Z?.disconnect(),Z=void 0,typeof document<"u"&&document.removeEventListener("load",At,true),f().installed=false,f().patched=false}async function ye(){return fe(),pe(),f().fontFamilies=Oe(),A(),X()}function X(){let e=f();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}}u();u();function I(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 me(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 ge(e){return e.width==null||e.height==null?"\u2014":`${Math.round(e.width)}\xD7${Math.round(e.height)}`}function $a(e,t){return e.sizeBytes!=null&&e.sizeSource==="measured"?I(e.sizeBytes):t>0?`~${I(t)}`:"\u2014"}var Lt={image:"IMG",font:"FONT",video:"VID",audio:"AUD",data:"DATA",other:"MISC"},Et={image:"#2DD4BF",font:"#C084FC",video:"#FF9F1C",audio:"#FF3366",data:"#00D4FF",other:"#8E8E93"};function Tt(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: ${ge(e)} (logical)`),e.scales.length&&t.push(`- Scales: ${me(e.scales)}`),e.sizeBytes!=null&&e.sizeSource==="measured"&&t.push(`- Size (all variants): ${I(e.sizeBytes)}`);let s=C(e);return s>0&&t.push(`- Decoded memory: ~${I(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
+ `)}function Rt(e,t,s,a,n){let r=["# Asset inventory","",`${t.total} assets \xB7 ${t.loaded} loaded \xB7 ${t.neverLoaded} not observed`+(t.totalBytes>0?` \xB7 ${I(t.totalBytes)} measured (${t.measuredCount}/${t.total})`:"")];if(a.fontFamilies.length&&r.push(`Fonts loaded: ${a.fontFamilies.join(", ")}`),a.graphSupported||r.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)._"),n){let l=n.netBytes!=null?`${n.netBytes>=0?"+":"\u2212"}${I(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 d of n.removed.slice(0,20))r.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&&r.push("","## Findings",...o),r.push("","## Assets (largest first)","","| Asset | Kind | Dimensions | Scales | Size | Loaded |","| --- | --- | --- | --- | --- | --- |");for(let l of e){let d=l.sizeBytes!=null&&l.sizeSource==="measured"?I(l.sizeBytes):C(l)>0?`~${I(C(l))}`:"\u2014";r.push(`| ${l.name}.${l.type} | ${l.kind} | ${l.kind==="image"?ge(l):"\u2014"} | ${me(l.scales)} | ${d} | ${l.loaded?"yes":"NO"} |`)}return r.join(`
3
+ `)}u();import{useMemo as Aa,useSyncExternalStore as Fa}from"react";u();var La=50*1024,Ea=100*1024,Ta=150*1024,Ra=2,Ma=.9,Pa=4*1024;function Oa(){try{let{Dimensions:e,PixelRatio:t}=(T(),rt(de)),s=e.get("screen"),a=t.get();return s.width*a*s.height*a}catch{return 1170*2532}}function ja(e){let t=e.sizesByScale;if(!t)return false;let s=Object.entries(t).map(([a,n])=>({scale:Number(a),bytes:n})).filter(a=>Number.isFinite(a.scale)&&a.bytes>0).sort((a,n)=>a.scale-n.scale);for(let a=1;a<s.length;a++)if(s[a-1].bytes>=Pa&&s[a].bytes<s[a-1].bytes*Ma)return true;return false}function je(e){let t=kt(),s=new Map;for(let p of e){if(!p.hash)continue;let D=s.get(p.hash);D?D.push(p):s.set(p.hash,[p])}let a=[];for(let[p,D]of s){if(D.length<2)continue;let G=D.find(k=>k.sizeBytes!=null);a.push({hash:p,ids:D.map(k=>k.id),wastedBytes:G?.sizeBytes!=null?G.sizeBytes*(D.length-1):null})}let n=Oa(),r=[],o=[],l=[],d=[],c=[],i=[],y=[];for(let p of e)p.loaded||l.push(p.id),p.kind==="image"&&p.scales.length>1&&!p.scales.some(D=>D>=t)&&r.push(p.id),(p.type==="png"||p.type==="jpg"||p.type==="jpeg")&&p.sizeBytes!=null&&p.sizeBytes>=La&&o.push(p.id),p.kind==="image"&&C(p)/4>n*Ra&&d.push(p.id),p.type==="gif"&&(p.sizeBytes??0)>=Ea&&c.push(p.id),p.kind==="font"&&(p.sizeBytes??0)>=Ta&&i.push(p.id),ja(p)&&y.push(p.id);return{duplicates:a,scaleGaps:r,webpCandidates:o,neverLoaded:l,overDecode:d,heavyGifs:c,heavyFonts:i,scaleAnomalies:y}}function Mt(){let e=Fa(ue,F,F);return Aa(()=>({records:e,stats:Me(e),insights:je(e)}),[e])}u();import{useSyncExternalStore as Ha}from"react";var Pt,Ot;function jt(){let e=F();return e!==Pt&&(Pt=e,Ot=X()),Ot}function Na(){return Ha(ue,jt,jt)}u();function Va(e){f().remoteDispatch=e}function be(){return f().remoteDispatch}function Wa(){f().captureDisabled=true}function Ua(e){let t=f(),s=e.records??[];t.records=s.map(a=>({id:a.id,key:a.key,loadStatus:a.loadStatus,durationMs:a.durationMs,cacheHit:a.cacheHit,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()})).filter(a=>!Ct(a)),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()}u();import{persistentStorage as He}from"@buoy-gg/shared-ui/web";var Ne="@react_buoy/assets/baseline",Ka=1024;async function Ht(){let e=f();if(e.baselineLoaded)return e.baseline;e.baselineLoaded=true;try{let t=await He.getItem(Ne);if(t){let s=JSON.parse(t);s&&typeof s.savedAt=="number"&&s.entries&&(e.baseline=s,A())}}catch{}return e.baseline}async function Nt(){let e=be();if(e)return await e("saveBaseline"),f().baseline??{savedAt:Date.now(),entries:{}};let t=f(),s={};for(let n of F())s[n.key]={hash:n.hash??null,sizeBytes:n.sizeSource==="measured"?n.sizeBytes??null:null,name:n.name,type:n.type};let a={savedAt:Date.now(),entries:s};t.baseline=a,t.baselineLoaded=true,A();try{await He.setItem(Ne,JSON.stringify(a))}catch{}return a}async function Vt(){let e=be();if(e){await e("clearBaseline");return}let t=f();t.baseline=null,t.baselineLoaded=true,A();try{await He.removeItem(Ne)}catch{}}function Wt(e,t){let s=[],a=[],n=new Set,r=0,o=0,l=false;for(let c of e){n.add(c.key);let i=t.entries[c.key];if(!i){s.push(c.id);continue}let y=c.sizeSource==="measured"?c.sizeBytes??null:null;y!=null&&i.sizeBytes!=null&&(l=true,r+=y,o+=i.sizeBytes,y-i.sizeBytes>=Ka&&a.push({id:c.id,deltaBytes:y-i.sizeBytes}))}let d=[];for(let[c,i]of Object.entries(t.entries))xt(c)||n.has(c)||(d.push({key:c,name:i.name,type:i.type}),i.sizeBytes!=null&&(l=true,o+=i.sizeBytes));for(let c of s){let i=e.find(y=>y.id===c);i?.sizeSource==="measured"&&i.sizeBytes!=null&&(l=true,r+=i.sizeBytes)}return{baselineSavedAt:t.savedAt,added:s,removed:d,grown:a.sort((c,i)=>i.deltaBytes-c.deltaBytes),netBytes:l?r-o:null}}function ve(){let e=f();return e.mirrorDiff?e.mirrorDiff:e.baseline?Wt(F(),e.baseline):null}u();T();import{night as V}from"@buoy-gg/shared-ui/web";u();T();import{useState as Ga}from"react";import{night as _a}from"@buoy-gg/shared-ui/web";u();T();import{buoyFetch as Ut}from"@buoy-gg/shared-ui/web";u();function Kt(){return null}async function qa(){pe();let e=It().length;return e?{ok:true,count:e}:{ok:false,message:"Register a browser asset manifest to inspect files that have not loaded yet."}}var Ja=4;function Ya(e){if(e.resolvedUri)return e.resolvedUri;let t=Gt(e);return t.length?t[0].url:null}function Qa(e){let t=f().captureDisabled;if(!t&&e.registryId!=null)return e.registryId;let s=Ya(e);return!s||t&&!/^https?:\/\//.test(s)?null:{uri:s}}function Gt(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(o=>{let l=o===1?"":`@${o}x`,d=(n===""?s.replace(`.${e.type}`,`${l}.${e.type}`):s.replace(r,`${l}.${e.type}`)).replace(/ /g,"%20");return{scale:o,url:d}})}let a=Kt();return!a||!e.httpServerLocation?[]:t.map(n=>{let r=n===1?"":`@${n}x`,o=`${e.httpServerLocation}/${e.name}${r}.${e.type}`,l=o.includes("?")?"&":"?",d=`${a}${o}${l}platform=${Za()}${e.hash?`&hash=${e.hash}`:""}`.replace(/ /g,"%20");return{scale:n,url:d}})}function Za(){try{return ce.OS}catch{return"ios"}}async function Xa(e){try{let t=await Ut(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 Ut(e);if(!t.ok)return null;let s=await t.blob();return s.size>0?s.size:null}catch{return null}}async function en(e){let t=Gt(e);if(!t.length){ne(e.id,{sizeSource:"estimate"});return}let s={},a=0;for(let{scale:n,url:r}of t){let o=await Xa(r);o!=null&&(s[String(n)]=o,a+=o)}a>0?ne(e.id,{sizesByScale:s,sizeBytes:a,sizeSource:"measured"}):ne(e.id,{sizeSource:"estimate"})}async function _t(){let e=f();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 n=t[s++];if(!n)return;await en(n),e.measuredCount=F().filter(r=>r.sizeSource==="measured").length}};await Promise.all(Array.from({length:Math.min(Ja,t.length)},a))}finally{e.measuring=false,A()}return{measured:e.measuredCount,total:F().length}}u();function tn(e){e&&typeof e=="object"&&za(e.uri)}u();function sn(){return null}import{jsx as Se}from"react/jsx-runtime";function qt({record:e,style:t,testID:s,compact:a=false}){let n=Qa(e);tn(n);let r=e.type.toLowerCase()==="svg",o=r&&ce.OS!=="web"?sn():null,l=`${e.key}:${e.hash??""}:${typeof n=="number"?n:n?.uri??""}`,[d,c]=Ga(null);if(n==null||d===l||r&&ce.OS!=="web"&&!o){let y=r?"SVG preview unavailable":"Image preview unavailable";return Se(m,{style:[t,Jt.fallback],accessibilityLabel:y,testID:`${s}-unavailable`,children:Se(b,{style:Jt.text,children:a?r?"SVG":"IMG":y})})}let i=()=>c(l);return o?Se(o,{source:n,style:t,contentFit:"contain",onError:i,testID:s}):Se(dt,{source:n,style:t,resizeMode:"contain",onError:i,testID:s})}var Jt=P.create({fallback:{alignItems:"center",justifyContent:"center"},text:{color:_a.color.textSecondary,fontSize:10,textAlign:"center"}});u();function ee(e){return String(e).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function re(e,t){return`buoy-assets-row-${ee(`${e}.${t}`)}`}function Yt(e,t,s){return`${re(e,t)}-badge-${ee(s)}`}function Ve(e){return`buoy-assets-filter-${ee(e)}`}function Qt(e){return`buoy-assets-detail-row-${ee(e)}`}function Zt(e){return`buoy-assets-font-${ee(e)}`}var v={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 Xt(e){return`buoy-assets-detail-finding-${e}`}import{Fragment as an,jsx as g,jsxs as We}from"react/jsx-runtime";function w({label:e,value:t}){let s=Qt(e);return We(m,{style:L.kvRow,testID:s,children:[g(b,{style:L.kvLabel,children:e}),g(b,{style:L.kvValue,selectable:true,testID:`${s}-value`,children:t})]})}function nn({record:e}){return e.kind==="image"?g(m,{style:L.previewBox,testID:v.detailPreview,children:g(qt,{testID:"buoy-internal-assets-preview",record:e,style:L.previewImage})}):e.kind==="font"?g(m,{style:L.previewBox,testID:v.detailFontPreview,children:g(b,{style:[L.fontPreview,{fontFamily:e.name}],children:"The quick brown fox jumps over the lazy dog 0123456789"})}):null}function rn({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(r=>r.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 n=C(e);return We(Ae,{style:L.scroll,contentContainerStyle:L.content,testID:v.detailScroll,children:[g(nn,{record:e}),s.length>0?g(m,{style:L.findings,testID:v.detailFindings,children:s.map((r,o)=>g(b,{style:L.findingText,testID:Xt(o),children:r},r))}):null,g(w,{label:"Name",value:`${e.name}.${e.type}`}),e.loadStatus&&We(an,{children:[g(w,{label:"Load",value:e.loadStatus==="error"?"Failed":"Loaded"}),g(w,{label:"Load time",value:e.durationMs==null?"Unknown":`${e.durationMs.toFixed(1)} ms`}),g(w,{label:"Load size",value:e.sizeBytes==null?"Unknown":I(e.sizeBytes)}),g(w,{label:"Cache",value:e.cacheHit==null?"Unknown":e.cacheHit?"Cache hit":"Web load"})]}),g(w,{label:"Kind",value:e.kind}),g(w,{label:"Status",value:e.loaded?"Loaded (registered at runtime)":"Not observed in the runtime registry"}),e.kind==="image"?g(w,{label:"Dimensions",value:`${ge(e)} (logical)`}):null,e.kind==="image"&&e.scales.length?g(w,{label:"Scales",value:me(e.scales)}):null,e.sizesByScale?Object.entries(e.sizesByScale).map(([r,o])=>g(w,{label:`Size @${r}x`,value:I(o)},r)):null,e.sizeBytes!=null&&e.sizeSource==="measured"?g(w,{label:"Total size",value:I(e.sizeBytes)}):null,n>0?g(w,{label:"Decoded memory",value:`~${I(n)} (RGBA)`}):null,e.registryId!=null?g(w,{label:"Registry id",value:String(e.registryId)}):null,e.hash?g(w,{label:"Hash",value:e.hash}):null,e.httpServerLocation?g(w,{label:"Location",value:e.httpServerLocation}):null,e.fileSystemLocation?g(w,{label:"Source dir",value:e.fileSystemLocation}):null,e.resolvedUri?g(w,{label:"Resolved URI",value:e.resolvedUri}):null]})}var L=P.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}});u();T();import{macOSColors as Ue,night as W,Pill as on}from"@buoy-gg/shared-ui/web";import{jsx as E,jsxs as U}from"react/jsx-runtime";function ln({label:e,color:t,testID:s}){return E(on,{label:e,color:t,variant:"quiet",dot:!!t,style:{paddingVertical:2.5},testID:s})}function dn({record:e,flags:t,sizeFraction:s,onPress:a}){let n=Et[e.kind],r=[];return e.loaded||r.push({label:"NOT OBSERVED"}),t.oversize&&r.push({label:"OVERSIZE",color:Ue.semantic.error}),t.duplicate&&r.push({label:"DUP"}),t.heavy&&r.push({label:"HEAVY"}),t.scaleAnomaly?r.push({label:"BAD SCALE",color:Ue.semantic.error}):t.scaleGap&&r.push({label:"LOW-RES"}),t.webp&&r.push({label:"WEBP",color:Ue.semantic.info}),U(N,{style:x.card,testID:re(e.name,e.type),onPress:()=>a(e.id),activeOpacity:.7,children:[U(m,{style:x.body,children:[E(m,{style:x.thumbBox,children:e.kind==="image"?E(qt,{testID:"buoy-internal-assets-thumb",record:e,style:x.thumb,compact:true}):E(b,{style:[x.thumbFallback,{color:n}],children:Lt[e.kind]})}),U(m,{style:x.main,children:[U(b,{style:x.name,numberOfLines:1,testID:`${re(e.name,e.type)}-name`,children:[e.name,U(b,{style:x.ext,children:[".",e.type]})]}),U(m,{style:x.metaRow,children:[e.kind==="image"&&e.width!=null?E(b,{style:x.meta,children:ge(e)}):null,e.kind==="image"&&e.scales.length?E(b,{style:x.meta,children:me(e.scales)}):null]})]}),U(m,{style:x.right,children:[E(b,{style:x.size,testID:`${re(e.name,e.type)}-size`,children:$a(e,C(e))}),r.length?E(m,{style:x.badgeRow,children:r.slice(0,3).map(o=>E(ln,{label:o.label,color:o.color,testID:Yt(e.name,e.type,o.label)},o.label))}):null]})]}),s>0?E(m,{style:x.sizeTrack,children:E(m,{style:[x.sizeFill,{backgroundColor:n,width:`${Math.max(2,Math.round(s*100))}%`}]})}):null]})}var x=P.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}});u();T();import{night as we}from"@buoy-gg/shared-ui/web";import{jsx as Ke}from"react/jsx-runtime";function cn({stats:e,duplicateCount:t,filter:s,onChange:a}){let n=[{key:"all",label:`ALL ${e.total}`,accent:we.color.textSecondary},{key:"duplicates",label:`DUPLICATES ${t}`,accent:"#FF9F1C"}];for(let r of Object.keys(e.byKind)){let o=e.byKind[r];o.count>0&&n.push({key:r,label:`${Lt[r]} ${o.count}`,accent:Et[r]})}return e.neverLoaded>0&&n.push({key:"unused",label:`NOT OBSERVED ${e.neverLoaded}`,accent:"#FF9F1C"}),n.length<=1?null:Ke(m,{style:Ge.bar,testID:v.filterBar,children:n.map(r=>{let o=r.key===s;return Ke(N,{accessibilityRole:"button",accessibilityState:{selected:o},testID:Ve(r.key),style:[Ge.chip,o&&{borderColor:r.accent,backgroundColor:`${r.accent}1A`}],onPress:()=>a(o?"all":r.key),children:Ke(b,{testID:`${Ve(r.key)}-label`,style:[Ge.chipText,{color:o?r.accent:we.color.textSecondary}],children:r.label})},r.key)})})}var Ge=P.create({bar:{flexDirection:"row",flexWrap:"wrap",gap:6,paddingHorizontal:10,paddingVertical:8},chip:{borderWidth:1,borderColor:we.color.border,backgroundColor:we.color.surface,borderRadius:999,paddingHorizontal:10,paddingVertical:5},chipText:{fontSize:10,fontWeight:"700",letterSpacing:.4,lineHeight:13}});u();import{ModalHeader as O,ToolbarClearButton as un,ToolbarCopyButton as es}from"@buoy-gg/shared-ui/web";import{jsx as j,jsxs as _e}from"react/jsx-runtime";function hn({stats:e,measuring:t,discovering:s=false,detailOpen:a,detailIndex:n=-1,detailTotal:r=0,onCloseDetail:o,onClear:l,getReport:d,onBack:c}){if(a){let y=n>=0&&r>0?`${n+1} of ${r}`:void 0;return _e(O,{children:[j(O.Navigation,{onBack:o}),j(O.Content,{title:"Asset detail",subtitle:y,testID:v.title}),j(O.Actions,{children:j(es,{value:d,testID:v.copy})})]})}let i=[`${e.total} assets${s?" so far":""}`];if(e.totalBytes>0&&!t&&!s){let y=e.measuredCount<e.total?"+":"";i.push(`${I(e.totalBytes)}${y}`)}return e.neverLoaded>0&&i.push(`${e.neverLoaded} not observed`),e.fontFamilies>0&&i.push(`${e.fontFamilies} fonts`),_e(O,{children:[c?j(O.Navigation,{onBack:c}):null,j(O.Content,{title:"Assets",subtitle:i.join(" \xB7 "),testID:v.title}),_e(O.Actions,{children:[j(es,{value:d,testID:v.copy}),j(un,{onPress:l,testID:v.clear})]})]})}u();T();import{night as K}from"@buoy-gg/shared-ui/web";import{jsx as ts,jsxs as ss}from"react/jsx-runtime";var pn={size:"name",name:"type",type:"size"};function fn({query:e,onQueryChange:t,sort:s,onSortChange:a}){return ss(m,{style:xe.row,children:[ts($e,{style:xe.input,value:e,onChangeText:t,placeholder:"Search assets\u2026",placeholderTextColor:K.color.placeholder,autoCapitalize:"none",autoCorrect:false,testID:v.search}),ts(N,{style:xe.button,onPress:()=>a(pn[s]),testID:v.sort,children:ss(b,{style:xe.buttonText,testID:`${v.sort}-label`,children:["\u2193 ",s.toUpperCase()]})})]})}var xe=P.create({row:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:10,paddingBottom:8},input:{flex:1,backgroundColor:K.color.surfaceElevated,borderWidth:1,borderColor:K.color.border,borderRadius:8,paddingHorizontal:10,paddingVertical:6,color:K.color.text,fontSize:12},button:{backgroundColor:K.color.surface,borderWidth:1,borderColor:K.color.border,borderRadius:8,paddingHorizontal:10,paddingVertical:7},buttonText:{color:K.color.textSecondary,fontSize:10,fontWeight:"700",letterSpacing:.5}});u();T();import{useEffect as yn,useState as mn}from"react";import{night as oe}from"@buoy-gg/shared-ui/web";import{jsx as Ce,jsxs as gn}from"react/jsx-runtime";function bn({status:e,total:t,onRetry:s}){let[a,n]=mn(false);yn(()=>{if(n(false),!e.graphFetchInFlight)return;let l=e.graphFetchStartedAt==null?0:Math.max(0,Date.now()-e.graphFetchStartedAt),d=setTimeout(()=>n(true),Math.max(0,8e3-l));return()=>clearTimeout(d)},[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.`),a&&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 o=!e.graphFetchInFlight&&e.graphSupported&&!!e.graphError;return o&&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:gn(m,{style:qe.notice,testID:v.notice,children:[e.graphFetchInFlight?Ce(Le,{size:"small",color:oe.color.textSecondary,accessibilityLabel:"Finding assets",testID:v.discoverySpinner}):null,r.map(l=>Ce(b,{style:qe.noticeText,testID:v.noticeText,children:l},l)),o?Ce(N,{accessibilityRole:"button",onPress:s,testID:v.retry,children:Ce(b,{style:qe.retryText,children:"Retry"})}):null]})}var qe=P.create({notice:{marginHorizontal:10,marginBottom:8,padding:10,borderRadius:8,borderWidth:1,borderColor:oe.color.border,backgroundColor:oe.color.surface,gap:4},noticeText:{color:oe.color.textSecondary,fontSize:11},retryText:{color:oe.color.text,fontSize:12,paddingVertical:6}});import{jsx as S,jsxs as te}from"react/jsx-runtime";function vn({names:e}){let t=[...new Set(e)];return t.length?te(m,{style:z.fontsBox,testID:v.fonts,children:[te(b,{style:z.fontsTitle,testID:v.fontsTitle,children:["LOADED FONT FAMILIES (",t.length,")"]}),S(m,{style:z.fontsWrap,children:t.map(s=>S(b,{style:z.fontChip,testID:Zt(s),children:s},s))})]}):null}function Sn({duplicates:e=false}){return S(ga,{testID:v.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 as(e,t){return(t.sizeBytes??C(t))-(e.sizeBytes??C(e))}var wn={size:as,name:(e,t)=>e.name.localeCompare(t.name)||e.type.localeCompare(t.type),type:(e,t)=>e.type.localeCompare(t.type)||as(e,t)};function Je({visible:e,onClose:t,onBack:s,onMinimize:a,persistenceKey:n,inline:r=false}){fe();let{records:o,stats:l,insights:d}=Mt(),c=Na(),[i,y]=ae(false);wt(()=>{y(false)},[c.graphFetchInFlight,c.lastScanAt]);let p=()=>{y(false);let h=be();h?h("rescan").catch(()=>y(true)):ye()},[D,G]=ae(null),[k,ls]=ae("all"),[Qe,Ze]=ae(""),[Xe,ds]=ae("size"),H=D!=null?Te(D):void 0;wt(()=>{if(!e)return;Ht(),y(false);let h=be();h?h("rescan").catch(()=>y(true)):ye()},[e]);let ke=new Set(d.duplicates.flatMap(h=>h.ids)),et=[...o].sort(wn[Xe]),tt=Qe.trim().toLowerCase(),_=et.filter(h=>!(k==="unused"&&h.loaded||k==="duplicates"&&!ke.has(h.id)||k!=="all"&&k!=="unused"&&k!=="duplicates"&&h.kind!==k||tt&&!`${h.name}.${h.type}`.toLowerCase().includes(tt))),se=H?_.findIndex(h=>h.id===H.id):-1,st=h=>{let M=_[h];M&&G(M.id)},q={scaleGaps:new Set(d.scaleGaps),scaleAnomalies:new Set(d.scaleAnomalies),duplicates:ke,webpCandidates:new Set(d.webpCandidates),overDecode:new Set(d.overDecode),heavy:new Set([...d.heavyGifs,...d.heavyFonts])},ie=0;for(let h of _){let M=h.sizeBytes??C(h);M>ie&&(ie=M)}let cs=()=>H?Tt(H):Rt(et,l,d,X(),ve()),at=S(hn,{stats:l,measuring:c.measuring,discovering:c.graphFetchInFlight,detailOpen:H!=null,detailIndex:se,detailTotal:_.length,onCloseDetail:()=>G(null),onClear:Re,getReport:cs,onBack:s}),nt=H?te(m,{style:z.detailContainer,children:[S(rn,{record:H,insights:d}),se>=0?S(pa,{currentIndex:se,totalItems:_.length,itemLabel:"Asset",onPrevious:()=>st(se-1),onNext:()=>st(se+1)}):null]}):te(m,{style:z.listContainer,children:[S(cn,{stats:l,duplicateCount:ke.size,filter:k,onChange:h=>{ls(h),h==="duplicates"&&Ze("")}}),S(fn,{query:Qe,onQueryChange:Ze,sort:Xe,onSortChange:ds}),S(bn,{status:c,total:l.total,onRetry:p}),i&&!c.graphFetchInFlight?te(m,{style:z.notice,children:[S(b,{style:z.noticeText,children:"Couldn't request an asset scan from the device."}),S(N,{accessibilityRole:"button",onPress:p,children:S(b,{style:z.retryText,children:"Retry"})})]}):null,k==="unused"?S(m,{style:z.notice,children:S(b,{style:z.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,k==="font"?S(vn,{names:c.fontFamilies}):null,S(lt,{testID:v.list,data:_,keyExtractor:h=>String(h.id),contentContainerStyle:z.listContent,renderItem:({item:h})=>S(dn,{record:h,flags:{scaleGap:q.scaleGaps.has(h.id),scaleAnomaly:q.scaleAnomalies.has(h.id),duplicate:q.duplicates.has(h.id),webp:q.webpCandidates.has(h.id),oversize:q.overDecode.has(h.id),heavy:q.heavy.has(h.id)},sizeFraction:ie>0?(h.sizeBytes??C(h))/ie:0,onPress:M=>G(typeof M=="number"?M:null)}),ListEmptyComponent:c.graphFetchInFlight?null:S(Sn,{duplicates:k==="duplicates"})})]});return r?te(m,{style:z.inlineRoot,children:[S(m,{style:z.inlineHeader,...ma,children:at}),nt]}):S(fa,{visible:e,onClose:t,onMinimize:a,persistenceKey:n,header:{showToggleButton:true,customContent:at},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:nt})}function xn(e={}){return S(Je,{...e,inline:true,visible:true,onClose:()=>{}})}var z=P.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:ya.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 Cn,defineToolPreset as kn}from"@buoy-gg/shared-ui/web";import{jsx as zn}from"react/jsx-runtime";var ns=kn({id:"assets",name:"ASSETS",description:"Every bundled asset \u2014 sizes, scale coverage, unused detection",slot:"both",icon:({size:e,color:t})=>zn(vt,{size:e,color:t||St}),component:Je}),Bn=Cn(ns);u();var rs=["image","font","video","audio","data","other"];function Ye(e){return{loadStatus:e.loadStatus,durationMs:e.durationMs,cacheHit:e.cacheHit,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:C(e)||null,sizeSource:e.sizeSource??null}}function In(e){let t=e?.id;if(typeof t!="number")throw new Error("Missing numeric `id` param");let s=Te(t);if(!s)throw new Error(`Asset record ${t} not found \u2014 re-run the list action for current ids.`);return s}function Dn(e,t){return(t.sizeBytes??C(t))-(e.sizeBytes??C(e))}function os(){let e=F();return{stats:Me(e),scanStatus:X(),insights:je(e),diff:ve(),records:[...e].sort(Dn)}}var $n={version:1,getSnapshot:()=>{let{records:e,...t}=os();return{...t,records:e.slice(0,200).map(Ye)}},subscribe:e=>ue(e),actions:{list:e=>{let t=e??{},s=Math.min(Math.max(t.limit??50,1),500),{records:a,...n}=os(),r=a;if(t.kind){if(!rs.includes(t.kind))throw new Error(`kind must be one of: ${rs.join(", ")}`);r=r.filter(o=>o.kind===t.kind)}return t.loadedOnly&&(r=r.filter(o=>o.loaded)),{...n,total:r.length,records:r.slice(0,s).map(Ye)}},getDetail:e=>{let t=In(e);return{...Ye(t),origin:t.origin,fileSystemLocation:t.fileSystemLocation??null,files:t.files??null,sizesByScale:t.sizesByScale??null,estDecodedBytes:C(t)||null}},rescan:async()=>({ok:true,scanStatus:await ye()}),measureSizes:async()=>{let e=await _t();return{ok:e.measured>0,...e}},saveBaseline:async()=>{let e=await Nt();return{ok:true,savedAt:e.savedAt,assets:Object.keys(e.entries).length}},clearBaseline:async()=>(await Vt(),{ok:true,message:"Baseline cleared"}),getDiff:()=>ve(),clearRecords:()=>(Re(),{ok:true,message:"Inventory cleared \u2014 rescan to rebuild"}),getScanStatus:()=>X()}};u();u();var is=0;function An(){if(typeof document>"u")return()=>{};++is===1&&fe();let e=true;return()=>{e&&(e=false,--is===0&&Ft())}}export{St as ASSETS_ICON_COLOR,v as ASSETS_TEST_IDS,vt as AssetsIcon,Je as AssetsModal,xn as AssetsToolView,Yt as assetBadgeTestID,Qt as assetDetailRowTestID,Ve as assetFilterTestID,Xt as assetFindingTestID,Zt as assetFontChipTestID,re as assetRowTestID,ee as assetSlug,$n as assetsSyncAdapter,ns as assetsToolPreset,Vt as clearBaseline,Re as clearRecords,Wt as computeDiff,je as computeInsights,Me as computeStats,Bn as createAssetsTool,Wa as disableAssetsCapture,C as estDecodedBytes,qa as fetchAssetGraph,Tt as formatAssetMarkdown,Rt as formatInventoryMarkdown,It as getBrowserAssetManifest,Kt as getDevServerOrigin,ve as getDiff,Oe as getLoadedFontFamilies,Da as getLocalAssets,Te as getRecord,X as getScanStatus,F as getSnapshot,fe as installAssetCapture,Ht as loadBaseline,Ba as loadBrowserAssetManifest,_t as measureSizes,Ia as recordBrowserAssetLoad,Bt as registerBrowserAssetManifest,Ua as replaceAssetsFromSnapshot,ye as rescan,Nt as saveBaseline,Va as setRemoteAssetsHandler,An as startBrowserAssetCapture,ue as subscribe,Mt as useAssetRecords};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/assets",
3
- "version": "7.0.62",
3
+ "version": "7.0.64",
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.62"
20
+ "@buoy-gg/shared-ui": "^7.0.64"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "react": "*"