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

Function tryResolveRefNode

src/commands/interaction/runtime/resolution.ts:306–323  ·  view source on GitHub ↗
(
  nodes: SnapshotState['nodes'],
  refInput: string,
  options: {
    fallbackLabel: string;
  },
)

Source from the content-addressed store, hash-verified

304}
305
306function tryResolveRefNode(
307 nodes: SnapshotState['nodes'],
308 refInput: string,
309 options: {
310 fallbackLabel: string;
311 },
312): { ref: string; node: SnapshotNode } | null {
313 const ref = normalizeRef(refInput);
314 if (!ref) throw new AppError('INVALID_ARGS', `Invalid ref: ${refInput}`);
315 const refNode = findNodeByRef(nodes, ref);
316 if (isUsableResolvedNode(refNode)) return { ref, node: refNode };
317 const fallbackNode =
318 options.fallbackLabel.length > 0 ? findNodeByLabel(nodes, options.fallbackLabel) : null;
319 if (isUsableResolvedNode(fallbackNode)) {
320 return { ref, node: fallbackNode };
321 }
322 return null;
323}
324
325function resolveNodeCenter(node: SnapshotNode, message: string): Point {
326 const point = resolveRectCenter(node.rect);

Callers 1

resolveSnapshotForRefFunction · 0.85

Calls 4

normalizeRefFunction · 0.90
findNodeByRefFunction · 0.90
findNodeByLabelFunction · 0.90
isUsableResolvedNodeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…