@adguard/agtree 4.0.0 → 4.0.2
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 +18 -18
- 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 +9 -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,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Pre-processor directives
|
|
2
|
+
* Pre-processor directives.
|
|
3
3
|
*
|
|
4
4
|
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#pre-processor-directives}
|
|
5
5
|
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#pre-parsing-directives}
|
|
@@ -12,6 +12,9 @@ import { BaseParser } from '../base-parser.js';
|
|
|
12
12
|
* Please note that this parser only handles general syntax for now, and does not validate the parameters at
|
|
13
13
|
* the parsing stage.
|
|
14
14
|
*
|
|
15
|
+
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#pre-processor-directives}
|
|
16
|
+
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#pre-parsing-directives}
|
|
17
|
+
*
|
|
15
18
|
* @example
|
|
16
19
|
* If your rule is
|
|
17
20
|
* ```adblock
|
|
@@ -19,15 +22,14 @@ import { BaseParser } from '../base-parser.js';
|
|
|
19
22
|
* ```
|
|
20
23
|
* then the directive's name is `if` and its value is `(adguard)`, but the parameter list
|
|
21
24
|
* is not parsed / validated further.
|
|
22
|
-
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#pre-processor-directives}
|
|
23
|
-
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#pre-parsing-directives}
|
|
24
25
|
*/
|
|
25
26
|
export declare class PreProcessorCommentParser extends BaseParser {
|
|
26
27
|
/**
|
|
27
28
|
* Determines whether the rule is a pre-processor rule.
|
|
28
29
|
*
|
|
29
|
-
* @param raw Raw rule
|
|
30
|
-
*
|
|
30
|
+
* @param raw Raw rule.
|
|
31
|
+
*
|
|
32
|
+
* @returns `true` if the rule is a pre-processor rule, `false` otherwise.
|
|
31
33
|
*/
|
|
32
34
|
static isPreProcessorRule(raw: string): boolean;
|
|
33
35
|
/**
|
|
@@ -36,8 +38,9 @@ export declare class PreProcessorCommentParser extends BaseParser {
|
|
|
36
38
|
* @param raw Raw input to parse.
|
|
37
39
|
* @param options Global parser options.
|
|
38
40
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
41
|
+
*
|
|
39
42
|
* @returns
|
|
40
|
-
* Pre-processor comment AST or null (if the raw rule cannot be parsed as a pre-processor comment)
|
|
43
|
+
* Pre-processor comment AST or null (if the raw rule cannot be parsed as a pre-processor comment).
|
|
41
44
|
*/
|
|
42
45
|
static parse(raw: string, options?: import("../index.js").ParserOptions, baseOffset?: number): PreProcessorCommentRule | null;
|
|
43
46
|
}
|
|
@@ -17,7 +17,9 @@ export declare class SimpleCommentParser extends BaseParser {
|
|
|
17
17
|
* Checks if the raw rule is a simple comment.
|
|
18
18
|
*
|
|
19
19
|
* @param raw Raw input to check.
|
|
20
|
+
*
|
|
20
21
|
* @returns `true` if the input is a simple comment, `false` otherwise.
|
|
22
|
+
*
|
|
21
23
|
* @note This method does not check for adblock agent comments.
|
|
22
24
|
*/
|
|
23
25
|
static isSimpleComment(raw: string): boolean;
|
|
@@ -27,6 +29,7 @@ export declare class SimpleCommentParser extends BaseParser {
|
|
|
27
29
|
* @param raw Raw input to parse.
|
|
28
30
|
* @param options Global parser options.
|
|
29
31
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
32
|
+
*
|
|
30
33
|
* @returns Comment rule node or null (if the raw rule cannot be parsed as a simple comment).
|
|
31
34
|
*/
|
|
32
35
|
static parse(raw: string, options?: import("../index.js").ParserOptions, baseOffset?: number): CommentRule | null;
|
|
@@ -17,7 +17,7 @@ export declare const ERROR_MESSAGES: {
|
|
|
17
17
|
* Where possible, it automatically detects the difference between supported syntaxes:
|
|
18
18
|
* - AdGuard
|
|
19
19
|
* - uBlock Origin
|
|
20
|
-
* - Adblock Plus
|
|
20
|
+
* - Adblock Plus.
|
|
21
21
|
*
|
|
22
22
|
* If the syntax is common / cannot be determined, the parser gives `Common` syntax.
|
|
23
23
|
*
|
|
@@ -30,22 +30,25 @@ export declare class CosmeticRuleParser extends BaseParser {
|
|
|
30
30
|
* Determines whether a rule is a cosmetic rule. The rule is considered cosmetic if it
|
|
31
31
|
* contains a cosmetic rule separator.
|
|
32
32
|
*
|
|
33
|
-
* @param raw Raw rule
|
|
34
|
-
*
|
|
33
|
+
* @param raw Raw rule.
|
|
34
|
+
*
|
|
35
|
+
* @returns `true` if the rule is a cosmetic rule, `false` otherwise.
|
|
35
36
|
*/
|
|
36
37
|
static isCosmeticRule(raw: string): boolean;
|
|
37
38
|
/**
|
|
38
39
|
* Parses a cosmetic rule. The structure of the cosmetic rules:
|
|
39
40
|
* - pattern (AdGuard pattern can have modifiers, other syntaxes don't)
|
|
40
41
|
* - separator
|
|
41
|
-
* - body
|
|
42
|
+
* - body.
|
|
42
43
|
*
|
|
43
44
|
* @param raw Raw input to parse.
|
|
44
45
|
* @param options Global parser options.
|
|
45
46
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
47
|
+
*
|
|
46
48
|
* @returns
|
|
47
|
-
* Parsed cosmetic rule AST or null if it failed to parse based on the known cosmetic rules
|
|
48
|
-
*
|
|
49
|
+
* Parsed cosmetic rule AST or null if it failed to parse based on the known cosmetic rules.
|
|
50
|
+
*
|
|
51
|
+
* @throws If the input matches the cosmetic rule pattern but syntactically invalid.
|
|
49
52
|
*/
|
|
50
53
|
static parse(raw: string, options?: import("../index.js").ParserOptions, baseOffset?: number): AnyCosmeticRule | null;
|
|
51
54
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type HtmlFilteringRuleBody, type Value } from '../../../nodes/index.js';
|
|
2
2
|
import { BaseParser } from '../../base-parser.js';
|
|
3
3
|
/**
|
|
4
4
|
* `AdgHtmlFilteringBodyParser` is responsible for parsing the body of an AdGuard-style HTML filtering rule.
|
|
5
5
|
*
|
|
6
6
|
* Please note that the parser will parse any HTML filtering rule if it is syntactically correct.
|
|
7
|
-
* For example, it will parse this
|
|
7
|
+
* For example, it will parse this:.
|
|
8
8
|
* ```adblock
|
|
9
9
|
* example.com$$div[special-attr="value"]
|
|
10
10
|
* ```
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* But it didn't check if the attribute `special-attr` actually supported by any adblocker..
|
|
13
13
|
*
|
|
14
14
|
* @see {@link https://www.w3.org/TR/selectors-4}
|
|
15
15
|
* @see {@link https://adguard.com/kb/general/ad-filtering/create-own-filters/#html-filtering-rules}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type HtmlFilteringRuleBody, type Value } from '../../../nodes/index.js';
|
|
2
2
|
import { BaseParser } from '../../base-parser.js';
|
|
3
3
|
/**
|
|
4
4
|
* Class responsible for parsing HTML filtering rule body.
|
|
5
5
|
*
|
|
6
6
|
* Please note that the parser will parse any HTML filtering rule body if it is syntactically correct.
|
|
7
|
-
* For example, it will parse this
|
|
7
|
+
* For example, it will parse this:.
|
|
8
8
|
* ```adblock
|
|
9
9
|
* span[special-attr="Example"]
|
|
10
10
|
* div:special-pseudo(Example)
|
|
11
11
|
* ```
|
|
12
12
|
*
|
|
13
|
-
*
|
|
14
|
-
* the attribute selector `special-attr` actually supported by any adblocker
|
|
13
|
+
* But it didn't check if the pseudo selector `special-pseudo` or if
|
|
14
|
+
* the attribute selector `special-attr` actually supported by any adblocker..
|
|
15
15
|
*
|
|
16
16
|
* @see {@link https://www.w3.org/TR/selectors-4}
|
|
17
17
|
* @see {@link https://adguard.com/kb/general/ad-filtering/create-own-filters/#html-filtering-rules}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type HtmlFilteringRuleBody, type Value } from '../../../nodes/index.js';
|
|
2
2
|
import { BaseParser } from '../../base-parser.js';
|
|
3
3
|
/**
|
|
4
4
|
* `UboHtmlFilteringBodyParser` is responsible for parsing the body of
|
|
5
5
|
* an uBlock-style HTML filtering rule, and also uBlock-style response header removal rule.
|
|
6
6
|
*
|
|
7
7
|
* Please note that the parser will parse any HTML filtering rule if it is syntactically correct.
|
|
8
|
-
* For example, it will parse this
|
|
8
|
+
* For example, it will parse this:.
|
|
9
9
|
* ```adblock
|
|
10
10
|
* example.com##^script:pseudo(content)
|
|
11
11
|
* example.com##^responseheader(header-name)
|
|
12
12
|
* ```
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
* the header name `header-name` actually supported by any adblocker
|
|
14
|
+
* But it didn't check if the pseudo selector `pseudo` or if
|
|
15
|
+
* the header name `header-name` actually supported by any adblocker..
|
|
16
16
|
*
|
|
17
17
|
* @see {@link https://www.w3.org/TR/selectors-4}
|
|
18
18
|
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#html-filters}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
2
|
+
* @file UBlock scriptlet injection body parser.
|
|
3
3
|
*/
|
|
4
4
|
import { type ScriptletInjectionRuleBody } from '../../../nodes/index.js';
|
|
5
5
|
import { BaseParser } from '../../base-parser.js';
|
|
@@ -7,12 +7,12 @@ import { BaseParser } from '../../base-parser.js';
|
|
|
7
7
|
* `AbpSnippetInjectionBodyParser` is responsible for parsing the body of an Adblock Plus-style snippet rule.
|
|
8
8
|
*
|
|
9
9
|
* Please note that the parser will parse any scriptlet rule if it is syntactically correct.
|
|
10
|
-
* For example, it will parse this
|
|
10
|
+
* For example, it will parse this:.
|
|
11
11
|
* ```adblock
|
|
12
12
|
* example.com#$#snippet0 arg0
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* But it didn't check if the scriptlet `snippet0` actually supported by any adblocker..
|
|
16
16
|
*
|
|
17
17
|
* @see {@link https://help.eyeo.com/adblockplus/snippet-filters-tutorial}
|
|
18
18
|
*/
|
|
@@ -23,8 +23,11 @@ export declare class AbpSnippetInjectionBodyParser extends BaseParser {
|
|
|
23
23
|
* @param raw Raw input to parse.
|
|
24
24
|
* @param options Global parser options.
|
|
25
25
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
26
|
-
*
|
|
27
|
-
* @
|
|
26
|
+
*
|
|
27
|
+
* @returns Node of the parsed scriptlet call body.
|
|
28
|
+
*
|
|
29
|
+
* @throws If the body is syntactically incorrect.
|
|
30
|
+
*
|
|
28
31
|
* @example
|
|
29
32
|
* ```
|
|
30
33
|
* #$#snippet0 arg0
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file AdGuard scriptlet injection body parser
|
|
2
|
+
* @file AdGuard scriptlet injection body parser.
|
|
3
3
|
*/
|
|
4
|
-
import { BaseParser } from '../../base-parser.js';
|
|
5
4
|
import { type ScriptletInjectionRuleBody } from '../../../nodes/index.js';
|
|
5
|
+
import { BaseParser } from '../../base-parser.js';
|
|
6
6
|
/**
|
|
7
7
|
* `AdgScriptletInjectionBodyParser` is responsible for parsing the body of an AdGuard-style scriptlet rule.
|
|
8
8
|
*
|
|
9
9
|
* Please note that the parser will parse any scriptlet rule if it is syntactically correct.
|
|
10
|
-
* For example, it will parse this
|
|
10
|
+
* For example, it will parse this:.
|
|
11
11
|
* ```adblock
|
|
12
12
|
* example.com#%#//scriptlet('scriptlet0', 'arg0')
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* But it didn't check if the scriptlet `scriptlet0` actually supported by any adblocker..
|
|
16
16
|
*
|
|
17
17
|
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#scriptlets}
|
|
18
18
|
*/
|
|
@@ -36,8 +36,11 @@ export declare class AdgScriptletInjectionBodyParser extends BaseParser {
|
|
|
36
36
|
* @param raw Raw input to parse.
|
|
37
37
|
* @param options Global parser options.
|
|
38
38
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
39
|
+
*
|
|
40
|
+
* @returns Node of the parsed scriptlet call body.
|
|
41
|
+
*
|
|
42
|
+
* @throws If the body is syntactically incorrect.
|
|
43
|
+
*
|
|
41
44
|
* @example
|
|
42
45
|
* ```
|
|
43
46
|
* //scriptlet('scriptlet0', 'arg0')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file
|
|
2
|
+
* @file UBlock scriptlet injection body parser.
|
|
3
3
|
*/
|
|
4
4
|
import { type ScriptletInjectionRuleBody } from '../../../nodes/index.js';
|
|
5
5
|
import { BaseParser } from '../../base-parser.js';
|
|
@@ -7,12 +7,12 @@ import { BaseParser } from '../../base-parser.js';
|
|
|
7
7
|
* `UboScriptletInjectionBodyParser` is responsible for parsing the body of a uBlock-style scriptlet rule.
|
|
8
8
|
*
|
|
9
9
|
* Please note that the parser will parse any scriptlet rule if it is syntactically correct.
|
|
10
|
-
* For example, it will parse this
|
|
10
|
+
* For example, it will parse this:.
|
|
11
11
|
* ```adblock
|
|
12
12
|
* example.com##+js(scriptlet0, arg0)
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* But it didn't check if the scriptlet `scriptlet0` actually supported by any adblocker..
|
|
16
16
|
*
|
|
17
17
|
* @see {@link https://github.com/gorhill/uBlock/wiki/Static-filter-syntax#scriptlet-injection}
|
|
18
18
|
*/
|
|
@@ -33,8 +33,11 @@ export declare class UboScriptletInjectionBodyParser extends BaseParser {
|
|
|
33
33
|
* @param raw Raw input to parse.
|
|
34
34
|
* @param options Global parser options.
|
|
35
35
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
36
|
-
*
|
|
37
|
-
* @
|
|
36
|
+
*
|
|
37
|
+
* @returns Node of the parsed scriptlet call body.
|
|
38
|
+
*
|
|
39
|
+
* @throws If the body is syntactically incorrect.
|
|
40
|
+
*
|
|
38
41
|
* @example
|
|
39
42
|
* ```
|
|
40
43
|
* ##+js(scriptlet0, arg0)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { type ComplexSelector, type SelectorList } from '../../../nodes/index.js';
|
|
2
|
+
import { type CssTokenStream, type TokenData } from '../../css/css-token-stream.js';
|
|
1
3
|
import { type ParserOptions } from '../../options.js';
|
|
2
|
-
import { type TokenData, type CssTokenStream } from '../../css/css-token-stream.js';
|
|
3
|
-
import { type SelectorList, type ComplexSelector } from '../../../nodes/index.js';
|
|
4
4
|
/**
|
|
5
5
|
* Interface that represents current selector list parser context.
|
|
6
6
|
*/
|
|
@@ -4,12 +4,12 @@ import { BaseParser } from '../../base-parser.js';
|
|
|
4
4
|
* Class responsible for parsing selector lists.
|
|
5
5
|
*
|
|
6
6
|
* Please note that the parser will parse any selector list if it is syntactically correct.
|
|
7
|
-
* For example, it will parse this
|
|
7
|
+
* For example, it will parse this:.
|
|
8
8
|
* ```adblock
|
|
9
9
|
* div[attr1="value1"] > h1[attr2="value2"], span[attr3="value3"]
|
|
10
10
|
* ```
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* But it didn't check if the given attribute or pseudo-class is valid or not..
|
|
13
13
|
*
|
|
14
14
|
* @see {@link https://www.w3.org/TR/selectors-4/#selector-list}'
|
|
15
15
|
*/
|
|
@@ -20,6 +20,7 @@ export declare class AdgCssInjectionParser extends BaseParser {
|
|
|
20
20
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
21
21
|
*
|
|
22
22
|
* @returns Parsed AdGuard CSS injection {@link CssInjectionRuleBody}.
|
|
23
|
+
*
|
|
23
24
|
* @throws An {@link AdblockSyntaxError} if the selector list is syntactically invalid.
|
|
24
25
|
*/
|
|
25
26
|
static parse(raw: string, options?: import("../index.js").ParserOptions, baseOffset?: number): CssInjectionRuleBody;
|
|
@@ -5,14 +5,16 @@ import { type OnErrorCallback, type OnTokenCallback, type TokenizerContextFuncti
|
|
|
5
5
|
/**
|
|
6
6
|
* Utility type to get the last element from a tuple, handling optional last elements correctly.
|
|
7
7
|
*
|
|
8
|
-
* @param T
|
|
8
|
+
* @param T The tuple to extract the last element from.
|
|
9
|
+
*
|
|
9
10
|
* @returns The last element of the tuple if present; `L | undefined` if the last element is optional.
|
|
10
11
|
*/
|
|
11
12
|
type Last<T extends unknown[]> = T extends [...infer _I, infer L] ? L : T extends [...infer _I, (infer L)?] ? L | undefined : never;
|
|
12
13
|
/**
|
|
13
14
|
* Utility type to remove the last element from a tuple, handling optional last elements correctly.
|
|
14
15
|
*
|
|
15
|
-
* @param T
|
|
16
|
+
* @param T The tuple to remove the last element from.
|
|
17
|
+
*
|
|
16
18
|
* @returns A tuple without the last element. If the last element is optional, it is also removed.
|
|
17
19
|
*/
|
|
18
20
|
type OmitLast<T extends unknown[]> = T extends [...infer Rest, infer _Last] ? Rest : T extends [...infer Rest, (infer _Last)?] ? Rest : never;
|
|
@@ -29,6 +31,7 @@ type OnTokenCallbackParameters = Parameters<OnTokenCallback>;
|
|
|
29
31
|
* @param props Additional properties of the token (if any - can be `undefined`, depending on the token type).
|
|
30
32
|
* @param balance Calculated balance level of the token.
|
|
31
33
|
* @param stop Function to halt tokenization.
|
|
34
|
+
*
|
|
32
35
|
* @note This function is keeping the same signature as the original `OnTokenCallback` to avoid breaking changes,
|
|
33
36
|
* just adding the `balance` parameter at the end.
|
|
34
37
|
*/
|
|
@@ -36,21 +39,23 @@ export type OnBalancedTokenCallback = (...args: [...OmitLast<OnTokenCallbackPara
|
|
|
36
39
|
/**
|
|
37
40
|
* Tokenize and ensure balanced pairs for standard CSS.
|
|
38
41
|
*
|
|
39
|
-
* @param raw Raw CSS string to tokenize
|
|
40
|
-
* @param onToken Callback which will be invoked for each token, extended with a `balance` parameter
|
|
41
|
-
* @param onError Error callback which is called when a parsing error is found (optional)
|
|
42
|
-
* @param functionHandlers Custom function handlers (optional)
|
|
43
|
-
*
|
|
42
|
+
* @param raw Raw CSS string to tokenize.
|
|
43
|
+
* @param onToken Callback which will be invoked for each token, extended with a `balance` parameter.
|
|
44
|
+
* @param onError Error callback which is called when a parsing error is found (optional).
|
|
45
|
+
* @param functionHandlers Custom function handlers (optional).
|
|
46
|
+
*
|
|
47
|
+
* @throws If the input is not balanced.
|
|
44
48
|
*/
|
|
45
49
|
export declare const tokenizeBalanced: (raw: string, onToken: OnBalancedTokenCallback, onError?: OnErrorCallback, functionHandlers?: Map<number, TokenizerContextFunction>) => void;
|
|
46
50
|
/**
|
|
47
51
|
* Tokenize and ensure balanced pairs for function calls.
|
|
48
52
|
*
|
|
49
|
-
* @param raw Raw CSS string to tokenize
|
|
50
|
-
* @param onToken Callback which will be invoked for each token, extended with a `balance` parameter
|
|
51
|
-
* @param onError Error callback which is called when a parsing error is found (optional)
|
|
52
|
-
* @param functionHandlers Custom function handlers (optional)
|
|
53
|
-
*
|
|
53
|
+
* @param raw Raw CSS string to tokenize.
|
|
54
|
+
* @param onToken Callback which will be invoked for each token, extended with a `balance` parameter.
|
|
55
|
+
* @param onError Error callback which is called when a parsing error is found (optional).
|
|
56
|
+
* @param functionHandlers Custom function handlers (optional).
|
|
57
|
+
*
|
|
58
|
+
* @throws If the input is not balanced.
|
|
54
59
|
*/
|
|
55
60
|
export declare const tokenizeFnBalanced: (raw: string, onToken: OnBalancedTokenCallback, onError?: OnErrorCallback, functionHandlers?: Map<number, TokenizerContextFunction>) => void;
|
|
56
61
|
export {};
|
|
@@ -92,6 +92,7 @@ export declare class CssTokenStream {
|
|
|
92
92
|
* Gets the token at the specified index.
|
|
93
93
|
*
|
|
94
94
|
* @param index The index of the token to retrieve.
|
|
95
|
+
*
|
|
95
96
|
* @returns The token at the specified index or undefined if the index is out of bounds.
|
|
96
97
|
*/
|
|
97
98
|
get(index?: number): TokenData | undefined;
|
|
@@ -99,7 +100,9 @@ export declare class CssTokenStream {
|
|
|
99
100
|
* Gets the token at the specified index or throws if no token is found at the specified index.
|
|
100
101
|
*
|
|
101
102
|
* @param index The index of the token to retrieve.
|
|
103
|
+
*
|
|
102
104
|
* @returns The token at the specified index or undefined if the index is out of bounds.
|
|
105
|
+
*
|
|
103
106
|
* @throws If no token is found at the specified index.
|
|
104
107
|
*/
|
|
105
108
|
getOrFail(index?: number): TokenData;
|
|
@@ -107,6 +110,7 @@ export declare class CssTokenStream {
|
|
|
107
110
|
* Gets the source fragment of the token at the specified index.
|
|
108
111
|
*
|
|
109
112
|
* @param index The index of the token to retrieve the fragment for.
|
|
113
|
+
*
|
|
110
114
|
* @returns The source fragment of the token or an empty string if the index is out of bounds.
|
|
111
115
|
*/
|
|
112
116
|
fragment(index?: number): string;
|
|
@@ -120,6 +124,7 @@ export declare class CssTokenStream {
|
|
|
120
124
|
* Looks ahead in the stream without changing the index.
|
|
121
125
|
*
|
|
122
126
|
* @param index The relative index to look ahead to, starting from the current index.
|
|
127
|
+
*
|
|
123
128
|
* @returns The next token or undefined if the end of the stream is reached.
|
|
124
129
|
*/
|
|
125
130
|
lookahead(index?: number): TokenData | undefined;
|
|
@@ -127,6 +132,7 @@ export declare class CssTokenStream {
|
|
|
127
132
|
* Looks behind in the stream without changing the index.
|
|
128
133
|
*
|
|
129
134
|
* @param index The relative index to look behind to, starting from the current index.
|
|
135
|
+
*
|
|
130
136
|
* @returns The previous token or undefined if the current token is the first in the stream.
|
|
131
137
|
*/
|
|
132
138
|
lookbehind(index?: number): TokenData | undefined;
|
|
@@ -151,6 +157,7 @@ export declare class CssTokenStream {
|
|
|
151
157
|
*
|
|
152
158
|
* @param type The type of token to skip until.
|
|
153
159
|
* @param balance The balance level of the token to skip until.
|
|
160
|
+
*
|
|
154
161
|
* @returns The number of tokens skipped.
|
|
155
162
|
*/
|
|
156
163
|
skipUntil(type: TokenType, balance?: number): number;
|
|
@@ -161,6 +168,7 @@ export declare class CssTokenStream {
|
|
|
161
168
|
*
|
|
162
169
|
* @param type The type of token to skip until.
|
|
163
170
|
* @param balance The balance level of the token to skip until.
|
|
171
|
+
*
|
|
164
172
|
* @returns An array containing the number of tokens skipped and the number of tokens skipped without leading and
|
|
165
173
|
* trailing whitespace tokens.
|
|
166
174
|
*/
|
|
@@ -174,6 +182,7 @@ export declare class CssTokenStream {
|
|
|
174
182
|
*
|
|
175
183
|
* @param type The expected token type.
|
|
176
184
|
* @param data Optional expectation data.
|
|
185
|
+
*
|
|
177
186
|
* @throws If the end of the stream is reached or if the token type or expectation data does not match.
|
|
178
187
|
*/
|
|
179
188
|
expect(type: TokenType, data?: ExpectationData): void;
|
|
@@ -181,6 +190,7 @@ export declare class CssTokenStream {
|
|
|
181
190
|
* Gets the balance level of the token at the specified index.
|
|
182
191
|
*
|
|
183
192
|
* @param index The index of the token to retrieve the balance level for.
|
|
193
|
+
*
|
|
184
194
|
* @returns The balance level of the token or 0 if the index is out of bounds.
|
|
185
195
|
*/
|
|
186
196
|
getBalance(index?: number): number;
|
|
@@ -213,6 +223,7 @@ export declare class CssTokenStream {
|
|
|
213
223
|
* and don't need the full `CssTokenStream` functionality.
|
|
214
224
|
*
|
|
215
225
|
* @param selector CSS selector string to check.
|
|
226
|
+
*
|
|
216
227
|
* @returns True if the selector contains `:has()`, `:is()`, or `:not()`,
|
|
217
228
|
* otherwise false.
|
|
218
229
|
*/
|
|
@@ -20,7 +20,9 @@ export declare const ERROR_MESSAGES: {
|
|
|
20
20
|
*
|
|
21
21
|
* @param name Pseudo name.
|
|
22
22
|
* @param wrapper Wrapper pseudo name (eg. `not`) (optional, defaults to `undefined`).
|
|
23
|
+
*
|
|
23
24
|
* @returns Formatted pseudo name.
|
|
25
|
+
*
|
|
24
26
|
* @example
|
|
25
27
|
* ```ts
|
|
26
28
|
* formatPseudoName('matches-path', 'not'); // => ':not(:matches-path(...))'
|
|
@@ -40,6 +42,7 @@ export declare class UboSelectorParser extends BaseParser {
|
|
|
40
42
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
41
43
|
*
|
|
42
44
|
* @returns Parsed uBO selector {@link UboSelectorParser}.
|
|
45
|
+
*
|
|
43
46
|
* @throws An {@link AdblockSyntaxError} if the selector list is syntactically invalid.
|
|
44
47
|
*/
|
|
45
48
|
static parse(raw: string, options?: import("../index.js").ParserOptions, baseOffset?: number): UboSelector;
|
|
@@ -11,7 +11,11 @@ export declare class FilterListParser extends BaseParser {
|
|
|
11
11
|
* @param raw Raw input to parse.
|
|
12
12
|
* @param options Global parser options.
|
|
13
13
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
14
|
-
*
|
|
14
|
+
*
|
|
15
|
+
* @returns AST of the source code (list of rules).
|
|
16
|
+
*
|
|
17
|
+
* @throws If one of the rules is syntactically invalid (if `tolerant` is `false`).
|
|
18
|
+
*
|
|
15
19
|
* @example
|
|
16
20
|
* ```js
|
|
17
21
|
* import { readFileSync } from 'fs';
|
|
@@ -23,7 +27,6 @@ export declare class FilterListParser extends BaseParser {
|
|
|
23
27
|
* // Parse the filter list content, then do something with the AST
|
|
24
28
|
* const ast = FilterListParser.parse(content);
|
|
25
29
|
* ```
|
|
26
|
-
* @throws If one of the rules is syntactically invalid (if `tolerant` is `false`)
|
|
27
30
|
*/
|
|
28
31
|
static parse(raw: string, options?: import("./options.js").ParserOptions, baseOffset?: number): FilterList;
|
|
29
32
|
}
|
|
@@ -15,6 +15,7 @@ export declare class AppListParser extends BaseParser {
|
|
|
15
15
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
16
16
|
*
|
|
17
17
|
* @returns App list AST.
|
|
18
|
+
*
|
|
18
19
|
* @throws An {@link AdblockSyntaxError} if the app list is syntactically invalid.
|
|
19
20
|
* @throws An {@link Error} if the options are invalid.
|
|
20
21
|
*/
|
|
@@ -3,22 +3,24 @@ import { BaseParser } from '../base-parser.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* `DomainListParser` is responsible for parsing a domain list.
|
|
5
5
|
*
|
|
6
|
+
* @see {@link https://help.eyeo.com/adblockplus/how-to-write-filters#elemhide_domains}
|
|
7
|
+
*
|
|
6
8
|
* @example
|
|
7
9
|
* - If the rule is `example.com,~example.net##.ads`, the domain list is `example.com,~example.net`.
|
|
8
10
|
* - If the rule is `ads.js^$script,domains=example.com|~example.org`, the domain list is `example.com|~example.org`.
|
|
9
11
|
* This parser is responsible for parsing these domain lists.
|
|
10
|
-
* @see {@link https://help.eyeo.com/adblockplus/how-to-write-filters#elemhide_domains}
|
|
11
12
|
*/
|
|
12
13
|
export declare class DomainListParser extends BaseParser {
|
|
13
14
|
/**
|
|
14
|
-
* Parses a domain list, eg. `example.com,example.org,~example.org
|
|
15
|
+
* Parses a domain list, eg. `example.com,example.org,~example.org`.
|
|
15
16
|
*
|
|
16
17
|
* @param raw Raw input to parse.
|
|
17
18
|
* @param options Global parser options.
|
|
18
19
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
19
|
-
* @param separator Separator character (default: comma)
|
|
20
|
+
* @param separator Separator character (default: comma).
|
|
20
21
|
*
|
|
21
22
|
* @returns Domain list AST.
|
|
23
|
+
*
|
|
22
24
|
* @throws An {@link AdblockSyntaxError} if the domain list is syntactically invalid.
|
|
23
25
|
* @throws An {@link Error} if the options are invalid.
|
|
24
26
|
*/
|
|
@@ -18,15 +18,17 @@ export declare class ListItemsParser {
|
|
|
18
18
|
* Parses a `raw` modifier value which may be represented as a list of items separated by `separator`.
|
|
19
19
|
* Needed for $app, $denyallow, $domain, $method.
|
|
20
20
|
*
|
|
21
|
+
* @template T Type of the list items.
|
|
22
|
+
*
|
|
21
23
|
* @param raw Raw input to parse.
|
|
22
24
|
* @param options Global parser options.
|
|
23
25
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
24
|
-
* @param separator Separator character (default: comma)
|
|
26
|
+
* @param separator Separator character (default: comma).
|
|
25
27
|
* @param type Type of the list items (default: {@link ListItemNodeType.Domain}).
|
|
26
|
-
* @template T Type of the list items.
|
|
27
28
|
*
|
|
28
29
|
* @returns List of parsed items.
|
|
29
|
-
*
|
|
30
|
+
*
|
|
31
|
+
* @throws An {@link AdblockSyntaxError} if the list is syntactically invalid.
|
|
30
32
|
*
|
|
31
33
|
* @example
|
|
32
34
|
* - parses an app list — `com.example.app|Example.exe`
|
|
@@ -23,10 +23,12 @@ export declare class LogicalExpressionParser extends BaseParser {
|
|
|
23
23
|
/**
|
|
24
24
|
* Split the expression into tokens.
|
|
25
25
|
*
|
|
26
|
-
* @param raw Source code of the expression
|
|
26
|
+
* @param raw Source code of the expression.
|
|
27
27
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
28
|
+
*
|
|
29
|
+
* @returns Token list.
|
|
30
|
+
*
|
|
31
|
+
* @throws {AdblockSyntaxError} If the expression is invalid.
|
|
30
32
|
*/
|
|
31
33
|
private static tokenize;
|
|
32
34
|
/**
|
|
@@ -35,8 +37,10 @@ export declare class LogicalExpressionParser extends BaseParser {
|
|
|
35
37
|
* @param raw Raw input to parse.
|
|
36
38
|
* @param options Global parser options.
|
|
37
39
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
40
|
+
*
|
|
41
|
+
* @returns Parsed expression.
|
|
42
|
+
*
|
|
43
|
+
* @throws {AdblockSyntaxError} If the expression is invalid.
|
|
40
44
|
*/
|
|
41
45
|
static parse(raw: string, options?: import("../index.js").ParserOptions, baseOffset?: number): AnyExpressionNode;
|
|
42
46
|
}
|
|
@@ -15,6 +15,7 @@ export declare class MethodListParser extends BaseParser {
|
|
|
15
15
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
16
16
|
*
|
|
17
17
|
* @returns Method list AST.
|
|
18
|
+
*
|
|
18
19
|
* @throws An {@link AdblockSyntaxError} if the method list is syntactically invalid.
|
|
19
20
|
* @throws An {@link Error} if the options are invalid.
|
|
20
21
|
*/
|
|
@@ -18,7 +18,8 @@ export declare class ModifierListParser extends BaseParser {
|
|
|
18
18
|
* @param raw Raw input to parse.
|
|
19
19
|
* @param options Global parser options.
|
|
20
20
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
21
|
-
*
|
|
21
|
+
*
|
|
22
|
+
* @returns Parsed modifiers interface.
|
|
22
23
|
*/
|
|
23
24
|
static parse(raw: string, options?: import("../index.js").ParserOptions, baseOffset?: number): ModifierList;
|
|
24
25
|
}
|
|
@@ -14,7 +14,8 @@ export declare class ModifierParser extends BaseParser {
|
|
|
14
14
|
* @param options Global parser options.
|
|
15
15
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
16
16
|
*
|
|
17
|
-
* @returns Parsed modifier
|
|
17
|
+
* @returns Parsed modifier.
|
|
18
|
+
*
|
|
18
19
|
* @throws An error if modifier name or value is empty.
|
|
19
20
|
*/
|
|
20
21
|
static parse(raw: string, options?: import("../index.js").ParserOptions, baseOffset?: number): Modifier;
|
|
@@ -10,8 +10,9 @@ export declare class ParameterListParser extends BaseParser {
|
|
|
10
10
|
* @param raw Raw input to parse.
|
|
11
11
|
* @param options Global parser options.
|
|
12
12
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
13
|
-
* @param separator Separator character (default: comma)
|
|
14
|
-
*
|
|
13
|
+
* @param separator Separator character (default: comma).
|
|
14
|
+
*
|
|
15
|
+
* @returns Parameter list AST.
|
|
15
16
|
*/
|
|
16
17
|
static parse(raw: string, options?: import("../index.js").ParserOptions, baseOffset?: number, separator?: string): ParameterList;
|
|
17
18
|
}
|
|
@@ -15,6 +15,7 @@ export declare class StealthOptionListParser extends BaseParser {
|
|
|
15
15
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
16
16
|
*
|
|
17
17
|
* @returns Stealth option list AST.
|
|
18
|
+
*
|
|
18
19
|
* @throws An {@link AdblockSyntaxError} if the stealth option list is syntactically invalid.
|
|
19
20
|
* @throws An {@link Error} if the options are invalid.
|
|
20
21
|
*/
|