@buoy-gg/images 7.0.56 → 7.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getCaptureStatus=getCaptureStatus;exports.installImageCapture=installImageCapture;exports.startBrowserImageCapture=startBrowserImageCapture;exports.stopBrowserImageCapture=stopBrowserImageCapture;var _state=require("../state");var _imageEventStore=require("../store/imageEventStore");var _overrides=require("./overrides");const tracked=new Map;let detach;let leases=0;const EMPTY_IMAGE="data:image/png;base64,";function apply(e){const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.getCaptureStatus=getCaptureStatus;exports.installImageCapture=installImageCapture;exports.startBrowserImageCapture=startBrowserImageCapture;exports.stopBrowserImageCapture=stopBrowserImageCapture;var _state=require("../state");var _imageEventStore=require("../store/imageEventStore");var _overrides=require("./overrides");const tracked=new Map;let detach;let leases=0;const EMPTY_IMAGE="data:image/png;base64,";function apply(e){const d=(0,_imageEventStore.getRecord)(e.id);if(!d)return;const c=(0,_state.imagesState)();const i=(0,_overrides.getOverride)(e.id);const l=(0,_overrides.getGlobalModes)();let s=e.source;if(l.network==="offline"&&d.sourceKind==="network")s=EMPTY_IMAGE;if(i?.source){const r=i.source;if(r.type==="url")s=r.uri;else if(r.type==="error")s=EMPTY_IMAGE;else s=null;if(r.type==="hang")(0,_imageEventStore.updateRecord)(e.id,{status:"loading"})}const u=c.reloadRequests.get(e.id);const p=u&&u.nonce!==e.nonce;if(p){e.nonce=u.nonce;if(u.bust&&s&&/^https?:/.test(new URL(s,document.baseURI).href)){const r=new URL(s,document.baseURI);r.searchParams.set("__buoy_reload",String(Date.now()));s=r.href}e.image.removeAttribute("src");(0,_imageEventStore.updateRecord)(e.id,{status:"loading",startedAt:Date.now(),loadCount:d.loadCount+1})}if(l.network==="cold"&&s&&/^https?:/.test(new URL(s,document.baseURI).href)){if(e.coldSource!==s||!e.coldURL||p){e.coldSource=s;const r=new URL(s,document.baseURI);r.searchParams.set("__buoy_reload",`${Date.now()}-${e.nonce}`);e.coldURL=r.href}s=e.coldURL}else{e.coldSource=void 0;e.coldURL=void 0}e.appliedSource=s;e.appliedSrcset=s!==e.source?null:e.srcset;if(e.appliedSrcset===null)e.image.removeAttribute("srcset");else if(e.image.getAttribute("srcset")!==e.appliedSrcset)e.image.setAttribute("srcset",e.appliedSrcset);if(s===null)e.image.removeAttribute("src");else if(e.image.getAttribute("src")!==s)e.image.setAttribute("src",s);const n=document.createElement("span").style;n.cssText=e.style??"";const t=i?.extraProps?.contentFit??i?.extraProps?.resizeMode;if(typeof t==="string")n.objectFit={stretch:"fill",center:"none"}[t]??t;if(l.blank||i?.source?.type==="blank")n.opacity="0";for(const[r,a]of Object.entries(i?.style??{})){const o=r.replace(/[A-Z]/g,f=>`-${f.toLowerCase()}`);n.setProperty(o,typeof a==="number"&&!["opacity","zIndex","flex","flexGrow","flexShrink"].includes(r)?`${a}px`:String(a))}if((c.flashUntil.get(e.id)??0)>Date.now())n.outline="3px solid #ff453a";e.appliedStyle=n.cssText||null;if(e.image.getAttribute("style")!==e.appliedStyle){if(e.appliedStyle===null)e.image.removeAttribute("style");else e.image.setAttribute("style",e.appliedStyle)}}function track(e){if(tracked.has(e)||e.closest("[data-buoy-root]"))return;const d=e.currentSrc||e.src;if(!d)return;const c=(0,_imageEventStore.createRecord)({lib:"web",uri:d,sourceKind:d.startsWith("data:")?"data":d.startsWith("blob:")?"file":"network",hasAltText:e.hasAttribute("alt")||e.hasAttribute("aria-label")});const i={id:c.id,image:e,source:e.getAttribute("src"),srcset:e.getAttribute("srcset"),style:e.getAttribute("style"),appliedSource:e.getAttribute("src"),appliedSrcset:e.getAttribute("srcset"),appliedStyle:e.getAttribute("style"),nonce:0,dispose(){}};const l=()=>{const n=e.getBoundingClientRect();const t=c.layout;const r=c.status==="loaded"&&t&&(t.width!==n.width||t.height!==n.height);(0,_imageEventStore.updateRecord)(c.id,{layout:{width:n.width,height:n.height},layoutShifts:(c.layoutShifts??0)+(r?1:0)})};const s=()=>{const n=performance.getEntriesByName(e.currentSrc||e.src);const t=n[n.length-1];(0,_imageEventStore.updateRecord)(c.id,{status:"loaded",loadedAt:Date.now(),intrinsic:{width:e.naturalWidth,height:e.naturalHeight},...!(0,_overrides.getOverride)(c.id)?.source&&(0,_overrides.getGlobalModes)().network==="normal"?{uri:e.currentSrc||e.src}:{},durationMs:t?.duration,bytesTotal:t&&t.encodedBodySize>0?t.encodedBodySize:void 0,cacheVerdict:t&&t.transferSize>0?"none":void 0,cacheVerdictSource:t?"event":void 0});l()};const u=()=>(0,_imageEventStore.updateRecord)(c.id,{status:"error",erroredAt:Date.now(),error:"The browser could not load this image."});e.addEventListener("load",s);e.addEventListener("error",u);const p=typeof ResizeObserver==="undefined"?void 0:new ResizeObserver(l);p?.observe(e);i.dispose=()=>{p?.disconnect();e.removeEventListener("load",s);e.removeEventListener("error",u)};tracked.set(e,i);l();(0,_imageEventStore.updateRecord)(c.id,{status:"loading",startedAt:Date.now(),loadCount:1});if(e.complete){if(e.naturalWidth>0)s();else u()}apply(i)}function installImageCapture(){const e=(0,_state.imagesState)();if(typeof document==="undefined"||e.captureDisabled||detach)return;e.captureInstalled=true;const d=new WeakSet;const c=t=>{t.querySelectorAll("img").forEach(track);const r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(let a=r.nextNode();a;a=r.nextNode()){const o=a.shadowRoot;if(!o)continue;if(!d.has(o)){d.add(o);s.observe(o,l)}c(o)}};const i=()=>{for(const[t,r]of tracked)if(!t.isConnected){r.dispose();tracked.delete(t);(0,_imageEventStore.updateRecord)(r.id,{mounted:false})}c(document)};const l={childList:true,subtree:true,attributes:true,attributeFilter:["src","srcset","style","alt"]};const s=new MutationObserver(t=>{if((0,_state.imagesState)().captureDisabled){stopBrowserImageCapture();return}for(const r of t){const a=r.target;const o=tracked.get(a);if(!o||r.type!=="attributes")continue;if(r.attributeName==="src"&&a.getAttribute("src")!==o.appliedSource||r.attributeName==="srcset"&&a.getAttribute("srcset")!==o.appliedSrcset){o.dispose();tracked.delete(a);(0,_imageEventStore.updateRecord)(o.id,{mounted:false})}else if(r.attributeName==="style"&&a.getAttribute("style")!==o.appliedStyle){o.style=a.getAttribute("style");apply(o)}}i()});s.observe(document.documentElement,l);const u=Element.prototype.attachShadow;const p=function(t){const r=u.call(this,t);if(t.mode==="open"&&!d.has(r)){d.add(r);s.observe(r,l)}return r};Element.prototype.attachShadow=p;const n=()=>{for(const t of tracked.values())apply(t)};e.actionListeners.add(n);detach=()=>{s.disconnect();e.actionListeners.delete(n);if(Element.prototype.attachShadow===p)Element.prototype.attachShadow=u;for(const t of tracked.values()){t.dispose();for(const[r,a,o]of[["src",t.source,t.appliedSource],["srcset",t.srcset,t.appliedSrcset],["style",t.style,t.appliedStyle]]){if(t.image.getAttribute(r)!==o)continue;if(a===null)t.image.removeAttribute(r);else t.image.setAttribute(r,a)}(0,_imageEventStore.updateRecord)(t.id,{mounted:false})}tracked.clear();e.captureInstalled=false};i()}function stopBrowserImageCapture(){detach?.();detach=void 0}function startBrowserImageCapture(){if(typeof document==="undefined")return()=>{};if(leases++===0)installImageCapture();let e=false;return()=>{if(e)return;e=true;if(--leases===0)stopBrowserImageCapture()}}function getCaptureStatus(){return(0,_state.imagesState)().mirrorCaptureStatus??{installed:!!detach,rnDecoratorActive:false,rnDecoratorTooLate:false,expoPatched:false,expoAvailable:false,browserObserverActive:!!detach}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{imagesState as
|
|
1
|
+
"use strict";import{imagesState as y}from"../state";import{createRecord as x,getRecord as E,updateRecord as f}from"../store/imageEventStore";import{getOverride as w,getGlobalModes as g}from"./overrides";const p=new Map;let h;let A=0;const v="data:image/png;base64,";function S(e){const i=E(e.id);if(!i)return;const c=y();const d=w(e.id);const l=g();let o=e.source;if(l.network==="offline"&&i.sourceKind==="network")o=v;if(d?.source){const r=d.source;if(r.type==="url")o=r.uri;else if(r.type==="error")o=v;else o=null;if(r.type==="hang")f(e.id,{status:"loading"})}const u=c.reloadRequests.get(e.id);const b=u&&u.nonce!==e.nonce;if(b){e.nonce=u.nonce;if(u.bust&&o&&/^https?:/.test(new URL(o,document.baseURI).href)){const r=new URL(o,document.baseURI);r.searchParams.set("__buoy_reload",String(Date.now()));o=r.href}e.image.removeAttribute("src");f(e.id,{status:"loading",startedAt:Date.now(),loadCount:i.loadCount+1})}if(l.network==="cold"&&o&&/^https?:/.test(new URL(o,document.baseURI).href)){if(e.coldSource!==o||!e.coldURL||b){e.coldSource=o;const r=new URL(o,document.baseURI);r.searchParams.set("__buoy_reload",`${Date.now()}-${e.nonce}`);e.coldURL=r.href}o=e.coldURL}else{e.coldSource=void 0;e.coldURL=void 0}e.appliedSource=o;e.appliedSrcset=o!==e.source?null:e.srcset;if(e.appliedSrcset===null)e.image.removeAttribute("srcset");else if(e.image.getAttribute("srcset")!==e.appliedSrcset)e.image.setAttribute("srcset",e.appliedSrcset);if(o===null)e.image.removeAttribute("src");else if(e.image.getAttribute("src")!==o)e.image.setAttribute("src",o);const n=document.createElement("span").style;n.cssText=e.style??"";const t=d?.extraProps?.contentFit??d?.extraProps?.resizeMode;if(typeof t==="string")n.objectFit={stretch:"fill",center:"none"}[t]??t;if(l.blank||d?.source?.type==="blank")n.opacity="0";for(const[r,a]of Object.entries(d?.style??{})){const s=r.replace(/[A-Z]/g,R=>`-${R.toLowerCase()}`);n.setProperty(s,typeof a==="number"&&!["opacity","zIndex","flex","flexGrow","flexShrink"].includes(r)?`${a}px`:String(a))}if((c.flashUntil.get(e.id)??0)>Date.now())n.outline="3px solid #ff453a";e.appliedStyle=n.cssText||null;if(e.image.getAttribute("style")!==e.appliedStyle){if(e.appliedStyle===null)e.image.removeAttribute("style");else e.image.setAttribute("style",e.appliedStyle)}}function L(e){if(p.has(e)||e.closest("[data-buoy-root]"))return;const i=e.currentSrc||e.src;if(!i)return;const c=x({lib:"web",uri:i,sourceKind:i.startsWith("data:")?"data":i.startsWith("blob:")?"file":"network",hasAltText:e.hasAttribute("alt")||e.hasAttribute("aria-label")});const d={id:c.id,image:e,source:e.getAttribute("src"),srcset:e.getAttribute("srcset"),style:e.getAttribute("style"),appliedSource:e.getAttribute("src"),appliedSrcset:e.getAttribute("srcset"),appliedStyle:e.getAttribute("style"),nonce:0,dispose(){}};const l=()=>{const n=e.getBoundingClientRect();const t=c.layout;const r=c.status==="loaded"&&t&&(t.width!==n.width||t.height!==n.height);f(c.id,{layout:{width:n.width,height:n.height},layoutShifts:(c.layoutShifts??0)+(r?1:0)})};const o=()=>{const n=performance.getEntriesByName(e.currentSrc||e.src);const t=n[n.length-1];f(c.id,{status:"loaded",loadedAt:Date.now(),intrinsic:{width:e.naturalWidth,height:e.naturalHeight},...!w(c.id)?.source&&g().network==="normal"?{uri:e.currentSrc||e.src}:{},durationMs:t?.duration,bytesTotal:t&&t.encodedBodySize>0?t.encodedBodySize:void 0,cacheVerdict:t&&t.transferSize>0?"none":void 0,cacheVerdictSource:t?"event":void 0});l()};const u=()=>f(c.id,{status:"error",erroredAt:Date.now(),error:"The browser could not load this image."});e.addEventListener("load",o);e.addEventListener("error",u);const b=typeof ResizeObserver==="undefined"?void 0:new ResizeObserver(l);b?.observe(e);d.dispose=()=>{b?.disconnect();e.removeEventListener("load",o);e.removeEventListener("error",u)};p.set(e,d);l();f(c.id,{status:"loading",startedAt:Date.now(),loadCount:1});if(e.complete){if(e.naturalWidth>0)o();else u()}S(d)}export function installImageCapture(){const e=y();if(typeof document==="undefined"||e.captureDisabled||h)return;e.captureInstalled=true;const i=new WeakSet;const c=t=>{t.querySelectorAll("img").forEach(L);const r=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT);for(let a=r.nextNode();a;a=r.nextNode()){const s=a.shadowRoot;if(!s)continue;if(!i.has(s)){i.add(s);o.observe(s,l)}c(s)}};const d=()=>{for(const[t,r]of p)if(!t.isConnected){r.dispose();p.delete(t);f(r.id,{mounted:false})}c(document)};const l={childList:true,subtree:true,attributes:true,attributeFilter:["src","srcset","style","alt"]};const o=new MutationObserver(t=>{if(y().captureDisabled){stopBrowserImageCapture();return}for(const r of t){const a=r.target;const s=p.get(a);if(!s||r.type!=="attributes")continue;if(r.attributeName==="src"&&a.getAttribute("src")!==s.appliedSource||r.attributeName==="srcset"&&a.getAttribute("srcset")!==s.appliedSrcset){s.dispose();p.delete(a);f(s.id,{mounted:false})}else if(r.attributeName==="style"&&a.getAttribute("style")!==s.appliedStyle){s.style=a.getAttribute("style");S(s)}}d()});o.observe(document.documentElement,l);const u=Element.prototype.attachShadow;const b=function(t){const r=u.call(this,t);if(t.mode==="open"&&!i.has(r)){i.add(r);o.observe(r,l)}return r};Element.prototype.attachShadow=b;const n=()=>{for(const t of p.values())S(t)};e.actionListeners.add(n);h=()=>{o.disconnect();e.actionListeners.delete(n);if(Element.prototype.attachShadow===b)Element.prototype.attachShadow=u;for(const t of p.values()){t.dispose();for(const[r,a,s]of[["src",t.source,t.appliedSource],["srcset",t.srcset,t.appliedSrcset],["style",t.style,t.appliedStyle]]){if(t.image.getAttribute(r)!==s)continue;if(a===null)t.image.removeAttribute(r);else t.image.setAttribute(r,a)}f(t.id,{mounted:false})}p.clear();e.captureInstalled=false};d()}export function stopBrowserImageCapture(){h?.();h=void 0}export function startBrowserImageCapture(){if(typeof document==="undefined")return()=>{};if(A++===0)installImageCapture();let e=false;return()=>{if(e)return;e=true;if(--A===0)stopBrowserImageCapture()}}export function getCaptureStatus(){return y().mirrorCaptureStatus??{installed:!!h,rnDecoratorActive:false,rnDecoratorTooLate:false,expoPatched:false,expoAvailable:false,browserObserverActive:!!h}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";var R=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var Me=Object.getOwnPropertyNames;var Re=Object.prototype.hasOwnProperty;var S=(e,t)=>()=>(e&&(t=e(e=0)),t);var H=(e,t)=>{for(var a in t)R(e,a,{get:t[a],enumerable:true})},E=(e,t,a,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Me(t))!Re.call(e,s)&&s!==a&&R(e,s,{get:()=>t[s],enumerable:!(n=Ie(t,s))||n.enumerable});return e},Ee=(e,t,a)=>(E(e,t,"default"),a&&E(a,t,"default"));var Te=e=>E(R({},"__esModule",{value:true}),e);var Ce,v=S(()=>{"use strict";Ce=(()=>{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)});function l(){let e=globalThis;return e[L]||(e[L]={records:[],byId:new Map,nextId:1,listeners:new Set,snapshot:[],emitScheduled:false,captureInstalled:false,rnInstalled:false,expoInstalled:false,decoratorRegistered:false,decoratorInvoked:false,attachSeen:0,expoAvailable:false,expoPatched:false,reloadRequests:new Map,actionListeners:new Set,expoInstances:new Map,overrides:new Map,flashUntil:new Map,recordVersions:new Map,globalVersion:0,versionCounter:0,globalModes:{network:"normal",blank:false},captureDisabled:false,remoteDispatch:null,mirrorPixelRatio:null,mirrorCaptureStatus:null}),e[L]}var L,x=S(()=>{"use strict";v();L=Symbol.for("buoy.images.globalState.v1")});function Pe(e){l().remoteDispatch=e}function g(){return l().remoteDispatch}async function De(e){try{let t=await e;return{ok:!!t?.ok,message:String(t?.message??"")}}catch(t){return{ok:false,message:String(t?.message??t)}}}var T=S(()=>{"use strict";v();x()});var q={};H(q,{AccessibilityInfo:()=>Ve,ActivityIndicator:()=>re,Alert:()=>ie,Animated:()=>Ue,AppRegistry:()=>ze,AppState:()=>Fe,Appearance:()=>We,BackHandler:()=>je,Button:()=>ae,CheckBox:()=>at,Clipboard:()=>_e,DeviceEventEmitter:()=>gt,Dimensions:()=>Ke,Easing:()=>$e,FlatList:()=>Y,I18nManager:()=>He,Image:()=>Z,ImageBackground:()=>ot,InteractionManager:()=>Ge,Keyboard:()=>qe,KeyboardAvoidingView:()=>it,LayoutAnimation:()=>Ye,Linking:()=>Ze,LogBox:()=>mt,Modal:()=>ee,NativeEventEmitter:()=>Je,NativeModules:()=>Oe,PanResponder:()=>Qe,Picker:()=>st,PixelRatio:()=>C,Platform:()=>Xe,Pressable:()=>X,ProgressBar:()=>nt,RefreshControl:()=>lt,SafeAreaView:()=>dt,ScrollView:()=>O,SectionList:()=>ct,Share:()=>et,StatusBar:()=>ut,StyleSheet:()=>G,Switch:()=>te,Text:()=>D,TextInput:()=>B,Touchable:()=>pt,TouchableHighlight:()=>J,TouchableNativeFeedback:()=>ft,TouchableOpacity:()=>N,TouchableWithoutFeedback:()=>Q,UIManager:()=>tt,Vibration:()=>rt,View:()=>P,VirtualizedList:()=>bt,YellowBox:()=>ht,findNodeHandle:()=>oe,unstable_createElement:()=>Ne,useColorScheme:()=>yt,useLocaleContext:()=>vt,useWindowDimensions:()=>wt});import*as Be from"react-native-web";import{unstable_createElement as Ne,NativeModules as Oe,AccessibilityInfo as Ve,Animated as Ue,Appearance as We,AppRegistry as ze,AppState as Fe,BackHandler as je,Clipboard as _e,Dimensions as Ke,Easing as $e,I18nManager as He,Keyboard as qe,InteractionManager as Ge,LayoutAnimation as Ye,Linking as Ze,NativeEventEmitter as Je,PanResponder as Qe,PixelRatio as C,Platform as Xe,Share as et,StyleSheet as G,UIManager as tt,Vibration as rt,CheckBox as at,FlatList as Y,Image as Z,ImageBackground as ot,KeyboardAvoidingView as it,Picker as st,ProgressBar as nt,RefreshControl as lt,SafeAreaView as dt,SectionList as ct,StatusBar as ut,Touchable as pt,TouchableNativeFeedback as ft,VirtualizedList as bt,YellowBox as ht,LogBox as mt,DeviceEventEmitter as gt,useColorScheme as yt,useLocaleContext as vt,useWindowDimensions as wt}from"react-native-web";import*as b from"react-native-web";import{createElement as St,forwardRef as xt}from"react";function m(e){let t=xt((n,s)=>{let{accessibilityState:r,accessibilityValue:c,...f}=n;for(let d of["busy","checked","disabled","expanded","selected"])r?.[d]!==void 0&&f[`aria-${d}`]===void 0&&(f[`aria-${d}`]=r[d]);for(let[d,o]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))c?.[d]!==void 0&&f[`aria-${o}`]===void 0&&(f[`aria-${o}`]=c[d]);return St(e,{...f,ref:s})}),a=e.State;return a&&Object.assign(t,{State:a}),t.displayName=e.displayName??e.name??"NativeWebView",t}var P,D,B,N,J,Q,X,O,ee,te,re,ae,oe,ie,se=S(()=>{v();Ee(q,Be);P=m(b.View),D=m(b.Text),B=m(b.TextInput),N=m(b.TouchableOpacity),J=m(b.TouchableHighlight),Q=m(b.TouchableWithoutFeedback),X=m(b.Pressable),O=m(b.ScrollView),ee=m(b.Modal),te=m(b.Switch),re=m(b.ActivityIndicator),ae=m(b.Button),oe=b.findNodeHandle,ie={alert(e,t,a,n){if(typeof document>"u")return;let s=document.createElement("dialog");s.dataset.buoyRoot="",s.setAttribute("aria-label",e),s.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",s.appendChild(r),t){let o=document.createElement("p");o.textContent=t,o.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",s.appendChild(o)}let c=document.createElement("div");c.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let f=a?.length?a:[{text:"OK"}],d=()=>{s.close?.(),s.remove()};for(let o of f){let i=document.createElement("button");i.type="button",i.textContent=o.text??"OK",i.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${o.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,i.onclick=()=>{d(),o.onPress?.()},c.appendChild(i)}s.addEventListener("cancel",o=>{o.preventDefault(),n?.cancelable!==false&&(d(),n?.onDismiss?.())}),s.appendChild(c),document.body.appendChild(s),s.showModal?s.showModal():s.setAttribute("open","")}}});var ne={};H(ne,{clearRecords:()=>ce,computeStats:()=>be,createRecord:()=>le,disableImagesCapture:()=>ue,effectivePixelRatio:()=>U,estDecodedBytes:()=>W,estWastedBytes:()=>z,getRecord:()=>V,getSnapshot:()=>A,neededPixels:()=>M,oversizeFactor:()=>fe,replaceImagesFromSnapshot:()=>pe,subscribe:()=>de,updateRecord:()=>h});function At(){let e=l();e.emitScheduled||(e.emitScheduled=true,requestAnimationFrame(()=>{e.emitScheduled=false;for(let t of e.listeners)t()}))}function I(){let e=l();e.snapshot=[...e.records],At()}function le(e){let t=l(),a={...e,id:t.nextId++,createdAt:Date.now(),status:"pending",mounted:true,loadCount:0};if(t.records.push(a),t.byId.set(a.id,a),t.records.length>F){let n=t.records.splice(0,t.records.length-F);for(let s of n)t.byId.delete(s.id)}return I(),a}function h(e,t){let a=l().byId.get(e);if(a)return Object.assign(a,t),I(),a}function V(e){return l().byId.get(e)}function A(){return l().snapshot}function de(e){return l().listeners.add(e),()=>l().listeners.delete(e)}function ce(){g()?.("clearRecords");let e=l();e.records=e.records.filter(t=>t.mounted&&t.status!=="loaded"&&t.status!=="error"),e.byId=new Map(e.records.map(t=>[t.id,t])),I()}function ue(){l().captureDisabled=true}function pe(e){let t=l(),a=e.records??[],n=0;for(let r of a)r.layout&&r.neededPx&&r.layout.width>n&&(n=r.layout.width,t.mirrorPixelRatio=r.neededPx.width/r.layout.width);let s=Date.now();t.records=[...a].reverse().map(r=>({id:r.id,lib:r.lib,uri:r.uri,sourceKind:r.kind,status:r.status,mounted:r.mounted,createdAt:s-r.ageMs,durationMs:r.ms??void 0,intrinsic:r.intrinsic??void 0,layout:r.layout??void 0,cacheVerdict:r.cache??void 0,cacheVerdictSource:r.cacheSource??void 0,progressSeen:r.progressSeen,bytesLoaded:r.status==="loaded"?r.bytesTotal??void 0:void 0,bytesTotal:r.bytesTotal??void 0,error:r.error??void 0,errorCode:r.errorCode??void 0,loadCount:r.loadCount,overrideLabel:r.overrideLabel??void 0,hasAltText:r.hasAltText??void 0,layoutShifts:r.layoutShifts})),t.byId=new Map(t.records.map(r=>[r.id,r])),e.globalModes&&(t.globalModes={...e.globalModes}),e.captureStatus&&(t.mirrorCaptureStatus=e.captureStatus),I();for(let r of t.actionListeners)r()}function U(){return l().mirrorPixelRatio??C.get()}function M(e){if(!e.layout||e.layout.width<=0||e.layout.height<=0)return null;let t=U();return{width:Math.round(e.layout.width*t),height:Math.round(e.layout.height*t)}}function fe(e){let t=M(e);if(!t||!e.intrinsic)return null;let a=t.width*t.height,n=e.intrinsic.width*e.intrinsic.height;return a<=0||n<=0?null:Math.sqrt(n/a)}function W(e){return e.intrinsic?e.intrinsic.width*e.intrinsic.height*4:0}function z(e){let t=M(e);if(!t||!e.intrinsic)return 0;let a=(e.intrinsic.width*e.intrinsic.height-t.width*t.height)*4;return Math.max(0,a)}function be(e){let t={total:e.length,loading:0,loaded:0,errors:0,networkLoads:0,estDecodedBytes:0,estWastedBytes:0};for(let a of e)(a.status==="loading"||a.status==="pending")&&a.mounted&&t.loading++,a.status==="loaded"&&t.loaded++,a.status==="error"&&t.errors++,(a.progressSeen||a.cacheVerdict==="none")&&t.networkLoads++,a.mounted&&a.status==="loaded"&&(t.estDecodedBytes+=W(a),t.estWastedBytes+=z(a));return t}var F,j=S(()=>{"use strict";v();se();T();x();F=500});v();T();x();j();function he(){for(let e of l().actionListeners)e()}function me(e){let t=l();if(e!=null){t.expoInstances.get(e)?.forceUpdate?.();return}for(let a of t.expoInstances.values())a?.forceUpdate?.()}function k(e){let t=l();t.recordVersions.set(e,++t.versionCounter),he(),me(e)}function ge(){let e=l();e.globalVersion=++e.versionCounter,he(),me()}function kt(e,t){return t.type==="url"?{id:e,kind:"url",uri:t.uri}:{id:e,kind:t.type}}function ye(e,t){l().overrides.set(e,t),h(e,{overrideLabel:t.label}),k(e)}function Lt(e,t){t.source&&g()?.("setOverride",kt(e,t.source)),ye(e,t)}function ve(e){l().overrides.delete(e),h(e,{overrideLabel:void 0}),k(e)}function It(e){g()?.("clearOverride",{id:e}),ve(e)}function _(e){if(e!=null)return l().overrides.get(e)}function Mt(e){return e.type==="hang"?"loading":e.type}function Rt(e,t){g()?.("massAction",{kind:Mt(e)});let a=0;for(let n of A())n.mounted&&(ye(n.id,{source:e,label:t}),a++);return a}function Et(){g()?.("massAction",{kind:"restore"});let e=new Set(l().overrides.keys());for(let t of A())t.overrideLabel!=null&&e.add(t.id);for(let t of e)ve(t);return e.size}function Tt(e=2500){g()?.("massAction",{kind:"flash"});let t=0;for(let a of A())a.mounted&&(we(a.id,e),t++);return t}function we(e,t=2500){l().flashUntil.set(e,Date.now()+t),k(e),setTimeout(()=>{l().flashUntil.delete(e),k(e)},t+50)}function Ct(e,t=2500){g()?.("flash",{id:e}),we(e,t)}function Pt(e){g()?.("setNetworkMode",{mode:e}),l().globalModes.network=e,ge()}function Dt(e){g()?.("setBlankImages",{enabled:e}),l().globalModes.blank=e,ge()}function K(){return l().globalModes}v();x();j();var y=new Map,w,Se=0,xe="data:image/png;base64,";function $(e){let t=V(e.id);if(!t)return;let a=l(),n=_(e.id),s=K(),r=e.source;if(s.network==="offline"&&t.sourceKind==="network"&&(r=xe),n?.source){let i=n.source;i.type==="url"?r=i.uri:i.type==="error"?r=xe:r=null,i.type==="hang"&&h(e.id,{status:"loading"})}let c=a.reloadRequests.get(e.id),f=c&&c.nonce!==e.nonce;if(f){if(e.nonce=c.nonce,c.bust&&r&&/^https?:/.test(new URL(r,document.baseURI).href)){let i=new URL(r,document.baseURI);i.searchParams.set("__buoy_reload",String(Date.now())),r=i.href}e.image.removeAttribute("src"),h(e.id,{status:"loading",startedAt:Date.now(),loadCount:t.loadCount+1})}if(s.network==="cold"&&r&&/^https?:/.test(new URL(r,document.baseURI).href)){if(e.coldSource!==r||!e.coldURL||f){e.coldSource=r;let i=new URL(r,document.baseURI);i.searchParams.set("__buoy_reload",`${Date.now()}-${e.nonce}`),e.coldURL=i.href}r=e.coldURL}else e.coldSource=void 0,e.coldURL=void 0;e.appliedSource=r,e.appliedSrcset=r!==e.source?null:e.srcset,e.appliedSrcset===null?e.image.removeAttribute("srcset"):e.image.getAttribute("srcset")!==e.appliedSrcset&&e.image.setAttribute("srcset",e.appliedSrcset),r===null?e.image.removeAttribute("src"):e.image.getAttribute("src")!==r&&e.image.setAttribute("src",r);let d=document.createElement("span").style;d.cssText=e.style??"";let o=n?.extraProps?.contentFit??n?.extraProps?.resizeMode;typeof o=="string"&&(d.objectFit={stretch:"fill",center:"none"}[o]??o),(s.blank||n?.source?.type==="blank")&&(d.opacity="0");for(let[i,p]of Object.entries(n?.style??{})){let u=i.replace(/[A-Z]/g,Le=>`-${Le.toLowerCase()}`);d.setProperty(u,typeof p=="number"&&!["opacity","zIndex","flex","flexGrow","flexShrink"].includes(i)?`${p}px`:String(p))}(a.flashUntil.get(e.id)??0)>Date.now()&&(d.outline="3px solid #ff453a"),e.appliedStyle=d.cssText||null,e.image.getAttribute("style")!==e.appliedStyle&&(e.appliedStyle===null?e.image.removeAttribute("style"):e.image.setAttribute("style",e.appliedStyle))}function Bt(e){if(y.has(e)||e.closest("[data-buoy-root]"))return;let t=e.currentSrc||e.src;if(!t)return;let a=le({lib:"web",uri:t,sourceKind:t.startsWith("data:")?"data":t.startsWith("blob:")?"file":"network",hasAltText:e.hasAttribute("alt")||e.hasAttribute("aria-label")}),n={id:a.id,image:e,source:e.getAttribute("src"),srcset:e.getAttribute("srcset"),style:e.getAttribute("style"),appliedSource:e.getAttribute("src"),appliedSrcset:e.getAttribute("srcset"),appliedStyle:e.getAttribute("style"),nonce:0,dispose(){}},s=()=>{let d=e.getBoundingClientRect(),o=a.layout,i=a.status==="loaded"&&o&&(o.width!==d.width||o.height!==d.height);h(a.id,{layout:{width:d.width,height:d.height},layoutShifts:(a.layoutShifts??0)+(i?1:0)})},r=()=>{let d=performance.getEntriesByName(e.currentSrc||e.src),o=d[d.length-1];h(a.id,{status:"loaded",loadedAt:Date.now(),intrinsic:{width:e.naturalWidth,height:e.naturalHeight},...!_(a.id)?.source&&K().network==="normal"?{uri:e.currentSrc||e.src}:{},durationMs:o?.duration,bytesTotal:o&&o.encodedBodySize>0?o.encodedBodySize:void 0,cacheVerdict:o&&o.transferSize>0?"none":void 0,cacheVerdictSource:o?"event":void 0}),s()},c=()=>h(a.id,{status:"error",erroredAt:Date.now(),error:"The browser could not load this image."});e.addEventListener("load",r),e.addEventListener("error",c);let f=typeof ResizeObserver>"u"?void 0:new ResizeObserver(s);f?.observe(e),n.dispose=()=>{f?.disconnect(),e.removeEventListener("load",r),e.removeEventListener("error",c)},y.set(e,n),s(),h(a.id,{status:"loading",startedAt:Date.now(),loadCount:1}),e.complete&&(e.naturalWidth>0?r():c()),$(n)}function Ae(){let e=l();if(typeof document>"u"||e.captureDisabled||w)return;e.captureInstalled=true;let t=new WeakSet,a=o=>{o.querySelectorAll("img").forEach(Bt);let i=document.createTreeWalker(o,NodeFilter.SHOW_ELEMENT);for(let p=i.nextNode();p;p=i.nextNode()){let u=p.shadowRoot;u&&(t.has(u)||(t.add(u),r.observe(u,s)),a(u))}},n=()=>{for(let[o,i]of y)o.isConnected||(i.dispose(),y.delete(o),h(i.id,{mounted:false}));a(document)},s={childList:true,subtree:true,attributes:true,attributeFilter:["src","srcset","style","alt"]},r=new MutationObserver(o=>{if(l().captureDisabled){ke();return}for(let i of o){let p=i.target,u=y.get(p);!u||i.type!=="attributes"||(i.attributeName==="src"&&p.getAttribute("src")!==u.appliedSource||i.attributeName==="srcset"&&p.getAttribute("srcset")!==u.appliedSrcset?(u.dispose(),y.delete(p),h(u.id,{mounted:false})):i.attributeName==="style"&&p.getAttribute("style")!==u.appliedStyle&&(u.style=p.getAttribute("style"),$(u)))}n()});r.observe(document.documentElement,s);let c=Element.prototype.attachShadow,f=function(o){let i=c.call(this,o);return o.mode==="open"&&!t.has(i)&&(t.add(i),r.observe(i,s)),i};Element.prototype.attachShadow=f;let d=()=>{for(let o of y.values())$(o)};e.actionListeners.add(d),w=()=>{r.disconnect(),e.actionListeners.delete(d),Element.prototype.attachShadow===f&&(Element.prototype.attachShadow=c);for(let o of y.values()){o.dispose();for(let[i,p,u]of[["src",o.source,o.appliedSource],["srcset",o.srcset,o.appliedSrcset],["style",o.style,o.appliedStyle]])o.image.getAttribute(i)===u&&(p===null?o.image.removeAttribute(i):o.image.setAttribute(i,p));h(o.id,{mounted:false})}y.clear(),e.captureInstalled=false},n()}function ke(){w?.(),w=void 0}function Nt(){if(typeof document>"u")return()=>{};Se++===0&&Ae();let e=false;return()=>{e||(e=true,--Se===0&&ke())}}function Ot(){return l().mirrorCaptureStatus??{installed:!!w,rnDecoratorActive:false,rnDecoratorTooLate:false,expoPatched:false,expoAvailable:false,browserObserverActive:!!w}}export{Te as a,v as b,P as c,D as d,B as e,N as f,O as g,C as h,G as i,Y as j,Z as k,se as l,l as m,x as n,Pe as o,g as p,De as q,T as r,h as s,V as t,A as u,de as v,ce as w,ue as x,pe as y,U as z,M as A,fe as B,W as C,z as D,be as E,ne as F,j as G,k as H,Lt as I,It as J,_ as K,Rt as L,Et as M,Tt as N,Ct as O,Pt as P,Dt as Q,K as R,Ae as S,Nt as T,Ot as U};
|
package/lib/web/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use client";import{A as re,B as ye,C as oe,D as ae,E as be,F as mt,G as z,H as gt,I as H,J as ie,K as pt,L as G,M as fe,N as ve,O as xe,P as we,Q as qe,R as j,S as Ge,T as yt,U as _,a as bt,b as y,c as m,d as g,e as ft,f as C,g as vt,h as xt,i as R,j as wt,k as _e,l as E,m as le,n as kt,o as $t,p as V,q as ke,r as J,s as St,t as Je,u as ne,v as $e,w as Se,x as Ct,y as Rt,z as Bt}from"./chunks/chunk-
|
|
1
|
+
"use client";import{A as re,B as ye,C as oe,D as ae,E as be,F as mt,G as z,H as gt,I as H,J as ie,K as pt,L as G,M as fe,N as ve,O as xe,P as we,Q as qe,R as j,S as Ge,T as yt,U as _,a as bt,b as y,c as m,d as g,e as ft,f as C,g as vt,h as xt,i as R,j as wt,k as _e,l as E,m as le,n as kt,o as $t,p as V,q as ke,r as J,s as St,t as Je,u as ne,v as $e,w as Se,x as Ct,y as Rt,z as Bt}from"./chunks/chunk-7LCF4HRE.mjs";y();y();y();y();import{ImagesIcon as Qe,IMAGES_ICON_COLOR as Xe}from"@buoy-gg/shared-ui/web";y();E();import{useEffect as It,useState as Tt}from"react";import{JsModal as Mt,macOSColors as zt,night as se,windowDragProps as Dt,ToolEmptyState as At}from"@buoy-gg/shared-ui/web";y();E();z();y();function de(e){let t=new Map,r=[],o=[],i=0,n=0;for(let a of e)a.mounted&&a.uri&&t.set(a.uri,(t.get(a.uri)??0)+1),a.loadCount>=5&&r.push({id:a.id,uri:a.uri,loadCount:a.loadCount}),(a.layoutShifts??0)>0&&o.push({id:a.id,uri:a.uri,shifts:a.layoutShifts??0}),a.mounted&&a.hasAltText===false&&i++,a.lib==="rn"&&a.mounted&&a.status==="loading"&&n++;return{duplicates:[...t.entries()].filter(([,a])=>a>1).map(([a,s])=>({uri:a,count:s})).sort((a,s)=>s.count-a.count),retryStorms:r.sort((a,s)=>s.loadCount-a.loadCount),queueSaturated:n>4,missingAlt:i,layoutShifters:o}}function Ce(e){let t=[];if(e.duplicates.length>0){let r=e.duplicates.reduce((o,i)=>o+i.count-1,0);t.push(`${e.duplicates.length} duplicate URL${e.duplicates.length>1?"s":""} (${r} redundant loads)`)}return e.retryStorms.length>0&&t.push(`${e.retryStorms.length} retry storm${e.retryStorms.length>1?"s":""}`),e.queueSaturated&&t.push("iOS image queue saturated (>4 loading)"),e.missingAlt>0&&t.push(`${e.missingAlt} missing alt text`),e.layoutShifters.length>0&&t.push(`${e.layoutShifters.length} layout-shifting image${e.layoutShifters.length>1?"s":""}`),t}y();z();import{macOSColors as D,night as Re}from"@buoy-gg/shared-ui/web";function x(e){return e<=0?"0 B":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Q(e){return e==null?"\u2014":e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(2)}s`}function Be(e){if(!e)return"(no source)";let t=e.match(/[?&]unstable_path=([^&?]+)/),r=t?decodeURIComponent(t[1]):e,o=(r.split("?")[0]??r).split("/").filter(Boolean);return o[o.length-1]??r}function ce(e){let t=ye(e);return t==null?{label:"",color:Re.color.textTertiary,factor:t}:t<.9?{label:`${t.toFixed(1)}\xD7 upscaled`,color:D.semantic.info,factor:t}:t<=1.1?{label:"right-sized",color:D.semantic.success,factor:t}:t<=1.5?{label:`${t.toFixed(1)}\xD7 oversized`,color:D.semantic.warning,factor:t}:{label:`${t.toFixed(1)}\xD7 oversized`,color:D.semantic.error,factor:t}}function Pt(e){switch(e.status){case"loaded":return D.semantic.success;case"error":return D.semantic.error;case"loading":return D.semantic.warning;default:return Re.color.textTertiary}}function ue(e){let t=e.cacheVerdict;return t==="memory"||t==="disk/memory"?{label:t.toUpperCase(),color:D.semantic.success}:t==="disk"?{label:"DISK",color:D.semantic.warning}:t==="none"||e.progressSeen?{label:"NETWORK",color:D.semantic.error}:{label:"?",color:Re.color.textTertiary}}function Ye(e){let t=ce(e),r=ue(e),o=re(e),i=oe(e),n=ae(e),a=[];return a.push(`## Image report \u2014 ${Be(e.uri)}`),a.push(""),a.push(`- URI: ${e.uri||"(none)"}`),a.push(`- Library: ${e.lib==="expo"?"expo-image":"RN <Image>"} \xB7 kind: ${e.sourceKind} \xB7 mounted: ${e.mounted?"yes":"no"}`),a.push(`- Status: ${e.status}${e.errorCode?` (HTTP ${e.errorCode})`:""} \xB7 load cycles: ${e.loadCount}`),a.push(`- Cache: ${r.label}${e.cacheVerdictSource?` (via ${e.cacheVerdictSource==="event"?"expo onLoad":"Image.queryCache"})`:""}`),a.push(`- Load time: ${Q(e.durationMs)}${e.displayedAt&&e.loadedAt?` \xB7 decode\u2192display ${Q(Math.max(0,e.displayedAt-e.loadedAt))}`:""}`),e.intrinsic&&a.push(`- Decoded: ${e.intrinsic.width}\xD7${e.intrinsic.height}px${e.mediaType?` (${e.mediaType})`:""}${e.isAnimated?" animated":""} \u2248 ${x(i)} decoded memory`),e.layout&&a.push(`- Displayed: ${Math.round(e.layout.width)}\xD7${Math.round(e.layout.height)}dp @${xt.get()}x (needs ${o?`${o.width}\xD7${o.height}px`:"?"})`),t.label&&a.push(`- Size verdict: ${t.label}${n>0&&o?` \u2014 wasting \u2248${x(n)}; serve ${o.width}\xD7${o.height}`:""}`),e.progressSeen&&a.push(`- Network transfer: ${e.bytesTotal?x(e.bytesTotal):"observed"}`),e.hasAltText===false&&a.push("- Accessibility: MISSING alt/accessibilityLabel"),(e.layoutShifts??0)>0&&a.push(`- Layout shifts after load: ${e.layoutShifts} (reserve explicit dimensions)`),e.error&&(a.push(`- Error: ${e.error}`),e.errorHeaders&&a.push(`- Response headers: ${JSON.stringify(e.errorHeaders)}`)),e.overrideLabel&&a.push(`- Simulation active: ${e.overrideLabel}`),a.join(`
|
|
2
2
|
`)}function Ze(e,t,r,o,i){let n=[];n.push(`## Buoy Images registry (${t.total} records)`),n.push(""),n.push(`${t.loaded} loaded \xB7 ${t.errors} failed \xB7 ${t.loading} in flight \xB7 \u2248${x(t.estDecodedBytes)} decoded`+(t.estWastedBytes>0?` \xB7 ${x(t.estWastedBytes)} wasted on oversized sources`:""));let a=Ce(r);a.length>0&&n.push(`Insights: ${a.join(" \xB7 ")}`),(i.network!=="normal"||i.blank)&&n.push(`Simulation active: network=${i.network}${i.blank?", blank images":""}`),o.rnDecoratorTooLate&&n.push("\u26A0 RN <Image> capture inactive (register import too late)"),n.push(""),n.push("| image | lib | status | cache | ms | decoded px | shown dp | verdict | notes |"),n.push("|---|---|---|---|---|---|---|---|---|");for(let s of e){let u=ce(s),S=ue(s),h=s.intrinsic?`${s.intrinsic.width}\xD7${s.intrinsic.height}`:"\u2013",k=s.layout?`${Math.round(s.layout.width)}\xD7${Math.round(s.layout.height)}`:"\u2013",p=[s.error?`error: ${s.error}`:null,s.overrideLabel?`sim: ${s.overrideLabel}`:null,s.hasAltText===false?"no alt":null,(s.layoutShifts??0)>0?`${s.layoutShifts} layout shifts`:null,s.mounted?null:"unmounted"].filter(Boolean).join("; ");n.push(`| ${Be(s.uri)} | ${s.lib} | ${s.status} | ${S.label} | ${s.durationMs!=null?Math.round(s.durationMs):"\u2013"} | ${h} | ${k} | ${u.label||"\u2013"} | ${p||"\u2013"} |`)}return n.join(`
|
|
3
3
|
`)}y();z();import{useMemo as Lt,useSyncExternalStore as Ot}from"react";function et(){let e=Ot($e,ne,ne);return Lt(()=>({records:[...e].reverse(),stats:be(e)}),[e])}J();z();y();y();function Ie(){return null}function Et(){return null}function Ft(){return null}E();import{useState as Te}from"react";import{macOSColors as B,night as b,monoFont as Wt}from"@buoy-gg/shared-ui/web";y();J();z();var X=new Map;async function Me(e){let t=V();if(t)return await t("proveSavings",{id:e.id});let r=re(e);if(!r)return{ok:false,message:"Measure the displayed image before optimizing it."};try{let o=await fetch(e.uri);if(!o.ok)throw new Error(`Image download returned HTTP ${o.status}.`);let i=await o.blob(),n=await createImageBitmap(i),a=document.createElement("canvas");a.width=Math.max(1,Math.min(n.width,Math.round(r.width))),a.height=Math.max(1,Math.min(n.height,Math.round(r.height)));let s=a.getContext("2d");if(!s)throw n.close(),new Error("Canvas is unavailable.");s.drawImage(n,0,0,a.width,a.height),n.close();let u=await new Promise((p,N)=>a.toBlob(te=>te?p(te):N(new Error("Image encoding failed.")),"image/webp",.8));if(u.type!=="image/webp")return{ok:false,message:"This browser cannot encode WebP images."};let S=X.get(e.id);S&&URL.revokeObjectURL(S);let h=URL.createObjectURL(u);for(X.set(e.id,h);X.size>30;){let[p,N]=X.entries().next().value;URL.revokeObjectURL(N),X.delete(p)}let k=i.size-u.size;return{ok:true,message:"WebP preview created.",originalBytes:i.size,originalBytesSource:"download",optimizedBytes:u.size,optimizedUri:h,optimizedDims:{width:a.width,height:a.height},savedBytes:k,savedPct:i.size?k/i.size*100:0}}catch(o){return{ok:false,message:`Image optimization failed: ${o instanceof Error?o.message:String(o)}`}}}J();z();import{Fragment as Nt,jsx as l,jsxs as w}from"react/jsx-runtime";function F({title:e,children:t}){return w(m,{style:d.section,children:[l(g,{style:d.sectionTitle,children:e}),l(m,{style:d.sectionBody,children:t})]})}function c({label:e,value:t,color:r}){return w(m,{style:d.kvRow,children:[l(g,{style:d.kvLabel,children:e}),l(g,{style:[d.kvValue,r?{color:r}:null],selectable:true,children:t})]})}function tt(e){let t=V();if(t){t("clearExpoCaches",{memory:e==="memory",disk:e==="disk"});return}try{let r=Ie();e==="memory"?r.Image.clearMemoryCache():r.Image.clearDiskCache()}catch{}}function Ht({record:e}){let[t,r]=Te(e.uri),o=t.trim(),i=e.mounted&&o.length>0&&o!==e.uri;return w(F,{title:"SWAP SOURCE URL",children:[l(ft,{style:d.urlInput,value:t,onChangeText:r,placeholder:"https://\u2026",placeholderTextColor:b.color.placeholder,autoCapitalize:"none",autoCorrect:false,multiline:true}),w(m,{style:d.actionsRow,children:[l(C,{style:[d.actionButton,!i&&d.actionDisabled],disabled:!i,onPress:()=>H(e.id,{source:{type:"url",uri:o},label:"URL swapped"}),children:l(g,{style:d.actionText,children:"Apply"})}),l(C,{style:d.actionButton,onPress:()=>r(e.uri),children:l(g,{style:d.actionText,children:"Reset field"})})]})]})}function jt({record:e}){let[t,r]=Te(false),[o,i]=Te(null),n=()=>{r(true),Me(e).then(i).catch(a=>i({ok:false,message:String(a?.message??a)})).finally(()=>r(false))};return l(F,{title:"PROVE SAVINGS (re-encode on device)",children:o==null?l(m,{style:d.actionsRow,children:l(C,{style:d.actionButton,onPress:n,disabled:t,children:l(g,{style:d.actionText,children:t?"Re-encoding\u2026":"Re-encode at displayed size (WebP)"})})}):w(Nt,{children:[l(c,{label:"Result",value:o.message||(o.ok?"done":"failed"),color:o.ok?B.semantic.success:B.semantic.error}),o.originalBytes!=null?l(c,{label:"Original",value:`${x(o.originalBytes)} (${o.originalBytesSource})`}):null,o.optimizedBytes!=null?l(c,{label:"Optimized",value:`${x(o.optimizedBytes)} \u2014 ${o.optimizedDims?.width}\xD7${o.optimizedDims?.height} WebP`,color:B.semantic.success}):null,o.savedBytes!=null?l(c,{label:"Saved",value:`${x(o.savedBytes)} (${o.savedPct}%)`,color:B.semantic.success}):null,w(m,{style:d.actionsRow,children:[o.ok&&o.optimizedUri&&e.mounted?l(C,{style:d.actionButton,onPress:()=>H(e.id,{source:{type:"url",uri:o.optimizedUri},label:"Optimized preview"}),children:l(g,{style:d.actionText,children:"Preview in place"})}):null,l(C,{style:d.actionButton,onPress:n,disabled:t,children:l(g,{style:d.actionText,children:t?"Re-encoding\u2026":"Re-run"})})]})]})})}function Vt({record:e}){let t=ce(e),r=ue(e),o=re(e),i=oe(e),n=ae(e);return w(vt,{style:d.container,contentContainerStyle:d.content,children:[e.overrideLabel?w(m,{style:d.overrideBanner,children:[w(g,{style:d.overrideText,children:["Simulation active: ",e.overrideLabel," \u2014 stats below describe the override, not the original source."]}),l(C,{onPress:()=>ie(e.id),children:l(g,{style:d.overrideRestore,children:"RESTORE"})})]}):null,e.uri&&e.sourceKind!=="data"?l(m,{style:d.previewBox,children:l(_e,{testID:"buoy-internal-images-preview",source:{uri:e.uri},style:d.preview,resizeMode:"contain"})}):null,w(F,{title:"SOURCE",children:[l(c,{label:"URI",value:e.uri||"(none)"}),l(c,{label:"Kind",value:e.sourceKind}),l(c,{label:"Library",value:e.lib==="web"?"Browser <img>":e.lib==="expo"?"expo-image":"RN <Image>"}),e.hasAltText===false?l(c,{label:"Alt text",value:"missing \u2014 add alt/accessibilityLabel",color:B.semantic.warning}):null,e.mediaType!=null?l(c,{label:"Media type",value:String(e.mediaType)}):null,e.isAnimated!=null?l(c,{label:"Animated",value:e.isAnimated?"yes":"no"}):null]}),w(F,{title:"LOAD",children:[l(c,{label:"Status",value:e.status,color:e.status==="error"?B.semantic.error:e.status==="loaded"?B.semantic.success:B.semantic.warning}),l(c,{label:"Duration",value:Q(e.durationMs)}),e.displayedAt&&e.loadedAt?l(c,{label:"Decode \u2192 display",value:Q(Math.max(0,e.displayedAt-e.loadedAt))}):null,l(c,{label:"Cache",value:`${r.label}`,color:r.color}),e.cacheVerdictSource?l(c,{label:"Cache source",value:e.cacheVerdictSource==="event"?"reported by expo-image onLoad":"Image.queryCache after load"}):null,e.progressSeen?l(c,{label:"Downloaded",value:e.bytesTotal?`${x(e.bytesLoaded??0)} / ${x(e.bytesTotal)}`:"network transfer observed"}):null,l(c,{label:"Load cycles",value:String(e.loadCount)}),l(c,{label:"Still mounted",value:e.mounted?"yes":"no"})]}),w(F,{title:"DIMENSIONS",children:[e.intrinsic?l(c,{label:"Decoded",value:`${e.intrinsic.width}\xD7${e.intrinsic.height} px`}):l(c,{label:"Decoded",value:"unknown"}),e.layout?l(c,{label:"Displayed",value:`${Math.round(e.layout.width)}\xD7${Math.round(e.layout.height)} dp (needs ${o?`${o.width}\xD7${o.height}`:"?"} px @${Math.round(Bt()*100)/100}x)`}):l(c,{label:"Displayed",value:"no layout yet"}),t.label?l(c,{label:"Verdict",value:t.label,color:t.color}):null,i>0?l(c,{label:"Est. decoded memory",value:x(i)}):null,n>0?l(c,{label:"Est. wasted",value:`${x(n)} \u2014 resize the source to ${o?`${o.width}\xD7${o.height}`:"the displayed size"}`,color:B.semantic.warning}):null,(e.layoutShifts??0)>0?l(c,{label:"Layout shifts",value:`${e.layoutShifts} \u2014 box resized after load; reserve explicit width/height`,color:B.semantic.warning}):null]}),e.sourceKind==="network"||e.sourceKind==="asset"?l(jt,{record:e},`savings-${e.id}`):null,e.status==="error"?w(F,{title:"ERROR",children:[l(c,{label:"Message",value:e.error??"unknown",color:B.semantic.error}),e.errorCode!=null?l(c,{label:"HTTP status",value:String(e.errorCode)}):null,e.errorHeaders?Object.entries(e.errorHeaders).map(([a,s])=>l(c,{label:a,value:String(s)},a)):null]}):null,e.sourceKind==="network"&&e.mounted?l(Ht,{record:e},e.id):null,e.lib==="expo"?l(F,{title:"CACHE ACTIONS (expo-image, global)",children:w(m,{style:d.actionsRow,children:[l(C,{style:d.actionButton,onPress:()=>tt("memory"),children:l(g,{style:d.actionText,children:"Clear memory cache"})}),l(C,{style:d.actionButton,onPress:()=>tt("disk"),children:l(g,{style:d.actionText,children:"Clear disk cache"})})]})}):null]})}var d=R.create({container:{flex:1},content:{padding:12,gap:12},previewBox:{height:140,borderRadius:8,backgroundColor:b.color.bg,overflow:"hidden"},preview:{width:"100%",height:"100%"},section:{gap:6},sectionTitle:{color:b.color.textTertiary,fontSize:10,fontWeight:"700",letterSpacing:.8},sectionBody:{backgroundColor:b.color.surface,borderRadius:8,borderWidth:R.hairlineWidth,borderColor:b.color.border,paddingHorizontal:10,paddingVertical:4},kvRow:{flexDirection:"row",paddingVertical:5,gap:12},kvLabel:{color:b.color.textSecondary,fontSize:11,width:110},kvValue:{color:b.color.text,fontSize:11,flex:1},actionsRow:{flexDirection:"row",gap:8,paddingVertical:8},actionButton:{backgroundColor:b.color.surfaceElevated,borderRadius:6,paddingHorizontal:10,paddingVertical:6,borderWidth:R.hairlineWidth,borderColor:b.color.border},actionText:{color:b.color.text,fontSize:11,fontWeight:"600"},actionDisabled:{opacity:.4},urlInput:{color:b.color.text,fontSize:11,fontFamily:Wt,backgroundColor:b.color.surfaceElevated,borderRadius:6,borderWidth:R.hairlineWidth,borderColor:b.color.border,paddingHorizontal:8,paddingVertical:6,marginTop:8},overrideBanner:{flexDirection:"row",alignItems:"center",gap:10,padding:10,borderRadius:8,backgroundColor:b.color.warningSoft},overrideText:{flex:1,color:b.color.warning,fontSize:11,lineHeight:15},overrideRestore:{color:b.color.warning,fontSize:11,fontWeight:"700",letterSpacing:.5}});y();E();import{useState as Ut}from"react";import{ChevronLeft as Kt,ChevronRight as qt,FooterButton as ze,FooterMessage as rt,FooterRow as ot,RefreshCw as Gt,ToolFooter as _t,night as W}from"@buoy-gg/shared-ui/web";y();J();kt();function Jt(e){return le().actionListeners.add(e),()=>le().actionListeners.delete(e)}function at(e,t){let r=le(),o=r.reloadRequests.get(e);r.reloadRequests.set(e,{nonce:(o?.nonce??0)+1,bust:t}),gt(e)}function it(){try{return Ie().Image??null}catch{return null}}function Qt(){try{let e=Et(),t=e?.default||e;if(t?.deleteAsync)return t}catch{}try{let e=Ft(),t=e?.default||e;if(t?.deleteAsync)return t}catch{}return null}async function De(e){let t=it(),r=Qt();if(!t?.getCachePathAsync||!r?.deleteAsync||!e.uri)return false;try{let o=await t.getCachePathAsync(e.uri);if(!o)return false;let i=o.startsWith("file://")?o:`file://${o}`;return await r.deleteAsync(i,{idempotent:true}),true}catch{return false}}async function Y(e){let t=V();if(t)return ke(t("retry",{id:e.id}));if(!e.mounted)return{ok:false,message:"Instance unmounted \u2014 cannot reload"};if(e.lib==="expo"){let r=le().expoInstances.get(e.id);return r?.reloadAsync?(await r.reloadAsync(),{ok:true,message:"Reload requested"}):{ok:false,message:"Live instance not reachable"}}return at(e.id,false),{ok:true,message:"Remounting image"}}async function Ae(){let e=V();if(e)return ke(e("massAction",{kind:"reload"}));let{getSnapshot:t}=(z(),bt(mt)),r=0;for(let o of t()){if(!o.mounted)continue;(await he(o)).ok&&r++}return{ok:r>0,message:`Hard-reloading ${r} mounted image${r===1?"":"s"}`}}async function he(e){let t=V();if(t)return ke(t("hardReload",{id:e.id}));if(!e.mounted)return{ok:false,message:"Instance unmounted \u2014 cannot reload"};if(e.sourceKind!=="network")return Y(e);if(e.lib==="expo"){let r=await De(e);await it()?.clearMemoryCache?.().catch?.(()=>false);let o=await Y(e);return o.ok?{ok:true,message:r?"Disk entry evicted, memory cache cleared, refetching":"Memory cache cleared, refetching (no disk entry found)"}:o}return at(e.id,true),{ok:true,message:"Refetching with cache bypassed"}}import{jsx as f,jsxs as Pe}from"react/jsx-runtime";function Xt({record:e,hasPrevious:t,hasNext:r,onPrevious:o,onNext:i}){let[n,a]=Ut(null),s=k=>{a("\u2026"),k().then(p=>a(p.message)).catch(p=>a(String(p?.message??p)))},u=!e.mounted,S=e.overrideLabel!=null,h=(k,p)=>{H(e.id,{source:k,label:p}),a(`${p} \u2014 Restore to undo`)};return Pe(_t,{children:[n?f(rt,{children:n}):u?f(rt,{tone:"muted",children:"Instance unmounted \u2014 reload actions need the image on screen."}):null,Pe(ot,{style:{gap:8},children:[f(C,{onPress:o,disabled:!t,style:[me.navButton,!t&&me.disabled],activeOpacity:.7,accessibilityLabel:"Previous image",children:f(Kt,{size:20,color:t?W.color.accent:W.color.textTertiary})}),f(ze,{label:"Hard reload",size:"md",disabled:u,icon:f(Gt,{size:13,color:u?W.color.textTertiary:W.color.info}),onPress:()=>s(()=>he(e))}),f(ze,{label:e.status==="error"?"Retry":"Reload",size:"md",disabled:u,onPress:()=>s(()=>Y(e))}),f(C,{onPress:i,disabled:!r,style:[me.navButton,!r&&me.disabled],activeOpacity:.7,accessibilityLabel:"Next image",children:f(qt,{size:20,color:r?W.color.accent:W.color.textTertiary})})]}),Pe(ot,{style:{gap:8},children:[f(Z,{label:"Error",disabled:u,onPress:()=>h({type:"error"},"Forced error")}),f(Z,{label:"Loading",disabled:u,onPress:()=>h({type:"hang"},"Forced loading")}),f(Z,{label:"Blank",disabled:u,onPress:()=>h({type:"blank"},"Blanked")}),f(Z,{label:"Find",disabled:u,onPress:()=>{xe(e.id),a("Flashing a red border on the image (2.5s)")}}),f(Z,{label:"Restore",accent:true,disabled:!S,onPress:()=>{ie(e.id),a("Override removed \u2014 original source restored")}})]})]})}function Z({label:e,onPress:t,disabled:r,accent:o}){return f(ze,{label:e,onPress:t,disabled:r,accent:o,style:{paddingVertical:7}})}var me=R.create({navButton:{paddingHorizontal:10,paddingVertical:8,borderRadius:6,backgroundColor:W.color.button,alignItems:"center",justifyContent:"center"},disabled:{opacity:.4}});y();E();import{macOSColors as Yt,night as A,Pill as Le}from"@buoy-gg/shared-ui/web";import{jsx as I,jsxs as ee}from"react/jsx-runtime";function Zt({record:e,onPress:t}){let r=ce(e),o=ue(e),i=e.sourceKind==="network"||e.sourceKind==="asset"||e.sourceKind==="file";return ee(C,{style:$.row,testID:`buoy-image-row-${e.id}`,onPress:()=>t(e.id),children:[ee(m,{style:$.thumbBox,children:[i&&e.uri?I(_e,{testID:"buoy-internal-images-thumb",source:{uri:e.uri},style:$.thumb,resizeMode:"cover"}):I(g,{style:$.thumbFallback,children:"?"}),I(m,{style:[$.statusDot,{backgroundColor:Pt(e)}]})]}),ee(m,{style:$.main,children:[I(g,{style:$.name,numberOfLines:1,children:Be(e.uri)}),ee(m,{style:$.metaRow,children:[I(Le,{variant:"text",label:e.lib==="web"?"WEB":e.lib==="expo"?"EXPO":"RN",color:A.color.textTertiary}),I(Le,{variant:"text",label:o.label,color:o.color}),e.overrideLabel?I(Le,{variant:"text",label:"SIM",color:A.color.warning}):null,I(g,{style:$.meta,children:Q(e.durationMs)}),e.intrinsic?ee(g,{style:$.meta,children:[e.intrinsic.width,"\xD7",e.intrinsic.height]}):null]})]}),I(m,{style:$.right,children:e.status==="error"?I(g,{style:[$.verdict,{color:Yt.semantic.error}],children:"FAILED"}):r.label?I(g,{style:[$.verdict,{color:r.color}],children:r.label}):null})]})}var $=R.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:R.hairlineWidth,borderBottomColor:A.color.border,gap:10},thumbBox:{width:40,height:40,borderRadius:6,backgroundColor:A.color.bg,alignItems:"center",justifyContent:"center",overflow:"hidden"},thumb:{width:40,height:40},thumbFallback:{color:A.color.textTertiary,fontSize:16,fontWeight:"700"},statusDot:{position:"absolute",right:2,bottom:2,width:8,height:8,borderRadius:4,borderWidth:1,borderColor:A.color.bg},main:{flex:1,gap:2},name:{color:A.color.text,fontSize:12,fontWeight:"600"},metaRow:{flexDirection:"row",alignItems:"center",gap:8},meta:{color:A.color.textSecondary,fontSize:10,fontVariant:["tabular-nums"]},right:{alignItems:"flex-end"},verdict:{fontSize:10,fontWeight:"700"}});y();import{ModalHeader as P,ToolbarClearButton as er,ToolbarCopyButton as lt}from"@buoy-gg/shared-ui/web";import{jsx as L,jsxs as Oe}from"react/jsx-runtime";function tr({stats:e,detailOpen:t,detailIndex:r=-1,detailTotal:o=0,onCloseDetail:i,onClear:n,getReport:a,onBack:s}){if(t){let S=r>=0&&o>0?`${r+1} of ${o}`:void 0;return Oe(P,{children:[L(P.Navigation,{onBack:i}),L(P.Content,{title:"Image detail",subtitle:S}),L(P.Actions,{children:L(lt,{value:a})})]})}let u=[`${e.total} images`,`${e.errors} failed`,`\u2248${x(e.estDecodedBytes)} decoded`];return e.estWastedBytes>0&&u.push(`${x(e.estWastedBytes)} wasted`),Oe(P,{children:[s?L(P.Navigation,{onBack:s}):null,L(P.Content,{title:"Images",subtitle:u.join(" \xB7 ")}),Oe(P.Actions,{children:[L(lt,{value:a}),L(er,{onPress:n})]})]})}y();E();import{useState as rr,useSyncExternalStore as or}from"react";import{FooterButton as nt,FooterCaption as ar,FooterMessage as ir,FooterRow as st,ToolFooter as lr,night as nr}from"@buoy-gg/shared-ui/web";import{jsx as T,jsxs as Ee}from"react/jsx-runtime";var sr=[{key:"normal",label:"Normal"},{key:"offline",label:"Offline"},{key:"cold",label:"Cold"}];function dr(){let[e,t]=rr(null),r=or(Jt,()=>j().network),o=(i,n)=>{let a=G(i,n);t(a>0?`${n} on ${a} image${a===1?"":"s"} \u2014 Restore all to undo`:"No mounted images")};return Ee(lr,{paddingBottom:10,style:{paddingTop:8},children:[e?T(ir,{children:e}):T(ar,{children:"MASS ACTIONS \u2014 every image on screen"}),Ee(st,{children:[T(U,{label:"Error",onPress:()=>o({type:"error"},"Forced error")}),T(U,{label:"Loading",onPress:()=>o({type:"hang"},"Forced loading")}),T(U,{label:"Blank",onPress:()=>o({type:"blank"},"Blanked")}),T(U,{label:"Reload",onPress:()=>{t("\u2026"),Ae().then(i=>t(i.message))}}),T(U,{label:"Find",onPress:()=>{let i=ve();t(`Flashing ${i} image${i===1?"":"s"} (2.5s)`)}}),T(U,{label:"Restore",accent:true,onPress:()=>{let i=fe();t(i>0?`Restored ${i} image${i===1?"":"s"}`:"No overrides active")}})]}),Ee(st,{children:[T(g,{style:cr.netLabel,children:"NET"}),sr.map(i=>{let n=r===i.key;return T(nt,{label:i.label,active:n,style:{paddingVertical:6},onPress:()=>{we(i.key),t(i.key==="normal"?"Network simulation off \u2014 tap RELOAD to load normally again":i.key==="offline"?"Offline: network images FAIL (bundled assets still load) \u2014 tap RELOAD to apply to on-screen images":"Cold (bypass caches) \u2014 tap RELOAD: everything refetches like first launch")}},i.key)})]})]})}function U({label:e,onPress:t,accent:r}){return T(nt,{label:e,onPress:t,accent:r})}var cr=R.create({netLabel:{color:nr.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.8,alignSelf:"center",marginRight:2}});y();E();import{night as Fe}from"@buoy-gg/shared-ui/web";import{jsx as We}from"react/jsx-runtime";function ur({insights:e}){let t=Ce(e);return t.length===0?null:We(m,{style:Ne.bar,children:t.map(r=>We(m,{style:Ne.chip,children:We(g,{style:Ne.chipText,children:r})},r))})}var Ne=R.create({bar:{flexDirection:"row",flexWrap:"wrap",gap:6,paddingHorizontal:10,paddingVertical:8,borderBottomWidth:R.hairlineWidth,borderBottomColor:Fe.color.border},chip:{backgroundColor:Fe.color.warningSoft,borderRadius:999,paddingHorizontal:10,paddingVertical:5},chipText:{color:Fe.color.warning,fontSize:10,fontWeight:"600",lineHeight:13}});import{jsx as v,jsxs as He}from"react/jsx-runtime";function hr(){let e=_(),t=[];return e.rnDecoratorTooLate&&t.push('RN <Image> instrumentation missed the module-load race \u2014 add `import "@buoy-gg/images/register"` as the FIRST import of your entry file.'),!e.browserObserverActive&&!e.expoAvailable&&!e.rnDecoratorActive&&!e.rnDecoratorTooLate&&t.push("Waiting for images\u2026 render some <Image> components to populate the list."),t.length===0?null:v(m,{style:K.notice,children:t.map(r=>v(g,{style:K.noticeText,children:r},r))})}function mr(){return v(At,{testID:"buoy-images-empty",otto:"listening",title:"No images captured yet",message:"Every RN <Image> and expo-image load is recorded here with cache verdicts, timings, and oversize checks."})}function je({visible:e,onClose:t,onBack:r,onMinimize:o,persistenceKey:i,inline:n=false}){Ge();let{records:a,stats:s}=et(),[u,S]=Tt(null),h=u!=null?Je(u):void 0,k=h?.status==="error"&&h.errorHeaders==null?h.id:null;It(()=>{let M=V();if(k==null||!M)return;let q=false;return M("getDetail",{id:k}).then(ut=>{if(q)return;let ht=ut?.errorHeaders;St(k,{errorHeaders:ht??{}})}).catch(()=>{}),()=>{q=true}},[k]);let p=h?a.findIndex(M=>M.id===h.id):-1,N=M=>{let q=a[M];q&&S(q.id)},te=()=>h?Ye(h):Ze(a,s,de(a),_(),j()),Ue=v(tr,{stats:s,detailOpen:h!=null,detailIndex:p,detailTotal:a.length,onCloseDetail:()=>S(null),onClear:Se,getReport:te,onBack:r}),Ke=h?He(m,{style:K.detailContainer,children:[v(Vt,{record:h}),v(Xt,{record:h,hasPrevious:p>0,hasNext:p>=0&&p<a.length-1,onPrevious:()=>N(p-1),onNext:()=>N(p+1)},h.id)]}):He(m,{style:K.listContainer,children:[v(ur,{insights:de(a)}),v(hr,{}),v(wt,{data:a,keyExtractor:M=>String(M.id),renderItem:({item:M})=>v(Zt,{record:M,onPress:S}),ListEmptyComponent:v(mr,{})}),v(dr,{})]});return n?He(m,{style:K.inlineRoot,children:[v(m,{style:K.inlineHeader,...Dt,children:Ue}),Ke]}):v(Mt,{visible:e,onClose:t,onMinimize:o,persistenceKey:i,header:{showToggleButton:true,customContent:Ue},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:Ke})}function gr(e={}){return v(je,{...e,inline:true,visible:true,onClose:()=>{}})}var K=R.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:zt.border.default,backgroundColor:"transparent"},listContainer:{flex:1},detailContainer:{flex:1},notice:{margin:10,padding:10,borderRadius:8,backgroundColor:se.color.warningSoft,gap:4},noticeText:{color:se.color.warning,fontSize:11},empty:{alignItems:"center",padding:32,gap:8},emptyTitle:{color:se.color.text,fontSize:13,fontWeight:"600"},emptyText:{color:se.color.textSecondary,fontSize:11,textAlign:"center",lineHeight:16}});import{createToolFactory as pr,defineToolPreset as yr}from"@buoy-gg/shared-ui/web";import{jsx as br}from"react/jsx-runtime";var dt=yr({id:"images",name:"IMAGES",description:"Image loads, caching, failures, and oversize checks",slot:"both",icon:({size:e,color:t})=>br(Qe,{size:e,color:t||Xe}),component:je}),fr=pr(dt);y();import{useEffect as vr}from"react";function xr(){return vr(yt,[]),null}y();z();var ge=2*1024;function pe(e){if(!e)return e;if(e.startsWith("data:")){let t=e.indexOf(","),r=t>=0?e.slice(0,Math.min(t+1,64)):"data:",o=t>=0?e.slice(t+1):e,i=o.length>16?`${o.slice(0,8)}\u2026${o.slice(-8)}`:o;return`${r}[${e.length} chars ${i}]`}return e.length<=ge?e:`${e.slice(0,ge)}\u2026 [${e.length-ge} more]`}function wr(e,t=ge){return e?e.length<=t?e:`${e.slice(0,t)}\u2026 [${e.length-t} more]`:null}function kr(e){return{...e,duplicates:e.duplicates.map(t=>({...t,uri:pe(t.uri)})),retryStorms:e.retryStorms.map(t=>({...t,uri:pe(t.uri)})),layoutShifters:e.layoutShifters.map(t=>({...t,uri:pe(t.uri)}))}}function Ve(e){let t=ye(e);return{id:e.id,lib:e.lib,uri:pe(e.uri),kind:e.sourceKind,status:e.status,mounted:e.mounted,cache:e.cacheVerdict??null,cacheSource:e.cacheVerdictSource??null,ms:e.durationMs!=null?Math.round(e.durationMs):null,intrinsic:e.intrinsic??null,layout:e.layout?{width:Math.round(e.layout.width),height:Math.round(e.layout.height)}:null,neededPx:re(e),oversizeFactor:t!=null?Math.round(t*100)/100:null,decodedKB:Math.round(oe(e)/1024),wastedKB:Math.round(ae(e)/1024),progressSeen:e.progressSeen===true,bytesTotal:e.bytesTotal??null,error:wr(e.error),errorCode:e.errorCode??null,loadCount:e.loadCount,overrideLabel:e.overrideLabel??null,hasAltText:e.hasAltText??null,layoutShifts:e.layoutShifts??0,ageMs:Date.now()-e.createdAt}}function O(e){let t=e?.id;if(typeof t!="number")throw new Error("Missing numeric `id` param");let r=Je(t);if(!r)throw new Error(`Image record ${t} not found (cleared or evicted) \u2014 re-run the list action for current ids.`);return r}function ct(){let e=ne();return{stats:be(e),captureStatus:_(),globalModes:j(),insights:kr(de(e)),records:[...e].reverse()}}var $r={version:1,getSnapshot:()=>{let{records:e,...t}=ct();return{...t,records:e.slice(0,100).map(Ve)}},subscribe:e=>$e(e),actions:{list:e=>{let t=e??{},r=Math.min(Math.max(t.limit??50,1),200),{records:o,...i}=ct(),n=t.status?o.filter(a=>a.status===t.status):o;return{...i,total:n.length,records:n.slice(0,r).map(Ve)}},getDetail:e=>{let t=O(e);return{...Ve(t),errorHeaders:t.errorHeaders??null}},hardReload:e=>he(O(e)),proveSavings:e=>Me(O(e)),retry:e=>Y(O(e)),evictDisk:async e=>{let t=O(e),r=await De(t);return{ok:r,message:r?"Disk cache entry deleted":"No disk entry found (expo-image + expo-file-system required)"}},flash:e=>(xe(O(e).id),{ok:true,message:"Flashing for 2.5s"}),setOverride:e=>{let t=O(e),r=e,o={error:{source:{type:"error"},label:"Forced error"},hang:{source:{type:"hang"},label:"Forced loading"},blank:{source:{type:"blank"},label:"Blanked"}};if(r.kind==="url"){if(!r.uri)throw new Error("kind 'url' requires a `uri` param");return H(t.id,{source:{type:"url",uri:r.uri},label:"URL swapped"}),{ok:true,message:`Source overridden to ${r.uri}`}}let i=r.kind?o[r.kind]:void 0;if(!i)throw new Error(`Unknown override kind: ${String(r.kind)}`);return t.mounted?(H(t.id,i),{ok:true,message:`${i.label} applied`}):{ok:false,message:"Instance unmounted \u2014 overrides need the image on screen"}},clearOverride:e=>(ie(O(e).id),{ok:true,message:"Override removed \u2014 original source restored"}),massAction:async e=>{let t=e?.kind;switch(t){case"error":{let r=G({type:"error"},"Forced error");return{ok:r>0,message:`Forced error on ${r} images`}}case"loading":{let r=G({type:"hang"},"Forced loading");return{ok:r>0,message:`Forced loading on ${r} images`}}case"blank":{let r=G({type:"blank"},"Blanked");return{ok:r>0,message:`Blanked ${r} images`}}case"reload":return Ae();case"flash":{let r=ve();return{ok:r>0,message:`Flashing ${r} images`}}case"restore":return{ok:true,message:`Restored ${fe()} images`};default:throw new Error(`Unknown mass kind: ${String(t)}`)}},setNetworkMode:e=>{let t=e?.mode;if(t!=="normal"&&t!=="offline"&&t!=="cold")throw new Error("mode must be 'normal' | 'offline' | 'cold'");return we(t),{ok:true,modes:j()}},setBlankImages:e=>(qe(e?.enabled===true),{ok:true,modes:j()}),clearRecords:()=>(Se(),{ok:true,message:"Registry cleared"}),clearExpoCaches:async e=>{let t=e??{},r=t.memory!==false,o=t.disk!==false;try{let i=Ie(),n=[];return r&&(await i.Image.clearMemoryCache(),n.push("memory")),o&&(await i.Image.clearDiskCache(),n.push("disk")),{ok:true,message:`Cleared expo-image ${n.join(" + ")} cache`}}catch{return{ok:false,message:"expo-image not installed"}}},getCaptureStatus:()=>_()}};z();J();z();export{Xe as IMAGES_ICON_COLOR,Qe as ImagesIcon,je as ImagesModal,xr as ImagesRoot,gr as ImagesToolView,fe as clearAllOverrides,ie as clearOverride,Se as clearRecords,de as computeInsights,be as computeStats,fr as createImagesTool,Ct as disableImagesCapture,oe as estDecodedBytes,ae as estWastedBytes,De as evictExpoDiskEntry,ve as flashAllMounted,xe as flashRecord,Ye as formatRecordMarkdown,Ze as formatRegistryMarkdown,_ as getCaptureStatus,j as getGlobalModes,ne as getImageRecords,pt as getOverride,Ae as hardReloadAllMounted,he as hardReloadRecord,$r as imagesSyncAdapter,dt as imagesToolPreset,Ce as insightChips,Ge as installImageCapture,ye as oversizeFactor,Me as proveSavings,Rt as replaceImagesFromSnapshot,Y as retryRecord,qe as setBlankImages,we as setNetworkMode,H as setOverride,G as setOverrideForAllMounted,$t as setRemoteImagesHandler,$e as subscribeImageRecords,et as useImageRecords};
|
package/lib/web/register.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{S as a,b as m}from"./chunks/chunk-
|
|
1
|
+
"use client";import{S as a,b as m}from"./chunks/chunk-7LCF4HRE.mjs";m();a();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buoy-gg/images",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.57",
|
|
4
4
|
"description": "Inspect instrumented React Native Image and expo-image loads, available cache and timing data, failures, and image-size estimates.",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"**/autoCapture.*"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@buoy-gg/shared-ui": "^7.0.
|
|
22
|
+
"@buoy-gg/shared-ui": "^7.0.57"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"react": "*"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use client";var M=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var Me=Object.getOwnPropertyNames;var Re=Object.prototype.hasOwnProperty;var v=(e,t)=>()=>(e&&(t=e(e=0)),t);var $=(e,t)=>{for(var a in t)M(e,a,{get:t[a],enumerable:true})},R=(e,t,a,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Me(t))!Re.call(e,o)&&o!==a&&M(e,o,{get:()=>t[o],enumerable:!(i=Ie(t,o))||i.enumerable});return e},Ce=(e,t,a)=>(R(e,t,"default"),a&&R(a,t,"default"));var Te=e=>R(M({},"__esModule",{value:true}),e);var m=v(()=>{"use strict";typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis)});function s(){let e=globalThis;return e[A]||(e[A]={records:[],byId:new Map,nextId:1,listeners:new Set,snapshot:[],emitScheduled:false,captureInstalled:false,rnInstalled:false,expoInstalled:false,decoratorRegistered:false,decoratorInvoked:false,attachSeen:0,expoAvailable:false,expoPatched:false,reloadRequests:new Map,actionListeners:new Set,expoInstances:new Map,overrides:new Map,flashUntil:new Map,recordVersions:new Map,globalVersion:0,versionCounter:0,globalModes:{network:"normal",blank:false},captureDisabled:false,remoteDispatch:null,mirrorPixelRatio:null,mirrorCaptureStatus:null}),e[A]}var A,w=v(()=>{"use strict";m();A=Symbol.for("buoy.images.globalState.v1")});function De(e){s().remoteDispatch=e}function h(){return s().remoteDispatch}async function Pe(e){try{let t=await e;return{ok:!!t?.ok,message:String(t?.message??"")}}catch(t){return{ok:false,message:String(t?.message??t)}}}var C=v(()=>{"use strict";m();w()});var H={};$(H,{AccessibilityInfo:()=>Oe,ActivityIndicator:()=>te,Alert:()=>oe,Animated:()=>Ue,AppRegistry:()=>je,AppState:()=>ze,Appearance:()=>Ne,BackHandler:()=>Fe,Button:()=>re,CheckBox:()=>rt,Clipboard:()=>We,DeviceEventEmitter:()=>gt,Dimensions:()=>Ke,Easing:()=>_e,FlatList:()=>G,I18nManager:()=>$e,Image:()=>Y,ImageBackground:()=>at,InteractionManager:()=>qe,Keyboard:()=>He,KeyboardAvoidingView:()=>ot,LayoutAnimation:()=>Ge,Linking:()=>Ye,LogBox:()=>ht,Modal:()=>X,NativeEventEmitter:()=>Ze,NativeModules:()=>Ve,PanResponder:()=>Je,Picker:()=>it,PixelRatio:()=>T,Platform:()=>Qe,Pressable:()=>Q,ProgressBar:()=>st,RefreshControl:()=>nt,SafeAreaView:()=>lt,ScrollView:()=>V,SectionList:()=>dt,Share:()=>Xe,StatusBar:()=>ct,StyleSheet:()=>q,Switch:()=>ee,Text:()=>P,TextInput:()=>E,Touchable:()=>ut,TouchableHighlight:()=>Z,TouchableNativeFeedback:()=>pt,TouchableOpacity:()=>B,TouchableWithoutFeedback:()=>J,UIManager:()=>et,Vibration:()=>tt,View:()=>D,VirtualizedList:()=>ft,YellowBox:()=>bt,findNodeHandle:()=>ae,unstable_createElement:()=>Be,useColorScheme:()=>mt,useLocaleContext:()=>yt,useWindowDimensions:()=>vt});import*as Ee from"react-native-web";import{unstable_createElement as Be,NativeModules as Ve,AccessibilityInfo as Oe,Animated as Ue,Appearance as Ne,AppRegistry as je,AppState as ze,BackHandler as Fe,Clipboard as We,Dimensions as Ke,Easing as _e,I18nManager as $e,Keyboard as He,InteractionManager as qe,LayoutAnimation as Ge,Linking as Ye,NativeEventEmitter as Ze,PanResponder as Je,PixelRatio as T,Platform as Qe,Share as Xe,StyleSheet as q,UIManager as et,Vibration as tt,CheckBox as rt,FlatList as G,Image as Y,ImageBackground as at,KeyboardAvoidingView as ot,Picker as it,ProgressBar as st,RefreshControl as nt,SafeAreaView as lt,SectionList as dt,StatusBar as ct,Touchable as ut,TouchableNativeFeedback as pt,VirtualizedList as ft,YellowBox as bt,LogBox as ht,DeviceEventEmitter as gt,useColorScheme as mt,useLocaleContext as yt,useWindowDimensions as vt}from"react-native-web";import*as p from"react-native-web";import{createElement as wt,forwardRef as St}from"react";function b(e){let t=St((i,o)=>{let{accessibilityState:r,accessibilityValue:l,...c}=i;for(let d of["busy","checked","disabled","expanded","selected"])r?.[d]!==void 0&&c[`aria-${d}`]===void 0&&(c[`aria-${d}`]=r[d]);for(let[d,n]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))l?.[d]!==void 0&&c[`aria-${n}`]===void 0&&(c[`aria-${n}`]=l[d]);return wt(e,{...c,ref:o})}),a=e.State;return a&&Object.assign(t,{State:a}),t.displayName=e.displayName??e.name??"NativeWebView",t}var D,P,E,B,Z,J,Q,V,X,ee,te,re,ae,oe,ie=v(()=>{m();Ce(H,Ee);D=b(p.View),P=b(p.Text),E=b(p.TextInput),B=b(p.TouchableOpacity),Z=b(p.TouchableHighlight),J=b(p.TouchableWithoutFeedback),Q=b(p.Pressable),V=b(p.ScrollView),X=b(p.Modal),ee=b(p.Switch),te=b(p.ActivityIndicator),re=b(p.Button),ae=p.findNodeHandle,oe={alert(e,t,a,i){if(typeof document>"u")return;let o=document.createElement("dialog");o.dataset.buoyRoot="",o.setAttribute("aria-label",e),o.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",o.appendChild(r),t){let n=document.createElement("p");n.textContent=t,n.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(n)}let l=document.createElement("div");l.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let c=a?.length?a:[{text:"OK"}],d=()=>{o.close?.(),o.remove()};for(let n of c){let u=document.createElement("button");u.type="button",u.textContent=n.text??"OK",u.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${n.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,u.onclick=()=>{d(),n.onPress?.()},l.appendChild(u)}o.addEventListener("cancel",n=>{n.preventDefault(),i?.cancelable!==false&&(d(),i?.onDismiss?.())}),o.appendChild(l),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}}});var se={};$(se,{clearRecords:()=>de,computeStats:()=>fe,createRecord:()=>ne,disableImagesCapture:()=>ce,effectivePixelRatio:()=>U,estDecodedBytes:()=>N,estWastedBytes:()=>j,getRecord:()=>O,getSnapshot:()=>S,neededPixels:()=>L,oversizeFactor:()=>pe,replaceImagesFromSnapshot:()=>ue,subscribe:()=>le,updateRecord:()=>f});function xt(){let e=s();e.emitScheduled||(e.emitScheduled=true,requestAnimationFrame(()=>{e.emitScheduled=false;for(let t of e.listeners)t()}))}function k(){let e=s();e.snapshot=[...e.records],xt()}function ne(e){let t=s(),a={...e,id:t.nextId++,createdAt:Date.now(),status:"pending",mounted:true,loadCount:0};if(t.records.push(a),t.byId.set(a.id,a),t.records.length>z){let i=t.records.splice(0,t.records.length-z);for(let o of i)t.byId.delete(o.id)}return k(),a}function f(e,t){let a=s().byId.get(e);if(a)return Object.assign(a,t),k(),a}function O(e){return s().byId.get(e)}function S(){return s().snapshot}function le(e){return s().listeners.add(e),()=>s().listeners.delete(e)}function de(){h()?.("clearRecords");let e=s();e.records=e.records.filter(t=>t.mounted&&t.status!=="loaded"&&t.status!=="error"),e.byId=new Map(e.records.map(t=>[t.id,t])),k()}function ce(){s().captureDisabled=true}function ue(e){let t=s(),a=e.records??[],i=0;for(let r of a)r.layout&&r.neededPx&&r.layout.width>i&&(i=r.layout.width,t.mirrorPixelRatio=r.neededPx.width/r.layout.width);let o=Date.now();t.records=[...a].reverse().map(r=>({id:r.id,lib:r.lib,uri:r.uri,sourceKind:r.kind,status:r.status,mounted:r.mounted,createdAt:o-r.ageMs,durationMs:r.ms??void 0,intrinsic:r.intrinsic??void 0,layout:r.layout??void 0,cacheVerdict:r.cache??void 0,cacheVerdictSource:r.cacheSource??void 0,progressSeen:r.progressSeen,bytesLoaded:r.status==="loaded"?r.bytesTotal??void 0:void 0,bytesTotal:r.bytesTotal??void 0,error:r.error??void 0,errorCode:r.errorCode??void 0,loadCount:r.loadCount,overrideLabel:r.overrideLabel??void 0,hasAltText:r.hasAltText??void 0,layoutShifts:r.layoutShifts})),t.byId=new Map(t.records.map(r=>[r.id,r])),e.globalModes&&(t.globalModes={...e.globalModes}),e.captureStatus&&(t.mirrorCaptureStatus=e.captureStatus),k();for(let r of t.actionListeners)r()}function U(){return s().mirrorPixelRatio??T.get()}function L(e){if(!e.layout||e.layout.width<=0||e.layout.height<=0)return null;let t=U();return{width:Math.round(e.layout.width*t),height:Math.round(e.layout.height*t)}}function pe(e){let t=L(e);if(!t||!e.intrinsic)return null;let a=t.width*t.height,i=e.intrinsic.width*e.intrinsic.height;return a<=0||i<=0?null:Math.sqrt(i/a)}function N(e){return e.intrinsic?e.intrinsic.width*e.intrinsic.height*4:0}function j(e){let t=L(e);if(!t||!e.intrinsic)return 0;let a=(e.intrinsic.width*e.intrinsic.height-t.width*t.height)*4;return Math.max(0,a)}function fe(e){let t={total:e.length,loading:0,loaded:0,errors:0,networkLoads:0,estDecodedBytes:0,estWastedBytes:0};for(let a of e)(a.status==="loading"||a.status==="pending")&&a.mounted&&t.loading++,a.status==="loaded"&&t.loaded++,a.status==="error"&&t.errors++,(a.progressSeen||a.cacheVerdict==="none")&&t.networkLoads++,a.mounted&&a.status==="loaded"&&(t.estDecodedBytes+=N(a),t.estWastedBytes+=j(a));return t}var z,F=v(()=>{"use strict";m();ie();C();w();z=500});m();C();w();F();function be(){for(let e of s().actionListeners)e()}function he(e){let t=s();if(e!=null){t.expoInstances.get(e)?.forceUpdate?.();return}for(let a of t.expoInstances.values())a?.forceUpdate?.()}function x(e){let t=s();t.recordVersions.set(e,++t.versionCounter),be(),he(e)}function ge(){let e=s();e.globalVersion=++e.versionCounter,be(),he()}function At(e,t){return t.type==="url"?{id:e,kind:"url",uri:t.uri}:{id:e,kind:t.type}}function me(e,t){s().overrides.set(e,t),f(e,{overrideLabel:t.label}),x(e)}function kt(e,t){t.source&&h()?.("setOverride",At(e,t.source)),me(e,t)}function ye(e){s().overrides.delete(e),f(e,{overrideLabel:void 0}),x(e)}function Lt(e){h()?.("clearOverride",{id:e}),ye(e)}function W(e){if(e!=null)return s().overrides.get(e)}function It(e){return e.type==="hang"?"loading":e.type}function Mt(e,t){h()?.("massAction",{kind:It(e)});let a=0;for(let i of S())i.mounted&&(me(i.id,{source:e,label:t}),a++);return a}function Rt(){h()?.("massAction",{kind:"restore"});let e=new Set(s().overrides.keys());for(let t of S())t.overrideLabel!=null&&e.add(t.id);for(let t of e)ye(t);return e.size}function Ct(e=2500){h()?.("massAction",{kind:"flash"});let t=0;for(let a of S())a.mounted&&(ve(a.id,e),t++);return t}function ve(e,t=2500){s().flashUntil.set(e,Date.now()+t),x(e),setTimeout(()=>{s().flashUntil.delete(e),x(e)},t+50)}function Tt(e,t=2500){h()?.("flash",{id:e}),ve(e,t)}function Dt(e){h()?.("setNetworkMode",{mode:e}),s().globalModes.network=e,ge()}function Pt(e){h()?.("setBlankImages",{enabled:e}),s().globalModes.blank=e,ge()}function K(){return s().globalModes}m();w();F();var g=new Map,y,we=0,Se="data:image/png;base64,";function _(e){let t=O(e.id);if(!t)return;let a=s(),i=W(e.id),o=K(),r=e.source;if(o.network==="offline"&&t.sourceKind==="network"&&(r=Se),i?.source){let u=i.source;u.type==="url"?r=u.uri:u.type==="error"?r=Se:r=null,u.type==="hang"&&f(e.id,{status:"loading"})}let l=a.reloadRequests.get(e.id),c=l&&l.nonce!==e.nonce;if(c){if(e.nonce=l.nonce,l.bust&&r&&/^https?:/.test(new URL(r,document.baseURI).href)){let u=new URL(r,document.baseURI);u.searchParams.set("__buoy_reload",String(Date.now())),r=u.href}e.image.removeAttribute("src"),f(e.id,{status:"loading",startedAt:Date.now(),loadCount:t.loadCount+1})}if(o.network==="cold"&&r&&/^https?:/.test(new URL(r,document.baseURI).href)){if(e.coldSource!==r||!e.coldURL||c){e.coldSource=r;let u=new URL(r,document.baseURI);u.searchParams.set("__buoy_reload",`${Date.now()}-${e.nonce}`),e.coldURL=u.href}r=e.coldURL}else e.coldSource=void 0,e.coldURL=void 0;e.appliedSource=r,e.appliedSrcset=r!==e.source?null:e.srcset,e.appliedSrcset===null?e.image.removeAttribute("srcset"):e.image.getAttribute("srcset")!==e.appliedSrcset&&e.image.setAttribute("srcset",e.appliedSrcset),r===null?e.image.removeAttribute("src"):e.image.getAttribute("src")!==r&&e.image.setAttribute("src",r);let d=document.createElement("span").style;d.cssText=e.style??"";let n=i?.extraProps?.contentFit??i?.extraProps?.resizeMode;typeof n=="string"&&(d.objectFit={stretch:"fill",center:"none"}[n]??n),(o.blank||i?.source?.type==="blank")&&(d.opacity="0");for(let[u,I]of Object.entries(i?.style??{})){let ke=u.replace(/[A-Z]/g,Le=>`-${Le.toLowerCase()}`);d.setProperty(ke,typeof I=="number"&&!["opacity","zIndex","flex","flexGrow","flexShrink"].includes(u)?`${I}px`:String(I))}(a.flashUntil.get(e.id)??0)>Date.now()&&(d.outline="3px solid #ff453a"),e.appliedStyle=d.cssText||null,e.image.getAttribute("style")!==e.appliedStyle&&(e.appliedStyle===null?e.image.removeAttribute("style"):e.image.setAttribute("style",e.appliedStyle))}function Et(e){if(g.has(e)||e.closest("[data-buoy-root]"))return;let t=e.currentSrc||e.src;if(!t)return;let a=ne({lib:"web",uri:t,sourceKind:t.startsWith("data:")?"data":t.startsWith("blob:")?"file":"network",hasAltText:e.hasAttribute("alt")||e.hasAttribute("aria-label")}),i={id:a.id,image:e,source:e.getAttribute("src"),srcset:e.getAttribute("srcset"),style:e.getAttribute("style"),appliedSource:e.getAttribute("src"),appliedSrcset:e.getAttribute("srcset"),appliedStyle:e.getAttribute("style"),nonce:0,dispose(){}},o=()=>{let d=e.getBoundingClientRect(),n=a.layout,u=a.status==="loaded"&&n&&(n.width!==d.width||n.height!==d.height);f(a.id,{layout:{width:d.width,height:d.height},layoutShifts:(a.layoutShifts??0)+(u?1:0)})},r=()=>{let d=performance.getEntriesByName(e.currentSrc||e.src),n=d[d.length-1];f(a.id,{status:"loaded",loadedAt:Date.now(),intrinsic:{width:e.naturalWidth,height:e.naturalHeight},...!W(a.id)?.source&&K().network==="normal"?{uri:e.currentSrc||e.src}:{},durationMs:n?.duration,bytesTotal:n&&n.encodedBodySize>0?n.encodedBodySize:void 0,cacheVerdict:n&&n.transferSize>0?"none":void 0,cacheVerdictSource:n?"event":void 0}),o()},l=()=>f(a.id,{status:"error",erroredAt:Date.now(),error:"The browser could not load this image."});e.addEventListener("load",r),e.addEventListener("error",l);let c=typeof ResizeObserver>"u"?void 0:new ResizeObserver(o);c?.observe(e),i.dispose=()=>{c?.disconnect(),e.removeEventListener("load",r),e.removeEventListener("error",l)},g.set(e,i),o(),f(a.id,{status:"loading",startedAt:Date.now(),loadCount:1}),e.complete&&(e.naturalWidth>0?r():l()),_(i)}function xe(){let e=s();if(typeof document>"u"||e.captureDisabled||y)return;e.captureInstalled=true;let t=()=>{for(let[o,r]of g)o.isConnected||(r.dispose(),g.delete(o),f(r.id,{mounted:false}));document.querySelectorAll("img").forEach(Et)},a=new MutationObserver(o=>{if(s().captureDisabled){Ae();return}for(let r of o){let l=r.target,c=g.get(l);!c||r.type!=="attributes"||(r.attributeName==="src"&&l.getAttribute("src")!==c.appliedSource||r.attributeName==="srcset"&&l.getAttribute("srcset")!==c.appliedSrcset?(c.dispose(),g.delete(l),f(c.id,{mounted:false})):r.attributeName==="style"&&l.getAttribute("style")!==c.appliedStyle&&(c.style=l.getAttribute("style"),_(c)))}t()});a.observe(document.documentElement,{childList:true,subtree:true,attributes:true,attributeFilter:["src","srcset","style","alt"]});let i=()=>{for(let o of g.values())_(o)};e.actionListeners.add(i),y=()=>{a.disconnect(),e.actionListeners.delete(i);for(let o of g.values()){o.dispose();for(let[r,l,c]of[["src",o.source,o.appliedSource],["srcset",o.srcset,o.appliedSrcset],["style",o.style,o.appliedStyle]])o.image.getAttribute(r)===c&&(l===null?o.image.removeAttribute(r):o.image.setAttribute(r,l));f(o.id,{mounted:false})}g.clear(),e.captureInstalled=false},t()}function Ae(){y?.(),y=void 0}function Bt(){if(typeof document>"u")return()=>{};we++===0&&xe();let e=false;return()=>{e||(e=true,--we===0&&Ae())}}function Vt(){return s().mirrorCaptureStatus??{installed:!!y,rnDecoratorActive:false,rnDecoratorTooLate:false,expoPatched:false,expoAvailable:false,browserObserverActive:!!y}}export{Te as a,m as b,D as c,P as d,E as e,B as f,V as g,T as h,q as i,G as j,Y as k,ie as l,s as m,w as n,De as o,h as p,Pe as q,C as r,f as s,O as t,S as u,le as v,de as w,ce as x,ue as y,U as z,L as A,pe as B,N as C,j as D,fe as E,se as F,F as G,x as H,kt as I,Lt as J,W as K,Mt as L,Rt as M,Ct as N,Tt as O,Dt as P,Pt as Q,K as R,xe as S,Bt as T,Vt as U};
|