@adguard/agtree 4.0.1 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/ast-utils/clone.js +12 -8
- package/dist/ast-utils/modifiers.js +13 -11
- package/dist/ast-utils/network-rules.js +10 -9
- package/dist/ast-utils/scriptlets.js +20 -18
- package/dist/common/abp-snippet-injection-body-common.js +1 -1
- package/dist/common/agent-common.js +1 -1
- package/dist/common/ubo-html-filtering-body-common.js +1 -1
- package/dist/common/ubo-selector-common.js +1 -1
- package/dist/compatibility-tables/base.js +7 -6
- package/dist/compatibility-tables/compatibility-table-data.js +1 -1
- package/dist/compatibility-tables/modifiers.js +4 -3
- package/dist/compatibility-tables/platforms.js +1 -1
- package/dist/compatibility-tables/redirects.js +4 -4
- package/dist/compatibility-tables/schemas/base.js +2 -2
- package/dist/compatibility-tables/schemas/modifier.js +4 -4
- package/dist/compatibility-tables/schemas/platform.js +3 -2
- package/dist/compatibility-tables/schemas/redirect.js +1 -1
- package/dist/compatibility-tables/schemas/resource-type.js +1 -1
- package/dist/compatibility-tables/schemas/scriptlet.js +1 -1
- package/dist/compatibility-tables/scriptlets.js +2 -2
- package/dist/compatibility-tables/utils/platform-helpers.js +6 -4
- package/dist/compatibility-tables/utils/resource-type-helpers.js +1 -1
- package/dist/compatibility-tables/utils/zod-camelcase.js +3 -3
- package/dist/converter/base-interfaces/base-converter.js +22 -16
- package/dist/converter/base-interfaces/conversion-result.js +15 -11
- package/dist/converter/base-interfaces/rule-converter-base.js +19 -13
- package/dist/converter/comment/index.js +11 -9
- package/dist/converter/cosmetic/css.js +12 -10
- package/dist/converter/cosmetic/element-hiding.js +12 -10
- package/dist/converter/cosmetic/header-removal.js +16 -13
- package/dist/converter/cosmetic/html.js +107 -20
- package/dist/converter/cosmetic/index.js +28 -24
- package/dist/converter/cosmetic/rule-modifiers/adg.js +15 -12
- package/dist/converter/cosmetic/rule-modifiers/ubo.js +22 -19
- package/dist/converter/cosmetic/scriptlet.js +26 -22
- package/dist/converter/css/index.js +13 -11
- package/dist/converter/data/css.js +8 -8
- package/dist/converter/filter-list.js +12 -10
- package/dist/converter/index.js +1 -1
- package/dist/converter/misc/network-rule-modifier.js +20 -16
- package/dist/converter/network/index.js +16 -12
- package/dist/converter/raw-filter-list.js +12 -10
- package/dist/converter/raw-rule.js +14 -12
- package/dist/converter/rule.js +17 -13
- package/dist/errors/adblock-syntax-error.js +1 -1
- package/dist/errors/not-implemented-error.js +2 -2
- package/dist/errors/rule-conversion-error.js +2 -2
- package/dist/generator/base-generator.js +1 -1
- package/dist/generator/comment/agent-comment-generator.js +4 -3
- package/dist/generator/comment/agent-generator.js +5 -4
- package/dist/generator/comment/comment-rule-generator.js +6 -5
- package/dist/generator/comment/config-comment-generator.js +5 -4
- package/dist/generator/comment/hint-comment-generator.js +5 -4
- package/dist/generator/comment/hint-generator.js +4 -3
- package/dist/generator/comment/metadata-comment-generator.js +3 -2
- package/dist/generator/comment/pre-processor-comment-generator.js +6 -5
- package/dist/generator/comment/simple-comment-generator.js +3 -2
- package/dist/generator/cosmetic/cosmetic-rule-body-generator.js +13 -11
- package/dist/generator/cosmetic/cosmetic-rule-generator.js +5 -4
- package/dist/generator/cosmetic/cosmetic-rule-pattern-generator.js +7 -5
- package/dist/generator/cosmetic/html-filtering-body/adg-html-filtering-body-generator.js +3 -3
- package/dist/generator/cosmetic/html-filtering-body/html-filtering-body-generator.js +1 -1
- package/dist/generator/cosmetic/html-filtering-body/ubo-html-filtering-body-generator.js +2 -2
- package/dist/generator/cosmetic/scriptlet-body/abp-snippet-injection-body-generator.js +7 -5
- package/dist/generator/cosmetic/scriptlet-body/adg-scriptlet-injection-body-generator.js +7 -5
- package/dist/generator/cosmetic/scriptlet-body/ubo-scriptlet-injection-body-generator.js +8 -6
- package/dist/generator/cosmetic/selector/attribute-selector-generator.js +2 -2
- package/dist/generator/cosmetic/selector/class-selector-generator.js +1 -1
- package/dist/generator/cosmetic/selector/complex-selector-generator.js +4 -4
- package/dist/generator/cosmetic/selector/id-selector-generator.js +1 -1
- package/dist/generator/cosmetic/selector/pseudo-class-selector-generator.js +1 -1
- package/dist/generator/cosmetic/selector/selector-combinator-generator.js +1 -1
- package/dist/generator/cosmetic/selector/selector-list-generator.js +1 -1
- package/dist/generator/cosmetic/selector/type-selector-generator.js +1 -1
- package/dist/generator/css/adg-css-injection-generator.js +5 -1
- package/dist/generator/filterlist-generator.js +5 -4
- package/dist/generator/index.js +1 -1
- package/dist/generator/misc/domain-list-generator.js +1 -1
- package/dist/generator/misc/list-items-generator.js +5 -3
- package/dist/generator/misc/logical-expression-generator.js +5 -4
- package/dist/generator/misc/modifier-generator.js +4 -3
- package/dist/generator/misc/modifier-list-generator.js +5 -4
- package/dist/generator/misc/parameter-list-generator.js +6 -5
- package/dist/generator/misc/value-generator.js +2 -1
- package/dist/generator/network/host-rule-generator.js +2 -1
- package/dist/generator/network/network-rule-generator.js +2 -1
- package/dist/generator/rule-generator.js +6 -4
- package/dist/index.js +1 -2
- package/dist/nodes/index.js +1 -1
- package/dist/package.json.js +2 -2
- package/dist/parser/base-parser.js +1 -1
- package/dist/parser/comment/agent-comment-parser.js +11 -9
- package/dist/parser/comment/agent-parser.js +12 -9
- package/dist/parser/comment/comment-parser.js +8 -7
- package/dist/parser/comment/config-comment-parser.js +9 -6
- package/dist/parser/comment/hint-comment-parser.js +17 -12
- package/dist/parser/comment/hint-parser.js +10 -7
- package/dist/parser/comment/metadata-comment-parser.js +9 -7
- package/dist/parser/comment/preprocessor-parser.js +14 -11
- package/dist/parser/comment/simple-comment-parser.js +5 -2
- package/dist/parser/cosmetic/cosmetic-rule-parser.js +29 -25
- package/dist/parser/cosmetic/html-filtering-body/adg-html-filtering-body-parser.js +3 -3
- package/dist/parser/cosmetic/html-filtering-body/html-filtering-body-parser.js +4 -4
- package/dist/parser/cosmetic/html-filtering-body/ubo-html-filtering-body-parser.js +7 -7
- package/dist/parser/cosmetic/scriptlet-body/abp-snippet-injection-body-parser.js +12 -9
- package/dist/parser/cosmetic/scriptlet-body/adg-scriptlet-injection-body-parser.js +12 -9
- package/dist/parser/cosmetic/scriptlet-body/ubo-scriptlet-injection-body-parser.js +11 -8
- package/dist/parser/cosmetic/selector/handlers/attribute-selector-handler.js +1 -1
- package/dist/parser/cosmetic/selector/handlers/class-selector-handler.js +1 -1
- package/dist/parser/cosmetic/selector/handlers/complex-selector-handler.js +1 -1
- package/dist/parser/cosmetic/selector/handlers/compound-selector-handler.js +2 -2
- package/dist/parser/cosmetic/selector/handlers/id-selector-handler.js +1 -1
- package/dist/parser/cosmetic/selector/handlers/pseudo-class-selector-handler.js +5 -3
- package/dist/parser/cosmetic/selector/handlers/type-selector-handler.js +1 -1
- package/dist/parser/cosmetic/selector/selector-list-parser.js +7 -7
- package/dist/parser/css/adg-css-injection-parser.js +4 -3
- package/dist/parser/css/balancing.js +22 -18
- package/dist/parser/css/constants.js +1 -1
- package/dist/parser/css/css-token-stream.js +15 -4
- package/dist/parser/css/ubo-selector-parser.js +8 -4
- package/dist/parser/filterlist-parser.js +8 -5
- package/dist/parser/index.js +1 -1
- package/dist/parser/misc/app-list-parser.js +4 -3
- package/dist/parser/misc/domain-list-parser.js +8 -6
- package/dist/parser/misc/list-items-parser.js +8 -6
- package/dist/parser/misc/logical-expression-parser.js +25 -18
- package/dist/parser/misc/method-list-parser.js +4 -3
- package/dist/parser/misc/modifier-list.js +3 -3
- package/dist/parser/misc/modifier-parser.js +5 -4
- package/dist/parser/misc/parameter-list-parser.js +6 -5
- package/dist/parser/misc/stealth-option-list-parser.js +4 -3
- package/dist/parser/misc/ubo-parameter-list-parser.js +10 -9
- package/dist/parser/misc/value-parser.js +2 -2
- package/dist/parser/network/host-rule-parser.js +15 -7
- package/dist/parser/network/network-rule-parser.js +11 -9
- package/dist/parser/options.js +1 -1
- package/dist/parser/rule-parser.js +11 -7
- package/dist/types/ast-utils/clone.d.ts +12 -8
- package/dist/types/ast-utils/filter-list.d.ts +5 -4
- package/dist/types/ast-utils/modifiers.d.ts +11 -9
- package/dist/types/ast-utils/network-rules.d.ts +8 -7
- package/dist/types/ast-utils/scriptlets.d.ts +19 -17
- package/dist/types/compatibility-tables/base.d.ts +6 -5
- package/dist/types/compatibility-tables/redirects.d.ts +1 -1
- package/dist/types/compatibility-tables/schemas/platform.d.ts +1 -0
- package/dist/types/compatibility-tables/utils/platform-helpers.d.ts +5 -3
- package/dist/types/compatibility-tables/utils/zod-camelcase.d.ts +3 -3
- package/dist/types/converter/base-interfaces/base-converter.d.ts +21 -15
- package/dist/types/converter/base-interfaces/conversion-result.d.ts +20 -16
- package/dist/types/converter/base-interfaces/rule-converter-base.d.ts +19 -13
- package/dist/types/converter/comment/index.d.ts +9 -7
- package/dist/types/converter/cosmetic/css.d.ts +9 -7
- package/dist/types/converter/cosmetic/element-hiding.d.ts +9 -7
- package/dist/types/converter/cosmetic/header-removal.d.ts +10 -7
- package/dist/types/converter/cosmetic/html.d.ts +29 -9
- package/dist/types/converter/cosmetic/index.d.ts +14 -10
- package/dist/types/converter/cosmetic/rule-modifiers/adg.d.ts +9 -6
- package/dist/types/converter/cosmetic/rule-modifiers/ubo.d.ts +9 -6
- package/dist/types/converter/cosmetic/scriptlet.d.ts +14 -10
- package/dist/types/converter/css/index.d.ts +9 -7
- package/dist/types/converter/data/css.d.ts +1 -1
- package/dist/types/converter/filter-list.d.ts +10 -8
- package/dist/types/converter/index.d.ts +1 -1
- package/dist/types/converter/misc/network-rule-modifier.d.ts +13 -9
- package/dist/types/converter/network/index.d.ts +15 -11
- package/dist/types/converter/raw-filter-list.d.ts +8 -6
- package/dist/types/converter/raw-rule.d.ts +8 -6
- package/dist/types/converter/rule.d.ts +14 -10
- package/dist/types/errors/not-implemented-error.d.ts +1 -1
- package/dist/types/errors/rule-conversion-error.d.ts +1 -1
- package/dist/types/generator/comment/agent-comment-generator.d.ts +3 -2
- package/dist/types/generator/comment/agent-generator.d.ts +4 -3
- package/dist/types/generator/comment/comment-rule-generator.d.ts +3 -2
- package/dist/types/generator/comment/config-comment-generator.d.ts +4 -3
- package/dist/types/generator/comment/hint-comment-generator.d.ts +4 -3
- package/dist/types/generator/comment/hint-generator.d.ts +3 -2
- package/dist/types/generator/comment/metadata-comment-generator.d.ts +1 -0
- package/dist/types/generator/comment/pre-processor-comment-generator.d.ts +3 -2
- package/dist/types/generator/comment/simple-comment-generator.d.ts +2 -1
- package/dist/types/generator/cosmetic/cosmetic-rule-body-generator.d.ts +7 -5
- package/dist/types/generator/cosmetic/cosmetic-rule-generator.d.ts +3 -2
- package/dist/types/generator/cosmetic/cosmetic-rule-pattern-generator.d.ts +4 -2
- package/dist/types/generator/cosmetic/html-filtering-body/adg-html-filtering-body-generator.d.ts +1 -1
- package/dist/types/generator/cosmetic/html-filtering-body/html-filtering-body-generator.d.ts +1 -1
- package/dist/types/generator/cosmetic/html-filtering-body/ubo-html-filtering-body-generator.d.ts +2 -2
- package/dist/types/generator/cosmetic/scriptlet-body/abp-snippet-injection-body-generator.d.ts +5 -3
- package/dist/types/generator/cosmetic/scriptlet-body/adg-scriptlet-injection-body-generator.d.ts +5 -3
- package/dist/types/generator/cosmetic/scriptlet-body/ubo-scriptlet-injection-body-generator.d.ts +7 -5
- package/dist/types/generator/css/adg-css-injection-generator.d.ts +4 -0
- package/dist/types/generator/css/ubo-selector-generator.d.ts +4 -3
- package/dist/types/generator/filterlist-generator.d.ts +3 -2
- package/dist/types/generator/misc/list-items-generator.d.ts +4 -2
- package/dist/types/generator/misc/logical-expression-generator.d.ts +4 -3
- package/dist/types/generator/misc/modifier-generator.d.ts +3 -2
- package/dist/types/generator/misc/modifier-list-generator.d.ts +4 -3
- package/dist/types/generator/misc/parameter-list-generator.d.ts +5 -4
- package/dist/types/generator/misc/value-generator.d.ts +1 -0
- package/dist/types/generator/network/host-rule-generator.d.ts +1 -0
- package/dist/types/generator/network/network-rule-generator.d.ts +1 -0
- package/dist/types/generator/rule-generator.d.ts +5 -3
- package/dist/types/index.d.ts +1 -2
- package/dist/types/nodes/index.d.ts +55 -54
- package/dist/types/parser/comment/agent-comment-parser.d.ts +5 -3
- package/dist/types/parser/comment/agent-parser.d.ts +7 -4
- package/dist/types/parser/comment/comment-parser.d.ts +5 -3
- package/dist/types/parser/comment/config-comment-parser.d.ts +5 -2
- package/dist/types/parser/comment/hint-comment-parser.d.ts +11 -6
- package/dist/types/parser/comment/hint-parser.d.ts +6 -3
- package/dist/types/parser/comment/metadata-comment-parser.d.ts +5 -3
- package/dist/types/parser/comment/preprocessor-parser.d.ts +9 -6
- package/dist/types/parser/comment/simple-comment-parser.d.ts +3 -0
- package/dist/types/parser/cosmetic/cosmetic-rule-parser.d.ts +9 -6
- package/dist/types/parser/cosmetic/html-filtering-body/adg-html-filtering-body-parser.d.ts +3 -3
- package/dist/types/parser/cosmetic/html-filtering-body/html-filtering-body-parser.d.ts +4 -4
- package/dist/types/parser/cosmetic/html-filtering-body/ubo-html-filtering-body-parser.d.ts +4 -4
- package/dist/types/parser/cosmetic/scriptlet-body/abp-snippet-injection-body-parser.d.ts +8 -5
- package/dist/types/parser/cosmetic/scriptlet-body/adg-scriptlet-injection-body-parser.d.ts +9 -6
- package/dist/types/parser/cosmetic/scriptlet-body/ubo-scriptlet-injection-body-parser.d.ts +8 -5
- package/dist/types/parser/cosmetic/selector/context.d.ts +2 -2
- package/dist/types/parser/cosmetic/selector/selector-list-parser.d.ts +2 -2
- package/dist/types/parser/css/adg-css-injection-parser.d.ts +1 -0
- package/dist/types/parser/css/balancing.d.ts +17 -12
- package/dist/types/parser/css/css-token-stream.d.ts +11 -0
- package/dist/types/parser/css/ubo-selector-parser.d.ts +3 -0
- package/dist/types/parser/filterlist-parser.d.ts +5 -2
- package/dist/types/parser/misc/app-list-parser.d.ts +1 -0
- package/dist/types/parser/misc/domain-list-parser.d.ts +5 -3
- package/dist/types/parser/misc/list-items-parser.d.ts +5 -3
- package/dist/types/parser/misc/logical-expression-parser.d.ts +9 -5
- package/dist/types/parser/misc/method-list-parser.d.ts +1 -0
- package/dist/types/parser/misc/modifier-list.d.ts +2 -1
- package/dist/types/parser/misc/modifier-parser.d.ts +2 -1
- package/dist/types/parser/misc/parameter-list-parser.d.ts +3 -2
- package/dist/types/parser/misc/stealth-option-list-parser.d.ts +1 -0
- package/dist/types/parser/misc/ubo-parameter-list-parser.d.ts +2 -1
- package/dist/types/parser/misc/value-parser.d.ts +1 -1
- package/dist/types/parser/network/host-rule-parser.d.ts +10 -2
- package/dist/types/parser/network/network-rule-parser.d.ts +5 -3
- package/dist/types/parser/options.d.ts +1 -1
- package/dist/types/parser/rule-parser.d.ts +6 -2
- package/dist/types/tokenizer/tokenizer.d.ts +2 -2
- package/dist/types/utils/adblockers.d.ts +9 -6
- package/dist/types/utils/clone.d.ts +4 -3
- package/dist/types/utils/constants.d.ts +1 -1
- package/dist/types/utils/cosmetic-rule-separator.d.ts +13 -10
- package/dist/types/utils/deep-freeze.d.ts +4 -4
- package/dist/types/utils/domain.d.ts +3 -2
- package/dist/types/utils/logical-expression.d.ts +9 -5
- package/dist/types/utils/multi-value-map.d.ts +3 -3
- package/dist/types/utils/position-provider.d.ts +3 -2
- package/dist/types/utils/quotes.d.ts +48 -42
- package/dist/types/utils/regexp.d.ts +24 -17
- package/dist/types/utils/string.d.ts +135 -103
- package/dist/types/utils/type-guards.d.ts +1 -0
- package/dist/types/validator/helpers.d.ts +1 -1
- package/dist/types/validator/index.d.ts +3 -3
- package/dist/types/version.d.ts +1 -1
- package/dist/utils/adblockers.js +10 -7
- package/dist/utils/bit-count.js +1 -1
- package/dist/utils/categorizer.js +2 -2
- package/dist/utils/clone.js +5 -4
- package/dist/utils/constants.js +2 -2
- package/dist/utils/cosmetic-rule-separator.js +15 -11
- package/dist/utils/deep-freeze.js +5 -5
- package/dist/utils/domain.js +4 -3
- package/dist/utils/error.js +3 -1
- package/dist/utils/index.js +1 -1
- package/dist/utils/logical-expression.js +10 -6
- package/dist/utils/multi-value-map.js +4 -4
- package/dist/utils/noop-modifier.js +1 -1
- package/dist/utils/position-provider.js +2 -1
- package/dist/utils/quotes.js +49 -43
- package/dist/utils/regexp.js +25 -18
- package/dist/utils/string.js +136 -104
- package/dist/utils/type-guards.js +2 -1
- package/dist/validator/constants.js +1 -1
- package/dist/validator/helpers.js +1 -1
- package/dist/validator/index.js +8 -8
- package/dist/validator/value.js +6 -6
- package/dist/version.js +2 -2
- package/package.json +3 -1
- package/dist/errors/binary-schema-mismatch-error.js +0 -37
- package/dist/types/errors/binary-schema-mismatch-error.d.ts +0 -23
|
@@ -1,42 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Base class for converters
|
|
2
|
+
* @file Base class for converters.
|
|
3
3
|
*
|
|
4
4
|
* TS doesn't support abstract static methods, so we should use
|
|
5
|
-
* a workaround and extend this class instead of implementing it
|
|
5
|
+
* a workaround and extend this class instead of implementing it.
|
|
6
6
|
*/
|
|
7
7
|
import { type ConversionResult } from './conversion-result.js';
|
|
8
8
|
/**
|
|
9
|
-
* Basic class for rule converters
|
|
9
|
+
* Basic class for rule converters.
|
|
10
10
|
*/
|
|
11
11
|
export declare class BaseConverter {
|
|
12
12
|
/**
|
|
13
|
-
* Converts some data to AdGuard format
|
|
13
|
+
* Converts some data to AdGuard format.
|
|
14
|
+
*
|
|
15
|
+
* @param data Data to convert.
|
|
14
16
|
*
|
|
15
|
-
* @param data Data to convert
|
|
16
17
|
* @returns An object which follows the {@link ConversionResult} interface. Its `result` property contains
|
|
17
18
|
* the converted node, and its `isConverted` flag indicates whether the original node was converted.
|
|
18
|
-
* If the node was not converted, the result will contain the original node with the same object reference
|
|
19
|
-
*
|
|
19
|
+
* If the node was not converted, the result will contain the original node with the same object reference.
|
|
20
|
+
*
|
|
21
|
+
* @throws If the data is invalid or incompatible.
|
|
20
22
|
*/
|
|
21
23
|
static convertToAdg(data: unknown): ConversionResult<unknown>;
|
|
22
24
|
/**
|
|
23
|
-
* Converts some data to Adblock Plus format
|
|
25
|
+
* Converts some data to Adblock Plus format.
|
|
26
|
+
*
|
|
27
|
+
* @param data Data to convert.
|
|
24
28
|
*
|
|
25
|
-
* @param data Data to convert
|
|
26
29
|
* @returns An object which follows the {@link ConversionResult} interface. Its `result` property contains
|
|
27
30
|
* the converted node, and its `isConverted` flag indicates whether the original node was converted.
|
|
28
|
-
* If the node was not converted, the result will contain the original node with the same object reference
|
|
29
|
-
*
|
|
31
|
+
* If the node was not converted, the result will contain the original node with the same object reference.
|
|
32
|
+
*
|
|
33
|
+
* @throws If the data is invalid or incompatible.
|
|
30
34
|
*/
|
|
31
35
|
static convertToAbp(data: unknown): ConversionResult<unknown>;
|
|
32
36
|
/**
|
|
33
|
-
* Converts some data to uBlock Origin format
|
|
37
|
+
* Converts some data to uBlock Origin format.
|
|
38
|
+
*
|
|
39
|
+
* @param data Data to convert.
|
|
34
40
|
*
|
|
35
|
-
* @param data Data to convert
|
|
36
41
|
* @returns An object which follows the {@link ConversionResult} interface. Its `result` property contains
|
|
37
42
|
* the converted node, and its `isConverted` flag indicates whether the original node was converted.
|
|
38
|
-
* If the node was not converted, the result will contain the original node with the same object reference
|
|
39
|
-
*
|
|
43
|
+
* If the node was not converted, the result will contain the original node with the same object reference.
|
|
44
|
+
*
|
|
45
|
+
* @throws If the data is invalid or incompatible.
|
|
40
46
|
*/
|
|
41
47
|
static convertToUbo(data: unknown): ConversionResult<unknown>;
|
|
42
48
|
}
|
|
@@ -1,43 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Conversion result interface and helper functions
|
|
2
|
+
* @file Conversion result interface and helper functions.
|
|
3
3
|
*/
|
|
4
4
|
import { type Node } from '../../nodes/index.js';
|
|
5
5
|
/**
|
|
6
|
-
* Common conversion result interface
|
|
6
|
+
* Common conversion result interface.
|
|
7
7
|
*
|
|
8
|
-
* @template T Type of the item to convert
|
|
9
|
-
* @template U Type of the conversion result (defaults to `T`, but can be `T[]` as well)
|
|
8
|
+
* @template T Type of the item to convert.
|
|
9
|
+
* @template U Type of the conversion result (defaults to `T`, but can be `T[]` as well).
|
|
10
10
|
*/
|
|
11
11
|
export interface ConversionResult<T, U extends T | T[] = T> {
|
|
12
12
|
/**
|
|
13
|
-
* Conversion result
|
|
13
|
+
* Conversion result.
|
|
14
14
|
*/
|
|
15
15
|
result: U;
|
|
16
16
|
/**
|
|
17
|
-
* Indicates whether the input item was converted
|
|
17
|
+
* Indicates whether the input item was converted.
|
|
18
18
|
*/
|
|
19
19
|
isConverted: boolean;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Adblock rule node conversion result interface, where the conversion result is an array of rules
|
|
22
|
+
* Adblock rule node conversion result interface, where the conversion result is an array of rules.
|
|
23
23
|
*/
|
|
24
24
|
export type NodeConversionResult<T extends Node> = ConversionResult<T, T[]>;
|
|
25
25
|
/**
|
|
26
26
|
* Helper function to create a generic conversion result.
|
|
27
27
|
*
|
|
28
|
-
* @
|
|
29
|
-
* @
|
|
30
|
-
*
|
|
31
|
-
* @
|
|
32
|
-
* @
|
|
28
|
+
* @template T Type of the item to convert.
|
|
29
|
+
* @template U Type of the conversion result (defaults to `T`, but can be `T[]` as well).
|
|
30
|
+
*
|
|
31
|
+
* @param result Conversion result.
|
|
32
|
+
* @param isConverted Indicates whether the input item was converted.
|
|
33
|
+
*
|
|
34
|
+
* @returns Generic conversion result.
|
|
33
35
|
*/
|
|
34
36
|
export declare function createConversionResult<T, U extends T | T[] = T>(result: U, isConverted: boolean): ConversionResult<T, U>;
|
|
35
37
|
/**
|
|
36
38
|
* Helper function to create a node conversion result.
|
|
37
39
|
*
|
|
38
|
-
* @
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
41
|
-
* @
|
|
40
|
+
* @template T Type of the node (extends `Node`).
|
|
41
|
+
*
|
|
42
|
+
* @param nodes Array of nodes.
|
|
43
|
+
* @param isConverted Indicates whether the input item was converted.
|
|
44
|
+
*
|
|
45
|
+
* @returns Node conversion result.
|
|
42
46
|
*/
|
|
43
47
|
export declare function createNodeConversionResult<T extends Node>(nodes: T[], isConverted: boolean): NodeConversionResult<T>;
|
|
@@ -1,44 +1,50 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Base class for rule converters
|
|
2
|
+
* @file Base class for rule converters.
|
|
3
3
|
*
|
|
4
4
|
* TS doesn't support abstract static methods, so we should use
|
|
5
|
-
* a workaround and extend this class instead of implementing it
|
|
5
|
+
* a workaround and extend this class instead of implementing it.
|
|
6
6
|
*/
|
|
7
7
|
import { type Node } from '../../nodes/index.js';
|
|
8
|
-
import { type NodeConversionResult } from './conversion-result.js';
|
|
9
8
|
import { BaseConverter } from './base-converter.js';
|
|
9
|
+
import { type NodeConversionResult } from './conversion-result.js';
|
|
10
10
|
/**
|
|
11
|
-
* Basic class for rule converters
|
|
11
|
+
* Basic class for rule converters.
|
|
12
12
|
*/
|
|
13
13
|
export declare class RuleConverterBase extends BaseConverter {
|
|
14
14
|
/**
|
|
15
15
|
* Converts an adblock filtering rule to AdGuard format, if possible.
|
|
16
16
|
*
|
|
17
|
-
* @param rule Rule node to convert
|
|
17
|
+
* @param rule Rule node to convert.
|
|
18
|
+
*
|
|
18
19
|
* @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
|
|
19
20
|
* the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
|
|
20
|
-
* If the rule was not converted, the result array will contain the original node with the same object reference
|
|
21
|
-
*
|
|
21
|
+
* If the rule was not converted, the result array will contain the original node with the same object reference.
|
|
22
|
+
*
|
|
23
|
+
* @throws If the rule is invalid or cannot be converted.
|
|
22
24
|
*/
|
|
23
25
|
static convertToAdg(rule: Node): NodeConversionResult<Node>;
|
|
24
26
|
/**
|
|
25
27
|
* Converts an adblock filtering rule to Adblock Plus format, if possible.
|
|
26
28
|
*
|
|
27
|
-
* @param rule Rule node to convert
|
|
29
|
+
* @param rule Rule node to convert.
|
|
30
|
+
*
|
|
28
31
|
* @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
|
|
29
32
|
* the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
|
|
30
|
-
* If the rule was not converted, the result array will contain the original node with the same object reference
|
|
31
|
-
*
|
|
33
|
+
* If the rule was not converted, the result array will contain the original node with the same object reference.
|
|
34
|
+
*
|
|
35
|
+
* @throws If the rule is invalid or cannot be converted.
|
|
32
36
|
*/
|
|
33
37
|
static convertToAbp(rule: Node): NodeConversionResult<Node>;
|
|
34
38
|
/**
|
|
35
39
|
* Converts an adblock filtering rule to uBlock Origin format, if possible.
|
|
36
40
|
*
|
|
37
|
-
* @param rule Rule node to convert
|
|
41
|
+
* @param rule Rule node to convert.
|
|
42
|
+
*
|
|
38
43
|
* @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
|
|
39
44
|
* the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
|
|
40
|
-
* If the rule was not converted, the result array will contain the original node with the same object reference
|
|
41
|
-
*
|
|
45
|
+
* If the rule was not converted, the result array will contain the original node with the same object reference.
|
|
46
|
+
*
|
|
47
|
+
* @throws If the rule is invalid or cannot be converted.
|
|
42
48
|
*/
|
|
43
49
|
static convertToUbo(rule: Node): NodeConversionResult<Node>;
|
|
44
50
|
}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Comment rule converter
|
|
2
|
+
* @file Comment rule converter.
|
|
3
3
|
*/
|
|
4
4
|
import { type AnyCommentRule } from '../../nodes/index.js';
|
|
5
|
-
import { RuleConverterBase } from '../base-interfaces/rule-converter-base.js';
|
|
6
5
|
import { type NodeConversionResult } from '../base-interfaces/conversion-result.js';
|
|
6
|
+
import { RuleConverterBase } from '../base-interfaces/rule-converter-base.js';
|
|
7
7
|
/**
|
|
8
|
-
* Comment rule converter class
|
|
8
|
+
* Comment rule converter class.
|
|
9
9
|
*
|
|
10
|
-
* @todo Implement `convertToUbo` and `convertToAbp
|
|
10
|
+
* @todo Implement `convertToUbo` and `convertToAbp`.
|
|
11
11
|
*/
|
|
12
12
|
export declare class CommentRuleConverter extends RuleConverterBase {
|
|
13
13
|
/**
|
|
14
14
|
* Converts a comment rule to AdGuard format, if possible.
|
|
15
15
|
*
|
|
16
|
-
* @param rule Rule node to convert
|
|
16
|
+
* @param rule Rule node to convert.
|
|
17
|
+
*
|
|
17
18
|
* @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
|
|
18
19
|
* the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
|
|
19
|
-
* If the rule was not converted, the result array will contain the original node with the same object reference
|
|
20
|
-
*
|
|
20
|
+
* If the rule was not converted, the result array will contain the original node with the same object reference.
|
|
21
|
+
*
|
|
22
|
+
* @throws If the rule is invalid or cannot be converted.
|
|
21
23
|
*/
|
|
22
24
|
static convertToAdg(rule: AnyCommentRule): NodeConversionResult<AnyCommentRule>;
|
|
23
25
|
}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file CSS injection rule converter
|
|
2
|
+
* @file CSS injection rule converter.
|
|
3
3
|
*/
|
|
4
4
|
import { type CssInjectionRule } from '../../nodes/index.js';
|
|
5
|
-
import { RuleConverterBase } from '../base-interfaces/rule-converter-base.js';
|
|
6
5
|
import { type NodeConversionResult } from '../base-interfaces/conversion-result.js';
|
|
6
|
+
import { RuleConverterBase } from '../base-interfaces/rule-converter-base.js';
|
|
7
7
|
/**
|
|
8
|
-
* CSS injection rule converter class
|
|
8
|
+
* CSS injection rule converter class.
|
|
9
9
|
*
|
|
10
|
-
* @todo Implement `convertToUbo` and `convertToAbp
|
|
10
|
+
* @todo Implement `convertToUbo` and `convertToAbp`.
|
|
11
11
|
*/
|
|
12
12
|
export declare class CssInjectionRuleConverter extends RuleConverterBase {
|
|
13
13
|
/**
|
|
14
14
|
* Converts a CSS injection rule to AdGuard format, if possible.
|
|
15
15
|
*
|
|
16
|
-
* @param rule Rule node to convert
|
|
16
|
+
* @param rule Rule node to convert.
|
|
17
|
+
*
|
|
17
18
|
* @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
|
|
18
19
|
* the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
|
|
19
|
-
* If the rule was not converted, the result array will contain the original node with the same object reference
|
|
20
|
-
*
|
|
20
|
+
* If the rule was not converted, the result array will contain the original node with the same object reference.
|
|
21
|
+
*
|
|
22
|
+
* @throws If the rule is invalid or cannot be converted.
|
|
21
23
|
*/
|
|
22
24
|
static convertToAdg(rule: CssInjectionRule): NodeConversionResult<CssInjectionRule>;
|
|
23
25
|
}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Element hiding rule converter
|
|
2
|
+
* @file Element hiding rule converter.
|
|
3
3
|
*/
|
|
4
4
|
import { type ElementHidingRule } from '../../nodes/index.js';
|
|
5
|
-
import { RuleConverterBase } from '../base-interfaces/rule-converter-base.js';
|
|
6
5
|
import { type NodeConversionResult } from '../base-interfaces/conversion-result.js';
|
|
6
|
+
import { RuleConverterBase } from '../base-interfaces/rule-converter-base.js';
|
|
7
7
|
/**
|
|
8
|
-
* Element hiding rule converter class
|
|
8
|
+
* Element hiding rule converter class.
|
|
9
9
|
*
|
|
10
|
-
* @todo Implement `convertToUbo` and `convertToAbp
|
|
10
|
+
* @todo Implement `convertToUbo` and `convertToAbp`.
|
|
11
11
|
*/
|
|
12
12
|
export declare class ElementHidingRuleConverter extends RuleConverterBase {
|
|
13
13
|
/**
|
|
14
14
|
* Converts an element hiding rule to AdGuard format, if possible.
|
|
15
15
|
*
|
|
16
|
-
* @param rule Rule node to convert
|
|
16
|
+
* @param rule Rule node to convert.
|
|
17
|
+
*
|
|
17
18
|
* @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
|
|
18
19
|
* the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
|
|
19
|
-
* If the rule was not converted, the result array will contain the original node with the same object reference
|
|
20
|
-
*
|
|
20
|
+
* If the rule was not converted, the result array will contain the original node with the same object reference.
|
|
21
|
+
*
|
|
22
|
+
* @throws If the rule is invalid or cannot be converted.
|
|
21
23
|
*/
|
|
22
24
|
static convertToAdg(rule: ElementHidingRule): NodeConversionResult<ElementHidingRule>;
|
|
23
25
|
}
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Converter for request header removal rules
|
|
2
|
+
* @file Converter for request header removal rules.
|
|
3
3
|
*/
|
|
4
4
|
import { type AnyRule } from '../../nodes/index.js';
|
|
5
|
-
import { RuleConverterBase } from '../base-interfaces/rule-converter-base.js';
|
|
6
5
|
import { type NodeConversionResult } from '../base-interfaces/conversion-result.js';
|
|
6
|
+
import { RuleConverterBase } from '../base-interfaces/rule-converter-base.js';
|
|
7
7
|
export declare const ERROR_MESSAGES: {
|
|
8
8
|
EMPTY_PARAMETER: string;
|
|
9
9
|
EXPECTED_END_OF_RULE: string;
|
|
10
10
|
MULTIPLE_DOMAINS_NOT_SUPPORTED: string;
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
|
-
* Converter for request header removal rules
|
|
13
|
+
* Converter for request header removal rules.
|
|
14
14
|
*
|
|
15
|
-
* @todo Implement `convertToUbo` (ABP currently doesn't support header removal rules)
|
|
15
|
+
* @todo Implement `convertToUbo` (ABP currently doesn't support header removal rules).
|
|
16
16
|
*/
|
|
17
17
|
export declare class HeaderRemovalRuleConverter extends RuleConverterBase {
|
|
18
18
|
/**
|
|
19
19
|
* Converts a header removal rule to AdGuard syntax, if possible.
|
|
20
20
|
*
|
|
21
|
-
* @param rule Rule node to convert
|
|
21
|
+
* @param rule Rule node to convert.
|
|
22
|
+
*
|
|
22
23
|
* @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
|
|
23
24
|
* the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
|
|
24
|
-
* If the rule was not converted, the result array will contain the original node with the same object reference
|
|
25
|
-
*
|
|
25
|
+
* If the rule was not converted, the result array will contain the original node with the same object reference.
|
|
26
|
+
*
|
|
27
|
+
* @throws If the rule is invalid or cannot be converted.
|
|
28
|
+
*
|
|
26
29
|
* @example
|
|
27
30
|
* If the input rule is:
|
|
28
31
|
* ```adblock
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file HTML filtering rule converter
|
|
2
|
+
* @file HTML filtering rule converter.
|
|
3
3
|
*/
|
|
4
4
|
import { type HtmlFilteringRule } from '../../nodes/index.js';
|
|
5
|
-
import { RuleConverterBase } from '../base-interfaces/rule-converter-base.js';
|
|
6
5
|
import { type NodeConversionResult } from '../base-interfaces/conversion-result.js';
|
|
6
|
+
import { RuleConverterBase } from '../base-interfaces/rule-converter-base.js';
|
|
7
7
|
/**
|
|
8
8
|
* Error messages used in HTML filtering rule conversion.
|
|
9
9
|
*/
|
|
@@ -27,9 +27,9 @@ export declare const ERROR_MESSAGES: {
|
|
|
27
27
|
readonly SPECIAL_PSEUDO_CLASS_SELECTOR_NOT_SUPPORTED: "Special pseudo-class selector '%s' is not supported in conversion";
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
* HTML filtering rule converter class
|
|
30
|
+
* HTML filtering rule converter class.
|
|
31
31
|
*
|
|
32
|
-
* @todo Implement `convertToUbo` (ABP currently doesn't support HTML filtering rules)
|
|
32
|
+
* @todo Implement `convertToUbo` (ABP currently doesn't support HTML filtering rules).
|
|
33
33
|
*/
|
|
34
34
|
export declare class HtmlRuleConverter extends RuleConverterBase {
|
|
35
35
|
/**
|
|
@@ -65,9 +65,9 @@ export declare class HtmlRuleConverter extends RuleConverterBase {
|
|
|
65
65
|
* - `[wildcard="*content*"]` -> `:contains(/*.content*./s)`
|
|
66
66
|
* convert search pattern to regular expression
|
|
67
67
|
* - `[min-length="min"]` -> `:contains(/^(?=.{min,}$).*\/s)`
|
|
68
|
-
* converts to a length-matching regular expression
|
|
68
|
+
* converts to a length-matching regular expression.
|
|
69
69
|
* - `[max-length="max"]` -> `:contains(/^(?=.{0,max}$).*\/s)`
|
|
70
|
-
* converts to a length-matching regular expression
|
|
70
|
+
* converts to a length-matching regular expression.
|
|
71
71
|
*
|
|
72
72
|
* Note: This attribute selector to pseudo-class selector conversion
|
|
73
73
|
* is needed because AdGuard special attribute selectors are going
|
|
@@ -102,7 +102,7 @@ export declare class HtmlRuleConverter extends RuleConverterBase {
|
|
|
102
102
|
* - `:has-text(text)` -> `:contains(text)`
|
|
103
103
|
* direct conversion, no changes to argument
|
|
104
104
|
* - `:min-text-length(min)` -> `:contains(/^(?=.{min,MAX_CONVERSION_DEFAULT}$).*\/s)`
|
|
105
|
-
* converts to a length-matching regular expression
|
|
105
|
+
* converts to a length-matching regular expression.
|
|
106
106
|
*
|
|
107
107
|
* @param name Name of the special pseudo-class selector.
|
|
108
108
|
* @param argument Argument of the special pseudo-class selector.
|
|
@@ -120,7 +120,7 @@ export declare class HtmlRuleConverter extends RuleConverterBase {
|
|
|
120
120
|
* convert search pattern to regular expression
|
|
121
121
|
* - `[min-length="min"]` -> `:min-text-length(min)`
|
|
122
122
|
* direct conversion, no changes to value
|
|
123
|
-
* - `[max-length]` is skipped
|
|
123
|
+
* - `[max-length]` is skipped.
|
|
124
124
|
*
|
|
125
125
|
* @param name Name of the special attribute selector.
|
|
126
126
|
* @param value Value of the special attribute selector.
|
|
@@ -131,7 +131,7 @@ export declare class HtmlRuleConverter extends RuleConverterBase {
|
|
|
131
131
|
/**
|
|
132
132
|
* Handles special pseudo-class selectors during AdGuard to uBlock conversion:
|
|
133
133
|
* - `:contains(text)` -> `:has-text(text)`
|
|
134
|
-
* direct conversion, no changes to argument
|
|
134
|
+
* direct conversion, no changes to argument.
|
|
135
135
|
*
|
|
136
136
|
* @param name Name of the special pseudo-class selector.
|
|
137
137
|
* @param argument Argument of the special pseudo-class selector.
|
|
@@ -141,6 +141,23 @@ export declare class HtmlRuleConverter extends RuleConverterBase {
|
|
|
141
141
|
* @throws If uBlock-specific pseudo-class selector is found in AdGuard rule.
|
|
142
142
|
*/
|
|
143
143
|
private static convertSpecialPseudoClassSelectorAdgToUbo;
|
|
144
|
+
/**
|
|
145
|
+
* Pre-scans a complex selector's child selectors
|
|
146
|
+
* for {@link AdgAttributeSelectors.MinLength}
|
|
147
|
+
* and {@link AdgAttributeSelectors.MaxLength} attribute selectors.
|
|
148
|
+
*
|
|
149
|
+
* Resolves duplicates to the most *restrictive* value:
|
|
150
|
+
* - for multiple `[min-length]` selectors, the largest value is selected;
|
|
151
|
+
* - for multiple `[max-length]` selectors, the smallest value is selected.
|
|
152
|
+
*
|
|
153
|
+
* Logs a warning when duplicate length selectors are found.
|
|
154
|
+
*
|
|
155
|
+
* @param selectors Child selectors of a complex selector to scan.
|
|
156
|
+
*
|
|
157
|
+
* @returns Resolved length constraints,
|
|
158
|
+
* or `null` if no length selectors were found.
|
|
159
|
+
*/
|
|
160
|
+
private static collectLengthConstraints;
|
|
144
161
|
/**
|
|
145
162
|
* Converts a HTML filtering rule body by handling special simple selectors via callbacks.
|
|
146
163
|
* Special simple selectors are skipped in the converted selector list and should be handled from callee.
|
|
@@ -150,6 +167,9 @@ export declare class HtmlRuleConverter extends RuleConverterBase {
|
|
|
150
167
|
* @param generator HTML filtering rule body generator used for generating raw value bodies.
|
|
151
168
|
* @param onSpecialAttributeSelector Callback invoked when a special attribute selector is found.
|
|
152
169
|
* @param onSpecialPseudoClassSelector Callback invoked when a special pseudo-class selector is found.
|
|
170
|
+
* @param shouldMergeLengthSelectors If true, `[min-length]` and `[max-length]` attribute
|
|
171
|
+
* selectors within the same complex selector are merged into a single `:contains()` pseudo-class.
|
|
172
|
+
* Defaults to `false`.
|
|
153
173
|
*
|
|
154
174
|
* @returns Converted selector list without special simple selectors.
|
|
155
175
|
*/
|
|
@@ -1,33 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Cosmetic rule converter
|
|
2
|
+
* @file Cosmetic rule converter.
|
|
3
3
|
*/
|
|
4
4
|
import { type AnyCosmeticRule, type AnyRule } from '../../nodes/index.js';
|
|
5
|
-
import { RuleConverterBase } from '../base-interfaces/rule-converter-base.js';
|
|
6
5
|
import { type NodeConversionResult } from '../base-interfaces/conversion-result.js';
|
|
6
|
+
import { RuleConverterBase } from '../base-interfaces/rule-converter-base.js';
|
|
7
7
|
/**
|
|
8
|
-
* Cosmetic rule converter class (also known as "non-basic rule converter")
|
|
8
|
+
* Cosmetic rule converter class (also known as "non-basic rule converter").
|
|
9
9
|
*
|
|
10
|
-
* @todo Implement `convertToUbo` and `convertToAbp
|
|
10
|
+
* @todo Implement `convertToUbo` and `convertToAbp`.
|
|
11
11
|
*/
|
|
12
12
|
export declare class CosmeticRuleConverter extends RuleConverterBase {
|
|
13
13
|
/**
|
|
14
14
|
* Converts a cosmetic rule to AdGuard syntax, if possible.
|
|
15
15
|
*
|
|
16
|
-
* @param rule Rule node to convert
|
|
16
|
+
* @param rule Rule node to convert.
|
|
17
|
+
*
|
|
17
18
|
* @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
|
|
18
19
|
* the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
|
|
19
|
-
* If the rule was not converted, the result array will contain the original node with the same object reference
|
|
20
|
-
*
|
|
20
|
+
* If the rule was not converted, the result array will contain the original node with the same object reference.
|
|
21
|
+
*
|
|
22
|
+
* @throws If the rule is invalid or cannot be converted.
|
|
21
23
|
*/
|
|
22
24
|
static convertToAdg(rule: AnyCosmeticRule): NodeConversionResult<AnyRule>;
|
|
23
25
|
/**
|
|
24
26
|
* Converts a cosmetic rule to uBlock Origin syntax, if possible.
|
|
25
27
|
*
|
|
26
|
-
* @param rule Rule node to convert
|
|
28
|
+
* @param rule Rule node to convert.
|
|
29
|
+
*
|
|
27
30
|
* @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
|
|
28
31
|
* the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
|
|
29
|
-
* If the rule was not converted, the result array will contain the original node with the same object reference
|
|
30
|
-
*
|
|
32
|
+
* If the rule was not converted, the result array will contain the original node with the same object reference.
|
|
33
|
+
*
|
|
34
|
+
* @throws If the rule is invalid or cannot be converted.
|
|
31
35
|
*/
|
|
32
36
|
static convertToUbo(rule: AnyCosmeticRule): NodeConversionResult<AnyRule>;
|
|
33
37
|
}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Cosmetic rule modifier converter from uBO to ADG
|
|
2
|
+
* @file Cosmetic rule modifier converter from uBO to ADG.
|
|
3
3
|
*/
|
|
4
4
|
import { type ModifierList } from '../../../nodes/index.js';
|
|
5
5
|
import { type ConversionResult } from '../../base-interfaces/conversion-result.js';
|
|
6
6
|
/**
|
|
7
|
-
* Helper class for converting cosmetic rule modifiers from uBO to ADG
|
|
7
|
+
* Helper class for converting cosmetic rule modifiers from uBO to ADG.
|
|
8
8
|
*/
|
|
9
9
|
export declare class AdgCosmeticRuleModifierConverter {
|
|
10
10
|
/**
|
|
11
11
|
* Converts a uBO cosmetic rule modifier list to ADG, if possible.
|
|
12
12
|
*
|
|
13
|
-
* @
|
|
13
|
+
* @see {@link https://github.com/gorhill/uBlock/wiki/Procedural-cosmetic-filters#cosmetic-filter-operators}
|
|
14
|
+
*
|
|
15
|
+
* @param modifierList Cosmetic rule modifier list node to convert.
|
|
16
|
+
*
|
|
14
17
|
* @returns An object which follows the {@link ConversionResult} interface. Its `result` property contains
|
|
15
18
|
* the converted node, and its `isConverted` flag indicates whether the original node was converted.
|
|
16
|
-
* If the node was not converted, the result will contain the original node with the same object reference
|
|
17
|
-
*
|
|
18
|
-
* @
|
|
19
|
+
* If the node was not converted, the result will contain the original node with the same object reference.
|
|
20
|
+
*
|
|
21
|
+
* @throws If the modifier list cannot be converted.
|
|
19
22
|
*/
|
|
20
23
|
static convertFromUbo(modifierList: ModifierList): ConversionResult<ModifierList>;
|
|
21
24
|
}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Cosmetic rule modifier converter from ADG to uBO
|
|
2
|
+
* @file Cosmetic rule modifier converter from ADG to uBO.
|
|
3
3
|
*/
|
|
4
4
|
import { type DomainList, type ModifierList } from '../../../nodes/index.js';
|
|
5
5
|
import { type ConversionResult } from '../../base-interfaces/conversion-result.js';
|
|
6
6
|
/**
|
|
7
|
-
* Helper class for converting cosmetic rule modifiers from ADG to uBO
|
|
7
|
+
* Helper class for converting cosmetic rule modifiers from ADG to uBO.
|
|
8
8
|
*/
|
|
9
9
|
export declare class UboCosmeticRuleModifierConverter {
|
|
10
10
|
/**
|
|
11
11
|
* Converts a ADG cosmetic rule modifier list to uBO, if possible.
|
|
12
12
|
*
|
|
13
|
-
* @
|
|
13
|
+
* @see {@link https://github.com/gorhill/uBlock/wiki/Procedural-cosmetic-filters#cosmetic-filter-operators}
|
|
14
|
+
*
|
|
15
|
+
* @param modifierList Cosmetic rule modifier list node to convert.
|
|
16
|
+
*
|
|
14
17
|
* @returns An object which follows the {@link ConversionResult} interface. Its `result` property contains
|
|
15
18
|
* the converted node, and its `isConverted` flag indicates whether the original node was converted.
|
|
16
|
-
* If the node was not converted, the result will contain the original node with the same object reference
|
|
17
|
-
*
|
|
18
|
-
* @
|
|
19
|
+
* If the node was not converted, the result will contain the original node with the same object reference.
|
|
20
|
+
*
|
|
21
|
+
* @throws If the modifier list cannot be converted.
|
|
19
22
|
*/
|
|
20
23
|
static convertFromAdg(modifierList: ModifierList): ConversionResult<{
|
|
21
24
|
modifierList: ModifierList;
|
|
@@ -1,33 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Scriptlet injection rule converter
|
|
2
|
+
* @file Scriptlet injection rule converter.
|
|
3
3
|
*/
|
|
4
4
|
import { type ScriptletInjectionRule } from '../../nodes/index.js';
|
|
5
|
-
import { RuleConverterBase } from '../base-interfaces/rule-converter-base.js';
|
|
6
5
|
import { type NodeConversionResult } from '../base-interfaces/conversion-result.js';
|
|
6
|
+
import { RuleConverterBase } from '../base-interfaces/rule-converter-base.js';
|
|
7
7
|
/**
|
|
8
|
-
* Scriptlet injection rule converter class
|
|
8
|
+
* Scriptlet injection rule converter class.
|
|
9
9
|
*
|
|
10
|
-
* @todo Implement `convertToUbo` and `convertToAbp
|
|
10
|
+
* @todo Implement `convertToUbo` and `convertToAbp`.
|
|
11
11
|
*/
|
|
12
12
|
export declare class ScriptletRuleConverter extends RuleConverterBase {
|
|
13
13
|
/**
|
|
14
14
|
* Converts a scriptlet injection rule to AdGuard format, if possible.
|
|
15
15
|
*
|
|
16
|
-
* @param rule Rule node to convert
|
|
16
|
+
* @param rule Rule node to convert.
|
|
17
|
+
*
|
|
17
18
|
* @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
|
|
18
19
|
* the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
|
|
19
|
-
* If the rule was not converted, the result array will contain the original node with the same object reference
|
|
20
|
-
*
|
|
20
|
+
* If the rule was not converted, the result array will contain the original node with the same object reference.
|
|
21
|
+
*
|
|
22
|
+
* @throws If the rule is invalid or cannot be converted.
|
|
21
23
|
*/
|
|
22
24
|
static convertToAdg(rule: ScriptletInjectionRule): NodeConversionResult<ScriptletInjectionRule>;
|
|
23
25
|
/**
|
|
24
26
|
* Converts a scriptlet injection rule to uBlock format, if possible.
|
|
25
27
|
*
|
|
26
|
-
* @param rule Rule node to convert
|
|
28
|
+
* @param rule Rule node to convert.
|
|
29
|
+
*
|
|
27
30
|
* @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
|
|
28
31
|
* the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
|
|
29
|
-
* If the rule was not converted, the result array will contain the original node with the same object reference
|
|
30
|
-
*
|
|
32
|
+
* If the rule was not converted, the result array will contain the original node with the same object reference.
|
|
33
|
+
*
|
|
34
|
+
* @throws If the rule is invalid or cannot be converted.
|
|
31
35
|
*/
|
|
32
36
|
static convertToUbo(rule: ScriptletInjectionRule): NodeConversionResult<ScriptletInjectionRule>;
|
|
33
37
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { CssTokenStream } from '../../parser/css/css-token-stream.js';
|
|
1
2
|
import { BaseConverter } from '../base-interfaces/base-converter.js';
|
|
2
3
|
import { type ConversionResult } from '../base-interfaces/conversion-result.js';
|
|
3
|
-
import { CssTokenStream } from '../../parser/css/css-token-stream.js';
|
|
4
4
|
export declare const ERROR_MESSAGES: {
|
|
5
5
|
INVALID_ATTRIBUTE_VALUE: string;
|
|
6
6
|
};
|
|
@@ -22,19 +22,21 @@ export declare const PseudoElements: {
|
|
|
22
22
|
};
|
|
23
23
|
export type PseudoElements = typeof PseudoElements[keyof typeof PseudoElements];
|
|
24
24
|
/**
|
|
25
|
-
* CSS selector converter
|
|
25
|
+
* CSS selector converter.
|
|
26
26
|
*
|
|
27
|
-
* @todo Implement `convertToUbo` and `convertToAbp
|
|
27
|
+
* @todo Implement `convertToUbo` and `convertToAbp`.
|
|
28
28
|
*/
|
|
29
29
|
export declare class CssSelectorConverter extends BaseConverter {
|
|
30
30
|
/**
|
|
31
|
-
* Converts Extended CSS elements to AdGuard-compatible ones
|
|
31
|
+
* Converts Extended CSS elements to AdGuard-compatible ones.
|
|
32
|
+
*
|
|
33
|
+
* @param selectorList Selector list to convert.
|
|
32
34
|
*
|
|
33
|
-
* @param selectorList Selector list to convert
|
|
34
35
|
* @returns An object which follows the {@link ConversionResult} interface. Its `result` property contains
|
|
35
36
|
* the converted node, and its `isConverted` flag indicates whether the original node was converted.
|
|
36
|
-
* If the node was not converted, the result will contain the original node with the same object reference
|
|
37
|
-
*
|
|
37
|
+
* If the node was not converted, the result will contain the original node with the same object reference.
|
|
38
|
+
*
|
|
39
|
+
* @throws If the rule is invalid or incompatible.
|
|
38
40
|
*/
|
|
39
41
|
static convertToAdg(selectorList: string | CssTokenStream): ConversionResult<string>;
|
|
40
42
|
}
|