mirror of
https://github.com/callstack/agent-device.git
synced 2026-09-14 20:06:34 +08:00
d76e0f94e9
* refactor: migrate snapshot to device runtime * refactor: complete snapshot runtime policy cutover * test: enforce snapshot owner-facts admission * refactor: consolidate desktop snapshot capture * fix: scroll to visible iOS smoke targets * fix: close snapshot cutover alias bypasses * fix: constrain snapshot admission identity flow * fix: enforce snapshot admission through owner facts * fix: adapt replay source tests to snapshot runtime
40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import type {
|
|
CaptureSnapshotInput,
|
|
PlatformRuntimeHost,
|
|
PlatformRuntimeOperations,
|
|
} from '@agent-device/contracts/platform';
|
|
import { bindLocalSnapshotInteractor } from '@agent-device/contracts/platform';
|
|
import { isMacOs, type DeviceInfo } from '@agent-device/kernel/device';
|
|
|
|
/** Apple-owned selection between app snapshots and explicit macOS surface snapshots. */
|
|
export function bindAppleSnapshotRuntime(
|
|
host: PlatformRuntimeHost,
|
|
request: Readonly<{ device: DeviceInfo; signal: AbortSignal }>,
|
|
): SnapshotRuntimeOperation {
|
|
const appSnapshot = bindLocalSnapshotInteractor({
|
|
device: request.device,
|
|
signal: request.signal,
|
|
resolveInteractor: host.localInteractors.resolve,
|
|
});
|
|
const captureSnapshot = async (input: CaptureSnapshotInput) => {
|
|
if (
|
|
isMacOs(request.device) &&
|
|
input.options?.surface !== undefined &&
|
|
input.options.surface !== 'app'
|
|
) {
|
|
return await host.snapshot.captureSurface(request.device, input.options, request.signal);
|
|
}
|
|
return await appSnapshot.captureSnapshot(input);
|
|
};
|
|
return Object.freeze({
|
|
captureSnapshot,
|
|
captureSnapshotWithCustomActions: captureSnapshot,
|
|
captureSnapshotWithoutActiveApp: captureSnapshot,
|
|
});
|
|
}
|
|
|
|
type SnapshotRuntimeOperation = Pick<
|
|
PlatformRuntimeOperations,
|
|
'captureSnapshot' | 'captureSnapshotWithCustomActions' | 'captureSnapshotWithoutActiveApp'
|
|
>;
|