@kaeawc/auto-mobile 0.0.93 → 0.0.94
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/build-info.json +12 -12
- package/dist/src/ble-peripheral.py +153 -0
- package/dist/src/{chunk-r6z1eztj.js → chunk-026y62r9.js} +11 -11
- package/dist/src/chunk-0jyfg947.js +4 -0
- package/dist/src/{chunk-8g1922rp.js → chunk-0zfpp1wh.js} +4 -4
- package/dist/src/{chunk-qf6nynk6.js → chunk-13qxf7ym.js} +5 -5
- package/dist/src/chunk-1scenrk7.js +4 -0
- package/dist/src/chunk-1vb5ph1k.js +4 -0
- package/dist/src/{chunk-710rxz9y.js → chunk-20g565q7.js} +3 -3
- package/dist/src/chunk-21h6dhdm.js +5 -0
- package/dist/src/chunk-25mfpthk.js +78 -0
- package/dist/src/{chunk-rbpdk7m0.js → chunk-2b39zyxc.js} +3 -3
- package/dist/src/chunk-2gzd6wbd.js +4 -0
- package/dist/src/{chunk-xgan0qqp.js → chunk-3dntffy9.js} +1 -1
- package/dist/src/chunk-3gfczcsn.js +4 -0
- package/dist/src/{chunk-dgrbdpb7.js → chunk-3h5jz1vb.js} +6 -6
- package/dist/src/{chunk-t6c8akcm.js → chunk-41zcy6b3.js} +3 -3
- package/dist/src/chunk-47n9m2de.js +4 -0
- package/dist/src/chunk-4vxeq0vd.js +58 -0
- package/dist/src/chunk-59dx6qaf.js +4 -0
- package/dist/src/chunk-5sdf9y92.js +4 -0
- package/dist/src/{chunk-58wzr3mt.js → chunk-5wk1t46v.js} +3 -3
- package/dist/src/{chunk-vy3bwm1d.js → chunk-661c50hh.js} +5 -5
- package/dist/src/chunk-68n6bjjd.js +21 -0
- package/dist/src/{chunk-v6pya0dm.js → chunk-69pmjdf2.js} +3 -3
- package/dist/src/{chunk-e98dqnc9.js → chunk-6hrj3jt6.js} +20 -20
- package/dist/src/{chunk-wbh8spm5.js → chunk-6myr26wx.js} +8 -8
- package/dist/src/chunk-6n96k09n.js +4 -0
- package/dist/src/chunk-6vwrbkre.js +4 -0
- package/dist/src/chunk-6wk0yrab.js +4 -0
- package/dist/src/chunk-6yhm9een.js +4 -0
- package/dist/src/{chunk-mjrps0ac.js → chunk-7k7gjg2t.js} +5 -5
- package/dist/src/chunk-7n5fz68h.js +4 -0
- package/dist/src/chunk-8cvnpnbp.js +4 -0
- package/dist/src/chunk-8kzv7rk7.js +4 -0
- package/dist/src/chunk-8nj68t1v.js +167 -0
- package/dist/src/{chunk-g7tmjbkt.js → chunk-96r3bpg7.js} +3 -3
- package/dist/src/chunk-97x887te.js +4 -0
- package/dist/src/{chunk-8ph29g99.js → chunk-99a6tbvd.js} +1 -1
- package/dist/src/chunk-9p5d2994.js +5 -0
- package/dist/src/{chunk-aabchzxk.js → chunk-9q265er0.js} +4 -4
- package/dist/src/{chunk-jh6vhqzx.js → chunk-9xgnrv5w.js} +3 -3
- package/dist/src/chunk-9xgsmshb.js +5 -0
- package/dist/src/chunk-a02d1wgv.js +4 -0
- package/dist/src/{chunk-ndt1ccxm.js → chunk-a9ps00a1.js} +10 -10
- package/dist/src/{chunk-5d2hft6c.js → chunk-aewdveet.js} +3 -3
- package/dist/src/{chunk-ycaj2sgf.js → chunk-b3tdtq7r.js} +6 -6
- package/dist/src/chunk-bn7jx7a2.js +4 -0
- package/dist/src/{chunk-3y6eykz9.js → chunk-bnyw27ja.js} +2 -2
- package/dist/src/{chunk-rqc9ap3x.js → chunk-bpwsg76p.js} +2 -2
- package/dist/src/chunk-bvranw3g.js +4 -0
- package/dist/src/chunk-c25a84zb.js +4 -0
- package/dist/src/chunk-c27yv1dx.js +5 -0
- package/dist/src/chunk-c3ewxm4x.js +5 -0
- package/dist/src/{chunk-rvvy1bte.js → chunk-cb1ga9rd.js} +5 -5
- package/dist/src/chunk-cn7fwy7k.js +4 -0
- package/dist/src/chunk-cnvy4a64.js +4 -0
- package/dist/src/{chunk-7rz9898k.js → chunk-cqhw4yr6.js} +3 -3
- package/dist/src/{chunk-g04bwyj3.js → chunk-ctmfshjc.js} +2 -2
- package/dist/src/chunk-ctwmhz13.js +4 -0
- package/dist/src/{chunk-waqwcjyn.js → chunk-d3jx9bz5.js} +2 -2
- package/dist/src/{chunk-ayp07wbb.js → chunk-d6rb08ga.js} +1 -1
- package/dist/src/chunk-ddqhj4eg.js +5 -0
- package/dist/src/{chunk-r7bpkgff.js → chunk-ddrhs1c3.js} +2 -2
- package/dist/src/chunk-dnjnh9p6.js +4 -0
- package/dist/src/{chunk-wyrkw6hw.js → chunk-dw5rwgya.js} +3 -3
- package/dist/src/{chunk-3xkpk44w.js → chunk-e0870khr.js} +3 -3
- package/dist/src/chunk-ea3k10kj.js +4 -0
- package/dist/src/chunk-emv82m1w.js +7 -0
- package/dist/src/chunk-f3m6pdnx.js +4 -0
- package/dist/src/chunk-f84z32cb.js +4 -0
- package/dist/src/chunk-fpczgf0z.js +4 -0
- package/dist/src/{chunk-2tqzq5qh.js → chunk-g2js4c2v.js} +18 -18
- package/dist/src/chunk-g3af2qbk.js +5 -0
- package/dist/src/{chunk-3qwrzxh0.js → chunk-gadtna7s.js} +6 -6
- package/dist/src/{chunk-ybbtagbt.js → chunk-gcyx407v.js} +3 -3
- package/dist/src/{chunk-bfw6125s.js → chunk-gfpntwc1.js} +3 -3
- package/dist/src/chunk-gmnm5e3e.js +4 -0
- package/dist/src/chunk-gp6vb5gf.js +4 -0
- package/dist/src/chunk-gppgy7pa.js +4 -0
- package/dist/src/chunk-hegfz0ae.js +5 -0
- package/dist/src/chunk-hpzxdp1k.js +17 -0
- package/dist/src/{chunk-qcxzr2my.js → chunk-j69g8b50.js} +3 -3
- package/dist/src/chunk-jvstjnqm.js +19 -0
- package/dist/src/chunk-jzqrv78s.js +4 -0
- package/dist/src/chunk-k2948b8d.js +4 -0
- package/dist/src/chunk-k4ftd40d.js +4 -0
- package/dist/src/{chunk-bxmsax22.js → chunk-kd9vfaxh.js} +3 -3
- package/dist/src/{chunk-s3jc6cwp.js → chunk-kdczmgwk.js} +3 -3
- package/dist/src/{chunk-t6bfvfkg.js → chunk-ke3wn14v.js} +1 -1
- package/dist/src/chunk-kh5n7m6w.js +4 -0
- package/dist/src/{chunk-6wt9rgjf.js → chunk-khejfph4.js} +3 -3
- package/dist/src/chunk-kny2xemh.js +4 -0
- package/dist/src/chunk-knyzw9md.js +4 -0
- package/dist/src/chunk-mbzpt2hp.js +4 -0
- package/dist/src/chunk-mm8rcxad.js +4 -0
- package/dist/src/chunk-nc4516tx.js +4 -0
- package/dist/src/{chunk-6bznss4t.js → chunk-ntfrqrqn.js} +5 -5
- package/dist/src/chunk-nz5h2j52.js +4 -0
- package/dist/src/chunk-p22s97qy.js +4 -0
- package/dist/src/chunk-p9kt1sgr.js +6 -0
- package/dist/src/{chunk-yb97j25b.js → chunk-pf282r5g.js} +4 -4
- package/dist/src/chunk-pnd4mrxy.js +4 -0
- package/dist/src/chunk-pqqteyj6.js +4 -0
- package/dist/src/{chunk-6xmss8er.js → chunk-qj1tbnv2.js} +6 -6
- package/dist/src/chunk-qnh9egwr.js +4 -0
- package/dist/src/chunk-qy3khhf8.js +8 -0
- package/dist/src/{chunk-z637nqg8.js → chunk-r0vp315h.js} +6 -6
- package/dist/src/chunk-r4j43b9s.js +237 -0
- package/dist/src/{chunk-1p7xf5kb.js → chunk-r54cxxze.js} +3 -3
- package/dist/src/{chunk-yf7ympyz.js → chunk-r6pvhj33.js} +92 -92
- package/dist/src/chunk-rb7aa5gr.js +54 -0
- package/dist/src/chunk-rdj50kb4.js +4 -0
- package/dist/src/chunk-rnd4vcas.js +4 -0
- package/dist/src/{chunk-w5b2jwk3.js → chunk-s3y3zfcx.js} +8 -8
- package/dist/src/chunk-s4g43k75.js +5 -0
- package/dist/src/chunk-sfqe223f.js +311 -0
- package/dist/src/{chunk-284ptqa4.js → chunk-sqdrxjw5.js} +5 -5
- package/dist/src/{chunk-zgja5f3p.js → chunk-t54k47em.js} +4 -4
- package/dist/src/{chunk-3sy6ahhz.js → chunk-tek4pnvv.js} +10 -10
- package/dist/src/chunk-tn74y7af.js +4 -0
- package/dist/src/{chunk-thbh3jew.js → chunk-tvq0nzam.js} +3 -3
- package/dist/src/{chunk-0jrrsnc9.js → chunk-tx4f0h9c.js} +4 -4
- package/dist/src/chunk-vdqag3fj.js +5 -0
- package/dist/src/chunk-vz5zzs57.js +4 -0
- package/dist/src/chunk-w4s2vfpj.js +4 -0
- package/dist/src/{chunk-4hw3665t.js → chunk-w5yypt53.js} +11 -11
- package/dist/src/{chunk-8037tzzj.js → chunk-w68v64vh.js} +3 -3
- package/dist/src/chunk-whwj0pdk.js +5 -0
- package/dist/src/chunk-wnmqt1dc.js +4 -0
- package/dist/src/{chunk-cyy71ggq.js → chunk-wpe46vsa.js} +3 -3
- package/dist/src/{chunk-w3vs79ex.js → chunk-wxdjeb4k.js} +19 -19
- package/dist/src/chunk-xcqzwf9j.js +247 -0
- package/dist/src/chunk-xezekwwn.js +5 -0
- package/dist/src/chunk-xf19m15s.js +4 -0
- package/dist/src/chunk-xghbxha4.js +4 -0
- package/dist/src/{chunk-00167wan.js → chunk-xn9m3xc2.js} +5 -5
- package/dist/src/{chunk-26k317v5.js → chunk-yqfz4vts.js} +3 -3
- package/dist/src/chunk-z8tvs8nk.js +5 -0
- package/dist/src/chunk-zm2rehqb.js +5 -0
- package/dist/src/chunk-zs6dqm35.js +4 -0
- package/dist/src/daemon/processEntry.js +2 -2
- package/dist/src/index.js +4 -4
- package/dist/src/runtime/bunRuntimeGuard.js +2 -2
- package/dist/src/utils/workers/iosBundleExtractWorker.js +2 -2
- package/package.json +2 -2
- package/dist/src/chunk-0n6swkwg.js +0 -5
- package/dist/src/chunk-0qsy1qsx.js +0 -57
- package/dist/src/chunk-11m8wj8j.js +0 -237
- package/dist/src/chunk-23p5f095.js +0 -4
- package/dist/src/chunk-28re4xrg.js +0 -4
- package/dist/src/chunk-2f9rkmhx.js +0 -5
- package/dist/src/chunk-2fxdh48t.js +0 -4
- package/dist/src/chunk-2tbdrbt6.js +0 -4
- package/dist/src/chunk-32gvv9b4.js +0 -21
- package/dist/src/chunk-3f3t1x97.js +0 -8
- package/dist/src/chunk-3fspkbc7.js +0 -4
- package/dist/src/chunk-3vg455e6.js +0 -4
- package/dist/src/chunk-49bsqdx3.js +0 -4
- package/dist/src/chunk-5snsn9cf.js +0 -4
- package/dist/src/chunk-5tm9mn47.js +0 -54
- package/dist/src/chunk-5zc77a5t.js +0 -4
- package/dist/src/chunk-64j0majr.js +0 -19
- package/dist/src/chunk-65y8v4td.js +0 -17
- package/dist/src/chunk-6awz7vhq.js +0 -5
- package/dist/src/chunk-6ep7f5ge.js +0 -4
- package/dist/src/chunk-7cs2da62.js +0 -5
- package/dist/src/chunk-7g103b54.js +0 -4
- package/dist/src/chunk-7j5vj4pa.js +0 -4
- package/dist/src/chunk-7tw8x05v.js +0 -4
- package/dist/src/chunk-7zy586cb.js +0 -4
- package/dist/src/chunk-84nanf8s.js +0 -5
- package/dist/src/chunk-8gvwcv2p.js +0 -4
- package/dist/src/chunk-8thrmfat.js +0 -4
- package/dist/src/chunk-8zgzzs7k.js +0 -78
- package/dist/src/chunk-97b1zmaq.js +0 -4
- package/dist/src/chunk-9fth9ayh.js +0 -4
- package/dist/src/chunk-9j6anhjr.js +0 -4
- package/dist/src/chunk-bfjwqk8q.js +0 -4
- package/dist/src/chunk-bnhscm2n.js +0 -4
- package/dist/src/chunk-c1vs4g1n.js +0 -4
- package/dist/src/chunk-ct3e7yng.js +0 -4
- package/dist/src/chunk-ddzkz92z.js +0 -4
- package/dist/src/chunk-drdz8hee.js +0 -5
- package/dist/src/chunk-eersndy7.js +0 -5
- package/dist/src/chunk-eggq53ks.js +0 -4
- package/dist/src/chunk-f2dya7cs.js +0 -4
- package/dist/src/chunk-fbakd6cw.js +0 -4
- package/dist/src/chunk-fgb98zjj.js +0 -5
- package/dist/src/chunk-fmpad823.js +0 -5
- package/dist/src/chunk-g0xr8zw0.js +0 -4
- package/dist/src/chunk-g3rjs80x.js +0 -4
- package/dist/src/chunk-g78rtrfv.js +0 -4
- package/dist/src/chunk-gabgv3y5.js +0 -4
- package/dist/src/chunk-gmr45m8f.js +0 -4
- package/dist/src/chunk-gsyfebqj.js +0 -4
- package/dist/src/chunk-h5rpn9wr.js +0 -247
- package/dist/src/chunk-hb1x7v55.js +0 -4
- package/dist/src/chunk-hrfytkxh.js +0 -168
- package/dist/src/chunk-j4yjzbak.js +0 -4
- package/dist/src/chunk-jd6a5v6p.js +0 -5
- package/dist/src/chunk-kn5spq15.js +0 -4
- package/dist/src/chunk-m94qs0f0.js +0 -4
- package/dist/src/chunk-n03dmn5q.js +0 -5
- package/dist/src/chunk-n72qhwd9.js +0 -4
- package/dist/src/chunk-nr6y0n4y.js +0 -5
- package/dist/src/chunk-pcsen2vs.js +0 -4
- package/dist/src/chunk-ppfr0b8h.js +0 -4
- package/dist/src/chunk-q10bdnat.js +0 -4
- package/dist/src/chunk-q9xmq595.js +0 -4
- package/dist/src/chunk-qyqypn28.js +0 -5
- package/dist/src/chunk-r2epb56s.js +0 -4
- package/dist/src/chunk-r5bxavdx.js +0 -311
- package/dist/src/chunk-r8jf3d92.js +0 -4
- package/dist/src/chunk-rc0dbypm.js +0 -4
- package/dist/src/chunk-rhcty4ms.js +0 -4
- package/dist/src/chunk-rpvckv3p.js +0 -4
- package/dist/src/chunk-ry0mz41y.js +0 -4
- package/dist/src/chunk-sfv61xjb.js +0 -6
- package/dist/src/chunk-t7w8rctc.js +0 -4
- package/dist/src/chunk-v2wd4n3e.js +0 -5
- package/dist/src/chunk-w4zga19f.js +0 -4
- package/dist/src/chunk-w7hkv422.js +0 -5
- package/dist/src/chunk-xa73x2cx.js +0 -5
- package/dist/src/chunk-y2vs6jwg.js +0 -4
- package/dist/src/chunk-yattm52s.js +0 -4
- package/dist/src/chunk-yjawdzk8.js +0 -4
- package/dist/src/chunk-zs1sghs9.js +0 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{i,l,e}from"./chunk-z637nqg8.js";import{Ns,R,Bt,uz,wn,Pn,Rp,Ic,An,qa,tb,Si,si}from"./chunk-r5bxavdx.js";import{PQ}from"./chunk-hrfytkxh.js";import{Wr,td,aa}from"./chunk-0qsy1qsx.js";import{r,t}from"./chunk-rbpdk7m0.js";function wU(s){return!s.authEnabled||s.ownsDevice?"owner":"viewer"}function jO(s){if(!s.authEnabled)return{action:"keep"};if(!s.sessionExists)return{action:"end",reason:"session_ended"};if(s.kind==="owner"&&!s.ownsDevice)return{action:"downgrade"};return{action:"keep"}}function KO(s){return{action:"end",reason:s.event}}var u={video_relay:{subscribe:"admission",postHandshake:"mutating"},webrtc:{start:{stream:"mutating",own_lease:"own_lease"},stop:{stream:"mutating",own_lease:"own_lease"},status:"read",list:"read",await:"read"}};function I(s){if(s.transport==="video_relay")return!s.postHandshake&&s.action==="subscribe"?u.video_relay.subscribe:u.video_relay.postHandshake;if(s.action==="start"||s.action==="stop")return u.webrtc[s.action][s.target==="own_lease"?"own_lease":"stream"];let n=u.webrtc,o=Object.hasOwn(n,s.action)?n[s.action]:"mutating";return typeof o==="string"?o:"mutating"}class v extends t{code="viewer_read_only";constructor(){super("Viewer subscriptions may release or renew their own leases; acquire device ownership before changing stream parameters or controlling other subscriptions.");this.name="ViewerReadOnlyError"}}function b(s,n){if(s==="viewer"&&I(n)==="mutating")throw new v}class GO extends t{reason;subscriptionKind;constructor({reason:s,subscriptionKind:n}){super(`WebRTC subscription ended: ${s}; call start to re-subscribe.`);this.name="WebRtcSubscriptionEndedError",this.reason=s,this.subscriptionKind=n}}async function YO(s,n,o="android",{timer:a=i,signal:c,source:d="webrtc-stream-resolve"}={}){let m=await s.getBootedDevices(o);if(await Wr(m,d),m.length===0){if(o==="either")return g(m,n,o);if(o==="android")throw new t("No connected android devices found.");m=await k(s,o,a,{signal:c,source:d})}return g(m,n,o)}function g(s,n,o){let a=o==="either"?"":`${o} `;if(n){let c=s.find((d)=>d.deviceId===n);if(!c)throw new t(`No connected ${a}device with id ${n}.`);return c}if(s.length===0)throw new t("No connected devices found.");if(s.length>1)throw new t(`Multiple connected ${a}devices; specify deviceId. Found: ${s.map((c)=>c.deviceId).join(", ")}`);return s[0]}async function k(s,n,o,{signal:a,source:c}){try{return await new wn(o).executeOrThrow(async()=>{let d=await s.getBootedDevices(n);if(d.length===0)throw Error(`No connected ${n} devices found.`);return await Wr(d,c),d},{delays:[250,500,1000,2000],maxAttempts:5,signal:a})}catch(d){if(a?.aborted)throw d;throw new t(`No connected ${n} devices found (after 5 attempts).`)}}function y(s){let{request:n,context:o}=s;if(!o?.holdsLease)return"stream";return n.action==="stop"||n.leaseId!==void 0&&o.parametersMatch?"own_lease":"stream"}var h="to start a WebRTC stream",C=td("WebRTC",()=>import("./chunk-wbh8spm5.js"));function O(){return R.sessionManager()??null}var W=5000,E=new si;async function x(s,n="android"){return YO(E,s,n)}function w(s){let n={};if(s.whipEndpoint)n.whipEndpoint=s.whipEndpoint;if(s.whipToken)n.bearerToken=s.whipToken;if(s.iceServers!==void 0)n.iceServers=s.iceServers;if(s.bitrateKbps!==void 0)n.bitrateKbps=s.bitrateKbps;if(s.size)n.size=s.size;if(s.iosSimulatorFps!==void 0)n.iosSimulatorFps=s.iosSimulatorFps;if(s.androidFps!==void 0)n.androidFps=s.androidFps;if(s.audio!==void 0)n.audioEnabled=s.audio;if(s.trickleIce!==void 0)n.trickleIce=s.trickleIce;return n}class D extends qa{injectedDeps;resolvedDeps=null;authenticator;admissionGate;managerModule;removeOwnershipListener=null;removeListeners=[];viewerControlRejections=new Set;closed=!1;closing=null;constructor(s=Bt(uz),n=i,o,{authenticator:a=An("webrtcStream",{allowObserverSessions:!0}),admissionGate:c=Ns,managerModule:d=C}={}){super(s,n,"WebRtcStream");this.injectedDeps=o,this.authenticator=a,this.admissionGate=c,this.managerModule=d}bypassesRequestChain(s){return s.action==="stop"}onServerStarted(){this.viewerControlRejections.clear(),this.closed=!1,this.closing=null,this.unsubscribeListeners();let s=this.injectedDeps?this.injectedDeps.ownershipChanges:O;this.removeOwnershipListener=s?.()?.onDeviceOwnershipChange((c)=>{this.onOwnershipChanged(c)})??null;let n=this.injectedDeps?this.injectedDeps.sessionReleases:Si,o=()=>{for(let c of this.resolvedDeps?.liveDeviceIds?.()??[])this.onOwnershipChanged(c)},a=this.injectedDeps?this.injectedDeps.observerReleases:tb;for(let c of[n?.subscribe(o),a?.subscribe(o)])if(c)this.removeListeners.push(c);this.registerLifecycleListeners()}registerLifecycleListeners(){let s=(this.injectedDeps?this.injectedDeps.deviceLifecycle:aa)?.(),n=s?.onDeviceRemoved((a)=>this.endDeviceStreams({deviceId:a,reason:"device_removed"})),o=s?.onDeviceIdentityChanged((a)=>this.checkDeviceActionable(a));for(let a of[n,o])if(a)this.removeListeners.push(a)}unsubscribeListeners(){this.removeOwnershipListener?.(),this.removeOwnershipListener=null;for(let s of this.removeListeners.splice(0))s()}onOwnershipChanged(s){this.reconcileOwnership(s).catch((n)=>{e.warn(`[WebRtcStream] ownership cleanup failed: ${r(n)}`,n)})}endDeviceStreams(s){if(this.closed)return;this.resolvedDeps?.endStreamsForDevice?.(s).catch((n)=>{e.warn(`[WebRtcStream] lifecycle cleanup failed: ${r(n)}`,n)})}checkDeviceActionable(s){if(this.closed||!this.resolvedDeps?.liveDeviceIds?.().includes(s))return;try{this.admissionGate.assertDeviceActionable(s,h)}catch(n){e.warn(`[WebRtcStream] identity no longer actionable for ${s}: ${r(n)}`),this.endDeviceStreams({deviceId:s,reason:"identity_quarantined"})}}async reconcileOwnership(s){if(this.closed||!this.resolvedDeps?.reconcileOwnership)return;await this.resolvedDeps.reconcileOwnership(s,(n)=>this.resolveLiveIdentity({sessionUuid:n,deviceId:s}))}resolveLiveIdentity(s){try{if(this.authenticator.resolveSubscriptionIdentity)return this.authenticator.resolveSubscriptionIdentity(s);return this.authenticator.authorize({...s,requireOwnership:!0}),{authEnabled:!0,sessionExists:!0,ownsDevice:!0}}catch(n){return e.warn(`[WebRtcStream] subscription identity check failed for deviceId=${s.deviceId}; ending session subscription`),{authEnabled:!0,sessionExists:!1,ownsDevice:!1}}}close(){if(this.closing)return this.closing;return this.closed=!0,this.viewerControlRejections.clear(),this.unsubscribeListeners(),this.closing=l(async()=>{await Promise.all([this.resolvedDeps?.stopAllStreams?.("daemon_shutdown"),super.close()])},{timer:this.timer,timeoutMs:W,label:"WebRTC socket server shutdown"}).catch((s)=>{e.warn(`[WebRtcStream] shutdown cleanup failed: ${r(s)}`,s)}),this.closing}async getDeps(){if(this.injectedDeps)return this.resolvedDeps=this.injectedDeps,this.injectedDeps;if(!this.resolvedDeps){let s=await this.managerModule.load();this.resolvedDeps={resolveDevice:x,startStream:s.startWebRtcStream,stopStream:s.stopWebRtcStream,stopStreamAsOwner:s.stopWebRtcStreamAsOwner,releaseOwnLeases:s.releaseWebRtcStreamOwnLeases,getControlContext:s.getWebRtcStreamControlContext,listStreams:s.listWebRtcStreams,getStream:s.getWebRtcStreamDescriptor,awaitReadiness:s.waitForWebRtcStreamReadiness,reconcileOwnership:s.reconcileWebRtcStreamsForDeviceOwnership,stopAllStreams:s.stopAllWebRtcStreams,getSubscriptionKind:s.getWebRtcSubscriptionKind,liveDeviceIds:s.getWebRtcStreamDeviceIds,endStreamsForDevice:s.endWebRtcStreamsForDevice}}return this.resolvedDeps}async handleRequest(s){try{this.assertOpen(),this.authorizeRequest(s);let n=this.authenticator.resolveSessionIdentity?.(s.sessionUuid)??s.sessionUuid,o=await this.getDeps();if(this.assertOpen(),s.action==="start")return await this.handleStart(o,s,n);let a=o.getSubscriptionKind?.({streamId:s.streamId,leaseId:s.leaseId,sessionUuid:n})??"owner",c=this.requestControlFacts({deps:o,request:s,sessionUuid:n,kind:a});return b(c.stopIdentity?.ownsDevice?"owner":a,{transport:"webrtc",action:s.action,target:c.target}),await this.dispatchRequest({deps:o,request:s,sessionUuid:n,kind:a,...c})}catch(n){return this.subscriptionErrorResponse({request:s,error:n})}}authorizeRequest(s){let n=s.action==="start"||!this.authenticator.resolveSubscriptionIdentity;this.authenticator.authorize({sessionUuid:s.sessionUuid,deviceId:n?s.deviceId:void 0,admitViewer:s.action==="start"})}requestControlFacts(s){let{deps:n,request:o,sessionUuid:a,kind:c}=s;if(o.action!=="start"&&o.action!=="stop")return{target:"stream"};let d=n.getControlContext?.({streamId:o.streamId,leaseId:o.leaseId,sessionUuid:a,deviceId:o.action==="start"?o.deviceId:void 0,overrides:w(o),compareParameters:o.action==="start"&&c==="viewer"});return{target:y({request:o,context:d}),addressedStreamId:d?.streamId,stopIdentity:this.resolveStopIdentity({request:o,deviceId:d?.deviceId})}}resolveStopIdentity(s){if(s.request.action!=="stop"||s.deviceId===void 0)return;let n=this.authenticator.resolveSubscriptionIdentity?.({sessionUuid:s.request.sessionUuid,deviceId:s.deviceId});return n?.authEnabled&&n.sessionExists?n:void 0}logViewerControlRejection(s){let n=this.authenticator.resolveSessionIdentity?.(s.sessionUuid)??s.sessionUuid,o=JSON.stringify([n,s.leaseId,s.action]),a=`[WebRtcStream] rejected viewer control: action=${s.action}`;if(this.viewerControlRejections.has(o)){e.debug(a);return}if(this.viewerControlRejections.add(o),this.viewerControlRejections.size>256){let c=this.viewerControlRejections.values().next().value;if(c!==void 0)this.viewerControlRejections.delete(c)}e.warn(a)}subscriptionErrorResponse({request:s,error:n}){let o=Ic(n);if("code"in o)return e.warn(`[WebRtcStream] Ownership refusal: ${r(n)}`,n),{...this.createErrorResponse(s.id,r(n)),...o,errorCode:o.code};if(n instanceof v)return this.logViewerControlRejection(s),{...this.createErrorResponse(s.id,n.message),errorCode:n.code,subscriptionKind:"viewer"};if(n instanceof GO)return e.info(`[WebRtcStream] reporting ended subscription: reason=${n.reason}`),{...this.createErrorResponse(s.id,n.message),reason:n.reason,subscriptionKind:n.subscriptionKind};throw n}async dispatchRequest(s){let{deps:n,request:o,sessionUuid:a,kind:c}=s;switch(o.action){case"start":return this.handleStart(n,o,a);case"stop":return this.handleStop(s);case"status":return this.handleStatus(n,o,a);case"list":return{id:o.id,success:!0,type:"webrtc_stream_response",action:"list",streams:n.listStreams(),subscriptionKind:o.leaseId?c:void 0};case"await":return this.handleAwait(n,o,a);default:throw new t(`Unsupported webrtcStream action: ${o.action}`)}}async handleStop(s){let{deps:n,request:o,sessionUuid:a,kind:c}=s,d={streamId:s.addressedStreamId??o.streamId,leaseId:o.leaseId,sessionUuid:a},m=s.stopIdentity?.ownsDevice&&n.stopStreamAsOwner?await n.stopStreamAsOwner(d):s.stopIdentity&&n.releaseOwnLeases?await n.releaseOwnLeases(d):await n.stopStream(o.streamId,o.leaseId,a);return{id:o.id,success:!0,type:"webrtc_stream_response",action:"stop",stream:m,subscriptionKind:c}}assertRenewalMayControl(s){let{deps:n,request:o,device:a,sessionUuid:c,subscriptionKind:d,renewingLease:m}=s;if(d!=="viewer"||!m)return;let S=n.getControlContext?.({deviceId:a.deviceId,leaseId:o.leaseId,sessionUuid:c,overrides:w(o),compareParameters:!0});b(d,{transport:"webrtc",action:"start",target:y({request:o,context:S})})}subscriberStartOverrides(s,n,o){if(n==="viewer"&&!o)return;let a=w(s);if(a.whipEndpoint)PQ(a.whipEndpoint);return a}async handleStart(s,n,o){if(n.deviceId!==void 0)this.admissionGate.assertDeviceActionable(n.deviceId,h);let a=await s.resolveDevice(n.deviceId,n.platform??"android");this.assertOpen(),this.admissionGate.assertDeviceActionable(a.deviceId,h),Rp(this.authenticator,{sessionUuid:n.sessionUuid,deviceId:a.deviceId,admitViewer:!0});let{subscriptionKind:c,ownsDevice:d,renewingLease:m}=this.startSubscription({deps:s,request:n,device:a,sessionUuid:o}),S=this.subscriberStartOverrides(n,c,m);if(!d)this.assertRenewalMayControl({deps:s,request:n,device:a,sessionUuid:o,subscriptionKind:c,renewingLease:m});let p=await s.startStream({device:a,streamId:n.streamId,leaseId:n.leaseId,sessionUuid:o,subscriptionKind:c,ownsDevice:d,overrides:S});return await this.recheckStartAdmission({deps:s,request:n,device:a,stream:p,sessionUuid:o}),e.info(`[WebRtcStream] started stream ${p.streamId} for device ${a.deviceId}`),{id:n.id,success:p.failure===null||p.failure===void 0,type:"webrtc_stream_response",action:"start",stream:p,subscriptionKind:s.getSubscriptionKind?.({streamId:p.streamId,leaseId:p.lease?.id,sessionUuid:o,existingLeaseOnly:!0})??c,failure:p.failure??null,error:p.failure?.message}}startSubscription(s){let{deps:n,request:o,device:a,sessionUuid:c}=s,d=o.leaseId?n.getSubscriptionKind?.({streamId:o.streamId,leaseId:o.leaseId,sessionUuid:c,allowEndedLease:!0,existingLeaseOnly:!0}):void 0,m=this.authenticator.resolveSubscriptionIdentity?.({sessionUuid:o.sessionUuid,deviceId:a.deviceId}),S=!!m?.authEnabled&&m.sessionExists&&m.ownsDevice;if(d!==void 0)return{subscriptionKind:d,ownsDevice:S,renewingLease:!0};return{subscriptionKind:m?wU(m):"owner",ownsDevice:S,renewingLease:!1}}async recheckStartAdmission(s){let{deps:n,request:o,device:a,stream:c,sessionUuid:d}=s;try{if(this.assertOpen(),Rp(this.authenticator,{sessionUuid:o.sessionUuid,deviceId:a.deviceId,admitViewer:!0}),c.lease?.id!==o.leaseId&&this.authenticator.resolveSubscriptionIdentity)await this.reconcileOwnership(a.deviceId)}catch(m){let S=c.lease?.id;if(S&&S!==o.leaseId)await l(()=>n.stopStream(c.streamId,S,d),{timer:this.timer,timeoutMs:W,label:"WebRTC rejected start lease cleanup"}).catch((p)=>{e.warn(`[WebRtcStream] rejected start cleanup failed: ${r(p)}`,p)});throw m}}async handleAwait(s,n,o){if(!n.streamId)throw new t("The WebRTC await action requires streamId.");if(!s.awaitReadiness)throw new t("WebRTC readiness waiting is unavailable.");let a=await s.awaitReadiness(n.streamId,n.readiness??"publishing",n.timeoutMs,{leaseId:n.leaseId,sessionUuid:o});return{id:n.id,success:a.failure===null||a.failure===void 0,type:"webrtc_stream_response",action:"await",stream:a,subscriptionKind:s.getSubscriptionKind?.({streamId:a.streamId,leaseId:a.lease?.id,sessionUuid:o})??"owner",failure:a.failure??null,error:a.failure?.message}}handleStatus(s,n,o){if(n.streamId){let a=s.getStream(n.streamId,n.leaseId,o);if(!a)throw new t(`No active WebRTC stream with id ${n.streamId}.`);return{id:n.id,success:a.failure===null||a.failure===void 0,type:"webrtc_stream_response",action:"status",stream:a,subscriptionKind:s.getSubscriptionKind?.({streamId:a.streamId,leaseId:a.lease?.id,sessionUuid:o})??"owner",failure:a.failure??null,error:a.failure?.message}}return{id:n.id,success:!0,type:"webrtc_stream_response",action:"list",streams:s.listStreams(),subscriptionKind:n.leaseId?s.getSubscriptionKind?.({leaseId:n.leaseId,sessionUuid:o})??"owner":void 0}}createErrorResponse(s,n){return{id:s,success:!1,type:"webrtc_stream_response",error:n}}assertOpen(){if(this.closed)throw new t("WebRTC stream socket server is closed.")}}var f=new Pn;function FK(){return f.instance?.getSocketPath()??Bt(uz)}async function LK(){await f.start(()=>new D)}async function BK(){await f.stop()}
|
|
3
|
-
export{
|
|
2
|
+
import{i,l,e}from"./chunk-r0vp315h.js";import{$s,w,$t,Oz,kn,In,Lp,Mc,_n,za,bb,Ai,Xn}from"./chunk-sfqe223f.js";import{BQ}from"./chunk-8nj68t1v.js";import{Kr,ad,ma}from"./chunk-4vxeq0vd.js";import{r,t}from"./chunk-2b39zyxc.js";function BU(s){return!s.authEnabled||s.ownsDevice?"owner":"viewer"}function pM(s){if(!s.authEnabled)return{action:"keep"};if(!s.sessionExists)return{action:"end",reason:"session_ended"};if(s.kind==="owner"&&!s.ownsDevice)return{action:"downgrade"};return{action:"keep"}}function mM(s){return{action:"end",reason:s.event}}var u={video_relay:{subscribe:"admission",postHandshake:"mutating"},webrtc:{start:{stream:"mutating",own_lease:"own_lease"},stop:{stream:"mutating",own_lease:"own_lease"},status:"read",list:"read",await:"read"}};function I(s){if(s.transport==="video_relay")return!s.postHandshake&&s.action==="subscribe"?u.video_relay.subscribe:u.video_relay.postHandshake;if(s.action==="start"||s.action==="stop")return u.webrtc[s.action][s.target==="own_lease"?"own_lease":"stream"];let n=u.webrtc,o=Object.hasOwn(n,s.action)?n[s.action]:"mutating";return typeof o==="string"?o:"mutating"}class v extends t{code="viewer_read_only";constructor(){super("Viewer subscriptions may release or renew their own leases; acquire device ownership before changing stream parameters or controlling other subscriptions.");this.name="ViewerReadOnlyError"}}function b(s,n){if(s==="viewer"&&I(n)==="mutating")throw new v}class fM extends t{reason;subscriptionKind;constructor({reason:s,subscriptionKind:n}){super(`WebRTC subscription ended: ${s}; call start to re-subscribe.`);this.name="WebRtcSubscriptionEndedError",this.reason=s,this.subscriptionKind=n}}async function hM(s,n,o="android",{timer:a=i,signal:c,source:d="webrtc-stream-resolve"}={}){let m=await s.getBootedDevices(o);if(await Kr(m,d),m.length===0){if(o==="either")return g(m,n,o);if(o==="android")throw new t("No connected android devices found.");m=await k(s,o,a,{signal:c,source:d})}return g(m,n,o)}function g(s,n,o){let a=o==="either"?"":`${o} `;if(n){let c=s.find((d)=>d.deviceId===n);if(!c)throw new t(`No connected ${a}device with id ${n}.`);return c}if(s.length===0)throw new t("No connected devices found.");if(s.length>1)throw new t(`Multiple connected ${a}devices; specify deviceId. Found: ${s.map((c)=>c.deviceId).join(", ")}`);return s[0]}async function k(s,n,o,{signal:a,source:c}){try{return await new kn(o).executeOrThrow(async()=>{let d=await s.getBootedDevices(n);if(d.length===0)throw Error(`No connected ${n} devices found.`);return await Kr(d,c),d},{delays:[250,500,1000,2000],maxAttempts:5,signal:a})}catch(d){if(a?.aborted)throw d;throw new t(`No connected ${n} devices found (after 5 attempts).`)}}function y(s){let{request:n,context:o}=s;if(!o?.holdsLease)return"stream";return n.action==="stop"||n.leaseId!==void 0&&o.parametersMatch?"own_lease":"stream"}var h="to start a WebRTC stream",C=ad("WebRTC",()=>import("./chunk-6myr26wx.js"));function O(){return w.sessionManager()??null}var W=5000,E=new Xn;async function x(s,n="android"){return hM(E,s,n)}function R(s){let n={};if(s.whipEndpoint)n.whipEndpoint=s.whipEndpoint;if(s.whipToken)n.bearerToken=s.whipToken;if(s.iceServers!==void 0)n.iceServers=s.iceServers;if(s.bitrateKbps!==void 0)n.bitrateKbps=s.bitrateKbps;if(s.size)n.size=s.size;if(s.iosSimulatorFps!==void 0)n.iosSimulatorFps=s.iosSimulatorFps;if(s.androidFps!==void 0)n.androidFps=s.androidFps;if(s.audio!==void 0)n.audioEnabled=s.audio;if(s.trickleIce!==void 0)n.trickleIce=s.trickleIce;return n}class D extends za{injectedDeps;resolvedDeps=null;authenticator;admissionGate;managerModule;removeOwnershipListener=null;removeListeners=[];viewerControlRejections=new Set;closed=!1;closing=null;constructor(s=$t(Oz),n=i,o,{authenticator:a=_n("webrtcStream",{allowObserverSessions:!0}),admissionGate:c=$s,managerModule:d=C}={}){super(s,n,"WebRtcStream");this.injectedDeps=o,this.authenticator=a,this.admissionGate=c,this.managerModule=d}bypassesRequestChain(s){return s.action==="stop"}onServerStarted(){this.viewerControlRejections.clear(),this.closed=!1,this.closing=null,this.unsubscribeListeners();let s=this.injectedDeps?this.injectedDeps.ownershipChanges:O;this.removeOwnershipListener=s?.()?.onDeviceOwnershipChange((c)=>{this.onOwnershipChanged(c)})??null;let n=this.injectedDeps?this.injectedDeps.sessionReleases:Ai,o=()=>{for(let c of this.resolvedDeps?.liveDeviceIds?.()??[])this.onOwnershipChanged(c)},a=this.injectedDeps?this.injectedDeps.observerReleases:bb;for(let c of[n?.subscribe(o),a?.subscribe(o)])if(c)this.removeListeners.push(c);this.registerLifecycleListeners()}registerLifecycleListeners(){let s=(this.injectedDeps?this.injectedDeps.deviceLifecycle:ma)?.(),n=s?.onDeviceRemoved((a)=>this.endDeviceStreams({deviceId:a,reason:"device_removed"})),o=s?.onDeviceIdentityChanged((a)=>this.checkDeviceActionable(a));for(let a of[n,o])if(a)this.removeListeners.push(a)}unsubscribeListeners(){this.removeOwnershipListener?.(),this.removeOwnershipListener=null;for(let s of this.removeListeners.splice(0))s()}onOwnershipChanged(s){this.reconcileOwnership(s).catch((n)=>{e.warn(`[WebRtcStream] ownership cleanup failed: ${r(n)}`,n)})}endDeviceStreams(s){if(this.closed)return;this.resolvedDeps?.endStreamsForDevice?.(s).catch((n)=>{e.warn(`[WebRtcStream] lifecycle cleanup failed: ${r(n)}`,n)})}checkDeviceActionable(s){if(this.closed||!this.resolvedDeps?.liveDeviceIds?.().includes(s))return;try{this.admissionGate.assertDeviceActionable(s,h)}catch(n){e.warn(`[WebRtcStream] identity no longer actionable for ${s}: ${r(n)}`),this.endDeviceStreams({deviceId:s,reason:"identity_quarantined"})}}async reconcileOwnership(s){if(this.closed||!this.resolvedDeps?.reconcileOwnership)return;await this.resolvedDeps.reconcileOwnership(s,(n)=>this.resolveLiveIdentity({sessionUuid:n,deviceId:s}))}resolveLiveIdentity(s){try{if(this.authenticator.resolveSubscriptionIdentity)return this.authenticator.resolveSubscriptionIdentity(s);return this.authenticator.authorize({...s,requireOwnership:!0}),{authEnabled:!0,sessionExists:!0,ownsDevice:!0}}catch(n){return e.warn(`[WebRtcStream] subscription identity check failed for deviceId=${s.deviceId}; ending session subscription`),{authEnabled:!0,sessionExists:!1,ownsDevice:!1}}}close(){if(this.closing)return this.closing;return this.closed=!0,this.viewerControlRejections.clear(),this.unsubscribeListeners(),this.closing=l(async()=>{await Promise.all([this.resolvedDeps?.stopAllStreams?.("daemon_shutdown"),super.close()])},{timer:this.timer,timeoutMs:W,label:"WebRTC socket server shutdown"}).catch((s)=>{e.warn(`[WebRtcStream] shutdown cleanup failed: ${r(s)}`,s)}),this.closing}async getDeps(){if(this.injectedDeps)return this.resolvedDeps=this.injectedDeps,this.injectedDeps;if(!this.resolvedDeps){let s=await this.managerModule.load();this.resolvedDeps={resolveDevice:x,startStream:s.startWebRtcStream,stopStream:s.stopWebRtcStream,stopStreamAsOwner:s.stopWebRtcStreamAsOwner,releaseOwnLeases:s.releaseWebRtcStreamOwnLeases,getControlContext:s.getWebRtcStreamControlContext,listStreams:s.listWebRtcStreams,getStream:s.getWebRtcStreamDescriptor,awaitReadiness:s.waitForWebRtcStreamReadiness,reconcileOwnership:s.reconcileWebRtcStreamsForDeviceOwnership,stopAllStreams:s.stopAllWebRtcStreams,getSubscriptionKind:s.getWebRtcSubscriptionKind,liveDeviceIds:s.getWebRtcStreamDeviceIds,endStreamsForDevice:s.endWebRtcStreamsForDevice}}return this.resolvedDeps}async handleRequest(s){try{this.assertOpen(),this.authorizeRequest(s);let n=this.authenticator.resolveSessionIdentity?.(s.sessionUuid)??s.sessionUuid,o=await this.getDeps();if(this.assertOpen(),s.action==="start")return await this.handleStart(o,s,n);let a=o.getSubscriptionKind?.({streamId:s.streamId,leaseId:s.leaseId,sessionUuid:n})??"owner",c=this.requestControlFacts({deps:o,request:s,sessionUuid:n,kind:a});return b(c.stopIdentity?.ownsDevice?"owner":a,{transport:"webrtc",action:s.action,target:c.target}),await this.dispatchRequest({deps:o,request:s,sessionUuid:n,kind:a,...c})}catch(n){return this.subscriptionErrorResponse({request:s,error:n})}}authorizeRequest(s){let n=s.action==="start"||!this.authenticator.resolveSubscriptionIdentity;this.authenticator.authorize({sessionUuid:s.sessionUuid,deviceId:n?s.deviceId:void 0,admitViewer:s.action==="start"})}requestControlFacts(s){let{deps:n,request:o,sessionUuid:a,kind:c}=s;if(o.action!=="start"&&o.action!=="stop")return{target:"stream"};let d=n.getControlContext?.({streamId:o.streamId,leaseId:o.leaseId,sessionUuid:a,deviceId:o.action==="start"?o.deviceId:void 0,overrides:R(o),compareParameters:o.action==="start"&&c==="viewer"});return{target:y({request:o,context:d}),addressedStreamId:d?.streamId,stopIdentity:this.resolveStopIdentity({request:o,deviceId:d?.deviceId})}}resolveStopIdentity(s){if(s.request.action!=="stop"||s.deviceId===void 0)return;let n=this.authenticator.resolveSubscriptionIdentity?.({sessionUuid:s.request.sessionUuid,deviceId:s.deviceId});return n?.authEnabled&&n.sessionExists?n:void 0}logViewerControlRejection(s){let n=this.authenticator.resolveSessionIdentity?.(s.sessionUuid)??s.sessionUuid,o=JSON.stringify([n,s.leaseId,s.action]),a=`[WebRtcStream] rejected viewer control: action=${s.action}`;if(this.viewerControlRejections.has(o)){e.debug(a);return}if(this.viewerControlRejections.add(o),this.viewerControlRejections.size>256){let c=this.viewerControlRejections.values().next().value;if(c!==void 0)this.viewerControlRejections.delete(c)}e.warn(a)}subscriptionErrorResponse({request:s,error:n}){let o=Mc(n);if("code"in o)return e.warn(`[WebRtcStream] Ownership refusal: ${r(n)}`,n),{...this.createErrorResponse(s.id,r(n)),...o,errorCode:o.code};if(n instanceof v)return this.logViewerControlRejection(s),{...this.createErrorResponse(s.id,n.message),errorCode:n.code,subscriptionKind:"viewer"};if(n instanceof fM)return e.info(`[WebRtcStream] reporting ended subscription: reason=${n.reason}`),{...this.createErrorResponse(s.id,n.message),reason:n.reason,subscriptionKind:n.subscriptionKind};throw n}async dispatchRequest(s){let{deps:n,request:o,sessionUuid:a,kind:c}=s;switch(o.action){case"start":return this.handleStart(n,o,a);case"stop":return this.handleStop(s);case"status":return this.handleStatus(n,o,a);case"list":return{id:o.id,success:!0,type:"webrtc_stream_response",action:"list",streams:n.listStreams(),subscriptionKind:o.leaseId?c:void 0};case"await":return this.handleAwait(n,o,a);default:throw new t(`Unsupported webrtcStream action: ${o.action}`)}}async handleStop(s){let{deps:n,request:o,sessionUuid:a,kind:c}=s,d={streamId:s.addressedStreamId??o.streamId,leaseId:o.leaseId,sessionUuid:a},m=s.stopIdentity?.ownsDevice&&n.stopStreamAsOwner?await n.stopStreamAsOwner(d):s.stopIdentity&&n.releaseOwnLeases?await n.releaseOwnLeases(d):await n.stopStream(o.streamId,o.leaseId,a);return{id:o.id,success:!0,type:"webrtc_stream_response",action:"stop",stream:m,subscriptionKind:c}}assertRenewalMayControl(s){let{deps:n,request:o,device:a,sessionUuid:c,subscriptionKind:d,renewingLease:m}=s;if(d!=="viewer"||!m)return;let S=n.getControlContext?.({deviceId:a.deviceId,leaseId:o.leaseId,sessionUuid:c,overrides:R(o),compareParameters:!0});b(d,{transport:"webrtc",action:"start",target:y({request:o,context:S})})}subscriberStartOverrides(s,n,o){if(n==="viewer"&&!o)return;let a=R(s);if(a.whipEndpoint)BQ(a.whipEndpoint);return a}async handleStart(s,n,o){if(n.deviceId!==void 0)this.admissionGate.assertDeviceActionable(n.deviceId,h);let a=await s.resolveDevice(n.deviceId,n.platform??"android");this.assertOpen(),this.admissionGate.assertDeviceActionable(a.deviceId,h),Lp(this.authenticator,{sessionUuid:n.sessionUuid,deviceId:a.deviceId,admitViewer:!0});let{subscriptionKind:c,ownsDevice:d,renewingLease:m}=this.startSubscription({deps:s,request:n,device:a,sessionUuid:o}),S=this.subscriberStartOverrides(n,c,m);if(!d)this.assertRenewalMayControl({deps:s,request:n,device:a,sessionUuid:o,subscriptionKind:c,renewingLease:m});let p=await s.startStream({device:a,streamId:n.streamId,leaseId:n.leaseId,sessionUuid:o,subscriptionKind:c,ownsDevice:d,overrides:S});return await this.recheckStartAdmission({deps:s,request:n,device:a,stream:p,sessionUuid:o}),e.info(`[WebRtcStream] started stream ${p.streamId} for device ${a.deviceId}`),{id:n.id,success:p.failure===null||p.failure===void 0,type:"webrtc_stream_response",action:"start",stream:p,subscriptionKind:s.getSubscriptionKind?.({streamId:p.streamId,leaseId:p.lease?.id,sessionUuid:o,existingLeaseOnly:!0})??c,failure:p.failure??null,error:p.failure?.message}}startSubscription(s){let{deps:n,request:o,device:a,sessionUuid:c}=s,d=o.leaseId?n.getSubscriptionKind?.({streamId:o.streamId,leaseId:o.leaseId,sessionUuid:c,allowEndedLease:!0,existingLeaseOnly:!0}):void 0,m=this.authenticator.resolveSubscriptionIdentity?.({sessionUuid:o.sessionUuid,deviceId:a.deviceId}),S=!!m?.authEnabled&&m.sessionExists&&m.ownsDevice;if(d!==void 0)return{subscriptionKind:d,ownsDevice:S,renewingLease:!0};return{subscriptionKind:m?BU(m):"owner",ownsDevice:S,renewingLease:!1}}async recheckStartAdmission(s){let{deps:n,request:o,device:a,stream:c,sessionUuid:d}=s;try{if(this.assertOpen(),Lp(this.authenticator,{sessionUuid:o.sessionUuid,deviceId:a.deviceId,admitViewer:!0}),c.lease?.id!==o.leaseId&&this.authenticator.resolveSubscriptionIdentity)await this.reconcileOwnership(a.deviceId)}catch(m){let S=c.lease?.id;if(S&&S!==o.leaseId)await l(()=>n.stopStream(c.streamId,S,d),{timer:this.timer,timeoutMs:W,label:"WebRTC rejected start lease cleanup"}).catch((p)=>{e.warn(`[WebRtcStream] rejected start cleanup failed: ${r(p)}`,p)});throw m}}async handleAwait(s,n,o){if(!n.streamId)throw new t("The WebRTC await action requires streamId.");if(!s.awaitReadiness)throw new t("WebRTC readiness waiting is unavailable.");let a=await s.awaitReadiness(n.streamId,n.readiness??"publishing",n.timeoutMs,{leaseId:n.leaseId,sessionUuid:o});return{id:n.id,success:a.failure===null||a.failure===void 0,type:"webrtc_stream_response",action:"await",stream:a,subscriptionKind:s.getSubscriptionKind?.({streamId:a.streamId,leaseId:a.lease?.id,sessionUuid:o})??"owner",failure:a.failure??null,error:a.failure?.message}}handleStatus(s,n,o){if(n.streamId){let a=s.getStream(n.streamId,n.leaseId,o);if(!a)throw new t(`No active WebRTC stream with id ${n.streamId}.`);return{id:n.id,success:a.failure===null||a.failure===void 0,type:"webrtc_stream_response",action:"status",stream:a,subscriptionKind:s.getSubscriptionKind?.({streamId:a.streamId,leaseId:a.lease?.id,sessionUuid:o})??"owner",failure:a.failure??null,error:a.failure?.message}}return{id:n.id,success:!0,type:"webrtc_stream_response",action:"list",streams:s.listStreams(),subscriptionKind:n.leaseId?s.getSubscriptionKind?.({leaseId:n.leaseId,sessionUuid:o})??"owner":void 0}}createErrorResponse(s,n){return{id:s,success:!1,type:"webrtc_stream_response",error:n}}assertOpen(){if(this.closed)throw new t("WebRTC stream socket server is closed.")}}var f=new In;function nG(){return f.instance?.getSocketPath()??$t(Oz)}async function iG(){await f.start(()=>new D)}async function oG(){await f.stop()}
|
|
3
|
+
export{BU,pM,mM,fM,hM,nG,iG,oG};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=10F0303C87B2604F64756E2164756E21
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ld,Zw,Jv,ke}from"./chunk-sfqe223f.js";var e=new Set([ld,ke.DEVICE_PORT,...Array.from({length:Jv-Zw+1},(o,r)=>Zw+r)]),HE=e;function iJ(o){e.add(o)}var t;function oJ(o){t=o}async function sJ(){await t?.stop("daemon")}
|
|
3
|
+
export{HE,iJ,oJ,sJ};
|
|
4
|
+
|
|
5
|
+
//# debugId=43C10041CF072A4864756E2164756E21
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
import{v}from"./chunk-
|
|
3
|
-
export{
|
|
2
|
+
import{v}from"./chunk-sfqe223f.js";import{h,I}from"./chunk-5wk1t46v.js";import{i,l}from"./chunk-r0vp315h.js";var _=h.MANAGED_ADB_SERVER.name,D=h.MANAGED_ADB_SERVER.legacyName,m=5000;function d(e=process.env){let r=I(h.MANAGED_ADB_SERVER,e);return r?.trim().toLowerCase()==="1"||r?.trim().toLowerCase()==="true"}async function WK(e={}){let r=e.environment??process.env;if(!d(r))return;let o=e.shutdownTimeoutMs??m,a=e.timer??i,t=new AbortController,s=(e.adbFactory??v).create(),n=`Managed ADB server shutdown timed out after ${o}ms`;await l(s.execute(["kill-server"],{timeoutMs:o,noRetry:!0,signal:t.signal}),{timer:a,timeoutMs:o,label:"Managed ADB server shutdown",timeoutError:()=>Error(n),onTimeout:()=>t.abort(Error(n))})}
|
|
3
|
+
export{WK};
|
|
4
4
|
|
|
5
|
-
//# debugId=
|
|
5
|
+
//# debugId=ED254857738E62C764756E2164756E21
|