@alwith/module-device 0.6.3 → 0.6.5

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.
Files changed (82) hide show
  1. package/dist/capture-window.d.ts +2 -0
  2. package/dist/capture-window.js +1 -0
  3. package/dist/{chunk-pxyqksfz.js → chunk-1r5rvxr9.js} +2 -2
  4. package/dist/chunk-1y1w0srz.js +2 -0
  5. package/dist/chunk-30kbebc6.js +2 -0
  6. package/dist/chunk-34h0m6pp.js +2 -0
  7. package/dist/chunk-35hpy1c6.js +2 -0
  8. package/dist/chunk-6m4eefxr.js +2 -0
  9. package/dist/chunk-a68z39dh.js +2 -0
  10. package/dist/{chunk-ge4zgdtr.js → chunk-bryvgfbf.js} +2 -2
  11. package/dist/{chunk-mx5dd23x.js → chunk-dv7gz9ee.js} +2 -2
  12. package/dist/{chunk-3zjj07q7.js → chunk-h83wwkt6.js} +2 -2
  13. package/dist/{chunk-3n6qrzdg.js → chunk-jdmxpq93.js} +2 -2
  14. package/dist/chunk-kr39jn06.js +2 -0
  15. package/dist/chunk-kza0t2p3.js +2 -0
  16. package/dist/chunk-pvbbmbn6.js +2 -0
  17. package/dist/chunk-z6e1m5r3.js +5 -0
  18. package/dist/{chunk-35bn393s.js → chunk-zsk39eje.js} +2 -2
  19. package/dist/generated/commands.d.ts +38 -0
  20. package/dist/generated/commands.js +1 -1
  21. package/dist/index.js +1 -1
  22. package/dist/preview/activity.js +1 -1
  23. package/dist/preview/bezel.js +1 -1
  24. package/dist/preview/capture-player.d.ts +6 -0
  25. package/dist/preview/capture-player.js +1 -0
  26. package/dist/preview/capture-preview.d.ts +6 -0
  27. package/dist/preview/capture-preview.js +1 -0
  28. package/dist/preview/captures.js +1 -1
  29. package/dist/preview/device-panel.js +1 -1
  30. package/dist/preview/gestures.js +1 -1
  31. package/dist/preview/index.d.ts +1 -0
  32. package/dist/preview/index.js +1 -1
  33. package/dist/preview/inspection.js +1 -1
  34. package/dist/preview/inspector.js +1 -1
  35. package/dist/preview/live-touch.js +1 -1
  36. package/dist/preview/locales.js +1 -1
  37. package/dist/preview/native-view.js +1 -1
  38. package/dist/preview/screens.js +1 -1
  39. package/dist/preview/types.d.ts +23 -0
  40. package/dist/tauri.d.ts +1 -0
  41. package/dist/tauri.js +1 -1
  42. package/native/darwin-arm64/THIRD_PARTY_NOTICES.md +7 -7
  43. package/native/darwin-arm64/alwith-device-helper +0 -0
  44. package/native/darwin-arm64/artifact.json +2 -2
  45. package/native/darwin-arm64/libalwith_native_device.dylib +0 -0
  46. package/native/win32-x64/THIRD_PARTY_NOTICES.md +7 -7
  47. package/native/win32-x64/alwith_native_device.dll +0 -0
  48. package/native/win32-x64/artifact.json +1 -1
  49. package/package.json +3 -3
  50. package/dist/chunk-40mwa0cy.js +0 -2
  51. package/dist/chunk-7n1fmm2p.js +0 -2
  52. package/dist/chunk-cyvmm690.js +0 -5
  53. package/dist/chunk-j6sbvhyq.js +0 -2
  54. package/dist/chunk-pa4b54h3.js +0 -2
  55. package/dist/chunk-tp1d4pv6.js +0 -2
  56. package/dist/chunk-xd4kq6pe.js +0 -2
  57. /package/native/darwin-arm64/licenses/{bytes-1.12.1 → bytes-1.12.2}/LICENSE +0 -0
  58. /package/native/darwin-arm64/licenses/{form_urlencoded-1.2.2 → form_urlencoded-1.2.3}/LICENSE-APACHE +0 -0
  59. /package/native/darwin-arm64/licenses/{form_urlencoded-1.2.2 → form_urlencoded-1.2.3}/LICENSE-MIT +0 -0
  60. /package/native/darwin-arm64/licenses/{hashbrown-0.17.1 → hashbrown-0.17.2}/LICENSE-APACHE +0 -0
  61. /package/native/darwin-arm64/licenses/{hashbrown-0.17.1 → hashbrown-0.17.2}/LICENSE-MIT +0 -0
  62. /package/native/darwin-arm64/licenses/{pin-project-lite-0.2.17 → pin-project-lite-0.2.18}/LICENSE-APACHE +0 -0
  63. /package/native/darwin-arm64/licenses/{pin-project-lite-0.2.17 → pin-project-lite-0.2.18}/LICENSE-MIT +0 -0
  64. /package/native/darwin-arm64/licenses/{smallvec-1.16.5 → smallvec-1.16.6}/LICENSE-APACHE +0 -0
  65. /package/native/darwin-arm64/licenses/{smallvec-1.16.5 → smallvec-1.16.6}/LICENSE-MIT +0 -0
  66. /package/native/darwin-arm64/licenses/{url-2.5.8 → url-2.5.9}/LICENSE-APACHE +0 -0
  67. /package/native/darwin-arm64/licenses/{url-2.5.8 → url-2.5.9}/LICENSE-MIT +0 -0
  68. /package/native/darwin-arm64/licenses/{uuid-1.29.2 → uuid-1.29.3}/LICENSE-APACHE +0 -0
  69. /package/native/darwin-arm64/licenses/{uuid-1.29.2 → uuid-1.29.3}/LICENSE-MIT +0 -0
  70. /package/native/win32-x64/licenses/{bytes-1.12.1 → bytes-1.12.2}/LICENSE +0 -0
  71. /package/native/win32-x64/licenses/{form_urlencoded-1.2.2 → form_urlencoded-1.2.3}/LICENSE-APACHE +0 -0
  72. /package/native/win32-x64/licenses/{form_urlencoded-1.2.2 → form_urlencoded-1.2.3}/LICENSE-MIT +0 -0
  73. /package/native/win32-x64/licenses/{hashbrown-0.17.1 → hashbrown-0.17.2}/LICENSE-APACHE +0 -0
  74. /package/native/win32-x64/licenses/{hashbrown-0.17.1 → hashbrown-0.17.2}/LICENSE-MIT +0 -0
  75. /package/native/win32-x64/licenses/{pin-project-lite-0.2.17 → pin-project-lite-0.2.18}/LICENSE-APACHE +0 -0
  76. /package/native/win32-x64/licenses/{pin-project-lite-0.2.17 → pin-project-lite-0.2.18}/LICENSE-MIT +0 -0
  77. /package/native/win32-x64/licenses/{smallvec-1.16.5 → smallvec-1.16.6}/LICENSE-APACHE +0 -0
  78. /package/native/win32-x64/licenses/{smallvec-1.16.5 → smallvec-1.16.6}/LICENSE-MIT +0 -0
  79. /package/native/win32-x64/licenses/{url-2.5.8 → url-2.5.9}/LICENSE-APACHE +0 -0
  80. /package/native/win32-x64/licenses/{url-2.5.8 → url-2.5.9}/LICENSE-MIT +0 -0
  81. /package/native/win32-x64/licenses/{uuid-1.29.2 → uuid-1.29.3}/LICENSE-APACHE +0 -0
  82. /package/native/win32-x64/licenses/{uuid-1.29.2 → uuid-1.29.3}/LICENSE-MIT +0 -0
@@ -1 +1 @@
1
- import{z}from"../chunk-j6sbvhyq.js";import"../chunk-40mwa0cy.js";import"../chunk-tp1d4pv6.js";import"../chunk-cyvmm690.js";import"../chunk-3n6qrzdg.js";import"../chunk-xd4kq6pe.js";import"../chunk-mx5dd23x.js";import"../chunk-35bn393s.js";import"../chunk-pa4b54h3.js";import"../chunk-ge4zgdtr.js";import"../chunk-arw91r4t.js";import"../chunk-pxyqksfz.js";export{z as DevicePanel};
1
+ import{R}from"../chunk-30kbebc6.js";import"../chunk-1r5rvxr9.js";import"../chunk-z6e1m5r3.js";import"../chunk-arw91r4t.js";import"../chunk-dv7gz9ee.js";import"../chunk-kza0t2p3.js";import"../chunk-bryvgfbf.js";import"../chunk-kr39jn06.js";import"../chunk-6m4eefxr.js";import"../chunk-34h0m6pp.js";import"../chunk-jdmxpq93.js";import"../chunk-zsk39eje.js";import"../chunk-a68z39dh.js";export{R as DevicePanel};
@@ -1 +1 @@
1
- import{v,o,s,f,b,l,c,M}from"../chunk-40mwa0cy.js";export{s as ANDROID_SHORTCUTS,o as IOS_SHORTCUTS,v as KEY_CODES,l as keyGesture,M as pathGesture,c as pointFor,f as releaseGesture,b as shortcutKey};
1
+ import{N,u,d,E,z,p,m,F}from"../chunk-a68z39dh.js";export{d as ANDROID_SHORTCUTS,u as IOS_SHORTCUTS,N as KEY_CODES,p as keyGesture,F as pathGesture,m as pointFor,E as releaseGesture,z as shortcutKey};
@@ -7,3 +7,4 @@ export type { PanelLabels } from "./locales";
7
7
  export { MenuButton } from "./menu";
8
8
  export type { MenuEntry } from "./menu";
9
9
  export type { AttachmentInfo, DeviceBridge, DeviceActivity, DeviceCapture, DeviceGesture, DeviceOwner, DevicePanelProps, LaunchedApp, LogEntry, LogPage, ManagedDevice } from "./types";
10
+ export { CapturePreview } from "./capture-preview";
@@ -1 +1 @@
1
- import{P,i,u,d}from"../chunk-xd4kq6pe.js";import"../chunk-ge4zgdtr.js";import"../chunk-pa4b54h3.js";import{v,o,s,f,b,l,c}from"../chunk-40mwa0cy.js";import"../chunk-cyvmm690.js";import"../chunk-pxyqksfz.js";import"../chunk-mx5dd23x.js";import{a,r,t}from"../chunk-35bn393s.js";import{n}from"../chunk-arw91r4t.js";import"../chunk-tp1d4pv6.js";import"../chunk-3n6qrzdg.js";import{z}from"../chunk-j6sbvhyq.js";export{s as ANDROID_SHORTCUTS,d as Bezel,z as DevicePanel,P as FRAMES,o as IOS_SHORTCUTS,v as KEY_CODES,n as MenuButton,a as deviceLocales,t as fill,i as frameKindFor,l as keyGesture,c as pointFor,f as releaseGesture,r as resolveDeviceLabels,u as screenPlacement,b as shortcutKey};
1
+ import{S,i,l,c}from"../chunk-kza0t2p3.js";import"../chunk-bryvgfbf.js";import"../chunk-34h0m6pp.js";import"../chunk-6m4eefxr.js";import"../chunk-kr39jn06.js";import{N,u,d,E,z,p,m}from"../chunk-a68z39dh.js";import"../chunk-z6e1m5r3.js";import"../chunk-1r5rvxr9.js";import"../chunk-dv7gz9ee.js";import{o,s,t}from"../chunk-zsk39eje.js";import{n}from"../chunk-arw91r4t.js";import"../chunk-jdmxpq93.js";import{R}from"../chunk-30kbebc6.js";import{T}from"../chunk-1y1w0srz.js";export{d as ANDROID_SHORTCUTS,c as Bezel,T as CapturePreview,R as DevicePanel,S as FRAMES,u as IOS_SHORTCUTS,N as KEY_CODES,n as MenuButton,o as deviceLocales,t as fill,i as frameKindFor,p as keyGesture,m as pointFor,E as releaseGesture,s as resolveDeviceLabels,l as screenPlacement,z as shortcutKey};
@@ -1 +1 @@
1
- import{S,w,k}from"../chunk-cyvmm690.js";export{k as elementContext,w as elementsAt,S as parseInspection};
1
+ import{b,w,x}from"../chunk-z6e1m5r3.js";export{x as elementContext,w as elementsAt,b as parseInspection};
@@ -1 +1 @@
1
- import{m,E}from"../chunk-pxyqksfz.js";export{E as Inspector,m as inspectionLabels};
1
+ import{g,y}from"../chunk-1r5rvxr9.js";export{y as Inspector,g as inspectionLabels};
@@ -1 +1 @@
1
- import{p}from"../chunk-mx5dd23x.js";export{p as LiveTouch};
1
+ import{h}from"../chunk-dv7gz9ee.js";export{h as LiveTouch};
@@ -1 +1 @@
1
- import{a,r,t}from"../chunk-35bn393s.js";export{a as deviceLocales,t as fill,r as resolveDeviceLabels};
1
+ import{o,s,t}from"../chunk-zsk39eje.js";export{o as deviceLocales,t as fill,s as resolveDeviceLabels};
@@ -1 +1 @@
1
- import{y,R,x}from"../chunk-tp1d4pv6.js";export{y as intersect,x as useNativeView,R as viewLayout};
1
+ import{P,B,r}from"../chunk-34h0m6pp.js";export{P as intersect,r as useNativeView,B as viewLayout};
@@ -1 +1 @@
1
- import{D,A}from"../chunk-3n6qrzdg.js";import"../chunk-35bn393s.js";export{D as AttachScreen,A as ConsentScreen};
1
+ import{A,C}from"../chunk-jdmxpq93.js";import"../chunk-zsk39eje.js";export{A as AttachScreen,C as ConsentScreen};
@@ -154,7 +154,30 @@ export interface DeviceCapture {
154
154
  createdAt: number;
155
155
  bytes: number;
156
156
  }
157
+ export interface CapturePlayback {
158
+ duration: number;
159
+ position: number;
160
+ playing: boolean;
161
+ ready: boolean;
162
+ }
163
+ export type CapturePlayerAction = {
164
+ type: "play";
165
+ } | {
166
+ type: "pause";
167
+ } | {
168
+ type: "seek";
169
+ position: number;
170
+ };
171
+ export interface CapturePlayer {
172
+ mount(id: string, layout: NativeViewLayout): Promise<string>;
173
+ update(id: string, layout: NativeViewLayout): Promise<void>;
174
+ control(id: string, action: CapturePlayerAction): Promise<void>;
175
+ status(id: string): Promise<CapturePlayback>;
176
+ unmount(id: string): Promise<void>;
177
+ }
157
178
  export interface DeviceBridge {
179
+ openCapture?(capture: DeviceCapture): Promise<void>;
180
+ capturePlayer?: CapturePlayer;
158
181
  nativeView?: NativeDeviceView;
159
182
  listDevices(platform: string): Promise<ManagedDevice[]>;
160
183
  attach(udid: string | undefined, platform: string): Promise<AttachmentInfo>;
package/dist/tauri.d.ts CHANGED
@@ -32,3 +32,4 @@ export declare function callDeviceTool(name: string, args: Record<string, unknow
32
32
  signal: AbortSignal;
33
33
  projectPath?: string;
34
34
  }): Promise<DeviceToolResult>;
35
+ export { openCaptureWindow } from "./capture-window";
package/dist/tauri.js CHANGED
@@ -1 +1 @@
1
- import{e,g}from"./chunk-7n1fmm2p.js";import"./chunk-35bn393s.js";import{h}from"./chunk-3zjj07q7.js";import{convertFileSrc as w,isTauri as y}from"@tauri-apps/api/core";function v(n){if(n==="ios"||n==="android")return n;throw Error(`Unsupported device platform: ${n}`)}function A(n){return{nativeView:{supported:(t)=>e.nativeViewSupported({platform:v(t)}),mount:(t,r)=>e.nativeViewMount({sessionId:n,udid:t,layout:r}),update:async(t,r)=>{await e.nativeViewUpdate({id:t,layout:r})},unmount:async(t)=>{await e.nativeViewUnmount({id:t})},status:(t)=>e.nativeViewStatus({id:t})},listDevices:(t)=>e.list({platform:v(t)}),attach:(t,r)=>e.attach({sessionId:n,platform:v(r),udid:t??null}),detach:async(t)=>{await e.detach({udid:t})},captureFrame:(t)=>e.frame({udid:t}),gesture:async(t,r)=>{await e.gesture({udid:t,gesture:r})},readActivity:()=>e.activity({sessionId:n}),listCaptures:()=>e.captureList({sessionId:n}),captureUrl:async(t)=>w(await e.captureAccess({sessionId:n,id:t})),removeCapture:async(t)=>{await e.captureRemove({sessionId:n,id:t})},monitorDensity:()=>e.monitorDensity(),capabilities:(t)=>e.capabilities({sessionId:n,udid:t}),inspect:(t)=>e.inspect({sessionId:n,udid:t}),appearance:(t)=>e.appearance({udid:t}),setAppearance:async(t,r)=>{await e.setAppearance({udid:t,mode:r})},setStatusBar:async(t,r)=>{await e.setStatusBar({udid:t,look:r})},shutdown:async(t)=>{await e.shutdown({udid:t})},restart:async(t)=>{await e.restart({udid:t})},readLogs:(t,r)=>e.logs({udid:t,query:{sinceSeq:r.sinceSeq??null,tail:r.tail??null,minLevel:r.minLevel??null,filter:r.filter??null}}),startRecording:(t)=>e.recordStart({udid:t}),stopRecording:(t)=>e.recordStop({udid:t}),saveScreenshot:(t)=>e.saveScreenshot({udid:t}),subscribe:(t,r)=>{if(!y())return()=>{};let s=!1,u,c=(a)=>a.filter((d)=>d.owner.type==="development_session"&&d.owner.id===n),p=-1;return g["device:attachments"].listen(({payload:a})=>{if(!s&&a.revision>p)p=a.revision,t(c(a.attachments))}).then(async(a)=>{if(s){a();return}u=a;let d=p,l=await e.attachments();if(!s&&p===d)t(c(l))}).catch((a)=>{if(!s)r?.(a)}),()=>{s=!0,u?.()}}}}async function x(){if(!y())return{mcpServers:[]};let n=await e.context();if(!n)return{mcpServers:[]};let t=await h(()=>Promise.resolve(n.registration),n.carrier),r=n.registration.token;return{mcpServers:t.mcpServers,...t.appendSystemPrompt?{appendSystemPrompt:t.appendSystemPrompt}:{},bind:async(s)=>{await e.bind({token:r,sessionId:s})}}}async function P(){let n=await e.tools();if(!Array.isArray(n)||n.some((t)=>!t||typeof t!=="object"||Array.isArray(t)||typeof t.name!=="string"||typeof t.description!=="string"||!t.inputSchema||typeof t.inputSchema!=="object"||Array.isArray(t.inputSchema)))throw Error("Invalid device tool definitions");return n}async function T(n,t,r){let{sessionId:s,requestId:u,signal:c}=r;c.throwIfAborted();let p=t.platform==="android"?"android":"ios",a=r.projectPath?`alwith:device:target:${JSON.stringify([r.projectPath,p])}`:null,d=t;if(n==="control"&&t.action==="attach"&&t.udid===void 0&&a){let o=localStorage.getItem(a);if(o){if((await e.list({platform:p})).some((i)=>i.id===o))d={...t,udid:o}}}c.throwIfAborted();let l=()=>{e.toolCancel({sessionId:s,requestId:u}).catch((o)=>console.error("Cannot cancel device operation",o))};c.addEventListener("abort",l,{once:!0});try{let o=await e.toolCall({sessionId:s,requestId:u,name:n,arguments:d});if(c.throwIfAborted(),!o||typeof o!=="object"||!("isError"in o)||typeof o.isError!=="boolean"||!("content"in o)||!Array.isArray(o.content)||o.content.some((i)=>!i||typeof i!=="object"||!("type"in i)||(i.type==="text"?!("text"in i)||typeof i.text!=="string":i.type==="image"?!("data"in i)||typeof i.data!=="string"||!("mimeType"in i)||typeof i.mimeType!=="string":!0)))throw Error("Invalid device tool result");let f=o;if(!f.isError&&n==="control"&&t.action==="attach"&&a){let i=f.content.find((m)=>m.type==="text");if(i?.type==="text"){let m=JSON.parse(i.text);if(typeof m.attachment?.udid==="string")localStorage.setItem(a,m.attachment.udid)}}return f}finally{c.removeEventListener("abort",l)}}export{T as callDeviceTool,A as deviceBridge,x as deviceSessionContext,P as deviceToolDefinitions};
1
+ import{e,v}from"./chunk-35hpy1c6.js";import"./chunk-zsk39eje.js";import{f}from"./chunk-h83wwkt6.js";import{L}from"./chunk-pvbbmbn6.js";import{convertFileSrc as h,isTauri as g}from"@tauri-apps/api/core";function w(r){if(r==="ios"||r==="android")return r;throw Error(`Unsupported device platform: ${r}`)}function D(r){return{capturePlayer:{mount:(t,n)=>e.capturePlayerMount({sessionId:r,id:t,layout:n}),update:async(t,n)=>{await e.capturePlayerUpdate({id:t,layout:n})},control:async(t,n)=>{await e.capturePlayerControl({id:t,action:n})},status:(t)=>e.capturePlayerStatus({id:t}),unmount:async(t)=>{await e.capturePlayerUnmount({id:t})}},nativeView:{supported:(t)=>e.nativeViewSupported({platform:w(t)}),mount:(t,n)=>e.nativeViewMount({sessionId:r,udid:t,layout:n}),update:async(t,n)=>{await e.nativeViewUpdate({id:t,layout:n})},unmount:async(t)=>{await e.nativeViewUnmount({id:t})},status:(t)=>e.nativeViewStatus({id:t})},listDevices:(t)=>e.list({platform:w(t)}),attach:(t,n)=>e.attach({sessionId:r,platform:w(n),udid:t??null}),detach:async(t)=>{await e.detach({udid:t})},captureFrame:(t)=>e.frame({udid:t}),gesture:async(t,n)=>{await e.gesture({udid:t,gesture:n})},readActivity:()=>e.activity({sessionId:r}),listCaptures:()=>e.captureList({sessionId:r}),captureUrl:async(t)=>h(await e.captureAccess({sessionId:r,id:t})),removeCapture:async(t)=>{await e.captureRemove({sessionId:r,id:t})},monitorDensity:()=>e.monitorDensity(),capabilities:(t)=>e.capabilities({sessionId:r,udid:t}),inspect:(t)=>e.inspect({sessionId:r,udid:t}),appearance:(t)=>e.appearance({udid:t}),setAppearance:async(t,n)=>{await e.setAppearance({udid:t,mode:n})},setStatusBar:async(t,n)=>{await e.setStatusBar({udid:t,look:n})},shutdown:async(t)=>{await e.shutdown({udid:t})},restart:async(t)=>{await e.restart({udid:t})},readLogs:(t,n)=>e.logs({udid:t,query:{sinceSeq:n.sinceSeq??null,tail:n.tail??null,minLevel:n.minLevel??null,filter:n.filter??null}}),startRecording:(t)=>e.recordStart({udid:t}),stopRecording:(t)=>e.recordStop({udid:t}),saveScreenshot:(t)=>e.saveScreenshot({udid:t}),subscribe:(t,n)=>{if(!g())return()=>{};let s=!1,d,c=(a)=>a.filter((u)=>u.owner.type==="development_session"&&u.owner.id===r),p=-1;return v["device:attachments"].listen(({payload:a})=>{if(!s&&a.revision>p)p=a.revision,t(c(a.attachments))}).then(async(a)=>{if(s){a();return}d=a;let u=p,l=await e.attachments();if(!s&&p===u)t(c(l))}).catch((a)=>{if(!s)n?.(a)}),()=>{s=!0,d?.()}}}}async function A(){if(!g())return{mcpServers:[]};let r=await e.context();if(!r)return{mcpServers:[]};let t=await f(()=>Promise.resolve(r.registration),r.carrier),n=r.registration.token;return{mcpServers:t.mcpServers,...t.appendSystemPrompt?{appendSystemPrompt:t.appendSystemPrompt}:{},bind:async(s)=>{await e.bind({token:n,sessionId:s})}}}async function x(){let r=await e.tools();if(!Array.isArray(r)||r.some((t)=>!t||typeof t!=="object"||Array.isArray(t)||typeof t.name!=="string"||typeof t.description!=="string"||!t.inputSchema||typeof t.inputSchema!=="object"||Array.isArray(t.inputSchema)))throw Error("Invalid device tool definitions");return r}async function T(r,t,n){let{sessionId:s,requestId:d,signal:c}=n;c.throwIfAborted();let p=t.platform==="android"?"android":"ios",a=n.projectPath?`alwith:device:target:${JSON.stringify([n.projectPath,p])}`:null,u=t;if(r==="control"&&t.action==="attach"&&t.udid===void 0&&a){let o=localStorage.getItem(a);if(o){if((await e.list({platform:p})).some((i)=>i.id===o))u={...t,udid:o}}}c.throwIfAborted();let l=()=>{e.toolCancel({sessionId:s,requestId:d}).catch((o)=>console.error("Cannot cancel device operation",o))};c.addEventListener("abort",l,{once:!0});try{let o=await e.toolCall({sessionId:s,requestId:d,name:r,arguments:u});if(c.throwIfAborted(),!o||typeof o!=="object"||!("isError"in o)||typeof o.isError!=="boolean"||!("content"in o)||!Array.isArray(o.content)||o.content.some((i)=>!i||typeof i!=="object"||!("type"in i)||(i.type==="text"?!("text"in i)||typeof i.text!=="string":i.type==="image"?!("data"in i)||typeof i.data!=="string"||!("mimeType"in i)||typeof i.mimeType!=="string":!0)))throw Error("Invalid device tool result");let m=o;if(!m.isError&&r==="control"&&t.action==="attach"&&a){let i=m.content.find((y)=>y.type==="text");if(i?.type==="text"){let y=JSON.parse(i.text);if(typeof y.attachment?.udid==="string")localStorage.setItem(a,y.attachment.udid)}}return m}finally{c.removeEventListener("abort",l)}}export{T as callDeviceTool,D as deviceBridge,A as deviceSessionContext,x as deviceToolDefinitions,L as openCaptureWindow};
@@ -13,7 +13,7 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
13
13
  - block2@0.6.2: MIT; licenses/block2-0.6.2/; source: https://raw.githubusercontent.com/madsmtm/objc2/b4167b582b2f75f9a1be75495c41b765344fd03c/LICENSE.md
14
14
  - bytemuck@1.25.2: Zlib OR Apache-2.0 OR MIT; licenses/bytemuck-1.25.2/
15
15
  - byteorder-lite@0.1.0: Unlicense OR MIT; licenses/byteorder-lite-0.1.0/
16
- - bytes@1.12.1: MIT; licenses/bytes-1.12.1/
16
+ - bytes@1.12.2: MIT; licenses/bytes-1.12.2/
17
17
  - cfg-if@1.0.5: MIT OR Apache-2.0; licenses/cfg-if-1.0.5/
18
18
  - crc32fast@1.5.5: MIT OR Apache-2.0; licenses/crc32fast-1.5.5/
19
19
  - dirs@7.0.0: MIT OR Apache-2.0; licenses/dirs-7.0.0/
@@ -28,12 +28,12 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
28
28
  - flate2@1.1.11: MIT OR Apache-2.0; licenses/flate2-1.1.11/
29
29
  - fnv@1.0.7: Apache-2.0 / MIT; licenses/fnv-1.0.7/
30
30
  - foldhash@0.2.0: Zlib; licenses/foldhash-0.2.0/
31
- - form_urlencoded@1.2.2: MIT OR Apache-2.0; licenses/form_urlencoded-1.2.2/
31
+ - form_urlencoded@1.2.3: MIT OR Apache-2.0; licenses/form_urlencoded-1.2.3/
32
32
  - futures-core@0.3.34: MIT OR Apache-2.0; licenses/futures-core-0.3.34/
33
33
  - futures-sink@0.3.34: MIT OR Apache-2.0; licenses/futures-sink-0.3.34/
34
34
  - getrandom@0.4.3: MIT OR Apache-2.0; licenses/getrandom-0.4.3/
35
35
  - h2@0.4.20: MIT; licenses/h2-0.4.20/
36
- - hashbrown@0.17.1: MIT OR Apache-2.0; licenses/hashbrown-0.17.1/
36
+ - hashbrown@0.17.2: MIT OR Apache-2.0; licenses/hashbrown-0.17.2/
37
37
  - http@1.5.0: MIT OR Apache-2.0; licenses/http-1.5.0/
38
38
  - icu_collections@2.4.0: Unicode-3.0; licenses/icu_collections-2.4.0/
39
39
  - icu_locale_core@2.4.0: Unicode-3.0; licenses/icu_locale_core-2.4.0/
@@ -64,7 +64,7 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
64
64
  - once_cell@1.21.4: MIT OR Apache-2.0; licenses/once_cell-1.21.4/
65
65
  - option-ext@0.2.0: MPL-2.0; licenses/option-ext-0.2.0/
66
66
  - percent-encoding@2.3.2: MIT OR Apache-2.0; licenses/percent-encoding-2.3.2/
67
- - pin-project-lite@0.2.17: Apache-2.0 OR MIT; licenses/pin-project-lite-0.2.17/
67
+ - pin-project-lite@0.2.18: Apache-2.0 OR MIT; licenses/pin-project-lite-0.2.18/
68
68
  - png@0.18.1: MIT OR Apache-2.0; licenses/png-0.18.1/
69
69
  - potential_utf@0.1.6: Unicode-3.0; licenses/potential_utf-0.1.6/
70
70
  - proc-macro2@1.0.107: MIT OR Apache-2.0; licenses/proc-macro2-1.0.107/
@@ -82,7 +82,7 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
82
82
  - signal-hook-registry@1.4.8: MIT OR Apache-2.0; licenses/signal-hook-registry-1.4.8/
83
83
  - simd-adler32@0.3.10: MIT; licenses/simd-adler32-0.3.10/
84
84
  - slab@0.4.12: MIT; licenses/slab-0.4.12/
85
- - smallvec@1.16.5: MIT OR Apache-2.0; licenses/smallvec-1.16.5/
85
+ - smallvec@1.16.6: MIT OR Apache-2.0; licenses/smallvec-1.16.6/
86
86
  - socket2@0.6.5: MIT OR Apache-2.0; licenses/socket2-0.6.5/
87
87
  - specta@2.0.0-rc.28: MIT; licenses/specta-2.0.0-rc.28/; source: https://raw.githubusercontent.com/specta-rs/specta/82278bb5fef379b755af41b831ae3d3533e55b39/LICENSE
88
88
  - specta-macros@2.0.0-rc.28: MIT; licenses/specta-macros-2.0.0-rc.28/; source: https://raw.githubusercontent.com/specta-rs/specta/82278bb5fef379b755af41b831ae3d3533e55b39/LICENSE
@@ -98,10 +98,10 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
98
98
  - tracing@0.1.44: MIT; licenses/tracing-0.1.44/
99
99
  - tracing-core@0.1.36: MIT; licenses/tracing-core-0.1.36/
100
100
  - unicode-ident@1.0.27: (MIT OR Apache-2.0) AND Unicode-3.0; licenses/unicode-ident-1.0.27/
101
- - url@2.5.8: MIT OR Apache-2.0; licenses/url-2.5.8/
101
+ - url@2.5.9: MIT OR Apache-2.0; licenses/url-2.5.9/
102
102
  - utf8_iter@1.1.0: Apache-2.0 OR MIT; licenses/utf8_iter-1.1.0/
103
103
  - utf_types@1.0.0: Apache-2.0 OR MIT; licenses/utf_types-1.0.0/
104
- - uuid@1.29.2: Apache-2.0 OR MIT; licenses/uuid-1.29.2/
104
+ - uuid@1.29.3: Apache-2.0 OR MIT; licenses/uuid-1.29.3/
105
105
  - writeable@0.6.4: Unicode-3.0; licenses/writeable-0.6.4/
106
106
  - yoke@0.8.4: Unicode-3.0; licenses/yoke-0.8.4/
107
107
  - yoke-derive@0.8.4: Unicode-3.0; licenses/yoke-derive-0.8.4/
@@ -4,10 +4,10 @@
4
4
  "abi": 1,
5
5
  "target": "aarch64-apple-darwin",
6
6
  "binary": "libalwith_native_device.dylib",
7
- "sha256": "44a397920967b84d0a3cd5ee6f17de9543b30eb2ff0dca37f63afb356e45d197",
7
+ "sha256": "d60f26aabda090d096a197b6822173109c2c104f75f8b821268c87f873750ac3",
8
8
  "helper": {
9
9
  "binary": "alwith-device-helper",
10
- "sha256": "57e36265453af4e13937027d49bf14ec9e8576f7c51fbd71d70c15e0839936f3",
10
+ "sha256": "82edaab6b72d37a9df7faf82c05d7c7fbb7c115dccac1a7493272daeb7135d96",
11
11
  "revision": "c793afad2a31092628f7013cf1aa96f266c85024"
12
12
  }
13
13
  }
@@ -11,7 +11,7 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
11
11
  - bitflags@2.13.2: MIT OR Apache-2.0; licenses/bitflags-2.13.2/
12
12
  - bytemuck@1.25.2: Zlib OR Apache-2.0 OR MIT; licenses/bytemuck-1.25.2/
13
13
  - byteorder-lite@0.1.0: Unlicense OR MIT; licenses/byteorder-lite-0.1.0/
14
- - bytes@1.12.1: MIT; licenses/bytes-1.12.1/
14
+ - bytes@1.12.2: MIT; licenses/bytes-1.12.2/
15
15
  - cfg-if@1.0.5: MIT OR Apache-2.0; licenses/cfg-if-1.0.5/
16
16
  - crc32fast@1.5.5: MIT OR Apache-2.0; licenses/crc32fast-1.5.5/
17
17
  - dirs@7.0.0: MIT OR Apache-2.0; licenses/dirs-7.0.0/
@@ -24,12 +24,12 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
24
24
  - flate2@1.1.11: MIT OR Apache-2.0; licenses/flate2-1.1.11/
25
25
  - fnv@1.0.7: Apache-2.0 / MIT; licenses/fnv-1.0.7/
26
26
  - foldhash@0.2.0: Zlib; licenses/foldhash-0.2.0/
27
- - form_urlencoded@1.2.2: MIT OR Apache-2.0; licenses/form_urlencoded-1.2.2/
27
+ - form_urlencoded@1.2.3: MIT OR Apache-2.0; licenses/form_urlencoded-1.2.3/
28
28
  - futures-core@0.3.34: MIT OR Apache-2.0; licenses/futures-core-0.3.34/
29
29
  - futures-sink@0.3.34: MIT OR Apache-2.0; licenses/futures-sink-0.3.34/
30
30
  - getrandom@0.4.3: MIT OR Apache-2.0; licenses/getrandom-0.4.3/
31
31
  - h2@0.4.20: MIT; licenses/h2-0.4.20/
32
- - hashbrown@0.17.1: MIT OR Apache-2.0; licenses/hashbrown-0.17.1/
32
+ - hashbrown@0.17.2: MIT OR Apache-2.0; licenses/hashbrown-0.17.2/
33
33
  - http@1.5.0: MIT OR Apache-2.0; licenses/http-1.5.0/
34
34
  - icu_collections@2.4.0: Unicode-3.0; licenses/icu_collections-2.4.0/
35
35
  - icu_locale_core@2.4.0: Unicode-3.0; licenses/icu_locale_core-2.4.0/
@@ -55,7 +55,7 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
55
55
  - once_cell@1.21.4: MIT OR Apache-2.0; licenses/once_cell-1.21.4/
56
56
  - option-ext@0.2.0: MPL-2.0; licenses/option-ext-0.2.0/
57
57
  - percent-encoding@2.3.2: MIT OR Apache-2.0; licenses/percent-encoding-2.3.2/
58
- - pin-project-lite@0.2.17: Apache-2.0 OR MIT; licenses/pin-project-lite-0.2.17/
58
+ - pin-project-lite@0.2.18: Apache-2.0 OR MIT; licenses/pin-project-lite-0.2.18/
59
59
  - png@0.18.1: MIT OR Apache-2.0; licenses/png-0.18.1/
60
60
  - potential_utf@0.1.6: Unicode-3.0; licenses/potential_utf-0.1.6/
61
61
  - proc-macro2@1.0.107: MIT OR Apache-2.0; licenses/proc-macro2-1.0.107/
@@ -71,7 +71,7 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
71
71
  - serde_json@1.0.154: MIT OR Apache-2.0; licenses/serde_json-1.0.154/
72
72
  - simd-adler32@0.3.10: MIT; licenses/simd-adler32-0.3.10/
73
73
  - slab@0.4.12: MIT; licenses/slab-0.4.12/
74
- - smallvec@1.16.5: MIT OR Apache-2.0; licenses/smallvec-1.16.5/
74
+ - smallvec@1.16.6: MIT OR Apache-2.0; licenses/smallvec-1.16.6/
75
75
  - socket2@0.6.5: MIT OR Apache-2.0; licenses/socket2-0.6.5/
76
76
  - specta@2.0.0-rc.28: MIT; licenses/specta-2.0.0-rc.28/; source: https://raw.githubusercontent.com/specta-rs/specta/82278bb5fef379b755af41b831ae3d3533e55b39/LICENSE
77
77
  - specta-macros@2.0.0-rc.28: MIT; licenses/specta-macros-2.0.0-rc.28/; source: https://raw.githubusercontent.com/specta-rs/specta/82278bb5fef379b755af41b831ae3d3533e55b39/LICENSE
@@ -87,10 +87,10 @@ ALwith native implementations are proprietary. Dependencies retain their own lic
87
87
  - tracing@0.1.44: MIT; licenses/tracing-0.1.44/
88
88
  - tracing-core@0.1.36: MIT; licenses/tracing-core-0.1.36/
89
89
  - unicode-ident@1.0.27: (MIT OR Apache-2.0) AND Unicode-3.0; licenses/unicode-ident-1.0.27/
90
- - url@2.5.8: MIT OR Apache-2.0; licenses/url-2.5.8/
90
+ - url@2.5.9: MIT OR Apache-2.0; licenses/url-2.5.9/
91
91
  - utf8_iter@1.1.0: Apache-2.0 OR MIT; licenses/utf8_iter-1.1.0/
92
92
  - utf_types@1.0.0: Apache-2.0 OR MIT; licenses/utf_types-1.0.0/
93
- - uuid@1.29.2: Apache-2.0 OR MIT; licenses/uuid-1.29.2/
93
+ - uuid@1.29.3: Apache-2.0 OR MIT; licenses/uuid-1.29.3/
94
94
  - windows-link@0.2.1: MIT OR Apache-2.0; licenses/windows-link-0.2.1/
95
95
  - windows-sys@0.61.2: MIT OR Apache-2.0; licenses/windows-sys-0.61.2/
96
96
  - writeable@0.6.4: Unicode-3.0; licenses/writeable-0.6.4/
@@ -4,5 +4,5 @@
4
4
  "abi": 1,
5
5
  "target": "x86_64-pc-windows-msvc",
6
6
  "binary": "alwith_native_device.dll",
7
- "sha256": "2dae797fe81d2f05604d2c54502b483a5e8be6ec55e515b24d06661a6bdb9e20"
7
+ "sha256": "340d35d8ae4f7ae445a11db157446aec4b5f366022ce729910f6317421f6844b"
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alwith/module-device",
3
- "version": "0.6.3",
3
+ "version": "0.6.5",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "files": [
@@ -33,12 +33,12 @@
33
33
  "scripts": {
34
34
  "build": "bun ../../scripts/build-npm.ts",
35
35
  "prepack": "bun run build && bun ../../scripts/verify-module-package.ts device",
36
- "test": "bun test src",
36
+ "test": "bun test --parallel=4 ./src",
37
37
  "test:rust": "cargo test --manifest-path rust/Cargo.toml"
38
38
  },
39
39
  "dependencies": {
40
40
  "@nyssance/shadcn": "^4.23.4",
41
- "lucide-react": "^1.73.0",
41
+ "lucide-react": "^1.77.0",
42
42
  "sonner": "^2.0.8"
43
43
  },
44
44
  "peerDependencies": {
@@ -1,2 +0,0 @@
1
- var v={Enter:40,Backspace:42,ArrowRight:79,ArrowLeft:80,ArrowDown:81,ArrowUp:82,Delete:76,Home:74,End:77,PageUp:75,PageDown:78},o={"meta+shift+h":{type:"button",name:"HOME"},"meta+l":{type:"button",name:"LOCK"},"ctrl+meta+z":{type:"shake"},"meta+shift+a":{type:"toggleAppearance"}},s={"meta+shift+h":{type:"button",name:"HOME"},"meta+shift+b":{type:"button",name:"BACK"},"meta+shift+r":{type:"button",name:"RECENTS"},"meta+l":{type:"button",name:"LOCK"},"meta+shift+a":{type:"toggleAppearance"}};function f(e,t){let r=t.t-e.t;if(Math.hypot(t.clientX-e.clientX,t.clientY-e.clientY)<6)return r>=500?{type:"longPress",x:e.x,y:e.y,duration:r/1000}:{type:"tap",x:e.x,y:e.y};return{type:"swipe",x1:e.x,y1:e.y,x2:t.x,y2:t.y,duration:Math.max(0.1,r/1000)}}function b(e){return[e.altKey&&"alt",e.ctrlKey&&"ctrl",e.metaKey&&"meta",e.shiftKey&&"shift",e.key.toLowerCase()].filter(Boolean).join("+")}function l(e,t){if(e.metaKey||e.ctrlKey)return t[b(e)]??null;let r=v[e.key];if(r!==void 0)return{type:"key",code:r};return e.key.length===1?{type:"text",value:e.key}:null}function c(e,t,r,i,n,u=0){if(e.width<=0||e.height<=0||i<=0||n<=0)return null;let y=(t-e.left)/e.width,m=(r-e.top)/e.height,[x,g]=u===90?[m,1-y]:u===180?[1-y,1-m]:u===270?[1-m,y]:[y,m];return{x:Math.max(0,Math.min(i-1,Math.round(x*i))),y:Math.max(0,Math.min(n-1,Math.round(g*n)))}}function M(e,t,r,i){let n=e[0],u=e.at(-1);if(!n||!u)throw Error("A pointer path requires samples");let y=f(n,u);if(!e.some((p)=>Math.hypot(p.clientX-n.clientX,p.clientY-n.clientY)>=6)&&!t)return y;let x=Math.min(60,Math.max(0.1,(u.t-n.t)/1000)),g=Math.min(600,Math.max(2,Math.ceil(x*60))),h=0,d=Array.from({length:g},(p,w)=>{let D=n.t+(u.t-n.t)*w/(g-1);while(h+1<e.length-1&&e[h+1].t<D)h++;let a=e[h],K=e[Math.min(h+1,e.length-1)],k=K.t===a.t?0:(D-a.t)/(K.t-a.t);return{x:a.x+(K.x-a.x)*k,y:a.y+(K.y-a.y)*k}});return{type:"touchPath",duration:x,fingers:t?[d,d.map(({x:p,y:w})=>({x:r-1-p,y:i-1-w}))]:[d]}}
2
- export{v,o,s,f,b,l,c,M};
@@ -1,2 +0,0 @@
1
- import{invoke as i}from"@tauri-apps/api/core";import{listen as n,once as s,emit as a,emitTo as o}from"@tauri-apps/api/event";var e={tools:()=>i("plugin:alwith-device|tools"),toolCall:(t)=>i("plugin:alwith-device|tool_call",t),toolCancel:(t)=>i("plugin:alwith-device|tool_cancel",t),context:()=>i("plugin:alwith-device|context"),bind:(t)=>i("plugin:alwith-device|bind",t),stopSession:(t)=>i("plugin:alwith-device|stop_session",t),list:(t)=>i("plugin:alwith-device|list",t),attachments:()=>i("plugin:alwith-device|attachments"),attach:(t)=>i("plugin:alwith-device|attach",t),detach:(t)=>i("plugin:alwith-device|detach",t),frame:(t)=>i("plugin:alwith-device|frame",t),nativeViewSupported:(t)=>i("plugin:alwith-device|native_view_supported",t),nativeViewMount:(t)=>i("plugin:alwith-device|native_view_mount",t),nativeViewUpdate:(t)=>i("plugin:alwith-device|native_view_update",t),nativeViewUnmount:(t)=>i("plugin:alwith-device|native_view_unmount",t),nativeViewStatus:(t)=>i("plugin:alwith-device|native_view_status",t),gesture:(t)=>i("plugin:alwith-device|gesture",t),inspect:(t)=>i("plugin:alwith-device|inspect",t),capabilities:(t)=>i("plugin:alwith-device|capabilities",t),monitorDensity:()=>i("plugin:alwith-device|monitor_density"),activity:(t)=>i("plugin:alwith-device|activity",t),captureList:(t)=>i("plugin:alwith-device|capture_list",t),captureAccess:(t)=>i("plugin:alwith-device|capture_access",t),captureRemove:(t)=>i("plugin:alwith-device|capture_remove",t),appearance:(t)=>i("plugin:alwith-device|appearance",t),setAppearance:(t)=>i("plugin:alwith-device|set_appearance",t),setStatusBar:(t)=>i("plugin:alwith-device|set_status_bar",t),shutdown:(t)=>i("plugin:alwith-device|shutdown",t),restart:(t)=>i("plugin:alwith-device|restart",t),saveScreenshot:(t)=>i("plugin:alwith-device|save_screenshot",t),recordStart:(t)=>i("plugin:alwith-device|record_start",t),recordStop:(t)=>i("plugin:alwith-device|record_stop",t),logs:(t)=>i("plugin:alwith-device|logs",t),crashReport:(t)=>i("plugin:alwith-device|crash_report",t)},g={"device:attachments":{name:"device:attachments",listen:(t)=>n("device:attachments",t),once:(t)=>s("device:attachments",t),emit:(t)=>a("device:attachments",t),emitTo:(t,r)=>o(t,"device:attachments",r)}};function T(t){return typeof t==="object"&&t!==null&&typeof t.code==="string"&&typeof t.message==="string"}function B(t){if(T(t)||t instanceof Error)return t.message;return String(t)}
2
- export{e,g,T,B};
@@ -1,5 +0,0 @@
1
- var f=(e)=>!!e&&typeof e==="object"&&!Array.isArray(e),l=(e)=>typeof e==="string"?e:"";function x(e){if(!f(e)||![e.x,e.y,e.width,e.height].every((t)=>typeof t==="number"&&Number.isFinite(t))||Number(e.width)<0||Number(e.height)<0)throw Error("Invalid accessibility element frame");return{x:Number(e.x),y:Number(e.y),width:Number(e.width),height:Number(e.height)}}function S(e,t){if(e.length>8388608)throw Error("Accessibility tree exceeds the supported size");let r=[],n=(s)=>{if(r.length>=20000||s.depth>128)throw Error("Accessibility tree exceeds the supported depth or element count");r.push(s)};if(t==="ios"){let s=JSON.parse(e);if(!f(s)||!Array.isArray(s.elements))throw Error("Invalid iOS accessibility tree");let c=(a,b,m)=>{a.forEach((i,u)=>{if(!f(i)||!Array.isArray(i.children))throw Error("Invalid iOS accessibility element");let o=`${b}/${u}`,{children:h,...d}=i;n({id:o,depth:m,label:l(i.label)||l(i.title)||l(i.value),role:l(i.type),identifier:l(i.identifier),enabled:i.enabled!==!1,frame:x(i.frame),properties:d}),c(h,o,m+1)})};c(s.elements,"",0)}else if(t==="android"){let s=new DOMParser().parseFromString(e,"application/xml");if(s.querySelector("parsererror")||s.documentElement.tagName!=="hierarchy")throw Error("Invalid Android accessibility tree");let c=(a,b,m)=>{Array.from(a.children).forEach((i,u)=>{if(i.tagName!=="node")throw Error("Invalid Android accessibility element");let o=Object.fromEntries(Array.from(i.attributes,(p)=>[p.name,p.value])),h=o.bounds?.match(/^\[(-?\d+),(-?\d+)\]\[(-?\d+),(-?\d+)\]$/);if(!h)throw Error("Invalid Android accessibility bounds");let[d,y,E,A]=h.slice(1).map(Number),g=`${b}/${u}`;n({id:g,depth:m,label:o["content-desc"]||o.text||"",role:o.class||"",identifier:o["resource-id"]||"",enabled:o.enabled!=="false",frame:x({x:d,y,width:E-d,height:A-y}),properties:o}),c(i,g,m+1)})};c(s.documentElement,"",0)}else throw Error(`Unsupported accessibility platform: ${t}`);return r}function w(e,t){return e.filter(({frame:r})=>r.width>0&&r.height>0&&t.x>=r.x&&t.y>=r.y&&t.x<r.x+r.width&&t.y<r.y+r.height).sort((r,n)=>r.frame.width*r.frame.height-n.frame.width*n.frame.height||n.depth-r.depth||e.indexOf(n)-e.indexOf(r))}function k(e,t,r,n){return`${n.trim()?`${n.trim()}
2
-
3
- `:""}Device element (${e}, ${t}, ${t==="ios"?"logical points":"physical pixels"}):
4
- ${JSON.stringify(r.properties,null,2)}`}
5
- export{S,w,k};
@@ -1,2 +0,0 @@
1
- import{N}from"./chunk-ge4zgdtr.js";import{i,u,d}from"./chunk-xd4kq6pe.js";import{C}from"./chunk-pa4b54h3.js";import{o,s,l,c}from"./chunk-40mwa0cy.js";import{S,w,k}from"./chunk-cyvmm690.js";import{m,E}from"./chunk-pxyqksfz.js";import{p}from"./chunk-mx5dd23x.js";import{r,t}from"./chunk-35bn393s.js";import{n}from"./chunk-arw91r4t.js";import{x}from"./chunk-tp1d4pv6.js";import{D,A}from"./chunk-3n6qrzdg.js";import{Camera as Dt,ChevronDown as ot,History as Nt,Home as Pt,Images as Tt,Maximize2 as Et,Minimize2 as Ct,RotateCw as Mt,ScanSearch as Rt,Square as zt,SquareTerminal as At,Video as Bt,X as dt}from"lucide-react";import{useCallback as te,useEffect as X,useMemo as Le,useRef as Ee,useState as T}from"react";import{toast as Ve}from"sonner";import{Button as ut}from"@nyssance/shadcn/vega/components/ui/button";import{Tooltip as Lt,TooltipContent as Ot,TooltipProvider as It,TooltipTrigger as Ft}from"@nyssance/shadcn/vega/components/ui/tooltip";import{jsx as h,jsxs as Y,Fragment as qt}from"react/jsx-runtime";var ve=[25,33,50,66,75,100,125,150,200],lt=(e)=>`alwith-device:consent:${e}`,$t={read:(e)=>Promise.resolve(rt(()=>localStorage.getItem(lt(e))==="granted")??!1),write:(e,P)=>Promise.resolve(rt(()=>localStorage.setItem(lt(e),P?"granted":"denied"))??void 0)};function rt(e){try{return e()}catch{return null}}function re(e){let P=e instanceof Error?e.message:String(e);try{let M=JSON.parse(P);if(typeof M==="object"&&M!==null&&"message"in M&&typeof M.message==="string")return M.message}catch{}return P}function z({bridge:e,onAddContext:P,onAddCapture:M,platform:U="ios",udid:j,initialDeviceId:I,onDeviceChange:H,language:B,agentName:O="AI",pollFps:R=60,maximized:G=!1,onMaximize:F,windowAction:V,windowGrip:ne,onClose:ce,className:ae}){let y=Le(()=>r(B),[B]),[W,q]=T(U),[Q,_]=T(I??null),[ye,pe]=T([]);X(()=>e.subscribe(pe,(a)=>oe(re(a))),[e]);let f=Le(()=>ye.find((a)=>a.udid===(j??Q))??(j?void 0:ye.reduce((a,v)=>!a||v.attachedAt>a.attachedAt?v:a,void 0)),[ye,j,Q]);X(()=>{if(f?.platform==="ios"||f?.platform==="android")q(f.platform)},[f?.platform]);let[ee,ge]=T(null);X(()=>{let a=!1;if(ge(null),f&&e.capabilities)e.capabilities(f.udid).then((v)=>{if(!a)ge(v)}).catch((v)=>{if(!a)oe(re(v))});return()=>{a=!0}},[f?.udid,e]);let[de,ie]=T("fit"),[Z,se]=T(!1),[Ce,Me]=T(null);X(()=>{if(!e.monitorDensity)return;let a=!1,v,b=async()=>{try{let K=await e.monitorDensity();if(!a)Me(K)}catch(K){if(!a)Me(null),oe(re(K))}if(!a)v=setTimeout(()=>void b(),1000)};return b(),()=>{a=!0,clearTimeout(v)}},[e]);let be=ee?.densityDpi&&Ce&&f?.pointWidth&&f?.pixelWidth?100*Ce*f.pixelWidth/f.pointWidth/ee.densityDpi:null,g=Z&&be?be:de,[L,J]=T(R),[ke,Oe]=T(0),[me,we]=T(!1),[Ie,je]=T(!1),[Ge,xe]=T(!1),[_e,Se]=T(!1),[Xe,De]=T(!1),[mt,Je]=T(0),[fe,he]=T(!1),[Fe,$e]=T([]),[Re,Ne]=T(null),[Pe,ze]=T([]),[He,Ye]=T(!1),[ft,Qe]=T(null),[ht,vt]=T(0);X(()=>{he(!1),Ne(null),$e([]),ze([])},[f?.udid]),X(()=>{if(!fe||!f||!e.inspect)return;let a=!1;Ye(!0),Qe(null),Ne(null),ze([]);let v=setTimeout(()=>{e.inspect(f.udid).then((b)=>{if(a)return;$e(S(b,f.platform))}).catch((b)=>{if(!a)$e([]),Qe(re(b))}).finally(()=>{if(!a)Ye(!1)})},150);return()=>{a=!0,clearTimeout(v)}},[fe,f?.udid,f?.platform,f?.inputRevision,f?.rotation,e,ht]);let yt=te((a)=>{if(He)return;let v=w(Fe,a);ze(v),Ne(v[0]??null)},[Fe,He]),[et,oe]=T(null);X(()=>oe(null),[f?.udid]),X(()=>{H?.(f?.udid)},[f?.udid,H]);let[We,Ae]=T(null),[Te,qe]=T(null),[gt,tt]=T(null),[nt,Ze]=T(null),[at,it]=T("live"),Ke=e.consent??$t,ue=te((a)=>{oe(null),a().catch((v)=>oe(re(v)))},[]),Be=te(async(a)=>{Ae(a&&!a.running?"booting":"attaching"),oe(null);try{let v=await e.attach(a?.id,a?.platform??W);return _(v.udid),pe((b)=>[...b.filter((K)=>K.udid!==v.udid),v]),tt(null),v}catch(v){let b=re(v);if(a&&/no simulator|not available|不可用|No device/i.test(b))tt(a.name);return oe(b),null}finally{Ae(null)}},[e,W]),Ue=te(async(a)=>{let v=a;if(!v){let b=await e.listDevices(W);if(v=b.find((K)=>K.running)??b[0],!v){oe(y.noSimulators);return}}if(await Ke.read(v.id))await Be(v);else qe(v)},[e,W,Ke,Be,y.noSimulators]);X(()=>{if(!f||!e.appearance)return;let a=!1;return e.appearance(f.udid).then((v)=>{if(!a)Ze(v)}).catch(()=>{return}),()=>{a=!0}},[e,f]);let bt=h(ct,{bridge:e,platform:W,labels:y,current:f?.udid,currentName:f?.deviceName,onPlatformChange:q,disabled:We!==null,onPick:(a)=>{if(f&&a.id!==f.udid)ue(async()=>{if(await Be(a))await e.detach(f.udid)});else if(!f)ue(()=>Ue(a))}}),kt=[{kind:"item",label:y.undo,disabled:!0,hint:y.inputUnavailable},{kind:"item",label:y.redo,disabled:!0},{kind:"separator"},{kind:"item",label:y.cut,disabled:!0},{kind:"item",label:y.copy,disabled:!0},{kind:"item",label:y.paste,disabled:!0},{kind:"item",label:y.selectAll,disabled:!0},{kind:"item",label:y.delete,disabled:!0}],wt=()=>{let a=f,v=(b)=>()=>{if(a)ue(()=>b(a))};return[{kind:"section",label:y.appearance},{kind:"item",label:y.light,checked:nt==="light",disabled:!a||!e.setAppearance,onSelect:v(async(b)=>{await e.setAppearance?.(b.udid,"light"),Ze("light")})},{kind:"item",label:y.dark,checked:nt==="dark",disabled:!a||!e.setAppearance,onSelect:v(async(b)=>{await e.setAppearance?.(b.udid,"dark"),Ze("dark")})},...ee?.hingeAngle!=null?[{kind:"section",label:B?.startsWith("zh")?"折叠角度":"Hinge angle"},...[0,90,180].map((b)=>({kind:"item",label:`${b}°`,checked:Math.abs(ee.hingeAngle-b)<0.5,onSelect:v(async(K)=>{await e.gesture(K.udid,{type:"hinge",angle:b}),ge(await e.capabilities(K.udid))})}))]:[],{kind:"section",label:y.statusBar},{kind:"item",label:y.statusLive,checked:at==="live",disabled:!a||!e.setStatusBar,onSelect:v(async(b)=>{await e.setStatusBar?.(b.udid,"live"),it("live")})},{kind:"item",label:y.statusShowcase,checked:at==="showcase",disabled:!a||!e.setStatusBar,onSelect:v(async(b)=>{await e.setStatusBar?.(b.udid,"showcase"),it("showcase")})},{kind:"separator"},{kind:"item",label:y.restart,disabled:!a||!e.restart,onSelect:v(async(b)=>{Ae("booting");try{await e.restart?.(b.udid),await e.attach(b.udid,b.platform)}finally{Ae(null)}})},{kind:"item",label:y.shutdown,disabled:!a||!e.shutdown,onSelect:v((b)=>e.shutdown(b.udid))},{kind:"separator"},{kind:"item",label:y.detach,disabled:!a,onSelect:v((b)=>e.detach(b.udid))}]},st=(a)=>(se(!1),ie((v)=>{let b=v==="fit"?100:v,K=ve.findIndex((St)=>St>=b);return(a>0?ve[Math.min(ve.length-1,(K===-1?ve.length-1:K)+1)]:ve[Math.max(0,(K===-1?ve.length:K)-1)])??v})),xt=()=>[...V?[{kind:"item",...V}]:[],{kind:"item",label:y.zoomIn,onSelect:()=>st(1),hint:"⌘+"},{kind:"item",label:y.zoomOut,onSelect:()=>st(-1),hint:"⌘−"},{kind:"item",label:y.zoomFit,checked:!Z&&de==="fit",onSelect:()=>{se(!1),ie("fit")}},{kind:"item",label:y.actualSize,checked:!Z&&de===100,onSelect:()=>{se(!1),ie(100)},hint:"⌘0"},{kind:"item",label:B?.startsWith("zh")?"物理尺寸":"Physical size",disabled:be===null,checked:Z,onSelect:()=>se(!0)},{kind:"section",label:y.frameRate},...[15,30,60].map((a)=>({kind:"item",label:`${a} FPS`,checked:L===a,onSelect:()=>J(a)}))],le=(a,v,b,K)=>Y(Lt,{children:[h(Ft,{render:h(ut,{variant:"ghost",size:"icon-sm","aria-label":a,"aria-pressed":K?.pressed,disabled:K?.disabled,onClick:b,className:"aria-pressed:bg-muted"}),children:v}),h(Ot,{children:a})]});return h(It,{children:Y("div",{"data-device-panel":!0,className:`bg-background text-foreground flex h-full min-h-0 flex-col ${ae??""}`,children:[Y("div",{"data-device-menubar":!0,className:"border-border flex h-10 shrink-0 items-center gap-0.5 overflow-x-auto border-b px-2 whitespace-nowrap",children:[ne,bt,h(n,{label:y.menuEdit,entries:kt}),h(n,{label:y.menuDevice,entries:wt}),h(n,{label:y.menuView,entries:xt}),h("span",{className:"flex-1"}),f&&h("span",{className:"text-muted-foreground mx-1 text-xs tabular-nums",children:ke>0?t(y.fpsValue,{fps:ke}):y.fpsIdle}),F&&le(G?y.collapse:y.expand,G?h(Ct,{}):h(Et,{}),F,{pressed:G}),ce&&le(y.close,h(dt,{}),ce)]}),et&&h("p",{role:"alert",className:"border-border text-destructive shrink-0 border-b px-3 py-1.5 text-xs",children:et}),Y("div",{className:"flex min-h-0 min-w-0 flex-1",children:[h("div",{"data-device-stage":!0,className:`[container-type:size] flex min-h-0 min-w-0 flex-1 items-start justify-start p-4 ${de==="fit"?"overflow-hidden":"overflow-auto"}`,children:f?h(Ht,{bridge:e,attachment:f,labels:y,fps:L,zoom:g,onError:oe,onFps:Oe,onInspect:fe?yt:void 0,selectedElement:fe?Re:null},f.udid):h(pt,{kind:i(W,Te?.name??"iPhone"),zoom:g,children:Te?h(A,{labels:y,agent:O,deviceName:Te.name,systemVersion:Te.systemVersion,onCancel:()=>qe(null),onContinue:()=>{let a=Te;qe(null),ue(async()=>{await Ke.write(a.id,!0),await Be(a)})}}):h(D,{labels:y,agent:O,unavailableDevice:gt,busy:We,error:null,onAttach:()=>void Ue(void 0),picker:h(ct,{bridge:e,platform:W,labels:y,disabled:We!==null,compact:!0,onPick:(a)=>void Ue(a)})})})}),Xe&&e.listCaptures&&e.captureUrl&&h(C,{bridge:e,language:B,revision:mt,onClose:()=>De(!1),onAdd:M}),fe&&f&&h(E,{elements:Fe,selected:Re,loading:He,error:ft,language:B,onSelect:(a)=>{Ne(a),ze([a])},onRefresh:()=>vt((a)=>a+1),onClose:()=>he(!1),onCycle:(a)=>{if(Pe.length&&Re)Ne(Pe[(Pe.indexOf(Re)+a+Pe.length)%Pe.length])},onCopy:(a)=>e.copyText?e.copyText(a):navigator.clipboard.writeText(a),onAdd:P?async(a,v)=>{await P(k(f.deviceName,f.platform,a,v))}:void 0},f.udid)]}),h("div",{"data-device-toolbar":!0,className:"flex shrink-0 justify-center py-3",children:Y("div",{className:"inline-flex items-center gap-0.5",children:[le(y.home,h(Pt,{className:"size-4"}),()=>f&&ue(()=>e.gesture(f.udid,{type:"button",name:"HOME"})),{disabled:!f}),le(y.rotate,h(Mt,{className:"size-4"}),()=>f&&ue(()=>e.gesture(f.udid,{type:"rotate",direction:"right"})),{disabled:!f}),le(y.screenshot,h(Dt,{className:"size-4"}),()=>f&&ue(async()=>{je(!0);try{let a;if(e.saveScreenshot)a=await e.saveScreenshot(f.udid,"");else{let v=await e.captureFrame(f.udid);if(!v)throw Error("Device did not produce a frame");let b=document.createElement("a");b.href=v,b.download=`${f.deviceName}-${Date.now()}.${v.startsWith("data:image/jpeg")?"jpg":"png"}`,b.click(),a=b.download}if(a)Je((v)=>v+1),Ve.success(t(y.screenshotSaved,{path:a}))}finally{je(!1)}}),{disabled:!f||Ie}),le(f?.recordingPath?y.stopRecording:y.record,f?.recordingPath?h(zt,{className:"size-4"}):h(Bt,{className:"size-4"}),()=>f&&ue(async()=>{we(!0);try{if(f.recordingPath){let a=await e.stopRecording(f.udid);Je((v)=>v+1),Ve.success(t(y.recordingSaved,{path:a}))}else await e.startRecording(f.udid),Ve.success(y.recordingStarted)}finally{we(!1)}}),{disabled:!f||me||!e.startRecording||!e.stopRecording,pressed:!!f?.recordingPath}),le(m(B).inspect,h(Rt,{}),()=>{he((a)=>!a),xe(!1),Se(!1),De(!1)},{disabled:!f||!e.inspect||!!f.recordingPath,pressed:fe}),le(B?.startsWith("zh")?"操作历史":"Activity",h(Nt,{}),()=>{Se((a)=>!a),xe(!1),he(!1),De(!1)},{disabled:!e.readActivity,pressed:_e}),le(B?.startsWith("zh")?"设备素材":"Captures",h(Tt,{}),()=>{De((a)=>!a),xe(!1),he(!1),Se(!1)},{disabled:!e.listCaptures||!e.captureUrl,pressed:Xe}),le(y.logs,h(At,{className:"size-4"}),()=>{xe((a)=>!a),he(!1),Se(!1),De(!1)},{disabled:!f||!e.readLogs,pressed:Ge})]})}),_e&&e.readActivity&&h(N,{bridge:e,language:B,onClose:()=>Se(!1)}),Ge&&f&&e.readLogs&&h(Wt,{bridge:e,udid:f.udid,labels:y,onClose:()=>xe(!1)})]})})}function ct({bridge:e,platform:P,labels:M,current:U,currentName:j,onPlatformChange:I,disabled:H,compact:B,onPick:O}){let[R,G]=T(null),[F,V]=T(null),ne=te(()=>{G(null),V(null),e.listDevices(P).then(G).catch((W)=>V(re(W)))},[e,P]);X(()=>{ne()},[ne]);let ce=()=>{if(F)return[{kind:"item",label:F,disabled:!0}];if(R===null)return[{kind:"item",label:M.loadingDevices,disabled:!0}];if(R.length===0)return[{kind:"item",label:M.noSimulators,disabled:!0}];let W=R.filter((_)=>_.running),q=R.filter((_)=>!_.running),Q=(_)=>({kind:"item",label:_.name,hint:_.systemVersion,checked:U===void 0?void 0:_.id===U,onSelect:()=>O(_)});return[...W.length>0?[{kind:"section",label:M.booted},...W.map(Q)]:[],...q.length>0?[{kind:"section",label:M.willBoot},...q.map(Q)]:[]]},ae=()=>[...I?[{kind:"item",label:"iOS",checked:P==="ios",onSelect:()=>I("ios")},{kind:"item",label:"Android",checked:P==="android",onSelect:()=>I("android")},{kind:"separator"}]:[],...ce()],y=(W)=>{if(W)ne()};if(B)return h(n,{ariaLabel:M.chooseDevice,entries:ae,disabled:H,caret:!1,align:"end",variant:"default",size:"lg",className:"border-s-primary-foreground/20 rounded-s-none border-s px-3",onOpenChange:y,children:h(ot,{className:"size-4","aria-hidden":!0})});return Y(n,{ariaLabel:M.chooseDevice,entries:ae,disabled:H,caret:!1,size:"default",className:"h-8 max-w-48 justify-start px-2 text-left",onOpenChange:y,children:[h("span",{className:"flex min-w-0 items-center gap-2",children:h("span",{className:"truncate text-[15px] font-medium",children:j??M.chooseDevice})}),h(ot,{className:"size-4 shrink-0 opacity-60","aria-hidden":!0})]})}function pt({kind:e,zoom:P,pixelWidth:M,pixelHeight:U,rotation:j,deviceRotation:I,scale:H=3,children:B,overlay:O}){let R=Le(()=>u(e,M,U),[e,M,U]),G=((I??j??0)-(j??0)+360)%360,F=G===90||G===270,V=F?1/R.aspect:R.aspect,ne=(M??1206)/H/(Number.parseFloat(R.style.width)/100),ce=(U??2622)/H/(Number.parseFloat(R.style.height)/100),ae=`min(100cqh, 100cqw, ${Math.max(ne,ce)}px)`,y=P==="fit"?{height:V>1?`calc(${ae} / ${V})`:ae,aspectRatio:V}:(()=>{let W=(100-2*Number.parseFloat(F?R.style.left:R.style.top))/100;return{height:`${(F?M??1206:U??2622)/H*P/100/W}px`,aspectRatio:V,flexShrink:0}})();return h("div",{"data-device-screen-stage":!0,"data-device-rotation":I??j??0,"data-device-zoom":P,className:"relative m-auto",style:y,children:Y("div",{className:"absolute",style:{left:"50%",top:"50%",width:F?`${R.aspect*100}%`:"100%",height:F?`${100/R.aspect}%`:"100%",transform:`translate(-50%, -50%) rotate(${G}deg)`},children:[h("div",{className:"bg-background absolute z-0 overflow-hidden",style:R.style,children:B}),h(d,{kind:e,pixelWidth:M,pixelHeight:U,rotation:j,style:{position:"absolute",inset:0,zIndex:10,width:"100%",height:"100%",pointerEvents:"none",userSelect:"none",filter:"drop-shadow(0 2px 6px rgb(0 0 0 / 0.2)) drop-shadow(0 12px 32px rgb(0 0 0 / 0.25))"}}),O&&h("div",{className:"absolute z-20",style:R.style,children:O})]})})}function Ht({bridge:e,attachment:P,labels:M,fps:U,zoom:j,onError:I,onFps:H,onInspect:B,selectedElement:O}){let{udid:R,deviceName:G,platform:F}=P,V=x(e.nativeView,F,R,U,I,H),[ne,ce]=T(null),ae=P.pixelWidth&&P.pixelHeight?{width:P.pixelWidth,height:P.pixelHeight}:null,[y,W]=T(!1),q=Ee(null),Q=Ee(!1),_=Ee([]);X(()=>{if(U<=0||V.supported!==!1)return;let g=!1,L,J=0,ke=async()=>{if(g)return;let Oe=performance.now();try{let me=await e.captureFrame(R);if(!g&&me){if(J>0)I(null);J=0,ce(me);let we=performance.now();_.current=[..._.current.filter((Ie)=>we-Ie<2000),we],H(Math.round(_.current.length/2))}}catch(me){if(!g)J++,_.current=[],ce(null),H(0),I(re(me))}if(g)return;L=setTimeout(()=>void ke(),J?Math.min(5000,250*2**Math.min(J,5)):Math.max(0,1000/U-(performance.now()-Oe)))};return ke(),()=>{if(g=!0,H(0),L!==void 0)clearTimeout(L)}},[e,R,U,H,I,V.supported]);let ye=i(F,G),pe=((P.deviceRotation??P.rotation??0)-(P.rotation??0)+360)%360,f=P.pointWidth??0,ee=P.pointHeight??0,ge=P.pixelWidth&&f>0?P.pixelWidth/f:void 0,de=te((g)=>{e.gesture(R,g).then(()=>I(null),(L)=>I(re(L)))},[e,R,I]),ie=te(()=>{if(y)return;W(!0),e.takeOver?.(R).catch(()=>{return})},[e,R,y]),Z=Le(()=>new p((g)=>e.gesture(R,g),(g)=>I(re(g))),[e,R,I]);X(()=>()=>Z.cancel(),[Z]),X(()=>{if(B)q.current=null,Z.cancel()},[B,Z]);let se=te((g,L)=>{let J=c(g.currentTarget.getBoundingClientRect(),g.clientX,g.clientY,f,ee,pe);return J?L?[J,{x:f-1-J.x,y:ee-1-J.y}]:[J]:null},[f,ee,pe]),Ce=te((g)=>{if(g.button!==0||q.current)return;let L=se(g,g.altKey);if(!L)return;if(g.preventDefault(),B){B(L[0]);return}ie(),g.currentTarget.setPointerCapture(g.pointerId),g.currentTarget.focus({preventScroll:!0}),q.current={mirrored:g.altKey},Z.push("begin",L)},[se,ie,Z,B]),Me=te((g)=>{if(g.button!==0||!q.current)return;let L=se(g,q.current.mirrored);if(q.current=null,L)Z.push("end",L);else Z.cancel()},[se,Z]),be=te((g)=>{if(B){g.preventDefault();return}if(g.nativeEvent.isComposing||Q.current)return;let L=l(g,F==="android"?s:o);if(!L)return;g.preventDefault(),g.stopPropagation(),ie(),de(L)},[F,de,ie,B]);return h(pt,{kind:ye,zoom:j,pixelWidth:ae?.width,pixelHeight:ae?.height,scale:ge,rotation:P.rotation??void 0,deviceRotation:P.deviceRotation??void 0,overlay:Y(qt,{children:[h("div",{role:"application",tabIndex:0,"aria-label":M.touchSurface,"data-device-touch-surface":!0,"data-controlling":y||void 0,title:y?M.takeOver:void 0,contentEditable:"plaintext-only",suppressContentEditableWarning:!0,spellCheck:!1,className:"h-full w-full cursor-pointer touch-none overflow-hidden text-transparent caret-transparent outline-none",onPointerDown:Ce,onPointerMove:(g)=>{if(!q.current)return;let L=se(g,q.current.mirrored);if(L)Z.push("move",L)},onPointerUp:Me,onPointerCancel:()=>{q.current=null,Z.cancel()},onLostPointerCapture:()=>{q.current=null,Z.cancel()},onBlur:()=>{q.current=null,Z.cancel()},onKeyDown:be,onCompositionStart:()=>{Q.current=!0},onCompositionEnd:(g)=>{if(Q.current=!1,g.data&&!B)ie(),de({type:"text",value:g.data});g.currentTarget.textContent=""},onInput:(g)=>{if(!Q.current)g.currentTarget.textContent=""},onPaste:(g)=>{g.preventDefault();let L=g.clipboardData.getData("text/plain");if(L&&!B)ie(),de({type:"text",value:L})}}),O&&f>0&&ee>0&&Y("div",{className:"pointer-events-none absolute",style:{left:`${O.frame.x/f*100}%`,top:`${O.frame.y/ee*100}%`,width:`${O.frame.width/f*100}%`,height:`${O.frame.height/ee*100}%`},children:[h("div",{"data-device-overlay":!0,className:"bg-primary absolute inset-x-0 top-0 h-0.5"}),h("div",{"data-device-overlay":!0,className:"bg-primary absolute inset-x-0 bottom-0 h-0.5"}),h("div",{"data-device-overlay":!0,className:"bg-primary absolute inset-y-0 left-0 w-0.5"}),h("div",{"data-device-overlay":!0,className:"bg-primary absolute inset-y-0 right-0 w-0.5"})]})]}),children:V.supported?h("div",{ref:V.ref,"data-device-native-view":!0,"data-native-rotation":pe,className:"bg-background h-full w-full"}):ne?h("img",{src:ne,alt:t(M.liveStream,{device:G}),draggable:!1,className:"block h-full w-full bg-black object-cover select-none"}):h("div",{className:"h-full w-full bg-black"})})}function Wt({bridge:e,udid:P,labels:M,onClose:U}){let[j,I]=T([]),H=Ee(0),B=Ee(null);return X(()=>{let O=!1,R=async()=>{try{let F=await e.readLogs(P,{sinceSeq:H.current||void 0,tail:200});if(O)return;if(F.entries.length>0)H.current=F.lastSeq,I((V)=>[...V,...F.entries].slice(-500))}catch{}};R();let G=setInterval(()=>void R(),2000);return()=>{O=!0,clearInterval(G)}},[e,P]),X(()=>{B.current?.scrollTo({top:B.current.scrollHeight})},[j]),Y("div",{"data-device-logs":!0,className:"border-border flex h-[40%] shrink-0 flex-col border-t",children:[Y("div",{className:"text-muted-foreground flex h-8 shrink-0 items-center gap-2 px-3 text-xs",children:[h("span",{className:"flex-1",children:M.logsTitle}),h(ut,{variant:"ghost",size:"icon-xs","aria-label":M.closeLogs,title:M.closeLogs,onClick:U,children:h(dt,{})})]}),h("div",{ref:B,className:"min-h-0 flex-1 overflow-auto px-3 pb-2 font-mono text-[11px] leading-4",children:j.length===0?h("p",{className:"text-muted-foreground py-4 text-center",children:M.logsEmpty}):j.map((O)=>Y("div",{className:"flex gap-2 break-all whitespace-pre-wrap",children:[h("span",{className:"text-muted-foreground shrink-0",children:O.timestamp.slice(11,23)}),h("span",{className:`shrink-0 ${O.level==="error"||O.level==="fault"?"text-destructive":"text-muted-foreground"}`,children:O.level}),h("span",{children:O.message})]},O.seq))})]})}
2
- export{z};
@@ -1,2 +0,0 @@
1
- import{Copy as w,FolderOpen as E,RefreshCw as F,Send as R,Trash2 as P,X as H}from"lucide-react";import{useEffect as y,useState as s}from"react";import{AlertDialog as O,AlertDialogAction as U,AlertDialogCancel as j,AlertDialogContent as K,AlertDialogDescription as W,AlertDialogFooter as X,AlertDialogHeader as q,AlertDialogTitle as G}from"@nyssance/shadcn/vega/components/ui/alert-dialog";import{Button as c}from"@nyssance/shadcn/vega/components/ui/button";import{ScrollArea as I}from"@nyssance/shadcn/vega/components/ui/scroll-area";import{jsx as e,jsxs as i}from"react/jsx-runtime";function C({bridge:r,language:b,revision:N,onClose:k,onAdd:m}){let l=b?.startsWith("zh"),[v,B]=s([]),[a,f]=s(null),[d,g]=s(null),[h,n]=s(null),[p,x]=s(!1),[z,D]=s(!1),[S,A]=s(0),[T]=s(()=>Boolean(document.createElement("video").canPlayType('video/mp4; codecs="avc1.42E01E"')));y(()=>{let t=!1;return r.listCaptures().then((o)=>{if(!t)B(o),n(null)}).catch((o)=>{if(!t)n(String(o))}),()=>{t=!0}},[r,N,S]),y(()=>{let t=!1;if(g(null),a)r.captureUrl(a.id).then((o)=>{if(!t)g(o)}).catch((o)=>{if(!t)n(String(o))});return()=>{t=!0}},[r,a]);let u=async(t)=>{x(!0),n(null);try{await t()}catch(o){n(String(o))}finally{x(!1)}};return i("section",{"data-device-captures":!0,className:"border-border flex w-80 min-w-64 shrink-0 flex-col border-l","aria-label":l?"设备素材":"Device captures",children:[i("div",{className:"flex h-10 shrink-0 items-center gap-1 px-2",children:[i("span",{className:"flex-1 text-sm",children:[l?"设备素材":"Captures"," · ",v.length]}),e(c,{variant:"ghost",size:"icon-sm","aria-label":l?"刷新素材":"Refresh captures",onClick:()=>A((t)=>t+1),children:e(F,{})}),e(c,{variant:"ghost",size:"icon-sm","aria-label":l?"关闭素材":"Close captures",onClick:k,children:e(H,{})})]}),h&&e("p",{role:"alert",className:"text-destructive px-3 text-xs",children:h}),e(I,{className:"min-h-0 flex-1",children:e("div",{className:"flex flex-col p-1",children:v.map((t)=>e(c,{disabled:p,variant:a?.id===t.id?"secondary":"ghost",size:"sm",className:"justify-start",onClick:()=>{f(t),n(null)},children:e("span",{className:"truncate",children:t.name})},t.id))})}),a&&i("div",{className:"border-border flex max-h-[65%] min-h-0 flex-col gap-2 border-t p-2",children:[d&&(a.kind==="image"?e("img",{src:d,alt:a.name,className:"min-h-0 flex-1 object-contain"}):T?e("video",{src:d,controls:!0,preload:"metadata",className:"min-h-0 flex-1",onError:()=>n(l?"录像解码失败":"Cannot decode the recording")}):e("p",{role:"status",className:"text-muted-foreground text-xs",children:l?"当前浏览器引擎不支持此录像编码。文件已保存,可加入聊天或显示文件。":"This browser engine cannot decode this recording. The saved file can be added to chat or revealed."})),i("div",{className:"flex shrink-0 items-center gap-1",children:[i("span",{className:"text-muted-foreground flex-1 text-xs",children:[(a.bytes/1024).toFixed(0)," KB"]}),r.revealCapture&&e(c,{variant:"ghost",size:"icon-sm","aria-label":l?"显示文件":"Reveal file",disabled:p,onClick:()=>void u(()=>r.revealCapture(a.path)),children:e(E,{})}),e(c,{variant:"ghost",size:"icon-sm","aria-label":l?"复制路径":"Copy path",disabled:p,onClick:()=>void u(()=>r.copyText?r.copyText(a.path):navigator.clipboard.writeText(a.path)),children:e(w,{})}),m&&e(c,{variant:"ghost",size:"icon-sm","aria-label":l?"将素材加入聊天":"Add capture to chat",disabled:!d||p,onClick:()=>void u(()=>m(a,d)),children:e(R,{})}),r.removeCapture&&e(c,{variant:"ghost",size:"icon-sm","aria-label":l?"删除素材":"Delete capture",disabled:p,onClick:()=>D(!0),children:e(P,{})})]})]}),e(O,{open:z,onOpenChange:D,children:i(K,{children:[i(q,{children:[e(G,{children:l?"删除素材文件?":"Delete capture file?"}),e(W,{children:a?.name})]}),i(X,{children:[e(j,{children:l?"取消":"Cancel"}),e(U,{onClick:()=>{if(a)u(async()=>{await r.removeCapture(a.id),f(null),A((t)=>t+1)})},children:l?"删除文件":"Delete file"})]})]})})]})}
2
- export{C};
@@ -1,2 +0,0 @@
1
- import{useEffect as E,useRef as k,useState as F}from"react";function y(e,i){let n=Math.max(e.x,i.x),l=Math.max(e.y,i.y);return{x:n,y:l,width:Math.max(0,Math.min(e.x+e.width,i.x+i.width)-n),height:Math.max(0,Math.min(e.y+e.height,i.y+i.height)-l)}}function R(e){let i=e.getBoundingClientRect(),n=y(i,{x:0,y:0,width:window.innerWidth,height:window.innerHeight}),l=!document.hidden&&e.isConnected;for(let r=e;r;r=r.parentElement){let o=getComputedStyle(r);if(o.display==="none"||o.visibility==="hidden"||Number(o.opacity)===0)l=!1;if(/(hidden|clip|scroll|auto)/.test(`${o.overflow} ${o.overflowX} ${o.overflowY}`))n=y(n,r.getBoundingClientRect())}let a=[];for(let r of document.querySelectorAll('[role="menu"], [role="dialog"], [role="listbox"], [role="tooltip"], [data-slot="tooltip-content"], [data-slot="popover-content"], [data-device-overlay]')){if(r.contains(e)||r.getAttribute("aria-hidden")==="true")continue;let o=r.getBoundingClientRect(),d=getComputedStyle(r);if(o.width===0||o.height===0||d.display==="none"||d.visibility==="hidden")continue;let v=y(n,o);if(r.getAttribute("aria-modal")==="true")l=!1;else if(v.width>0&&v.height>0)a.push(v)}let c=getComputedStyle(e.parentElement??e).borderTopLeftRadius,m=Number.parseFloat(c)||0;return{occlusions:a,x:i.x,y:i.y,width:i.width,height:i.height,clipX:n.x,clipY:n.y,clipWidth:n.width,clipHeight:n.height,radius:c.endsWith("%")?i.width*m/100:m,rotation:Number(e.dataset.nativeRotation??0),maxFps:60,visible:l&&n.width>0&&n.height>0}}function x(e,i,n,l,a,c){let m=k(l);m.current=l;let[r,o]=F(e?null:!1),[d,v]=F(null);return E(()=>{let u=!1;if(o(e?null:!1),e)e.supported(i).then((s)=>{if(!u)o(s)},(s)=>{if(!u)a(String(s))});return()=>{u=!0}},[e,i,a]),E(()=>{if(!e||!r||!d)return;let u=!1,s,w=0,p=!1,b=!1,N="",f=!1,L,T=()=>{let t=s;if(s=void 0,t)e.unmount(t).catch((h)=>console.error("Cannot unmount native device view",h))},g=(t)=>{if(u||f)return;f=!0,cancelAnimationFrame(w),clearTimeout(L),T(),a(String(t)),c(0)},C=0,S=performance.now(),A=async()=>{if(u||!s||f)return;try{let t=await e.status(s);if(u||f)return;if(t.error){g(t.error);return}let h=performance.now();c(Math.round((t.frames-C)*1000/Math.max(1,h-S))),C=t.frames,S=h,L=setTimeout(()=>void A(),500)}catch(t){g(t)}},M=()=>{if(u||f||!s)return;if(p){b=!0;return}let t={...R(d),maxFps:m.current},h=JSON.stringify([t,window.devicePixelRatio]);if(h===N)return;N=h,p=!0,e.update(s,t).catch(g).finally(()=>{if(p=!1,b)b=!1,M()})},H=()=>{if(u||f)return;w=requestAnimationFrame(H),M()},V=()=>M();return document.addEventListener("visibilitychange",V),e.mount(n,{...R(d),maxFps:m.current}).then(async(t)=>{if(u){await e.unmount(t);return}s=t,a(null),H(),A()}).catch(g),()=>{u=!0,cancelAnimationFrame(w),clearTimeout(L),c(0),document.removeEventListener("visibilitychange",V),T()}},[e,r,d,n,a,c]),{supported:r,ref:v}}
2
- export{y,R,x};
@@ -1,2 +0,0 @@
1
- import{memo as L,useId as Q,useMemo as S}from"react";import{jsx as R,jsxs as E}from"react/jsx-runtime";var P={iPhone:{pixelW:1206,pixelH:2622,screenRadius:186,frame:34,silver:8,grey:12,nubProtrude:27,nubs:[["left",507,102],["left",690,192],["left",927,192],["right",813,303]]},androidPhone:{pixelW:1080,pixelH:2400,screenRadius:100,frame:22,silver:6,grey:8,nubProtrude:18,nubs:[["right",480,130],["right",670,240]]},iPad:{pixelW:1668,pixelH:2420,screenRadius:58,frame:64,silver:12,grey:16,nubProtrude:20,nubs:[["right",202,104],["right",328,104],["top",-148,126]]}};function i(t,r){if(t==="android")return"androidPhone";return r.toLowerCase().includes("ipad")?"iPad":"iPhone"}function K(t,r,F){let l=P[t],k=l.frame+l.silver+l.grey,g=k+l.nubProtrude,b=r??l.pixelW,f=F??l.pixelH;return{p:l,edge:k,margin:g,W:b+2*g,H:f+2*g,width:b,height:f}}function u(t,r,F){let{p:l,margin:k,W:g,H:b,width:f,height:h}=K(t,r,F),m=100*k/g,n=100*k/b;return{aspect:g/b,style:{left:`${m}%`,top:`${n}%`,width:`${100-2*m}%`,height:`${100-2*n}%`,borderRadius:`${100*l.screenRadius/f}% / ${100*l.screenRadius/h}%`}}}function B(t,r,F,l,k){let g=Math.min(k,Math.min(F,l)/3.06),b=1.528665*g,f=1.088311*g,h=0.868407*g,m=0.631494*g,n=0.372375*g,c=0.16906*g,W=0.066987*g,e=t+F,o=r+l,a=(z)=>+z.toFixed(3),s=(z,H,p,v,C,w)=>`C${a(z)} ${a(H)} ${a(p)} ${a(v)} ${a(C)} ${a(w)}`;return[`M${a(t+b)} ${a(r)}`,`L${a(e-b)} ${a(r)}`,s(e-f,r,e-h,r,e-m,r+W),s(e-n,r+c,e-c,r+n,e-W,r+m),s(e,r+h,e,r+f,e,r+b),`L${a(e)} ${a(o-b)}`,s(e,o-f,e,o-h,e-W,o-m),s(e-c,o-n,e-n,o-c,e-m,o-W),s(e-h,o,e-f,o,e-b,o),`L${a(t+b)} ${a(o)}`,s(t+f,o,t+h,o,t+m,o-W),s(t+n,o-c,t+c,o-n,t+W,o-m),s(t,o-h,t,o-f,t,o-b),`L${a(t)} ${a(r+b)}`,s(t,r+f,t,r+h,t+W,r+m),s(t+c,r+n,t+n,r+c,t+m,r+W),s(t+h,r,t+f,r,t+b,r),"Z"].join("")}var d=L(function({kind:r="iPhone",pixelWidth:F,pixelHeight:l,rotation:k,className:g,style:b}){let f=Q(),h=k??((F??0)>(l??0)?90:0),m=h===90||h===270,n=S(()=>{let{p:c,edge:W,W:e,H:o}=K(r,m?l:F,m?F:l),a=(H)=>B(c.nubProtrude+H,c.nubProtrude+H,e-2*(c.nubProtrude+H),o-2*(c.nubProtrude+H),c.screenRadius+(W-H)),s=c.nubProtrude,z=c.nubs.map(([H,p,v])=>{let C=p+6,w=p+v-6;switch(H){case"left":return{fill:`M0 ${p}h${s}v${v}H0z`,edge:`M${s} ${p}H6Q0 ${p} 0 ${C}V${w}Q0 ${p+v} 6 ${p+v}H${s}`};case"right":return{fill:`M${e-s} ${p}H${e}v${v}H${e-s}z`,edge:`M${e-s} ${p}H${e-6}Q${e} ${p} ${e} ${C}V${w}Q${e} ${p+v} ${e-6} ${p+v}H${e-s}`};default:{let M=p>=0?p:e+p-v;return{fill:`M${M} 0v${s}h${v}V0z`,edge:`M${M} ${s}V6Q${M} 0 ${M+6} 0H${M+v-6}Q${M+v} 0 ${M+v} 6V${s}`}}}});return{W:e,H:o,outer:a(0),grey:a(c.silver),black:a(c.silver+c.grey),cutout:a(W),nubFill:z.map((H)=>H.fill).join(""),nubEdge:z.map((H)=>H.edge).join("")}},[r,F,l,m]);return E("svg",{viewBox:`0 0 ${m?n.H:n.W} ${m?n.W:n.H}`,className:g,style:b,"aria-hidden":!0,focusable:!1,children:[R("defs",{children:E("linearGradient",{id:f,x1:"0",y1:"0",x2:"1",y2:"1",children:[R("stop",{offset:"0%",stopColor:"#e8e8ec"}),R("stop",{offset:"45%",stopColor:"#bcbcc0"}),R("stop",{offset:"55%",stopColor:"#b4b4b8"}),R("stop",{offset:"100%",stopColor:"#e2e2e6"})]})}),E("g",{transform:h===90?`translate(${n.H} 0) rotate(90)`:h===180?`translate(${n.W} ${n.H}) rotate(180)`:h===270?`translate(0 ${n.W}) rotate(270)`:void 0,children:[R("path",{d:`${n.outer} ${n.cutout}`,fill:`url(#${f})`,fillRule:"evenodd"}),R("path",{d:`${n.grey} ${n.cutout}`,fill:"#4a4a4e",fillRule:"evenodd"}),R("path",{d:`${n.black} ${n.cutout}`,fill:"#0b0b0c",fillRule:"evenodd"}),R("path",{d:n.cutout,fill:"none",stroke:"#2a2a2c",strokeWidth:3}),R("path",{d:n.outer,fill:"none",stroke:"#000",strokeWidth:1.5,vectorEffect:"non-scaling-stroke"}),R("path",{d:n.nubFill,fill:"#4a4a4e"}),R("path",{d:n.nubEdge,fill:"none",stroke:"#000",strokeWidth:1.5,strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]})]})});
2
- export{P,i,u,d};