Skip to main content

Function: resolve()

function resolve(context): Promise<Resolution>;

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

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<Resolution>

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