expo-device-hub 0.15.0 → 0.15.1
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.
- package/dist/client/_expo/static/js/web/{index-0eccae32da572b2da1e160c30dcbcc8e.js → index-b067b431abff858a0c5cffdec4353299.js} +3 -3
- package/dist/client/index.html +1 -1
- package/package.json +1 -1
- package/vendor/serve-emu/dist/middleware.js +13 -9
- package/vendor/serve-sim/dist/middleware.js +98 -98
- package/vendor/serve-sim/dist/serve-sim.js +119 -119
|
@@ -237,7 +237,7 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v
|
|
|
237
237
|
__d(function(g,r,i,a,m,e,d){"use strict";function t(t,n){return`${t.replace(/\/$/,"")}${n}`}Object.defineProperty(e,'__esModule',{value:!0}),e.apiUrl=t,e.deviceApiUrl=function(n,c,u){const o=new URL(t(n,c));u&&o.searchParams.set("device",u);return o.toString()}},171,[]);
|
|
238
238
|
__d(function(g,r,i,a,m,e,d){"use strict";function t(t){return!t||"object"!=typeof t||Array.isArray(t)?null:t}function n(t){return"number"==typeof t&&Number.isFinite(t)?t:null}function o(o){const u=t(o);if(!u)return null;const l=n(u.latitude),c=n(u.longitude);return null===l||null===c?null:{latitude:l,longitude:c}}Object.defineProperty(e,'__esModule',{value:!0}),e.parseAndroidFix=o,e.readAndroidLocation=async function(n,u,l){try{const c=await n(u,{cache:"no-store",signal:l});if(!c.ok)return null;const s=t(await c.json());return s&&"boolean"==typeof s.emulator?s.emulator?{supported:!0,location:o(s.location)}:{supported:!1,location:null}:null}catch{return null}},e.writeAndroidLocation=async function(n,u,l){const c=await n(u,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(l)}),s=t(await c.json().catch(()=>null));if(!c.ok||!0!==s?.ok){const t=s?.error;throw new Error("string"==typeof t?t:`Location update failed (${c.status})`)}return o(s.location)??l}},172,[]);
|
|
239
239
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.parseAndroidPermissions=o,e.androidPermissionsBackend=function(c,p,u=fetch){const l=async t=>{const l=`/api/apps/permissions?packageName=${encodeURIComponent(t)}`,f=await u((0,n.deviceApiUrl)(c,l,p),{cache:"no-store"});return(0,s.readPermissions)(f,o,"Could not read permissions")},f=async(o,t)=>{const l=await u((0,n.deviceApiUrl)(c,o,p),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(l.ok)return;const f=await l.json().catch(()=>null);throw new Error((0,s.errorMessage)(f,"Permission update failed"))};return{list:l,write:async(n,s,o)=>(await f(t[o],{packageName:n,permission:s}),l(n)),reset:async n=>(await f("/api/apps/reset-permissions",{packageName:n}),l(n))}};var n=r(d[0]),s=r(d[1]);function o(n){const o=(0,s.asRecord)(n);if(!o||!0!==o.ok||!Array.isArray(o.permissions))return null;const t=[];for(const n of o.permissions){const o=(0,s.asRecord)(n);if(!o||"string"!=typeof o.name||"boolean"!=typeof o.granted)return null;t.push({id:o.name,label:(0,s.humanize)(o.name),state:o.granted?"granted":"denied"})}return t}const t={grant:"/api/apps/grant",revoke:"/api/apps/revoke"}},173,[171,164]);
|
|
240
|
-
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.
|
|
240
|
+
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.parseAppIconResponse=c,e.fetchAndroidAppIcon=async function(o,t,s,p=fetch){const f=new URL((0,n.deviceApiUrl)(o,'/api/apps/icon',t));f.searchParams.set('packageName',s);const u=await p(f.toString(),{cache:'no-store'});if(!u.ok)throw new Error(`app icon request failed with ${u.status}`);return c(await u.json())},e.carryForwardAppIcon=function(n,o){return n&&n.id===o.id&&n.iconDataUrl&&!o.iconDataUrl?Object.assign({},o,{iconDataUrl:n.iconDataUrl}):o};var n=r(d[0]),o=r(d[1]);const t=['image/png','image/webp','image/jpeg','image/gif'];function c(n){const c=(0,o.asRecord)(n);if(!c||!0!==c.ok)throw new Error('app icon response is invalid');if(null===c.icon)return null;const s=(0,o.asRecord)(c.icon);if(!s)throw new Error('app icon must be an object');const{mimeType:p,data:f}=s;if('string'!=typeof p||!t.includes(p))throw new Error('app icon mimeType is invalid');if('string'!=typeof f||!f)throw new Error('app icon data is invalid');return`data:${p};base64,${f}`}},174,[171,164]);
|
|
241
241
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_ANDROID_DEVICE_EVENTS",{enumerable:!0,get:function(){return t}}),e.createAndroidEventCursor=function(){return{latestId:0,clearedThroughId:0,hasSnapshot:!1,clearPending:!1}},e.clearAndroidEventCursor=function(t){return t.hasSnapshot?Object.assign({},t,{clearedThroughId:Math.max(t.clearedThroughId,t.latestId),clearPending:!1}):Object.assign({},t,{clearPending:!0})},e.mergeAndroidEventSnapshotCursor=function(t,n){const s=n.reduce((t,n)=>Number.isSafeInteger(n.id)&&n.id>0?Math.max(t,n.id):t,0);let o=t.hasSnapshot&&(t.latestId>0&&0===s||s>0&&s<t.latestId)?0:t.clearedThroughId;t.clearPending&&(o=Math.max(o,s));return{latestId:s,clearedThroughId:o,hasSnapshot:!0,clearPending:!1}},e.mapAndroidSessionEvent=p,e.mapAndroidSessionEvents=y,e.reconcileAndroidSessionEvents=function(t,n,s){const o=y(n,s);return t.length===o.length&&t.every((t,n)=>{const s=o[n];return void 0!==s&&t.id===s.id&&t.timestamp===s.timestamp&&t.source===s.source&&t.kind===s.kind&&t.action===s.action&&t.status===s.status&&t.message===s.message&&JSON.stringify(t.details)===JSON.stringify(s.details)})?t:o};const t=500;function n(t,n){return`android:${encodeURIComponent(t)}:${n}`}function s(t){return'number'==typeof t&&Number.isFinite(t)?`${Math.round(100*t)}%`:'?'}function o(t,n){return`${s(t)}, ${s(n)}`}function c(t){return'number'==typeof t&&Number.isFinite(t)?t:null}function u(t){return'string'==typeof t?Array.from(t).length:0}function l(t){return t?'text'!==t.type?Object.assign({},t):{type:'text',textLength:u(t.text),redacted:!0}:{}}function h(t,s){const h=t.gesture,p='string'==typeof h?.type?h.type:'unknown',y={id:n(s,t.id),timestamp:t.at,source:t.source,details:{delayMs:t.delayMs,gesture:l(h)}};switch(p){case'touch':{const t='string'==typeof h?.action?h.action:'unknown';return Object.assign({},y,{kind:'touch',action:t,message:`Touch ${t} at ${o(h?.x,h?.y)}`})}case'tap':return Object.assign({},y,{kind:'touch',action:'tap',message:`Tap at ${o(h?.x,h?.y)}`});case'swipe':{const t=c(h?.durationMs);return Object.assign({},y,{kind:'touch',action:'swipe',message:`Swipe ${o(h?.x1,h?.y1)} \u2192 ${o(h?.x2,h?.y2)}${null===t?'':` (${Math.round(t)} ms)`}`})}case'key':{const t=c(h?.keycode);return Object.assign({},y,{kind:'keyboard',action:'key',message:null===t?'Key input':`Keycode ${t}`})}case'text':{const t=u(h?.text);return Object.assign({},y,{kind:'keyboard',action:'text',message:`Text input (${t} ${1===t?'character':'characters'}, redacted)`})}case'back':case'home':case'recents':case'power':return Object.assign({},y,{kind:'button',action:p,message:`Button ${f=p,f.length>0?`${f[0].toUpperCase()}${f.slice(1)}`:f}`});default:return Object.assign({},y,{kind:'gesture',action:p,message:`Gesture ${p}`})}var f}function p(t,s){if('gesture'===t.kind)return h(t,s);if('location'===t.kind){const o=c(t.location?.latitude),u=c(t.location?.longitude),l=null===o||null===u?'unknown coordinates':`${o.toFixed(5)}, ${u.toFixed(5)}`;return{id:n(s,t.id),timestamp:t.at,source:t.source,kind:'location',action:'set',message:`Location ${l}`,details:{delayMs:t.delayMs,location:Object.assign({},t.location)}}}return{id:n(s,t.id),timestamp:t.at,source:t.source,kind:t.kind||'event',message:`Event ${t.kind||'unknown'}`,details:{delayMs:t.delayMs}}}function y(t,n){return t.slice(-500).map(t=>p(t,n))}},175,[]);
|
|
242
242
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.androidScaleForSizeStep=t,e.androidSizeStepForScale=o,Object.defineProperty(e,"androidFontScaleForTextSize",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"androidTextSizeForFontScale",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"ANDROID_DEVICE_SETTING_KEYS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ANDROID_POLLED_DEVICE_SETTING_KEYS",{enumerable:!0,get:function(){return h}}),e.createAndroidDeviceSettingVersions=function(){return Object.fromEntries(b.map(n=>[n,0]))},e.androidDeviceSettingPathFor=function(n){return f[n].path},e.androidDeviceSettingRequest=function(n,t){if(!y(n))return null;const o=f[n],l=o.encode(t);return null===l?null:{path:o.path,body:l}},e.parseAndroidDeviceSetting=function(n,t){const o=u(t);return o&&!0===o.ok?f[n].decode(o):null},e.androidDisplayWidthDpFromPayload=function(n){const t=u(n);if(!t||!0!==t.ok)return null;const o=u(t.displayDensity)?.widthDp;return'number'==typeof o&&Number.isFinite(o)&&o>0?o:null};const n=[{value:'small',scale:.85},{value:'medium',scale:1},{value:'large',scale:1.15},{value:'extra-large',scale:1.3}];function t(t){return n.find(n=>n.value===t)?.scale??null}function o(t){const o=Number(t);return!Number.isFinite(o)||o<=0?null:n.reduce((n,t)=>Math.abs(t.scale-o)<Math.abs(n.scale-o)?t:n).value}const l=t,c=o;function u(n){return!n||'object'!=typeof n||Array.isArray(n)?null:n}function s(n){return'on'===n||'off'===n?{enabled:'on'===n}:null}function p(n){const t=u(n)?.enabled;return!0===t?'on':!1===t?'off':null}const f={appearance:{path:'/api/uimode',polled:!1,encode:n=>'light'===n||'dark'===n?{night:'dark'===n?'yes':'no'}:null,decode:n=>'yes'===n.night?'dark':'no'===n.night||'auto'===n.night?'light':null},network:{path:'/api/network',polled:!0,encode:s,decode:n=>{const t=u(n.network);return t?!0===t.enabled?'on':!1===t.enabled?'off':null===t.enabled?'unknown':null:null}},'text-size':{path:'/api/font-scale',polled:!0,encode:n=>{const o=t(n);return null===o?null:{scale:o}},decode:n=>{const t=u(n.fontScale);return null===t?null:o(t.scale)}},'display-size':{path:'/api/display-density',polled:!0,encode:n=>{const o=t(n);return null===o?null:{scale:o}},decode:n=>{const t=u(n.displayDensity);return null===t?null:o(t.scale)}},'reduce-motion':{path:'/api/reduce-motion',polled:!0,encode:s,decode:n=>p(n.reduceMotion)},'bold-text':{path:'/api/font-weight',polled:!0,encode:s,decode:n=>p(n.fontWeight)},'increase-contrast':{path:'/api/high-text-contrast',polled:!0,encode:s,decode:n=>p(n.highTextContrast)},'onscreen-keyboard':{path:'/api/software-keyboard',polled:!0,encode:s,decode:n=>p(n.softwareKeyboard)}},b=Object.keys(f),h=b.filter(n=>f[n].polled);function y(n){return Object.hasOwn(f,n)}},176,[]);
|
|
243
243
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.androidStreamSettingsPatch=function(t){const o={};for(const s of['maxDimension','h264Fps','h264Bitrate']){const[u,S]=n.DEVICE_STREAM_SETTING_BOUNDS[s],c=t[s];if(void 0!==c){if('number'!=typeof c||!Number.isInteger(c)||c<u||c>S)return null;o[s]=c}}return Object.keys(o).length>0?o:null},e.parseAndroidStreamSettings=function(t,o=n.DEFAULT_DEVICE_STREAM_SETTINGS){if(!t||'object'!=typeof t||Array.isArray(t))return null;const s=t.maxDimension,[u,S]=n.DEVICE_STREAM_SETTING_BOUNDS.maxDimension;if('number'!=typeof s||!Number.isInteger(s)||s<u||s>S)return null;return(0,n.normalizeDeviceStreamSettings)(t,o)};var n=r(d[0])},177,[178]);
|
|
@@ -265,13 +265,13 @@ __d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{v
|
|
|
265
265
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WebRtcSignalingBusyError",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"WebRtcSignalingTimeoutError",{enumerable:!0,get:function(){return n}}),e.closeWebRtcSession=async function({url:t,beaconUrl:n=t,sessionId:o,keepalive:s=!1,sendBeacon:c,fetchImpl:u=fetch}){const l=JSON.stringify({sessionId:o}),b=c??('undefined'!=typeof navigator&&'function'==typeof navigator.sendBeacon?navigator.sendBeacon.bind(navigator):void 0);if(s&&b)try{if(b(n,new Blob([l],{type:'text/plain;charset=UTF-8'})))return}catch{}await u(t,{method:'POST',headers:{'Content-Type':'application/json'},body:l,keepalive:s}).then(()=>{},()=>{})},e.postWebRtcOffer=async function({url:c,body:u,signal:l,requestTimeoutMs:b,busyRetryIntervalMs:f,busyRetryCount:y,fetchImpl:p=fetch}){for(let h=0;h<=y;h++){if(l?.aborted)throw o(l);const w=new AbortController;let v=!1;const T=()=>w.abort(l?o(l):void 0);l?.addEventListener('abort',T,{once:!0});const E=setTimeout(()=>{v=!0,w.abort()},b);let R;try{R=await p(c,{method:'POST',headers:{'Content-Type':'application/json'},signal:w.signal,body:u})}catch(t){if(v&&!l?.aborted)throw new n;throw t}finally{clearTimeout(E),l?.removeEventListener('abort',T)}if(409!==R.status)return R;if(await(R.body?.cancel()),h===y)throw new t;await s(f,l)}throw new t};class t extends Error{constructor(){super('WebRTC signaling stayed busy for too long. Reload to try again.'),this.name='WebRtcSignalingBusyError'}}class n extends Error{constructor(){super('WebRTC signaling timed out.'),this.name='WebRtcSignalingTimeoutError'}}function o(t){return t.reason??new DOMException('The operation was aborted','AbortError')}function s(t,n){return n?.aborted?Promise.reject(o(n)):new Promise((s,c)=>{const u=setTimeout(function(){n?.removeEventListener('abort',l),s()},t);function l(){clearTimeout(u),c(n?o(n):new DOMException('The operation was aborted','AbortError'))}n?.addEventListener('abort',l,{once:!0})})}},199,[]);
|
|
266
266
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.readWebRtcClientCounters=f,e.describeWebRtcClientCounters=M,e.readWebRtcServerStats=C,e.describeWebRtcPublisherCounters=D,e.appendStreamStatsSample=S,e.useWebRtcStreamStats=function(n,o,c,p,b=fetch){const[y,F]=(0,t.useState)(null),B=(0,t.useRef)(null),R=(0,t.useRef)(0);return(0,t.useEffect)(()=>{if(B.current=null,R.current=0,!p||null===n||!o)return void F(null);F({samples:[],encoder:null,capture:null,stale:!1,serverStale:!1});const t=Date.now();let y=!1,v=!1,h=!1,w={serverFps:null,encoder:null,capture:null,publisherCounters:null},C=null,k=0,T=null;const L=async()=>{if(h||y)return;h=!0,T=new AbortController;const t=T,s=window.setTimeout(()=>t.abort(),u);try{const s=await j(o,n.sessionId,t.signal,b);if(y)return;const l=s.publisherCounters?D(C,s.publisherCounters):{publisherFps:null,payloadBitrateBps:null};s.publisherCounters&&(C=s.publisherCounters);const u=s.encoder?Object.assign({},s.encoder,l):null;w=Object.assign({},s,{encoder:u}),k=Date.now(),F(t=>t?Object.assign({},t,{encoder:u,capture:s.capture,serverStale:!1}):t)}catch{}finally{window.clearTimeout(s),T===t&&(T=null),h=!1}},P=async()=>{if(v||y)return;v=!0;const t=Date.now(),s=c.current;try{const l=await n.peerConnection.getStats();if(y)return;const u=f(l,t,s);if(null===u)return;const o=M(B.current,u);B.current=u,R.current=t;const c=Object.assign({atMs:t,serverFps:w.serverFps},o);F(t=>{const n=t??{samples:[],encoder:null,capture:null,stale:!1,serverStale:!1};return Object.assign({},n,{samples:S(n.samples,c),stale:!1})})}catch{}finally{v=!1}};L(),P();const I=window.setInterval(()=>{L(),P()},s),E=window.setInterval(()=>{const n=Date.now(),s=n-(R.current||t)>l,u=n-(k||t)>l;F(t=>null===t||t.stale===s&&t.serverStale===u?t:Object.assign({},t,{stale:s,serverStale:u}))},s);return()=>{y=!0,T?.abort(),window.clearInterval(I),window.clearInterval(E)}},[n,p,c,o,b]),y};var t=r(d[0]);const n=250,s=1e3,l=4e3,u=3e3;function o(t){return'number'==typeof t&&Number.isFinite(t)&&t>=0?t:null}function c(t){return'string'==typeof t&&t.length>0?t:null}function p(t){return'object'==typeof t&&null!==t&&!Array.isArray(t)}function f(t,n,s){const l=new Map,u=new Map;let p=null,f=null,b=null,y=null,F=null,B=-1;for(const n of t.values()){const t=n;switch(t.type){case'inbound-rtp':{if('video'!==t.kind&&'video'!==t.mediaType)break;const n=o(t.framesDecoded)??0;if(n<B)break;B=n,F=t;break}case'transport':'string'==typeof t.selectedCandidatePairId&&(p=t.selectedCandidatePairId);break;case'candidate-pair':'string'==typeof t.id&&l.set(t.id,t),!0===t.selected?f=t:!0===t.nominated&&'succeeded'===t.state?b??=t:'succeeded'===t.state&&(y??=t);break;case'local-candidate':case'remote-candidate':'string'==typeof t.id&&u.set(t.id,t)}}if(null===F)return null;let M=f??b??y;null!==p&&(M=l.get(p)??M);const R=null===M?null:o(M.currentRoundTripTime);let v='unknown';if(null!==M){const t=[M.localCandidateId,M.remoteCandidateId].map(t=>'string'==typeof t?c(u.get(t)?.candidateType):null);t.every(t=>null!==t)&&(v=t.includes('relay')?'relay':'direct')}const h=o(F.totalFreezesDuration),w=o(F.jitter);return{atMs:n,presentedFrames:s,bytesReceived:o(F.bytesReceived),framesDropped:o(F.framesDropped),freezeCount:o(F.freezeCount),freezeDurationMs:null===h?null:1e3*h,packetsReceived:o(F.packetsReceived),packetsLost:o(F.packetsLost),jitterMs:null===w?null:1e3*w,jitterBufferDelaySeconds:o(F.jitterBufferDelay),jitterBufferEmittedCount:o(F.jitterBufferEmittedCount),roundTripMs:null===R?null:1e3*R,icePath:v}}function b(t){return{clientFps:null,clientBitrateBps:null,clientPacketLossRatio:null,clientJitterMs:t.jitterMs,clientJitterBufferMs:null,clientDroppedFrames:null,clientFreezeCount:null,clientFreezeDurationMs:null,clientRoundTripMs:t.roundTripMs,clientIcePath:t.icePath}}function y(t,n){if(null===t.packetsReceived||null===n.packetsReceived||null===t.packetsLost||null===n.packetsLost)return null;const s=n.packetsLost-t.packetsLost,l=n.packetsReceived-t.packetsReceived;if(s<0||l<0)return null;const u=l+s;return u>0?s/u:null}function F(t,n){if(null===t.jitterBufferDelaySeconds||null===n.jitterBufferDelaySeconds||null===t.jitterBufferEmittedCount||null===n.jitterBufferEmittedCount)return null;const s=n.jitterBufferDelaySeconds-t.jitterBufferDelaySeconds,l=n.jitterBufferEmittedCount-t.jitterBufferEmittedCount;return s<0||l<=0?null:s/l*1e3}function B(t,n){if(null===t||null===n)return null;const s=n-t;return s<0?null:s}function M(t,s){const l=b(s);if(null===t)return l;const u=s.atMs-t.atMs;if(u<n)return l;const o=B(t.presentedFrames,s.presentedFrames),c=B(t.bytesReceived,s.bytesReceived),p=B(t.framesDropped,s.framesDropped),f=B(t.freezeCount,s.freezeCount),M=B(t.freezeDurationMs,s.freezeDurationMs),R=u/1e3;return{clientFps:null===o?null:o/R,clientBitrateBps:null===c?null:8*c/R,clientPacketLossRatio:y(t,s),clientJitterMs:s.jitterMs,clientJitterBufferMs:F(t,s),clientDroppedFrames:p,clientFreezeCount:f,clientFreezeDurationMs:M,clientRoundTripMs:s.roundTripMs,clientIcePath:s.icePath}}function R(t){if(!p(t))return null;const n=o(t.targetBitrateBps),s=o(t.targetKbps);return{codec:c(t.codec),encodeFps:o(t.encodeFps)??o(t.reportedFps),targetBitrateBps:n??(null===s?null:1e3*s),encodeMsPerFrame:o(t.encodeMsPerFrame),framesEncoded:o(t.framesEncoded),framesSent:o(t.framesSent),framesDropped:o(t.framesDropped)??o(t.sourceFramesDropped),packetLossRatio:o(t.packetLossRatio)??o(t.lossRatio),qualityLimitationReason:c(t.qualityLimitationReason),publisherFps:o(t.publisherFps),publisherSubmittedFrames:o(t.publisherSubmittedFrames)??o(t.submittedFrames),publisherDroppedFrames:o(t.publisherDroppedFrames),payloadBitrateBps:o(t.payloadBitrateBps)}}function v(t){if(!p(t))return null;const n=p(t.grpc)?t.grpc:null,s=t=>{const s=null!==n&&p(n[t])?n[t]:null;return{p50:o(s?.p50),p95:o(s?.p95)}};return{screenFrames:o(t.screenFrames),idleFrames:o(t.idleFrames),offeredFrames:o(t.offeredFrames),forwardedFrames:o(t.forwardedFrames),pumpRestarts:o(t.pumpRestarts),grpc:null===n?null:{imageMode:'png'===n.imageMode||'mmap'===n.imageMode||'rgb888'===n.imageMode?n.imageMode:null,producerFps:o(n.sourceTimestampFps),receiveFps:o(n.rawMessageReceiveFps),usableImageFps:o(n.usableImageFps),encoderInputFps:o(n.freshEncoderWriteFps),messagesReceived:o(n.rawGrpcMessagesReceived),messagesEmitted:o(n.rawGrpcMessagesEmitted),messagesCoalesced:o(n.rawGrpcMessagesCoalesced),sequenceGaps:o(n.sequenceGaps),imagePayloadBytes:o(n.imagePayloadBytes),transportBytes:o(n.transportBytes),messageBytesReceived:o(n.grpcMessageBytesReceived),mmapFileBytesRead:o(n.mmapFileBytesRead),mmapReadRetries:o(n.mmapReadRetries),mmapTornFramesDropped:o(n.mmapTornFramesDropped),productionToReceiveLatencyMs:s('productionToReceiveLatencyMs'),productionToUsableLatencyMs:s('productionToUsableLatencyMs'),protobufDecodeTimeMs:s('protobufDecodeTimeMs'),mmapReadCopyTimeMs:s('sharedReadCopyTimeMs')}}}function h(t,n){return{codec:c(t.codec),encodeFps:o(t.fps),targetBitrateBps:o(t.configuredBitrateBps),encodeMsPerFrame:null,framesEncoded:o(t.frames),framesSent:null,framesDropped:null,packetLossRatio:null,qualityLimitationReason:null,publisherFps:null,publisherSubmittedFrames:o(n?.submittedFrames),publisherDroppedFrames:o(n?.publisherDroppedFrames),payloadBitrateBps:null}}function w(t,n){if(null===n)return null;const s=o(t.sampledAt),l=o(n.submittedFrames),u=o(n.payloadBytesSubmitted);return null===s||null===l||null===u?null:{atMs:s,submittedFrames:l,payloadBytesSubmitted:u}}function C(t,n){if(!p(t))return{serverFps:null,encoder:null,capture:null,publisherCounters:null};const s=Array.isArray(t.sessions)?t.sessions.find(t=>p(t)&&t.sessionId===n):null,l=p(s)?s:null,u=p(t.source)?t.source:null;if(null!==u)return{serverFps:o(u.fps),encoder:h(u,l),capture:v(t.capture),publisherCounters:w(t,l)};const c=o(t.serverFps);return{serverFps:null===l?c:o(l.sourceFps)??o(l.reportedFps)??c,encoder:R(l??t.encoder),capture:v(t.capture),publisherCounters:null}}function D(t,s){if(null===t)return{publisherFps:null,payloadBitrateBps:null};const l=s.atMs-t.atMs;if(l<n)return{publisherFps:null,payloadBitrateBps:null};const u=s.submittedFrames-t.submittedFrames,o=s.payloadBytesSubmitted-t.payloadBytesSubmitted,c=l/1e3;return{publisherFps:u<0?null:u/c,payloadBitrateBps:o<0?null:8*o/c}}function S(t,n){return[...t,n].slice(-60)}async function j(t,n,s,l){const u=new URL(t,window.location.href);u.searchParams.set('sessionId',n);const o=await l(u,{cache:'no-store',signal:s});if(!o.ok)throw await(o.body?.cancel()),new Error(`WebRTC server statistics unavailable (${o.status})`);return C(await o.json(),n)}},200,[38]);
|
|
267
267
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.presentedVideoFrameDelta=function(t,n){if(!Number.isSafeInteger(n)||n<0)return 1;if(null===t||!Number.isSafeInteger(t)||n<=t)return 1;return n-t}},201,[]);
|
|
268
|
-
__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WS_TAG_SCREEN_CONFIG",{enumerable:!0,get:function(){return K}}),e.toQueryStyleHelperWsUrl=ne,e.useIosDeviceClient=function(ae){const{baseUrl:ce,enabled:ie=!0,device:oe=null,streamMode:le,token:ue=null}=ae,de=ie&&!!ce,pe=(0,t.useMemo)(()=>(0,E.sessionTokenFetch)(ue),[ue]),me=(0,t.useMemo)(()=>(0,E.sessionTokenProtocols)('ios',ue),[ue]),[fe,ge]=(0,t.useState)('idle'),[he,ve]=(0,t.useState)(null),[Se,be]=(0,t.useState)(null),[ye,we]=(0,t.useState)(0),[Ee,ke]=(0,t.useState)([]),[Ce,Re]=(0,t.useState)(!1),[Ie,Te]=(0,t.useState)(l.createIosEventLogState),xe=Ie.events,[Ue,Oe]=(0,t.useState)(!1),[Ae,Pe]=(0,t.useState)(null),[Fe,De]=(0,t.useState)(V),[Le,Me]=(0,t.useState)(null),je=de&&ce&&Le?.key===se(ce,oe,ue)?Le.config:null,[Ne,_e]=(0,t.useState)(null),[We,$e]=(0,t.useState)(null),[He,Ge]=(0,t.useState)(()=>new Set),[Be,Ke]=(0,t.useState)(null),[qe,Je]=(0,t.useState)(null),Ve=(0,t.useRef)(null),Qe=(0,t.useRef)([]),ze=(0,t.useRef)(0),Xe=(0,t.useRef)(null),Ye=(0,t.useRef)(null),Ze=(0,t.useRef)(null),et=(0,t.useRef)(null),[tt,rt]=(0,t.useReducer)(r.avccFallbackReducer,r.initialAvccFallback),[nt,st]=(0,t.useState)('h264'),[at,ct]=(0,t.useState)('h264'),[it,ot]=(0,t.useState)(!1),lt=(0,t.useRef)(new b.KeyedWriteTracker),ut=(0,t.useRef)(je);(0,t.useLayoutEffect)(()=>{ut.current=je},[je]);const dt=(0,t.useRef)(0),pt='webrtc'===le&&!it,mt=('h264'===le||it)&&(0,a.isAvccSupported)()&&!tt.fellBack;(0,t.useEffect)(()=>{'webrtc'!==le&&(ot(!1),ct(nt))},[le,nt]);const ft=(0,t.useRef)(!1),gt=(0,t.useRef)(null);(0,t.useEffect)(()=>{gt.current=Se},[Se]);const ht=(0,t.useRef)(!1),vt=(0,t.useCallback)(()=>{const t=Xe.current,r=et.current;t&&r&&(t.src=`${r}${r.includes('?')?'&':'?'}t=${Date.now()}`)},[]),St=(0,t.useCallback)(t=>{pt?(Ze.current=t??null,Ye.current=null,Xe.current=null):mt?(Ye.current=t??null,Ze.current=null,Xe.current=null):(Xe.current=t??null,Ye.current=null,Ze.current=null,t&&vt())},[vt,mt,pt]),bt=(0,t.useCallback)((t,r)=>{Qe.current=(0,F.sendOrQueueWsMessage)(Ve.current,Qe.current,t,r)},[]),yt=(0,t.useCallback)(t=>{const r=(0,c.streamGeometry)(gt.current).inputOrientation;let n;'begin'===t.phase?(ft.current=void 0!==(0,c.homeIndicatorEdge)(t),ft.current&&(n=c.HID_EDGE_BOTTOM)):ft.current&&(n=c.HID_EDGE_BOTTOM,'end'===t.phase&&(ft.current=!1));const s=(0,c.rawPointForDisplayPoint)(r,t.x,t.y),a=void 0===n?void 0:(0,c.rawEdgeForDisplayEdge)(r,n),o=void 0===a?Object.assign({type:t.phase},s):Object.assign({type:t.phase},s,{edge:a});bt(j,o)},[bt]),wt=(0,t.useCallback)(t=>{const r=(0,c.streamGeometry)(gt.current).inputOrientation,n=(0,c.rawPointForDisplayPoint)(r,t.a.x,t.a.y),s=(0,c.rawPointForDisplayPoint)(r,t.b.x,t.b.y);bt(_,{type:t.phase,x1:n.x,y1:n.y,x2:s.x,y2:s.y})},[bt]),Et=(0,t.useCallback)(t=>{if(!Number.isFinite(t.dx)||!Number.isFinite(t.dy))return;if(0===t.dx&&0===t.dy)return;const r=(0,c.streamGeometry)(gt.current).inputOrientation,n=(0,c.rawDeltaForDisplayDelta)(r,t.dx,t.dy),s=(0,c.rawPointForDisplayPoint)(r,t.x,t.y);bt(H,{dx:n.dx,dy:n.dy,x:s.x,y:s.y})},[bt]),kt=(0,t.useCallback)(t=>{const r=(0,h.hidUsageForCode)(t.code);return null!==r&&(bt(W,{type:t.phase,usage:r}),!0)},[bt]),Ct=(0,t.useMemo)(()=>(0,y.createPacedKeySender)(t=>bt(W,{type:t.type,usage:t.usage})),[bt]);(0,t.useEffect)(()=>()=>Ct.dispose(),[Ct]);const Rt=(0,t.useCallback)(t=>Ct.enqueue(t),[Ct]),It=(0,t.useCallback)(t=>{const r=je;if(!(r&&r.execWsUrl&&r.execToken&&r.device))return;const n=Be;Ke(t),(0,u.hostUiRequest)(r.execWsUrl,r.execToken,{device:r.device,option:J,value:t?'on':'off'},me).catch(()=>Ke(n))},[je,Be,me]),Tt=(0,t.useCallback)(()=>{bt(G,{})},[bt]),xt=(0,t.useCallback)(t=>{const r=Y[t];r&&bt(N,{button:r})},[bt]),Ut=(0,t.useCallback)(async()=>{const t=(t,r)=>bt(W,{type:t,usage:r});t('down',q),await new Promise(t=>setTimeout(t,30)),t('up',q)},[bt]),Ot=(0,t.useCallback)(()=>{const t=gt.current?.orientation??'portrait',r=X[(X.indexOf(t)+1)%X.length];bt($,{orientation:r})},[bt]),At=(0,t.useCallback)(async()=>{if(!ce)return null;const t=je?.device??oe;return(0,f.fetchScreenshot)(ce,t,pe)},[ce,oe,je,pe]),Pt=(0,t.useCallback)((t,r)=>{const n=je;if(!n?.execWsUrl||!n.execToken||!n.device)return;const{device:s,execToken:a,execWsUrl:c}=n,o=lt.current,l=o.start(t);l&&(Ge(o.pending),$e(n=>Object.assign({},n??{},{[t]:r})),'appearance'!==t||'light'!==r&&'dark'!==r||_e(r),(0,u.hostUiRequest)(c,a,{device:s,option:t,value:r},me).catch(async()=>{if(o.isCurrent(l)&&ut.current===n)try{const r=await(0,u.hostUiRequest)(c,a,{device:s},me);if(!o.isCurrent(l)||ut.current!==n)return;const d={};for(const[t,n]of Object.entries(r.status??{}))'string'==typeof n&&(d[t]=n);if($e(r=>(0,S.mergeAuthoritativeDeviceSetting)(r,t,d)),'appearance'===t){const t=d.appearance;'light'!==t&&'dark'!==t||_e(t)}}catch{}}).finally(()=>{o.finish(l)&&Ge(o.pending)}))},[je,me]),Ft=(0,t.useCallback)(t=>Pt('appearance',t),[Pt]),Dt=(0,t.useCallback)(t=>{st(t),ct(t),ot(!1)},[]),Lt=(0,t.useCallback)(()=>Re(!0),[]),Mt=(0,t.useCallback)(()=>Re(!1),[]),jt=(0,t.useCallback)(()=>ke([]),[]),Nt=(0,t.useCallback)(()=>Oe(!0),[]),_t=(0,t.useCallback)(()=>Oe(!1),[]),Wt=(0,t.useCallback)(()=>{const t=je?.device;t&&Te(r=>(0,l.clearIosEventLogState)(r,t))},[je?.device]);(0,t.useEffect)(()=>{if(!de||!ce)return Me(null),void ge('idle');let t=!1,r=null;ge('connecting'),ve(null);const n=`${ce.replace(/\/$/,'')}/api${oe?`?device=${encodeURIComponent(oe)}`:''}`,s=t=>{const r=new URL(ce,window.location.href),n=(0,w.proxyPreviewConfigForBrowser)(t,r),s='/'===n.basePath?'':n.basePath??'',a=t=>t?n.proxyHelpers?(0,w.middlewareEndpointForBrowser)(t,r,s):new URL(t,r).toString():null,c=a(n.appStateEndpoint);return Object.assign({url:n.url,streamUrl:(0,E.withSessionTokenQuery)(n.streamUrl??`${n.url}/stream.mjpeg`,ue),wsUrl:ne(n.wsUrl??`${re(n.url)}/ws`),device:n.device??null,execWsUrl:re(a(`${s}/exec-ws`)),execToken:n.execToken??null,logsPath:n.logsEndpoint??null,appStateUrl:c&&(0,E.withSessionTokenQuery)(c,ue),eventsPath:n.eventLogEventsEndpoint??null,metricsPath:n.metricsEndpoint??null,axUrl:a(n.axEndpoint),streamSettingsUrl:n.streamSettingsEndpoint?n.proxyHelpers?`${n.url}/stream-settings`:a(n.streamSettingsEndpoint):null,initialStreamSettings:n.streamSettings,gridApiUrl:a(n.gridApiEndpoint??`${s}/grid/api`),webRtcCodec:'webrtc'===n.streamSettings?.transport?n.streamSettings.codec:'h264'},'webrtc'===n.streamSettings?.transport&&n.streamSettings.iceServers?{webRtcIceServers:n.streamSettings.iceServers}:{})};let a=!1;const c=async()=>{if(!t)try{const l=await pe(n,{signal:AbortSignal.timeout(3e3)});if(!l.ok)return void(t||(r=setTimeout(c,D)));const u=await l.json();if(u&&u.url&&u.device){if(!t){const t=s(u);Dt(t.webRtcCodec),Me({key:se(ce,oe,ue),config:t})}return}oe&&!a&&(a=!0,(0,o.startIosHelper)(oe,ce,pe).catch(()=>{})),t||(r=setTimeout(c,D))}catch{t||(r=setTimeout(c,D))}};return c(),()=>{t=!0,r&&clearTimeout(r)}},[de,ce,oe,Dt,pe,ue]);const $t=(0,t.useRef)({frames:0,startedAt:0}),Ht=(0,t.useCallback)((t=1)=>{const r=performance.now(),n=$t.current;if(0===n.startedAt&&(n.startedAt=r),n.frames+=t,r-n.startedAt<1e3)return;const s=Math.round(1e3*n.frames/(r-n.startedAt));n.frames=0,n.startedAt=r,we(t=>t===s?t:s)},[]),{stream:Gt,failure:Bt,error:Kt,markFrameDecoded:qt,streamStats:Jt,setStreamStatsEnabled:Vt}=(0,O.useWebRtcStream)({offerUrl:je?`${je.url}/webrtc/offer`:'',closeUrl:je?`${je.url}/webrtc/close`:'',closeBeaconUrl:je?(0,E.withSessionTokenQuery)(`${je.url}/webrtc/close`,ue):'',statsUrl:je?`${je.url}/webrtc/stats`:'',enabled:de&&pt&&!!je,codec:at,iceServers:je?.webRtcIceServers,fetchImpl:pe}),Qt=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(!pt||!Bt)return;if(Qt.current===Bt.sessionId)return;Qt.current=Bt.sessionId;const t=(0,P.webRtcFallbackDecision)(nt,at,Bt);t&&('switch-to-http'===t.type?ot(!0):ct(t.codec))},[pt,Bt,nt,at]),(0,t.useEffect)(()=>{pt&&(Kt?(ge('error'),ve(Kt)):Gt||(ge('connecting'),ve(null)))},[pt,Kt,Gt]),(0,t.useEffect)(()=>{if(!pt)return;const t=Ze.current;if(!t)return;let r=!1,n=!0,s=0,a=null;const c=(s=1)=>{if(r)return;const{videoWidth:a,videoHeight:c}=t;a>0&&c>0&&!ht.current&&be(t=>t&&void 0===t.orientation&&t.width===a&&t.height===c?t:{width:a,height:c}),Ht(s),qt(s),n&&(n=!1,ge('streaming'),ve(null))},o=(r,n)=>{const l=(0,A.presentedVideoFrameDelta)(a,n.presentedFrames);Number.isSafeInteger(n.presentedFrames)&&n.presentedFrames>=0&&(a=n.presentedFrames),c(l),s=t.requestVideoFrameCallback(o)},l=()=>c(),u=()=>c(0);if(t.srcObject=Gt,Gt){'function'==typeof t.requestVideoFrameCallback?s=t.requestVideoFrameCallback(o):t.addEventListener('timeupdate',l),t.addEventListener('loadeddata',u,{once:!0}),t.play().catch(()=>{})}return()=>{r=!0,t.removeEventListener('loadeddata',u),t.removeEventListener('timeupdate',l),s&&'function'==typeof t.cancelVideoFrameCallback&&t.cancelVideoFrameCallback(s),t.srcObject=null}},[pt,Gt,qt,Ht]),(0,t.useEffect)(()=>{rt('reset'),ot(!1),we(0)},[le,je?.url,je?.webRtcCodec]),(0,t.useEffect)(()=>{if(!mt||!je?.url)return;const t=setTimeout(()=>rt('timeout'),r.AVCC_FRAME_TIMEOUT_MS);return()=>clearTimeout(t)},[mt,je?.url]),(0,T.useAvccStream)({url:je?.url??'',enabled:de&&mt&&!!je,canvasRef:Ye,fetchImpl:pe,onFirstFrame:()=>{ge('streaming'),ve(null)},onFrame:Ht,onDecodedFrame:()=>rt('decoded-frame'),onResize:(t,r)=>{ht.current||be(n=>n&&void 0===n.orientation&&n.width===t&&n.height===r?n:{width:t,height:r})},onError:t=>{ge('error'),ve(t)},onDecoderError:()=>rt('error')});const zt=mt||pt?null:je?.streamUrl??null;(0,t.useEffect)(()=>{if(!zt)return void(et.current=null);et.current=zt,ge('connecting'),ve(null);let t=!1,r=!1,n=null;const s=Xe.current,a=()=>{if(t||r)return;const n=Xe.current;n&&0!==n.naturalWidth&&0!==n.naturalHeight&&(r=!0,ge('streaming'),ve(null),ht.current||be(t=>t&&void 0===t.orientation&&t.width===n.naturalWidth&&t.height===n.naturalHeight?t:{width:n.naturalWidth,height:n.naturalHeight}))},c=()=>{t||(r=!1,ge('error'),ve('Stream unavailable \u2014 retrying\u2026'),n=setTimeout(()=>{t||vt()},D))};s?.addEventListener('load',a),s?.addEventListener('error',c),vt();const o=setInterval(a,400);return()=>{t=!0,clearInterval(o),n&&clearTimeout(n),s?.removeEventListener('load',a),s?.removeEventListener('error',c);const r=Xe.current;r&&r.removeAttribute('src'),be(null),we(0)}},[zt,vt]);const Xt=je?.wsUrl??null;(0,t.useEffect)(()=>{if(Ke(null),!Xt)return;let t=!1,r=null;ht.current=!1;const n=()=>{if(t)return;let s;try{s=new WebSocket(Xt,me)}catch{return}s.binaryType='arraybuffer',Ve.current=s,s.onopen=()=>{Qe.current=(0,F.flushWsMessageQueue)(s,Qe.current),bt(B,{enabled:!1}),t||Ke(!1)},s.onmessage=t=>{if(!(t.data instanceof ArrayBuffer))return;const r=new Uint8Array(t.data);if(!(r.length<1||r[0]!==K))try{const t=JSON.parse(Z.decode(r.subarray(1)));t.width>0&&t.height>0&&(ht.current=!0,be(r=>r&&r.width===t.width&&r.height===t.height&&r.orientation===t.orientation?r:t))}catch{}},s.onclose=()=>{t||(Ve.current=null,r=setTimeout(n,D))},s.onerror=()=>{try{s.close()}catch{}}};return n(),()=>{t=!0,r&&clearTimeout(r);try{Ve.current?.close()}catch{}Ve.current=null,Qe.current=[],Ke(null)}},[Xt,bt,me]);const Yt=je?.execWsUrl??null,Zt=je?.execToken??null,er=je?.logsPath??null,tr=je?.eventsPath??null,rr=je?.metricsPath??null,nr=je?.device??null,sr=je?.axUrl??null,ar=(0,t.useMemo)(()=>sr?t=>(0,s.loadIosAccessibility)(sr,t,pe):null,[sr,pe]),cr=(0,R.useAccessibility)(ar),ir=(0,t.useMemo)(()=>Yt&&Zt?(t,r)=>(0,u.runHostAction)(Yt,Zt,t,r,me):null,[Yt,Zt,me]),or=(0,t.useMemo)(()=>ir&&nr?{set:t=>(0,p.setIosLocation)(ir,nr,t),clear:()=>(0,p.clearIosLocation)(ir,nr)}:null,[ir,nr]),{location:lr,locationPending:ur,locationError:dr,setLocation:pr,clearLocation:mr,locationCapabilities:fr}=(0,x.useDeviceLocation)(or),gr=(0,I.useAppPermissions)({active:de,appId:null,backend:null});(0,t.useEffect)(()=>{Te((0,l.createIosEventLogState)())},[tr,nr]),(0,t.useEffect)(()=>{if(dt.current=0,!rr)return void Pe(null);Pe({hostCores:null,samples:[],errored:!1,stale:!1});const t=setInterval(()=>{const t=dt.current;t>0&&Date.now()-t>L&&Pe(t=>t&&!t.stale?Object.assign({},t,{stale:!0}):t)},1e3);return()=>clearInterval(t)},[rr]),(0,t.useEffect)(()=>{if(!Yt||!Zt)return;const t=new Map,r=new Map;if(Ce&&er&&(t.set(1,'logs'),r.set(1,er)),Ue&&tr&&nr&&(t.set(2,'events'),r.set(2,tr)),rr&&(t.set(3,'metrics'),r.set(3,rr)),0===t.size)return;let s=!1,a=null,c=null;const o=new Map,u=()=>{rr&&Pe(t=>t?Object.assign({},t,{errored:!0}):t)},d=(t,r)=>{if('logs'===t){let t=r.data;try{const n=JSON.parse(r.data);'string'==typeof n.eventMessage&&(t=n.eventMessage)}catch{}return void(t&&ke(r=>[...r,{id:"i"+ ++ze.current,source:'syslog',message:t}].slice(-200)))}if('events'===t&&nr)Te(t=>(0,l.mergeIosEventLogPayload)(t,r.data,nr));else if('metrics'===t)try{const t=JSON.parse(r.data);if('meta'===r.event){const r=(0,n.parseActivityHostCores)(t);return void Pe(t=>t?Object.assign({},t,{hostCores:r,errored:!1}):t)}const s=(0,n.parseActivitySample)(t);if(!s)return;dt.current=Date.now(),Pe(t=>(0,n.appendActivitySample)(t??{hostCores:null,samples:[],errored:!1,stale:!1},s))}catch{}},p=()=>{if(!s){o.clear();try{a=new WebSocket(Yt,me)}catch{return u(),void(c=setTimeout(p,D))}a.onopen=()=>a?.send(JSON.stringify({token:Zt})),a.onmessage=n=>{let s;try{s=JSON.parse(String(n.data))}catch{return}if(s.ready)for(const[t,n]of r)a?.send(JSON.stringify({sub:t,path:n}));else if('number'==typeof s.sub&&t.has(s.sub)){if(s.end)return u(),void a?.close();if('string'==typeof s.data){const r=s.sub,n=t.get(r);o.set(r,(0,k.drainSseChunk)(o.get(r)??'',s.data,t=>d(n,t)))}}},a.onclose=()=>{s||(u(),c=setTimeout(p,D))},a.onerror=()=>{try{a?.close()}catch{}}}};return p(),()=>{s=!0,c&&clearTimeout(c);try{a?.close()}catch{}}},[Ce,Ue,Yt,Zt,er,tr,rr,nr,me]),(0,t.useEffect)(()=>{if(lt.current.reset(),Ge(new Set),!Yt||!Zt||!nr)return _e(null),void $e(null);let t=!1;return(0,u.hostUiRequest)(Yt,Zt,{device:nr},me).then(r=>{if(t)return;const n={};for(const[t,s]of Object.entries(r.status??{}))'string'==typeof s&&(n[t]=s);$e(n),'light'!==n.appearance&&'dark'!==n.appearance||_e(n.appearance);const s=r.status?.[J];'on'!==s&&'off'!==s||Ke(t=>t??'on'===s)}).catch(()=>{}),()=>{t=!0}},[Yt,Zt,nr,me]);const hr=je?.streamSettingsUrl??null,vr=je?.initialStreamSettings,Sr=(0,t.useMemo)(()=>hr?(0,C.normalizeDeviceStreamSettings)(vr):null,[vr,hr]),{streamSettings:br,streamSettingsPending:yr,updateStreamSettings:wr}=(0,U.useStreamSettingsResource)({url:hr,initialSettings:Sr,parse:ee,toPatch:te,fetchImpl:pe}),Er=je?.appStateUrl??null;(0,t.useEffect)(()=>{if(Je(null),!Er)return;let t=null;try{t=new EventSource(Er)}catch{return}return t.onmessage=t=>{try{const r=JSON.parse(String(t.data));r.bundleId&&Je(t=>t&&t.id===r.bundleId?t.pid===r.pid&&t.isReactNative===r.isReactNative?t:Object.assign({},t,{pid:r.pid,isReactNative:r.isReactNative}):{id:r.bundleId,pid:r.pid,isReactNative:r.isReactNative})}catch{}},()=>t?.close()},[Er]);const kr=qe?.id??null;(0,t.useEffect)(()=>{if(!kr||!ir||!nr)return;let t=!1;return(0,d.getIosAppDetails)(ir,nr,kr).then(r=>{!t&&r&&Je(t=>t&&t.id===kr?Object.assign({},t,r):t)}).catch(()=>{}),()=>{t=!0}},[kr,ir,nr]);const Cr=je?.gridApiUrl??null;(0,t.useEffect)(()=>{if(!Cr)return void De(V);let t=!1;return pe(Cr,{signal:AbortSignal.timeout(3e3)}).then(t=>t.json()).then(r=>{!t&&Array.isArray(r.devices)&&0!==r.devices.length&&De(r.devices.map(t=>({id:String(t.device??t.id??'ios'),name:String(t.name??t.device??'Simulator'),system:'string'==typeof t.runtime?t.runtime:void 0,platform:'ios',current:null!=t.helper})))}).catch(()=>{}),()=>{t=!0}},[Cr,pe]);const Rr=!!Yt&&!!Zt&&!!nr,Ir=!!rr,Tr=!!tr,xr=null!==ar,Ur=!!hr,Or=(0,t.useMemo)(()=>({deviceSettings:Rr,activity:Ir,events:Tr,camera:!1,accessibility:xr,streamSettings:!!Ur&&z,location:fr,permissions:!1}),[Rr,Ir,Tr,xr,Ur,fr]);return Object.assign({platform:'ios',status:fe,error:he,screen:Se,fps:ye,devices:Fe,logs:Ee,logsEnabled:Ce,attachLogs:Lt,detachLogs:Mt,clearLogs:jt,events:xe,eventsEnabled:Ue,attachEvents:Nt,detachEvents:_t,clearEvents:Wt,activity:Ae,deviceSettings:We,deviceSettingsPending:He,setDeviceSetting:Pt,displayWidthDp:null,camera:null,cameraPending:v.NO_PENDING_CAMERA_WRITES,cameraError:null,setCameraImage:M,clearCameraImage:M},cr,{location:lr,locationPending:ur,locationError:dr,setLocation:pr,clearLocation:mr},gr,{streamCapabilities:Q,screenRecording:null,streamSettings:br,streamSettingsPending:yr,updateStreamSettings:wr,streamSource:null,streamSourcePending:!1,streamSourceError:null,setStreamSource:M,setGrpcImageMode:M,setGrpcEncoder:M,setGrpcInputSource:M,streamStats:Jt,setStreamStatsEnabled:Vt,webRtcCodec:nt,setWebRtcCodec:Dt,capabilities:Or,foregroundApp:qe,videoKind:pt?'video':mt?'canvas':'img',attachVideo:St,sendTouch:yt,sendMultiTouch:wt,sendKey:kt,sendKeyEvents:Rt,sendScroll:Et,pressButton:xt,reload:Ut,rotate:Ot,screenshot:At,appearance:Ne,setAppearance:Ft,hardwareKeyboardConnected:Be,setHardwareKeyboardConnected:It,toggleSoftwareKeyboard:Tt})};var t=_r(_d[0]),r=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),a=_r(_d[4]),c=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),u=_r(_d[8]),d=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),v=_r(_d[13]),S=_r(_d[14]),b=_r(_d[15]),y=_r(_d[16]),w=_r(_d[17]),E=_r(_d[18]),k=_r(_d[19]),C=_r(_d[20]),R=_r(_d[21]),I=_r(_d[22]),T=_r(_d[23]),x=_r(_d[24]),U=_r(_d[25]),O=_r(_d[26]),A=_r(_d[27]),P=_r(_d[28]),F=_r(_d[29]);const D=1500,L=8e3,M=()=>{},j=3,N=4,_=5,W=6,$=7,H=11,G=12,B=14,K=130,q=21,J='hardware-keyboard',V=[{id:'ios',name:'iPhone Simulator',platform:'ios',current:!0}],Q={modeAvailability:{mjpeg:!0,h264:!0,webrtc:!0},httpCodecs:['auto','h264','mjpeg'],webRtcCodecs:['h264','vp9','vp8']},z={mjpegFps:!0,mjpegQuality:!0,maxDimension:!0,h264Bitrate:!0,h264Fps:!0},X=['portrait','landscape_left','portrait_upside_down','landscape_right'],Y={home:'home',appSwitcher:'app_switcher',power:'lock',back:null,recents:null,hideKeyboard:null},Z=new TextDecoder;function ee(t,r){return(0,C.normalizeDeviceStreamSettings)(t,r)}function te(t){return Object.keys(t).length>0?t:null}function re(t){return t.replace(/^http/,'ws')}function ne(t){const r=new URL(t),n=r.pathname.match(/^(.*\/helper)\/([^/]+)\/ws$/);if(!n)throw new Error(`Invalid helper ws url, no deviceId matched: ${t}`);return r.pathname=`${n[1]}/ws`,r.searchParams.has('device')||r.searchParams.set('device',decodeURIComponent(n[2])),r.toString()}function se(t,r,n){return JSON.stringify([t,r,n])}},202,[38,203,169,167,204,154,205,206,207,208,209,196,184,165,181,183,210,211,192,168,178,189,194,212,193,195,197,201,198,213]);
|
|
268
|
+
__d(function(g,_r,i,_a,m,e,_d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"WS_TAG_SCREEN_CONFIG",{enumerable:!0,get:function(){return K}}),e.toQueryStyleHelperWsUrl=ne,e.useIosDeviceClient=function(ae){const{baseUrl:ce,enabled:ie=!0,device:oe=null,streamMode:le,token:ue=null}=ae,de=ie&&!!ce,pe=(0,t.useMemo)(()=>(0,E.sessionTokenFetch)(ue),[ue]),fe=(0,t.useMemo)(()=>(0,E.sessionTokenProtocols)('ios',ue),[ue]),[me,ge]=(0,t.useState)('idle'),[he,ve]=(0,t.useState)(null),[be,Se]=(0,t.useState)(null),[ye,we]=(0,t.useState)(0),[Ee,ke]=(0,t.useState)([]),[Ce,Re]=(0,t.useState)(!1),[Ie,Ue]=(0,t.useState)(l.createIosEventLogState),Te=Ie.events,[xe,Ae]=(0,t.useState)(!1),[Oe,Pe]=(0,t.useState)(null),[Fe,De]=(0,t.useState)(V),[Le,Me]=(0,t.useState)(null),je=de&&ce&&Le?.key===se(ce,oe,ue)?Le.config:null,[Ne,_e]=(0,t.useState)(null),[We,$e]=(0,t.useState)(null),[He,Ge]=(0,t.useState)(()=>new Set),[Be,Ke]=(0,t.useState)(null),[qe,Je]=(0,t.useState)(null),Ve=(0,t.useRef)(null),Qe=(0,t.useRef)([]),ze=(0,t.useRef)(0),Xe=(0,t.useRef)(null),Ye=(0,t.useRef)(null),Ze=(0,t.useRef)(null),et=(0,t.useRef)(null),[tt,rt]=(0,t.useReducer)(r.avccFallbackReducer,r.initialAvccFallback),[nt,st]=(0,t.useState)('h264'),[at,ct]=(0,t.useState)('h264'),[it,ot]=(0,t.useState)(!1),lt=(0,t.useRef)(new S.KeyedWriteTracker),ut=(0,t.useRef)(je);(0,t.useLayoutEffect)(()=>{ut.current=je},[je]);const dt=(0,t.useRef)(0),pt='webrtc'===le&&!it,ft=('h264'===le||it)&&(0,a.isAvccSupported)()&&!tt.fellBack;(0,t.useEffect)(()=>{'webrtc'!==le&&(ot(!1),ct(nt))},[le,nt]);const mt=(0,t.useRef)(!1),gt=(0,t.useRef)(null);(0,t.useEffect)(()=>{gt.current=be},[be]);const ht=(0,t.useRef)(!1),vt=(0,t.useCallback)(()=>{const t=Xe.current,r=et.current;t&&r&&(t.src=`${r}${r.includes('?')?'&':'?'}t=${Date.now()}`)},[]),bt=(0,t.useCallback)(t=>{pt?(Ze.current=t??null,Ye.current=null,Xe.current=null):ft?(Ye.current=t??null,Ze.current=null,Xe.current=null):(Xe.current=t??null,Ye.current=null,Ze.current=null,t&&vt())},[vt,ft,pt]),St=(0,t.useCallback)((t,r)=>{Qe.current=(0,F.sendOrQueueWsMessage)(Ve.current,Qe.current,t,r)},[]),yt=(0,t.useCallback)(t=>{const r=(0,c.streamGeometry)(gt.current).inputOrientation;let n;'begin'===t.phase?(mt.current=void 0!==(0,c.homeIndicatorEdge)(t),mt.current&&(n=c.HID_EDGE_BOTTOM)):mt.current&&(n=c.HID_EDGE_BOTTOM,'end'===t.phase&&(mt.current=!1));const s=(0,c.rawPointForDisplayPoint)(r,t.x,t.y),a=void 0===n?void 0:(0,c.rawEdgeForDisplayEdge)(r,n),o=void 0===a?Object.assign({type:t.phase},s):Object.assign({type:t.phase},s,{edge:a});St(j,o)},[St]),wt=(0,t.useCallback)(t=>{const r=(0,c.streamGeometry)(gt.current).inputOrientation,n=(0,c.rawPointForDisplayPoint)(r,t.a.x,t.a.y),s=(0,c.rawPointForDisplayPoint)(r,t.b.x,t.b.y);St(_,{type:t.phase,x1:n.x,y1:n.y,x2:s.x,y2:s.y})},[St]),Et=(0,t.useCallback)(t=>{if(!Number.isFinite(t.dx)||!Number.isFinite(t.dy))return;if(0===t.dx&&0===t.dy)return;const r=(0,c.streamGeometry)(gt.current).inputOrientation,n=(0,c.rawDeltaForDisplayDelta)(r,t.dx,t.dy),s=(0,c.rawPointForDisplayPoint)(r,t.x,t.y);St(H,{dx:n.dx,dy:n.dy,x:s.x,y:s.y})},[St]),kt=(0,t.useCallback)(t=>{const r=(0,h.hidUsageForCode)(t.code);return null!==r&&(St(W,{type:t.phase,usage:r}),!0)},[St]),Ct=(0,t.useMemo)(()=>(0,y.createPacedKeySender)(t=>St(W,{type:t.type,usage:t.usage})),[St]);(0,t.useEffect)(()=>()=>Ct.dispose(),[Ct]);const Rt=(0,t.useCallback)(t=>Ct.enqueue(t),[Ct]),It=(0,t.useCallback)(t=>{const r=je;if(!(r&&r.execWsUrl&&r.execToken&&r.device))return;const n=Be;Ke(t),(0,u.hostUiRequest)(r.execWsUrl,r.execToken,{device:r.device,option:J,value:t?'on':'off'},fe).catch(()=>Ke(n))},[je,Be,fe]),Ut=(0,t.useCallback)(()=>{St(G,{})},[St]),Tt=(0,t.useCallback)(t=>{const r=Y[t];r&&St(N,{button:r})},[St]),xt=(0,t.useCallback)(async()=>{const t=(t,r)=>St(W,{type:t,usage:r});t('down',q),await new Promise(t=>setTimeout(t,30)),t('up',q)},[St]),At=(0,t.useCallback)(()=>{const t=gt.current?.orientation??'portrait',r=X[(X.indexOf(t)+1)%X.length];St($,{orientation:r})},[St]),Ot=(0,t.useCallback)(async()=>{if(!ce)return null;const t=je?.device??oe;return(0,f.fetchScreenshot)(ce,t,pe)},[ce,oe,je,pe]),Pt=(0,t.useCallback)((t,r)=>{const n=je;if(!n?.execWsUrl||!n.execToken||!n.device)return;const{device:s,execToken:a,execWsUrl:c}=n,o=lt.current,l=o.start(t);l&&(Ge(o.pending),$e(n=>Object.assign({},n??{},{[t]:r})),'appearance'!==t||'light'!==r&&'dark'!==r||_e(r),(0,u.hostUiRequest)(c,a,{device:s,option:t,value:r},fe).catch(async()=>{if(o.isCurrent(l)&&ut.current===n)try{const r=await(0,u.hostUiRequest)(c,a,{device:s},fe);if(!o.isCurrent(l)||ut.current!==n)return;const d={};for(const[t,n]of Object.entries(r.status??{}))'string'==typeof n&&(d[t]=n);if($e(r=>(0,b.mergeAuthoritativeDeviceSetting)(r,t,d)),'appearance'===t){const t=d.appearance;'light'!==t&&'dark'!==t||_e(t)}}catch{}}).finally(()=>{o.finish(l)&&Ge(o.pending)}))},[je,fe]),Ft=(0,t.useCallback)(t=>Pt('appearance',t),[Pt]),Dt=(0,t.useCallback)(t=>{st(t),ct(t),ot(!1)},[]),Lt=(0,t.useCallback)(()=>Re(!0),[]),Mt=(0,t.useCallback)(()=>Re(!1),[]),jt=(0,t.useCallback)(()=>ke([]),[]),Nt=(0,t.useCallback)(()=>Ae(!0),[]),_t=(0,t.useCallback)(()=>Ae(!1),[]),Wt=(0,t.useCallback)(()=>{const t=je?.device;t&&Ue(r=>(0,l.clearIosEventLogState)(r,t))},[je?.device]);(0,t.useEffect)(()=>{if(!de||!ce)return Me(null),void ge('idle');let t=!1,r=null;ge('connecting'),ve(null);const n=`${ce.replace(/\/$/,'')}/api${oe?`?device=${encodeURIComponent(oe)}`:''}`,s=t=>{const r=new URL(ce,window.location.href),n=(0,w.proxyPreviewConfigForBrowser)(t,r),s='/'===n.basePath?'':n.basePath??'',a=t=>t?n.proxyHelpers?(0,w.middlewareEndpointForBrowser)(t,r,s):new URL(t,r).toString():null,c=a(n.appStateEndpoint);return Object.assign({url:n.url,streamUrl:(0,E.withSessionTokenQuery)(n.streamUrl??`${n.url}/stream.mjpeg`,ue),wsUrl:ne(n.wsUrl??`${re(n.url)}/ws`),device:n.device??null,execWsUrl:re(a(`${s}/exec-ws`)),execToken:n.execToken??null,logsPath:n.logsEndpoint??null,appStateUrl:c&&(0,E.withSessionTokenQuery)(c,ue),appIconUrl:a(n.appIconEndpoint),eventsPath:n.eventLogEventsEndpoint??null,metricsPath:n.metricsEndpoint??null,axUrl:a(n.axEndpoint),streamSettingsUrl:n.streamSettingsEndpoint?n.proxyHelpers?`${n.url}/stream-settings`:a(n.streamSettingsEndpoint):null,initialStreamSettings:n.streamSettings,gridApiUrl:a(n.gridApiEndpoint??`${s}/grid/api`),webRtcCodec:'webrtc'===n.streamSettings?.transport?n.streamSettings.codec:'h264'},'webrtc'===n.streamSettings?.transport&&n.streamSettings.iceServers?{webRtcIceServers:n.streamSettings.iceServers}:{})};let a=!1;const c=async()=>{if(!t)try{const l=await pe(n,{signal:AbortSignal.timeout(3e3)});if(!l.ok)return void(t||(r=setTimeout(c,D)));const u=await l.json();if(u&&u.url&&u.device){if(!t){const t=s(u);Dt(t.webRtcCodec),Me({key:se(ce,oe,ue),config:t})}return}oe&&!a&&(a=!0,(0,o.startIosHelper)(oe,ce,pe).catch(()=>{})),t||(r=setTimeout(c,D))}catch{t||(r=setTimeout(c,D))}};return c(),()=>{t=!0,r&&clearTimeout(r)}},[de,ce,oe,Dt,pe,ue]);const $t=(0,t.useRef)({frames:0,startedAt:0}),Ht=(0,t.useCallback)((t=1)=>{const r=performance.now(),n=$t.current;if(0===n.startedAt&&(n.startedAt=r),n.frames+=t,r-n.startedAt<1e3)return;const s=Math.round(1e3*n.frames/(r-n.startedAt));n.frames=0,n.startedAt=r,we(t=>t===s?t:s)},[]),{stream:Gt,failure:Bt,error:Kt,markFrameDecoded:qt,streamStats:Jt,setStreamStatsEnabled:Vt}=(0,A.useWebRtcStream)({offerUrl:je?`${je.url}/webrtc/offer`:'',closeUrl:je?`${je.url}/webrtc/close`:'',closeBeaconUrl:je?(0,E.withSessionTokenQuery)(`${je.url}/webrtc/close`,ue):'',statsUrl:je?`${je.url}/webrtc/stats`:'',enabled:de&&pt&&!!je,codec:at,iceServers:je?.webRtcIceServers,fetchImpl:pe}),Qt=(0,t.useRef)(null);(0,t.useEffect)(()=>{if(!pt||!Bt)return;if(Qt.current===Bt.sessionId)return;Qt.current=Bt.sessionId;const t=(0,P.webRtcFallbackDecision)(nt,at,Bt);t&&('switch-to-http'===t.type?ot(!0):ct(t.codec))},[pt,Bt,nt,at]),(0,t.useEffect)(()=>{pt&&(Kt?(ge('error'),ve(Kt)):Gt||(ge('connecting'),ve(null)))},[pt,Kt,Gt]),(0,t.useEffect)(()=>{if(!pt)return;const t=Ze.current;if(!t)return;let r=!1,n=!0,s=0,a=null;const c=(s=1)=>{if(r)return;const{videoWidth:a,videoHeight:c}=t;a>0&&c>0&&!ht.current&&Se(t=>t&&void 0===t.orientation&&t.width===a&&t.height===c?t:{width:a,height:c}),Ht(s),qt(s),n&&(n=!1,ge('streaming'),ve(null))},o=(r,n)=>{const l=(0,O.presentedVideoFrameDelta)(a,n.presentedFrames);Number.isSafeInteger(n.presentedFrames)&&n.presentedFrames>=0&&(a=n.presentedFrames),c(l),s=t.requestVideoFrameCallback(o)},l=()=>c(),u=()=>c(0);if(t.srcObject=Gt,Gt){'function'==typeof t.requestVideoFrameCallback?s=t.requestVideoFrameCallback(o):t.addEventListener('timeupdate',l),t.addEventListener('loadeddata',u,{once:!0}),t.play().catch(()=>{})}return()=>{r=!0,t.removeEventListener('loadeddata',u),t.removeEventListener('timeupdate',l),s&&'function'==typeof t.cancelVideoFrameCallback&&t.cancelVideoFrameCallback(s),t.srcObject=null}},[pt,Gt,qt,Ht]),(0,t.useEffect)(()=>{rt('reset'),ot(!1),we(0)},[le,je?.url,je?.webRtcCodec]),(0,t.useEffect)(()=>{if(!ft||!je?.url)return;const t=setTimeout(()=>rt('timeout'),r.AVCC_FRAME_TIMEOUT_MS);return()=>clearTimeout(t)},[ft,je?.url]),(0,U.useAvccStream)({url:je?.url??'',enabled:de&&ft&&!!je,canvasRef:Ye,fetchImpl:pe,onFirstFrame:()=>{ge('streaming'),ve(null)},onFrame:Ht,onDecodedFrame:()=>rt('decoded-frame'),onResize:(t,r)=>{ht.current||Se(n=>n&&void 0===n.orientation&&n.width===t&&n.height===r?n:{width:t,height:r})},onError:t=>{ge('error'),ve(t)},onDecoderError:()=>rt('error')});const zt=ft||pt?null:je?.streamUrl??null;(0,t.useEffect)(()=>{if(!zt)return void(et.current=null);et.current=zt,ge('connecting'),ve(null);let t=!1,r=!1,n=null;const s=Xe.current,a=()=>{if(t||r)return;const n=Xe.current;n&&0!==n.naturalWidth&&0!==n.naturalHeight&&(r=!0,ge('streaming'),ve(null),ht.current||Se(t=>t&&void 0===t.orientation&&t.width===n.naturalWidth&&t.height===n.naturalHeight?t:{width:n.naturalWidth,height:n.naturalHeight}))},c=()=>{t||(r=!1,ge('error'),ve('Stream unavailable \u2014 retrying\u2026'),n=setTimeout(()=>{t||vt()},D))};s?.addEventListener('load',a),s?.addEventListener('error',c),vt();const o=setInterval(a,400);return()=>{t=!0,clearInterval(o),n&&clearTimeout(n),s?.removeEventListener('load',a),s?.removeEventListener('error',c);const r=Xe.current;r&&r.removeAttribute('src'),Se(null),we(0)}},[zt,vt]);const Xt=je?.wsUrl??null;(0,t.useEffect)(()=>{if(Ke(null),!Xt)return;let t=!1,r=null;ht.current=!1;const n=()=>{if(t)return;let s;try{s=new WebSocket(Xt,fe)}catch{return}s.binaryType='arraybuffer',Ve.current=s,s.onopen=()=>{Qe.current=(0,F.flushWsMessageQueue)(s,Qe.current),St(B,{enabled:!1}),t||Ke(!1)},s.onmessage=t=>{if(!(t.data instanceof ArrayBuffer))return;const r=new Uint8Array(t.data);if(!(r.length<1||r[0]!==K))try{const t=JSON.parse(Z.decode(r.subarray(1)));t.width>0&&t.height>0&&(ht.current=!0,Se(r=>r&&r.width===t.width&&r.height===t.height&&r.orientation===t.orientation?r:t))}catch{}},s.onclose=()=>{t||(Ve.current=null,r=setTimeout(n,D))},s.onerror=()=>{try{s.close()}catch{}}};return n(),()=>{t=!0,r&&clearTimeout(r);try{Ve.current?.close()}catch{}Ve.current=null,Qe.current=[],Ke(null)}},[Xt,St,fe]);const Yt=je?.execWsUrl??null,Zt=je?.execToken??null,er=je?.logsPath??null,tr=je?.eventsPath??null,rr=je?.metricsPath??null,nr=je?.device??null,sr=je?.axUrl??null,ar=(0,t.useMemo)(()=>sr?t=>(0,s.loadIosAccessibility)(sr,t,pe):null,[sr,pe]),cr=(0,R.useAccessibility)(ar),ir=(0,t.useMemo)(()=>Yt&&Zt?(t,r)=>(0,u.runHostAction)(Yt,Zt,t,r,fe):null,[Yt,Zt,fe]),or=(0,t.useMemo)(()=>ir&&nr?{set:t=>(0,p.setIosLocation)(ir,nr,t),clear:()=>(0,p.clearIosLocation)(ir,nr)}:null,[ir,nr]),{location:lr,locationPending:ur,locationError:dr,setLocation:pr,clearLocation:fr,locationCapabilities:mr}=(0,T.useDeviceLocation)(or),gr=(0,I.useAppPermissions)({active:de,appId:null,backend:null});(0,t.useEffect)(()=>{Ue((0,l.createIosEventLogState)())},[tr,nr]),(0,t.useEffect)(()=>{if(dt.current=0,!rr)return void Pe(null);Pe({hostCores:null,samples:[],errored:!1,stale:!1});const t=setInterval(()=>{const t=dt.current;t>0&&Date.now()-t>L&&Pe(t=>t&&!t.stale?Object.assign({},t,{stale:!0}):t)},1e3);return()=>clearInterval(t)},[rr]),(0,t.useEffect)(()=>{if(!Yt||!Zt)return;const t=new Map,r=new Map;if(Ce&&er&&(t.set(1,'logs'),r.set(1,er)),xe&&tr&&nr&&(t.set(2,'events'),r.set(2,tr)),rr&&(t.set(3,'metrics'),r.set(3,rr)),0===t.size)return;let s=!1,a=null,c=null;const o=new Map,u=()=>{rr&&Pe(t=>t?Object.assign({},t,{errored:!0}):t)},d=(t,r)=>{if('logs'===t){let t=r.data;try{const n=JSON.parse(r.data);'string'==typeof n.eventMessage&&(t=n.eventMessage)}catch{}return void(t&&ke(r=>[...r,{id:"i"+ ++ze.current,source:'syslog',message:t}].slice(-200)))}if('events'===t&&nr)Ue(t=>(0,l.mergeIosEventLogPayload)(t,r.data,nr));else if('metrics'===t)try{const t=JSON.parse(r.data);if('meta'===r.event){const r=(0,n.parseActivityHostCores)(t);return void Pe(t=>t?Object.assign({},t,{hostCores:r,errored:!1}):t)}const s=(0,n.parseActivitySample)(t);if(!s)return;dt.current=Date.now(),Pe(t=>(0,n.appendActivitySample)(t??{hostCores:null,samples:[],errored:!1,stale:!1},s))}catch{}},p=()=>{if(!s){o.clear();try{a=new WebSocket(Yt,fe)}catch{return u(),void(c=setTimeout(p,D))}a.onopen=()=>a?.send(JSON.stringify({token:Zt})),a.onmessage=n=>{let s;try{s=JSON.parse(String(n.data))}catch{return}if(s.ready)for(const[t,n]of r)a?.send(JSON.stringify({sub:t,path:n}));else if('number'==typeof s.sub&&t.has(s.sub)){if(s.end)return u(),void a?.close();if('string'==typeof s.data){const r=s.sub,n=t.get(r);o.set(r,(0,k.drainSseChunk)(o.get(r)??'',s.data,t=>d(n,t)))}}},a.onclose=()=>{s||(u(),c=setTimeout(p,D))},a.onerror=()=>{try{a?.close()}catch{}}}};return p(),()=>{s=!0,c&&clearTimeout(c);try{a?.close()}catch{}}},[Ce,xe,Yt,Zt,er,tr,rr,nr,fe]),(0,t.useEffect)(()=>{if(lt.current.reset(),Ge(new Set),!Yt||!Zt||!nr)return _e(null),void $e(null);let t=!1;return(0,u.hostUiRequest)(Yt,Zt,{device:nr},fe).then(r=>{if(t)return;const n={};for(const[t,s]of Object.entries(r.status??{}))'string'==typeof s&&(n[t]=s);$e(n),'light'!==n.appearance&&'dark'!==n.appearance||_e(n.appearance);const s=r.status?.[J];'on'!==s&&'off'!==s||Ke(t=>t??'on'===s)}).catch(()=>{}),()=>{t=!0}},[Yt,Zt,nr,fe]);const hr=je?.streamSettingsUrl??null,vr=je?.initialStreamSettings,br=(0,t.useMemo)(()=>hr?(0,C.normalizeDeviceStreamSettings)(vr):null,[vr,hr]),{streamSettings:Sr,streamSettingsPending:yr,updateStreamSettings:wr}=(0,x.useStreamSettingsResource)({url:hr,initialSettings:br,parse:ee,toPatch:te,fetchImpl:pe}),Er=je?.appStateUrl??null;(0,t.useEffect)(()=>{if(Je(null),!Er)return;let t=null;try{t=new EventSource(Er)}catch{return}return t.onmessage=t=>{try{const r=JSON.parse(String(t.data));r.bundleId&&Je(t=>t&&t.id===r.bundleId?t.pid===r.pid&&t.isReactNative===r.isReactNative?t:Object.assign({},t,{pid:r.pid,isReactNative:r.isReactNative}):{id:r.bundleId,pid:r.pid,isReactNative:r.isReactNative})}catch{}},()=>t?.close()},[Er]);const kr=qe?.id??null,Cr=je?.appIconUrl??null;(0,t.useEffect)(()=>{if(!kr||!ir||!nr)return;let t=!1;return(0,d.getIosAppDetails)(ir,nr,kr,{includeIcon:!Cr}).then(r=>{!t&&r&&Je(t=>t&&t.id===kr?Object.assign({},t,r):t)}).catch(()=>{}),()=>{t=!0}},[kr,ir,nr,Cr]),(0,t.useEffect)(()=>{if(!kr||!Cr)return;const t=new AbortController;return(0,d.fetchIosAppIcon)(Cr,kr,{fetchImpl:pe,signal:t.signal}).then(r=>{!t.signal.aborted&&r&&Je(t=>t&&t.id===kr?Object.assign({},t,{iconDataUrl:r}):t)}).catch(()=>{}),()=>t.abort()},[kr,Cr,pe]);const Rr=je?.gridApiUrl??null;(0,t.useEffect)(()=>{if(!Rr)return void De(V);let t=!1;return pe(Rr,{signal:AbortSignal.timeout(3e3)}).then(t=>t.json()).then(r=>{!t&&Array.isArray(r.devices)&&0!==r.devices.length&&De(r.devices.map(t=>({id:String(t.device??t.id??'ios'),name:String(t.name??t.device??'Simulator'),system:'string'==typeof t.runtime?t.runtime:void 0,platform:'ios',current:null!=t.helper})))}).catch(()=>{}),()=>{t=!0}},[Rr,pe]);const Ir=!!Yt&&!!Zt&&!!nr,Ur=!!rr,Tr=!!tr,xr=null!==ar,Ar=!!hr,Or=(0,t.useMemo)(()=>({deviceSettings:Ir,activity:Ur,events:Tr,camera:!1,accessibility:xr,streamSettings:!!Ar&&z,location:mr,permissions:!1}),[Ir,Ur,Tr,xr,Ar,mr]);return Object.assign({platform:'ios',status:me,error:he,screen:be,fps:ye,devices:Fe,logs:Ee,logsEnabled:Ce,attachLogs:Lt,detachLogs:Mt,clearLogs:jt,events:Te,eventsEnabled:xe,attachEvents:Nt,detachEvents:_t,clearEvents:Wt,activity:Oe,deviceSettings:We,deviceSettingsPending:He,setDeviceSetting:Pt,displayWidthDp:null,camera:null,cameraPending:v.NO_PENDING_CAMERA_WRITES,cameraError:null,setCameraImage:M,clearCameraImage:M},cr,{location:lr,locationPending:ur,locationError:dr,setLocation:pr,clearLocation:fr},gr,{streamCapabilities:Q,screenRecording:null,streamSettings:Sr,streamSettingsPending:yr,updateStreamSettings:wr,streamSource:null,streamSourcePending:!1,streamSourceError:null,setStreamSource:M,setGrpcImageMode:M,setGrpcEncoder:M,setGrpcInputSource:M,streamStats:Jt,setStreamStatsEnabled:Vt,webRtcCodec:nt,setWebRtcCodec:Dt,capabilities:Or,foregroundApp:qe,videoKind:pt?'video':ft?'canvas':'img',attachVideo:bt,sendTouch:yt,sendMultiTouch:wt,sendKey:kt,sendKeyEvents:Rt,sendScroll:Et,pressButton:Tt,reload:xt,rotate:At,screenshot:Ot,appearance:Ne,setAppearance:Ft,hardwareKeyboardConnected:Be,setHardwareKeyboardConnected:It,toggleSoftwareKeyboard:Ut})};var t=_r(_d[0]),r=_r(_d[1]),n=_r(_d[2]),s=_r(_d[3]),a=_r(_d[4]),c=_r(_d[5]),o=_r(_d[6]),l=_r(_d[7]),u=_r(_d[8]),d=_r(_d[9]),p=_r(_d[10]),f=_r(_d[11]),h=_r(_d[12]),v=_r(_d[13]),b=_r(_d[14]),S=_r(_d[15]),y=_r(_d[16]),w=_r(_d[17]),E=_r(_d[18]),k=_r(_d[19]),C=_r(_d[20]),R=_r(_d[21]),I=_r(_d[22]),U=_r(_d[23]),T=_r(_d[24]),x=_r(_d[25]),A=_r(_d[26]),O=_r(_d[27]),P=_r(_d[28]),F=_r(_d[29]);const D=1500,L=8e3,M=()=>{},j=3,N=4,_=5,W=6,$=7,H=11,G=12,B=14,K=130,q=21,J='hardware-keyboard',V=[{id:'ios',name:'iPhone Simulator',platform:'ios',current:!0}],Q={modeAvailability:{mjpeg:!0,h264:!0,webrtc:!0},httpCodecs:['auto','h264','mjpeg'],webRtcCodecs:['h264','vp9','vp8']},z={mjpegFps:!0,mjpegQuality:!0,maxDimension:!0,h264Bitrate:!0,h264Fps:!0},X=['portrait','landscape_left','portrait_upside_down','landscape_right'],Y={home:'home',appSwitcher:'app_switcher',power:'lock',back:null,recents:null,hideKeyboard:null},Z=new TextDecoder;function ee(t,r){return(0,C.normalizeDeviceStreamSettings)(t,r)}function te(t){return Object.keys(t).length>0?t:null}function re(t){return t.replace(/^http/,'ws')}function ne(t){const r=new URL(t),n=r.pathname.match(/^(.*\/helper)\/([^/]+)\/ws$/);if(!n)throw new Error(`Invalid helper ws url, no deviceId matched: ${t}`);return r.pathname=`${n[1]}/ws`,r.searchParams.has('device')||r.searchParams.set('device',decodeURIComponent(n[2])),r.toString()}function se(t,r,n){return JSON.stringify([t,r,n])}},202,[38,203,169,167,204,154,205,206,207,208,209,196,184,165,181,183,210,211,192,168,178,189,194,212,193,195,197,201,198,213]);
|
|
269
269
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"initialAvccFallback",{enumerable:!0,get:function(){return t}}),e.avccFallbackReducer=function(c,n){switch(n){case'decoded-frame':return c.streamed?c:Object.assign({},c,{streamed:!0});case'timeout':return c.streamed||c.fellBack?c:Object.assign({},c,{fellBack:!0});case'error':return c.fellBack?c:Object.assign({},c,{fellBack:!0});case'reset':return t}},Object.defineProperty(e,"AVCC_FRAME_TIMEOUT_MS",{enumerable:!0,get:function(){return c}});const t={streamed:!1,fellBack:!1};const c=4e3},203,[]);
|
|
270
270
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"AVCC_TAG_DESCRIPTION",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"AVCC_TAG_KEYFRAME",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"AVCC_TAG_DELTA",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"AVCC_TAG_SEED",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"AvccDemuxer",{enumerable:!0,get:function(){return u}}),e.avcCodecString=function(t){if(t.length<4)return'avc1.42E01E';const n=t=>t.toString(16).padStart(2,'0');return`avc1.${n(t[1])}${n(t[2])}${n(t[3])}`},e.isAvccSupported=function(){return'undefined'!=typeof globalThis&&void 0!==globalThis.VideoDecoder};const t=1,n=2,s=3,h=4,f={[t]:'description',[n]:'keyframe',[s]:'delta',[h]:'seed'};class u{buffer=new Uint8Array(65536);length=0;start=0;append(t){if(this.length+t.length>this.buffer.length&&(this.start>0&&(this.buffer.copyWithin(0,this.start,this.length),this.length-=this.start,this.start=0),this.length+t.length>this.buffer.length)){let n=this.buffer.length;for(;n<this.length+t.length;)n*=2;const s=new Uint8Array(n);s.set(this.buffer.subarray(0,this.length)),this.buffer=s}this.buffer.set(t,this.length),this.length+=t.length}push(t){t.length>0&&this.append(t);const n=[],s=this.buffer;for(;this.length-this.start>=4;){const t=this.start,h=(s[t]<<24|s[t+1]<<16|s[t+2]<<8|s[t+3])>>>0;if(this.length-t-4<h)break;if(h<1){this.start+=4;continue}const u=f[s[t+4]];u&&n.push({type:u,payload:s.slice(t+5,t+4+h)}),this.start+=4+h}return this.start>0&&(this.start<this.length&&this.buffer.copyWithin(0,this.start,this.length),this.length-=this.start,this.start=0),n}reset(){this.length=0,this.start=0}}},204,[]);
|
|
271
271
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.endpointFor=function(s,c){return o(`${t(c)}${n[s]}`)},e.startIosHelper=async function(n,s,c=fetch){const u=t(o(s));await c(`${u}/grid/api/start`,{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({udid:n}),signal:AbortSignal.timeout(19e4)})};const n={ios:'/vendor/serve-sim',android:'/vendor/serve-emu'};function t(n){return n.replace(/\/+$/,'')}function o(n){return n.startsWith('http')?n:'undefined'!=typeof window&&window.location?.origin?`${window.location.origin}${n}`:n}},205,[]);
|
|
272
272
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"MAX_IOS_DEVICE_EVENTS",{enumerable:!0,get:function(){return t}}),e.parseIosEventLogPayload=p,e.mapIosEventLogEntry=T,e.createIosEventLogState=function(t=0){const n=Math.max(0,Math.floor(t));return{events:[],clearedThroughId:n,latestId:n,hasSnapshot:!1,clearPending:!1}},e.mergeIosEventLogPayload=function(t,n,s){const o=p(n);if(!o)return t;const c=void 0!==o.events,u=(o.events??[]).reduce((t,n)=>Math.max(t,n.id),0),l=c&&t.hasSnapshot&&(t.latestId>0&&0===u||u>0&&u<t.latestId);let f=l?0:t.clearedThroughId;if(c&&t.clearPending)for(const t of o.events??[])f=Math.max(f,t.id);const h=new Map;if(!l)for(const n of t.events){const t=v(n,s);null!==t&&t>f&&h.set(t,n)}const y=[...o.events??[],...o.event?[o.event]:[]];for(const t of y)t.id<=f||h.set(t.id,T(t,s));return{events:[...h.entries()].sort(([t],[n])=>t-n).slice(-500).map(([,t])=>t),clearedThroughId:f,latestId:c?Math.max(u,o.event?.id??0):Math.max(t.latestId,o.event?.id??0),hasSnapshot:t.hasSnapshot||c,clearPending:!c&&t.clearPending}},e.clearIosEventLogState=function(t,n){let s=t.clearedThroughId;for(const o of t.events){const t=v(o,n);null!==t&&(s=Math.max(s,t))}return{events:[],clearedThroughId:s,latestId:t.latestId,hasSnapshot:t.hasSnapshot,clearPending:!t.hasSnapshot}};const t=500,n=/^(?:command|credential|password|path|secret|stderr|stdout|text|token)$/i,s=/^[a-z0-9][a-z0-9._:/-]*$/i,o=128,c=5;function u(t){return null!==t&&'object'==typeof t&&!Array.isArray(t)}function l(t,n){return Object.prototype.hasOwnProperty.call(t,n)}function f(t){return'string'==typeof t&&t.length>0&&t.length<=o&&s.test(t)?t:null}function h(t){if(!u(t))return null;if(!Number.isSafeInteger(t.id)||t.id<0)return null;if('string'!=typeof t.timestamp||!Number.isFinite(Date.parse(t.timestamp)))return null;const n=f(t.source),s=f(t.kind);if(!n||!s)return null;const o=void 0===t.action?void 0:f(t.action);if(void 0!==t.action&&!o)return null;const c='ok'===t.status||'error'===t.status?t.status:void 0,l=u(t.details)?Object.assign({},t.details):void 0;return Object.assign({id:t.id,timestamp:t.timestamp,source:n,kind:s},'string'==typeof t.msg?{msg:t.msg}:{},'string'==typeof t.summary?{summary:t.summary}:{},'string'==typeof t.device?{device:t.device}:{},o?{action:o}:{},c?{status:c}:{},l?{details:l}:{})}function p(t){let n=t;if('string'==typeof n)try{n=JSON.parse(n)}catch{return null}if(!u(n))return null;const s={};let o=!1;if(l(n,'events')){if(!Array.isArray(n.events))return null;s.events=n.events.map(t=>h(t)).filter(t=>null!==t),o=!0}if(l(n,'event')){const t=h(n.event);if(!t)return o?s:null;s.event=t,o=!0}return o?s:null}function y(t,n){return`ios:${encodeURIComponent(t)}:${n}`}function v(t,n){const s=`ios:${encodeURIComponent(n)}:`;if(!t.id.startsWith(s))return null;const o=Number(t.id.slice(s.length));return Number.isSafeInteger(o)&&o>=0?o:null}function k(t){return t.replace(/[-_]+/g,' ')}function $(t){const n=k(t);return n.length>0?`${n[0].toUpperCase()}${n.slice(1)}`:n}function I(t){return'number'==typeof t&&Number.isFinite(t)?t:null}function S(t,n){const s=t?.[n];if(!u(s))return null;const o=I(s.x),c=I(s.y);return null===o||null===c?null:{x:o,y:c}}function b(t){return Math.min(1,Math.max(0,t)).toFixed(2)}function w(t){return`${b(t.x)}, ${b(t.y)}`}function M(t){return'string'!=typeof t?'key':'character'===t||/^(?:Arrow(?:Down|Left|Right|Up)|Backspace|CapsLock|Delete|End|Enter|Escape|F\d{1,2}|Home|Insert|Numpad[A-Za-z0-9]+|PageDown|PageUp|Pause|PrintScreen|ScrollLock|Space|Tab)$/.test(t)||/^(?:Alt|Control|Meta|Shift)(?:Left|Right)$/.test(t)?t:'character'}function A(t,s){if(s>=c)return'[truncated]';if(Array.isArray(t))return t.slice(0,100).map(t=>A(t,s+1));if(!u(t))return t;const o={};for(const[c,u]of Object.entries(t))o[c]=n.test(c)?'[redacted]':A(u,s+1);return o}function E(t){if(!t.details)return;const n=A(t.details,0);if('key'===t.kind){const s=M(t.details.key);n.key=s,'character'===s&&(n.redacted=!0,delete n.usage)}return n}function P(t){switch(t.kind){case'tap':case'drag':case'touch':case'multi-touch':case'scroll':return'touch';case'key':case'software-keyboard':return'keyboard';case'ui-setting':return'settings';default:return t.kind}}function x(t){return'tap'===t.kind||'drag'===t.kind||'scroll'===t.kind?t.kind:'software-keyboard'===t.kind?'toggle':'multi-touch'===t.kind?t.action?`multi-touch-${t.action}`:'multi-touch':t.action}function C(t,n){const s=x(t);switch(t.kind){case'tap':{const t=S(n,'current')??S(n,'start');return t?`Tap at ${w(t)}`:'Tap'}case'drag':{const t=S(n,'start'),s=S(n,'current');return t&&s?`Drag from ${w(t)} to ${w(s)}`:'Drag'}case'touch':return s?`Touch ${k(s)}`:'Touch';case'multi-touch':return t.action?`Multi-touch ${k(t.action)}`:'Multi-touch';case'scroll':return'Scroll';case'key':{const t=M(n?.key);return s?`Key ${k(s)} ${t}`:`Key ${t}`}case'software-keyboard':return'Software keyboard';case'button':return s?`Button ${$(s)}`:'Button';case'rotate':return s?`Rotate ${k(s)}`:'Rotate';case'memory-warning':return'Memory warning';case'ca-debug':return s?`Core Animation ${k(s)}`:'Core Animation setting';case'digital-crown':return'Digital Crown';case'app':return s?`${$(s)} app`:'App event';case'media':return'Add media';case'screenshot':{if('error'!==t.status)return'Screenshot';const s='string'==typeof n?.file?'Screenshot not saved to session artifacts':'Screenshot failed';return'string'==typeof n?.error?`${s}: ${n.error}`:s}case'camera':return s?`Camera ${k(s)}`:'Camera';case'ui-setting':{const t=f(n?.value);return s?`Set ${$(s)}${t?` to ${$(t)}`:''}`:'Device setting changed'}default:return`Event ${k(t.kind)}`}}function T(t,n){const s=E(t),o=x(t);return Object.assign({id:y(n,t.id),timestamp:t.timestamp,source:t.source,kind:P(t)},o?{action:o}:{},{message:C(t,s)},t.status?{status:t.status}:{},s?{details:s}:{})}},206,[]);
|
|
273
273
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.runHostAction=async function(o,n,c,u,w){let l;try{l=await s(o,n,{action:c,params:u},t,w)}catch(t){if(t instanceof Error&&(f=t.message,!['exec-ws timeout','exec-ws error','exec-ws closed'].includes(f)))return{stdout:'',stderr:t.message,exitCode:1};throw t}var f;return{stdout:l.stdout??'',stderr:l.stderr??'',exitCode:l.exitCode??1}},e.hostUiRequest=async function(t,n,c,u){const w=await s(t,n,{ui:c},o,u),l={};void 0!==w.status&&(l.status=w.status);void 0!==w.ok&&(l.ok=w.ok);return l};const t=1e4,o=5e3;function s(t,o,s,n,c){return new Promise((u,w)=>{let l;try{l=new WebSocket(t,c)}catch(t){return void w(t)}let f,y=!1;const x=t=>{if(!y){y=!0,clearTimeout(f);try{l.close()}catch{}t()}};f=setTimeout(()=>x(()=>w(new Error('exec-ws timeout'))),n),l.onopen=()=>l.send(JSON.stringify({token:o})),l.onmessage=t=>{let o;try{o=JSON.parse(String(t.data))}catch{return}o.ready?l.send(JSON.stringify(Object.assign({id:1},s))):1===o.id&&(o.error?x(()=>w(new Error(o.error))):x(()=>u(o)))},l.onerror=()=>x(()=>w(new Error('exec-ws error'))),l.onclose=()=>x(()=>w(new Error('exec-ws closed')))})}},207,[]);
|
|
274
|
-
__d(function(g,r,i,a,m,e,d){"use strict";async function n(n,t,o){const l=
|
|
274
|
+
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.fetchIosAppDetails=n,e.fetchIosAppIcon=async function(n,c,{fetchImpl:l=fetch,signal:u,retryDelaysMs:p=o}={}){const f=new URL(n);f.searchParams.set('bundleId',c);for(let n=0;;n++){const o=n<p.length;let c;try{c=await l(f.toString(),{cache:'no-store',signal:u})}catch(t){if(u?.aborted||!o)throw t;await s(p[n],u);continue}if(c.ok)return(0,t.parseAppIconResponse)(await c.json());if(c.status<500||!o)throw new Error(`app icon request failed with ${c.status}`);await s(p[n],u)}},e.getIosAppDetails=function(t,o,s,l={}){const u=`${o}:${s}:${!1!==l.includeIcon}`,p=c.get(u);if(p)return p;const f=n(t,o,s,l).catch(t=>{throw c.delete(u),t});return c.set(u,f),f};var t=r(d[0]);async function n(t,n,o,{includeIcon:s=!0}={}){const c=await t('app.container',{udid:n,bundleId:o});if(0!==c.exitCode)return null;const l=c.stdout.trim();if(!l)return null;const u=await t('app.infoPlist',{path:`${l}/Info.plist`});let p,f={};if(0===u.exitCode)try{f=JSON.parse(u.stdout)}catch{}const h=f?.CFBundleIcons?.CFBundlePrimaryIcon??f?.['CFBundleIcons~ipad']?.CFBundlePrimaryIcon,I=h?.CFBundleIconFiles??f?.CFBundleIconFiles;let F;if(I&&I.length>0?p=I[I.length-1]:'string'==typeof f?.CFBundleIconFile&&(p=f.CFBundleIconFile),s&&p){const n=[`${p}@3x.png`,`${p}@2x.png`,`${p}.png`,`${p}60x60@3x.png`,`${p}60x60@2x.png`],o=(await t('app.iconPath',{appPath:l,candidates:n})).stdout.trim();if(o){const n=await t('file.readBase64',{path:o});0===n.exitCode&&(F=`data:image/png;base64,${n.stdout.replace(/\s+/g,'')}`)}}return Object.assign({appPath:l,label:f.CFBundleDisplayName??f.CFBundleName,version:f.CFBundleShortVersionString,build:f.CFBundleVersion,minOS:f.MinimumOSVersion,executable:f.CFBundleExecutable},s?{iconDataUrl:F}:{})}const o=[1e3,2e3,4e3];function s(t,n){return new Promise((o,s)=>{if(n?.aborted)return s(n.reason);const c=()=>{clearTimeout(l),s(n.reason)},l=setTimeout(()=>{n?.removeEventListener('abort',c),o()},t);n?.addEventListener('abort',c,{once:!0})})}const c=new Map},208,[174]);
|
|
275
275
|
__d(function(g,r,i,a,m,e,d){"use strict";function t(t){const n=/Reason:\s*(.+)$/m.exec(t.stderr);if(n)return n[1].trim();return t.stderr.split('\n').map(t=>t.trim()).filter(t=>t.length>0).at(-1)??'simctl location failed'}function n(n){if(0!==n.exitCode)throw new Error(t(n))}Object.defineProperty(e,'__esModule',{value:!0}),e.simctlFailureMessage=t,e.setIosLocation=async function(t,o,c){return n(await t('location.set',{udid:o,lat:c.latitude,lng:c.longitude})),c},e.clearIosLocation=async function(t,o){n(await t('location.clear',{udid:o}))}},209,[]);
|
|
276
276
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),Object.defineProperty(e,"KEY_EVENT_PACE_MS",{enumerable:!0,get:function(){return n}}),e.createPacedKeySender=function(t,u=n,l=setTimeout,o=clearTimeout){const c=[];let s=null;const f=()=>{s=null;const n=c.shift();void 0!==n&&(t(n),c.length>0&&(s=l(f,u)))};return{enqueue(n){if(0!==n.length){for(const t of n)c.push(t);null==s&&f()}},dispose(){c.length=0,null!=s&&o(s),s=null}}};const n=4},210,[]);
|
|
277
277
|
__d(function(g,r,i,a,m,e,d){"use strict";Object.defineProperty(e,'__esModule',{value:!0}),e.middlewareEndpointForBrowser=function(t,n,s=""){const o=n.pathname.replace(/\/+$/,''),p=s.replace(/\/+$/,''),c=new URL(n);c.pathname=`${o}/`,c.search='',c.hash='';const h=new URL(t,new URL(`${p}/`,c)),$=''!==p&&(h.pathname===p||h.pathname.startsWith(`${p}/`)),l=h.pathname.slice($?p.length:0).replace(/^\/+/,'');return c.pathname=`${o}/${l}`,c.search=h.search,c.hash=h.hash,c.toString()},e.proxyPreviewConfigForBrowser=function(t,n){if(!t.device||!t.proxyHelpers)return t;const s=`${n.pathname.replace(/\/+$/,'')}/helper/${encodeURIComponent(t.device)}`,o=n.origin,p='https:'===n.protocol?'wss:':'ws:';return Object.assign({},t,{url:`${o}${s}`,streamUrl:`${o}${s}/stream.mjpeg`,wsUrl:`${p}//${n.host}${s}/ws`,streamSettingsEndpoint:`${o}${s}/stream-settings`})}},211,[]);
|
package/dist/client/index.html
CHANGED
|
@@ -56,6 +56,6 @@
|
|
|
56
56
|
<noscript> You need to enable JavaScript to run Expo Device Hub. </noscript>
|
|
57
57
|
<!-- The root element for the Hub dashboard. -->
|
|
58
58
|
<div id="root"></div>
|
|
59
|
-
<script src="./_expo/static/js/web/index-
|
|
59
|
+
<script src="./_expo/static/js/web/index-b067b431abff858a0c5cffdec4353299.js" defer></script>
|
|
60
60
|
</body>
|
|
61
61
|
</html>
|
package/package.json
CHANGED
|
@@ -631,19 +631,22 @@ async function createAppInternal(opts, dependencies = {}) {
|
|
|
631
631
|
// whose embedded screen size disagrees), and resync every client onto
|
|
632
632
|
// the new stream from a fresh keyframe.
|
|
633
633
|
if (f.width > 0 && f.height > 0) {
|
|
634
|
+
const sizeChanged = screen.width !== f.width || screen.height !== f.height;
|
|
634
635
|
screen.width = f.width;
|
|
635
636
|
screen.height = f.height;
|
|
636
637
|
cachedConfig = null;
|
|
637
638
|
for (const c of clients){
|
|
638
639
|
if (!c.video) continue;
|
|
639
640
|
c.awaitingKeyFrame = true;
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
641
|
+
if (sizeChanged) {
|
|
642
|
+
sendJson(c.socket, {
|
|
643
|
+
type: "video-session",
|
|
644
|
+
size: {
|
|
645
|
+
width: f.width,
|
|
646
|
+
height: f.height
|
|
647
|
+
}
|
|
648
|
+
});
|
|
649
|
+
}
|
|
647
650
|
}
|
|
648
651
|
webRtcPublisher?.resetVideoSource();
|
|
649
652
|
}
|
|
@@ -1998,7 +2001,8 @@ export function createApp(opts, dependencies = {}) {
|
|
|
1998
2001
|
selectedSerial = first.serial;
|
|
1999
2002
|
return first.serial;
|
|
2000
2003
|
};
|
|
2001
|
-
const
|
|
2004
|
+
const defaultStreamModeFor = (serial)=>(isEmulatorSerial(serial) ? defaults.streamMode : undefined) ?? "scrcpy";
|
|
2005
|
+
const createConfiguredApp = async (serial, streamMode = streamModeOverrides.get(serial) ?? defaultStreamModeFor(serial), parentSignal, deviceState, encoderSettings, grpcImageMode = grpcImageModeOverrides.get(serial) ?? defaults.grpcImageMode ?? DEFAULT_GRPC_IMAGE_MODE, inputSource = streamMode === "grpc-screenshot" ? inputSourceOverrides.get(serial) ?? defaults.inputSource ?? DEFAULT_GRPC_INPUT_SOURCE : "scrcpy", encoder = encoderOverrides.get(serial) ?? defaults.encoder ?? DEFAULT_GRPC_ENCODER)=>{
|
|
2002
2006
|
const operation = beginOperation(serial, parentSignal);
|
|
2003
2007
|
let created = null;
|
|
2004
2008
|
try {
|
|
@@ -2124,7 +2128,7 @@ export function createApp(opts, dependencies = {}) {
|
|
|
2124
2128
|
const configuredGrpcImageMode = grpcImageModeOverrides.get(serial) ?? defaults.grpcImageMode ?? DEFAULT_GRPC_IMAGE_MODE;
|
|
2125
2129
|
const currentGrpcImageMode = current ? grpcImageModeForApp(current, configuredGrpcImageMode) : configuredGrpcImageMode;
|
|
2126
2130
|
const grpcImageMode = requestedGrpcImageMode ?? currentGrpcImageMode;
|
|
2127
|
-
const currentMode = current ? streamSessionForApp(current).mode : streamModeOverrides.get(serial) ??
|
|
2131
|
+
const currentMode = current ? streamSessionForApp(current).mode : streamModeOverrides.get(serial) ?? defaultStreamModeFor(serial);
|
|
2128
2132
|
const configuredInputSource = inputSourceOverrides.get(serial) ?? defaults.inputSource ?? DEFAULT_GRPC_INPUT_SOURCE;
|
|
2129
2133
|
const currentInputSource = current ? inputSourceForApp(current) : currentMode === "grpc-screenshot" ? configuredInputSource : "scrcpy";
|
|
2130
2134
|
const inputSource = streamMode === "scrcpy" ? "scrcpy" : requestedInputSource ?? (currentMode === "grpc-screenshot" ? currentInputSource : configuredInputSource);
|