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:
- 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<{
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