Repository navigation
Expand file tree
/
Copy pathruntime.ts
More file actions
600 lines (582 loc) · 24.2 KB
/
Copy pathruntime.ts
File metadata and controls
600 lines (582 loc) · 24.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
import {
type DeviceBinding,
type RuntimeOperationFact,
localRuntimeOwner,
whenAdmitted,
} from '@agent-device/contracts/platform-runtime';
import { bindSimulatorReadiness } from './runtime-simulator-readiness.ts';
import type { NetworkDumpInput } from '@agent-device/contracts/network-runtime';
import type { AppStateRuntimeOperations } from '@agent-device/contracts/app-state-runtime';
import { bindAppleAppStateRuntime } from './app-state-runtime.ts';
import type {
PlatformRuntimeHost,
PlatformRuntimeOperations,
PlatformRuntimeOwner,
} from '@agent-device/contracts/platform-runtime-operations';
import {
applicationLifecycleOperationFacts,
availableApplicationLifecycleOperations,
} from '@agent-device/contracts/application-lifecycle-runtime';
import {
bindElementTextRuntime,
elementTextRuntimeOperationFacts,
} from '@agent-device/contracts/element-text-runtime';
import {
bindLocalFocusInteractor,
focusRuntimeOperationFacts,
} from '@agent-device/contracts/focus-runtime';
import { bindLocalGestureInteractor } from '@agent-device/contracts/gesture-runtime';
import { bindLocalScrollInteractor } from '@agent-device/contracts/scroll-runtime';
import {
bindLocalScreenshotInteractor,
screenshotRuntimeOperationFacts,
} from '@agent-device/contracts/screenshot-runtime';
import { selectorObservationRuntimeOperationFacts } from '@agent-device/contracts/selector-observation-runtime';
import { snapshotRuntimeOperationFacts } from '@agent-device/contracts/snapshot-runtime';
import {
bindLocalTypeTextInteractor,
typeTextRuntimeOperationFacts,
} from '@agent-device/contracts/type-text-runtime';
import {
bindLocalTouchInteractor,
touchRuntimeOperationFacts,
} from '@agent-device/contracts/touch-runtime';
import { viewportRuntimeOperationFacts } from '@agent-device/contracts/viewport-runtime';
import {
isIosFamily,
isMacOs,
resolveDeviceAppleOs,
type DeviceInfo,
} from '@agent-device/kernel/device';
import { audioProbeRuntimeOperationFacts } from '@agent-device/contracts/audio-probe-runtime';
import { perfRuntimeOperationFacts } from '@agent-device/contracts/perf-runtime';
import { createHostAudioProbeCaptureOperations } from '@agent-device/capture-kit';
import { appleAudioProbeCaptureFact } from './audio/runtime.ts';
import { createApplePerfOperations } from './perf/runtime.ts';
import { appleGestureAndScrollFacts } from './gesture-facts.ts';
import { createAppleAppLogRuntime } from './logs/runtime.ts';
import { dumpAppleNetworkTraffic } from './network/runtime.ts';
import {
appleScreenRecordingFacts,
createAppleScreenRecordingOperations,
} from './recording/runtime.ts';
import type { EnsureReadyInput } from '@agent-device/contracts/device-readiness-runtime';
import { ensureAppleReady } from './readiness/runtime.ts';
import { bindAppleApplicationLifecycle } from './lifecycle.ts';
import {
appleAppDeploymentFacts,
createAppleAppDeploymentOperations,
} from './deployment/runtime.ts';
import { appleNavigationFacts, createAppleNavigationOperations } from './navigation/runtime.ts';
import { appleSystemFacts, createAppleSystemOperations } from './system/runtime.ts';
import { appleFoldableFacts, createAppleFoldableOperations } from './foldable/runtime.ts';
import { bindAppleFindTextRuntime, bindAppleSnapshotRuntime } from './runtime-snapshot.ts';
import type { MacOsAppBackend } from '@agent-device/contracts/session';
import { hostMacOsAppBackend } from './os/macos/app-backend.ts';
import { macOsNativeBackendFacts } from './os/macos/native-backend-facts.ts';
import { createAppleSnapshotRoute } from './snapshot-route.ts';
const owner = localRuntimeOwner('apple');
const available = Object.freeze({ available: true } as const);
const unavailable = Object.freeze({
available: false,
reason: 'unsupported-platform-leaf',
} as const);
const viewportUnavailable = Object.freeze({
available: false,
reason: 'unsupported-platform-leaf',
hint: 'viewport resizes web targets only (--platform web). Apple screen geometry is fixed by the selected simulator or device type — open a different simulator to test another screen size.',
} as const);
const audioQueryUnavailable = Object.freeze({
available: false,
reason: 'unsupported-platform-leaf',
hint: 'the stateless audio page probe is a web-session operation; Apple targets use the host capture.',
} as const);
const perfUnavailable = Object.freeze({
available: false,
reason: 'unsupported-device-backend',
hint: 'perf requires an Apple simulator, macOS device, or CoreDevice-backed physical Apple device.',
} as const);
/**
* Focus drives touch through the Apple interactor, which exists for the simulator and physical
* device kinds only. Parity with the retired `focus` capability bucket
* (`{ simulator: true, device: true }`), stated as one fact instead of an admission table.
*/
const focusKindUnavailable = Object.freeze({
available: false,
reason: 'unsupported-device-kind',
hint: 'focus is supported on Apple simulators and physical devices.',
} as const);
const appStateUnavailable = Object.freeze({
available: false,
reason: 'unsupported-platform-leaf',
hint: "Apple appstate is unavailable here: the runner reads the session app's XCUIApplication state on iOS-family simulators and physical devices only, and the Apple target answers no sessionless foreground probe. The per-command answer is the targetActivation disclosure, which a capture carries when its command had to re-activate the session app (#2682).",
} as const);
/**
* A live runner reads the session app's `XCUIApplication.state` on the kinds it drives; the read
* never starts one (see `bindAppleAppStateRuntime`). That is a fact about the session app, never a
* guess about the foreground (#2682): after `home` the app reports a background state, and which
* app took the screen stays nobody's to tell.
*/
function appleAppStateFact(device: DeviceInfo): RuntimeOperationFact {
if (!isIosFamily(device) || device.appleOs === 'watchos') return appStateUnavailable;
return device.kind === 'simulator' || device.kind === 'device' ? available : appStateUnavailable;
}
const headlessUnavailable = Object.freeze({
available: false,
reason: 'unsupported-provider-mode',
hint: 'Headless boot is supported only for local Android emulators.',
} as const);
const elementTextLeafUnavailable = Object.freeze({
available: false,
reason: 'unsupported-platform-leaf',
hint: 'watchOS has no XCUITest-driveable UI, so element text comes from the captured tree only.',
} as const);
const elementTextKindUnavailable = Object.freeze({
available: false,
reason: 'unsupported-device-kind',
} as const);
const watchOpenTargetUnavailable = Object.freeze({
available: false,
reason: 'unsupported-platform-leaf',
hint: 'watchOS open is not supported because XCUITest cannot drive watchOS UI.',
} as const);
const watchPrepareUnavailable = Object.freeze({
available: false,
reason: 'unsupported-platform-leaf',
hint: 'watchOS runner preparation is not supported because XCUITest cannot drive watchOS UI.',
} as const);
const watchCloseTargetUnavailable = Object.freeze({
available: false,
reason: 'unsupported-platform-leaf',
hint: 'watchOS close is not supported because XCUITest cannot drive watchOS UI.',
} as const);
const runtimeHintsUnavailable = Object.freeze({
available: false,
reason: 'unsupported-device-kind',
hint: 'Runtime hints are supported only for local iOS-family simulators and Android devices.',
} as const);
const appleOpenTargetKindUnavailable = unsupportedAppleDeviceKind(
'open is supported only for Apple simulators and devices.',
);
const applePrepareKindUnavailable = unsupportedAppleDeviceKind(
'prepare is supported only for Apple simulators and devices.',
);
const appleCloseTargetKindUnavailable = unsupportedAppleDeviceKind(
'close is supported only for Apple simulators and devices.',
);
const portReverseUnavailable = Object.freeze({
available: false,
reason: 'unsupported-provider-mode',
hint: 'Port reverse is supported only by an owning provider runtime.',
} as const);
const shutdownKindUnavailable = Object.freeze({
available: false,
reason: 'unsupported-device-kind',
hint: 'shutdown is supported only for Apple simulators and Android emulators.',
} as const);
const snapshotKindUnavailable = unsupportedAppleDeviceKind(
'snapshot is supported only for Apple simulators and devices.',
);
const snapshotCustomActionsUnavailable = Object.freeze({
available: false,
reason: 'unsupported-platform-leaf',
hint: 'Re-run without --actions, or target an iOS simulator.',
} as const);
const screenshotWatchOsUnavailable = Object.freeze({
available: false,
reason: 'unsupported-platform-leaf',
hint: 'screenshot is not supported on watchOS because XCUITest cannot drive watchOS UI.',
} as const);
const screenshotKindUnavailable = unsupportedAppleDeviceKind(
'screenshot is supported only for Apple simulators and devices.',
);
const snapshotActiveAppRequired = Object.freeze({
available: false,
reason: 'owner-capability-missing',
hint: 'Open the app under test before capturing its snapshot.',
} as const);
function unsupportedAppleDeviceKind(hint: string) {
return Object.freeze({ available: false, reason: 'unsupported-device-kind', hint } as const);
}
function shutdownFact(device: DeviceInfo) {
if (!isIosFamily(device) || device.appleOs === 'watchos') return unavailable;
return device.kind === 'simulator' ? available : shutdownKindUnavailable;
}
function appleApplicationLifecycleFacts(device: DeviceInfo) {
const openTarget = appleOpenTargetFact(device);
const prepareAppleRunner = applePrepareAppleRunnerFact(device);
const closeTarget = appleCloseTargetFact(device);
const runtimeHints = appleRuntimeHintsFact(device);
return applicationLifecycleOperationFacts({
resolveOpenTarget: openTarget,
prepareApplicationOpen: openTarget,
openApplication: openTarget,
applyRuntimeHints: runtimeHints,
clearRuntimeHints: runtimeHints,
closeApplication: closeTarget,
finalizeApplicationClose: closeTarget,
prepareAppleRunner,
configureProviderPortReverse: portReverseUnavailable,
});
}
function appleOpenTargetFact(device: DeviceInfo) {
if (resolveDeviceAppleOs(device) === 'watchos') return watchOpenTargetUnavailable;
return device.kind === 'simulator' || device.kind === 'device'
? available
: appleOpenTargetKindUnavailable;
}
function applePrepareAppleRunnerFact(device: DeviceInfo) {
if (resolveDeviceAppleOs(device) === 'watchos') return watchPrepareUnavailable;
return device.kind === 'simulator' || device.kind === 'device'
? available
: applePrepareKindUnavailable;
}
function appleCloseTargetFact(device: DeviceInfo) {
if (resolveDeviceAppleOs(device) === 'watchos') return watchCloseTargetUnavailable;
return device.kind === 'simulator' || device.kind === 'device'
? available
: appleCloseTargetKindUnavailable;
}
function appleRuntimeHintsFact(device: DeviceInfo) {
return resolveDeviceAppleOs(device) !== 'watchos' &&
isIosFamily(device) &&
device.kind === 'simulator'
? available
: runtimeHintsUnavailable;
}
function appInventoryFacts(device: DeviceInfo) {
if (device.appleOs === 'watchos') {
return Object.freeze({
available: false,
reason: 'unsupported-platform-leaf' as const,
hint: 'watchOS app inventory is not supported.',
});
}
if (device.kind === 'device' && device.iosPhysicalDeviceBackend === 'xctest') {
return Object.freeze({
available: false,
reason: 'unsupported-device-backend' as const,
hint: 'App inventory is available only on CoreDevice-backed physical iOS devices.',
});
}
return available;
}
function appleFocusFact(device: DeviceInfo): RuntimeOperationFact {
return device.kind === 'simulator' || device.kind === 'device' ? available : focusKindUnavailable;
}
export function createApplePlatformRuntime(host: PlatformRuntimeHost): PlatformRuntimeOwner {
const appLogs = createAppleAppLogRuntime(host);
const snapshotRoute = createAppleSnapshotRoute(host);
// A daemon setting, read on the first macOS device and kept for the owner's lifetime so facts and
// bindings agree on it. Other Apple devices never read it, so a bad value cannot fail them.
let resolvedMacOsAppBackend: MacOsAppBackend | undefined;
const macOsAppBackend = (device: DeviceInfo): MacOsAppBackend =>
isMacOs(device) ? (resolvedMacOsAppBackend ??= hostMacOsAppBackend()) : 'xctest';
const inspectFacts = async (device: DeviceInfo) => {
const logs = await appLogs.inspectFacts(device);
const deployment = appleAppDeploymentFacts(device);
const leafRecordingFacts = appleScreenRecordingFacts(device);
const hostAvailability = leafRecordingFacts.available
? await host.screenRecording.apple.availability(device)
: undefined;
const recordingFacts =
leafRecordingFacts.available && hostAvailability?.available === false
? Object.freeze({
available: false,
reason: 'unsupported-provider-mode' as const,
hint: hostAvailability.hint,
})
: leafRecordingFacts;
const readiness = device.appleOs === 'watchos' ? unavailable : available;
const boot = isMacOs(device) || device.appleOs === 'watchos' ? unavailable : available;
const apps = appInventoryFacts(device);
return Object.freeze({
device: logs.device,
operations: {
...logs.operations,
...deployment,
appState: appleAppStateFact(device),
networkDump: available,
screenRecordingStart: recordingFacts,
screenRecordingReattach: recordingFacts,
screenRecordingCleanup: recordingFacts,
...appleSnapshotFacts(device),
...screenshotRuntimeOperationFacts({ capture: appleScreenshotFact(device) }),
...selectorObservationRuntimeOperationFacts({
findText: appleSnapshotFact(device),
}),
...viewportRuntimeOperationFacts({ setViewport: viewportUnavailable }),
...focusRuntimeOperationFacts({ focus: appleFocusFact(device) }),
...appleGestureAndScrollFacts(device),
// Text entry rides the same interactor authority the point focus does, so it shares the
// exact kind cell (parity with the retired `type` bucket, `{ simulator, device }`).
...typeTextRuntimeOperationFacts({ type: appleFocusFact(device) }),
...touchRuntimeOperationFacts({
unsupported: unavailable,
tap: appleFocusFact(device),
longPress: appleFocusFact(device),
fill: appleFocusFact(device),
...(isIosFamily(device) ? { tapElementSelector: appleFocusFact(device) } : {}),
}),
...elementTextRuntimeOperationFacts({ readTextAtPoint: appleElementTextFact(device) }),
...appleNavigationFacts(device),
...appleFoldableFacts(device),
...appleSystemFacts(device),
...audioProbeRuntimeOperationFacts({
capture: appleAudioProbeCaptureFact(device),
query: audioQueryUnavailable,
}),
...perfRuntimeOperationFacts(applePerfFacts(device)),
ensureReady: readiness,
bootTarget: boot,
bootTargetHeadless: headlessUnavailable,
listApps: apps,
...appleApplicationLifecycleFacts(device),
shutdownTarget: shutdownFact(device),
...macOsNativeBackendFacts(device, macOsAppBackend(device)),
},
});
};
return Object.freeze({
owner,
ownsDevice: (device) => device.platform === 'apple',
inspectFacts,
bind: async (request) => {
const logs = await appLogs.bind(request);
const facts = await inspectFacts(request.device);
const recordingFacts = facts.operations.screenRecordingStart;
// Typed on its own so the operations literal below stays within what tsc can represent.
const appStateOperations: Partial<AppStateRuntimeOperations> = whenAdmitted(
facts.operations.appState,
() =>
bindAppleAppStateRuntime(host, {
device: request.device,
signal: request.scope.signal,
resolveInteractor: host.localInteractors.resolve,
}),
);
const operations: DeviceBinding<PlatformRuntimeOperations>['operations'] = {
...appStateOperations,
...logs.operations,
...createAppleAppDeploymentOperations({
host,
device: request.device,
signal: request.scope.signal,
}),
networkDump: async (input: NetworkDumpInput) =>
await dumpAppleNetworkTraffic(host, request.device, input, request.scope.signal),
...whenAdmitted(recordingFacts, () =>
createAppleScreenRecordingOperations({
host,
device: request.device,
owner,
signal: request.scope.signal,
}),
),
...whenAdmitted(facts.operations.audioProbeStart, () =>
createHostAudioProbeCaptureOperations({
host: host.audioProbe.hostCapture,
device: request.device,
owner,
}),
),
...whenAdmitted(facts.operations.perfFrames, () =>
createApplePerfOperations({
resolveHost: () => host.perf.apple,
device: request.device,
owner,
}),
),
...whenAdmitted(facts.operations.captureSnapshot, () =>
bindAppleSnapshotRuntime(
host,
{
device: request.device,
signal: request.scope.signal,
appBackend: macOsAppBackend(request.device),
},
snapshotRoute,
),
),
...whenAdmitted(facts.operations.captureScreenshot, () =>
bindLocalScreenshotInteractor({
device: request.device,
signal: request.scope.signal,
resolveInteractor: host.localInteractors.resolve,
}),
),
...whenAdmitted(facts.operations.focusPoint, () =>
bindLocalFocusInteractor({
device: request.device,
signal: request.scope.signal,
resolveInteractor: host.localInteractors.resolve,
}),
),
...bindLocalGestureInteractor({
device: request.device,
signal: request.scope.signal,
facts: facts.operations,
resolveInteractor: host.localInteractors.resolve,
}),
...whenAdmitted(facts.operations.scrollDirection, () =>
bindLocalScrollInteractor({
device: request.device,
signal: request.scope.signal,
resolveInteractor: host.localInteractors.resolve,
}),
),
...whenAdmitted(facts.operations.typeText, () =>
bindLocalTypeTextInteractor({
device: request.device,
signal: request.scope.signal,
resolveInteractor: host.localInteractors.resolve,
}),
),
...whenAdmitted(facts.operations.tapPoint, () =>
bindLocalTouchInteractor({
device: request.device,
signal: request.scope.signal,
resolveInteractor: host.localInteractors.resolve,
facts: facts.operations,
pause: async (milliseconds) =>
await host.clock.sleep(milliseconds, request.scope.signal),
}),
),
...whenAdmitted(facts.operations.readTextAtPoint, () =>
bindElementTextRuntime({
device: request.device,
signal: request.scope.signal,
resolveInteractor: host.localInteractors.resolve,
}),
),
...whenAdmitted(facts.operations.findText, () =>
bindAppleFindTextRuntime(host, {
device: request.device,
signal: request.scope.signal,
appBackend: macOsAppBackend(request.device),
}),
),
...createAppleNavigationOperations({
host,
device: request.device,
signal: request.scope.signal,
admitted: facts.operations,
}),
...createAppleSystemOperations({
host,
device: request.device,
signal: request.scope.signal,
}),
...createAppleFoldableOperations({
device: request.device,
signal: request.scope.signal,
}),
...whenAdmitted(facts.operations.ensureReady, () => ({
ensureReady: async () =>
await ensureAppleReady(host, request.device, request.scope.signal),
})),
...whenAdmitted(facts.operations.bootTarget, () => ({
bootTarget: async (input: EnsureReadyInput) =>
await ensureAppleReady(host, request.device, request.scope.signal, {
deadlineAtMs: input.deadlineAtMs,
}),
})),
...whenAdmitted(facts.operations.listApps, () => ({
listApps: async (input: { device: DeviceInfo; filter: 'all' | 'user-installed' }) => {
request.scope.signal.throwIfAborted();
const { listIosApps } = await import('./core/app-resolution.ts');
return (await listIosApps(input.device, input.filter)).map((app) => ({
id: app.bundleId,
name: app.name,
}));
},
})),
...availableApplicationLifecycleOperations(
bindAppleApplicationLifecycle({
host,
device: request.device,
signal: request.scope.signal,
observation: snapshotRoute,
}),
facts.operations,
),
...whenAdmitted(facts.operations.shutdownTarget, () => ({
shutdownTarget: async () =>
await host.deviceShutdown.apple.shutdownTarget(request.device, request.scope.signal),
})),
};
return Object.freeze({
device: logs.device,
owner,
facts,
operations: bindSimulatorReadiness(operations),
[Symbol.asyncDispose]: async () => await logs[Symbol.asyncDispose](),
}) satisfies DeviceBinding<PlatformRuntimeOperations>;
},
shutdown: async () => {
await Promise.all([appLogs.shutdown(), snapshotRoute.shutdown()]);
},
});
}
function applePerfFacts(device: DeviceInfo): Readonly<{
frames: RuntimeOperationFact;
memorySample: RuntimeOperationFact;
memorySnapshot: RuntimeOperationFact;
nativeCapture: RuntimeOperationFact;
profileReport: RuntimeOperationFact;
}> {
const supported =
device.iosPhysicalDeviceBackend !== 'xctest' && resolveDeviceAppleOs(device) !== 'watchos';
const fact = supported ? available : perfUnavailable;
return {
frames: fact,
memorySample: fact,
memorySnapshot: fact,
nativeCapture: fact,
profileReport: fact,
};
}
/**
* The live point read is the XCUITest runner's `readText` for app sessions and the macOS helper
* for desktop/menubar surfaces. Both need a driveable Apple UI, so watchOS and the non
* simulator/device kinds have no read at all.
*/
function appleElementTextFact(device: DeviceInfo) {
if (resolveDeviceAppleOs(device) === 'watchos') return elementTextLeafUnavailable;
return device.kind === 'simulator' || device.kind === 'device'
? available
: elementTextKindUnavailable;
}
function appleSnapshotFact(device: DeviceInfo) {
if (resolveDeviceAppleOs(device) === 'watchos') return snapshotKindUnavailable;
return device.kind === 'simulator' || device.kind === 'device'
? available
: snapshotKindUnavailable;
}
/**
* macOS surface selection (app window vs desktop/menubar) lives inside the Apple interactor's own
* capture, so the ordinary local interactor binding covers every admitted Apple cell — unlike
* snapshot, whose desktop surfaces come from a separate host port.
*/
function appleScreenshotFact(device: DeviceInfo) {
if (resolveDeviceAppleOs(device) === 'watchos') return screenshotWatchOsUnavailable;
return device.kind === 'simulator' || device.kind === 'device'
? available
: screenshotKindUnavailable;
}
function appleSnapshotFacts(device: DeviceInfo) {
const capture = appleSnapshotFact(device);
return snapshotRuntimeOperationFacts({
capture,
customActions:
capture.available && isIosFamily(device) && device.kind === 'simulator'
? available
: snapshotCustomActionsUnavailable,
withoutActiveApp: isIosFamily(device) ? snapshotActiveAppRequired : capture,
});
}
/**
* An operation is present on a binding only when the owner's own facts admitted it. One helper so
* the binding below reads as a list of admitted operations rather than a chain of branches — and
* so the next operation added here costs no additional complexity.
*/