(params: {
req: DaemonRequest;
sessionName: string;
sessionStore: SessionStore;
session: ReturnType<SessionStore['get']>;
current: ReturnType<SessionStore['getRuntimeHints']>;
})
| 100 | } |
| 101 | |
| 102 | function setRuntimeCommand(params: { |
| 103 | req: DaemonRequest; |
| 104 | sessionName: string; |
| 105 | sessionStore: SessionStore; |
| 106 | session: ReturnType<SessionStore['get']>; |
| 107 | current: ReturnType<SessionStore['getRuntimeHints']>; |
| 108 | }): DaemonResponse { |
| 109 | const { req, sessionName, sessionStore, session, current } = params; |
| 110 | // approach (b): resolve the session's PUBLIC leaf platform (ios/macos), never the |
| 111 | // internal `apple`, so the legacy `--platform ios` selector still matches. |
| 112 | const sessionLeaf = sessionLeafPlatform(session); |
| 113 | const platform = toRuntimePlatform(req.flags?.platform ?? current?.platform ?? sessionLeaf); |
| 114 | if (!platform) { |
| 115 | return errorResponse( |
| 116 | 'INVALID_ARGS', |
| 117 | 'runtime set only supports iOS and Android sessions. Pass --platform ios|android or open an iOS/Android session first.', |
| 118 | ); |
| 119 | } |
| 120 | if (sessionLeaf !== undefined && sessionLeaf !== platform) { |
| 121 | return errorResponse( |
| 122 | 'INVALID_ARGS', |
| 123 | `runtime set targets ${platform}, but session "${sessionName}" is already bound to ${sessionLeaf}.`, |
| 124 | ); |
| 125 | } |
| 126 | const nextRuntime = mergeRuntimeHints(current, buildRuntimeHints(req.flags, platform)); |
| 127 | if (countConfiguredRuntimeHints(nextRuntime) === 0) { |
| 128 | return errorResponse( |
| 129 | 'INVALID_ARGS', |
| 130 | 'runtime set requires at least one hint such as --metro-host, --metro-port, --bundle-url, or --launch-url.', |
| 131 | ); |
| 132 | } |
| 133 | sessionStore.setRuntimeHints(sessionName, nextRuntime); |
| 134 | return { |
| 135 | ok: true, |
| 136 | data: { |
| 137 | session: sessionName, |
| 138 | configured: true, |
| 139 | runtime: nextRuntime, |
| 140 | }, |
| 141 | }; |
| 142 | } |
| 143 | |
| 144 | async function handlePortReverseCommand( |
| 145 | req: DaemonRequest, |
no test coverage detected