@limrun/api 0.71.0 → 0.72.0

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 (57) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/exec-client.d.mts.map +1 -1
  3. package/exec-client.d.ts.map +1 -1
  4. package/exec-client.js +1 -5
  5. package/exec-client.js.map +1 -1
  6. package/exec-client.mjs +2 -6
  7. package/exec-client.mjs.map +1 -1
  8. package/index.d.mts +1 -1
  9. package/index.d.mts.map +1 -1
  10. package/index.d.ts +1 -1
  11. package/index.d.ts.map +1 -1
  12. package/index.js +3 -2
  13. package/index.js.map +1 -1
  14. package/index.mjs +1 -1
  15. package/index.mjs.map +1 -1
  16. package/instance-client.d.mts +4 -3
  17. package/instance-client.d.mts.map +1 -1
  18. package/instance-client.d.ts +4 -3
  19. package/instance-client.d.ts.map +1 -1
  20. package/instance-client.js.map +1 -1
  21. package/instance-client.mjs.map +1 -1
  22. package/internal/session-stream.d.mts +25 -3
  23. package/internal/session-stream.d.mts.map +1 -1
  24. package/internal/session-stream.d.ts +25 -3
  25. package/internal/session-stream.d.ts.map +1 -1
  26. package/internal/session-stream.js +39 -5
  27. package/internal/session-stream.js.map +1 -1
  28. package/internal/session-stream.mjs +38 -5
  29. package/internal/session-stream.mjs.map +1 -1
  30. package/internal/sse-fetch.d.mts +5 -0
  31. package/internal/sse-fetch.d.mts.map +1 -1
  32. package/internal/sse-fetch.d.ts +5 -0
  33. package/internal/sse-fetch.d.ts.map +1 -1
  34. package/internal/sse-fetch.js +8 -0
  35. package/internal/sse-fetch.js.map +1 -1
  36. package/internal/sse-fetch.mjs +7 -0
  37. package/internal/sse-fetch.mjs.map +1 -1
  38. package/ios-client.d.mts +48 -10
  39. package/ios-client.d.mts.map +1 -1
  40. package/ios-client.d.ts +48 -10
  41. package/ios-client.d.ts.map +1 -1
  42. package/ios-client.js +28 -6
  43. package/ios-client.js.map +1 -1
  44. package/ios-client.mjs +27 -6
  45. package/ios-client.mjs.map +1 -1
  46. package/package.json +1 -1
  47. package/src/exec-client.ts +2 -8
  48. package/src/index.ts +1 -1
  49. package/src/instance-client.ts +4 -3
  50. package/src/internal/session-stream.ts +54 -7
  51. package/src/internal/sse-fetch.ts +8 -0
  52. package/src/ios-client.ts +85 -20
  53. package/src/version.ts +1 -1
  54. package/version.d.mts +1 -1
  55. package/version.d.ts +1 -1
  56. package/version.js +1 -1
  57. package/version.mjs +1 -1
package/src/ios-client.ts CHANGED
@@ -162,6 +162,8 @@ export type ElementTreeNode = {
162
162
  AXUniqueId?: string | null;
163
163
  AXValue?: string | null;
164
164
  children?: ElementTreeNode[];
165
+ /** True when visibleOnly omitted offscreen descendants of this container. */
166
+ has_offscreen_children?: boolean;
165
167
  content_required: boolean;
166
168
  custom_actions: string[];
167
169
  enabled: boolean;
@@ -178,6 +180,11 @@ export type ElementTreeNode = {
178
180
 
179
181
  export type ElementTree = ElementTreeNode[];
180
182
 
183
+ export type ElementTreeOptions = {
184
+ /** Skip branches whose nonempty frames fall outside the display. Full-tree reads only. Defaults to false. */
185
+ visibleOnly?: boolean;
186
+ };
187
+
181
188
  export type ElementTreeResultMessage = {
182
189
  type: 'elementTreeResult';
183
190
  id: string;
@@ -320,6 +327,12 @@ export type DeviceInfo = {
320
327
  screenHeight: number;
321
328
  /** Device model name */
322
329
  model: string;
330
+ /** Current interface orientation, when the simulator can report it. */
331
+ orientation?: 'portrait' | 'portraitUpsideDown' | 'landscapeLeft' | 'landscapeRight';
332
+ /** Current display width in points, accounting for orientation. */
333
+ displayWidth?: number;
334
+ /** Current display height in points, accounting for orientation. */
335
+ displayHeight?: number;
323
336
  /** Simulator OS version, e.g. "26.4" */
324
337
  osVersion?: string;
325
338
  };
@@ -754,14 +767,14 @@ export type InstanceClient = {
754
767
  * @param point Optional point to get the element at that specific location
755
768
  * @returns A promise that resolves to the parsed accessibility tree
756
769
  */
757
- elementTree: (point?: AccessibilityPoint) => Promise<ElementTree>;
770
+ elementTree: (point?: AccessibilityPoint, options?: ElementTreeOptions) => Promise<ElementTree>;
758
771
 
759
772
  /**
760
773
  * Get the raw element tree string returned by the server.
761
774
  * @param point Optional point to get the element at that specific location
762
775
  * @returns A promise that resolves to the raw accessibility tree payload
763
776
  */
764
- elementTreeRaw: (point?: AccessibilityPoint) => Promise<string>;
777
+ elementTreeRaw: (point?: AccessibilityPoint, options?: ElementTreeOptions) => Promise<string>;
765
778
 
766
779
  /**
767
780
  * Tap at the specified coordinates on the active screen (uses native screen dimensions)
@@ -1069,9 +1082,10 @@ export type InstanceClient = {
1069
1082
  * delivers lines as they are captured; a dropped connection reconnects
1070
1083
  * and resumes exactly where it left off, so every line is delivered once.
1071
1084
  * The stream is independent of this client's websocket and survives
1072
- * {@link disconnect}; `onError` fires at most once, after the stream has
1073
- * kept failing for several minutes (e.g. the instance was deleted), and
1074
- * the stream is closed. Returns a function that closes the stream.
1085
+ * {@link disconnect}; `onError` fires at most once and the stream is
1086
+ * closed: at once with a `SessionStreamRejectedError` when the
1087
+ * instance refuses it (404 once the instance is gone), or after it has
1088
+ * kept failing for several minutes. Returns a function that closes it.
1075
1089
  */
1076
1090
  streamAppLogCapture: (handlers: {
1077
1091
  onLine: (line: SessionLogLine) => void;
@@ -1107,10 +1121,7 @@ export type InstanceClient = {
1107
1121
  * {@link streamAppLogCapture}, except that a gap longer than the replay
1108
1122
  * window loses the samples in between.
1109
1123
  */
1110
- streamPerformance: (handlers: {
1111
- onSample: (sample: PerformanceSample) => void;
1112
- onError?: (error: Error) => void;
1113
- }) => () => void;
1124
+ streamPerformance: (handlers: PerformanceStreamHandlers) => () => void;
1114
1125
 
1115
1126
  /**
1116
1127
  * Play an audio file as the simulator's microphone input. Stage the file on
@@ -1465,10 +1476,12 @@ export type InstanceClient = {
1465
1476
  lsof: () => Promise<LsofEntry[]>;
1466
1477
 
1467
1478
  /**
1468
- * Device information fetched during client initialization.
1479
+ * Device information fetched during client initialization and refreshed by getDeviceInfo().
1469
1480
  * Contains id, udid, screen dimensions, and model.
1470
1481
  */
1471
1482
  deviceInfo: DeviceInfo;
1483
+ /** Fetch current device info without reading the accessibility tree; refreshes deviceInfo. */
1484
+ getDeviceInfo: () => Promise<DeviceInfo>;
1472
1485
  };
1473
1486
 
1474
1487
  /**
@@ -1600,6 +1613,9 @@ type ServerResponse = {
1600
1613
  screenHeight?: number;
1601
1614
  model?: string;
1602
1615
  osVersion?: string;
1616
+ orientation?: DeviceInfo['orientation'];
1617
+ displayWidth?: number;
1618
+ displayHeight?: number;
1603
1619
  // Simctl streaming fields
1604
1620
  stdout?: string;
1605
1621
  stderr?: string;
@@ -1795,6 +1811,43 @@ export class SimctlExecution extends EventEmitter {
1795
1811
  }
1796
1812
  }
1797
1813
 
1814
+ export type PerformanceStreamOptions = {
1815
+ /** The instance's status.apiUrl. */
1816
+ apiUrl: string;
1817
+ /** The instance token. */
1818
+ token: string;
1819
+ onSample: (sample: PerformanceSample) => void;
1820
+ /**
1821
+ * Called after each connection's replay of recent samples, the first and every reconnect, so
1822
+ * later samples are live. Runtimes that predate the signal never call it.
1823
+ */
1824
+ onReplayed?: (() => void) | undefined;
1825
+ /**
1826
+ * Called at most once, when the stream closes for good: at once with a
1827
+ * SessionStreamRejectedError (status 404 when the instance is gone or its runtime
1828
+ * predates performance), or after the give-up window when it stays unreachable.
1829
+ */
1830
+ onError?: ((error: Error) => void) | undefined;
1831
+ };
1832
+
1833
+ /** What a performance stream reports to, without the instance's address. */
1834
+ export type PerformanceStreamHandlers = Omit<PerformanceStreamOptions, 'apiUrl' | 'token'>;
1835
+
1836
+ /**
1837
+ * Tails the running apps' {@link PerformanceSample}s with only the instance's apiUrl and token,
1838
+ * without the WebSocket an {@link InstanceClient} opens. On connect the instance replays its
1839
+ * recent samples, then sends new ones; call the returned function to stop.
1840
+ */
1841
+ export function streamPerformance(options: PerformanceStreamOptions): () => void {
1842
+ return streamSessionEntries<PerformanceSample>({
1843
+ url: `${options.apiUrl}/session/performance/events`,
1844
+ token: options.token,
1845
+ onEntry: options.onSample,
1846
+ onReplayed: options.onReplayed,
1847
+ onError: options.onError,
1848
+ });
1849
+ }
1850
+
1798
1851
  /**
1799
1852
  * Creates a client for interacting with a Limrun iOS instance
1800
1853
  * @param options Configuration options including webrtcUrl, token and log level
@@ -2146,6 +2199,9 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
2146
2199
  screenHeight: msg.screenHeight!,
2147
2200
  model: msg.model!,
2148
2201
  osVersion: msg.osVersion,
2202
+ orientation: msg.orientation,
2203
+ displayWidth: msg.displayWidth,
2204
+ displayHeight: msg.displayHeight,
2149
2205
  }),
2150
2206
  openUrlResult: () => undefined,
2151
2207
  appInstallationResult: (msg) => ({
@@ -2378,7 +2434,7 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
2378
2434
  streamEventCapture,
2379
2435
  startPerformanceCapture,
2380
2436
  stopPerformanceCapture,
2381
- streamPerformance,
2437
+ streamPerformance: streamClientPerformance,
2382
2438
  playOnMicrophone,
2383
2439
  stopMicrophonePlayback,
2384
2440
  microphoneStatus,
@@ -2412,6 +2468,7 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
2412
2468
  clearCameraVideo,
2413
2469
  lsof,
2414
2470
  deviceInfo: cachedDeviceInfo,
2471
+ getDeviceInfo,
2415
2472
  });
2416
2473
  }
2417
2474
  });
@@ -2425,12 +2482,18 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
2425
2482
  return sendRequest<ScreenshotData>('screenshot', options);
2426
2483
  };
2427
2484
 
2428
- const elementTree = (point?: AccessibilityPoint): Promise<ElementTree> => {
2429
- return sendRequest<ElementTree>('elementTree', { point });
2485
+ const elementTree = (
2486
+ point?: AccessibilityPoint,
2487
+ options: ElementTreeOptions = {},
2488
+ ): Promise<ElementTree> => {
2489
+ return sendRequest<ElementTree>('elementTree', { point, ...options });
2430
2490
  };
2431
2491
 
2432
- const elementTreeRaw = (point?: AccessibilityPoint): Promise<string> => {
2433
- return sendRequest<string>('elementTree', { point }, (msg) => msg.json ?? '');
2492
+ const elementTreeRaw = (
2493
+ point?: AccessibilityPoint,
2494
+ options: ElementTreeOptions = {},
2495
+ ): Promise<string> => {
2496
+ return sendRequest<string>('elementTree', { point, ...options }, (msg) => msg.json ?? '');
2434
2497
  };
2435
2498
 
2436
2499
  const tap = (x: number, y: number): Promise<void> => {
@@ -2926,7 +2989,7 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
2926
2989
  };
2927
2990
 
2928
2991
  const tailSession = <T extends { ts: number }>(
2929
- stream: 'applogs' | 'events' | 'performance',
2992
+ stream: 'applogs' | 'events',
2930
2993
  onEntry: (entry: T) => void,
2931
2994
  onError?: (error: Error) => void,
2932
2995
  ): (() => void) =>
@@ -2947,10 +3010,8 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
2947
3010
  onError?: (error: Error) => void;
2948
3011
  }): (() => void) => tailSession('events', handlers.onEvent, handlers.onError);
2949
3012
 
2950
- const streamPerformance = (handlers: {
2951
- onSample: (sample: PerformanceSample) => void;
2952
- onError?: (error: Error) => void;
2953
- }): (() => void) => tailSession('performance', handlers.onSample, handlers.onError);
3013
+ const streamClientPerformance = (handlers: PerformanceStreamHandlers): (() => void) =>
3014
+ streamPerformance({ ...handlers, apiUrl: options.apiUrl, token: options.token });
2954
3015
 
2955
3016
  const stopRecording = async (saveTo: { presignedUrl?: string; localPath?: string }): Promise<string> => {
2956
3017
  await sendRequest<void>('stopVideoRecording', {
@@ -3103,6 +3164,10 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
3103
3164
  return sendRequest<DeviceInfo>('deviceInfo');
3104
3165
  };
3105
3166
 
3167
+ const getDeviceInfo = async (): Promise<DeviceInfo> => {
3168
+ return Object.assign(cachedDeviceInfo, await fetchDeviceInfo());
3169
+ };
3170
+
3106
3171
  // Cached device info, populated during connection
3107
3172
  let cachedDeviceInfo: DeviceInfo;
3108
3173
 
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.71.0'; // x-release-please-version
1
+ export const VERSION = '0.72.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.71.0";
1
+ export declare const VERSION = "0.72.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.71.0";
1
+ export declare const VERSION = "0.72.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.71.0'; // x-release-please-version
4
+ exports.VERSION = '0.72.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.71.0'; // x-release-please-version
1
+ export const VERSION = '0.72.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map