MCPcopy Index your code
hub / github.com/callstack/agent-device / handlePinchCommand

Function handlePinchCommand

src/core/dispatch-interactions.ts:867–892  ·  view source on GitHub ↗
(
  device: DeviceInfo,
  interactor: Interactor,
  positionals: string[],
  context: DispatchContext | undefined,
)

Source from the content-addressed store, hash-verified

865}
866
867export async function handlePinchCommand(
868 device: DeviceInfo,
869 interactor: Interactor,
870 positionals: string[],
871 context: DispatchContext | undefined,
872): Promise<Record<string, unknown>> {
873 // Cross-platform TV-target gate (also rejects Android TV, which shares target: 'tv');
874 // NOT narrowed to the tvOS Apple-OS leaf (isTvOsDevice) so Android-TV behavior is unchanged.
875 if (device.target === 'tv') {
876 throw new AppError('UNSUPPORTED_OPERATION', 'gesture pinch is not supported on tvOS');
877 }
878 if (isMacOs(device) && context?.surface && context.surface !== 'app') {
879 throw new AppError(
880 'UNSUPPORTED_OPERATION',
881 'gesture pinch is only supported in macOS app sessions. Re-open the target app without --surface desktop|menubar|frontmost-app first.',
882 );
883 }
884 const scale = Number(positionals[0]);
885 const x = positionals[1] ? Number(positionals[1]) : undefined;
886 const y = positionals[2] ? Number(positionals[2]) : undefined;
887 if (Number.isNaN(scale) || scale <= 0) {
888 throw new AppError('INVALID_ARGS', 'gesture pinch requires scale > 0');
889 }
890 const interactionResult = await interactor.pinch(scale, x, y);
891 return { scale, x, y, ...interactionResult, ...successText(`Pinched to scale ${scale}`) };
892}
893
894export async function handleRotateGestureCommand(
895 device: DeviceInfo,

Callers 1

dispatch.tsFile · 0.90

Calls 3

isMacOsFunction · 0.90
successTextFunction · 0.90
pinchMethod · 0.80

Tested by

no test coverage detected