@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
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
@@ -10,7 +10,6 @@ import { BaseParser } from '../base-parser.js';
|
|
|
10
10
|
import { defaultParserOptions } from '../options.js';
|
|
11
11
|
import { ModifierParser } from './modifier-parser.js';
|
|
12
12
|
|
|
13
|
-
/* eslint-disable no-param-reassign */
|
|
14
13
|
/**
|
|
15
14
|
* `ModifierListParser` is responsible for parsing modifier lists. Please note that the name is not
|
|
16
15
|
* uniform, "modifiers" are also known as "options".
|
|
@@ -29,7 +28,8 @@ class ModifierListParser extends BaseParser {
|
|
|
29
28
|
* @param raw Raw input to parse.
|
|
30
29
|
* @param options Global parser options.
|
|
31
30
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
32
|
-
*
|
|
31
|
+
*
|
|
32
|
+
* @returns Parsed modifiers interface.
|
|
33
33
|
*/
|
|
34
34
|
static parse(raw, options = defaultParserOptions, baseOffset = 0) {
|
|
35
35
|
const result = {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
|
+
import { AdblockSyntaxError } from '../../errors/adblock-syntax-error.js';
|
|
7
8
|
import { NEGATION_MARKER, MODIFIER_ASSIGN_OPERATOR } from '../../utils/constants.js';
|
|
8
9
|
import { StringUtils } from '../../utils/string.js';
|
|
9
|
-
import { AdblockSyntaxError } from '../../errors/adblock-syntax-error.js';
|
|
10
|
-
import { defaultParserOptions } from '../options.js';
|
|
11
10
|
import { BaseParser } from '../base-parser.js';
|
|
11
|
+
import { defaultParserOptions } from '../options.js';
|
|
12
12
|
import { ValueParser } from './value-parser.js';
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -25,7 +25,8 @@ class ModifierParser extends BaseParser {
|
|
|
25
25
|
* @param options Global parser options.
|
|
26
26
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
27
27
|
*
|
|
28
|
-
* @returns Parsed modifier
|
|
28
|
+
* @returns Parsed modifier.
|
|
29
|
+
*
|
|
29
30
|
* @throws An error if modifier name or value is empty.
|
|
30
31
|
*/
|
|
31
32
|
static parse(raw, options = defaultParserOptions, baseOffset = 0) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
|
-
import { StringUtils } from '../../utils/string.js';
|
|
8
7
|
import { COMMA } from '../../utils/constants.js';
|
|
9
|
-
import {
|
|
8
|
+
import { StringUtils } from '../../utils/string.js';
|
|
10
9
|
import { BaseParser } from '../base-parser.js';
|
|
10
|
+
import { defaultParserOptions } from '../options.js';
|
|
11
11
|
import { ValueParser } from './value-parser.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -20,8 +20,9 @@ class ParameterListParser extends BaseParser {
|
|
|
20
20
|
* @param raw Raw input to parse.
|
|
21
21
|
* @param options Global parser options.
|
|
22
22
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
23
|
-
* @param separator Separator character (default: comma)
|
|
24
|
-
*
|
|
23
|
+
* @param separator Separator character (default: comma).
|
|
24
|
+
*
|
|
25
|
+
* @returns Parameter list AST.
|
|
25
26
|
*/
|
|
26
27
|
static parse(raw, options = defaultParserOptions, baseOffset = 0, separator = COMMA) {
|
|
27
28
|
// Prepare the parameter list node
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
|
-
import { PIPE } from '../../utils/constants.js';
|
|
8
7
|
import { ListItemNodeType, ListNodeType } from '../../nodes/index.js';
|
|
9
|
-
import {
|
|
8
|
+
import { PIPE } from '../../utils/constants.js';
|
|
10
9
|
import { BaseParser } from '../base-parser.js';
|
|
10
|
+
import { defaultParserOptions } from '../options.js';
|
|
11
11
|
import { ListItemsParser } from './list-items-parser.js';
|
|
12
12
|
|
|
13
13
|
const STEALTH_OPTION_LIST_SEPARATOR = PIPE;
|
|
@@ -26,6 +26,7 @@ class StealthOptionListParser extends BaseParser {
|
|
|
26
26
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
27
27
|
*
|
|
28
28
|
* @returns Stealth option list AST.
|
|
29
|
+
*
|
|
29
30
|
* @throws An {@link AdblockSyntaxError} if the stealth option list is syntactically invalid.
|
|
30
31
|
* @throws An {@link Error} if the options are invalid.
|
|
31
32
|
*/
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
|
-
import { StringUtils } from '../../utils/string.js';
|
|
8
|
-
import { COMMA, ESCAPE_CHARACTER } from '../../utils/constants.js';
|
|
9
|
-
import { defaultParserOptions } from '../options.js';
|
|
10
|
-
import { ValueParser } from './value-parser.js';
|
|
11
7
|
import { AdblockSyntaxError } from '../../errors/adblock-syntax-error.js';
|
|
8
|
+
import { COMMA, ESCAPE_CHARACTER } from '../../utils/constants.js';
|
|
12
9
|
import { QUOTE_SET } from '../../utils/quotes.js';
|
|
10
|
+
import { StringUtils } from '../../utils/string.js';
|
|
11
|
+
import { defaultParserOptions } from '../options.js';
|
|
13
12
|
import { ParameterListParser } from './parameter-list-parser.js';
|
|
13
|
+
import { ValueParser } from './value-parser.js';
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Parser for uBO-specific parameter lists.
|
|
@@ -25,6 +25,7 @@ class UboParameterListParser extends ParameterListParser {
|
|
|
25
25
|
* @param separator Separator character (default: comma).
|
|
26
26
|
* @param requireQuotes Whether to require quotes around the parameter values (default: false).
|
|
27
27
|
* @param supportedQuotes Set of accepted quotes (default: {@link QUOTE_SET}).
|
|
28
|
+
*
|
|
28
29
|
* @returns Parameter list node.
|
|
29
30
|
*
|
|
30
31
|
* @note Based on {@link https://github.com/gorhill/uBlock/blob/f9ab4b75041815e6e5690d80851189ae3dc660d0/src/js/static-filtering-parser.js#L607-L699} to provide consistency.
|
|
@@ -71,16 +72,16 @@ class UboParameterListParser extends ParameterListParser {
|
|
|
71
72
|
* At that point found `possibleClosingQuoteIndex` is wrong
|
|
72
73
|
* | is `offset`
|
|
73
74
|
* ~ is `possibleClosingQuoteIndex`
|
|
74
|
-
* ^ is `nextSeparatorIndex
|
|
75
|
+
* ^ is `nextSeparatorIndex`.
|
|
75
76
|
*
|
|
76
77
|
* Example 1: "abc, ').cba='1'"
|
|
77
|
-
* |
|
|
78
|
+
* | ~^.
|
|
78
79
|
* Example 2: "abc, ').cba, '1'"
|
|
79
80
|
* | ~^
|
|
80
81
|
* Example 3: "abc, ').cba='1', cba"
|
|
81
|
-
* |
|
|
82
|
+
* | ~^.
|
|
82
83
|
*
|
|
83
|
-
* Search for separator before `possibleClosingQuoteIndex
|
|
84
|
+
* Search for separator before `possibleClosingQuoteIndex`.
|
|
84
85
|
*/
|
|
85
86
|
const separatorIndexBeforeQuote = StringUtils.findNextUnescapedCharacterBackwards(raw, separator, possibleClosingQuoteIndex, ESCAPE_CHARACTER, offset + 1);
|
|
86
87
|
if (separatorIndexBeforeQuote !== -1) {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
|
-
import { defaultParserOptions } from '../options.js';
|
|
8
7
|
import { BaseParser } from '../base-parser.js';
|
|
8
|
+
import { defaultParserOptions } from '../options.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Value parser.
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
|
-
import { getDomain, getHostname } from 'tldts';
|
|
8
7
|
import isIp from 'is-ip';
|
|
9
|
-
import {
|
|
8
|
+
import { getDomain, getHostname } from 'tldts';
|
|
10
9
|
import { NetworkRuleType, RuleCategory } from '../../nodes/index.js';
|
|
11
|
-
import { defaultParserOptions } from '../options.js';
|
|
12
|
-
import { BaseParser } from '../base-parser.js';
|
|
13
10
|
import { AdblockSyntax } from '../../utils/adblockers.js';
|
|
11
|
+
import { StringUtils } from '../../utils/string.js';
|
|
12
|
+
import { BaseParser } from '../base-parser.js';
|
|
14
13
|
import { ValueParser } from '../misc/value-parser.js';
|
|
14
|
+
import { defaultParserOptions } from '../options.js';
|
|
15
15
|
|
|
16
16
|
/* eslint-disable no-param-reassign */
|
|
17
17
|
/**
|
|
@@ -20,20 +20,27 @@ import { ValueParser } from '../misc/value-parser.js';
|
|
|
20
20
|
* HostRule is a structure for simple host-level rules (i.e. /etc/hosts syntax).
|
|
21
21
|
* It also supports "just domain" syntax. In this case, the IP will be set to 0.0.0.0.
|
|
22
22
|
*
|
|
23
|
-
* Rules syntax looks like this
|
|
23
|
+
* Rules syntax looks like this:.
|
|
24
24
|
* ```text
|
|
25
25
|
* IP_address canonical_hostname [aliases...]
|
|
26
26
|
* ```
|
|
27
27
|
*
|
|
28
|
+
* @see {@link http://man7.org/linux/man-pages/man5/hosts.5.html}
|
|
29
|
+
*
|
|
28
30
|
* @example
|
|
29
31
|
* `192.168.1.13 bar.mydomain.org bar` -- ipv4
|
|
30
32
|
* `ff02::1 ip6-allnodes` -- ipv6
|
|
31
33
|
* `::1 localhost ip6-localhost ip6-loopback` -- ipv6 aliases
|
|
32
34
|
* `example.org` -- "just domain" syntax
|
|
33
|
-
* @see {@link http://man7.org/linux/man-pages/man5/hosts.5.html}
|
|
34
35
|
*/
|
|
35
36
|
class HostRuleParser extends BaseParser {
|
|
37
|
+
/**
|
|
38
|
+
* Default IP address for host rules without explicit IP.
|
|
39
|
+
*/
|
|
36
40
|
static NULL_IP = '0.0.0.0';
|
|
41
|
+
/**
|
|
42
|
+
* Comment marker character.
|
|
43
|
+
*/
|
|
37
44
|
static COMMENT_MARKER = '#';
|
|
38
45
|
/**
|
|
39
46
|
* Parses an etc/hosts-like rule.
|
|
@@ -41,6 +48,7 @@ class HostRuleParser extends BaseParser {
|
|
|
41
48
|
* @param raw Raw input to parse.
|
|
42
49
|
* @param options Global parser options.
|
|
43
50
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
51
|
+
*
|
|
44
52
|
* @returns Host rule node.
|
|
45
53
|
*
|
|
46
54
|
* @throws If the input contains invalid data.
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
|
+
import { AdblockSyntaxError } from '../../errors/adblock-syntax-error.js';
|
|
8
|
+
import { RuleCategory, NetworkRuleType } from '../../nodes/index.js';
|
|
7
9
|
import { AdblockSyntax } from '../../utils/adblockers.js';
|
|
8
|
-
import { StringUtils } from '../../utils/string.js';
|
|
9
|
-
import { ModifierListParser } from '../misc/modifier-list.js';
|
|
10
10
|
import { NETWORK_RULE_EXCEPTION_MARKER, NETWORK_RULE_EXCEPTION_MARKER_LEN, NETWORK_RULE_SEPARATOR, REGEX_MARKER, ESCAPE_CHARACTER } from '../../utils/constants.js';
|
|
11
|
-
import {
|
|
12
|
-
import { AdblockSyntaxError } from '../../errors/adblock-syntax-error.js';
|
|
13
|
-
import { defaultParserOptions } from '../options.js';
|
|
11
|
+
import { StringUtils } from '../../utils/string.js';
|
|
14
12
|
import { BaseParser } from '../base-parser.js';
|
|
13
|
+
import { ModifierListParser } from '../misc/modifier-list.js';
|
|
15
14
|
import { ValueParser } from '../misc/value-parser.js';
|
|
15
|
+
import { defaultParserOptions } from '../options.js';
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* `NetworkRuleParser` is responsible for parsing network rules.
|
|
@@ -30,7 +30,8 @@ class NetworkRuleParser extends BaseParser {
|
|
|
30
30
|
* @param raw Raw input to parse.
|
|
31
31
|
* @param options Global parser options.
|
|
32
32
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
33
|
-
*
|
|
33
|
+
*
|
|
34
|
+
* @returns Network rule AST.
|
|
34
35
|
*
|
|
35
36
|
* @throws If the rule is syntactically incorrect.
|
|
36
37
|
*/
|
|
@@ -96,8 +97,9 @@ class NetworkRuleParser extends BaseParser {
|
|
|
96
97
|
/**
|
|
97
98
|
* Finds the index of the separator character in a network rule.
|
|
98
99
|
*
|
|
99
|
-
* @param rule Network rule to check
|
|
100
|
-
*
|
|
100
|
+
* @param rule Network rule to check.
|
|
101
|
+
*
|
|
102
|
+
* @returns The index of the separator character, or -1 if there is no separator.
|
|
101
103
|
*/
|
|
102
104
|
static findNetworkRuleSeparatorIndex(rule) {
|
|
103
105
|
// As we are looking for the last separator, we start from the end of the string
|
package/dist/parser/options.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* AGTree v4.0.
|
|
2
|
+
* AGTree v4.0.2 (build date: Tue, 17 Mar 2026 23:34:38 GMT)
|
|
3
3
|
* (c) 2026 Adguard Software Ltd.
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
6
|
*/
|
|
7
|
+
import { AdblockSyntaxError } from '../errors/adblock-syntax-error.js';
|
|
8
|
+
import { RuleCategory } from '../nodes/index.js';
|
|
7
9
|
import { AdblockSyntax } from '../utils/adblockers.js';
|
|
10
|
+
import { BaseParser } from './base-parser.js';
|
|
8
11
|
import { CommentParser } from './comment/comment-parser.js';
|
|
9
12
|
import { CosmeticRuleParser } from './cosmetic/cosmetic-rule-parser.js';
|
|
13
|
+
import { HostRuleParser } from './network/host-rule-parser.js';
|
|
10
14
|
import { NetworkRuleParser } from './network/network-rule-parser.js';
|
|
11
|
-
import { RuleCategory } from '../nodes/index.js';
|
|
12
|
-
import { AdblockSyntaxError } from '../errors/adblock-syntax-error.js';
|
|
13
15
|
import { defaultParserOptions } from './options.js';
|
|
14
|
-
import { BaseParser } from './base-parser.js';
|
|
15
|
-
import { HostRuleParser } from './network/host-rule-parser.js';
|
|
16
16
|
|
|
17
17
|
/* eslint-disable no-param-reassign */
|
|
18
18
|
/**
|
|
@@ -28,6 +28,7 @@ class RuleParser extends BaseParser {
|
|
|
28
28
|
* @param raw Raw input to parse.
|
|
29
29
|
* @param options Global parser options.
|
|
30
30
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
31
|
+
*
|
|
31
32
|
* @returns Host rule or network rule node.
|
|
32
33
|
*/
|
|
33
34
|
static parseHostOrNetworkRule(raw, options, baseOffset) {
|
|
@@ -69,8 +70,11 @@ class RuleParser extends BaseParser {
|
|
|
69
70
|
* @param raw Raw input to parse.
|
|
70
71
|
* @param options Global parser options.
|
|
71
72
|
* @param baseOffset Starting offset of the input. Node locations are calculated relative to this offset.
|
|
72
|
-
*
|
|
73
|
-
* @
|
|
73
|
+
*
|
|
74
|
+
* @returns Adblock rule node.
|
|
75
|
+
*
|
|
76
|
+
* @throws If the input matches a pattern but syntactically invalid.
|
|
77
|
+
*
|
|
74
78
|
* @example
|
|
75
79
|
* Take a look at the following example:
|
|
76
80
|
* ```js
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Custom clone functions for AST nodes, this is probably the most efficient way to clone AST nodes.
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
|
+
* @todo Maybe move them to parser classes as 'clone' methods.
|
|
4
5
|
*/
|
|
5
|
-
import { type
|
|
6
|
+
import { type DomainList, type ModifierList, type ParameterList } from '../nodes/index.js';
|
|
6
7
|
/**
|
|
7
8
|
* Clones a scriptlet rule node.
|
|
8
9
|
*
|
|
9
|
-
* @param node Node to clone
|
|
10
|
-
*
|
|
10
|
+
* @param node Node to clone.
|
|
11
|
+
*
|
|
12
|
+
* @returns Cloned node.
|
|
11
13
|
*/
|
|
12
14
|
export declare function cloneScriptletRuleNode(node: ParameterList): ParameterList;
|
|
13
15
|
/**
|
|
14
16
|
* Clones a domain list node.
|
|
15
17
|
*
|
|
16
|
-
* @param node Node to clone
|
|
17
|
-
*
|
|
18
|
+
* @param node Node to clone.
|
|
19
|
+
*
|
|
20
|
+
* @returns Cloned node.
|
|
18
21
|
*/
|
|
19
22
|
export declare function cloneDomainListNode(node: DomainList): DomainList;
|
|
20
23
|
/**
|
|
21
24
|
* Clones a modifier list node.
|
|
22
25
|
*
|
|
23
|
-
* @param node Node to clone
|
|
24
|
-
*
|
|
26
|
+
* @param node Node to clone.
|
|
27
|
+
*
|
|
28
|
+
* @returns Cloned node.
|
|
25
29
|
*/
|
|
26
30
|
export declare function cloneModifierListNode(node: ModifierList): ModifierList;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Utility functions for working with filter list nodes
|
|
2
|
+
* @file Utility functions for working with filter list nodes.
|
|
3
3
|
*/
|
|
4
4
|
import { type AnyRule, type FilterList } from '../nodes/index.js';
|
|
5
5
|
/**
|
|
6
|
-
* Creates a filter list node
|
|
6
|
+
* Creates a filter list node.
|
|
7
7
|
*
|
|
8
|
-
* @param rules Rules to put in the list (optional, defaults to an empty list)
|
|
9
|
-
*
|
|
8
|
+
* @param rules Rules to put in the list (optional, defaults to an empty list).
|
|
9
|
+
*
|
|
10
|
+
* @returns Filter list node.
|
|
10
11
|
*/
|
|
11
12
|
export declare function createFilterListNode(rules?: AnyRule[]): FilterList;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Utility functions for working with modifier nodes
|
|
2
|
+
* @file Utility functions for working with modifier nodes.
|
|
3
3
|
*/
|
|
4
4
|
import { type Modifier, type ModifierList } from '../nodes/index.js';
|
|
5
5
|
/**
|
|
6
|
-
* Creates a modifier node
|
|
6
|
+
* Creates a modifier node.
|
|
7
7
|
*
|
|
8
|
-
* @param name Name of the modifier
|
|
9
|
-
* @param value Value of the modifier
|
|
10
|
-
* @param exception Whether the modifier is an exception
|
|
11
|
-
*
|
|
8
|
+
* @param name Name of the modifier.
|
|
9
|
+
* @param value Value of the modifier.
|
|
10
|
+
* @param exception Whether the modifier is an exception.
|
|
11
|
+
*
|
|
12
|
+
* @returns Modifier node.
|
|
12
13
|
*/
|
|
13
14
|
export declare function createModifierNode(name: string, value?: string | undefined, exception?: boolean): Modifier;
|
|
14
15
|
/**
|
|
15
|
-
* Creates a modifier list node
|
|
16
|
+
* Creates a modifier list node.
|
|
17
|
+
*
|
|
18
|
+
* @param modifiers Modifiers to put in the list (optional, defaults to an empty list).
|
|
16
19
|
*
|
|
17
|
-
* @
|
|
18
|
-
* @returns Modifier list node
|
|
20
|
+
* @returns Modifier list node.
|
|
19
21
|
*/
|
|
20
22
|
export declare function createModifierListNode(modifiers?: Modifier[]): ModifierList;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Utility functions for working with network rule nodes
|
|
2
|
+
* @file Utility functions for working with network rule nodes.
|
|
3
3
|
*/
|
|
4
4
|
import { type ModifierList, type NetworkRule } from '../nodes/index.js';
|
|
5
5
|
import { AdblockSyntax } from '../utils/adblockers.js';
|
|
6
6
|
/**
|
|
7
|
-
* Creates a network rule node
|
|
7
|
+
* Creates a network rule node.
|
|
8
8
|
*
|
|
9
|
-
* @param pattern Rule pattern
|
|
10
|
-
* @param modifiers Rule modifiers (optional, default: undefined)
|
|
11
|
-
* @param exception Exception rule flag (optional, default: false)
|
|
12
|
-
* @param syntax Adblock syntax (optional, default: Common)
|
|
13
|
-
*
|
|
9
|
+
* @param pattern Rule pattern.
|
|
10
|
+
* @param modifiers Rule modifiers (optional, default: undefined).
|
|
11
|
+
* @param exception Exception rule flag (optional, default: false).
|
|
12
|
+
* @param syntax Adblock syntax (optional, default: Common).
|
|
13
|
+
*
|
|
14
|
+
* @returns Network rule node.
|
|
14
15
|
*/
|
|
15
16
|
export declare function createNetworkRuleNode(pattern: string, modifiers?: ModifierList | undefined, exception?: boolean, syntax?: AdblockSyntax): NetworkRule;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @file Utility functions for working with scriptlet nodes
|
|
2
|
+
* @file Utility functions for working with scriptlet nodes.
|
|
3
3
|
*/
|
|
4
4
|
import { type ParameterList } from '../nodes/index.js';
|
|
5
5
|
import { type QuoteType } from '../utils/quotes.js';
|
|
@@ -12,41 +12,43 @@ import { type QuoteType } from '../utils/quotes.js';
|
|
|
12
12
|
*/
|
|
13
13
|
type ParamTransformer = (param: string | null) => string | null;
|
|
14
14
|
/**
|
|
15
|
-
* Get name of the scriptlet from the scriptlet node
|
|
15
|
+
* Get name of the scriptlet from the scriptlet node.
|
|
16
16
|
*
|
|
17
|
-
* @param scriptletNode Scriptlet node to get name of
|
|
18
|
-
*
|
|
19
|
-
* @
|
|
17
|
+
* @param scriptletNode Scriptlet node to get name of.
|
|
18
|
+
*
|
|
19
|
+
* @returns Name of the scriptlet.
|
|
20
|
+
*
|
|
21
|
+
* @throws If the scriptlet is empty.
|
|
20
22
|
*/
|
|
21
23
|
export declare function getScriptletName(scriptletNode: ParameterList): string;
|
|
22
24
|
/**
|
|
23
|
-
* Transform the nth argument of the scriptlet node
|
|
25
|
+
* Transform the nth argument of the scriptlet node.
|
|
24
26
|
*
|
|
25
|
-
* @param scriptletNode Scriptlet node to transform argument of
|
|
26
|
-
* @param index Index of the argument to transform (index 0 is the scriptlet name)
|
|
27
|
-
* @param transform Function to transform the argument
|
|
27
|
+
* @param scriptletNode Scriptlet node to transform argument of.
|
|
28
|
+
* @param index Index of the argument to transform (index 0 is the scriptlet name).
|
|
29
|
+
* @param transform Function to transform the argument.
|
|
28
30
|
*/
|
|
29
31
|
export declare function transformNthScriptletArgument(scriptletNode: ParameterList, index: number, transform: ParamTransformer): void;
|
|
30
32
|
/**
|
|
31
|
-
* Transform all arguments of the scriptlet node
|
|
33
|
+
* Transform all arguments of the scriptlet node.
|
|
32
34
|
*
|
|
33
|
-
* @param scriptletNode Scriptlet node to transform arguments of
|
|
34
|
-
* @param transform Function to transform the arguments
|
|
35
|
+
* @param scriptletNode Scriptlet node to transform arguments of.
|
|
36
|
+
* @param transform Function to transform the arguments.
|
|
35
37
|
*/
|
|
36
38
|
export declare function transformAllScriptletArguments(scriptletNode: ParameterList, transform: ParamTransformer): void;
|
|
37
39
|
/**
|
|
38
40
|
* Set name of the scriptlet.
|
|
39
41
|
* Modifies input `scriptletNode` if needed.
|
|
40
42
|
*
|
|
41
|
-
* @param scriptletNode Scriptlet node to set name of
|
|
42
|
-
* @param name Name to set
|
|
43
|
+
* @param scriptletNode Scriptlet node to set name of.
|
|
44
|
+
* @param name Name to set.
|
|
43
45
|
*/
|
|
44
46
|
export declare function setScriptletName(scriptletNode: ParameterList, name: string): void;
|
|
45
47
|
/**
|
|
46
|
-
* Set quote type of the scriptlet parameters
|
|
48
|
+
* Set quote type of the scriptlet parameters.
|
|
47
49
|
*
|
|
48
|
-
* @param scriptletNode Scriptlet node to set quote type of
|
|
49
|
-
* @param quoteType Preferred quote type
|
|
50
|
+
* @param scriptletNode Scriptlet node to set quote type of.
|
|
51
|
+
* @param quoteType Preferred quote type.
|
|
50
52
|
*/
|
|
51
53
|
export declare function setScriptletQuoteType(scriptletNode: ParameterList, quoteType: QuoteType): void;
|
|
52
54
|
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Provides common compatibility table methods.
|
|
3
3
|
*/
|
|
4
|
-
import { type
|
|
4
|
+
import { type AdblockProduct } from '../utils/adblockers.js';
|
|
5
5
|
import { type AnyPlatform, type SpecificPlatform } from './platforms.js';
|
|
6
|
+
import { type BaseCompatibilityDataSchema } from './schemas/index.js';
|
|
6
7
|
import { type CompatibilityTable } from './types.js';
|
|
7
|
-
import { type AdblockProduct } from '../utils/adblockers.js';
|
|
8
8
|
/**
|
|
9
9
|
* Lists all supported entity records by a product.
|
|
10
10
|
*
|
|
@@ -78,18 +78,19 @@ export declare abstract class CompatibilityTableBase<T extends BaseCompatibility
|
|
|
78
78
|
* Helper method to get a 'row' from the compatibility table data by name.
|
|
79
79
|
*
|
|
80
80
|
* @param name Compatibility data name.
|
|
81
|
+
*
|
|
81
82
|
* @returns Compatibility table row storage or `null` if not found.
|
|
82
83
|
*/
|
|
83
84
|
private getRowStorage;
|
|
84
85
|
/**
|
|
85
86
|
* Checks whether a compatibility data `name` exists for any platform.
|
|
86
87
|
*
|
|
87
|
-
* @note Technically, do the same as `exists()` method with generic platform _any_
|
|
88
|
-
* but it is faster because it does not apply complex logic.
|
|
89
|
-
*
|
|
90
88
|
* @param name Compatibility data name.
|
|
91
89
|
*
|
|
92
90
|
* @returns True if the compatibility data exists, false otherwise.
|
|
91
|
+
*
|
|
92
|
+
* @note Technically, do the same as `exists()` method with generic platform _any_
|
|
93
|
+
* but it is faster because it does not apply complex logic.
|
|
93
94
|
*/
|
|
94
95
|
existsAny(name: string): boolean;
|
|
95
96
|
/**
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* @file Compatibility tables for redirects.
|
|
3
3
|
*/
|
|
4
4
|
import { CompatibilityTableBase } from './base.js';
|
|
5
|
+
import { type AnyPlatform } from './platforms.js';
|
|
5
6
|
import { type RedirectDataSchema } from './schemas/index.js';
|
|
6
7
|
import { type CompatibilityTable } from './types.js';
|
|
7
|
-
import { type AnyPlatform } from './platforms.js';
|
|
8
8
|
/**
|
|
9
9
|
* Compatibility table for redirects.
|
|
10
10
|
*/
|
|
@@ -28,6 +28,7 @@ export declare const parseRawPlatforms: (rawPlatforms: string) => AnyPlatform;
|
|
|
28
28
|
* @param bitmask Platform bitmask (can be specific, generic, or combined platforms).
|
|
29
29
|
*
|
|
30
30
|
* @returns Platform string, e.g. 'adg_safari_any|adg_os_any' or 'adg_os_windows|adg_ext_chrome'.
|
|
31
|
+
*
|
|
31
32
|
* @throws Error if the bitmask is 0 or contains unknown platforms.
|
|
32
33
|
*/
|
|
33
34
|
export declare const stringifyPlatforms: (bitmask: AnyPlatform) => string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Provides platform mapping and helper functions.
|
|
3
3
|
*/
|
|
4
|
-
import { type AnyPlatform, GenericPlatform, SpecificPlatform } from '../platforms.js';
|
|
5
4
|
import { AdblockProduct } from '../../utils/adblockers.js';
|
|
6
5
|
import { type ReadonlyRecord } from '../../utils/types.js';
|
|
6
|
+
import { type AnyPlatform, GenericPlatform, SpecificPlatform } from '../platforms.js';
|
|
7
7
|
/**
|
|
8
8
|
* Map of specific platforms string names to their corresponding enum values.
|
|
9
9
|
*/
|
|
@@ -55,7 +55,7 @@ export declare const hasPlatformMultipleProducts: (platform: AnyPlatform) => boo
|
|
|
55
55
|
* - Empty array `[]` if platform is 0 or no products are found
|
|
56
56
|
* - Array of specific products based on which products are present
|
|
57
57
|
* (e.g., `['AdGuard', 'UblockOrigin']` if both AdGuard and uBlock Origin are specified)
|
|
58
|
-
* - `['AdGuard', 'UblockOrigin', 'AdblockPlus']` for GenericPlatform.Any
|
|
58
|
+
* - `['AdGuard', 'UblockOrigin', 'AdblockPlus']` for GenericPlatform.Any.
|
|
59
59
|
*/
|
|
60
60
|
export declare const platformToAdblockProduct: (platform: AnyPlatform) => AdblockProduct[];
|
|
61
61
|
/**
|
|
@@ -76,7 +76,7 @@ export type PlatformsByProduct = Partial<Record<AdblockProduct, AnyPlatform[]>>;
|
|
|
76
76
|
* - Empty object `{}` if platform is 0 or no products are found
|
|
77
77
|
* - Object with single product key for single-product platforms
|
|
78
78
|
* - Object with multiple product keys for multi-product platforms
|
|
79
|
-
* - Each array contains the minimal representation using generic platforms where possible
|
|
79
|
+
* - Each array contains the minimal representation using generic platforms where possible.
|
|
80
80
|
*
|
|
81
81
|
* @example
|
|
82
82
|
* ```typescript
|
|
@@ -108,6 +108,7 @@ export declare const getPlatformsByProduct: (platform: AnyPlatform) => Platforms
|
|
|
108
108
|
* @param platform Platform string name, e.g., 'adg_os_windows'.
|
|
109
109
|
*
|
|
110
110
|
* @returns Specific or generic platform enum value.
|
|
111
|
+
*
|
|
111
112
|
* @throws Error if the platform is unknown.
|
|
112
113
|
*/
|
|
113
114
|
export declare const getPlatformId: (platform: string) => SpecificPlatform | GenericPlatform;
|
|
@@ -117,6 +118,7 @@ export declare const getPlatformId: (platform: string) => SpecificPlatform | Gen
|
|
|
117
118
|
* @param platform Specific platform enum value.
|
|
118
119
|
*
|
|
119
120
|
* @returns Specific platform string name, e.g., 'adg_os_windows'.
|
|
121
|
+
*
|
|
120
122
|
* @throws Error if the platform is unknown.
|
|
121
123
|
*/
|
|
122
124
|
export declare const getSpecificPlatformName: (platform: SpecificPlatform) => string;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @file Zod camelCase utility.
|
|
3
3
|
*/
|
|
4
|
-
import type zod from 'zod';
|
|
5
4
|
import { type CamelCasedPropertiesDeep } from 'type-fest';
|
|
5
|
+
import type zod from 'zod';
|
|
6
6
|
/**
|
|
7
7
|
* Transforms Zod schema to camelCase.
|
|
8
8
|
*
|
|
9
|
+
* @see {@link https://github.com/colinhacks/zod/issues/486#issuecomment-1501097361}
|
|
10
|
+
*
|
|
9
11
|
* @param zod Zod schema.
|
|
10
12
|
*
|
|
11
13
|
* @returns Zod schema with camelCase properties.
|
|
12
|
-
*
|
|
13
|
-
* @see {@link https://github.com/colinhacks/zod/issues/486#issuecomment-1501097361}
|
|
14
14
|
*/
|
|
15
15
|
export declare const zodToCamelCase: <T extends zod.ZodTypeAny>(zod: T) => zod.ZodEffects<zod.ZodTypeAny, CamelCasedPropertiesDeep<T["_output"]>>;
|