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

Function dispatchIsViaRuntime

src/daemon/selector-runtime.ts:148–195  ·  view source on GitHub ↗
(
  params: SelectorRuntimeParams,
)

Source from the content-addressed store, hash-verified

146}
147
148export async function dispatchIsViaRuntime(
149 params: SelectorRuntimeParams,
150): Promise<DaemonResponse | null> {
151 const { req } = params;
152 if (req.command !== 'is') return null;
153 const predicate = (req.positionals?.[0] ?? '').toLowerCase();
154 if (!isSupportedPredicate(predicate)) {
155 return errorResponse(
156 'INVALID_ARGS',
157 'is requires predicate: visible|hidden|exists|editable|selected|text',
158 );
159 }
160 const { split } = splitIsSelectorArgs(req.positionals ?? []);
161 if (!split) return errorResponse('INVALID_ARGS', 'is requires a selector expression');
162 const expectedText = split.rest.join(' ').trim();
163 if (predicate === 'text' && !expectedText) {
164 return errorResponse('INVALID_ARGS', 'is text requires expected text value');
165 }
166 if (predicate !== 'text' && split.rest.length > 0) {
167 return errorResponse('INVALID_ARGS', `is ${predicate} does not accept trailing values`);
168 }
169 const directResponse = await dispatchDirectIosSelectorIs(
170 params,
171 predicate as IsPredicate,
172 split.selectorExpression,
173 expectedText,
174 );
175 if (directResponse) return directResponse;
176
177 const resolvedRuntime = await createSelectorRuntime(params, {
178 requireSession: true,
179 capability: 'is',
180 });
181 if (!resolvedRuntime.ok) return resolvedRuntime.response;
182
183 const response = await toDaemonResponse(async () => {
184 const result = await resolvedRuntime.runtime.selectors.is({
185 session: params.sessionName,
186 requestId: req.meta?.requestId,
187 predicate: predicate as IsPredicate,
188 selector: split.selectorExpression,
189 expectedText,
190 });
191 recordIfSession(params.sessionStore, params.sessionName, req, result);
192 return stripSelectorChain(result);
193 });
194 return await maybeAndroidForegroundBlockerResponse(params, response, `is ${predicate}`);
195}
196
197export async function dispatchWaitViaRuntime(
198 params: SelectorRuntimeParams,

Callers 1

Calls 9

isSupportedPredicateFunction · 0.90
errorResponseFunction · 0.90
splitIsSelectorArgsFunction · 0.90
createSelectorRuntimeFunction · 0.90
recordIfSessionFunction · 0.90
stripSelectorChainFunction · 0.90
toDaemonResponseFunction · 0.85

Tested by

no test coverage detected