@expo/serve-sim 0.1.35-canary.0 → 0.1.36

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.
@@ -119,5 +119,5 @@ ${E}`)}})();return}if(!A){N.destroy();return}let U=A.device??x;if(A.upstreamPath
119
119
  \r
120
120
  `)};let B=async(M)=>{return y6(z,M)};return B.handleWebSocket=C6({path:`${Z}/exec-ws`,execToken:H,ssePrefixes:[`${Z}/api/events`,`${Z}/api/event-log/events`,`${Z}/appstate`,`${Z}/logs`,`${Z}/metrics`,`${Z}/ax`],onUiRequest:W,onCommandResult:(M,N)=>L$(M,N),onSseRequest(M,N){let j=new URL(M,N.url);return B(new Request(j,{headers:{accept:"text/event-stream"}}))}}),B.handleUpgrade=(M,N,j)=>{z.handleUpgrade?.(M,N,j)},B}export{J1 as startDeviceInProcess,P3 as simMiddleware,M0 as selectServeSimState,T4 as rewriteStateForRequestHost,G0 as readServeSimStates,h8 as previewConfigForState,o2 as parseGridPaging,D3 as matchInstalledAppByDisplayName,O1 as handleMetricsRequest};
121
121
 
122
- //# debugId=DDC480C4D1EF6D9D64756E2164756E21
122
+ //# debugId=BA4F8FABF97089D764756E2164756E21
123
123
  //# sourceMappingURL=middleware.js.map
Binary file
package/dist/serve-sim.js CHANGED
@@ -159,7 +159,7 @@ Usage:
159
159
  serve-sim permissions reset <permission|all> <bundle-id> [-d <udid|name>]
160
160
  serve-sim permissions list [bundle-id] [-d <udid|name>]
161
161
 
162
- Permissions: ${u$().join(", ")}`),process.exit(1);let Y=J.device?t(J.device):X0();if(!Y)console.error("No booted simulator. Boot one or pass -d <udid|name>."),process.exit(1);if(J.verb==="list"){let G={udid:Y,bundleId:J.bundleId??null,tcc:Z1(Y,J.bundleId),location:Y1(Y,J.bundleId),notifications:W1(Y,J.bundleId)};console.log(JSON.stringify(G,null,Q?0:2)),process.exit(0)}let X=J.bundleId;try{if(J.permission==="all")for(let G of u$())L6(Y,"reset",G,void 0,X);else L6(Y,J.verb,J.permission,J.value,X)}catch(G){console.error(G?.message??String(G)),process.exit(1)}if(Q)console.log(JSON.stringify({udid:Y,verb:J.verb,permission:J.permission,value:J.value??null,bundleId:X}));else{let G=J.value?` (${J.value})`:"";console.log(`\uD83D\uDD10 ${J.verb} ${J.permission}${G} for ${X} on ${Y}`)}process.exit(0)}t$();Z8();function g6($,Q={}){let Z=new Date($.timestamp),J=Number.isNaN(Z.getTime())?$.timestamp:Z.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),Y=Q.deviceLabel??($.device?$.device.slice(0,8):null),X=$.status==="error"?" failed":"";return[J,Y,`${e1($)}${X?` (${X.trim()})`:""}`].filter(Boolean).join(" ")}function e1($){if($.kind==="tap"){let Q=e4($.details,"current")??e4($.details,"start");return Q?`Tap at ${J8(Q)}`:"Tap"}if($.kind==="drag"){let Q=e4($.details,"start"),Z=e4($.details,"current");if(Q&&Z)return`Drag from ${J8(Q)} to ${J8(Z)}`;return"Drag"}if($.kind==="key"){let Q=$2($.details,"key")??$.action??"key",Z=$.action==="down"?"down":$.action==="up"?"up":$.action;return Z?`Key ${Z} ${u6(Q)}`:`Key ${u6(Q)}`}if($.kind==="rotate"){let Q=$.action?m6($.action):"";return Q?`Rotate ${Q}`:"Rotate"}return Z2($.msg??$.summary)}function e4($,Q){let Z=$?.[Q];if(!Z||typeof Z!=="object"||Array.isArray(Z))return null;let J=Z;return typeof J.x==="number"&&typeof J.y==="number"?{x:J.x,y:J.y}:null}function $2($,Q){let Z=$?.[Q];return typeof Z==="string"&&Z.length>0?Z:null}function J8($){return`${h6($.x)}, ${h6($.y)}`}function h6($){if(!Number.isFinite($))return"?";return(Math.round((Q2($,0,1)+Number.EPSILON)*100)/100).toFixed(2)}function Q2($,Q,Z){return Math.min(Z,Math.max(Q,$))}function Z2($){return $.replace(/\b[a-z]+(?:_[a-z]+)+\b/g,m6)}function m6($){return $.replace(/[-_]+/g," ")}function u6($){return{MetaLeft:"Left Command",MetaRight:"Right Command",AltLeft:"Left Option",AltRight:"Right Option",ControlLeft:"Left Control",ControlRight:"Right Control",ShiftLeft:"Left Shift",ShiftRight:"Right Shift",ArrowLeft:"Left Arrow",ArrowRight:"Right Arrow",ArrowUp:"Up Arrow",ArrowDown:"Down Arrow"}[$]??$}G8();function K8($,Q){let Z=$.split(",").map((Y)=>Y.trim()).filter(Boolean),J=Q==="stun"?/^stuns?:/i:/^turns?:/i;if(Z.length===0||Z.length>16||Z.some((Y)=>Y.length>2048||!J.test(Y)))throw Error(`Expected one or more comma-separated ${Q.toUpperCase()} URLs`);return Z}function W8($,Q){let Z=$??{transport:"http"},J=Q??{transport:"http"};if(Z.transport!==J.transport)return!1;if(Z.transport==="http"&&J.transport==="http")return(Z.codec??"auto")===(J.codec??"auto");if(Z.transport!=="webrtc"||J.transport!=="webrtc")return!1;if(Z.codec!==J.codec)return!1;let Y=Z.iceServers??[],X=J.iceServers??[];if(Y.length!==X.length)return!1;return Y.every((G,W)=>{let K=X[W];return G.username===K.username&&G.credential===K.credential&&G.urls.length===K.urls.length&&G.urls.every((z,V)=>z===K.urls[V])})}function p6($,Q){let Z=[];for(let J of $??[])for(let Y of J.urls){let X=Y.toLowerCase();if(Q.some((G)=>X.startsWith(G)))Z.push(Y)}return Z}function K2($){for(let Q of $??[])if(Q.urls.some((Z)=>/^turns?:/i.test(Z)))return Q;return null}function W2($){if(!$)return[];let Q=[];if(Q.push("--transport",$.transport),$.transport==="http"){if($.codec)Q.push("--codec",$.codec);return Q}Q.push("--webrtc-codec",$.codec);let Z=p6($.iceServers,["stun:","stuns:"]);if(Z.length)Q.push("--stun-url",Z.join(","));let J=p6($.iceServers,["turn:","turns:"]);if(J.length){Q.push("--turn-url",J.join(","));let Y=K2($.iceServers);if(Y?.username)Q.push("--turn-username",Y.username);if(Y?.credential)Q.push("--turn-credential",Y.credential)}return Q}function d6($,Q,Z,J){return[$,"--port",String(Q),"--host",Z,...W2(J)]}var w0=d4(import.meta.url);function qX(){return"0.1.35-canary.0"}function W7(){if(!V0(M0))B9(M0,{recursive:!0})}function e($){if($)return U9(g4($));for(let Q of c4()){let Z=U9(Q);if(Z)return Z}return null}var A$={at:0,booted:null};function IX(){let $=Date.now();if(A$.booted&&$-A$.at<1000)return A$.booted;try{let Q=Z0("xcrun simctl list devices booted -j",{encoding:"utf-8",stdio:["ignore","pipe","pipe"],timeout:3000}),Z=JSON.parse(Q),J=new Set;for(let Y of Object.values(Z.devices))for(let X of Y)if(X.state==="Booted")J.add(X.udid);return A$={at:$,booted:J},J}catch{return null}}function U9($){try{if(!V0($))return L0("state file missing %s",$),null;let Q=JSON.parse(n0($,"utf-8"));try{process.kill(Q.pid,0)}catch{return L0("helper pid %d dead, removing stale state %s",Q.pid,$),d0($),null}let Z=IX();if(Z&&!Z.has(Q.device)){if(Q.pid===process.pid){L0("dropping own stale state for non-booted device %s",Q.device);try{d0($)}catch{}return null}L0("helper pid %d bound to non-booted device %s — killing stale helper",Q.pid,Q.device),console.error(`[serve-sim] Helper pid ${Q.pid} is bound to device ${Q.device} which is no longer booted — killing stale helper.`);try{process.kill(Q.pid,"SIGTERM")}catch{}try{d0($)}catch{}return null}return L0("state ok pid=%d device=%s port=%d",Q.pid,Q.device,Q.port),Q}catch(Q){return L0("readStateFile threw for %s: %o",$,Q),null}}function f4(){let $=[];for(let Q of c4()){let Z=U9(Q);if(Z)$.push(Z)}return $}function xX($){W7(),m4($),L0("wrote state pid=%d device=%s port=%d",$.pid,$.device,$.port)}function A0($){if($){L0("clearState device=%s",$);try{d0(g4($))}catch{}}else{L0("clearState (all)");for(let Q of c4())try{d0(Q)}catch{}}}function F9(){try{let $=Z0("xcrun simctl list devices -j",{encoding:"utf-8"}),Q=JSON.parse($),Z=Object.keys(Q.devices).filter((J)=>/SimRuntime\.iOS-/i.test(J)).sort((J,Y)=>{let X=(J.match(/iOS-(\d+)-(\d+)/)??[]).slice(1).map(Number),G=(Y.match(/iOS-(\d+)-(\d+)/)??[]).slice(1).map(Number);return(G[0]??0)-(X[0]??0)||(G[1]??0)-(X[1]??0)});for(let J of Z){let X=(Q.devices[J]??[]).find((G)=>G.isAvailable!==!1&&/^iPhone\b/i.test(G.name));if(X)return{udid:X.udid,name:X.name}}}catch{}return null}function X7($){return z7().get($)??null}function z7(){let $=new Map;try{let Q=Z0("xcrun simctl list devices -j",{encoding:"utf-8"}),Z=JSON.parse(Q);for(let J of Object.values(Z.devices))for(let Y of J)$.set(Y.udid,Y.name)}catch{}return $}function V7($){try{let Q=Z0("xcrun simctl list devices -j",{encoding:"utf-8"}),Z=JSON.parse(Q);for(let J of Object.values(Z.devices))for(let Y of J)if(Y.udid===$)return Y.state==="Booted"}catch{}return!1}function _9($){try{return process.kill($,0),!0}catch{return!1}}function D$($){try{process.kill($,"SIGTERM")}catch{return}let Q=Date.now()+500;while(Date.now()<Q)try{process.kill($,0),k0(25)}catch{return}try{process.kill($,"SIGKILL")}catch{}let Z=Date.now()+500;while(Date.now()<Z)try{process.kill($,0),k0(25)}catch{return}}function wX($){if(!V7($))try{Z0(`xcrun simctl boot ${$}`,{encoding:"utf-8",stdio:"pipe"})}catch(Q){let Z=(Q.stderr??Q.message??"").toLowerCase();if(!Z.includes("booted")&&!Z.includes("current state"))throw Error(`Failed to boot device ${$}: ${Q.stderr||Q.message}`)}try{Z0("open -ga Simulator",{encoding:"utf-8",stdio:"pipe",timeout:3000})}catch{}}function SX(){let $=CX();for(let Q of Object.values($))for(let Z of Q??[])if(Z.family==="IPv4"&&!Z.internal)return Z.address;return null}async function H7($){let Q=new Set(f4().map((Z)=>Z.port));for(let Z=$;Z<$+100;Z++){if(Q.has(Z))continue;if(await W6(Z))return Z}throw Error(`No available port found in range ${$}-${$+99}`)}async function kX($){wX($);try{Z0(`xcrun simctl bootstatus ${$} -b`,{encoding:"utf-8",stdio:"pipe",timeout:60000})}catch(Q){if(!V7($))console.error(`Device ${$} failed to reach booted state: ${Q.stderr||Q.message}`),process.exit(1)}}function yX($){if(process.argv[0]&&/(^|\/)serve-sim$/.test(process.argv[0]))return{command:process.argv[0],args:$};return{command:process.argv[0],args:[process.argv[1],...$]}}async function fX($,Q=150000){let Z=Date.now();while(Date.now()-Z<Q){let J=e($);if(J)return J;await new Promise((Y)=>setTimeout(Y,200))}return null}async function M7($,Q,Z){Q8("startHelper udid=%s port=%d detach=%s",$,Q,Z.detach);let J="127.0.0.1";W7(),A0($),H6(Q);let Y=_0(M0,`server-${$}.log`),X=N9(Y,"w"),{command:G,args:W}=yX(d6($,Q,J,Z.stream)),K=G7(G,W,{detached:Z.detach,stdio:["ignore",X,X]});if(R9(X),Z.detach)K.unref();let z=await fX($);if(!z){if(K.pid)D$(K.pid);let V="";try{V=n0(Y,"utf-8").trim()}catch{}console.error(V?`Preview server failed:
162
+ Permissions: ${u$().join(", ")}`),process.exit(1);let Y=J.device?t(J.device):X0();if(!Y)console.error("No booted simulator. Boot one or pass -d <udid|name>."),process.exit(1);if(J.verb==="list"){let G={udid:Y,bundleId:J.bundleId??null,tcc:Z1(Y,J.bundleId),location:Y1(Y,J.bundleId),notifications:W1(Y,J.bundleId)};console.log(JSON.stringify(G,null,Q?0:2)),process.exit(0)}let X=J.bundleId;try{if(J.permission==="all")for(let G of u$())L6(Y,"reset",G,void 0,X);else L6(Y,J.verb,J.permission,J.value,X)}catch(G){console.error(G?.message??String(G)),process.exit(1)}if(Q)console.log(JSON.stringify({udid:Y,verb:J.verb,permission:J.permission,value:J.value??null,bundleId:X}));else{let G=J.value?` (${J.value})`:"";console.log(`\uD83D\uDD10 ${J.verb} ${J.permission}${G} for ${X} on ${Y}`)}process.exit(0)}t$();Z8();function g6($,Q={}){let Z=new Date($.timestamp),J=Number.isNaN(Z.getTime())?$.timestamp:Z.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),Y=Q.deviceLabel??($.device?$.device.slice(0,8):null),X=$.status==="error"?" failed":"";return[J,Y,`${e1($)}${X?` (${X.trim()})`:""}`].filter(Boolean).join(" ")}function e1($){if($.kind==="tap"){let Q=e4($.details,"current")??e4($.details,"start");return Q?`Tap at ${J8(Q)}`:"Tap"}if($.kind==="drag"){let Q=e4($.details,"start"),Z=e4($.details,"current");if(Q&&Z)return`Drag from ${J8(Q)} to ${J8(Z)}`;return"Drag"}if($.kind==="key"){let Q=$2($.details,"key")??$.action??"key",Z=$.action==="down"?"down":$.action==="up"?"up":$.action;return Z?`Key ${Z} ${u6(Q)}`:`Key ${u6(Q)}`}if($.kind==="rotate"){let Q=$.action?m6($.action):"";return Q?`Rotate ${Q}`:"Rotate"}return Z2($.msg??$.summary)}function e4($,Q){let Z=$?.[Q];if(!Z||typeof Z!=="object"||Array.isArray(Z))return null;let J=Z;return typeof J.x==="number"&&typeof J.y==="number"?{x:J.x,y:J.y}:null}function $2($,Q){let Z=$?.[Q];return typeof Z==="string"&&Z.length>0?Z:null}function J8($){return`${h6($.x)}, ${h6($.y)}`}function h6($){if(!Number.isFinite($))return"?";return(Math.round((Q2($,0,1)+Number.EPSILON)*100)/100).toFixed(2)}function Q2($,Q,Z){return Math.min(Z,Math.max(Q,$))}function Z2($){return $.replace(/\b[a-z]+(?:_[a-z]+)+\b/g,m6)}function m6($){return $.replace(/[-_]+/g," ")}function u6($){return{MetaLeft:"Left Command",MetaRight:"Right Command",AltLeft:"Left Option",AltRight:"Right Option",ControlLeft:"Left Control",ControlRight:"Right Control",ShiftLeft:"Left Shift",ShiftRight:"Right Shift",ArrowLeft:"Left Arrow",ArrowRight:"Right Arrow",ArrowUp:"Up Arrow",ArrowDown:"Down Arrow"}[$]??$}G8();function K8($,Q){let Z=$.split(",").map((Y)=>Y.trim()).filter(Boolean),J=Q==="stun"?/^stuns?:/i:/^turns?:/i;if(Z.length===0||Z.length>16||Z.some((Y)=>Y.length>2048||!J.test(Y)))throw Error(`Expected one or more comma-separated ${Q.toUpperCase()} URLs`);return Z}function W8($,Q){let Z=$??{transport:"http"},J=Q??{transport:"http"};if(Z.transport!==J.transport)return!1;if(Z.transport==="http"&&J.transport==="http")return(Z.codec??"auto")===(J.codec??"auto");if(Z.transport!=="webrtc"||J.transport!=="webrtc")return!1;if(Z.codec!==J.codec)return!1;let Y=Z.iceServers??[],X=J.iceServers??[];if(Y.length!==X.length)return!1;return Y.every((G,W)=>{let K=X[W];return G.username===K.username&&G.credential===K.credential&&G.urls.length===K.urls.length&&G.urls.every((z,V)=>z===K.urls[V])})}function p6($,Q){let Z=[];for(let J of $??[])for(let Y of J.urls){let X=Y.toLowerCase();if(Q.some((G)=>X.startsWith(G)))Z.push(Y)}return Z}function K2($){for(let Q of $??[])if(Q.urls.some((Z)=>/^turns?:/i.test(Z)))return Q;return null}function W2($){if(!$)return[];let Q=[];if(Q.push("--transport",$.transport),$.transport==="http"){if($.codec)Q.push("--codec",$.codec);return Q}Q.push("--webrtc-codec",$.codec);let Z=p6($.iceServers,["stun:","stuns:"]);if(Z.length)Q.push("--stun-url",Z.join(","));let J=p6($.iceServers,["turn:","turns:"]);if(J.length){Q.push("--turn-url",J.join(","));let Y=K2($.iceServers);if(Y?.username)Q.push("--turn-username",Y.username);if(Y?.credential)Q.push("--turn-credential",Y.credential)}return Q}function d6($,Q,Z,J){return[$,"--port",String(Q),"--host",Z,...W2(J)]}var w0=d4(import.meta.url);function qX(){return"0.1.36"}function W7(){if(!V0(M0))B9(M0,{recursive:!0})}function e($){if($)return U9(g4($));for(let Q of c4()){let Z=U9(Q);if(Z)return Z}return null}var A$={at:0,booted:null};function IX(){let $=Date.now();if(A$.booted&&$-A$.at<1000)return A$.booted;try{let Q=Z0("xcrun simctl list devices booted -j",{encoding:"utf-8",stdio:["ignore","pipe","pipe"],timeout:3000}),Z=JSON.parse(Q),J=new Set;for(let Y of Object.values(Z.devices))for(let X of Y)if(X.state==="Booted")J.add(X.udid);return A$={at:$,booted:J},J}catch{return null}}function U9($){try{if(!V0($))return L0("state file missing %s",$),null;let Q=JSON.parse(n0($,"utf-8"));try{process.kill(Q.pid,0)}catch{return L0("helper pid %d dead, removing stale state %s",Q.pid,$),d0($),null}let Z=IX();if(Z&&!Z.has(Q.device)){if(Q.pid===process.pid){L0("dropping own stale state for non-booted device %s",Q.device);try{d0($)}catch{}return null}L0("helper pid %d bound to non-booted device %s — killing stale helper",Q.pid,Q.device),console.error(`[serve-sim] Helper pid ${Q.pid} is bound to device ${Q.device} which is no longer booted — killing stale helper.`);try{process.kill(Q.pid,"SIGTERM")}catch{}try{d0($)}catch{}return null}return L0("state ok pid=%d device=%s port=%d",Q.pid,Q.device,Q.port),Q}catch(Q){return L0("readStateFile threw for %s: %o",$,Q),null}}function f4(){let $=[];for(let Q of c4()){let Z=U9(Q);if(Z)$.push(Z)}return $}function xX($){W7(),m4($),L0("wrote state pid=%d device=%s port=%d",$.pid,$.device,$.port)}function A0($){if($){L0("clearState device=%s",$);try{d0(g4($))}catch{}}else{L0("clearState (all)");for(let Q of c4())try{d0(Q)}catch{}}}function F9(){try{let $=Z0("xcrun simctl list devices -j",{encoding:"utf-8"}),Q=JSON.parse($),Z=Object.keys(Q.devices).filter((J)=>/SimRuntime\.iOS-/i.test(J)).sort((J,Y)=>{let X=(J.match(/iOS-(\d+)-(\d+)/)??[]).slice(1).map(Number),G=(Y.match(/iOS-(\d+)-(\d+)/)??[]).slice(1).map(Number);return(G[0]??0)-(X[0]??0)||(G[1]??0)-(X[1]??0)});for(let J of Z){let X=(Q.devices[J]??[]).find((G)=>G.isAvailable!==!1&&/^iPhone\b/i.test(G.name));if(X)return{udid:X.udid,name:X.name}}}catch{}return null}function X7($){return z7().get($)??null}function z7(){let $=new Map;try{let Q=Z0("xcrun simctl list devices -j",{encoding:"utf-8"}),Z=JSON.parse(Q);for(let J of Object.values(Z.devices))for(let Y of J)$.set(Y.udid,Y.name)}catch{}return $}function V7($){try{let Q=Z0("xcrun simctl list devices -j",{encoding:"utf-8"}),Z=JSON.parse(Q);for(let J of Object.values(Z.devices))for(let Y of J)if(Y.udid===$)return Y.state==="Booted"}catch{}return!1}function _9($){try{return process.kill($,0),!0}catch{return!1}}function D$($){try{process.kill($,"SIGTERM")}catch{return}let Q=Date.now()+500;while(Date.now()<Q)try{process.kill($,0),k0(25)}catch{return}try{process.kill($,"SIGKILL")}catch{}let Z=Date.now()+500;while(Date.now()<Z)try{process.kill($,0),k0(25)}catch{return}}function wX($){if(!V7($))try{Z0(`xcrun simctl boot ${$}`,{encoding:"utf-8",stdio:"pipe"})}catch(Q){let Z=(Q.stderr??Q.message??"").toLowerCase();if(!Z.includes("booted")&&!Z.includes("current state"))throw Error(`Failed to boot device ${$}: ${Q.stderr||Q.message}`)}try{Z0("open -ga Simulator",{encoding:"utf-8",stdio:"pipe",timeout:3000})}catch{}}function SX(){let $=CX();for(let Q of Object.values($))for(let Z of Q??[])if(Z.family==="IPv4"&&!Z.internal)return Z.address;return null}async function H7($){let Q=new Set(f4().map((Z)=>Z.port));for(let Z=$;Z<$+100;Z++){if(Q.has(Z))continue;if(await W6(Z))return Z}throw Error(`No available port found in range ${$}-${$+99}`)}async function kX($){wX($);try{Z0(`xcrun simctl bootstatus ${$} -b`,{encoding:"utf-8",stdio:"pipe",timeout:60000})}catch(Q){if(!V7($))console.error(`Device ${$} failed to reach booted state: ${Q.stderr||Q.message}`),process.exit(1)}}function yX($){if(process.argv[0]&&/(^|\/)serve-sim$/.test(process.argv[0]))return{command:process.argv[0],args:$};return{command:process.argv[0],args:[process.argv[1],...$]}}async function fX($,Q=150000){let Z=Date.now();while(Date.now()-Z<Q){let J=e($);if(J)return J;await new Promise((Y)=>setTimeout(Y,200))}return null}async function M7($,Q,Z){Q8("startHelper udid=%s port=%d detach=%s",$,Q,Z.detach);let J="127.0.0.1";W7(),A0($),H6(Q);let Y=_0(M0,`server-${$}.log`),X=N9(Y,"w"),{command:G,args:W}=yX(d6($,Q,J,Z.stream)),K=G7(G,W,{detached:Z.detach,stdio:["ignore",X,X]});if(R9(X),Z.detach)K.unref();let z=await fX($);if(!z){if(K.pid)D$(K.pid);let V="";try{V=n0(Y,"utf-8").trim()}catch{}console.error(V?`Preview server failed:
163
163
  ${V}`:"Preview server failed to start"),process.exit(1)}return Z.detach?{pid:z.pid}:{pid:z.pid,child:K}}async function bX($,Q,Z,J,Y=!1){$8("follow devices=%o startPort=%d",$,Q);let X=$.length>0?$.map(t):(()=>{let M=X0();if(M)return[M];let L=F9();if(!L)console.error("No device specified and no available iOS simulator found."),process.exit(1);if(!Z)console.log(`No booted simulator — booting ${L.name}...`);return[L.udid]})(),G=new Map,W=[],K=Q;for(let M of X){let L=e(M);if(L)if(Y&&!W8(L.streamSettings,J))D$(L.pid),A0(M);else{if(!Z){let T=X7(M)??M;if(X.length>1)console.log(`
164
164
  ==> ${T} (${M}) <==`);console.log(` Already running on port ${L.port}`),console.log(` Stream: ${L.streamUrl}`),console.log(` WebSocket: ${L.wsUrl}`)}W.push(L);continue}K=await H7(K);let{child:_}=await M7(M,K,{detach:!1,stream:J});if(_)G.set(M,_);let F=e(M)??s0(M,K,"/","127.0.0.1");if(W.push(F),!Z){let T=X7(M)??M;if(X.length>1)console.log(`
165
165
  ==> ${T} (${M}) <==`);console.log(` Stream: ${F.streamUrl}`),console.log(` WebSocket: ${F.wsUrl}`),console.log(` Port: ${K}`)}K++}if(W.length===1){let M=W[0];console.log(JSON.stringify({url:M.url,streamUrl:M.streamUrl,wsUrl:M.wsUrl,port:M.port,device:M.device}))}else console.log(JSON.stringify({devices:W.map((M)=>({url:M.url,streamUrl:M.streamUrl,wsUrl:M.wsUrl,port:M.port,device:M.device}))}));if(G.size===0)return;let z=!1,V=(M)=>{if(z)return;if(z=!0,!Z)console.log(`
@@ -214,5 +214,5 @@ Examples:
214
214
  serve-sim --list Show all running streams
215
215
  serve-sim --kill Stop all streams`).action(async($,Q)=>{if(Q.list!==void 0){uX(typeof Q.list==="string"?Q.list:void 0);return}if(Q.kill!==void 0){gX(typeof Q.kill==="string"?Q.kill:void 0);return}if(Q.transport!=="http"&&Q.transport!=="webrtc")console.error("--transport must be one of: http, webrtc."),process.exit(1);let Z=(z)=>J0.getOptionValueSource(z)==="cli",J=["webrtcCodec","stunUrl","turnUrl","turnUsername","turnCredential"].some(Z);if(Q.transport==="http"&&J)console.error("WebRTC options require --transport webrtc."),process.exit(1);if(Q.transport==="webrtc"&&Z("codec"))console.error("--codec configures HTTP streaming; use --webrtc-codec with --transport webrtc."),process.exit(1);if(Q.turnUsername===void 0!==(Q.turnCredential===void 0))console.error("--turn-username and --turn-credential must be provided together."),process.exit(1);if((Q.turnUsername!==void 0||Q.turnCredential!==void 0)&&!Q.turnUrl)console.error("--turn-username and --turn-credential require --turn-url."),process.exit(1);let Y=Q.stunUrl??[],X=[];if(Y.length)X.push({urls:Y});if(Q.turnUrl)X.push({urls:Q.turnUrl,username:Q.turnUsername,credential:Q.turnCredential});let G=Q.transport==="webrtc"?{transport:"webrtc",codec:Q.webrtcCodec,...X.length?{iceServers:X}:{}}:{transport:"http",codec:Q.codec},W=Q.port,K=Z("transport")||Z("codec")||J;if(Q.detach){let z=await vX($,W??3100,G,K);hX(z)}else if(Q.preview===!1)await bX($,W??3100,!!Q.quiet,G,K);else await WG(W??3200,$,W!==void 0,Q.host,{stream:G,metricsCorsOrigins:Q.metricsCorsOrigin})});var S0=["-d, --device <udid>","Target a specific simulator (udid or name)"];J0.command("gesture").description("Send a touch gesture").argument("<json>",`Gesture JSON, e.g. '{"type":"begin","x":0.5,"y":0.5}'`).option(...S0).action(($,Q)=>pX($,Q.device));J0.command("tap").description("Tap at normalized 0..1 coords").argument("<x>","X coord, normalized 0..1").argument("<y>","Y coord, normalized 0..1").option(...S0).action(($,Q,Z)=>dX($,Q,Z.device));J0.command("button").description("Send a hardware button press").argument("[name]","Button name","home").option(...S0).action(($,Q)=>aX($,Q.device));J0.command("type").description("Type text (US keyboard only)").argument("[text...]","Text to type").option(...S0).option("--stdin","Read text from stdin").option("--file <path>","Read text from a file").action(($,Q)=>nX($,{device:Q.device,stdin:Q.stdin,file:Q.file}));J0.command("rotate").description("Set device orientation (portrait|portrait_upside_down|landscape_left|landscape_right)").argument("<orientation>").option(...S0).action(($,Q)=>iX($,Q.device));J0.command("ca-debug").description("Toggle a CoreAnimation debug render flag (blended|copies|misaligned|offscreen|slow-animations)").argument("<option>").argument("<state>","on|off").option(...S0).action(($,Q,Z)=>rX($,Q,Z.device));J0.command("memory-warning").description("Simulate a memory warning on the device").option(...S0).action(($)=>tX($.device));J0.command("event-log").description("Show recent simulator events").option(...S0).option("-j, --json","Print JSON").option("-n, --limit <count>","Maximum number of events").action(($)=>mX($.device,{json:$.json,limit:$.limit}));J0.command("camera").description("Inject a synthetic camera feed and launch an app (see `camera --help`)").allowUnknownOption(!0).helpOption(!1).argument("[args...]").action(($)=>GG($));J0.command("permissions").description("Manage app permissions (see `permissions` with no args for usage)").allowUnknownOption(!0).helpOption(!1).argument("[args...]").action(($)=>j6($));J0.command("ui").description("Get or set simulator-wide UI options (see `ui --help`)").allowUnknownOption(!0).helpOption(!1).argument("[args...]").action(($)=>C6($));await J0.parseAsync(process.argv);
216
216
 
217
- //# debugId=54647A67387186AB64756E2164756E21
217
+ //# debugId=B2991F5E6D7762EB64756E2164756E21
218
218
  //# sourceMappingURL=serve-sim.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/serve-sim",
3
- "version": "0.1.35-canary.0",
3
+ "version": "0.1.36",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Evan Bacon",