@expo/serve-sim 0.1.49 → 0.1.50

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.
@@ -37,7 +37,7 @@ function __sd_simulate(p){
37
37
  `+Object.keys(U).map((j)=>`${j}: ${U[j]}`).join(`\r
38
38
  `)+`\r
39
39
  \r
40
- `+_)}function N(M,F,_,U,j,x){if(M.listenerCount("wsClientError")){let S=Error(j);Error.captureStackTrace(S,N),M.emit("wsClientError",S,_,F)}else E(_,U,j,x)}});I3=_0(kZ(),1),x3=_0(p8(),1),q3=_0($4(),1),S3=_0(Z$(),1),w3=_0(J$(),1),y3=_0(Y$(),1),tZ=_0(m8(),1),_$=_0(fZ(),1),$$=tZ.default;K2={"Network.setUserAgentOverride":"Page.overrideUserAgent","Network.setCacheDisabled":"Network.setResourceCachingDisabled"},z2={"Network.requestWillBeSent":{walltime:"wallTime"}},H2={hasUserGesture:!1,redirectHasExtraInfo:!1},M2={hasExtraInfo:!1},_2={encodedDataLength:0,shouldReportCorbBlocking:!1},F2={initialPriority:"Medium",referrerPolicy:"origin"},N2={connectionReused:!1,connectionId:0,fromDiskCache:!1,fromServiceWorker:!1,encodedDataLength:0};E2={"media-rule":"mediaRule","media-import-rule":"importRule","media-style-node":"inlineSheet","media-link-node":"linkedSheet"};S2={protocolVersion:"1.3",product:"Safari/inspect-webkit",revision:"605.1.15",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS like Mac OS X) AppleWebKit/605.1.15 Safari/inspect-webkit",jsVersion:""};g2=["Animation","Autofill","Audits","ServiceWorker","Profiler","HeapProfiler","Storage","Tethering","Tracing","BackgroundService","FedCm","DeviceAccess","WebAuthn","Cast","Database","ApplicationCache","BackgroundFetch","DeviceOrientation","EventBreakpoints","FileSystem","HeadlessExperimental","IndexedDB","Memory","PerformanceTimeline","Performance","Preload","Schema","Security","SystemInfo","WebAudio"],u2={"Network.setAttachDebugStack":{},"Network.emulateNetworkConditionsByRule":{ruleIds:[]},"Network.overrideNetworkState":{},"Network.clearAcceptedEncodingsOverride":{},"Network.setAcceptedEncodings":{},"Network.enableReportingApi":{},"Overlay.setShowHinge":{},"Overlay.setShowViewportSizeOnResize":{},"Overlay.setShowGridOverlays":{},"Overlay.setShowFlexOverlays":{},"Overlay.setShowScrollSnapOverlays":{},"Overlay.setShowContainerQueryOverlays":{},"Overlay.setShowIsolatedElements":{},"Overlay.setPausedInDebuggerMessage":{},"Overlay.setShowAdHighlights":{},"Overlay.setShowDebugBorders":{},"Overlay.setShowFPSCounter":{},"Overlay.setShowLayoutShiftRegions":{},"Overlay.setShowScrollBottleneckRects":{},"Overlay.setShowHitTestBorders":{},"Overlay.setShowWebVitals":{},"CSS.trackComputedStyleUpdates":{},"CSS.takeComputedStyleUpdates":{nodeIds:[]},"CSS.startRuleUsageTracking":{},"CSS.stopRuleUsageTracking":{ruleUsage:[]},"CSS.takeCoverageDelta":{coverage:[],timestamp:0},"Page.setAdBlockingEnabled":{},"Page.removeScriptToEvaluateOnNewDocument":{},"Page.setBypassCSP":{},"Page.setInterceptFileChooserDialog":{},"Page.setPrerenderingAllowed":{},"Page.setRPHRegistrationMode":{},"Page.setSPCTransactionMode":{},"Emulation.setEmulatedVisionDeficiency":{},"Emulation.setFocusEmulationEnabled":{},"Emulation.setAutoDarkModeOverride":{},"Emulation.setAutomationOverride":{},"Emulation.setLocaleOverride":{},"Emulation.setTimezoneOverride":{},"Emulation.setVisibleSize":{},"Emulation.setIdleOverride":{},"Emulation.clearIdleOverride":{},"Emulation.setGeolocationOverride":{},"Emulation.clearGeolocationOverride":{},"Emulation.setSensorOverrideEnabled":{},"Emulation.setSensorOverrideReadings":{},"Emulation.setHardwareConcurrencyOverride":{},"Emulation.setNavigatorOverrides":{},"Emulation.setPageScaleFactor":{},"Emulation.setScrollbarsHidden":{},"Emulation.setDocumentCookieDisabled":{},"DOMDebugger.setBreakOnCSPViolation":{},"Runtime.addBinding":{},"Runtime.removeBinding":{},"Debugger.setReturnValue":{},"Debugger.setBlackboxExecutionContexts":{},"Debugger.setInstrumentationBreakpoint":{},"DOM.markUndoableState":{},"DOM.undo":{},"DOM.redo":{},"DOM.copyTo":{nodeId:0},"DOM.collectClassNamesFromSubtree":{classNames:[]},"Accessibility.enable":{},"Accessibility.disable":{},"Accessibility.getFullAXTree":{nodes:[]},"Accessibility.getRootAXNode":{node:null},"Accessibility.getPartialAXTree":{nodes:[]},"Accessibility.queryAXTree":{nodes:[]},"Accessibility.getAXNodeAndAncestors":{nodes:[]},"Accessibility.getChildAXNodes":{nodes:[]}};m2={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}});import{readdirSync as X1,readFileSync as G1,existsSync as c$,unlinkSync as E$,watch as T$}from"fs";import{readFile as V1,unlink as W1}from"fs/promises";import{execSync as X4,spawn as K1,exec as z1,execFile as N0}from"child_process";import{tmpdir as l$}from"os";import{join as v4}from"path";import{createServer as H1}from"net";import{createHash as d$,randomBytes as I$,timingSafeEqual as M1}from"crypto";import{WebSocket as x$}from"ws";var p4="Accessibility unavailable on this simulator.";import{createRequire as T5}from"module";import{dirname as l4,join as d4}from"path";import{existsSync as I5}from"fs";import{fileURLToPath as j9}from"url";var z4={mjpegFps:60,mjpegQuality:0.7,maxDimension:0,h264Bitrate:6000000,h264Fps:60},U5={transport:"http",httpCodec:"auto",webRtcCodec:"h264",...z4};function N9($){return typeof $==="number"&&Number.isFinite($)?$:null}function L9($,Q,Z,J){let Y=N9($);return Y==null?Q:Math.min(J,Math.max(Z,Y))}function K4($,Q,Z,J){return Math.round(L9($,Q,Z,J))}function A5($){if(!Array.isArray($)||$.length>16)return null;let Q=[];for(let Z of $){if(!Z||typeof Z!=="object")return null;let J=Z.urls;if(!Array.isArray(J)||J.length===0||J.length>16||!J.every((G)=>typeof G==="string"&&G.length<=2048&&/^(stun|stuns|turn|turns):/i.test(G)))return null;let{username:Y,credential:X}=Z;if(Y!==void 0&&typeof Y!=="string")return null;if(X!==void 0&&typeof X!=="string")return null;Q.push({urls:J,...typeof Y==="string"?{username:Y}:{},...typeof X==="string"?{credential:X}:{}})}return Q}var j5=new Set(["mjpegFps","mjpegQuality","maxDimension","h264Bitrate","h264Fps"]),R5=new Set(["maxDimension","h264Bitrate","h264Fps"]);function B9($,Q){if(!$||typeof $!=="object"||Array.isArray($))return null;let Z=$,J=Object.keys(Z),Y=Q==="webrtc"?R5:j5;if(J.length===0||J.some((X)=>!Y.has(X)))return null;for(let X of["mjpegFps","mjpegQuality","maxDimension","h264Bitrate","h264Fps"])if(X in Z&&N9(Z[X])==null)return null;return Z}function F9($={},Q=U5){let J=Object.prototype.hasOwnProperty.call($,"iceServers")?A5($.iceServers):Q.iceServers,Y=J===null?Q.iceServers:J&&J.length>0?J:void 0;return{transport:$.transport==="http"||$.transport==="webrtc"?$.transport:Q.transport,httpCodec:$.httpCodec==="auto"||$.httpCodec==="mjpeg"||$.httpCodec==="h264"?$.httpCodec:Q.httpCodec,webRtcCodec:$.webRtcCodec==="vp8"||$.webRtcCodec==="vp9"||$.webRtcCodec==="h264"?$.webRtcCodec:Q.webRtcCodec,...Y?{iceServers:Y}:{},...m4($,Q)}}function m4($={},Q=z4){return{mjpegFps:K4($.mjpegFps,Q.mjpegFps,1,120),mjpegQuality:L9($.mjpegQuality,Q.mjpegQuality,0.05,1),maxDimension:K4($.maxDimension,Q.maxDimension,0,4096),h264Bitrate:K4($.h264Bitrate,Q.h264Bitrate,1e5,50000000),h264Fps:K4($.h264Fps,Q.h264Fps,1,140)}}function O9($){return{mjpegFps:$.mjpegFps,mjpegQuality:$.mjpegQuality,maxDimension:$.maxDimension,h264Bitrate:$.h264Bitrate,h264Fps:$.h264Fps}}function c4($,Q){if(Q==="webrtc")return{maxDimension:$.maxDimension,h264Bitrate:$.h264Bitrate,h264Fps:$.h264Fps};return{mjpegFps:$.mjpegFps,mjpegQuality:$.mjpegQuality,maxDimension:$.maxDimension,h264Bitrate:$.h264Bitrate,h264Fps:$.h264Fps}}function U9($){let Q=$?{mjpegFps:$.mjpegFps,mjpegQuality:$.mjpegQuality,maxDimension:$.maxDimension,h264Bitrate:$.h264Bitrate,h264Fps:$.h264Fps}:{};if($?.transport==="webrtc")return F9({transport:"webrtc",webRtcCodec:$.codec,iceServers:$.iceServers,...Q});return F9({transport:"http",httpCodec:$?.codec??"auto",...Q})}function M4($){return typeof $==="object"&&$!==null&&!Array.isArray($)}function H4($){return typeof $==="number"&&Number.isFinite($)?$:0}function Z0($){return typeof $==="number"&&Number.isFinite($)?$:null}function l0($){return typeof $==="string"&&$.length>0?$:null}function C5($){if(!M4($))return{};let Q={};for(let[Z,J]of Object.entries($)){let Y=Z0(J);if(Y!==null)Q[Z]=Y*1000}return Q}function D5($,Q){let Z=[l0($),l0(Q)];if(Z.some((J)=>J===null))return"unknown";return Z.includes("relay")?"relay":"direct"}function P5($){let Q=H4($.framesEncoded),Z=H4($.packetsSent),J=H4($.packetsLost),Y=Z0($.totalEncodeTime),X=Z0($.targetBitrate),G=Z0($.roundTripTime);return{sessionId:l0($.sessionId)??"",sourceFrames:Z0($.sourceFrames),sourceFps:Z0($.sourceFramesPerSecond),sourceFramesDropped:Z0($.sourceFramesDropped),codec:l0($.codec),connected:$.connected===!0,qualityLimitationReason:l0($.qualityLimitationReason),qualityLimitationMs:C5($.qualityLimitationDurations),framesEncoded:Q,framesSent:H4($.framesSent),reportedFps:Z0($.framesPerSecond),targetKbps:X===null?null:X/1000,totalEncodeMs:Y===null?null:Y*1000,encodeMsPerFrame:Y===null||Q<=0?null:Y*1000/Q,width:Z0($.frameWidth),height:Z0($.frameHeight),packetsSent:Z,packetsLost:J,lossRatio:Z>0?Math.max(0,J)/Z:null,roundTripMs:G===null?null:G*1000,path:D5($.localCandidateType,$.remoteCandidateType)}}function A9($){if(!M4($)||!Array.isArray($.sessions))return{sessions:[]};return{sessions:$.sessions.filter(M4).map(P5),capture:E5($.capture)}}function E5($){if(!M4($))return null;let{screenFrames:Q,idleFrames:Z}=$;if(typeof Q!=="number"||typeof Z!=="number")return null;return{screenFrames:Q,idleFrames:Z,offeredFrames:typeof $.offeredFrames==="number"?$.offeredFrames:null,forwardedFrames:typeof $.forwardedFrames==="number"?$.forwardedFrames:null,pumpRestarts:typeof $.pumpRestarts==="number"?$.pumpRestarts:null}}var x5=T5(import.meta.url),q5=0,S5=1,w5=1,y5=2,d0={portrait:1,portraitUpsideDown:2,landscapeRight:3,landscapeLeft:4};function k5(){let $=[d4(l4(process.execPath),"native","serve-sim-native.node"),d4(l4(j9(import.meta.url)),"native","serve-sim-native.node"),d4(l4(j9(import.meta.url)),"..","dist","native","serve-sim-native.node")];for(let Q of $)if(I5(Q))return Q;throw Error(`serve-sim-native.node not found. Looked in:
40
+ `+_)}function N(M,F,_,U,j,x){if(M.listenerCount("wsClientError")){let S=Error(j);Error.captureStackTrace(S,N),M.emit("wsClientError",S,_,F)}else E(_,U,j,x)}});I3=_0(kZ(),1),x3=_0(p8(),1),q3=_0($4(),1),S3=_0(Z$(),1),w3=_0(J$(),1),y3=_0(Y$(),1),tZ=_0(m8(),1),_$=_0(fZ(),1),$$=tZ.default;K2={"Network.setUserAgentOverride":"Page.overrideUserAgent","Network.setCacheDisabled":"Network.setResourceCachingDisabled"},z2={"Network.requestWillBeSent":{walltime:"wallTime"}},H2={hasUserGesture:!1,redirectHasExtraInfo:!1},M2={hasExtraInfo:!1},_2={encodedDataLength:0,shouldReportCorbBlocking:!1},F2={initialPriority:"Medium",referrerPolicy:"origin"},N2={connectionReused:!1,connectionId:0,fromDiskCache:!1,fromServiceWorker:!1,encodedDataLength:0};E2={"media-rule":"mediaRule","media-import-rule":"importRule","media-style-node":"inlineSheet","media-link-node":"linkedSheet"};S2={protocolVersion:"1.3",product:"Safari/inspect-webkit",revision:"605.1.15",userAgent:"Mozilla/5.0 (iPhone; CPU iPhone OS like Mac OS X) AppleWebKit/605.1.15 Safari/inspect-webkit",jsVersion:""};g2=["Animation","Autofill","Audits","ServiceWorker","Profiler","HeapProfiler","Storage","Tethering","Tracing","BackgroundService","FedCm","DeviceAccess","WebAuthn","Cast","Database","ApplicationCache","BackgroundFetch","DeviceOrientation","EventBreakpoints","FileSystem","HeadlessExperimental","IndexedDB","Memory","PerformanceTimeline","Performance","Preload","Schema","Security","SystemInfo","WebAudio"],u2={"Network.setAttachDebugStack":{},"Network.emulateNetworkConditionsByRule":{ruleIds:[]},"Network.overrideNetworkState":{},"Network.clearAcceptedEncodingsOverride":{},"Network.setAcceptedEncodings":{},"Network.enableReportingApi":{},"Overlay.setShowHinge":{},"Overlay.setShowViewportSizeOnResize":{},"Overlay.setShowGridOverlays":{},"Overlay.setShowFlexOverlays":{},"Overlay.setShowScrollSnapOverlays":{},"Overlay.setShowContainerQueryOverlays":{},"Overlay.setShowIsolatedElements":{},"Overlay.setPausedInDebuggerMessage":{},"Overlay.setShowAdHighlights":{},"Overlay.setShowDebugBorders":{},"Overlay.setShowFPSCounter":{},"Overlay.setShowLayoutShiftRegions":{},"Overlay.setShowScrollBottleneckRects":{},"Overlay.setShowHitTestBorders":{},"Overlay.setShowWebVitals":{},"CSS.trackComputedStyleUpdates":{},"CSS.takeComputedStyleUpdates":{nodeIds:[]},"CSS.startRuleUsageTracking":{},"CSS.stopRuleUsageTracking":{ruleUsage:[]},"CSS.takeCoverageDelta":{coverage:[],timestamp:0},"Page.setAdBlockingEnabled":{},"Page.removeScriptToEvaluateOnNewDocument":{},"Page.setBypassCSP":{},"Page.setInterceptFileChooserDialog":{},"Page.setPrerenderingAllowed":{},"Page.setRPHRegistrationMode":{},"Page.setSPCTransactionMode":{},"Emulation.setEmulatedVisionDeficiency":{},"Emulation.setFocusEmulationEnabled":{},"Emulation.setAutoDarkModeOverride":{},"Emulation.setAutomationOverride":{},"Emulation.setLocaleOverride":{},"Emulation.setTimezoneOverride":{},"Emulation.setVisibleSize":{},"Emulation.setIdleOverride":{},"Emulation.clearIdleOverride":{},"Emulation.setGeolocationOverride":{},"Emulation.clearGeolocationOverride":{},"Emulation.setSensorOverrideEnabled":{},"Emulation.setSensorOverrideReadings":{},"Emulation.setHardwareConcurrencyOverride":{},"Emulation.setNavigatorOverrides":{},"Emulation.setPageScaleFactor":{},"Emulation.setScrollbarsHidden":{},"Emulation.setDocumentCookieDisabled":{},"DOMDebugger.setBreakOnCSPViolation":{},"Runtime.addBinding":{},"Runtime.removeBinding":{},"Debugger.setReturnValue":{},"Debugger.setBlackboxExecutionContexts":{},"Debugger.setInstrumentationBreakpoint":{},"DOM.markUndoableState":{},"DOM.undo":{},"DOM.redo":{},"DOM.copyTo":{nodeId:0},"DOM.collectClassNamesFromSubtree":{classNames:[]},"Accessibility.enable":{},"Accessibility.disable":{},"Accessibility.getFullAXTree":{nodes:[]},"Accessibility.getRootAXNode":{node:null},"Accessibility.getPartialAXTree":{nodes:[]},"Accessibility.queryAXTree":{nodes:[]},"Accessibility.getAXNodeAndAncestors":{nodes:[]},"Accessibility.getChildAXNodes":{nodes:[]}};m2={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"}});import{readdirSync as X1,readFileSync as G1,existsSync as c$,unlinkSync as E$,watch as T$}from"fs";import{readFile as V1,unlink as W1}from"fs/promises";import{execSync as X4,spawn as K1,exec as z1,execFile as N0}from"child_process";import{tmpdir as l$}from"os";import{join as v4}from"path";import{createServer as H1}from"net";import{createHash as d$,randomBytes as I$,timingSafeEqual as M1}from"crypto";import{WebSocket as x$}from"ws";var p4="Accessibility unavailable on this simulator.";import{createRequire as T5}from"module";import{dirname as l4,join as d4}from"path";import{existsSync as I5}from"fs";import{fileURLToPath as j9}from"url";var z4={mjpegFps:60,mjpegQuality:0.7,maxDimension:0,h264Bitrate:6000000,h264Fps:60},U5={transport:"http",httpCodec:"auto",webRtcCodec:"h264",...z4};function N9($){return typeof $==="number"&&Number.isFinite($)?$:null}function L9($,Q,Z,J){let Y=N9($);return Y==null?Q:Math.min(J,Math.max(Z,Y))}function K4($,Q,Z,J){return Math.round(L9($,Q,Z,J))}function A5($){if(!Array.isArray($)||$.length>16)return null;let Q=[];for(let Z of $){if(!Z||typeof Z!=="object")return null;let J=Z.urls;if(!Array.isArray(J)||J.length===0||J.length>16||!J.every((G)=>typeof G==="string"&&G.length<=2048&&/^(stun|stuns|turn|turns):/i.test(G)))return null;let{username:Y,credential:X}=Z;if(Y!==void 0&&typeof Y!=="string")return null;if(X!==void 0&&typeof X!=="string")return null;Q.push({urls:J,...typeof Y==="string"?{username:Y}:{},...typeof X==="string"?{credential:X}:{}})}return Q}var j5=new Set(["mjpegFps","mjpegQuality","maxDimension","h264Bitrate","h264Fps"]),R5=new Set(["maxDimension","h264Bitrate","h264Fps"]);function B9($,Q){if(!$||typeof $!=="object"||Array.isArray($))return null;let Z=$,J=Object.keys(Z),Y=Q==="webrtc"?R5:j5;if(J.length===0||J.some((X)=>!Y.has(X)))return null;for(let X of["mjpegFps","mjpegQuality","maxDimension","h264Bitrate","h264Fps"])if(X in Z&&N9(Z[X])==null)return null;return Z}function F9($={},Q=U5){let J=Object.prototype.hasOwnProperty.call($,"iceServers")?A5($.iceServers):Q.iceServers,Y=J===null?Q.iceServers:J&&J.length>0?J:void 0;return{transport:$.transport==="http"||$.transport==="webrtc"?$.transport:Q.transport,httpCodec:$.httpCodec==="auto"||$.httpCodec==="mjpeg"||$.httpCodec==="h264"?$.httpCodec:Q.httpCodec,webRtcCodec:$.webRtcCodec==="vp8"||$.webRtcCodec==="vp9"||$.webRtcCodec==="h264"?$.webRtcCodec:Q.webRtcCodec,...Y?{iceServers:Y}:{},...m4($,Q)}}function m4($={},Q=z4){return{mjpegFps:K4($.mjpegFps,Q.mjpegFps,1,120),mjpegQuality:L9($.mjpegQuality,Q.mjpegQuality,0.05,1),maxDimension:K4($.maxDimension,Q.maxDimension,0,4096),h264Bitrate:K4($.h264Bitrate,Q.h264Bitrate,1e5,50000000),h264Fps:K4($.h264Fps,Q.h264Fps,1,140)}}function O9($){return{mjpegFps:$.mjpegFps,mjpegQuality:$.mjpegQuality,maxDimension:$.maxDimension,h264Bitrate:$.h264Bitrate,h264Fps:$.h264Fps}}function c4($,Q){if(Q==="webrtc")return{maxDimension:$.maxDimension,h264Bitrate:$.h264Bitrate,h264Fps:$.h264Fps};return{mjpegFps:$.mjpegFps,mjpegQuality:$.mjpegQuality,maxDimension:$.maxDimension,h264Bitrate:$.h264Bitrate,h264Fps:$.h264Fps}}function U9($){let Q=$?{mjpegFps:$.mjpegFps,mjpegQuality:$.mjpegQuality,maxDimension:$.maxDimension,h264Bitrate:$.h264Bitrate,h264Fps:$.h264Fps}:{};if($?.transport==="webrtc")return F9({transport:"webrtc",webRtcCodec:$.codec,iceServers:$.iceServers,...Q});return F9({transport:"http",httpCodec:$?.codec??"auto",...Q})}function M4($){return typeof $==="object"&&$!==null&&!Array.isArray($)}function H4($){return typeof $==="number"&&Number.isFinite($)?$:0}function Z0($){return typeof $==="number"&&Number.isFinite($)?$:null}function l0($){return typeof $==="string"&&$.length>0?$:null}function C5($){if(!M4($))return{};let Q={};for(let[Z,J]of Object.entries($)){let Y=Z0(J);if(Y!==null)Q[Z]=Y*1000}return Q}function D5($,Q){let Z=[l0($),l0(Q)];if(Z.some((J)=>J===null))return"unknown";return Z.includes("relay")?"relay":"direct"}function P5($){let Q=H4($.framesEncoded),Z=H4($.packetsSent),J=H4($.packetsLost),Y=Z0($.totalEncodeTime),X=Z0($.targetBitrate),G=Z0($.roundTripTime);return{sessionId:l0($.sessionId)??"",sourceFrames:Z0($.sourceFrames),sourceFps:Z0($.sourceFramesPerSecond),sourceFramesDropped:Z0($.sourceFramesDropped),codec:l0($.codec),connected:$.connected===!0,qualityLimitationReason:l0($.qualityLimitationReason),qualityLimitationMs:C5($.qualityLimitationDurations),framesEncoded:Q,framesSent:H4($.framesSent),reportedFps:Z0($.framesPerSecond),targetKbps:X===null?null:X/1000,totalEncodeMs:Y===null?null:Y*1000,encodeMsPerFrame:Y===null||Q<=0?null:Y*1000/Q,width:Z0($.frameWidth),height:Z0($.frameHeight),packetsSent:Z,packetsLost:J,lossRatio:Z>0?Math.max(0,J)/Z:null,roundTripMs:G===null?null:G*1000,path:D5($.localCandidateType,$.remoteCandidateType)}}function A9($){if(!M4($)||!Array.isArray($.sessions))return{sessions:[]};return{sessions:$.sessions.filter(M4).map(P5),capture:E5($.capture)}}function E5($){if(!M4($))return null;let{screenFrames:Q,idleFrames:Z}=$;if(typeof Q!=="number"||typeof Z!=="number")return null;return{screenFrames:Q,idleFrames:Z,offeredFrames:typeof $.offeredFrames==="number"?$.offeredFrames:null,forwardedFrames:typeof $.forwardedFrames==="number"?$.forwardedFrames:null,pumpRestarts:typeof $.pumpRestarts==="number"?$.pumpRestarts:null,captureCpuCopies:Z0($.captureCpuCopies)}}var x5=T5(import.meta.url),q5=0,S5=1,w5=1,y5=2,d0={portrait:1,portraitUpsideDown:2,landscapeRight:3,landscapeLeft:4};function k5(){let $=[d4(l4(process.execPath),"native","serve-sim-native.node"),d4(l4(j9(import.meta.url)),"native","serve-sim-native.node"),d4(l4(j9(import.meta.url)),"..","dist","native","serve-sim-native.node")];for(let Q of $)if(I5(Q))return Q;throw Error(`serve-sim-native.node not found. Looked in:
41
41
  ${$.join(`
42
42
  `)}
43
43
  Run \`bun run build.ts\` to build the native addon.`)}var n4;function _4(){if(!n4)n4=x5(k5());return n4}class i4{handle;constructor($){this.handle=new(_4()).SimHID($)}async guard($,Q,Z){try{return await Q()}catch(J){return console.error(`[hid] ${$} ignored bad input:`,J instanceof Error?J.message:J),Z}}touch($,Q,Z,J,Y,X=0){return this.guard("touch",()=>this.handle.touch($,Q,Z,J,Y,X),void 0)}multiTouch($,Q,Z,J,Y,X,G){return this.guard("multiTouch",()=>this.handle.multiTouch($,Q,Z,J,Y,X,G),void 0)}button($){return this.guard("button",()=>this.handle.button($),void 0)}buttonHid($,Q,Z="press"){return this.guard("buttonHid",()=>this.handle.buttonHid($,Q,Z),void 0)}key($,Q){return this.guard("key",()=>this.handle.key($,Q),void 0)}scroll($,Q,Z,J,Y,X){return this.guard("scroll",()=>this.handle.scroll($,Q,Y??NaN,X??NaN,Z,J),void 0)}digitalCrown($){return this.guard("digitalCrown",()=>this.handle.digitalCrown($),void 0)}orientation($){return this.guard("orientation",()=>this.handle.orientation($),!1)}memoryWarning(){return this.guard("memoryWarning",()=>this.handle.memoryWarning(),void 0)}softwareKeyboard(){return this.guard("softwareKeyboard",()=>this.handle.softwareKeyboard(),void 0)}caDebug($,Q){return this.guard("caDebug",()=>this.handle.caDebug($,Q),!1)}}class o4{handle;constructor($,Q=z4){this.handle=new(_4()).SimCapture($,Q.mjpegFps,Q.mjpegQuality,Q.maxDimension,Q.h264Fps,Q.h264Bitrate)}start(){return this.handle.start()}updateStreamSettings($){return this.handle.updateStreamSettings($.mjpegFps,$.mjpegQuality,$.maxDimension,$.h264Fps,$.h264Bitrate)}subscribeMjpeg($){return this.handle.subscribe(q5,(Q,Z,J,Y)=>{return $({data:Q,width:Z,height:J})})}subscribeAvcc($){return this.handle.subscribe(S5,(Q,Z,J,Y)=>{return $({data:Q,width:Z,height:J,isDescription:(Y&w5)!==0,isKeyframe:(Y&y5)!==0})})}async handleWebRTCOffer($){return JSON.parse(await this.handle.handleWebRTCOffer(JSON.stringify($)))}closeWebRTCSession($){return this.handle.closeWebRTCSession($)}async webRTCSenderStats($){return A9(JSON.parse(await this.handle.webRTCSenderStats($??"")))}screenSize(){return this.handle.screenSize()}stop(){return this.handle.stop()}}function F4($){return _4().axDescribe($)}function N4($){return _4().axFrontmost($)}var a4=500,R9=500,f5=2000,v5=15000;function b5($){return $[0]?.frame??{x:0,y:0,width:1,height:1}}function h5($,Q){return Math.abs($.x-Q.x)<0.5&&Math.abs($.y-Q.y)<0.5&&Math.abs($.width-Q.width)<0.5&&Math.abs($.height-Q.height)<0.5}function g5($){let Q=b5($),Z=[],J=(Y,X)=>{if(Z.length>=a4)return;let G=Y.frame;if(!h5(G,Q))Z.push({id:Y.AXUniqueId??X,path:X,label:Y.AXLabel??"",value:Y.AXValue??"",role:Y.role_description,type:Y.type,enabled:Y.enabled!==!1,frame:G});for(let V=0;V<Y.children.length&&Z.length<a4;V++)J(Y.children[V],`${X}.${V}`)};for(let Y=0;Y<$.length&&Z.length<a4;Y++)J($[Y],String(Y));return{screen:{width:Q.width,height:Q.height},elements:Z}}async function u5($){let Q;try{Q=JSON.parse(await F4($))}catch{return{screen:{width:1,height:1},elements:[],errors:[p4]}}return g5(Q)}function p5($){return $?.errors?.includes(p4)??!1}function m5($){return $.elements.length>0&&$.screen.width>1&&$.screen.height>1}async function c5($){let Q=[];try{let Z=await u5($);if(Z.errors?.length)return Z;if(!m5(Z))throw Error(`native AX returned ${Z.elements.length} elements in ${Z.screen.width}x${Z.screen.height} AX space`);return{...Z,errors:Q}}catch(Z){Q.push(Z.message||String(Z))}return{screen:{width:1,height:1},elements:[],errors:Q}}function l5($){return`data: ${JSON.stringify($)}
@@ -131,5 +131,5 @@ ${N}`)}})();return}if(!A){H.destroy();return}let D=A.device??T;if(A.upstreamPath
131
131
  \r
132
132
  `)};let L=async(O)=>{return o6(z,O)},B=h6({path:`${Z}/exec-ws`,execToken:K,ssePrefixes:[`${Z}/api/events`,`${Z}/api/event-log/events`,`${Z}/grid/api/status/events`,`${Z}/appstate`,`${Z}/logs`,`${Z}/metrics`,`${Z}/ax`],onUiRequest:W,onCommandResult:(O,H)=>k$(O,H),onSseRequest(O,H){let P=new URL(O,H.url);return L(new Request(P,{headers:{accept:"text/event-stream"}}))}});return L.handleWebSocket=(O,H)=>{if(B(O,H))return!0;if(f9(O,H,{helperProxyTarget:(P)=>a8(P,J),fallbackDevice:$?.device??null,resolveSession:(P)=>a0(P,Q)}))return!0;return!1},L.handleUpgrade=(O,H,P)=>{z.handleUpgrade?.(O,H,P)},L}export{q1 as startDeviceInProcess,JY as simMiddleware,W0 as selectServeSimState,y4 as rewriteStateForRequestHost,J0 as readServeSimStates,r8 as previewConfigForState,b$ as parseGridPaging,ZY as matchInstalledAppByDisplayName,i1 as handleMetricsRequest,U1 as deviceNameFromBootedNames};
133
133
 
134
- //# debugId=9D04BFD3A1D5A7EF64756E2164756E21
134
+ //# debugId=400FF03521E4933164756E2164756E21
135
135
  //# sourceMappingURL=middleware.js.map
Binary file