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:
- Load anchors JSON (if provided)
- Find matching anchor by snippet hash
- Resolve selectors from AST/HTML
- Check liveness and calculate stability
- Return the best selector
Parameters
context
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