MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / postSimulatorAction

Function postSimulatorAction

packages/client/src/api/controls.ts:37–64  ·  view source on GitHub ↗
(
  udid: string,
  action: string,
  payload?: LaunchPayload | OpenUrlPayload,
)

Source from the content-addressed store, hash-verified

35}
36
37async function postSimulatorAction(
38 udid: string,
39 action: string,
40 payload?: LaunchPayload | OpenUrlPayload,
41): Promise<SimulatorMetadata | null> {
42 if (action === "launch" || action === "open-url") {
43 const response = await apiRequest<{
44 ok: boolean;
45 simulator?: SimulatorMetadata | null;
46 }>(`/api/simulators/${encodeURIComponent(udid)}/action`, {
47 method: "POST",
48 body: JSON.stringify({
49 action: action === "open-url" ? "openUrl" : "launch",
50 ...payload,
51 }),
52 });
53 return response.simulator ?? null;
54 }
55 const response = await apiRequest<SimulatorResponse | { ok: boolean }>(
56 `/api/simulators/${udid}/${action}`,
57 {
58 method: "POST",
59 body: payload ? JSON.stringify(payload) : undefined,
60 },
61 );
62
63 return "simulator" in response ? response.simulator : null;
64}
65
66export function bootSimulator(udid: string) {
67 return postSimulatorAction(udid, "boot");

Callers 4

bootSimulatorFunction · 0.85
shutdownSimulatorFunction · 0.85
openSimulatorUrlFunction · 0.85
launchSimulatorBundleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected