Skip to main content

Function: resolve()

function resolve(context): Promise<{
error?: string;
plugin?: string;
reasons?: string[];
selector: string;
stabilityScore?: number;
subselector?: string;
updatedAnchors?: Record<string, unknown>;
}>;

Defined in: packages/uimatch-selector-anchors/src/core/resolver.ts:99

Main resolve function implementing SPI contract

This function integrates all the components:

  1. Load anchors JSON (if provided)
  2. Find matching anchor by snippet hash
  3. Resolve selectors from AST/HTML
  4. Check liveness and calculate stability
  5. Return the best selector

Parameters

context

ResolveContext

Resolution context from uiMatch

Returns

Promise<{ error?: string; plugin?: string; reasons?: string[]; selector: string; stabilityScore?: number; subselector?: string; updatedAnchors?: Record<string, unknown>; }>

Resolution result with selector and metadata

Example

const resolution = await resolve({
initialSelector: '[data-testid="button"]',
anchorsPath: './anchors.json',
probe: async (selector) => ({ isAlive: true, selector }),
writeBack: false
});

console.log(resolution.selector); // Best selector found
console.log(resolution.stabilityScore); // 0-100 score
console.log(resolution.reasons); // Detailed resolution steps