@limrun/api 0.79.6 → 0.80.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/CHANGELOG.md +41 -0
- package/client.d.mts +4 -1
- package/client.d.mts.map +1 -1
- package/client.d.ts +4 -1
- package/client.d.ts.map +1 -1
- package/client.js +1 -1
- package/client.js.map +1 -1
- package/client.mjs +1 -1
- package/client.mjs.map +1 -1
- package/exec-client.d.mts +64 -15
- package/exec-client.d.mts.map +1 -1
- package/exec-client.d.ts +64 -15
- package/exec-client.d.ts.map +1 -1
- package/exec-client.js.map +1 -1
- package/exec-client.mjs.map +1 -1
- package/folder-sync.d.mts +2 -0
- package/folder-sync.d.mts.map +1 -1
- package/folder-sync.d.ts +2 -0
- package/folder-sync.d.ts.map +1 -1
- package/folder-sync.js +1 -1
- package/folder-sync.js.map +1 -1
- package/folder-sync.mjs +1 -1
- package/folder-sync.mjs.map +1 -1
- package/index.d.mts +2 -2
- package/index.d.mts.map +1 -1
- package/index.d.ts +2 -2
- package/index.d.ts.map +1 -1
- package/index.js.map +1 -1
- package/index.mjs.map +1 -1
- package/instance-client.d.mts +43 -3
- package/instance-client.d.mts.map +1 -1
- package/instance-client.d.ts +43 -3
- package/instance-client.d.ts.map +1 -1
- package/instance-client.js +44 -55
- package/instance-client.js.map +1 -1
- package/instance-client.mjs +43 -55
- package/instance-client.mjs.map +1 -1
- package/internal/asset-source.d.mts +11 -0
- package/internal/asset-source.d.mts.map +1 -0
- package/internal/asset-source.d.ts +11 -0
- package/internal/asset-source.d.ts.map +1 -0
- package/internal/asset-source.js +15 -0
- package/internal/asset-source.js.map +1 -0
- package/internal/asset-source.mjs +12 -0
- package/internal/asset-source.mjs.map +1 -0
- package/internal/file-transfer.d.mts +43 -0
- package/internal/file-transfer.d.mts.map +1 -0
- package/internal/file-transfer.d.ts +43 -0
- package/internal/file-transfer.d.ts.map +1 -0
- package/internal/file-transfer.js +270 -0
- package/internal/file-transfer.js.map +1 -0
- package/internal/file-transfer.mjs +261 -0
- package/internal/file-transfer.mjs.map +1 -0
- package/ios-client.d.mts +23 -4
- package/ios-client.d.mts.map +1 -1
- package/ios-client.d.ts +23 -4
- package/ios-client.d.ts.map +1 -1
- package/ios-client.js +11 -2
- package/ios-client.js.map +1 -1
- package/ios-client.mjs +11 -2
- package/ios-client.mjs.map +1 -1
- package/lib/workload-credentials.d.mts +2 -1
- package/lib/workload-credentials.d.mts.map +1 -1
- package/lib/workload-credentials.d.ts +2 -1
- package/lib/workload-credentials.d.ts.map +1 -1
- package/lib/workload-credentials.js +3 -0
- package/lib/workload-credentials.js.map +1 -1
- package/lib/workload-credentials.mjs +3 -0
- package/lib/workload-credentials.mjs.map +1 -1
- package/package.json +2 -1
- package/resources/access-tokens.d.mts +17 -0
- package/resources/access-tokens.d.mts.map +1 -1
- package/resources/access-tokens.d.ts +17 -0
- package/resources/access-tokens.d.ts.map +1 -1
- package/resources/access-tokens.js +39 -3
- package/resources/access-tokens.js.map +1 -1
- package/resources/access-tokens.mjs +36 -2
- package/resources/access-tokens.mjs.map +1 -1
- package/resources/assets.d.mts +6 -0
- package/resources/assets.d.mts.map +1 -1
- package/resources/assets.d.ts +6 -0
- package/resources/assets.d.ts.map +1 -1
- package/resources/index.d.mts +1 -1
- package/resources/index.d.mts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/macos-instances-helpers.d.mts +112 -0
- package/resources/macos-instances-helpers.d.mts.map +1 -1
- package/resources/macos-instances-helpers.d.ts +112 -0
- package/resources/macos-instances-helpers.d.ts.map +1 -1
- package/resources/macos-instances-helpers.js +105 -0
- package/resources/macos-instances-helpers.js.map +1 -1
- package/resources/macos-instances-helpers.mjs +104 -0
- package/resources/macos-instances-helpers.mjs.map +1 -1
- package/resources/scoped-tokens.d.mts +2 -2
- package/resources/scoped-tokens.d.mts.map +1 -1
- package/resources/scoped-tokens.d.ts +2 -2
- package/resources/scoped-tokens.d.ts.map +1 -1
- package/resources/scoped-tokens.js +9 -2
- package/resources/scoped-tokens.js.map +1 -1
- package/resources/scoped-tokens.mjs +9 -2
- package/resources/scoped-tokens.mjs.map +1 -1
- package/resources/session-artifacts.d.mts +7 -4
- package/resources/session-artifacts.d.mts.map +1 -1
- package/resources/session-artifacts.d.ts +7 -4
- package/resources/session-artifacts.d.ts.map +1 -1
- package/resources/xcode-instances-helpers.d.mts +33 -18
- package/resources/xcode-instances-helpers.d.mts.map +1 -1
- package/resources/xcode-instances-helpers.d.ts +33 -18
- package/resources/xcode-instances-helpers.d.ts.map +1 -1
- package/resources/xcode-instances-helpers.js +5 -2
- package/resources/xcode-instances-helpers.js.map +1 -1
- package/resources/xcode-instances-helpers.mjs +5 -2
- package/resources/xcode-instances-helpers.mjs.map +1 -1
- package/src/client.ts +5 -2
- package/src/exec-client.ts +77 -22
- package/src/folder-sync.ts +3 -1
- package/src/index.ts +9 -0
- package/src/instance-client.ts +87 -60
- package/src/internal/asset-source.ts +13 -0
- package/src/internal/file-transfer.ts +284 -0
- package/src/ios-client.ts +43 -6
- package/src/lib/workload-credentials.ts +6 -1
- package/src/resources/access-tokens.ts +39 -2
- package/src/resources/assets.ts +7 -0
- package/src/resources/index.ts +4 -0
- package/src/resources/macos-instances-helpers.ts +257 -0
- package/src/resources/scoped-tokens.ts +14 -3
- package/src/resources/session-artifacts.ts +7 -4
- package/src/resources/xcode-instances-helpers.ts +49 -19
- package/src/version.ts +1 -1
- package/version.d.mts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
package/src/exec-client.ts
CHANGED
|
@@ -113,15 +113,16 @@ export type XcodeBuildExecRequest = {
|
|
|
113
113
|
certificatePassword?: string;
|
|
114
114
|
/** One profile per embedded bundle. */
|
|
115
115
|
provisioningProfilesBase64?: string[];
|
|
116
|
+
/** Secret read by the build instead of the inline certificate fields. */
|
|
117
|
+
certificateSecret?: string;
|
|
118
|
+
/** Profile secrets the build adds to provisioningProfilesBase64. */
|
|
119
|
+
provisioningProfileSecrets?: string[];
|
|
116
120
|
};
|
|
117
121
|
cloudSigning?: {
|
|
118
122
|
method: 'app-store-connect' | 'release-testing' | 'debugging';
|
|
119
123
|
teamId: string;
|
|
120
|
-
apiKeyId: string;
|
|
121
|
-
apiIssuerId: string;
|
|
122
|
-
apiPrivateKeyBase64: string;
|
|
123
124
|
entitlements?: Record<string, string>;
|
|
124
|
-
};
|
|
125
|
+
} & AppStoreConnectTeamKey;
|
|
125
126
|
/** Wire name retained for compatibility with the limbuild exec API. */
|
|
126
127
|
testflight?: AppStoreUploadConfig;
|
|
127
128
|
buildSettings?: Record<string, string>;
|
|
@@ -136,8 +137,8 @@ export type XcodeBuildExecRequest = {
|
|
|
136
137
|
fileFromSecret?: Record<string, string>;
|
|
137
138
|
gitInit?: boolean;
|
|
138
139
|
/**
|
|
139
|
-
* Build a Debug simulator app that later builds with this option can
|
|
140
|
-
* in place while it runs. See XcodeBuildOptions.hotReload.
|
|
140
|
+
* Build a Debug simulator or Mac app that later builds with this option can
|
|
141
|
+
* update in place while it runs. See XcodeBuildOptions.hotReload.
|
|
141
142
|
*/
|
|
142
143
|
hotReload?: boolean;
|
|
143
144
|
/** How xcodebuild stdout is processed before streaming. Defaults to 'xcbeautify'. */
|
|
@@ -225,13 +226,29 @@ export type GradleReactNativeConfig = {
|
|
|
225
226
|
* passwords live only for the build's duration and never appear in
|
|
226
227
|
* streamed output.
|
|
227
228
|
*/
|
|
228
|
-
export type GradleSigningConfig =
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
229
|
+
export type GradleSigningConfig =
|
|
230
|
+
| {
|
|
231
|
+
/** Base64-encoded PKCS12 or JKS upload keystore. */
|
|
232
|
+
keystoreBase64: string;
|
|
233
|
+
keystorePassword: string;
|
|
234
|
+
keyAlias: string;
|
|
235
|
+
keyPassword: string;
|
|
236
|
+
keystoreSecret?: never;
|
|
237
|
+
}
|
|
238
|
+
| {
|
|
239
|
+
/**
|
|
240
|
+
* Secret ID or name/<exact name> holding the upload key, read by the
|
|
241
|
+
* build itself. The value is the JSON saved for an androidSigningKey:
|
|
242
|
+
* keystoreBase64, keystorePassword, keyAlias and keyPassword. The
|
|
243
|
+
* instance role needs `secret:<target>:read`. Requires a server with
|
|
244
|
+
* credential secret support.
|
|
245
|
+
*/
|
|
246
|
+
keystoreSecret: string;
|
|
247
|
+
keystoreBase64?: never;
|
|
248
|
+
keystorePassword?: never;
|
|
249
|
+
keyAlias?: never;
|
|
250
|
+
keyPassword?: never;
|
|
251
|
+
};
|
|
235
252
|
|
|
236
253
|
export type GradleBuildExecRequest = {
|
|
237
254
|
command: 'gradlebuild';
|
|
@@ -259,8 +276,8 @@ export type GradleBuildExecRequest = {
|
|
|
259
276
|
|
|
260
277
|
/**
|
|
261
278
|
* Publish the built AAB to a Google Play track after a successful build.
|
|
262
|
-
* Requires signing. Exactly one of accessToken or
|
|
263
|
-
* must be set; the credential is held in memory for the build duration
|
|
279
|
+
* Requires signing. Exactly one of accessToken, serviceAccountJsonBase64 or
|
|
280
|
+
* credentialsSecret must be set; the credential is held in memory for the build duration
|
|
264
281
|
* only. Progress and failure causes stream as `playstore` SSE events.
|
|
265
282
|
*/
|
|
266
283
|
export type GradlePlaystoreConfig = {
|
|
@@ -268,6 +285,15 @@ export type GradlePlaystoreConfig = {
|
|
|
268
285
|
accessToken?: string;
|
|
269
286
|
/** Base64-encoded service-account JSON key invited in Play Console. */
|
|
270
287
|
serviceAccountJsonBase64?: string;
|
|
288
|
+
/**
|
|
289
|
+
* Secret ID or name/<exact name> holding the Play credential, read by the
|
|
290
|
+
* build itself: serviceAccountJsonBase64 as saved for a
|
|
291
|
+
* googlePlayServiceAccount, or clientId, clientSecret and refreshToken
|
|
292
|
+
* from a Google sign-in. The build refreshes a sign-in's access token
|
|
293
|
+
* itself. The instance role needs `secret:<target>:read`. Requires a
|
|
294
|
+
* server with credential secret support.
|
|
295
|
+
*/
|
|
296
|
+
credentialsSecret?: string;
|
|
271
297
|
/**
|
|
272
298
|
* Play track ID, passed to Google verbatim: internal (default), alpha,
|
|
273
299
|
* beta, production, or a custom closed-testing track. Publishing
|
|
@@ -424,6 +450,41 @@ export type PlaystoreEvent = {
|
|
|
424
450
|
message?: string;
|
|
425
451
|
};
|
|
426
452
|
|
|
453
|
+
/**
|
|
454
|
+
* An App Store Connect API key passed inline. Prefer {@link AppStoreConnectKeySecret}
|
|
455
|
+
* so the private key stays in Limrun secret storage.
|
|
456
|
+
*/
|
|
457
|
+
export type AppStoreConnectInlineKey = {
|
|
458
|
+
/** App Store Connect API key ID, e.g. 2X9R4HXF34. */
|
|
459
|
+
apiKeyId: string;
|
|
460
|
+
/** Issuer ID for team API keys. Omit for individual API keys. */
|
|
461
|
+
apiIssuerId?: string;
|
|
462
|
+
/** Base64-encoded content of the .p8 private key file. */
|
|
463
|
+
apiPrivateKeyBase64: string;
|
|
464
|
+
apiKeySecret?: never;
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* An App Store Connect API key read from Limrun secret storage by the build
|
|
469
|
+
* itself. The value is the JSON saved for an appStoreConnectApiKey: keyId,
|
|
470
|
+
* privateKeyP8Base64 and, for team keys, issuerId. The instance role needs
|
|
471
|
+
* `secret:<target>:read`. Requires a server with credential secret support.
|
|
472
|
+
*/
|
|
473
|
+
export type AppStoreConnectKeySecret = {
|
|
474
|
+
/** Secret ID or name/<exact name>, e.g. name/VMBY3VYW4U/APP_STORE_CONNECT_API_KEY. */
|
|
475
|
+
apiKeySecret: string;
|
|
476
|
+
apiKeyId?: never;
|
|
477
|
+
apiIssuerId?: never;
|
|
478
|
+
apiPrivateKeyBase64?: never;
|
|
479
|
+
};
|
|
480
|
+
|
|
481
|
+
export type AppStoreConnectKey = AppStoreConnectInlineKey | AppStoreConnectKeySecret;
|
|
482
|
+
|
|
483
|
+
/** Cloud signing needs a team key, which always has an issuer ID. */
|
|
484
|
+
export type AppStoreConnectTeamKey =
|
|
485
|
+
| (AppStoreConnectInlineKey & { apiIssuerId: string })
|
|
486
|
+
| AppStoreConnectKeySecret;
|
|
487
|
+
|
|
427
488
|
export type AppStoreUploadConfig = {
|
|
428
489
|
/**
|
|
429
490
|
* Optional App Store Connect app ID. Its bundle ID must exactly match the
|
|
@@ -431,12 +492,6 @@ export type AppStoreUploadConfig = {
|
|
|
431
492
|
* exact bundle-ID match automatically.
|
|
432
493
|
*/
|
|
433
494
|
appId?: string;
|
|
434
|
-
/** App Store Connect API key ID, e.g. 2X9R4HXF34. */
|
|
435
|
-
apiKeyId: string;
|
|
436
|
-
/** Issuer ID for team API keys. Omit for individual API keys. */
|
|
437
|
-
apiIssuerId?: string;
|
|
438
|
-
/** Base64-encoded content of the .p8 private key file. */
|
|
439
|
-
apiPrivateKeyBase64: string;
|
|
440
495
|
/**
|
|
441
496
|
* How long the server watches for App Store Connect's processing verdict
|
|
442
497
|
* after the upload. A FAILED verdict within the window fails the build;
|
|
@@ -451,7 +506,7 @@ export type AppStoreUploadConfig = {
|
|
|
451
506
|
* App Store Connect before upload.
|
|
452
507
|
*/
|
|
453
508
|
autoIncrementBuildNumber?: boolean;
|
|
454
|
-
};
|
|
509
|
+
} & AppStoreConnectKey;
|
|
455
510
|
|
|
456
511
|
type DataListener = (chunk: string) => void;
|
|
457
512
|
type CloseListener = () => void;
|
package/src/folder-sync.ts
CHANGED
|
@@ -65,6 +65,8 @@ export type FolderSyncOptions = {
|
|
|
65
65
|
compression?: 'zstd' | 'gzip' | 'identity';
|
|
66
66
|
/** Folder the files sync into on the instance. Defaults to the local folder's name. */
|
|
67
67
|
rootName?: string;
|
|
68
|
+
/** Endpoint the batches post to. Defaults to `${apiUrl}/sync`. */
|
|
69
|
+
url?: string;
|
|
68
70
|
/**
|
|
69
71
|
* Called after every successful sync: the one-shot sync, the initial sync
|
|
70
72
|
* in watch mode, and each watch-triggered re-sync.
|
|
@@ -215,7 +217,7 @@ async function httpFolderSyncBatch(
|
|
|
215
217
|
payloadFiles: { filePath: string }[],
|
|
216
218
|
compression: 'zstd' | 'gzip' | 'identity',
|
|
217
219
|
): Promise<FolderSyncHttpResponse> {
|
|
218
|
-
const url = folderSyncHttpUrl(opts.apiUrl);
|
|
220
|
+
const url = opts.url ?? folderSyncHttpUrl(opts.apiUrl);
|
|
219
221
|
const headers: Record<string, string> = {
|
|
220
222
|
// OpenAPI route expects application/octet-stream.
|
|
221
223
|
'Content-Type': 'application/octet-stream',
|
package/src/index.ts
CHANGED
|
@@ -113,6 +113,10 @@ export {
|
|
|
113
113
|
type ExecResult,
|
|
114
114
|
type ExecChildProcess,
|
|
115
115
|
type AppStoreEvent,
|
|
116
|
+
type AppStoreConnectInlineKey,
|
|
117
|
+
type AppStoreConnectKey,
|
|
118
|
+
type AppStoreConnectKeySecret,
|
|
119
|
+
type AppStoreConnectTeamKey,
|
|
116
120
|
type AppStoreUploadConfig,
|
|
117
121
|
type PlaystoreEvent,
|
|
118
122
|
type WebhookConfig,
|
|
@@ -189,6 +193,11 @@ export {
|
|
|
189
193
|
type MacosLaunchMode,
|
|
190
194
|
type MacosLaunchAppOptions,
|
|
191
195
|
type MacosLaunchAppResult,
|
|
196
|
+
type MacosInstalledApp,
|
|
197
|
+
type MacosSyncOptions,
|
|
198
|
+
type MacosSyncResult,
|
|
199
|
+
type MacosFileEntry,
|
|
200
|
+
type PullResult,
|
|
192
201
|
} from './resources/macos-instances-helpers';
|
|
193
202
|
export { type AssetUploadOptions } from './resources/daemon-client-shared';
|
|
194
203
|
export {
|
package/src/instance-client.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { assetSourceFields, type AssetSource } from './internal/asset-source';
|
|
2
|
+
export type { AssetSource } from './internal/asset-source';
|
|
1
3
|
import { WebSocket, Data } from 'ws';
|
|
2
4
|
import { execFile } from 'node:child_process';
|
|
3
5
|
import fs from 'fs';
|
|
@@ -27,7 +29,7 @@ import { androidBlockedDomainsUrl, requestBlockedDomains } from './internal/bloc
|
|
|
27
29
|
import { addTrustedCaCertificate, type TrustedCaCertificate } from './internal/trusted-ca';
|
|
28
30
|
import { persistFields, type PersistOption } from './internal/persist-option';
|
|
29
31
|
import { streamSessionEntries } from './internal/session-stream';
|
|
30
|
-
import type { SessionLogLine, SessionEvent } from './resources/session-artifacts';
|
|
32
|
+
import type { PerformanceSample, SessionLogLine, SessionEvent } from './resources/session-artifacts';
|
|
31
33
|
import { LogcatProcess } from './logcat-process';
|
|
32
34
|
|
|
33
35
|
export { type PersistOption } from './internal/persist-option';
|
|
@@ -371,6 +373,14 @@ export type InstanceClient = {
|
|
|
371
373
|
onEvent: (event: SessionEvent) => void;
|
|
372
374
|
onError?: (error: Error) => void;
|
|
373
375
|
}) => () => void;
|
|
376
|
+
/**
|
|
377
|
+
* Tail the running apps' {@link PerformanceSample}s; no capture is needed.
|
|
378
|
+
* On connect the instance replays its recent samples, so a late subscriber
|
|
379
|
+
* still sees history. Same reconnect and lifecycle semantics as
|
|
380
|
+
* {@link streamAppLogCapture}, except that a gap longer than the replay
|
|
381
|
+
* window loses the samples in between.
|
|
382
|
+
*/
|
|
383
|
+
streamPerformance: (handlers: PerformanceStreamHandlers) => () => void;
|
|
374
384
|
/** Send an application-level keepAlive message on the control websocket. */
|
|
375
385
|
keepAlive: () => void;
|
|
376
386
|
/**
|
|
@@ -420,11 +430,15 @@ export type InstanceClient = {
|
|
|
420
430
|
/** The names the emulator cannot resolve. */
|
|
421
431
|
getBlockedDomains: () => Promise<string[]>;
|
|
422
432
|
/**
|
|
423
|
-
* Send
|
|
433
|
+
* Send a URL or { assetName } to the instance. Names require delegated asset read permission.
|
|
434
|
+
* The instance will download the asset
|
|
424
435
|
* and process it (currently APK install is supported). Resolves on success,
|
|
425
436
|
* rejects with an Error on failure.
|
|
426
437
|
*/
|
|
427
|
-
sendAsset: (
|
|
438
|
+
sendAsset: (source: AssetSource, timeoutMs?: number) => Promise<void>;
|
|
439
|
+
|
|
440
|
+
/** Install an APK by exact asset name using the instance role. */
|
|
441
|
+
installAppByName: (assetName: string, timeoutMs?: number) => Promise<void>;
|
|
428
442
|
|
|
429
443
|
/**
|
|
430
444
|
* Delta-sync a local APK to the instance and install it.
|
|
@@ -465,6 +479,44 @@ export type InstanceClient = {
|
|
|
465
479
|
*/
|
|
466
480
|
export type LogLevel = 'none' | 'error' | 'warn' | 'info' | 'debug';
|
|
467
481
|
|
|
482
|
+
export type PerformanceStreamOptions = {
|
|
483
|
+
/** The instance's status.apiUrl. */
|
|
484
|
+
apiUrl: string;
|
|
485
|
+
/** The instance token. */
|
|
486
|
+
token: string;
|
|
487
|
+
onSample: (sample: PerformanceSample) => void;
|
|
488
|
+
/**
|
|
489
|
+
* Called after each connection's replay of recent samples. Android instances
|
|
490
|
+
* do not send the signal yet, so it is never called for them today.
|
|
491
|
+
*/
|
|
492
|
+
onReplayed?: (() => void) | undefined;
|
|
493
|
+
/**
|
|
494
|
+
* Called at most once, when the stream closes for good: at once with a
|
|
495
|
+
* SessionStreamRejectedError (status 404 when the instance is gone or its runtime
|
|
496
|
+
* predates performance), or after the give-up window when it stays unreachable.
|
|
497
|
+
*/
|
|
498
|
+
onError?: ((error: Error) => void) | undefined;
|
|
499
|
+
};
|
|
500
|
+
|
|
501
|
+
/** What a performance stream reports to, without the instance's address. */
|
|
502
|
+
export type PerformanceStreamHandlers = Omit<PerformanceStreamOptions, 'apiUrl' | 'token'>;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Tails the running apps' {@link PerformanceSample}s of an Android instance with only its apiUrl
|
|
506
|
+
* and token, without the WebSocket an {@link InstanceClient} opens. The instance samples every app
|
|
507
|
+
* you installed once a second; on connect it replays its recent samples, then sends new ones.
|
|
508
|
+
* Call the returned function to stop.
|
|
509
|
+
*/
|
|
510
|
+
export function streamPerformance(options: PerformanceStreamOptions): () => void {
|
|
511
|
+
return streamSessionEntries<PerformanceSample>({
|
|
512
|
+
url: `${options.apiUrl}/session/performance/events`,
|
|
513
|
+
token: options.token,
|
|
514
|
+
onEntry: options.onSample,
|
|
515
|
+
onReplayed: options.onReplayed,
|
|
516
|
+
onError: options.onError,
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
|
|
468
520
|
export type ScrollDirection = 'up' | 'down' | 'left' | 'right';
|
|
469
521
|
export enum RecordingQuality {
|
|
470
522
|
Q5 = 5,
|
|
@@ -770,15 +822,14 @@ type ScreenshotErrorResponse = {
|
|
|
770
822
|
id: string;
|
|
771
823
|
};
|
|
772
824
|
|
|
773
|
-
type AssetRequest = {
|
|
774
|
-
type: 'asset';
|
|
775
|
-
url: string;
|
|
776
|
-
};
|
|
825
|
+
type AssetRequest = { type: 'asset'; id: string } & ({ url: string } | { assetName: string });
|
|
777
826
|
|
|
778
827
|
type AssetResultResponse = {
|
|
779
828
|
type: 'assetResult';
|
|
780
829
|
result: 'success' | 'failure' | string;
|
|
781
|
-
url
|
|
830
|
+
url?: string;
|
|
831
|
+
assetName?: string;
|
|
832
|
+
id?: string;
|
|
782
833
|
message?: string;
|
|
783
834
|
};
|
|
784
835
|
|
|
@@ -1113,7 +1164,7 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
|
|
|
1113
1164
|
let intentionalDisconnect = false;
|
|
1114
1165
|
let lastError: string | undefined;
|
|
1115
1166
|
const pendingRequests: Map<string, PendingRequest<unknown>> = new Map();
|
|
1116
|
-
const
|
|
1167
|
+
const pendingAssetRequests: Map<string, PendingRequest<void> & { url?: string }> = new Map();
|
|
1117
1168
|
// App exit callbacks are keyed by execId. They intentionally survive transient
|
|
1118
1169
|
// WebSocket reconnects and are one-shot once a matching appExit is processed.
|
|
1119
1170
|
const appExitCallbacks: Map<string, LaunchAppExitCallback> = new Map();
|
|
@@ -1156,13 +1207,11 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
|
|
|
1156
1207
|
request.reject(new Error(reason));
|
|
1157
1208
|
});
|
|
1158
1209
|
pendingRequests.clear();
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
request.reject(new Error(reason));
|
|
1163
|
-
});
|
|
1210
|
+
pendingAssetRequests.forEach((request) => {
|
|
1211
|
+
clearTimeout(request.timeout);
|
|
1212
|
+
request.reject(new Error(reason));
|
|
1164
1213
|
});
|
|
1165
|
-
|
|
1214
|
+
pendingAssetRequests.clear();
|
|
1166
1215
|
};
|
|
1167
1216
|
|
|
1168
1217
|
const cleanup = (): void => {
|
|
@@ -1434,18 +1483,17 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
|
|
|
1434
1483
|
}
|
|
1435
1484
|
case 'assetResult': {
|
|
1436
1485
|
logger.debug('Received assetResult:', message);
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
if (
|
|
1440
|
-
|
|
1441
|
-
break;
|
|
1486
|
+
let id = message.id;
|
|
1487
|
+
// Old servers omit id. Only those replies may fall back to the oldest matching URL.
|
|
1488
|
+
if (id === undefined && typeof message.url === 'string') {
|
|
1489
|
+
id = [...pendingAssetRequests].find(([, request]) => request.url === message.url)?.[0];
|
|
1442
1490
|
}
|
|
1443
|
-
const request =
|
|
1444
|
-
if (
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
pendingAssetRequestsByUrl.set(url, queue);
|
|
1491
|
+
const request = typeof id === 'string' ? pendingAssetRequests.get(id) : undefined;
|
|
1492
|
+
if (!request || typeof id !== 'string') {
|
|
1493
|
+
logger.warn('Received assetResult for an unknown or completed request');
|
|
1494
|
+
break;
|
|
1448
1495
|
}
|
|
1496
|
+
pendingAssetRequests.delete(id);
|
|
1449
1497
|
clearTimeout(request.timeout);
|
|
1450
1498
|
if (message.result === 'success') {
|
|
1451
1499
|
logger.debug('Asset result is success');
|
|
@@ -1558,6 +1606,8 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
|
|
|
1558
1606
|
stopEventCapture,
|
|
1559
1607
|
streamAppLogCapture,
|
|
1560
1608
|
streamEventCapture,
|
|
1609
|
+
streamPerformance: (handlers: PerformanceStreamHandlers) =>
|
|
1610
|
+
streamPerformance({ ...handlers, apiUrl: options.apiUrl, token: options.token }),
|
|
1561
1611
|
keepAlive,
|
|
1562
1612
|
disconnect,
|
|
1563
1613
|
startAdbTunnel,
|
|
@@ -1568,6 +1618,7 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
|
|
|
1568
1618
|
setBlockedDomains,
|
|
1569
1619
|
getBlockedDomains,
|
|
1570
1620
|
sendAsset,
|
|
1621
|
+
installAppByName: (assetName, timeoutMs) => sendAsset({ assetName }, timeoutMs),
|
|
1571
1622
|
syncApp,
|
|
1572
1623
|
getConnectionState,
|
|
1573
1624
|
onConnectionStateChange,
|
|
@@ -2040,53 +2091,29 @@ export async function createInstanceClient(options: InstanceClientOptions): Prom
|
|
|
2040
2091
|
const getBlockedDomains = (): Promise<string[]> =>
|
|
2041
2092
|
requestBlockedDomains(androidBlockedDomainsUrl(requireAdbUrl('read blocked domains')), options.token);
|
|
2042
2093
|
|
|
2043
|
-
const sendAsset = async (
|
|
2094
|
+
const sendAsset = async (source: AssetSource, timeoutMs?: number): Promise<void> => {
|
|
2044
2095
|
if (!ws || ws.readyState !== WebSocket.OPEN) {
|
|
2045
2096
|
return Promise.reject(new Error('WebSocket is not connected or connection is not open.'));
|
|
2046
2097
|
}
|
|
2047
|
-
const
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
};
|
|
2098
|
+
const fields = assetSourceFields(source);
|
|
2099
|
+
const id = crypto.randomUUID();
|
|
2100
|
+
const assetRequest: AssetRequest = { type: 'asset', ...fields, id };
|
|
2051
2101
|
return new Promise<void>((resolve, reject) => {
|
|
2052
|
-
let request: PendingRequest<void>;
|
|
2053
2102
|
const timeout = setTimeout(() => {
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
return;
|
|
2057
|
-
}
|
|
2058
|
-
const idx = queue.indexOf(request);
|
|
2059
|
-
if (idx >= 0) {
|
|
2060
|
-
queue.splice(idx, 1);
|
|
2061
|
-
reject(new Error(`Request asset timed out for url: ${url}`));
|
|
2062
|
-
}
|
|
2063
|
-
if (queue.length === 0) {
|
|
2064
|
-
pendingAssetRequestsByUrl.delete(url);
|
|
2065
|
-
} else {
|
|
2066
|
-
pendingAssetRequestsByUrl.set(url, queue);
|
|
2103
|
+
if (pendingAssetRequests.delete(id)) {
|
|
2104
|
+
reject(new Error(`Request asset timed out for id: ${id}`));
|
|
2067
2105
|
}
|
|
2068
2106
|
}, timeoutMs ?? 120_000);
|
|
2069
|
-
|
|
2107
|
+
pendingAssetRequests.set(id, {
|
|
2070
2108
|
resolve,
|
|
2071
|
-
reject
|
|
2109
|
+
reject,
|
|
2072
2110
|
timeout,
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
queue.push(request);
|
|
2076
|
-
pendingAssetRequestsByUrl.set(url, queue);
|
|
2111
|
+
...('url' in fields && { url: fields.url }),
|
|
2112
|
+
});
|
|
2077
2113
|
ws!.send(JSON.stringify(assetRequest), (err?: Error) => {
|
|
2078
2114
|
if (err) {
|
|
2079
2115
|
clearTimeout(timeout);
|
|
2080
|
-
|
|
2081
|
-
const idx = queued.indexOf(request);
|
|
2082
|
-
if (idx >= 0) {
|
|
2083
|
-
queued.splice(idx, 1);
|
|
2084
|
-
}
|
|
2085
|
-
if (queued.length === 0) {
|
|
2086
|
-
pendingAssetRequestsByUrl.delete(url);
|
|
2087
|
-
} else {
|
|
2088
|
-
pendingAssetRequestsByUrl.set(url, queued);
|
|
2089
|
-
}
|
|
2116
|
+
pendingAssetRequests.delete(id);
|
|
2090
2117
|
logger.error('Failed to send asset request:', err);
|
|
2091
2118
|
reject(err);
|
|
2092
2119
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** A download URL, or an asset the instance has delegated permission to read. */
|
|
2
|
+
export type AssetSource = string | { assetName: string; url?: never };
|
|
3
|
+
|
|
4
|
+
export function assetSourceFields(source: AssetSource): { url: string } | { assetName: string } {
|
|
5
|
+
if (typeof source === 'string') {
|
|
6
|
+
if (!source) throw new Error('url must not be empty');
|
|
7
|
+
return { url: source };
|
|
8
|
+
}
|
|
9
|
+
if (!source || typeof source.assetName !== 'string' || !source.assetName || 'url' in source) {
|
|
10
|
+
throw new Error('Provide a URL string or { assetName: <non-empty name> }');
|
|
11
|
+
}
|
|
12
|
+
return { assetName: source.assetName };
|
|
13
|
+
}
|