UNPKG

@adguard/agtree

Version:
38 lines (37 loc) 1.82 kB
/** * @file Adblock rule converter * * This file is the entry point for all rule converters * which automatically detects the rule type and calls * the corresponding "sub-converter". */ import { type AnyRule } from '../nodes/index.js'; import { RuleConverterBase } from './base-interfaces/rule-converter-base.js'; import { type NodeConversionResult } from './base-interfaces/conversion-result.js'; /** * Adblock filtering rule converter class * * @todo Implement `convertToUbo` and `convertToAbp` */ export declare class RuleConverter extends RuleConverterBase { /** * Converts an adblock filtering rule to AdGuard format, if possible. * * @param rule Rule node to convert * @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains * the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted. * If the rule was not converted, the result array will contain the original node with the same object reference * @throws If the rule is invalid or cannot be converted */ static convertToAdg(rule: AnyRule): NodeConversionResult<AnyRule>; /** * Converts an adblock filtering rule to uBlock Origin format, if possible. * * @param rule Rule node to convert * @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains * the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted. * If the rule was not converted, the result array will contain the original node with the same object reference * @throws If the rule is invalid or cannot be converted */ static convertToUbo(rule: AnyRule): NodeConversionResult<AnyRule>; }