@buoy-gg/images 7.0.74 → 7.0.76
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.clearRecords=clearRecords;exports.computeStats=computeStats;exports.createRecord=createRecord;exports.disableImagesCapture=disableImagesCapture;exports.effectivePixelRatio=effectivePixelRatio;exports.estDecodedBytes=estDecodedBytes;exports.estWastedBytes=estWastedBytes;exports.getRecord=getRecord;exports.getSnapshot=getSnapshot;exports.neededPixels=neededPixels;exports.oversizeFactor=oversizeFactor;exports.replaceImagesFromSnapshot=replaceImagesFromSnapshot;exports.subscribe=subscribe;exports.updateRecord=updateRecord;var _sharedUi=require("@buoy-gg/shared-ui");var _reactNative=require("react-native");var _remote=require("../remote");var _state=require("../state");const MAX_RECORDS=500;function emit(){const e=(0,_state.imagesState)();if(e.emitScheduled)return;e.emitScheduled=true;requestAnimationFrame(()=>{e.emitScheduled=false;for(const t of e.listeners)t()})}function invalidate(){const e=(0,_state.imagesState)();e.snapshot=[...e.records];emit()}function createRecord(e){const t=(0,_state.imagesState)();const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.clearRecords=clearRecords;exports.computeStats=computeStats;exports.createRecord=createRecord;exports.disableImagesCapture=disableImagesCapture;exports.effectivePixelRatio=effectivePixelRatio;exports.estDecodedBytes=estDecodedBytes;exports.estWastedBytes=estWastedBytes;exports.getRecord=getRecord;exports.getSnapshot=getSnapshot;exports.neededPixels=neededPixels;exports.oversizeFactor=oversizeFactor;exports.replaceImagesFromSnapshot=replaceImagesFromSnapshot;exports.subscribe=subscribe;exports.updateRecord=updateRecord;var _sharedUi=require("@buoy-gg/shared-ui");var _reactNative=require("react-native");var _remote=require("../remote");var _state=require("../state");const MAX_RECORDS=500;function emit(){const e=(0,_state.imagesState)();if(e.emitScheduled)return;e.emitScheduled=true;requestAnimationFrame(()=>{e.emitScheduled=false;for(const t of e.listeners)t()})}function invalidate(){const e=(0,_state.imagesState)();e.snapshot=[...e.records];emit()}function createRecord(e){const t=(0,_state.imagesState)();const i={...e,id:t.nextId++,createdAt:Date.now(),status:"pending",mounted:true,loadCount:0};t.records.push(i);t.byId.set(i.id,i);if(t.records.length>MAX_RECORDS){const r=t.records.splice(0,t.records.length-MAX_RECORDS);for(const n of r)t.byId.delete(n.id)}invalidate();return i}function updateRecord(e,t){const i=(0,_state.imagesState)();const r=i.byId.get(e);if(!r)return void 0;Object.assign(r,t);invalidate();return r}function getRecord(e){return(0,_state.imagesState)().byId.get(e)}function getSnapshot(){return(0,_state.imagesState)().snapshot}function subscribe(e){const t=(0,_state.imagesState)();t.listeners.add(e);return()=>(0,_state.imagesState)().listeners.delete(e)}function clearRecords(){void(0,_remote.remoteImagesDispatch)()?.("clearRecords");const e=(0,_state.imagesState)();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]));invalidate()}function disableImagesCapture(){(0,_state.imagesState)().captureDisabled=true}function replaceImagesFromSnapshot(e){const t=(0,_state.imagesState)();const i=(e.records??[]).filter(s=>!(0,_sharedUi.isBuoyAssetPath)(s.uri));let r=0;for(const s of i){if(s.layout&&s.neededPx&&s.layout.width>r){r=s.layout.width;t.mirrorPixelRatio=s.neededPx.width/s.layout.width}}const n=Date.now();t.records=[...i].reverse().map(s=>({id:s.id,lib:s.lib,uri:s.uri,sourceKind:s.kind,status:s.status,mounted:s.mounted,createdAt:n-s.ageMs,durationMs:s.ms??void 0,intrinsic:s.intrinsic??void 0,layout:s.layout??void 0,cacheVerdict:s.cache??void 0,cacheVerdictSource:s.cacheSource??void 0,progressSeen:s.progressSeen,bytesLoaded:s.status==="loaded"?s.bytesTotal??void 0:void 0,bytesTotal:s.bytesTotal??void 0,error:s.error??void 0,errorCode:s.errorCode??void 0,loadCount:s.loadCount,overrideLabel:s.overrideLabel??void 0,hasAltText:s.hasAltText??void 0,layoutShifts:s.layoutShifts}));t.byId=new Map(t.records.map(s=>[s.id,s]));if(e.globalModes)t.globalModes={...e.globalModes};if(e.captureStatus)t.mirrorCaptureStatus=e.captureStatus;invalidate();for(const s of t.actionListeners)s()}function effectivePixelRatio(){return(0,_state.imagesState)().mirrorPixelRatio??_reactNative.PixelRatio.get()}function neededPixels(e){if(!e.layout||e.layout.width<=0||e.layout.height<=0)return null;const t=effectivePixelRatio();return{width:Math.round(e.layout.width*t),height:Math.round(e.layout.height*t)}}function isVector(e){return e.mediaType==="image/svg+xml"||/^data:image\/svg\+xml/i.test(e.uri)||/\.svg(?:[?#]|$)/i.test(e.uri)}function oversizeFactor(e){const t=neededPixels(e);if(!t||!e.intrinsic||isVector(e))return null;const i=t.width*t.height;const r=e.intrinsic.width*e.intrinsic.height;if(i<=0||r<=0)return null;return Math.sqrt(r/i)}function estDecodedBytes(e){if(!e.intrinsic)return 0;return e.intrinsic.width*e.intrinsic.height*4}function estWastedBytes(e){const t=neededPixels(e);if(!t||!e.intrinsic||isVector(e))return 0;const i=(e.intrinsic.width*e.intrinsic.height-t.width*t.height)*4;return Math.max(0,i)}function computeStats(e){const t={total:e.length,loading:0,loaded:0,errors:0,networkLoads:0,estDecodedBytes:0,estWastedBytes:0};for(const i of e){if((i.status==="loading"||i.status==="pending")&&i.mounted)t.loading++;if(i.status==="loaded")t.loaded++;if(i.status==="error")t.errors++;if(i.progressSeen||i.cacheVerdict==="none")t.networkLoads++;if(i.mounted&&i.status==="loaded"){t.estDecodedBytes+=estDecodedBytes(i);t.estWastedBytes+=estWastedBytes(i)}}return t}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{isBuoyAssetPath as
|
|
1
|
+
"use strict";import{isBuoyAssetPath as c}from"@buoy-gg/shared-ui";import{PixelRatio as l}from"react-native";import{remoteImagesDispatch as f}from"../remote";import{imagesState as s}from"../state";const u=500;function h(){const e=s();if(e.emitScheduled)return;e.emitScheduled=true;requestAnimationFrame(()=>{e.emitScheduled=false;for(const t of e.listeners)t()})}function r(){const e=s();e.snapshot=[...e.records];h()}export function createRecord(e){const t=s();const i={...e,id:t.nextId++,createdAt:Date.now(),status:"pending",mounted:true,loadCount:0};t.records.push(i);t.byId.set(i.id,i);if(t.records.length>u){const o=t.records.splice(0,t.records.length-u);for(const d of o)t.byId.delete(d.id)}r();return i}export function updateRecord(e,t){const i=s();const o=i.byId.get(e);if(!o)return void 0;Object.assign(o,t);r();return o}export function getRecord(e){return s().byId.get(e)}export function getSnapshot(){return s().snapshot}export function subscribe(e){const t=s();t.listeners.add(e);return()=>s().listeners.delete(e)}export function clearRecords(){void f()?.("clearRecords");const 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]));r()}export function disableImagesCapture(){s().captureDisabled=true}export function replaceImagesFromSnapshot(e){const t=s();const i=(e.records??[]).filter(n=>!c(n.uri));let o=0;for(const n of i){if(n.layout&&n.neededPx&&n.layout.width>o){o=n.layout.width;t.mirrorPixelRatio=n.neededPx.width/n.layout.width}}const d=Date.now();t.records=[...i].reverse().map(n=>({id:n.id,lib:n.lib,uri:n.uri,sourceKind:n.kind,status:n.status,mounted:n.mounted,createdAt:d-n.ageMs,durationMs:n.ms??void 0,intrinsic:n.intrinsic??void 0,layout:n.layout??void 0,cacheVerdict:n.cache??void 0,cacheVerdictSource:n.cacheSource??void 0,progressSeen:n.progressSeen,bytesLoaded:n.status==="loaded"?n.bytesTotal??void 0:void 0,bytesTotal:n.bytesTotal??void 0,error:n.error??void 0,errorCode:n.errorCode??void 0,loadCount:n.loadCount,overrideLabel:n.overrideLabel??void 0,hasAltText:n.hasAltText??void 0,layoutShifts:n.layoutShifts}));t.byId=new Map(t.records.map(n=>[n.id,n]));if(e.globalModes)t.globalModes={...e.globalModes};if(e.captureStatus)t.mirrorCaptureStatus=e.captureStatus;r();for(const n of t.actionListeners)n()}export function effectivePixelRatio(){return s().mirrorPixelRatio??l.get()}export function neededPixels(e){if(!e.layout||e.layout.width<=0||e.layout.height<=0)return null;const t=effectivePixelRatio();return{width:Math.round(e.layout.width*t),height:Math.round(e.layout.height*t)}}function a(e){return e.mediaType==="image/svg+xml"||/^data:image\/svg\+xml/i.test(e.uri)||/\.svg(?:[?#]|$)/i.test(e.uri)}export function oversizeFactor(e){const t=neededPixels(e);if(!t||!e.intrinsic||a(e))return null;const i=t.width*t.height;const o=e.intrinsic.width*e.intrinsic.height;if(i<=0||o<=0)return null;return Math.sqrt(o/i)}export function estDecodedBytes(e){if(!e.intrinsic)return 0;return e.intrinsic.width*e.intrinsic.height*4}export function estWastedBytes(e){const t=neededPixels(e);if(!t||!e.intrinsic||a(e))return 0;const i=(e.intrinsic.width*e.intrinsic.height-t.width*t.height)*4;return Math.max(0,i)}export function computeStats(e){const t={total:e.length,loading:0,loaded:0,errors:0,networkLoads:0,estDecodedBytes:0,estWastedBytes:0};for(const i of e){if((i.status==="loading"||i.status==="pending")&&i.mounted)t.loading++;if(i.status==="loaded")t.loaded++;if(i.status==="error")t.errors++;if(i.progressSeen||i.cacheVerdict==="none")t.networkLoads++;if(i.mounted&&i.status==="loaded"){t.estDecodedBytes+=estDecodedBytes(i);t.estWastedBytes+=estWastedBytes(i)}}return t}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";var M=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var w=(e,t)=>()=>(e&&(t=e(e=0)),t);var J=(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 s of Be(t))!Ne.call(e,s)&&s!==a&&M(e,s,{get:()=>t[s],enumerable:!(i=De(t,s))||i.enumerable});return e},Oe=(e,t,a)=>(R(e,t,"default"),a&&R(a,t,"default"));var Ve=e=>R(M({},"__esModule",{value:true}),e);var Ue,g=w(()=>{"use strict";Ue=(()=>{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 d(){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,A=w(()=>{"use strict";g();L=Symbol.for("buoy.images.globalState.v1")});function Ke(e){d().remoteDispatch=e}function y(){return d().remoteDispatch}async function ze(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 P=w(()=>{"use strict";g();A()});var Q,Fe=w(()=>{"use strict";g();Q='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'});import{useEffect as We,useState as je}from"react";import{createPortal as He}from"react-dom";import{jsx as _e}from"react/jsx-runtime";function Z(){let e=document;if(e[S])return e[S].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:Q});let a=()=>{let o=document.fullscreenElement,c=o&&o.tagName!=="CANVAS"?o:document.body;t.parentElement!==c&&c.appendChild(t)},i=new Map,s=o=>{(!t.contains(o.target)||!T(o.target))&&i.set(o.code||o.key,{key:o.key,code:o.code,location:o.location,keyCode:o.keyCode,which:o.which,altKey:o.altKey,ctrlKey:o.ctrlKey,metaKey:o.metaKey,shiftKey:o.shiftKey})},r=o=>{i.delete(o.code||o.key)},u=()=>i.clear(),p=()=>{let o=[...i.values()];i.clear();for(let c of o)document.dispatchEvent(new KeyboardEvent("keyup",{...c,bubbles:true}))},l=o=>{T(o.target)&&o.stopPropagation()},n=o=>o.stopPropagation();return a(),document.addEventListener("fullscreenchange",a),document.addEventListener("keydown",s,true),document.addEventListener("keyup",r,true),window.addEventListener("blur",u),t.addEventListener("focusin",p),t.addEventListener("keydown",l),t.addEventListener("keyup",l),t.addEventListener("keypress",l),t.addEventListener("wheel",n,{passive:true}),e[S]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",a),document.removeEventListener("keydown",s,true),document.removeEventListener("keyup",r,true),window.removeEventListener("blur",u),t.remove(),delete e[S]}},t}function $e({children:e}){let[t,a]=je(null);return We(()=>{let i=Z(),s=document[S];return s.users++,a(i),()=>{--s.users===0&&s.dispose()}},[]),t?He(_e("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var S,T,qe=w(()=>{"use strict";g();Fe();S=Symbol.for("@buoy-gg/portal-host"),T=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 X={};J(X,{AccessibilityInfo:()=>Qe,ActivityIndicator:()=>de,Alert:()=>pe,Animated:()=>Ze,AppRegistry:()=>et,AppState:()=>tt,Appearance:()=>Xe,BackHandler:()=>rt,Button:()=>ce,CheckBox:()=>yt,Clipboard:()=>at,DeviceEventEmitter:()=>Pt,Dimensions:()=>ot,Easing:()=>nt,FlatList:()=>te,I18nManager:()=>st,Image:()=>re,ImageBackground:()=>gt,InteractionManager:()=>lt,Keyboard:()=>it,KeyboardAvoidingView:()=>vt,LayoutAnimation:()=>dt,Linking:()=>ct,LogBox:()=>Rt,Modal:()=>ie,NativeEventEmitter:()=>ut,NativeModules:()=>Je,PanResponder:()=>pt,Picker:()=>wt,PixelRatio:()=>D,Platform:()=>ft,Pressable:()=>se,ProgressBar:()=>St,RefreshControl:()=>xt,SafeAreaView:()=>At,ScrollView:()=>K,SectionList:()=>Et,Share:()=>mt,StatusBar:()=>kt,StyleSheet:()=>ee,Switch:()=>le,Text:()=>O,TextInput:()=>V,Touchable:()=>Lt,TouchableHighlight:()=>oe,TouchableNativeFeedback:()=>Ct,TouchableOpacity:()=>U,TouchableWithoutFeedback:()=>ne,UIManager:()=>bt,Vibration:()=>ht,View:()=>N,VirtualizedList:()=>It,YellowBox:()=>Mt,findNodeHandle:()=>ue,unstable_createElement:()=>Ye,useColorScheme:()=>Tt,useLocaleContext:()=>Dt,useWindowDimensions:()=>Bt});import*as Ge from"react-native-web";import{unstable_createElement as Ye,NativeModules as Je,AccessibilityInfo as Qe,Animated as Ze,Appearance as Xe,AppRegistry as et,AppState as tt,BackHandler as rt,Clipboard as at,Dimensions as ot,Easing as nt,I18nManager as st,Keyboard as it,InteractionManager as lt,LayoutAnimation as dt,Linking as ct,NativeEventEmitter as ut,PanResponder as pt,PixelRatio as D,Platform as ft,Share as mt,StyleSheet as ee,UIManager as bt,Vibration as ht,CheckBox as yt,FlatList as te,Image as re,ImageBackground as gt,KeyboardAvoidingView as vt,Picker as wt,ProgressBar as St,RefreshControl as xt,SafeAreaView as At,SectionList as Et,StatusBar as kt,Touchable as Lt,TouchableNativeFeedback as Ct,VirtualizedList as It,YellowBox as Mt,LogBox as Rt,DeviceEventEmitter as Pt,useColorScheme as Tt,useLocaleContext as Dt,useWindowDimensions as Bt}from"react-native-web";import*as m from"react-native-web";import{createElement as B,forwardRef as ae,useCallback as Nt,useRef as Ot}from"react";function h(e){let t=ae((i,s)=>{let{accessibilityState:r,accessibilityValue:u,...p}=i;for(let l of["busy","checked","disabled","expanded","selected"])r?.[l]!==void 0&&p[`aria-${l}`]===void 0&&(p[`aria-${l}`]=r[l]);for(let[l,n]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))u?.[l]!==void 0&&p[`aria-${n}`]===void 0&&(p[`aria-${n}`]=u[l]);return B(e,{...p,ref:s})}),a=e.State;return a&&Object.assign(t,{State:a}),t.displayName=e.displayName??e.name??"NativeWebView",t}var N,O,V,U,oe,ne,se,K,z,ie,le,de,ce,ue,pe,fe=w(()=>{g();Oe(X,Ge);qe();N=h(m.View),O=h(m.Text),V=h(m.TextInput),U=h(m.TouchableOpacity),oe=h(m.TouchableHighlight),ne=h(m.TouchableWithoutFeedback),se=h(m.Pressable),K=h(m.ScrollView),z=ae((e,t)=>{let a=Ot(null),i=Nt(s=>{if(s){let r=s;for(;r.parentElement&&r.parentElement!==document.body;)r=r.parentElement;r.parentElement===document.body&&(a.current=r,Object.assign(r.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),Z().appendChild(r))}else a.current&&(document.body.appendChild(a.current),a.current=null);typeof t=="function"?t(s):t&&(t.current=s)},[t]);return B($e,null,B(m.Modal,{...e,ref:i}))});z.displayName="Modal";ie=h(z),le=h(m.Switch),de=h(m.ActivityIndicator),ce=h(m.Button),ue=m.findNodeHandle,pe={alert(e,t,a,i){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 n=document.createElement("p");n.textContent=t,n.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",s.appendChild(n)}let u=document.createElement("div");u.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let p=a?.length?a:[{text:"OK"}],l=()=>{s.close?.(),s.remove()};for(let n of p){let o=document.createElement("button");o.type="button",o.textContent=n.text??"OK",o.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${n.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,o.onclick=()=>{l(),n.onPress?.()},u.appendChild(o)}s.addEventListener("cancel",n=>{n.preventDefault(),i?.cancelable!==false&&(l(),i?.onDismiss?.())}),s.appendChild(u),document.body.appendChild(s),s.showModal?s.showModal():s.setAttribute("open","")}}});var me={};J(me,{clearRecords:()=>ye,computeStats:()=>Se,createRecord:()=>be,disableImagesCapture:()=>ge,effectivePixelRatio:()=>W,estDecodedBytes:()=>j,estWastedBytes:()=>H,getRecord:()=>F,getSnapshot:()=>E,neededPixels:()=>I,oversizeFactor:()=>we,replaceImagesFromSnapshot:()=>ve,subscribe:()=>he,updateRecord:()=>b});import{isBuoyAssetPath as Vt}from"@buoy-gg/shared-ui/web";function Ut(){let e=d();e.emitScheduled||(e.emitScheduled=true,requestAnimationFrame(()=>{e.emitScheduled=false;for(let t of e.listeners)t()}))}function C(){let e=d();e.snapshot=[...e.records],Ut()}function be(e){let t=d(),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>_){let i=t.records.splice(0,t.records.length-_);for(let s of i)t.byId.delete(s.id)}return C(),a}function b(e,t){let a=d().byId.get(e);if(a)return Object.assign(a,t),C(),a}function F(e){return d().byId.get(e)}function E(){return d().snapshot}function he(e){return d().listeners.add(e),()=>d().listeners.delete(e)}function ye(){y()?.("clearRecords");let e=d();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])),C()}function ge(){d().captureDisabled=true}function ve(e){let t=d(),a=(e.records??[]).filter(r=>!Vt(r.uri)),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 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),C();for(let r of t.actionListeners)r()}function W(){return d().mirrorPixelRatio??D.get()}function I(e){if(!e.layout||e.layout.width<=0||e.layout.height<=0)return null;let t=W();return{width:Math.round(e.layout.width*t),height:Math.round(e.layout.height*t)}}function we(e){let t=I(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 j(e){return e.intrinsic?e.intrinsic.width*e.intrinsic.height*4:0}function H(e){let t=I(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 Se(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+=j(a),t.estWastedBytes+=H(a));return t}var _,$=w(()=>{"use strict";g();fe();P();A();_=500});g();P();A();$();function xe(){for(let e of d().actionListeners)e()}function Ae(e){let t=d();if(e!=null){t.expoInstances.get(e)?.forceUpdate?.();return}for(let a of t.expoInstances.values())a?.forceUpdate?.()}function k(e){let t=d();t.recordVersions.set(e,++t.versionCounter),xe(),Ae(e)}function Ee(){let e=d();e.globalVersion=++e.versionCounter,xe(),Ae()}function Kt(e,t){return t.type==="url"?{id:e,kind:"url",uri:t.uri}:{id:e,kind:t.type}}function ke(e,t){d().overrides.set(e,t),b(e,{overrideLabel:t.label}),k(e)}function zt(e,t){t.source&&y()?.("setOverride",Kt(e,t.source)),ke(e,t)}function Le(e){d().overrides.delete(e),b(e,{overrideLabel:void 0}),k(e)}function Ft(e){y()?.("clearOverride",{id:e}),Le(e)}function q(e){if(e!=null)return d().overrides.get(e)}function Wt(e){return e.type==="hang"?"loading":e.type}function jt(e,t){y()?.("massAction",{kind:Wt(e)});let a=0;for(let i of E())i.mounted&&(ke(i.id,{source:e,label:t}),a++);return a}function Ht(){y()?.("massAction",{kind:"restore"});let e=new Set(d().overrides.keys());for(let t of E())t.overrideLabel!=null&&e.add(t.id);for(let t of e)Le(t);return e.size}function _t(e=2500){y()?.("massAction",{kind:"flash"});let t=0;for(let a of E())a.mounted&&(Ce(a.id,e),t++);return t}function Ce(e,t=2500){d().flashUntil.set(e,Date.now()+t),k(e),setTimeout(()=>{d().flashUntil.delete(e),k(e)},t+50)}function $t(e,t=2500){y()?.("flash",{id:e}),Ce(e,t)}function qt(e){y()?.("setNetworkMode",{mode:e}),d().globalModes.network=e,Ee()}function Gt(e){y()?.("setBlankImages",{enabled:e}),d().globalModes.blank=e,Ee()}function G(){return d().globalModes}g();A();$();import{isBuoyElement as Yt,isBuoyAssetPath as Jt}from"@buoy-gg/shared-ui/web";var v=new Map,x,Ie=0,Me="data:image/png;base64,";function Y(e){let t=F(e.id);if(!t)return;let a=d(),i=q(e.id),s=G(),r=e.source;if(s.network==="offline"&&t.sourceKind==="network"&&(r=Me),i?.source){let o=i.source;o.type==="url"?r=o.uri:o.type==="error"?r=Me:r=null,o.type==="hang"&&b(e.id,{status:"loading"})}let u=a.reloadRequests.get(e.id),p=u&&u.nonce!==e.nonce;if(p){if(e.nonce=u.nonce,u.bust&&r&&/^https?:/.test(new URL(r,document.baseURI).href)){let o=new URL(r,document.baseURI);o.searchParams.set("__buoy_reload",String(Date.now())),r=o.href}e.image.removeAttribute("src"),b(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||p){e.coldSource=r;let o=new URL(r,document.baseURI);o.searchParams.set("__buoy_reload",`${Date.now()}-${e.nonce}`),e.coldURL=o.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 l=document.createElement("span").style;l.cssText=e.style??"";let n=i?.extraProps?.contentFit??i?.extraProps?.resizeMode;typeof n=="string"&&(l.objectFit={stretch:"fill",center:"none"}[n]??n),(s.blank||i?.source?.type==="blank")&&(l.opacity="0");for(let[o,c]of Object.entries(i?.style??{})){let f=o.replace(/[A-Z]/g,Te=>`-${Te.toLowerCase()}`);l.setProperty(f,typeof c=="number"&&!["opacity","zIndex","flex","flexGrow","flexShrink"].includes(o)?`${c}px`:String(c))}(a.flashUntil.get(e.id)??0)>Date.now()&&(l.outline="3px solid #ff453a"),e.appliedStyle=l.cssText||null,e.image.getAttribute("style")!==e.appliedStyle&&(e.appliedStyle===null?e.image.removeAttribute("style"):e.image.setAttribute("style",e.appliedStyle))}function Qt(e){if(v.has(e)||Yt(e))return;let t=e.currentSrc||e.src;if(!t||Jt(t))return;let a=be({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(){}},s=()=>{let l=e.getBoundingClientRect(),n=a.layout,o=a.status==="loaded"&&n&&(n.width!==l.width||n.height!==l.height);b(a.id,{layout:{width:l.width,height:l.height},layoutShifts:(a.layoutShifts??0)+(o?1:0)})},r=()=>{let l=performance.getEntriesByName(e.currentSrc||e.src),n=l[l.length-1];b(a.id,{status:"loaded",loadedAt:Date.now(),intrinsic:{width:e.naturalWidth,height:e.naturalHeight},...!q(a.id)?.source&&G().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}),s()},u=()=>b(a.id,{status:"error",erroredAt:Date.now(),error:"The browser could not load this image."});e.addEventListener("load",r),e.addEventListener("error",u);let p=typeof ResizeObserver>"u"?void 0:new ResizeObserver(s);p?.observe(e),i.dispose=()=>{p?.disconnect(),e.removeEventListener("load",r),e.removeEventListener("error",u)},v.set(e,i),s(),b(a.id,{status:"loading",startedAt:Date.now(),loadCount:1}),e.complete&&(e.naturalWidth>0?r():u()),Y(i)}function Re(){let e=d();if(typeof document>"u"||e.captureDisabled||x)return;e.captureInstalled=true;let t=new WeakSet,a=n=>{n.querySelectorAll("img").forEach(Qt);let o=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT);for(let c=o.nextNode();c;c=o.nextNode()){let f=c.shadowRoot;f&&(t.has(f)||(t.add(f),r.observe(f,s)),a(f))}},i=()=>{for(let[n,o]of v)n.isConnected||(o.dispose(),v.delete(n),b(o.id,{mounted:false}));a(document)},s={childList:true,subtree:true,attributes:true,attributeFilter:["src","srcset","style","alt"]},r=new MutationObserver(n=>{if(d().captureDisabled){Pe();return}for(let o of n){let c=o.target,f=v.get(c);!f||o.type!=="attributes"||(o.attributeName==="src"&&c.getAttribute("src")!==f.appliedSource||o.attributeName==="srcset"&&c.getAttribute("srcset")!==f.appliedSrcset?(f.dispose(),v.delete(c),b(f.id,{mounted:false})):o.attributeName==="style"&&c.getAttribute("style")!==f.appliedStyle&&(f.style=c.getAttribute("style"),Y(f)))}i()});r.observe(document.documentElement,s);let u=Element.prototype.attachShadow,p=function(n){let o=u.call(this,n);return n.mode==="open"&&!t.has(o)&&(t.add(o),r.observe(o,s)),o};Element.prototype.attachShadow=p;let l=()=>{for(let n of v.values())Y(n)};e.actionListeners.add(l),x=()=>{r.disconnect(),e.actionListeners.delete(l),Element.prototype.attachShadow===p&&(Element.prototype.attachShadow=u);for(let n of v.values()){n.dispose();for(let[o,c,f]of[["src",n.source,n.appliedSource],["srcset",n.srcset,n.appliedSrcset],["style",n.style,n.appliedStyle]])n.image.getAttribute(o)===f&&(c===null?n.image.removeAttribute(o):n.image.setAttribute(o,c));b(n.id,{mounted:false})}v.clear(),e.captureInstalled=false},i()}function Pe(){x?.(),x=void 0}function Zt(){if(typeof document>"u")return()=>{};Ie++===0&&Re();let e=false;return()=>{e||(e=true,--Ie===0&&Pe())}}function Xt(){return d().mirrorCaptureStatus??{installed:!!x,rnDecoratorActive:false,rnDecoratorTooLate:false,expoPatched:false,expoAvailable:false,browserObserverActive:!!x}}export{Ve as a,g as b,N as c,O as d,V as e,U as f,K as g,D as h,ee as i,te as j,re as k,fe as l,d as m,A as n,Ke as o,y as p,ze as q,P as r,b as s,F as t,E as u,he as v,ye as w,ge as x,ve as y,W as z,I as A,we as B,j as C,H as D,Se as E,me as F,$ as G,k as H,zt as I,Ft as J,q as K,jt as L,Ht as M,_t as N,$t as O,qt as P,Gt as Q,G as R,Re as S,Zt as T,Xt as U};
|
|
1
|
+
"use client";var M=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var Ne=Object.prototype.hasOwnProperty;var w=(e,t)=>()=>(e&&(t=e(e=0)),t);var J=(e,t)=>{for(var r in t)M(e,r,{get:t[r],enumerable:true})},R=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Be(t))!Ne.call(e,n)&&n!==r&&M(e,n,{get:()=>t[n],enumerable:!(i=De(t,n))||i.enumerable});return e},Oe=(e,t,r)=>(R(e,t,"default"),r&&R(r,t,"default"));var Ve=e=>R(M({},"__esModule",{value:true}),e);var Ue,g=w(()=>{"use strict";Ue=(()=>{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 d(){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,A=w(()=>{"use strict";g();L=Symbol.for("buoy.images.globalState.v1")});function Ke(e){d().remoteDispatch=e}function y(){return d().remoteDispatch}async function ze(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 P=w(()=>{"use strict";g();A()});var Q,Fe=w(()=>{"use strict";g();Q='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'});import{useEffect as je,useState as We}from"react";import{createPortal as _e}from"react-dom";import{jsx as He}from"react/jsx-runtime";function Z(){let e=document;if(e[S])return e[S].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:Q});let r=()=>{let o=document.fullscreenElement,u=o&&o.tagName!=="CANVAS"?o:document.body;t.parentElement!==u&&u.appendChild(t)},i=new Map,n=o=>{(!t.contains(o.target)||!T(o.target))&&i.set(o.code||o.key,{key:o.key,code:o.code,location:o.location,keyCode:o.keyCode,which:o.which,altKey:o.altKey,ctrlKey:o.ctrlKey,metaKey:o.metaKey,shiftKey:o.shiftKey})},a=o=>{i.delete(o.code||o.key)},c=()=>i.clear(),p=()=>{let o=[...i.values()];i.clear();for(let u of o)document.dispatchEvent(new KeyboardEvent("keyup",{...u,bubbles:true}))},l=o=>{T(o.target)&&o.stopPropagation()},s=o=>o.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",n,true),document.addEventListener("keyup",a,true),window.addEventListener("blur",c),t.addEventListener("focusin",p),t.addEventListener("keydown",l),t.addEventListener("keyup",l),t.addEventListener("keypress",l),t.addEventListener("wheel",s,{passive:true}),e[S]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",n,true),document.removeEventListener("keyup",a,true),window.removeEventListener("blur",c),t.remove(),delete e[S]}},t}function $e({children:e}){let[t,r]=We(null);return je(()=>{let i=Z(),n=document[S];return n.users++,r(i),()=>{--n.users===0&&n.dispose()}},[]),t?_e(He("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var S,T,qe=w(()=>{"use strict";g();Fe();S=Symbol.for("@buoy-gg/portal-host"),T=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 X={};J(X,{AccessibilityInfo:()=>Qe,ActivityIndicator:()=>de,Alert:()=>pe,Animated:()=>Ze,AppRegistry:()=>et,AppState:()=>tt,Appearance:()=>Xe,BackHandler:()=>at,Button:()=>ue,CheckBox:()=>yt,Clipboard:()=>rt,DeviceEventEmitter:()=>Pt,Dimensions:()=>ot,Easing:()=>st,FlatList:()=>te,I18nManager:()=>nt,Image:()=>ae,ImageBackground:()=>gt,InteractionManager:()=>lt,Keyboard:()=>it,KeyboardAvoidingView:()=>vt,LayoutAnimation:()=>dt,Linking:()=>ut,LogBox:()=>Rt,Modal:()=>ie,NativeEventEmitter:()=>ct,NativeModules:()=>Je,PanResponder:()=>pt,Picker:()=>wt,PixelRatio:()=>D,Platform:()=>ft,Pressable:()=>ne,ProgressBar:()=>St,RefreshControl:()=>xt,SafeAreaView:()=>At,ScrollView:()=>K,SectionList:()=>Et,Share:()=>mt,StatusBar:()=>kt,StyleSheet:()=>ee,Switch:()=>le,Text:()=>O,TextInput:()=>V,Touchable:()=>Lt,TouchableHighlight:()=>oe,TouchableNativeFeedback:()=>Ct,TouchableOpacity:()=>U,TouchableWithoutFeedback:()=>se,UIManager:()=>ht,Vibration:()=>bt,View:()=>N,VirtualizedList:()=>It,YellowBox:()=>Mt,findNodeHandle:()=>ce,unstable_createElement:()=>Ye,useColorScheme:()=>Tt,useLocaleContext:()=>Dt,useWindowDimensions:()=>Bt});import*as Ge from"react-native-web";import{unstable_createElement as Ye,NativeModules as Je,AccessibilityInfo as Qe,Animated as Ze,Appearance as Xe,AppRegistry as et,AppState as tt,BackHandler as at,Clipboard as rt,Dimensions as ot,Easing as st,I18nManager as nt,Keyboard as it,InteractionManager as lt,LayoutAnimation as dt,Linking as ut,NativeEventEmitter as ct,PanResponder as pt,PixelRatio as D,Platform as ft,Share as mt,StyleSheet as ee,UIManager as ht,Vibration as bt,CheckBox as yt,FlatList as te,Image as ae,ImageBackground as gt,KeyboardAvoidingView as vt,Picker as wt,ProgressBar as St,RefreshControl as xt,SafeAreaView as At,SectionList as Et,StatusBar as kt,Touchable as Lt,TouchableNativeFeedback as Ct,VirtualizedList as It,YellowBox as Mt,LogBox as Rt,DeviceEventEmitter as Pt,useColorScheme as Tt,useLocaleContext as Dt,useWindowDimensions as Bt}from"react-native-web";import*as m from"react-native-web";import{createElement as B,forwardRef as re,useCallback as Nt,useRef as Ot}from"react";function b(e){let t=re((i,n)=>{let{accessibilityState:a,accessibilityValue:c,...p}=i;for(let l of["busy","checked","disabled","expanded","selected"])a?.[l]!==void 0&&p[`aria-${l}`]===void 0&&(p[`aria-${l}`]=a[l]);for(let[l,s]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))c?.[l]!==void 0&&p[`aria-${s}`]===void 0&&(p[`aria-${s}`]=c[l]);return B(e,{...p,ref:n})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var N,O,V,U,oe,se,ne,K,z,ie,le,de,ue,ce,pe,fe=w(()=>{g();Oe(X,Ge);qe();N=b(m.View),O=b(m.Text),V=b(m.TextInput),U=b(m.TouchableOpacity),oe=b(m.TouchableHighlight),se=b(m.TouchableWithoutFeedback),ne=b(m.Pressable),K=b(m.ScrollView),z=re((e,t)=>{let r=Ot(null),i=Nt(n=>{if(n){let a=n;for(;a.parentElement&&a.parentElement!==document.body;)a=a.parentElement;a.parentElement===document.body&&(r.current=a,Object.assign(a.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),Z().appendChild(a))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(n):t&&(t.current=n)},[t]);return B($e,null,B(m.Modal,{...e,ref:i}))});z.displayName="Modal";ie=b(z),le=b(m.Switch),de=b(m.ActivityIndicator),ue=b(m.Button),ce=m.findNodeHandle,pe={alert(e,t,r,i){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 a=document.createElement("h2");if(a.textContent=e,a.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(a),t){let s=document.createElement("p");s.textContent=t,s.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(s)}let c=document.createElement("div");c.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let p=r?.length?r:[{text:"OK"}],l=()=>{n.close?.(),n.remove()};for(let s of p){let o=document.createElement("button");o.type="button",o.textContent=s.text??"OK",o.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${s.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,o.onclick=()=>{l(),s.onPress?.()},c.appendChild(o)}n.addEventListener("cancel",s=>{s.preventDefault(),i?.cancelable!==false&&(l(),i?.onDismiss?.())}),n.appendChild(c),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}}});var me={};J(me,{clearRecords:()=>ye,computeStats:()=>Se,createRecord:()=>he,disableImagesCapture:()=>ge,effectivePixelRatio:()=>j,estDecodedBytes:()=>W,estWastedBytes:()=>_,getRecord:()=>F,getSnapshot:()=>E,neededPixels:()=>I,oversizeFactor:()=>we,replaceImagesFromSnapshot:()=>ve,subscribe:()=>be,updateRecord:()=>h});import{isBuoyAssetPath as Vt}from"@buoy-gg/shared-ui/web";function Ut(){let e=d();e.emitScheduled||(e.emitScheduled=true,requestAnimationFrame(()=>{e.emitScheduled=false;for(let t of e.listeners)t()}))}function C(){let e=d();e.snapshot=[...e.records],Ut()}function he(e){let t=d(),r={...e,id:t.nextId++,createdAt:Date.now(),status:"pending",mounted:true,loadCount:0};if(t.records.push(r),t.byId.set(r.id,r),t.records.length>H){let i=t.records.splice(0,t.records.length-H);for(let n of i)t.byId.delete(n.id)}return C(),r}function h(e,t){let r=d().byId.get(e);if(r)return Object.assign(r,t),C(),r}function F(e){return d().byId.get(e)}function E(){return d().snapshot}function be(e){return d().listeners.add(e),()=>d().listeners.delete(e)}function ye(){y()?.("clearRecords");let e=d();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])),C()}function ge(){d().captureDisabled=true}function ve(e){let t=d(),r=(e.records??[]).filter(a=>!Vt(a.uri)),i=0;for(let a of r)a.layout&&a.neededPx&&a.layout.width>i&&(i=a.layout.width,t.mirrorPixelRatio=a.neededPx.width/a.layout.width);let n=Date.now();t.records=[...r].reverse().map(a=>({id:a.id,lib:a.lib,uri:a.uri,sourceKind:a.kind,status:a.status,mounted:a.mounted,createdAt:n-a.ageMs,durationMs:a.ms??void 0,intrinsic:a.intrinsic??void 0,layout:a.layout??void 0,cacheVerdict:a.cache??void 0,cacheVerdictSource:a.cacheSource??void 0,progressSeen:a.progressSeen,bytesLoaded:a.status==="loaded"?a.bytesTotal??void 0:void 0,bytesTotal:a.bytesTotal??void 0,error:a.error??void 0,errorCode:a.errorCode??void 0,loadCount:a.loadCount,overrideLabel:a.overrideLabel??void 0,hasAltText:a.hasAltText??void 0,layoutShifts:a.layoutShifts})),t.byId=new Map(t.records.map(a=>[a.id,a])),e.globalModes&&(t.globalModes={...e.globalModes}),e.captureStatus&&(t.mirrorCaptureStatus=e.captureStatus),C();for(let a of t.actionListeners)a()}function j(){return d().mirrorPixelRatio??D.get()}function I(e){if(!e.layout||e.layout.width<=0||e.layout.height<=0)return null;let t=j();return{width:Math.round(e.layout.width*t),height:Math.round(e.layout.height*t)}}function we(e){let t=I(e);if(!t||!e.intrinsic)return null;let r=t.width*t.height,i=e.intrinsic.width*e.intrinsic.height;return r<=0||i<=0?null:Math.sqrt(i/r)}function W(e){return e.intrinsic?e.intrinsic.width*e.intrinsic.height*4:0}function _(e){let t=I(e);if(!t||!e.intrinsic)return 0;let r=(e.intrinsic.width*e.intrinsic.height-t.width*t.height)*4;return Math.max(0,r)}function Se(e){let t={total:e.length,loading:0,loaded:0,errors:0,networkLoads:0,estDecodedBytes:0,estWastedBytes:0};for(let r of e)(r.status==="loading"||r.status==="pending")&&r.mounted&&t.loading++,r.status==="loaded"&&t.loaded++,r.status==="error"&&t.errors++,(r.progressSeen||r.cacheVerdict==="none")&&t.networkLoads++,r.mounted&&r.status==="loaded"&&(t.estDecodedBytes+=W(r),t.estWastedBytes+=_(r));return t}var H,$=w(()=>{"use strict";g();fe();P();A();H=500});g();P();A();$();function xe(){for(let e of d().actionListeners)e()}function Ae(e){let t=d();if(e!=null){t.expoInstances.get(e)?.forceUpdate?.();return}for(let r of t.expoInstances.values())r?.forceUpdate?.()}function k(e){let t=d();t.recordVersions.set(e,++t.versionCounter),xe(),Ae(e)}function Ee(){let e=d();e.globalVersion=++e.versionCounter,xe(),Ae()}function Kt(e,t){return t.type==="url"?{id:e,kind:"url",uri:t.uri}:{id:e,kind:t.type}}function ke(e,t){d().overrides.set(e,t),h(e,{overrideLabel:t.label}),k(e)}function zt(e,t){t.source&&y()?.("setOverride",Kt(e,t.source)),ke(e,t)}function Le(e){d().overrides.delete(e),h(e,{overrideLabel:void 0}),k(e)}function Ft(e){y()?.("clearOverride",{id:e}),Le(e)}function q(e){if(e!=null)return d().overrides.get(e)}function jt(e){return e.type==="hang"?"loading":e.type}function Wt(e,t){y()?.("massAction",{kind:jt(e)});let r=0;for(let i of E())i.mounted&&(ke(i.id,{source:e,label:t}),r++);return r}function _t(){y()?.("massAction",{kind:"restore"});let e=new Set(d().overrides.keys());for(let t of E())t.overrideLabel!=null&&e.add(t.id);for(let t of e)Le(t);return e.size}function Ht(e=2500){y()?.("massAction",{kind:"flash"});let t=0;for(let r of E())r.mounted&&(Ce(r.id,e),t++);return t}function Ce(e,t=2500){d().flashUntil.set(e,Date.now()+t),k(e),setTimeout(()=>{d().flashUntil.delete(e),k(e)},t+50)}function $t(e,t=2500){y()?.("flash",{id:e}),Ce(e,t)}function qt(e){y()?.("setNetworkMode",{mode:e}),d().globalModes.network=e,Ee()}function Gt(e){y()?.("setBlankImages",{enabled:e}),d().globalModes.blank=e,Ee()}function G(){return d().globalModes}g();A();$();import{isBuoyElement as Yt,isBuoyAssetPath as Jt}from"@buoy-gg/shared-ui/web";var v=new Map,x,Ie=0,Me="data:image/png;base64,";function Y(e){let t=F(e.id);if(!t)return;let r=d(),i=q(e.id),n=G(),a=e.source;if(n.network==="offline"&&t.sourceKind==="network"&&(a=Me),i?.source){let o=i.source;o.type==="url"?a=o.uri:o.type==="error"?a=Me:a=null,o.type==="hang"&&h(e.id,{status:"loading"})}let c=r.reloadRequests.get(e.id),p=c&&c.nonce!==e.nonce;if(p){if(e.nonce=c.nonce,c.bust&&a&&/^https?:/.test(new URL(a,document.baseURI).href)){let o=new URL(a,document.baseURI);o.searchParams.set("__buoy_reload",String(Date.now())),a=o.href}e.image.removeAttribute("src"),h(e.id,{status:"loading",startedAt:Date.now(),loadCount:t.loadCount+1})}if(n.network==="cold"&&a&&/^https?:/.test(new URL(a,document.baseURI).href)){if(e.coldSource!==a||!e.coldURL||p){e.coldSource=a;let o=new URL(a,document.baseURI);o.searchParams.set("__buoy_reload",`${Date.now()}-${e.nonce}`),e.coldURL=o.href}a=e.coldURL}else e.coldSource=void 0,e.coldURL=void 0;e.appliedSource=a,e.appliedSrcset=a!==e.source?null:e.srcset,e.appliedSrcset===null?e.image.removeAttribute("srcset"):e.image.getAttribute("srcset")!==e.appliedSrcset&&e.image.setAttribute("srcset",e.appliedSrcset),a===null?e.image.removeAttribute("src"):e.image.getAttribute("src")!==a&&e.image.setAttribute("src",a);let l=document.createElement("span").style;l.cssText=e.style??"";let s=i?.extraProps?.contentFit??i?.extraProps?.resizeMode;typeof s=="string"&&(l.objectFit={stretch:"fill",center:"none"}[s]??s),(n.blank||i?.source?.type==="blank")&&(l.opacity="0");for(let[o,u]of Object.entries(i?.style??{})){let f=o.replace(/[A-Z]/g,Te=>`-${Te.toLowerCase()}`);l.setProperty(f,typeof u=="number"&&!["opacity","zIndex","flex","flexGrow","flexShrink"].includes(o)?`${u}px`:String(u))}(r.flashUntil.get(e.id)??0)>Date.now()&&(l.outline="3px solid #ff453a"),e.appliedStyle=l.cssText||null,e.image.getAttribute("style")!==e.appliedStyle&&(e.appliedStyle===null?e.image.removeAttribute("style"):e.image.setAttribute("style",e.appliedStyle))}function Qt(e){if(v.has(e)||Yt(e))return;let t=e.currentSrc||e.src;if(!t||Jt(t))return;let r=he({lib:"web",uri:t,sourceKind:t.startsWith("data:")?"data":t.startsWith("blob:")?"file":"network",hasAltText:e.hasAttribute("alt")||e.hasAttribute("aria-label")}),i={id:r.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(){}},n=()=>{let l=e.getBoundingClientRect(),s=r.layout,o=r.status==="loaded"&&s&&(s.width!==l.width||s.height!==l.height);h(r.id,{layout:{width:l.width,height:l.height},layoutShifts:(r.layoutShifts??0)+(o?1:0)})},a=()=>{let l=performance.getEntriesByName(e.currentSrc||e.src),s=l[l.length-1];h(r.id,{status:"loaded",loadedAt:Date.now(),intrinsic:{width:e.naturalWidth,height:e.naturalHeight},...!q(r.id)?.source&&G().network==="normal"?{uri:e.currentSrc||e.src}:{},durationMs:s?.duration,bytesTotal:s&&s.encodedBodySize>0?s.encodedBodySize:void 0,cacheVerdict:s&&s.transferSize>0?"none":void 0,cacheVerdictSource:s?"event":void 0}),n()},c=()=>h(r.id,{status:"error",erroredAt:Date.now(),error:"The browser could not load this image."});e.addEventListener("load",a),e.addEventListener("error",c);let p=typeof ResizeObserver>"u"?void 0:new ResizeObserver(n);p?.observe(e),i.dispose=()=>{p?.disconnect(),e.removeEventListener("load",a),e.removeEventListener("error",c)},v.set(e,i),n(),h(r.id,{status:"loading",startedAt:Date.now(),loadCount:1}),e.complete&&(e.naturalWidth>0?a():c()),Y(i)}function Re(){let e=d();if(typeof document>"u"||e.captureDisabled||x)return;e.captureInstalled=true;let t=new WeakSet,r=s=>{s.querySelectorAll("img").forEach(Qt);let o=document.createTreeWalker(s,NodeFilter.SHOW_ELEMENT);for(let u=o.nextNode();u;u=o.nextNode()){let f=u.shadowRoot;f&&(t.has(f)||(t.add(f),a.observe(f,n)),r(f))}},i=()=>{for(let[s,o]of v)s.isConnected||(o.dispose(),v.delete(s),h(o.id,{mounted:false}));r(document)},n={childList:true,subtree:true,attributes:true,attributeFilter:["src","srcset","style","alt"]},a=new MutationObserver(s=>{if(d().captureDisabled){Pe();return}for(let o of s){let u=o.target,f=v.get(u);!f||o.type!=="attributes"||(o.attributeName==="src"&&u.getAttribute("src")!==f.appliedSource||o.attributeName==="srcset"&&u.getAttribute("srcset")!==f.appliedSrcset?(f.dispose(),v.delete(u),h(f.id,{mounted:false})):o.attributeName==="style"&&u.getAttribute("style")!==f.appliedStyle&&(f.style=u.getAttribute("style"),Y(f)))}i()});a.observe(document.documentElement,n);let c=Element.prototype.attachShadow,p=function(s){let o=c.call(this,s);return s.mode==="open"&&!t.has(o)&&(t.add(o),a.observe(o,n)),o};Element.prototype.attachShadow=p;let l=()=>{for(let s of v.values())Y(s)};e.actionListeners.add(l),x=()=>{a.disconnect(),e.actionListeners.delete(l),Element.prototype.attachShadow===p&&(Element.prototype.attachShadow=c);for(let s of v.values()){s.dispose();for(let[o,u,f]of[["src",s.source,s.appliedSource],["srcset",s.srcset,s.appliedSrcset],["style",s.style,s.appliedStyle]])s.image.getAttribute(o)===f&&(u===null?s.image.removeAttribute(o):s.image.setAttribute(o,u));h(s.id,{mounted:false})}v.clear(),e.captureInstalled=false},i()}function Pe(){x?.(),x=void 0}function Zt(){if(typeof document>"u")return()=>{};Ie++===0&&Re();let e=false;return()=>{e||(e=true,--Ie===0&&Pe())}}function Xt(){return d().mirrorCaptureStatus??{installed:!!x,rnDecoratorActive:false,rnDecoratorTooLate:false,expoPatched:false,expoAvailable:false,browserObserverActive:!!x}}export{Ve as a,g as b,N as c,O as d,V as e,U as f,K as g,D as h,ee as i,te as j,ae as k,fe as l,d as m,A as n,Ke as o,y as p,ze as q,P as r,h as s,F as t,E as u,be as v,ye as w,ge as x,ve as y,j as z,I as A,we as B,W as C,_ as D,Se as E,me as F,$ as G,k as H,zt as I,Ft as J,q as K,Wt as L,_t as M,Ht as N,$t as O,qt as P,Gt as Q,G as R,Re as S,Zt as T,Xt as U};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";var D=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Fe=Object.prototype.hasOwnProperty;var w=(e,t)=>()=>(e&&(t=e(e=0)),t);var te=(e,t)=>{for(var o in t)D(e,o,{get:t[o],enumerable:true})},B=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ze(t))!Fe.call(e,s)&&s!==o&&D(e,s,{get:()=>t[s],enumerable:!(i=je(t,s))||i.enumerable});return e},We=(e,t,o)=>(B(e,t,"default"),o&&B(o,t,"default"));var _e=e=>B(D({},"__esModule",{value:true}),e);var He,g=w(()=>{"use strict";He=(()=>{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 c(){let e=globalThis;return e[M]||(e[M]={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[M]}var M,L=w(()=>{"use strict";g();M=Symbol.for("buoy.images.globalState.v1")});function qe(e){c().remoteDispatch=e}function y(){return c().remoteDispatch}async function Ge(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 N=w(()=>{"use strict";g();L()});var re,Qe=w(()=>{"use strict";g();re='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'});import{useEffect as Ye,useState as Je}from"react";import{createPortal as Ze}from"react-dom";import{jsx as Xe}from"react/jsx-runtime";function oe(){let e=document;if(e[E])return e[E].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:re});let o=()=>{let a=document.fullscreenElement,d=a&&a.tagName!=="CANVAS"?a:document.body;t.parentElement!==d&&d.appendChild(t)},i=new Map,s=a=>{(!t.contains(a.target)||!V(a.target))&&i.set(a.code||a.key,{key:a.key,code:a.code,location:a.location,keyCode:a.keyCode,which:a.which,altKey:a.altKey,ctrlKey:a.ctrlKey,metaKey:a.metaKey,shiftKey:a.shiftKey})},r=a=>{i.delete(a.code||a.key)},u=()=>i.clear(),f=()=>{let a=[...i.values()];i.clear();for(let d of a)document.dispatchEvent(new KeyboardEvent("keyup",{...d,bubbles:true}))},l=a=>{V(a.target)&&a.stopPropagation()},n=a=>a.stopPropagation();return o(),document.addEventListener("fullscreenchange",o),document.addEventListener("keydown",s,true),document.addEventListener("keyup",r,true),window.addEventListener("blur",u),t.addEventListener("focusin",f),t.addEventListener("keydown",l),t.addEventListener("keyup",l),t.addEventListener("keypress",l),t.addEventListener("wheel",n,{passive:true}),e[E]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",o),document.removeEventListener("keydown",s,true),document.removeEventListener("keyup",r,true),window.removeEventListener("blur",u),t.remove(),delete e[E]}},t}function et({children:e}){let[t,o]=Je(null);return Ye(()=>{let i=oe(),s=document[E];return s.users++,o(i),()=>{--s.users===0&&s.dispose()}},[]),t?Ze(Xe("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var E,V,tt=w(()=>{"use strict";g();Qe();E=Symbol.for("@buoy-gg/portal-host"),V=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 ae={};te(ae,{AccessibilityInfo:()=>nt,ActivityIndicator:()=>ye,Alert:()=>we,Animated:()=>ue,AppRegistry:()=>it,AppState:()=>lt,Appearance:()=>st,BackHandler:()=>dt,Button:()=>ge,CheckBox:()=>Et,Clipboard:()=>ct,DeviceEventEmitter:()=>$t,Dimensions:()=>ut,Easing:()=>pt,FlatList:()=>ne,I18nManager:()=>ft,Image:()=>se,ImageBackground:()=>kt,InteractionManager:()=>ht,Keyboard:()=>mt,KeyboardAvoidingView:()=>Lt,LayoutAnimation:()=>bt,Linking:()=>yt,LogBox:()=>Vt,Modal:()=>he,NativeEventEmitter:()=>gt,NativeModules:()=>at,PanResponder:()=>vt,Picker:()=>Ct,PixelRatio:()=>$,Platform:()=>wt,Pressable:()=>me,ProgressBar:()=>It,RefreshControl:()=>Mt,SafeAreaView:()=>Rt,ScrollView:()=>W,SectionList:()=>Tt,Share:()=>xt,StatusBar:()=>Pt,StyleSheet:()=>j,Switch:()=>be,Text:()=>T,TextInput:()=>z,Touchable:()=>Ot,TouchableHighlight:()=>pe,TouchableNativeFeedback:()=>Dt,TouchableOpacity:()=>F,TouchableWithoutFeedback:()=>fe,UIManager:()=>St,Vibration:()=>At,View:()=>R,VirtualizedList:()=>Bt,YellowBox:()=>Nt,findNodeHandle:()=>ve,unstable_createElement:()=>ot,useColorScheme:()=>Ut,useLocaleContext:()=>Kt,useWindowDimensions:()=>jt});import*as rt from"react-native-web";import{unstable_createElement as ot,NativeModules as at,AccessibilityInfo as nt,Appearance as st,AppRegistry as it,AppState as lt,BackHandler as dt,Clipboard as ct,Dimensions as ut,Easing as pt,I18nManager as ft,Keyboard as mt,InteractionManager as ht,LayoutAnimation as bt,Linking as yt,NativeEventEmitter as gt,PanResponder as vt,PixelRatio as $,Platform as wt,Share as xt,UIManager as St,Vibration as At,CheckBox as Et,FlatList as ne,Image as se,ImageBackground as kt,KeyboardAvoidingView as Lt,Picker as Ct,ProgressBar as It,RefreshControl as Mt,SafeAreaView as Rt,SectionList as Tt,StatusBar as Pt,Touchable as Ot,TouchableNativeFeedback as Dt,VirtualizedList as Bt,YellowBox as Nt,LogBox as Vt,DeviceEventEmitter as $t,useColorScheme as Ut,useLocaleContext as Kt,useWindowDimensions as jt}from"react-native-web";import*as m from"react-native-web";import{createElement as U,forwardRef as ie,useCallback as zt,useRef as Ft}from"react";function K(e){if(Array.isArray(e)){let d=e.map(K);return d.some((p,A)=>p!==e[A])?d:e}if(!e||typeof e!="object"||!de.some(d=>e[d]!=null))return e;let{shadowColor:t,shadowOffset:o,shadowOpacity:i,shadowRadius:s,textShadowColor:r,textShadowOffset:u,textShadowRadius:f,...l}=e;if(t!=null||o!=null||i!=null||s!=null){let d=t??"black",p=i==null?d:`color-mix(in srgb, ${d} ${Math.min(i,1)*100}%, transparent)`,A=`${S(o?.width??0)} ${S(o?.height??0)} ${S(s??0)} ${p}`;l.boxShadow=typeof l.boxShadow=="string"?`${l.boxShadow}, ${A}`:l.boxShadow??A}let{width:n=0,height:a=0}=u??{};if(r&&(n||a||f)){let d=`${S(n)} ${S(a)} ${S(f??0)} ${r}`;l.textShadow=l.textShadow?`${l.textShadow}, ${d}`:d}return l}function le(e,t){if(typeof e=="function")return i=>le(e(i),t);let o=K(e);return t?[o,ce[t]]:o}function b(e){let t=ie((i,s)=>{let{accessibilityState:r,accessibilityValue:u,pointerEvents:f,...l}=i;for(let a of["busy","checked","disabled","expanded","selected"])r?.[a]!==void 0&&l[`aria-${a}`]===void 0&&(l[`aria-${a}`]=r[a]);for(let[a,d]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))u?.[a]!==void 0&&l[`aria-${d}`]===void 0&&(l[`aria-${d}`]=u[a]);let n=le(l.style,f);return n!==l.style&&(l.style=n),U(e,{...l,ref:s})}),o=e.State;return o&&Object.assign(t,{State:o}),t.displayName=e.displayName??e.name??"NativeWebView",t}var x,de,S,ce,j,R,T,ue,z,F,pe,fe,me,W,_,he,be,ye,ge,ve,we,xe=w(()=>{g();We(ae,rt);tt();x=m,de=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],S=e=>typeof e=="number"?`${e}px`:e;ce=x.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});j={...x.StyleSheet,create:e=>x.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,o])=>[t,K(o)])))};R=b(m.View),T=b(m.Text),ue={...x.Animated,View:x.Animated.createAnimatedComponent(R),Text:x.Animated.createAnimatedComponent(T)},z=b(m.TextInput),F=b(m.TouchableOpacity),pe=b(m.TouchableHighlight),fe=b(m.TouchableWithoutFeedback),me=b(m.Pressable),W=b(m.ScrollView),_=ie((e,t)=>{let o=Ft(null),i=zt(s=>{if(s){let r=s;for(;r.parentElement&&r.parentElement!==document.body;)r=r.parentElement;r.parentElement===document.body&&(o.current=r,Object.assign(r.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),oe().appendChild(r))}else o.current&&(document.body.appendChild(o.current),o.current=null);typeof t=="function"?t(s):t&&(t.current=s)},[t]);return U(et,null,U(m.Modal,{...e,ref:i}))});_.displayName="Modal";he=b(_),be=b(m.Switch),ye=b(m.ActivityIndicator),ge=b(m.Button),ve=m.findNodeHandle,we={alert(e,t,o,i){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 n=document.createElement("p");n.textContent=t,n.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",s.appendChild(n)}let u=document.createElement("div");u.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let f=o?.length?o:[{text:"OK"}],l=()=>{s.close?.(),s.remove()};for(let n of f){let a=document.createElement("button");a.type="button",a.textContent=n.text??"OK",a.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${n.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,a.onclick=()=>{l(),n.onPress?.()},u.appendChild(a)}s.addEventListener("cancel",n=>{n.preventDefault(),i?.cancelable!==false&&(l(),i?.onDismiss?.())}),s.appendChild(u),document.body.appendChild(s),s.showModal?s.showModal():s.setAttribute("open","")}}});var Se={};te(Se,{clearRecords:()=>ke,computeStats:()=>Re,createRecord:()=>Ae,disableImagesCapture:()=>Le,effectivePixelRatio:()=>q,estDecodedBytes:()=>G,estWastedBytes:()=>Q,getRecord:()=>H,getSnapshot:()=>C,neededPixels:()=>O,oversizeFactor:()=>Me,replaceImagesFromSnapshot:()=>Ce,subscribe:()=>Ee,updateRecord:()=>h});import{isBuoyAssetPath as Wt}from"@buoy-gg/shared-ui/web";function _t(){let e=c();e.emitScheduled||(e.emitScheduled=true,requestAnimationFrame(()=>{e.emitScheduled=false;for(let t of e.listeners)t()}))}function P(){let e=c();e.snapshot=[...e.records],_t()}function Ae(e){let t=c(),o={...e,id:t.nextId++,createdAt:Date.now(),status:"pending",mounted:true,loadCount:0};if(t.records.push(o),t.byId.set(o.id,o),t.records.length>Y){let i=t.records.splice(0,t.records.length-Y);for(let s of i)t.byId.delete(s.id)}return P(),o}function h(e,t){let o=c().byId.get(e);if(o)return Object.assign(o,t),P(),o}function H(e){return c().byId.get(e)}function C(){return c().snapshot}function Ee(e){return c().listeners.add(e),()=>c().listeners.delete(e)}function ke(){y()?.("clearRecords");let e=c();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])),P()}function Le(){c().captureDisabled=true}function Ce(e){let t=c(),o=(e.records??[]).filter(r=>!Wt(r.uri)),i=0;for(let r of o)r.layout&&r.neededPx&&r.layout.width>i&&(i=r.layout.width,t.mirrorPixelRatio=r.neededPx.width/r.layout.width);let s=Date.now();t.records=[...o].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),P();for(let r of t.actionListeners)r()}function q(){return c().mirrorPixelRatio??$.get()}function O(e){if(!e.layout||e.layout.width<=0||e.layout.height<=0)return null;let t=q();return{width:Math.round(e.layout.width*t),height:Math.round(e.layout.height*t)}}function Ie(e){return e.mediaType==="image/svg+xml"||/^data:image\/svg\+xml/i.test(e.uri)||/\.svg(?:[?#]|$)/i.test(e.uri)}function Me(e){let t=O(e);if(!t||!e.intrinsic||Ie(e))return null;let o=t.width*t.height,i=e.intrinsic.width*e.intrinsic.height;return o<=0||i<=0?null:Math.sqrt(i/o)}function G(e){return e.intrinsic?e.intrinsic.width*e.intrinsic.height*4:0}function Q(e){let t=O(e);if(!t||!e.intrinsic||Ie(e))return 0;let o=(e.intrinsic.width*e.intrinsic.height-t.width*t.height)*4;return Math.max(0,o)}function Re(e){let t={total:e.length,loading:0,loaded:0,errors:0,networkLoads:0,estDecodedBytes:0,estWastedBytes:0};for(let o of e)(o.status==="loading"||o.status==="pending")&&o.mounted&&t.loading++,o.status==="loaded"&&t.loaded++,o.status==="error"&&t.errors++,(o.progressSeen||o.cacheVerdict==="none")&&t.networkLoads++,o.mounted&&o.status==="loaded"&&(t.estDecodedBytes+=G(o),t.estWastedBytes+=Q(o));return t}var Y,J=w(()=>{"use strict";g();xe();N();L();Y=500});g();N();L();J();function Te(){for(let e of c().actionListeners)e()}function Pe(e){let t=c();if(e!=null){t.expoInstances.get(e)?.forceUpdate?.();return}for(let o of t.expoInstances.values())o?.forceUpdate?.()}function I(e){let t=c();t.recordVersions.set(e,++t.versionCounter),Te(),Pe(e)}function Oe(){let e=c();e.globalVersion=++e.versionCounter,Te(),Pe()}function Ht(e,t){return t.type==="url"?{id:e,kind:"url",uri:t.uri}:{id:e,kind:t.type}}function De(e,t){c().overrides.set(e,t),h(e,{overrideLabel:t.label}),I(e)}function qt(e,t){t.source&&y()?.("setOverride",Ht(e,t.source)),De(e,t)}function Be(e){c().overrides.delete(e),h(e,{overrideLabel:void 0}),I(e)}function Gt(e){y()?.("clearOverride",{id:e}),Be(e)}function Z(e){if(e!=null)return c().overrides.get(e)}function Qt(e){return e.type==="hang"?"loading":e.type}function Yt(e,t){y()?.("massAction",{kind:Qt(e)});let o=0;for(let i of C())i.mounted&&(De(i.id,{source:e,label:t}),o++);return o}function Jt(){y()?.("massAction",{kind:"restore"});let e=new Set(c().overrides.keys());for(let t of C())t.overrideLabel!=null&&e.add(t.id);for(let t of e)Be(t);return e.size}function Zt(e=2500){y()?.("massAction",{kind:"flash"});let t=0;for(let o of C())o.mounted&&(Ne(o.id,e),t++);return t}function Ne(e,t=2500){c().flashUntil.set(e,Date.now()+t),I(e),setTimeout(()=>{c().flashUntil.delete(e),I(e)},t+50)}function Xt(e,t=2500){y()?.("flash",{id:e}),Ne(e,t)}function er(e){y()?.("setNetworkMode",{mode:e}),c().globalModes.network=e,Oe()}function tr(e){y()?.("setBlankImages",{enabled:e}),c().globalModes.blank=e,Oe()}function X(){return c().globalModes}g();L();J();import{isBuoyElement as rr,isBuoyAssetPath as or}from"@buoy-gg/shared-ui/web";var v=new Map,k,Ve=0,$e="data:image/png;base64,";function ee(e){let t=H(e.id);if(!t)return;let o=c(),i=Z(e.id),s=X(),r=e.source;if(s.network==="offline"&&t.sourceKind==="network"&&(r=$e),i?.source){let a=i.source;a.type==="url"?r=a.uri:a.type==="error"?r=$e:r=null,a.type==="hang"&&h(e.id,{status:"loading"})}let u=o.reloadRequests.get(e.id),f=u&&u.nonce!==e.nonce;if(f){if(e.nonce=u.nonce,u.bust&&r&&/^https?:/.test(new URL(r,document.baseURI).href)){let a=new URL(r,document.baseURI);a.searchParams.set("__buoy_reload",String(Date.now())),r=a.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 a=new URL(r,document.baseURI);a.searchParams.set("__buoy_reload",`${Date.now()}-${e.nonce}`),e.coldURL=a.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 l=document.createElement("span").style;l.cssText=e.style??"";let n=i?.extraProps?.contentFit??i?.extraProps?.resizeMode;typeof n=="string"&&(l.objectFit={stretch:"fill",center:"none"}[n]??n),(s.blank||i?.source?.type==="blank")&&(l.opacity="0");for(let[a,d]of Object.entries(i?.style??{})){let p=a.replace(/[A-Z]/g,A=>`-${A.toLowerCase()}`);l.setProperty(p,typeof d=="number"&&!["opacity","zIndex","flex","flexGrow","flexShrink"].includes(a)?`${d}px`:String(d))}(o.flashUntil.get(e.id)??0)>Date.now()&&(l.outline="3px solid #ff453a"),e.appliedStyle=l.cssText||null,e.image.getAttribute("style")!==e.appliedStyle&&(e.appliedStyle===null?e.image.removeAttribute("style"):e.image.setAttribute("style",e.appliedStyle))}function ar(e){if(v.has(e)||rr(e))return;let t=e.currentSrc||e.src;if(!t||or(t))return;let o=Ae({lib:"web",uri:t,sourceKind:t.startsWith("data:")?"data":t.startsWith("blob:")?"file":"network",hasAltText:e.hasAttribute("alt")||e.hasAttribute("aria-label")}),i={id:o.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 l=e.getBoundingClientRect(),n=o.layout,a=o.status==="loaded"&&n&&(n.width!==l.width||n.height!==l.height);h(o.id,{layout:{width:l.width,height:l.height},layoutShifts:(o.layoutShifts??0)+(a?1:0)})},r=()=>{let l=performance.getEntriesByName(e.currentSrc||e.src),n=l[l.length-1];h(o.id,{status:"loaded",loadedAt:Date.now(),intrinsic:{width:e.naturalWidth,height:e.naturalHeight},...!Z(o.id)?.source&&X().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}),s()},u=()=>h(o.id,{status:"error",erroredAt:Date.now(),error:"The browser could not load this image."});e.addEventListener("load",r),e.addEventListener("error",u);let f=typeof ResizeObserver>"u"?void 0:new ResizeObserver(s);f?.observe(e),i.dispose=()=>{f?.disconnect(),e.removeEventListener("load",r),e.removeEventListener("error",u)},v.set(e,i),s(),h(o.id,{status:"loading",startedAt:Date.now(),loadCount:1}),e.complete&&(e.naturalWidth>0?r():u()),ee(i)}function Ue(){let e=c();if(typeof document>"u"||e.captureDisabled||k)return;e.captureInstalled=true;let t=new WeakSet,o=n=>{n.querySelectorAll("img").forEach(ar);let a=document.createTreeWalker(n,NodeFilter.SHOW_ELEMENT);for(let d=a.nextNode();d;d=a.nextNode()){let p=d.shadowRoot;p&&(t.has(p)||(t.add(p),r.observe(p,s)),o(p))}},i=()=>{for(let[n,a]of v)n.isConnected||(a.dispose(),v.delete(n),h(a.id,{mounted:false}));o(document)},s={childList:true,subtree:true,attributes:true,attributeFilter:["src","srcset","style","alt"]},r=new MutationObserver(n=>{if(c().captureDisabled){Ke();return}for(let a of n){let d=a.target,p=v.get(d);!p||a.type!=="attributes"||(a.attributeName==="src"&&d.getAttribute("src")!==p.appliedSource||a.attributeName==="srcset"&&d.getAttribute("srcset")!==p.appliedSrcset?(p.dispose(),v.delete(d),h(p.id,{mounted:false})):a.attributeName==="style"&&d.getAttribute("style")!==p.appliedStyle&&(p.style=d.getAttribute("style"),ee(p)))}i()});r.observe(document.documentElement,s);let u=Element.prototype.attachShadow,f=function(n){let a=u.call(this,n);return n.mode==="open"&&!t.has(a)&&(t.add(a),r.observe(a,s)),a};Element.prototype.attachShadow=f;let l=()=>{for(let n of v.values())ee(n)};e.actionListeners.add(l),k=()=>{r.disconnect(),e.actionListeners.delete(l),Element.prototype.attachShadow===f&&(Element.prototype.attachShadow=u);for(let n of v.values()){n.dispose();for(let[a,d,p]of[["src",n.source,n.appliedSource],["srcset",n.srcset,n.appliedSrcset],["style",n.style,n.appliedStyle]])n.image.getAttribute(a)===p&&(d===null?n.image.removeAttribute(a):n.image.setAttribute(a,d));h(n.id,{mounted:false})}v.clear(),e.captureInstalled=false},i()}function Ke(){k?.(),k=void 0}function nr(){if(typeof document>"u")return()=>{};Ve++===0&&Ue();let e=false;return()=>{e||(e=true,--Ve===0&&Ke())}}function sr(){return c().mirrorCaptureStatus??{installed:!!k,rnDecoratorActive:false,rnDecoratorTooLate:false,expoPatched:false,expoAvailable:false,browserObserverActive:!!k}}export{_e as a,g as b,j as c,R as d,T as e,z as f,F as g,W as h,$ as i,ne as j,se as k,xe as l,c as m,L as n,qe as o,y as p,Ge as q,N as r,h as s,H as t,C as u,Ee as v,ke as w,Le as x,Ce as y,q as z,O as A,Me as B,G as C,Q as D,Re as E,Se as F,J as G,I as H,qt as I,Gt as J,Z as K,Yt as L,Jt as M,Zt as N,Xt as O,er as P,tr as Q,X as R,Ue as S,nr as T,sr 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 gt,G as M,H as pt,I as H,J as ie,K as yt,L as G,M as fe,N as ve,O as xe,P as we,Q as Ke,R as j,S as qe,T as bt,U as _,a as ft,b as y,c as
|
|
1
|
+
"use client";import{A as re,B as ye,C as oe,D as ae,E as be,F as gt,G as M,H as pt,I as H,J as ie,K as yt,L as G,M as fe,N as ve,O as xe,P as we,Q as Ke,R as j,S as qe,T as bt,U as _,a as ft,b as y,c as C,d as m,e as g,f as vt,g as I,h as xt,i as wt,j as $t,k as Ge,l as E,m as le,n as kt,o as St,p as V,q as $e,r as J,s as Ct,t as _e,u as ne,v as ke,w as Se,x as It,y as Rt,z as Dt}from"./chunks/chunk-CUHKOIVI.mjs";y();y();y();y();import{ImagesIcon as Je,IMAGES_ICON_COLOR as Qe}from"@buoy-gg/shared-ui/web";y();E();import{useEffect as Bt,useState as Tt}from"react";import{JsModal as Mt,macOSColors as zt,night as se,windowDragProps as At,ToolEmptyState as Lt}from"@buoy-gg/shared-ui/web";y();E();M();y();function de(e){let t=new Map,r=[],o=[],i=0,l=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"&&l++;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:l>4,missingAlt:i,layoutShifters:o}}function Xe(e){let t=[];if(e.duplicates.length>0){let r=e.duplicates.reduce((o,i)=>o+i.count-1,0);t.push({key:"duplicates",text:`${e.duplicates.length} duplicate URL${e.duplicates.length>1?"s":""} (${r} redundant loads)`})}return e.retryStorms.length>0&&t.push({key:"retry",text:`${e.retryStorms.length} retry storm${e.retryStorms.length>1?"s":""}`}),e.queueSaturated&&t.push({key:"queue",text:"iOS image queue saturated (>4 loading)"}),e.missingAlt>0&&t.push({key:"alt",text:`${e.missingAlt} missing alt text`}),e.layoutShifters.length>0&&t.push({key:"shift",text:`${e.layoutShifters.length} layout-shifting image${e.layoutShifters.length>1?"s":""}`}),t}function Ye(e){return Xe(e).map(t=>t.text)}y();M();import{macOSColors as z,night as Ce}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 Ie(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:Ce.color.textTertiary,factor:t}:t<.9?{label:`${t.toFixed(1)}\xD7 upscaled`,color:z.semantic.info,factor:t}:t<=1.1?{label:"right-sized",color:z.semantic.success,factor:t}:t<=1.5?{label:`${t.toFixed(1)}\xD7 oversized`,color:z.semantic.warning,factor:t}:{label:`${t.toFixed(1)}\xD7 oversized`,color:z.semantic.error,factor:t}}function Pt(e){switch(e.status){case"loaded":return z.semantic.success;case"error":return z.semantic.error;case"loading":return z.semantic.warning;default:return Ce.color.textTertiary}}function ue(e){let t=e.cacheVerdict;return t==="memory"||t==="disk/memory"?{label:t.toUpperCase(),color:z.semantic.success}:t==="disk"?{label:"DISK",color:z.semantic.warning}:t==="none"||e.progressSeen?{label:"NETWORK",color:z.semantic.error}:{label:"?",color:Ce.color.textTertiary}}function Ze(e){let t=ce(e),r=ue(e),o=re(e),i=oe(e),l=ae(e),a=[];return a.push(`## Image report \u2014 ${Ie(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 @${wt.get()}x (needs ${o?`${o.width}\xD7${o.height}px`:"?"})`),t.label&&a.push(`- Size verdict: ${t.label}${l>0&&o?` \u2014 wasting \u2248${x(l)}; 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 et(e,t,r,o,i){let l=[];l.push(`## Buoy Images registry (${t.total} records)`),l.push(""),l.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=Ye(r);a.length>0&&l.push(`Insights: ${a.join(" \xB7 ")}`),(i.network!=="normal"||i.blank)&&l.push(`Simulation active: network=${i.network}${i.blank?", blank images":""}`),o.rnDecoratorTooLate&&l.push("\u26A0 RN <Image> capture inactive (register import too late)"),l.push(""),l.push("| image | lib | status | cache | ms | decoded px | shown dp | verdict | notes |"),l.push("|---|---|---|---|---|---|---|---|---|");for(let s of e){let u=ce(s),S=ue(s),h=s.intrinsic?`${s.intrinsic.width}\xD7${s.intrinsic.height}`:"\u2013",$=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("; ");l.push(`| ${Ie(s.uri)} | ${s.lib} | ${s.status} | ${S.label} | ${s.durationMs!=null?Math.round(s.durationMs):"\u2013"} | ${h} | ${$} | ${u.label||"\u2013"} | ${p||"\u2013"} |`)}return l.join(`
|
|
3
|
-
`)}y();M();import{useMemo as Ot,useSyncExternalStore as Et}from"react";function tt(){let e=Et(ke,ne,ne);return Ot(()=>({records:[...e].reverse(),stats:be(e)}),[e])}J();M();y();y();function Re(){return null}function Ft(){return null}function Wt(){return null}E();import{useState as De}from"react";import{macOSColors as R,night as b,monoFont as Nt}from"@buoy-gg/shared-ui/web";y();J();M();import{buoyFetch as Ht}from"@buoy-gg/shared-ui/web";var X=new Map;async function Be(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 Ht(e.uri);if(!o.ok)throw new Error(`Image download returned HTTP ${o.status}.`);let i=await o.blob(),l=await createImageBitmap(i),a=document.createElement("canvas");a.width=Math.max(1,Math.min(l.width,Math.round(r.width))),a.height=Math.max(1,Math.min(l.height,Math.round(r.height)));let s=a.getContext("2d");if(!s)throw l.close(),new Error("Canvas is unavailable.");s.drawImage(l,0,0,a.width,a.height),l.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 $=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:$,savedPct:i.size?$/i.size*100:0}}catch(o){return{ok:false,message:`Image optimization failed: ${o instanceof Error?o.message:String(o)}`}}}J();M();import{Fragment as jt,jsx as n,jsxs as w}from"react/jsx-runtime";function F({title:e,children:t}){return w(m,{style:d.section,children:[n(g,{style:d.sectionTitle,children:e}),n(m,{style:d.sectionBody,children:t})]})}function Vt(e){return`buoy-images-detail-${e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}`}function c({label:e,value:t,color:r}){return w(m,{style:d.kvRow,children:[n(g,{style:d.kvLabel,children:e}),n(g,{testID:Vt(e),style:[d.kvValue,r?{color:r}:null],selectable:true,children:t})]})}function rt(e){let t=V();if(t){t("clearExpoCaches",{memory:e==="memory",disk:e==="disk"});return}try{let r=Re();e==="memory"?r.Image.clearMemoryCache():r.Image.clearDiskCache()}catch{}}function Ut({record:e}){let[t,r]=De(e.uri),o=t.trim(),i=e.mounted&&o.length>0&&o!==e.uri;return w(F,{title:"SWAP SOURCE URL",children:[n(vt,{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:[n(C,{style:[d.actionButton,!i&&d.actionDisabled],disabled:!i,onPress:()=>H(e.id,{source:{type:"url",uri:o},label:"URL swapped"}),children:n(g,{style:d.actionText,children:"Apply"})}),n(C,{style:d.actionButton,onPress:()=>r(e.uri),children:n(g,{style:d.actionText,children:"Reset field"})})]})]})}function Kt({record:e}){let[t,r]=De(false),[o,i]=De(null),l=()=>{r(true),Be(e).then(i).catch(a=>i({ok:false,message:String(a?.message??a)})).finally(()=>r(false))};return n(F,{title:"PROVE SAVINGS (re-encode on device)",children:o==null?n(m,{style:d.actionsRow,children:n(C,{style:d.actionButton,onPress:l,disabled:t,children:n(g,{style:d.actionText,children:t?"Re-encoding\u2026":"Re-encode at displayed size (WebP)"})})}):w(jt,{children:[n(c,{label:"Result",value:o.message||(o.ok?"done":"failed"),color:o.ok?R.semantic.success:R.semantic.error}),o.originalBytes!=null?n(c,{label:"Original",value:`${x(o.originalBytes)} (${o.originalBytesSource})`}):null,o.optimizedBytes!=null?n(c,{label:"Optimized",value:`${x(o.optimizedBytes)} \u2014 ${o.optimizedDims?.width}\xD7${o.optimizedDims?.height} WebP`,color:R.semantic.success}):null,o.savedBytes!=null?n(c,{label:"Saved",value:`${x(o.savedBytes)} (${o.savedPct}%)`,color:R.semantic.success}):null,w(m,{style:d.actionsRow,children:[o.ok&&o.optimizedUri&&e.mounted?n(C,{style:d.actionButton,onPress:()=>H(e.id,{source:{type:"url",uri:o.optimizedUri},label:"Optimized preview"}),children:n(g,{style:d.actionText,children:"Preview in place"})}):null,n(C,{style:d.actionButton,onPress:l,disabled:t,children:n(g,{style:d.actionText,children:t?"Re-encoding\u2026":"Re-run"})})]})]})})}function qt({record:e}){let t=ce(e),r=ue(e),o=re(e),i=oe(e),l=ae(e);return w(xt,{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."]}),n(C,{onPress:()=>ie(e.id),children:n(g,{style:d.overrideRestore,children:"RESTORE"})})]}):null,e.uri&&e.sourceKind!=="data"?n(m,{style:d.previewBox,children:n(Ge,{testID:"buoy-internal-images-preview",source:{uri:e.uri},style:d.preview,resizeMode:"contain"})}):null,w(F,{title:"SOURCE",children:[n(c,{label:"URI",value:e.uri||"(none)"}),n(c,{label:"Kind",value:e.sourceKind}),n(c,{label:"Library",value:e.lib==="web"?"Browser <img>":e.lib==="expo"?"expo-image":"RN <Image>"}),e.hasAltText===false?n(c,{label:"Alt text",value:"missing \u2014 add alt/accessibilityLabel",color:R.semantic.warning}):null,e.mediaType!=null?n(c,{label:"Media type",value:String(e.mediaType)}):null,e.isAnimated!=null?n(c,{label:"Animated",value:e.isAnimated?"yes":"no"}):null]}),w(F,{title:"LOAD",children:[n(c,{label:"Status",value:e.status,color:e.status==="error"?R.semantic.error:e.status==="loaded"?R.semantic.success:R.semantic.warning}),n(c,{label:"Duration",value:Q(e.durationMs)}),e.displayedAt&&e.loadedAt?n(c,{label:"Decode \u2192 display",value:Q(Math.max(0,e.displayedAt-e.loadedAt))}):null,n(c,{label:"Cache",value:`${r.label}`,color:r.color}),e.cacheVerdictSource?n(c,{label:"Cache source",value:e.cacheVerdictSource==="event"?"reported by expo-image onLoad":"Image.queryCache after load"}):null,e.progressSeen?n(c,{label:"Downloaded",value:e.bytesTotal?`${x(e.bytesLoaded??0)} / ${x(e.bytesTotal)}`:"network transfer observed"}):null,n(c,{label:"Load cycles",value:String(e.loadCount)}),n(c,{label:"Still mounted",value:e.mounted?"yes":"no"})]}),w(F,{title:"DIMENSIONS",children:[e.intrinsic?n(c,{label:"Decoded",value:`${e.intrinsic.width}\xD7${e.intrinsic.height} px`}):n(c,{label:"Decoded",value:"unknown"}),e.layout?n(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(Dt()*100)/100}x)`}):n(c,{label:"Displayed",value:"no layout yet"}),t.label?n(c,{label:"Verdict",value:t.label,color:t.color}):null,i>0?n(c,{label:"Est. decoded memory",value:x(i)}):null,l>0?n(c,{label:"Est. wasted",value:`${x(l)} \u2014 resize the source to ${o?`${o.width}\xD7${o.height}`:"the displayed size"}`,color:R.semantic.warning}):null,(e.layoutShifts??0)>0?n(c,{label:"Layout shifts",value:`${e.layoutShifts} \u2014 box resized after load; reserve explicit width/height`,color:R.semantic.warning}):null]}),e.sourceKind==="network"||e.sourceKind==="asset"?n(Kt,{record:e},`savings-${e.id}`):null,e.status==="error"?w(F,{title:"ERROR",children:[n(c,{label:"Message",value:e.error??"unknown",color:R.semantic.error}),e.errorCode!=null?n(c,{label:"HTTP status",value:String(e.errorCode)}):null,e.errorHeaders?Object.entries(e.errorHeaders).map(([a,s])=>n(c,{label:a,value:String(s)},a)):null]}):null,e.sourceKind==="network"&&e.mounted?n(Ut,{record:e},e.id):null,e.lib==="expo"?n(F,{title:"CACHE ACTIONS (expo-image, global)",children:w(m,{style:d.actionsRow,children:[n(C,{style:d.actionButton,onPress:()=>rt("memory"),children:n(g,{style:d.actionText,children:"Clear memory cache"})}),n(C,{style:d.actionButton,onPress:()=>rt("disk"),children:n(g,{style:d.actionText,children:"Clear disk cache"})})]})}):null]})}var d=I.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:I.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:I.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:Nt,backgroundColor:b.color.surfaceElevated,borderRadius:6,borderWidth:I.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 Gt}from"react";import{ChevronLeft as _t,ChevronRight as Jt,FooterButton as Te,FooterMessage as ot,FooterRow as at,RefreshCw as Qt,ToolFooter as Xt,night as W}from"@buoy-gg/shared-ui/web";y();J();kt();function Yt(e){return le().actionListeners.add(e),()=>le().actionListeners.delete(e)}function it(e,t){let r=le(),o=r.reloadRequests.get(e);r.reloadRequests.set(e,{nonce:(o?.nonce??0)+1,bust:t}),pt(e)}function lt(){try{return Re().Image??null}catch{return null}}function Zt(){try{let e=Ft(),t=e?.default||e;if(t?.deleteAsync)return t}catch{}try{let e=Wt(),t=e?.default||e;if(t?.deleteAsync)return t}catch{}return null}async function Me(e){let t=lt(),r=Zt();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 $e(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 it(e.id,false),{ok:true,message:"Remounting image"}}async function ze(){let e=V();if(e)return $e(e("massAction",{kind:"reload"}));let{getSnapshot:t}=(M(),ft(gt)),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 $e(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 Me(e);await lt()?.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 it(e.id,true),{ok:true,message:"Refetching with cache bypassed"}}import{jsx as f,jsxs as Ae}from"react/jsx-runtime";function er({record:e,hasPrevious:t,hasNext:r,onPrevious:o,onNext:i}){let[l,a]=Gt(null),s=$=>{a("\u2026"),$().then(p=>a(p.message)).catch(p=>a(String(p?.message??p)))},u=!e.mounted,S=e.overrideLabel!=null,h=($,p)=>{H(e.id,{source:$,label:p}),a(`${p} \u2014 Restore to undo`)};return Ae(Xt,{children:[l?f(ot,{testID:"buoy-images-detail-footer-message",children:l}):u?f(ot,{tone:"muted",children:"Instance unmounted \u2014 reload actions need the image on screen."}):null,Ae(at,{style:{gap:8},children:[f(C,{onPress:o,disabled:!t,style:[me.navButton,!t&&me.disabled],activeOpacity:.7,testID:"buoy-images-detail-previous",accessibilityLabel:"Previous image",children:f(_t,{size:20,color:t?W.color.accent:W.color.textTertiary})}),f(Te,{label:"Hard reload",size:"md",testID:"buoy-images-detail-hard-reload",disabled:u,icon:f(Qt,{size:13,color:u?W.color.textTertiary:W.color.info}),onPress:()=>s(()=>he(e))}),f(Te,{label:e.status==="error"?"Retry":"Reload",size:"md",testID:"buoy-images-detail-reload",disabled:u,onPress:()=>s(()=>Y(e))}),f(C,{onPress:i,disabled:!r,style:[me.navButton,!r&&me.disabled],activeOpacity:.7,testID:"buoy-images-detail-next",accessibilityLabel:"Next image",children:f(Jt,{size:20,color:r?W.color.accent:W.color.textTertiary})})]}),Ae(at,{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(Te,{label:e,onPress:t,disabled:r,accent:o,testID:`buoy-images-sim-${e.toLowerCase()}`,style:{paddingVertical:7}})}var me=I.create({navButton:{paddingHorizontal:10,paddingVertical:8,borderRadius:6,backgroundColor:W.color.button,alignItems:"center",justifyContent:"center"},disabled:{opacity:.4}});y();E();import{macOSColors as tr,night as A,Pill as Le}from"@buoy-gg/shared-ui/web";import{jsx as D,jsxs as ee}from"react/jsx-runtime";function rr({record:e,onPress:t}){let r=ce(e),o=ue(e),i=e.sourceKind==="network"||e.sourceKind==="asset"||e.sourceKind==="file",l=`buoy-image-row-${e.id}`;return ee(C,{style:k.row,testID:l,onPress:()=>t(e.id),children:[ee(m,{style:k.thumbBox,children:[i&&e.uri?D(Ge,{testID:"buoy-internal-images-thumb",source:{uri:e.uri},style:k.thumb,resizeMode:"cover"}):D(g,{style:k.thumbFallback,children:"?"}),D(m,{testID:`${l}-status`,accessibilityLabel:e.status,style:[k.statusDot,{backgroundColor:Pt(e)}]})]}),ee(m,{style:k.main,children:[D(g,{style:k.name,numberOfLines:1,testID:`${l}-name`,children:Ie(e.uri)}),ee(m,{style:k.metaRow,children:[D(Le,{variant:"text",label:e.lib==="web"?"WEB":e.lib==="expo"?"EXPO":"RN",color:A.color.textTertiary}),D(Le,{variant:"text",label:o.label,color:o.color,testID:`${l}-cache`}),e.overrideLabel?D(Le,{variant:"text",label:"SIM",color:A.color.warning,testID:`${l}-sim`}):null,D(g,{style:k.meta,children:Q(e.durationMs)}),e.intrinsic?ee(g,{style:k.meta,testID:`${l}-size`,children:[e.intrinsic.width,"\xD7",e.intrinsic.height]}):null]})]}),D(m,{style:k.right,children:e.status==="error"?D(g,{testID:`${l}-verdict`,style:[k.verdict,{color:tr.semantic.error}],children:"FAILED"}):r.label?D(g,{testID:`${l}-verdict`,style:[k.verdict,{color:r.color}],children:r.label}):null})]})}var k=I.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:I.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 L,ToolbarClearButton as or,ToolbarCopyButton as nt}from"@buoy-gg/shared-ui/web";import{jsx as P,jsxs as Pe}from"react/jsx-runtime";function ar({stats:e,detailOpen:t,detailIndex:r=-1,detailTotal:o=0,onCloseDetail:i,onClear:l,getReport:a,onBack:s}){if(t){let S=r>=0&&o>0?`${r+1} of ${o}`:void 0;return Pe(L,{children:[P(L.Navigation,{onBack:i}),P(L.Content,{title:"Image detail",subtitle:S,testID:"buoy-images-detail-title"}),P(L.Actions,{children:P(nt,{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`),Pe(L,{children:[s?P(L.Navigation,{onBack:s}):null,P(L.Content,{title:"Images",subtitle:u.join(" \xB7 "),testID:"buoy-images-title"}),Pe(L.Actions,{children:[P(nt,{value:a}),P(or,{onPress:l,testID:"buoy-images-clear"})]})]})}y();E();import{useState as ir,useSyncExternalStore as lr}from"react";import{FooterButton as st,FooterCaption as nr,FooterMessage as sr,FooterRow as dt,ToolFooter as dr,night as cr}from"@buoy-gg/shared-ui/web";import{jsx as B,jsxs as Oe}from"react/jsx-runtime";var ur=[{key:"normal",label:"Normal"},{key:"offline",label:"Offline"},{key:"cold",label:"Cold"}];function hr(){let[e,t]=ir(null),r=lr(Yt,()=>j().network),o=(i,l)=>{let a=G(i,l);t(a>0?`${l} on ${a} image${a===1?"":"s"} \u2014 Restore all to undo`:"No mounted images")};return Oe(dr,{paddingBottom:10,style:{paddingTop:8},children:[e?B(sr,{testID:"buoy-images-message",children:e}):B(nr,{children:"MASS ACTIONS \u2014 every image on screen"}),Oe(dt,{children:[B(U,{label:"Error",onPress:()=>o({type:"error"},"Forced error")}),B(U,{label:"Loading",onPress:()=>o({type:"hang"},"Forced loading")}),B(U,{label:"Blank",onPress:()=>o({type:"blank"},"Blanked")}),B(U,{label:"Reload",onPress:()=>{t("\u2026"),ze().then(i=>t(i.message))}}),B(U,{label:"Find",onPress:()=>{let i=ve();t(`Flashing ${i} image${i===1?"":"s"} (2.5s)`)}}),B(U,{label:"Restore",accent:true,onPress:()=>{let i=fe();t(i>0?`Restored ${i} image${i===1?"":"s"}`:"No overrides active")}})]}),Oe(dt,{children:[B(g,{style:mr.netLabel,children:"NET"}),ur.map(i=>{let l=r===i.key;return B(st,{label:i.label,active:l,testID:`buoy-images-net-${i.key}`,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 B(st,{label:e,onPress:t,accent:r,testID:`buoy-images-mass-${e.toLowerCase()}`})}var mr=I.create({netLabel:{color:cr.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.8,alignSelf:"center",marginRight:2}});y();E();import{night as Ee}from"@buoy-gg/shared-ui/web";import{jsx as Fe}from"react/jsx-runtime";function gr({insights:e}){let t=Xe(e);return t.length===0?null:Fe(m,{style:We.bar,children:t.map(r=>Fe(m,{style:We.chip,children:Fe(g,{style:We.chipText,testID:`buoy-images-insight-${r.key}`,children:r.text})},r.key))})}var We=I.create({bar:{flexDirection:"row",flexWrap:"wrap",gap:6,paddingHorizontal:10,paddingVertical:8,borderBottomWidth:I.hairlineWidth,borderBottomColor:Ee.color.border},chip:{backgroundColor:Ee.color.warningSoft,borderRadius:999,paddingHorizontal:10,paddingVertical:5},chipText:{color:Ee.color.warning,fontSize:10,fontWeight:"600",lineHeight:13}});import{jsx as v,jsxs as Ne}from"react/jsx-runtime";function pr(){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 yr(){return v(Lt,{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 He({visible:e,onClose:t,onBack:r,onMinimize:o,persistenceKey:i,inline:l=false}){qe();let{records:a,stats:s}=tt(),[u,S]=Tt(null),h=u!=null?_e(u):void 0,$=h?.status==="error"&&h.errorHeaders==null?h.id:null;Bt(()=>{let T=V();if($==null||!T)return;let q=false;return T("getDetail",{id:$}).then(ht=>{if(q)return;let mt=ht?.errorHeaders;Ct($,{errorHeaders:mt??{}})}).catch(()=>{}),()=>{q=true}},[$]);let p=h?a.findIndex(T=>T.id===h.id):-1,N=T=>{let q=a[T];q&&S(q.id)},te=()=>h?Ze(h):et(a,s,de(a),_(),j()),Ve=v(ar,{stats:s,detailOpen:h!=null,detailIndex:p,detailTotal:a.length,onCloseDetail:()=>S(null),onClear:Se,getReport:te,onBack:r}),Ue=h?Ne(m,{style:K.detailContainer,children:[v(qt,{record:h}),v(er,{record:h,hasPrevious:p>0,hasNext:p>=0&&p<a.length-1,onPrevious:()=>N(p-1),onNext:()=>N(p+1)},h.id)]}):Ne(m,{style:K.listContainer,children:[v(gr,{insights:de(a)}),v(pr,{}),v($t,{testID:"buoy-images-list",data:a,keyExtractor:T=>String(T.id),renderItem:({item:T})=>v(rr,{record:T,onPress:S}),ListEmptyComponent:v(yr,{})}),v(hr,{})]});return l?Ne(m,{style:K.inlineRoot,children:[v(m,{style:K.inlineHeader,...At,children:Ve}),Ue]}):v(Mt,{visible:e,onClose:t,onMinimize:o,persistenceKey:i,header:{showToggleButton:true,customContent:Ve},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:Ue})}function br(e={}){return v(He,{...e,inline:true,visible:true,onClose:()=>{}})}var K=I.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 fr,defineToolPreset as vr}from"@buoy-gg/shared-ui/web";import{jsx as xr}from"react/jsx-runtime";var ct=vr({id:"images",name:"IMAGES",description:"Image loads, caching, failures, and oversize checks",slot:"both",icon:({size:e,color:t})=>xr(Je,{size:e,color:t||Qe}),component:He}),wr=fr(ct);y();import{useEffect as $r}from"react";function kr(){return $r(bt,[]),null}y();M();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 Sr(e,t=ge){return e?e.length<=t?e:`${e.slice(0,t)}\u2026 [${e.length-t} more]`:null}function Cr(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 je(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:Sr(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=_e(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 ut(){let e=ne();return{stats:be(e),captureStatus:_(),globalModes:j(),insights:Cr(de(e)),records:[...e].reverse()}}var Ir={version:1,getSnapshot:()=>{let{records:e,...t}=ut();return{...t,records:e.slice(0,100).map(je)}},subscribe:e=>ke(e),actions:{list:e=>{let t=e??{},r=Math.min(Math.max(t.limit??50,1),200),{records:o,...i}=ut(),l=t.status?o.filter(a=>a.status===t.status):o;return{...i,total:l.length,records:l.slice(0,r).map(je)}},getDetail:e=>{let t=O(e);return{...je(t),errorHeaders:t.errorHeaders??null}},hardReload:e=>he(O(e)),proveSavings:e=>Be(O(e)),retry:e=>Y(O(e)),evictDisk:async e=>{let t=O(e),r=await Me(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 ze();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=>(Ke(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=Re(),l=[];return r&&(await i.Image.clearMemoryCache(),l.push("memory")),o&&(await i.Image.clearDiskCache(),l.push("disk")),{ok:true,message:`Cleared expo-image ${l.join(" + ")} cache`}}catch{return{ok:false,message:"expo-image not installed"}}},getCaptureStatus:()=>_()}};M();J();M();export{Qe as IMAGES_ICON_COLOR,Je as ImagesIcon,He as ImagesModal,kr as ImagesRoot,br as ImagesToolView,fe as clearAllOverrides,ie as clearOverride,Se as clearRecords,de as computeInsights,be as computeStats,wr as createImagesTool,It as disableImagesCapture,oe as estDecodedBytes,ae as estWastedBytes,Me as evictExpoDiskEntry,ve as flashAllMounted,xe as flashRecord,Ze as formatRecordMarkdown,et as formatRegistryMarkdown,_ as getCaptureStatus,j as getGlobalModes,ne as getImageRecords,yt as getOverride,ze as hardReloadAllMounted,he as hardReloadRecord,Ir as imagesSyncAdapter,ct as imagesToolPreset,Ye as insightChips,qe as installImageCapture,ye as oversizeFactor,Be as proveSavings,Rt as replaceImagesFromSnapshot,Y as retryRecord,Ke as setBlankImages,we as setNetworkMode,H as setOverride,G as setOverrideForAllMounted,St as setRemoteImagesHandler,ke as subscribeImageRecords,tt as useImageRecords};
|
|
3
|
+
`)}y();M();import{useMemo as Ot,useSyncExternalStore as Et}from"react";function tt(){let e=Et(ke,ne,ne);return Ot(()=>({records:[...e].reverse(),stats:be(e)}),[e])}J();M();y();y();function Re(){return null}function Ft(){return null}function Wt(){return null}E();import{useState as De}from"react";import{macOSColors as R,night as b,monoFont as Nt}from"@buoy-gg/shared-ui/web";y();J();M();import{buoyFetch as Ht}from"@buoy-gg/shared-ui/web";var X=new Map;async function Be(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 Ht(e.uri);if(!o.ok)throw new Error(`Image download returned HTTP ${o.status}.`);let i=await o.blob(),l=await createImageBitmap(i),a=document.createElement("canvas");a.width=Math.max(1,Math.min(l.width,Math.round(r.width))),a.height=Math.max(1,Math.min(l.height,Math.round(r.height)));let s=a.getContext("2d");if(!s)throw l.close(),new Error("Canvas is unavailable.");s.drawImage(l,0,0,a.width,a.height),l.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 $=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:$,savedPct:i.size?$/i.size*100:0}}catch(o){return{ok:false,message:`Image optimization failed: ${o instanceof Error?o.message:String(o)}`}}}J();M();import{Fragment as jt,jsx as n,jsxs as w}from"react/jsx-runtime";function F({title:e,children:t}){return w(m,{style:d.section,children:[n(g,{style:d.sectionTitle,children:e}),n(m,{style:d.sectionBody,children:t})]})}function Vt(e){return`buoy-images-detail-${e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}`}function c({label:e,value:t,color:r}){return w(m,{style:d.kvRow,children:[n(g,{style:d.kvLabel,children:e}),n(g,{testID:Vt(e),style:[d.kvValue,r?{color:r}:null],selectable:true,children:t})]})}function rt(e){let t=V();if(t){t("clearExpoCaches",{memory:e==="memory",disk:e==="disk"});return}try{let r=Re();e==="memory"?r.Image.clearMemoryCache():r.Image.clearDiskCache()}catch{}}function Ut({record:e}){let[t,r]=De(e.uri),o=t.trim(),i=e.mounted&&o.length>0&&o!==e.uri;return w(F,{title:"SWAP SOURCE URL",children:[n(vt,{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:[n(I,{style:[d.actionButton,!i&&d.actionDisabled],disabled:!i,onPress:()=>H(e.id,{source:{type:"url",uri:o},label:"URL swapped"}),children:n(g,{style:d.actionText,children:"Apply"})}),n(I,{style:d.actionButton,onPress:()=>r(e.uri),children:n(g,{style:d.actionText,children:"Reset field"})})]})]})}function Kt({record:e}){let[t,r]=De(false),[o,i]=De(null),l=()=>{r(true),Be(e).then(i).catch(a=>i({ok:false,message:String(a?.message??a)})).finally(()=>r(false))};return n(F,{title:"PROVE SAVINGS (re-encode on device)",children:o==null?n(m,{style:d.actionsRow,children:n(I,{style:d.actionButton,onPress:l,disabled:t,children:n(g,{style:d.actionText,children:t?"Re-encoding\u2026":"Re-encode at displayed size (WebP)"})})}):w(jt,{children:[n(c,{label:"Result",value:o.message||(o.ok?"done":"failed"),color:o.ok?R.semantic.success:R.semantic.error}),o.originalBytes!=null?n(c,{label:"Original",value:`${x(o.originalBytes)} (${o.originalBytesSource})`}):null,o.optimizedBytes!=null?n(c,{label:"Optimized",value:`${x(o.optimizedBytes)} \u2014 ${o.optimizedDims?.width}\xD7${o.optimizedDims?.height} WebP`,color:R.semantic.success}):null,o.savedBytes!=null?n(c,{label:"Saved",value:`${x(o.savedBytes)} (${o.savedPct}%)`,color:R.semantic.success}):null,w(m,{style:d.actionsRow,children:[o.ok&&o.optimizedUri&&e.mounted?n(I,{style:d.actionButton,onPress:()=>H(e.id,{source:{type:"url",uri:o.optimizedUri},label:"Optimized preview"}),children:n(g,{style:d.actionText,children:"Preview in place"})}):null,n(I,{style:d.actionButton,onPress:l,disabled:t,children:n(g,{style:d.actionText,children:t?"Re-encoding\u2026":"Re-run"})})]})]})})}function qt({record:e}){let t=ce(e),r=ue(e),o=re(e),i=oe(e),l=ae(e);return w(xt,{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."]}),n(I,{onPress:()=>ie(e.id),children:n(g,{style:d.overrideRestore,children:"RESTORE"})})]}):null,e.uri&&e.sourceKind!=="data"?n(m,{style:d.previewBox,children:n(Ge,{testID:"buoy-internal-images-preview",source:{uri:e.uri},style:d.preview,resizeMode:"contain"})}):null,w(F,{title:"SOURCE",children:[n(c,{label:"URI",value:e.uri||"(none)"}),n(c,{label:"Kind",value:e.sourceKind}),n(c,{label:"Library",value:e.lib==="web"?"Browser <img>":e.lib==="expo"?"expo-image":"RN <Image>"}),e.hasAltText===false?n(c,{label:"Alt text",value:"missing \u2014 add alt/accessibilityLabel",color:R.semantic.warning}):null,e.mediaType!=null?n(c,{label:"Media type",value:String(e.mediaType)}):null,e.isAnimated!=null?n(c,{label:"Animated",value:e.isAnimated?"yes":"no"}):null]}),w(F,{title:"LOAD",children:[n(c,{label:"Status",value:e.status,color:e.status==="error"?R.semantic.error:e.status==="loaded"?R.semantic.success:R.semantic.warning}),n(c,{label:"Duration",value:Q(e.durationMs)}),e.displayedAt&&e.loadedAt?n(c,{label:"Decode \u2192 display",value:Q(Math.max(0,e.displayedAt-e.loadedAt))}):null,n(c,{label:"Cache",value:`${r.label}`,color:r.color}),e.cacheVerdictSource?n(c,{label:"Cache source",value:e.cacheVerdictSource==="event"?"reported by expo-image onLoad":"Image.queryCache after load"}):null,e.progressSeen?n(c,{label:"Downloaded",value:e.bytesTotal?`${x(e.bytesLoaded??0)} / ${x(e.bytesTotal)}`:"network transfer observed"}):null,n(c,{label:"Load cycles",value:String(e.loadCount)}),n(c,{label:"Still mounted",value:e.mounted?"yes":"no"})]}),w(F,{title:"DIMENSIONS",children:[e.intrinsic?n(c,{label:"Decoded",value:`${e.intrinsic.width}\xD7${e.intrinsic.height} px`}):n(c,{label:"Decoded",value:"unknown"}),e.layout?n(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(Dt()*100)/100}x)`}):n(c,{label:"Displayed",value:"no layout yet"}),t.label?n(c,{label:"Verdict",value:t.label,color:t.color}):null,i>0?n(c,{label:"Est. decoded memory",value:x(i)}):null,l>0?n(c,{label:"Est. wasted",value:`${x(l)} \u2014 resize the source to ${o?`${o.width}\xD7${o.height}`:"the displayed size"}`,color:R.semantic.warning}):null,(e.layoutShifts??0)>0?n(c,{label:"Layout shifts",value:`${e.layoutShifts} \u2014 box resized after load; reserve explicit width/height`,color:R.semantic.warning}):null]}),e.sourceKind==="network"||e.sourceKind==="asset"?n(Kt,{record:e},`savings-${e.id}`):null,e.status==="error"?w(F,{title:"ERROR",children:[n(c,{label:"Message",value:e.error??"unknown",color:R.semantic.error}),e.errorCode!=null?n(c,{label:"HTTP status",value:String(e.errorCode)}):null,e.errorHeaders?Object.entries(e.errorHeaders).map(([a,s])=>n(c,{label:a,value:String(s)},a)):null]}):null,e.sourceKind==="network"&&e.mounted?n(Ut,{record:e},e.id):null,e.lib==="expo"?n(F,{title:"CACHE ACTIONS (expo-image, global)",children:w(m,{style:d.actionsRow,children:[n(I,{style:d.actionButton,onPress:()=>rt("memory"),children:n(g,{style:d.actionText,children:"Clear memory cache"})}),n(I,{style:d.actionButton,onPress:()=>rt("disk"),children:n(g,{style:d.actionText,children:"Clear disk cache"})})]})}):null]})}var d=C.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:C.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:C.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:Nt,backgroundColor:b.color.surfaceElevated,borderRadius:6,borderWidth:C.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 Gt}from"react";import{ChevronLeft as _t,ChevronRight as Jt,FooterButton as Te,FooterMessage as ot,FooterRow as at,RefreshCw as Qt,ToolFooter as Xt,night as W}from"@buoy-gg/shared-ui/web";y();J();kt();function Yt(e){return le().actionListeners.add(e),()=>le().actionListeners.delete(e)}function it(e,t){let r=le(),o=r.reloadRequests.get(e);r.reloadRequests.set(e,{nonce:(o?.nonce??0)+1,bust:t}),pt(e)}function lt(){try{return Re().Image??null}catch{return null}}function Zt(){try{let e=Ft(),t=e?.default||e;if(t?.deleteAsync)return t}catch{}try{let e=Wt(),t=e?.default||e;if(t?.deleteAsync)return t}catch{}return null}async function Me(e){let t=lt(),r=Zt();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 $e(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 it(e.id,false),{ok:true,message:"Remounting image"}}async function ze(){let e=V();if(e)return $e(e("massAction",{kind:"reload"}));let{getSnapshot:t}=(M(),ft(gt)),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 $e(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 Me(e);await lt()?.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 it(e.id,true),{ok:true,message:"Refetching with cache bypassed"}}import{jsx as f,jsxs as Ae}from"react/jsx-runtime";function er({record:e,hasPrevious:t,hasNext:r,onPrevious:o,onNext:i}){let[l,a]=Gt(null),s=$=>{a("\u2026"),$().then(p=>a(p.message)).catch(p=>a(String(p?.message??p)))},u=!e.mounted,S=e.overrideLabel!=null,h=($,p)=>{H(e.id,{source:$,label:p}),a(`${p} \u2014 Restore to undo`)};return Ae(Xt,{children:[l?f(ot,{testID:"buoy-images-detail-footer-message",children:l}):u?f(ot,{tone:"muted",children:"Instance unmounted \u2014 reload actions need the image on screen."}):null,Ae(at,{style:{gap:8},children:[f(I,{onPress:o,disabled:!t,style:[me.navButton,!t&&me.disabled],activeOpacity:.7,testID:"buoy-images-detail-previous",accessibilityLabel:"Previous image",children:f(_t,{size:20,color:t?W.color.accent:W.color.textTertiary})}),f(Te,{label:"Hard reload",size:"md",testID:"buoy-images-detail-hard-reload",disabled:u,icon:f(Qt,{size:13,color:u?W.color.textTertiary:W.color.info}),onPress:()=>s(()=>he(e))}),f(Te,{label:e.status==="error"?"Retry":"Reload",size:"md",testID:"buoy-images-detail-reload",disabled:u,onPress:()=>s(()=>Y(e))}),f(I,{onPress:i,disabled:!r,style:[me.navButton,!r&&me.disabled],activeOpacity:.7,testID:"buoy-images-detail-next",accessibilityLabel:"Next image",children:f(Jt,{size:20,color:r?W.color.accent:W.color.textTertiary})})]}),Ae(at,{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(Te,{label:e,onPress:t,disabled:r,accent:o,testID:`buoy-images-sim-${e.toLowerCase()}`,style:{paddingVertical:7}})}var me=C.create({navButton:{paddingHorizontal:10,paddingVertical:8,borderRadius:6,backgroundColor:W.color.button,alignItems:"center",justifyContent:"center"},disabled:{opacity:.4}});y();E();import{macOSColors as tr,night as A,Pill as Le}from"@buoy-gg/shared-ui/web";import{jsx as D,jsxs as ee}from"react/jsx-runtime";function rr({record:e,onPress:t}){let r=ce(e),o=ue(e),i=e.sourceKind==="network"||e.sourceKind==="asset"||e.sourceKind==="file",l=`buoy-image-row-${e.id}`;return ee(I,{style:k.row,testID:l,onPress:()=>t(e.id),children:[ee(m,{style:k.thumbBox,children:[i&&e.uri?D(Ge,{testID:"buoy-internal-images-thumb",source:{uri:e.uri},style:k.thumb,resizeMode:"cover"}):D(g,{style:k.thumbFallback,children:"?"}),D(m,{testID:`${l}-status`,accessibilityLabel:e.status,style:[k.statusDot,{backgroundColor:Pt(e)}]})]}),ee(m,{style:k.main,children:[D(g,{style:k.name,numberOfLines:1,testID:`${l}-name`,children:Ie(e.uri)}),ee(m,{style:k.metaRow,children:[D(Le,{variant:"text",label:e.lib==="web"?"WEB":e.lib==="expo"?"EXPO":"RN",color:A.color.textTertiary}),D(Le,{variant:"text",label:o.label,color:o.color,testID:`${l}-cache`}),e.overrideLabel?D(Le,{variant:"text",label:"SIM",color:A.color.warning,testID:`${l}-sim`}):null,D(g,{style:k.meta,children:Q(e.durationMs)}),e.intrinsic?ee(g,{style:k.meta,testID:`${l}-size`,children:[e.intrinsic.width,"\xD7",e.intrinsic.height]}):null]})]}),D(m,{style:k.right,children:e.status==="error"?D(g,{testID:`${l}-verdict`,style:[k.verdict,{color:tr.semantic.error}],children:"FAILED"}):r.label?D(g,{testID:`${l}-verdict`,style:[k.verdict,{color:r.color}],children:r.label}):null})]})}var k=C.create({row:{flexDirection:"row",alignItems:"center",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:C.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 L,ToolbarClearButton as or,ToolbarCopyButton as nt}from"@buoy-gg/shared-ui/web";import{jsx as P,jsxs as Pe}from"react/jsx-runtime";function ar({stats:e,detailOpen:t,detailIndex:r=-1,detailTotal:o=0,onCloseDetail:i,onClear:l,getReport:a,onBack:s}){if(t){let S=r>=0&&o>0?`${r+1} of ${o}`:void 0;return Pe(L,{children:[P(L.Navigation,{onBack:i}),P(L.Content,{title:"Image detail",subtitle:S,testID:"buoy-images-detail-title"}),P(L.Actions,{children:P(nt,{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`),Pe(L,{children:[s?P(L.Navigation,{onBack:s}):null,P(L.Content,{title:"Images",subtitle:u.join(" \xB7 "),testID:"buoy-images-title"}),Pe(L.Actions,{children:[P(nt,{value:a}),P(or,{onPress:l,testID:"buoy-images-clear"})]})]})}y();E();import{useState as ir,useSyncExternalStore as lr}from"react";import{FooterButton as st,FooterCaption as nr,FooterMessage as sr,FooterRow as dt,ToolFooter as dr,night as cr}from"@buoy-gg/shared-ui/web";import{jsx as B,jsxs as Oe}from"react/jsx-runtime";var ur=[{key:"normal",label:"Normal"},{key:"offline",label:"Offline"},{key:"cold",label:"Cold"}];function hr(){let[e,t]=ir(null),r=lr(Yt,()=>j().network),o=(i,l)=>{let a=G(i,l);t(a>0?`${l} on ${a} image${a===1?"":"s"} \u2014 Restore all to undo`:"No mounted images")};return Oe(dr,{paddingBottom:10,style:{paddingTop:8},children:[e?B(sr,{testID:"buoy-images-message",children:e}):B(nr,{children:"MASS ACTIONS \u2014 every image on screen"}),Oe(dt,{children:[B(U,{label:"Error",onPress:()=>o({type:"error"},"Forced error")}),B(U,{label:"Loading",onPress:()=>o({type:"hang"},"Forced loading")}),B(U,{label:"Blank",onPress:()=>o({type:"blank"},"Blanked")}),B(U,{label:"Reload",onPress:()=>{t("\u2026"),ze().then(i=>t(i.message))}}),B(U,{label:"Find",onPress:()=>{let i=ve();t(`Flashing ${i} image${i===1?"":"s"} (2.5s)`)}}),B(U,{label:"Restore",accent:true,onPress:()=>{let i=fe();t(i>0?`Restored ${i} image${i===1?"":"s"}`:"No overrides active")}})]}),Oe(dt,{children:[B(g,{style:mr.netLabel,children:"NET"}),ur.map(i=>{let l=r===i.key;return B(st,{label:i.label,active:l,testID:`buoy-images-net-${i.key}`,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 B(st,{label:e,onPress:t,accent:r,testID:`buoy-images-mass-${e.toLowerCase()}`})}var mr=C.create({netLabel:{color:cr.color.textTertiary,fontSize:9,fontWeight:"700",letterSpacing:.8,alignSelf:"center",marginRight:2}});y();E();import{night as Ee}from"@buoy-gg/shared-ui/web";import{jsx as Fe}from"react/jsx-runtime";function gr({insights:e}){let t=Xe(e);return t.length===0?null:Fe(m,{style:We.bar,children:t.map(r=>Fe(m,{style:We.chip,children:Fe(g,{style:We.chipText,testID:`buoy-images-insight-${r.key}`,children:r.text})},r.key))})}var We=C.create({bar:{flexDirection:"row",flexWrap:"wrap",gap:6,paddingHorizontal:10,paddingVertical:8,borderBottomWidth:C.hairlineWidth,borderBottomColor:Ee.color.border},chip:{backgroundColor:Ee.color.warningSoft,borderRadius:999,paddingHorizontal:10,paddingVertical:5},chipText:{color:Ee.color.warning,fontSize:10,fontWeight:"600",lineHeight:13}});import{jsx as v,jsxs as Ne}from"react/jsx-runtime";function pr(){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 yr(){return v(Lt,{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 He({visible:e,onClose:t,onBack:r,onMinimize:o,persistenceKey:i,inline:l=false}){qe();let{records:a,stats:s}=tt(),[u,S]=Tt(null),h=u!=null?_e(u):void 0,$=h?.status==="error"&&h.errorHeaders==null?h.id:null;Bt(()=>{let T=V();if($==null||!T)return;let q=false;return T("getDetail",{id:$}).then(ht=>{if(q)return;let mt=ht?.errorHeaders;Ct($,{errorHeaders:mt??{}})}).catch(()=>{}),()=>{q=true}},[$]);let p=h?a.findIndex(T=>T.id===h.id):-1,N=T=>{let q=a[T];q&&S(q.id)},te=()=>h?Ze(h):et(a,s,de(a),_(),j()),Ve=v(ar,{stats:s,detailOpen:h!=null,detailIndex:p,detailTotal:a.length,onCloseDetail:()=>S(null),onClear:Se,getReport:te,onBack:r}),Ue=h?Ne(m,{style:K.detailContainer,children:[v(qt,{record:h}),v(er,{record:h,hasPrevious:p>0,hasNext:p>=0&&p<a.length-1,onPrevious:()=>N(p-1),onNext:()=>N(p+1)},h.id)]}):Ne(m,{style:K.listContainer,children:[v(gr,{insights:de(a)}),v(pr,{}),v($t,{testID:"buoy-images-list",data:a,keyExtractor:T=>String(T.id),renderItem:({item:T})=>v(rr,{record:T,onPress:S}),ListEmptyComponent:v(yr,{})}),v(hr,{})]});return l?Ne(m,{style:K.inlineRoot,children:[v(m,{style:K.inlineHeader,...At,children:Ve}),Ue]}):v(Mt,{visible:e,onClose:t,onMinimize:o,persistenceKey:i,header:{showToggleButton:true,customContent:Ve},enablePersistence:true,initialMode:"bottomSheet",disableScrollWrapper:true,children:Ue})}function br(e={}){return v(He,{...e,inline:true,visible:true,onClose:()=>{}})}var K=C.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 fr,defineToolPreset as vr}from"@buoy-gg/shared-ui/web";import{jsx as xr}from"react/jsx-runtime";var ct=vr({id:"images",name:"IMAGES",description:"Image loads, caching, failures, and oversize checks",slot:"both",icon:({size:e,color:t})=>xr(Je,{size:e,color:t||Qe}),component:He}),wr=fr(ct);y();import{useEffect as $r}from"react";function kr(){return $r(bt,[]),null}y();M();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 Sr(e,t=ge){return e?e.length<=t?e:`${e.slice(0,t)}\u2026 [${e.length-t} more]`:null}function Cr(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 je(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:Sr(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=_e(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 ut(){let e=ne();return{stats:be(e),captureStatus:_(),globalModes:j(),insights:Cr(de(e)),records:[...e].reverse()}}var Ir={version:1,getSnapshot:()=>{let{records:e,...t}=ut();return{...t,records:e.slice(0,100).map(je)}},subscribe:e=>ke(e),actions:{list:e=>{let t=e??{},r=Math.min(Math.max(t.limit??50,1),200),{records:o,...i}=ut(),l=t.status?o.filter(a=>a.status===t.status):o;return{...i,total:l.length,records:l.slice(0,r).map(je)}},getDetail:e=>{let t=O(e);return{...je(t),errorHeaders:t.errorHeaders??null}},hardReload:e=>he(O(e)),proveSavings:e=>Be(O(e)),retry:e=>Y(O(e)),evictDisk:async e=>{let t=O(e),r=await Me(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 ze();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=>(Ke(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=Re(),l=[];return r&&(await i.Image.clearMemoryCache(),l.push("memory")),o&&(await i.Image.clearDiskCache(),l.push("disk")),{ok:true,message:`Cleared expo-image ${l.join(" + ")} cache`}}catch{return{ok:false,message:"expo-image not installed"}}},getCaptureStatus:()=>_()}};M();J();M();export{Qe as IMAGES_ICON_COLOR,Je as ImagesIcon,He as ImagesModal,kr as ImagesRoot,br as ImagesToolView,fe as clearAllOverrides,ie as clearOverride,Se as clearRecords,de as computeInsights,be as computeStats,wr as createImagesTool,It as disableImagesCapture,oe as estDecodedBytes,ae as estWastedBytes,Me as evictExpoDiskEntry,ve as flashAllMounted,xe as flashRecord,Ze as formatRecordMarkdown,et as formatRegistryMarkdown,_ as getCaptureStatus,j as getGlobalModes,ne as getImageRecords,yt as getOverride,ze as hardReloadAllMounted,he as hardReloadRecord,Ir as imagesSyncAdapter,ct as imagesToolPreset,Ye as insightChips,qe as installImageCapture,ye as oversizeFactor,Be as proveSavings,Rt as replaceImagesFromSnapshot,Y as retryRecord,Ke as setBlankImages,we as setNetworkMode,H as setOverride,G as setOverrideForAllMounted,St as setRemoteImagesHandler,ke as subscribeImageRecords,tt 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-CUHKOIVI.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.76",
|
|
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.76"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
25
|
"react": "*"
|