@limrun/api 0.16.0 → 0.17.0-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.mts CHANGED
@@ -4,5 +4,6 @@ export { APIPromise } from "./core/api-promise.mjs";
4
4
  export { Limrun, type ClientOptions } from "./client.mjs";
5
5
  export { PagePromise } from "./core/pagination.mjs";
6
6
  export * from "./instance-client.mjs";
7
+ export * as Ios from "./ios-client.mjs";
7
8
  export { LimrunError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./core/error.mjs";
8
9
  //# sourceMappingURL=index.d.mts.map
package/index.d.mts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,IAAI,OAAO,EAAE;OAErB,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE;OAC3B,EAAE,UAAU,EAAE;OACd,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE;OAC9B,EAAE,WAAW,EAAE;;OAEf,EACL,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,IAAI,OAAO,EAAE;OAErB,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE;OAC3B,EAAE,UAAU,EAAE;OACd,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE;OAC9B,EAAE,WAAW,EAAE;;OAEf,KAAK,GAAG;OACR,EACL,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB"}
package/index.d.ts CHANGED
@@ -4,5 +4,6 @@ export { APIPromise } from "./core/api-promise.js";
4
4
  export { Limrun, type ClientOptions } from "./client.js";
5
5
  export { PagePromise } from "./core/pagination.js";
6
6
  export * from "./instance-client.js";
7
+ export * as Ios from "./ios-client.js";
7
8
  export { LimrunError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./core/error.js";
8
9
  //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,IAAI,OAAO,EAAE;OAErB,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE;OAC3B,EAAE,UAAU,EAAE;OACd,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE;OAC9B,EAAE,WAAW,EAAE;;OAEf,EACL,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"OAEO,EAAE,MAAM,IAAI,OAAO,EAAE;OAErB,EAAE,KAAK,UAAU,EAAE,MAAM,EAAE;OAC3B,EAAE,UAAU,EAAE;OACd,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE;OAC9B,EAAE,WAAW,EAAE;;OAEf,KAAK,GAAG;OACR,EACL,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB"}
package/index.js CHANGED
@@ -4,7 +4,7 @@ exports = module.exports = function (...args) {
4
4
  return new exports.default(...args)
5
5
  }
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.LimrunError = exports.PagePromise = exports.Limrun = exports.APIPromise = exports.toFile = exports.default = void 0;
7
+ exports.UnprocessableEntityError = exports.PermissionDeniedError = exports.InternalServerError = exports.AuthenticationError = exports.BadRequestError = exports.RateLimitError = exports.ConflictError = exports.NotFoundError = exports.APIUserAbortError = exports.APIConnectionTimeoutError = exports.APIConnectionError = exports.APIError = exports.LimrunError = exports.Ios = exports.PagePromise = exports.Limrun = exports.APIPromise = exports.toFile = exports.default = void 0;
8
8
  const tslib_1 = require("./internal/tslib.js");
9
9
  var client_1 = require("./client.js");
10
10
  Object.defineProperty(exports, "default", { enumerable: true, get: function () { return client_1.Limrun; } });
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "Limrun", { enumerable: true, get: function () {
17
17
  var pagination_1 = require("./core/pagination.js");
18
18
  Object.defineProperty(exports, "PagePromise", { enumerable: true, get: function () { return pagination_1.PagePromise; } });
19
19
  tslib_1.__exportStar(require("./instance-client.js"), exports);
20
+ exports.Ios = tslib_1.__importStar(require("./ios-client.js"));
20
21
  var error_1 = require("./core/error.js");
21
22
  Object.defineProperty(exports, "LimrunError", { enumerable: true, get: function () { return error_1.LimrunError; } });
22
23
  Object.defineProperty(exports, "APIError", { enumerable: true, get: function () { return error_1.APIError; } });
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,sCAA6C;AAApC,iGAAA,MAAM,OAAW;AAE1B,6CAAyD;AAA/B,iGAAA,MAAM,OAAA;AAChC,qDAAgD;AAAvC,yGAAA,UAAU,OAAA;AACnB,sCAAsD;AAA7C,gGAAA,MAAM,OAAA;AACf,mDAAgD;AAAvC,yGAAA,WAAW,OAAA;AACpB,+DAAkC;AAClC,yCAcsB;AAbpB,oGAAA,WAAW,OAAA;AACX,iGAAA,QAAQ,OAAA;AACR,2GAAA,kBAAkB,OAAA;AAClB,kHAAA,yBAAyB,OAAA;AACzB,0GAAA,iBAAiB,OAAA;AACjB,sGAAA,aAAa,OAAA;AACb,sGAAA,aAAa,OAAA;AACb,uGAAA,cAAc,OAAA;AACd,wGAAA,eAAe,OAAA;AACf,4GAAA,mBAAmB,OAAA;AACnB,4GAAA,mBAAmB,OAAA;AACnB,8GAAA,qBAAqB,OAAA;AACrB,iHAAA,wBAAwB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;AAEtF,sCAA6C;AAApC,iGAAA,MAAM,OAAW;AAE1B,6CAAyD;AAA/B,iGAAA,MAAM,OAAA;AAChC,qDAAgD;AAAvC,yGAAA,UAAU,OAAA;AACnB,sCAAsD;AAA7C,gGAAA,MAAM,OAAA;AACf,mDAAgD;AAAvC,yGAAA,WAAW,OAAA;AACpB,+DAAkC;AAClC,+DAAoC;AACpC,yCAcsB;AAbpB,oGAAA,WAAW,OAAA;AACX,iGAAA,QAAQ,OAAA;AACR,2GAAA,kBAAkB,OAAA;AAClB,kHAAA,yBAAyB,OAAA;AACzB,0GAAA,iBAAiB,OAAA;AACjB,sGAAA,aAAa,OAAA;AACb,sGAAA,aAAa,OAAA;AACb,uGAAA,cAAc,OAAA;AACd,wGAAA,eAAe,OAAA;AACf,4GAAA,mBAAmB,OAAA;AACnB,4GAAA,mBAAmB,OAAA;AACnB,8GAAA,qBAAqB,OAAA;AACrB,iHAAA,wBAAwB,OAAA"}
package/index.mjs CHANGED
@@ -5,5 +5,6 @@ export { APIPromise } from "./core/api-promise.mjs";
5
5
  export { Limrun } from "./client.mjs";
6
6
  export { PagePromise } from "./core/pagination.mjs";
7
7
  export * from "./instance-client.mjs";
8
+ export * as Ios from "./ios-client.mjs";
8
9
  export { LimrunError, APIError, APIConnectionError, APIConnectionTimeoutError, APIUserAbortError, NotFoundError, ConflictError, RateLimitError, BadRequestError, AuthenticationError, InternalServerError, PermissionDeniedError, UnprocessableEntityError, } from "./core/error.mjs";
9
10
  //# sourceMappingURL=index.mjs.map
package/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,MAAM,IAAI,OAAO,EAAE;OAErB,EAAmB,MAAM,EAAE;OAC3B,EAAE,UAAU,EAAE;OACd,EAAE,MAAM,EAAsB;OAC9B,EAAE,WAAW,EAAE;;OAEf,EACL,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB"}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,MAAM,IAAI,OAAO,EAAE;OAErB,EAAmB,MAAM,EAAE;OAC3B,EAAE,UAAU,EAAE;OACd,EAAE,MAAM,EAAsB;OAC9B,EAAE,WAAW,EAAE;;OAEf,KAAK,GAAG;OACR,EACL,WAAW,EACX,QAAQ,EACR,kBAAkB,EAClB,yBAAyB,EACzB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,cAAc,EACd,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,wBAAwB,GACzB"}
package/internal/tslib.js CHANGED
@@ -5,6 +5,7 @@ exports.__classPrivateFieldSet = __classPrivateFieldSet;
5
5
  exports.__classPrivateFieldGet = __classPrivateFieldGet;
6
6
  exports.__importStar = __importStar;
7
7
  exports.__exportStar = __exportStar;
8
+ exports.__importDefault = __importDefault;
8
9
  function __classPrivateFieldSet(receiver, state, value, kind, f) {
9
10
  if (kind === "m")
10
11
  throw new TypeError("Private method is not writable");
@@ -79,3 +80,6 @@ function __exportStar(m, o) {
79
80
  if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p))
80
81
  __createBinding(o, m, p);
81
82
  }
83
+ function __importDefault(mod) {
84
+ return mod && mod.__esModule ? mod : { default: mod };
85
+ }
@@ -0,0 +1,207 @@
1
+ import { EventEmitter } from 'events';
2
+ /**
3
+ * Connection state of the instance client
4
+ */
5
+ export type ConnectionState = 'connecting' | 'connected' | 'disconnected' | 'reconnecting';
6
+ /**
7
+ * Callback function for connection state changes
8
+ */
9
+ export type ConnectionStateCallback = (state: ConnectionState) => void;
10
+ /**
11
+ * Events emitted by a simctl execution
12
+ */
13
+ export interface SimctlExecutionEvents {
14
+ stdout: (data: Buffer) => void;
15
+ stderr: (data: Buffer) => void;
16
+ 'line-stdout': (line: string) => void;
17
+ 'line-stderr': (line: string) => void;
18
+ exit: (code: number) => void;
19
+ error: (error: Error) => void;
20
+ }
21
+ /**
22
+ * A client for interacting with a Limrun iOS instance
23
+ */
24
+ export type InstanceClient = {
25
+ /**
26
+ * Take a screenshot of the current screen
27
+ * @returns A promise that resolves to the screenshot data
28
+ */
29
+ screenshot: () => Promise<ScreenshotData>;
30
+ /**
31
+ * Disconnect from the Limrun instance
32
+ */
33
+ disconnect: () => void;
34
+ /**
35
+ * Get current connection state
36
+ */
37
+ getConnectionState: () => ConnectionState;
38
+ /**
39
+ * Register callback for connection state changes
40
+ * @returns A function to unregister the callback
41
+ */
42
+ onConnectionStateChange: (callback: ConnectionStateCallback) => () => void;
43
+ /**
44
+ * Run `simctl` command targeting the instance with given arguments.
45
+ * Returns an EventEmitter that streams stdout, stderr, and exit events.
46
+ *
47
+ * @param args Arguments to pass to simctl
48
+ * @returns A SimctlExecution handle for listening to command output
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * const execution = client.simctl(['boot', 'device-id']);
53
+ *
54
+ * // Listen to raw data
55
+ * execution.on('stdout', (data) => {
56
+ * console.log('stdout:', data.toString());
57
+ * });
58
+ *
59
+ * // Or listen line-by-line
60
+ * execution.on('line-stdout', (line) => {
61
+ * console.log('Line:', line);
62
+ * });
63
+ *
64
+ * execution.on('line-stderr', (line) => {
65
+ * console.error('Error:', line);
66
+ * });
67
+ *
68
+ * execution.on('exit', (code) => {
69
+ * console.log('Process exited with code:', code);
70
+ * });
71
+ *
72
+ * // Or wait for completion
73
+ * const result = await execution.wait();
74
+ * console.log('Exit code:', result.code);
75
+ * console.log('Full stdout:', result.stdout.toString());
76
+ * ```
77
+ */
78
+ simctl: (args: string[]) => SimctlExecution;
79
+ /**
80
+ * Copy a file to the sandbox of the simulator. Returns the path of the file that can be used in simctl commands.
81
+ * @param name The name of the file in the sandbox of the simulator.
82
+ * @param path The path of the file to copy to the sandbox of the simulator.
83
+ * @returns A promise that resolves to the path of the file that can be used in simctl commands.
84
+ */
85
+ cp: (name: string, path: string) => Promise<string>;
86
+ };
87
+ /**
88
+ * Controls the verbosity of logging in the client
89
+ */
90
+ export type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
91
+ /**
92
+ * Configuration options for creating an iOS client
93
+ */
94
+ export type InstanceClientOptions = {
95
+ /**
96
+ * The API URL for the instance.
97
+ */
98
+ apiUrl: string;
99
+ /**
100
+ * The token to use for authentication.
101
+ */
102
+ token: string;
103
+ /**
104
+ * Controls logging verbosity
105
+ * @default 'info'
106
+ */
107
+ logLevel?: LogLevel;
108
+ /**
109
+ * Maximum number of reconnection attempts
110
+ * @default 6
111
+ */
112
+ maxReconnectAttempts?: number;
113
+ /**
114
+ * Initial reconnection delay in milliseconds
115
+ * @default 1000
116
+ */
117
+ reconnectDelay?: number;
118
+ /**
119
+ * Maximum reconnection delay in milliseconds
120
+ * @default 30000
121
+ */
122
+ maxReconnectDelay?: number;
123
+ };
124
+ type ScreenshotData = {
125
+ dataUri: string;
126
+ };
127
+ /**
128
+ * Handle for a running simctl command execution.
129
+ *
130
+ * This class extends EventEmitter and provides streaming access to command output.
131
+ * Methods starting with underscore (_) are internal and should not be called directly.
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * const execution = client.simctl(['boot', 'device-id']);
136
+ *
137
+ * // Listen to raw output
138
+ * execution.on('stdout', (data) => console.log(data.toString()));
139
+ *
140
+ * // Or listen line-by-line (more convenient for most use cases)
141
+ * execution.on('line-stdout', (line) => console.log('Output:', line));
142
+ * execution.on('line-stderr', (line) => console.error('Error:', line));
143
+ *
144
+ * execution.on('exit', (code) => console.log('Exit code:', code));
145
+ * ```
146
+ */
147
+ export declare class SimctlExecution extends EventEmitter {
148
+ private stdoutChunks;
149
+ private stderrChunks;
150
+ private stdoutLineBuffer;
151
+ private stderrLineBuffer;
152
+ private exitCodeValue;
153
+ private completed;
154
+ private waitPromise;
155
+ private stopCallback;
156
+ get isRunning(): boolean;
157
+ constructor(stopCallback: () => void);
158
+ /**
159
+ * Register an event listener for stdout, stderr, line-stdout, line-stderr, exit, or error events.
160
+ * @param event The event name
161
+ * @param listener The callback function for this event
162
+ */
163
+ on<E extends keyof SimctlExecutionEvents>(event: E, listener: SimctlExecutionEvents[E]): this;
164
+ /**
165
+ * Register a one-time event listener that will be removed after firing once.
166
+ * @param event The event name
167
+ * @param listener The callback function for this event
168
+ */
169
+ once<E extends keyof SimctlExecutionEvents>(event: E, listener: SimctlExecutionEvents[E]): this;
170
+ /**
171
+ * Remove an event listener.
172
+ * @param event The event name
173
+ * @param listener The callback function to remove
174
+ */
175
+ off<E extends keyof SimctlExecutionEvents>(event: E, listener: SimctlExecutionEvents[E]): this;
176
+ /**
177
+ * Wait for the command to complete and get the full result.
178
+ * This accumulates all stdout/stderr chunks in memory.
179
+ * @returns Promise that resolves with exit code and complete output
180
+ */
181
+ wait(): Promise<{
182
+ code: number;
183
+ stdout: Buffer;
184
+ stderr: Buffer;
185
+ }>;
186
+ /**
187
+ * Stop the running simctl command (if supported by server).
188
+ * This cleans up the execution tracking.
189
+ */
190
+ stop(): void;
191
+ /** @internal - Handle stdout data from server */
192
+ _handleStdout(data: Buffer): void;
193
+ /** @internal - Handle stderr data from server */
194
+ _handleStderr(data: Buffer): void;
195
+ /** @internal - Handle exit code from server */
196
+ _handleExit(code: number): void;
197
+ /** @internal - Handle errors from server or connection */
198
+ _handleError(error: Error): void;
199
+ }
200
+ /**
201
+ * Creates a client for interacting with a Limrun iOS instance
202
+ * @param options Configuration options including webrtcUrl, token and log level
203
+ * @returns An InstanceClient for controlling the instance
204
+ */
205
+ export declare function createInstanceClient(options: InstanceClientOptions): Promise<InstanceClient>;
206
+ export {};
207
+ //# sourceMappingURL=ios-client.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ios-client.d.mts","sourceRoot":"","sources":["src/ios-client.ts"],"names":[],"mappings":"OAEO,EAAE,YAAY,EAAE,MAAM,QAAQ;AAErC;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,WAAW,GAAG,cAAc,GAAG,cAAc,CAAC;AAE3F;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,IAAI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;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC,CA2alG"}
@@ -0,0 +1,207 @@
1
+ import { EventEmitter } from 'events';
2
+ /**
3
+ * Connection state of the instance client
4
+ */
5
+ export type ConnectionState = 'connecting' | 'connected' | 'disconnected' | 'reconnecting';
6
+ /**
7
+ * Callback function for connection state changes
8
+ */
9
+ export type ConnectionStateCallback = (state: ConnectionState) => void;
10
+ /**
11
+ * Events emitted by a simctl execution
12
+ */
13
+ export interface SimctlExecutionEvents {
14
+ stdout: (data: Buffer) => void;
15
+ stderr: (data: Buffer) => void;
16
+ 'line-stdout': (line: string) => void;
17
+ 'line-stderr': (line: string) => void;
18
+ exit: (code: number) => void;
19
+ error: (error: Error) => void;
20
+ }
21
+ /**
22
+ * A client for interacting with a Limrun iOS instance
23
+ */
24
+ export type InstanceClient = {
25
+ /**
26
+ * Take a screenshot of the current screen
27
+ * @returns A promise that resolves to the screenshot data
28
+ */
29
+ screenshot: () => Promise<ScreenshotData>;
30
+ /**
31
+ * Disconnect from the Limrun instance
32
+ */
33
+ disconnect: () => void;
34
+ /**
35
+ * Get current connection state
36
+ */
37
+ getConnectionState: () => ConnectionState;
38
+ /**
39
+ * Register callback for connection state changes
40
+ * @returns A function to unregister the callback
41
+ */
42
+ onConnectionStateChange: (callback: ConnectionStateCallback) => () => void;
43
+ /**
44
+ * Run `simctl` command targeting the instance with given arguments.
45
+ * Returns an EventEmitter that streams stdout, stderr, and exit events.
46
+ *
47
+ * @param args Arguments to pass to simctl
48
+ * @returns A SimctlExecution handle for listening to command output
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * const execution = client.simctl(['boot', 'device-id']);
53
+ *
54
+ * // Listen to raw data
55
+ * execution.on('stdout', (data) => {
56
+ * console.log('stdout:', data.toString());
57
+ * });
58
+ *
59
+ * // Or listen line-by-line
60
+ * execution.on('line-stdout', (line) => {
61
+ * console.log('Line:', line);
62
+ * });
63
+ *
64
+ * execution.on('line-stderr', (line) => {
65
+ * console.error('Error:', line);
66
+ * });
67
+ *
68
+ * execution.on('exit', (code) => {
69
+ * console.log('Process exited with code:', code);
70
+ * });
71
+ *
72
+ * // Or wait for completion
73
+ * const result = await execution.wait();
74
+ * console.log('Exit code:', result.code);
75
+ * console.log('Full stdout:', result.stdout.toString());
76
+ * ```
77
+ */
78
+ simctl: (args: string[]) => SimctlExecution;
79
+ /**
80
+ * Copy a file to the sandbox of the simulator. Returns the path of the file that can be used in simctl commands.
81
+ * @param name The name of the file in the sandbox of the simulator.
82
+ * @param path The path of the file to copy to the sandbox of the simulator.
83
+ * @returns A promise that resolves to the path of the file that can be used in simctl commands.
84
+ */
85
+ cp: (name: string, path: string) => Promise<string>;
86
+ };
87
+ /**
88
+ * Controls the verbosity of logging in the client
89
+ */
90
+ export type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
91
+ /**
92
+ * Configuration options for creating an iOS client
93
+ */
94
+ export type InstanceClientOptions = {
95
+ /**
96
+ * The API URL for the instance.
97
+ */
98
+ apiUrl: string;
99
+ /**
100
+ * The token to use for authentication.
101
+ */
102
+ token: string;
103
+ /**
104
+ * Controls logging verbosity
105
+ * @default 'info'
106
+ */
107
+ logLevel?: LogLevel;
108
+ /**
109
+ * Maximum number of reconnection attempts
110
+ * @default 6
111
+ */
112
+ maxReconnectAttempts?: number;
113
+ /**
114
+ * Initial reconnection delay in milliseconds
115
+ * @default 1000
116
+ */
117
+ reconnectDelay?: number;
118
+ /**
119
+ * Maximum reconnection delay in milliseconds
120
+ * @default 30000
121
+ */
122
+ maxReconnectDelay?: number;
123
+ };
124
+ type ScreenshotData = {
125
+ dataUri: string;
126
+ };
127
+ /**
128
+ * Handle for a running simctl command execution.
129
+ *
130
+ * This class extends EventEmitter and provides streaming access to command output.
131
+ * Methods starting with underscore (_) are internal and should not be called directly.
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * const execution = client.simctl(['boot', 'device-id']);
136
+ *
137
+ * // Listen to raw output
138
+ * execution.on('stdout', (data) => console.log(data.toString()));
139
+ *
140
+ * // Or listen line-by-line (more convenient for most use cases)
141
+ * execution.on('line-stdout', (line) => console.log('Output:', line));
142
+ * execution.on('line-stderr', (line) => console.error('Error:', line));
143
+ *
144
+ * execution.on('exit', (code) => console.log('Exit code:', code));
145
+ * ```
146
+ */
147
+ export declare class SimctlExecution extends EventEmitter {
148
+ private stdoutChunks;
149
+ private stderrChunks;
150
+ private stdoutLineBuffer;
151
+ private stderrLineBuffer;
152
+ private exitCodeValue;
153
+ private completed;
154
+ private waitPromise;
155
+ private stopCallback;
156
+ get isRunning(): boolean;
157
+ constructor(stopCallback: () => void);
158
+ /**
159
+ * Register an event listener for stdout, stderr, line-stdout, line-stderr, exit, or error events.
160
+ * @param event The event name
161
+ * @param listener The callback function for this event
162
+ */
163
+ on<E extends keyof SimctlExecutionEvents>(event: E, listener: SimctlExecutionEvents[E]): this;
164
+ /**
165
+ * Register a one-time event listener that will be removed after firing once.
166
+ * @param event The event name
167
+ * @param listener The callback function for this event
168
+ */
169
+ once<E extends keyof SimctlExecutionEvents>(event: E, listener: SimctlExecutionEvents[E]): this;
170
+ /**
171
+ * Remove an event listener.
172
+ * @param event The event name
173
+ * @param listener The callback function to remove
174
+ */
175
+ off<E extends keyof SimctlExecutionEvents>(event: E, listener: SimctlExecutionEvents[E]): this;
176
+ /**
177
+ * Wait for the command to complete and get the full result.
178
+ * This accumulates all stdout/stderr chunks in memory.
179
+ * @returns Promise that resolves with exit code and complete output
180
+ */
181
+ wait(): Promise<{
182
+ code: number;
183
+ stdout: Buffer;
184
+ stderr: Buffer;
185
+ }>;
186
+ /**
187
+ * Stop the running simctl command (if supported by server).
188
+ * This cleans up the execution tracking.
189
+ */
190
+ stop(): void;
191
+ /** @internal - Handle stdout data from server */
192
+ _handleStdout(data: Buffer): void;
193
+ /** @internal - Handle stderr data from server */
194
+ _handleStderr(data: Buffer): void;
195
+ /** @internal - Handle exit code from server */
196
+ _handleExit(code: number): void;
197
+ /** @internal - Handle errors from server or connection */
198
+ _handleError(error: Error): void;
199
+ }
200
+ /**
201
+ * Creates a client for interacting with a Limrun iOS instance
202
+ * @param options Configuration options including webrtcUrl, token and log level
203
+ * @returns An InstanceClient for controlling the instance
204
+ */
205
+ export declare function createInstanceClient(options: InstanceClientOptions): Promise<InstanceClient>;
206
+ export {};
207
+ //# sourceMappingURL=ios-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ios-client.d.ts","sourceRoot":"","sources":["src/ios-client.ts"],"names":[],"mappings":"OAEO,EAAE,YAAY,EAAE,MAAM,QAAQ;AAErC;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,WAAW,GAAG,cAAc,GAAG,cAAc,CAAC;AAE3F;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;AAEvE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;OAGG;IACH,UAAU,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,CAAC;IAE1C;;OAEG;IACH,UAAU,EAAE,MAAM,IAAI,CAAC;IAEvB;;OAEG;IACH,kBAAkB,EAAE,MAAM,eAAe,CAAC;IAE1C;;;OAGG;IACH,uBAAuB,EAAE,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