@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
package/dist/utils/string.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
|
|
@@ -17,14 +17,15 @@ const DOUBLE_QUOTE_MARKER = '"';
|
|
|
17
17
|
class StringUtils {
|
|
18
18
|
/**
|
|
19
19
|
* Finds the first occurrence of a character that:
|
|
20
|
-
* - isn't preceded by an escape character
|
|
20
|
+
* - isn't preceded by an escape character.
|
|
21
|
+
*
|
|
22
|
+
* @param pattern Source pattern.
|
|
23
|
+
* @param searchedCharacter Searched character.
|
|
24
|
+
* @param start Start index.
|
|
25
|
+
* @param escapeCharacter Escape character, \ by default.
|
|
26
|
+
* @param end End index (excluded).
|
|
21
27
|
*
|
|
22
|
-
* @
|
|
23
|
-
* @param searchedCharacter - Searched character
|
|
24
|
-
* @param start - Start index
|
|
25
|
-
* @param escapeCharacter - Escape character, \ by default
|
|
26
|
-
* @param end - End index (excluded)
|
|
27
|
-
* @returns Index or -1 if the character not found
|
|
28
|
+
* @returns Index or -1 if the character not found.
|
|
28
29
|
*/
|
|
29
30
|
static findNextUnescapedCharacter(pattern, searchedCharacter, start = 0, escapeCharacter = ESCAPE_CHARACTER, end = pattern.length) {
|
|
30
31
|
for (let i = start; i < end; i += 1) {
|
|
@@ -38,12 +39,13 @@ class StringUtils {
|
|
|
38
39
|
/**
|
|
39
40
|
* Finds the first occurrence in backward direction of a character that isn't preceded by an escape character.
|
|
40
41
|
*
|
|
41
|
-
* @param pattern
|
|
42
|
-
* @param searchedCharacter
|
|
43
|
-
* @param start
|
|
44
|
-
* @param escapeCharacter
|
|
45
|
-
* @param end
|
|
46
|
-
*
|
|
42
|
+
* @param pattern Source pattern.
|
|
43
|
+
* @param searchedCharacter Searched character.
|
|
44
|
+
* @param start Start index.
|
|
45
|
+
* @param escapeCharacter Escape character, \ by default.
|
|
46
|
+
* @param end End index (Included).
|
|
47
|
+
*
|
|
48
|
+
* @returns Index or -1 if the character not found.
|
|
47
49
|
*/
|
|
48
50
|
static findNextUnescapedCharacterBackwards(pattern, searchedCharacter, start = pattern.length - 1, escapeCharacter = ESCAPE_CHARACTER, end = 0) {
|
|
49
51
|
for (let i = start; i >= end; i -= 1) {
|
|
@@ -56,12 +58,13 @@ class StringUtils {
|
|
|
56
58
|
}
|
|
57
59
|
/**
|
|
58
60
|
* Finds the last occurrence of a character that:
|
|
59
|
-
* - isn't preceded by an escape character
|
|
61
|
+
* - isn't preceded by an escape character.
|
|
60
62
|
*
|
|
61
|
-
* @param pattern
|
|
62
|
-
* @param searchedCharacter
|
|
63
|
-
* @param escapeCharacter
|
|
64
|
-
*
|
|
63
|
+
* @param pattern Source pattern.
|
|
64
|
+
* @param searchedCharacter Searched character.
|
|
65
|
+
* @param escapeCharacter Escape character, \ by default.
|
|
66
|
+
*
|
|
67
|
+
* @returns Index or -1 if the character not found.
|
|
65
68
|
*/
|
|
66
69
|
static findLastUnescapedCharacter(pattern, searchedCharacter, escapeCharacter = ESCAPE_CHARACTER) {
|
|
67
70
|
for (let i = pattern.length - 1; i >= 0; i -= 1) {
|
|
@@ -75,14 +78,15 @@ class StringUtils {
|
|
|
75
78
|
/**
|
|
76
79
|
* Finds the next occurrence of a character that:
|
|
77
80
|
* - isn't preceded by an escape character
|
|
78
|
-
* - isn't followed by the specified character
|
|
79
|
-
*
|
|
80
|
-
* @param pattern
|
|
81
|
-
* @param start
|
|
82
|
-
* @param searchedCharacter
|
|
83
|
-
* @param notFollowedBy
|
|
84
|
-
* @param escapeCharacter
|
|
85
|
-
*
|
|
81
|
+
* - isn't followed by the specified character.
|
|
82
|
+
*
|
|
83
|
+
* @param pattern Source pattern.
|
|
84
|
+
* @param start Start index.
|
|
85
|
+
* @param searchedCharacter Searched character.
|
|
86
|
+
* @param notFollowedBy Searched character not followed by this character.
|
|
87
|
+
* @param escapeCharacter Escape character, \ by default.
|
|
88
|
+
*
|
|
89
|
+
* @returns Index or -1 if the character not found.
|
|
86
90
|
*/
|
|
87
91
|
static findNextUnescapedCharacterThatNotFollowedBy(pattern, start, searchedCharacter, notFollowedBy, escapeCharacter = ESCAPE_CHARACTER) {
|
|
88
92
|
for (let i = start; i < pattern.length; i += 1) {
|
|
@@ -98,13 +102,14 @@ class StringUtils {
|
|
|
98
102
|
/**
|
|
99
103
|
* Finds the last occurrence of a character that:
|
|
100
104
|
* - isn't preceded by an escape character
|
|
101
|
-
* - isn't followed by the specified character
|
|
105
|
+
* - isn't followed by the specified character.
|
|
106
|
+
*
|
|
107
|
+
* @param pattern Source pattern.
|
|
108
|
+
* @param searchedCharacter Searched character.
|
|
109
|
+
* @param notFollowedBy Searched character not followed by this character.
|
|
110
|
+
* @param escapeCharacter Escape character, \ by default.
|
|
102
111
|
*
|
|
103
|
-
* @
|
|
104
|
-
* @param searchedCharacter - Searched character
|
|
105
|
-
* @param notFollowedBy - Searched character not followed by this character
|
|
106
|
-
* @param escapeCharacter - Escape character, \ by default
|
|
107
|
-
* @returns Index or -1 if the character not found
|
|
112
|
+
* @returns Index or -1 if the character not found.
|
|
108
113
|
*/
|
|
109
114
|
static findLastUnescapedCharacterThatNotFollowedBy(pattern, searchedCharacter, notFollowedBy, escapeCharacter = ESCAPE_CHARACTER) {
|
|
110
115
|
for (let i = pattern.length - 1; i >= 0; i -= 1) {
|
|
@@ -120,12 +125,13 @@ class StringUtils {
|
|
|
120
125
|
/**
|
|
121
126
|
* Finds the next occurrence of a character that:
|
|
122
127
|
* - isn't part of any string literal ('literal' or "literal")
|
|
123
|
-
* - isn't part of any RegExp expression (/regexp/)
|
|
128
|
+
* - isn't part of any RegExp expression (/regexp/).
|
|
129
|
+
*
|
|
130
|
+
* @param pattern Source pattern.
|
|
131
|
+
* @param searchedCharacter Searched character.
|
|
132
|
+
* @param start Start index.
|
|
124
133
|
*
|
|
125
|
-
* @
|
|
126
|
-
* @param searchedCharacter - Searched character
|
|
127
|
-
* @param start - Start index
|
|
128
|
-
* @returns Index or -1 if the character not found
|
|
134
|
+
* @returns Index or -1 if the character not found.
|
|
129
135
|
*/
|
|
130
136
|
static findUnescapedNonStringNonRegexChar(pattern, searchedCharacter, start = 0) {
|
|
131
137
|
let open = null;
|
|
@@ -190,13 +196,14 @@ class StringUtils {
|
|
|
190
196
|
/**
|
|
191
197
|
* Finds the next occurrence of a character that:
|
|
192
198
|
* - isn't part of any string literal ('literal' or "literal")
|
|
193
|
-
* - isn't preceded by an escape character
|
|
199
|
+
* - isn't preceded by an escape character.
|
|
200
|
+
*
|
|
201
|
+
* @param pattern Source pattern.
|
|
202
|
+
* @param searchedCharacter Searched character.
|
|
203
|
+
* @param start Start index.
|
|
204
|
+
* @param escapeCharacter Escape character, \ by default.
|
|
194
205
|
*
|
|
195
|
-
* @
|
|
196
|
-
* @param searchedCharacter - Searched character
|
|
197
|
-
* @param start - Start index
|
|
198
|
-
* @param escapeCharacter - Escape character, \ by default
|
|
199
|
-
* @returns Index or -1 if the character not found
|
|
206
|
+
* @returns Index or -1 if the character not found.
|
|
200
207
|
*/
|
|
201
208
|
static findNextUnquotedUnescapedCharacter(pattern, searchedCharacter, start = 0, escapeCharacter = ESCAPE_CHARACTER) {
|
|
202
209
|
let openQuote = null;
|
|
@@ -221,16 +228,18 @@ class StringUtils {
|
|
|
221
228
|
/**
|
|
222
229
|
* Finds the next occurrence of a character that:
|
|
223
230
|
* - isn't "bracketed"
|
|
224
|
-
* - isn't preceded by an escape character
|
|
231
|
+
* - isn't preceded by an escape character.
|
|
232
|
+
*
|
|
233
|
+
* @param pattern Source pattern.
|
|
234
|
+
* @param searchedCharacter Searched character.
|
|
235
|
+
* @param start Start index.
|
|
236
|
+
* @param escapeCharacter Escape character, \ by default.
|
|
237
|
+
* @param openBracket Open bracket, ( by default.
|
|
238
|
+
* @param closeBracket Close bracket, ( by default.
|
|
225
239
|
*
|
|
226
|
-
* @
|
|
227
|
-
*
|
|
228
|
-
* @
|
|
229
|
-
* @param escapeCharacter - Escape character, \ by default
|
|
230
|
-
* @param openBracket - Open bracket, ( by default
|
|
231
|
-
* @param closeBracket - Close bracket, ( by default
|
|
232
|
-
* @throws If the opening and closing brackets are the same
|
|
233
|
-
* @returns Index or -1 if the character not found
|
|
240
|
+
* @returns Index or -1 if the character not found.
|
|
241
|
+
*
|
|
242
|
+
* @throws If the opening and closing brackets are the same.
|
|
234
243
|
*/
|
|
235
244
|
static findNextNotBracketedUnescapedCharacter(pattern, searchedCharacter, start = 0, escapeCharacter = ESCAPE_CHARACTER, openBracket = '(', closeBracket = ')') {
|
|
236
245
|
if (openBracket === closeBracket) {
|
|
@@ -253,11 +262,12 @@ class StringUtils {
|
|
|
253
262
|
/**
|
|
254
263
|
* Splits the source pattern along characters that:
|
|
255
264
|
* - isn't part of any string literal ('literal' or "literal")
|
|
256
|
-
* - isn't preceded by an escape character
|
|
265
|
+
* - isn't preceded by an escape character.
|
|
257
266
|
*
|
|
258
|
-
* @param pattern
|
|
259
|
-
* @param delimeterCharacter
|
|
260
|
-
*
|
|
267
|
+
* @param pattern Source pattern.
|
|
268
|
+
* @param delimeterCharacter Delimeter character.
|
|
269
|
+
*
|
|
270
|
+
* @returns Splitted string.
|
|
261
271
|
*/
|
|
262
272
|
static splitStringByUnquotedUnescapedCharacter(pattern, delimeterCharacter) {
|
|
263
273
|
const parts = [];
|
|
@@ -278,11 +288,12 @@ class StringUtils {
|
|
|
278
288
|
* Splits the source pattern along characters that:
|
|
279
289
|
* - isn't part of any string literal ('literal' or "literal")
|
|
280
290
|
* - isn't part of any RegExp expression (/regexp/)
|
|
281
|
-
* - isn't preceded by an escape character
|
|
291
|
+
* - isn't preceded by an escape character.
|
|
292
|
+
*
|
|
293
|
+
* @param pattern Source pattern.
|
|
294
|
+
* @param delimeterCharacter Delimeter character.
|
|
282
295
|
*
|
|
283
|
-
* @
|
|
284
|
-
* @param delimeterCharacter - Delimeter character
|
|
285
|
-
* @returns Splitted string
|
|
296
|
+
* @returns Splitted string.
|
|
286
297
|
*/
|
|
287
298
|
static splitStringByUnescapedNonStringNonRegexChar(pattern, delimeterCharacter) {
|
|
288
299
|
const parts = [];
|
|
@@ -301,11 +312,12 @@ class StringUtils {
|
|
|
301
312
|
}
|
|
302
313
|
/**
|
|
303
314
|
* Splits the source pattern along characters that:
|
|
304
|
-
* - isn't preceded by an escape character
|
|
315
|
+
* - isn't preceded by an escape character.
|
|
316
|
+
*
|
|
317
|
+
* @param pattern Source pattern.
|
|
318
|
+
* @param delimeterCharacter Delimeter character.
|
|
305
319
|
*
|
|
306
|
-
* @
|
|
307
|
-
* @param delimeterCharacter - Delimeter character
|
|
308
|
-
* @returns Splitted string
|
|
320
|
+
* @returns Splitted string.
|
|
309
321
|
*/
|
|
310
322
|
static splitStringByUnescapedCharacter(pattern, delimeterCharacter) {
|
|
311
323
|
const parts = [];
|
|
@@ -325,8 +337,9 @@ class StringUtils {
|
|
|
325
337
|
/**
|
|
326
338
|
* Determines whether the given character is a space or tab character.
|
|
327
339
|
*
|
|
328
|
-
* @param char
|
|
329
|
-
*
|
|
340
|
+
* @param char The character to check.
|
|
341
|
+
*
|
|
342
|
+
* @returns True if the given character is a space or tab character, false otherwise.
|
|
330
343
|
*/
|
|
331
344
|
static isWhitespace(char) {
|
|
332
345
|
return char === SPACE || char === TAB;
|
|
@@ -335,6 +348,7 @@ class StringUtils {
|
|
|
335
348
|
* Checks if the given character is a digit.
|
|
336
349
|
*
|
|
337
350
|
* @param char The character to check.
|
|
351
|
+
*
|
|
338
352
|
* @returns `true` if the given character is a digit, `false` otherwise.
|
|
339
353
|
*/
|
|
340
354
|
static isDigit(char) {
|
|
@@ -344,6 +358,7 @@ class StringUtils {
|
|
|
344
358
|
* Checks if the given character is a small letter.
|
|
345
359
|
*
|
|
346
360
|
* @param char The character to check.
|
|
361
|
+
*
|
|
347
362
|
* @returns `true` if the given character is a small letter, `false` otherwise.
|
|
348
363
|
*/
|
|
349
364
|
static isSmallLetter(char) {
|
|
@@ -353,6 +368,7 @@ class StringUtils {
|
|
|
353
368
|
* Checks if the given character is a capital letter.
|
|
354
369
|
*
|
|
355
370
|
* @param char The character to check.
|
|
371
|
+
*
|
|
356
372
|
* @returns `true` if the given character is a capital letter, `false` otherwise.
|
|
357
373
|
*/
|
|
358
374
|
static isCapitalLetter(char) {
|
|
@@ -362,6 +378,7 @@ class StringUtils {
|
|
|
362
378
|
* Checks if the given character is a letter (small or capital).
|
|
363
379
|
*
|
|
364
380
|
* @param char The character to check.
|
|
381
|
+
*
|
|
365
382
|
* @returns `true` if the given character is a letter, `false` otherwise.
|
|
366
383
|
*/
|
|
367
384
|
static isLetter(char) {
|
|
@@ -370,7 +387,8 @@ class StringUtils {
|
|
|
370
387
|
/**
|
|
371
388
|
* Checks if the given character is a letter or a digit.
|
|
372
389
|
*
|
|
373
|
-
* @param char Character to check
|
|
390
|
+
* @param char Character to check.
|
|
391
|
+
*
|
|
374
392
|
* @returns `true` if the given character is a letter or a digit, `false` otherwise.
|
|
375
393
|
*/
|
|
376
394
|
static isAlphaNumeric(char) {
|
|
@@ -379,9 +397,10 @@ class StringUtils {
|
|
|
379
397
|
/**
|
|
380
398
|
* Searches for the first non-whitespace character in the source pattern.
|
|
381
399
|
*
|
|
382
|
-
* @param pattern
|
|
383
|
-
* @param start
|
|
384
|
-
*
|
|
400
|
+
* @param pattern Source pattern.
|
|
401
|
+
* @param start Start index.
|
|
402
|
+
*
|
|
403
|
+
* @returns Index or -1 if the character not found.
|
|
385
404
|
*/
|
|
386
405
|
static findFirstNonWhitespaceCharacter(pattern, start = 0) {
|
|
387
406
|
for (let i = start; i < pattern.length; i += 1) {
|
|
@@ -394,8 +413,9 @@ class StringUtils {
|
|
|
394
413
|
/**
|
|
395
414
|
* Searches for the last non-whitespace character in the source pattern.
|
|
396
415
|
*
|
|
397
|
-
* @param pattern
|
|
398
|
-
*
|
|
416
|
+
* @param pattern Source pattern.
|
|
417
|
+
*
|
|
418
|
+
* @returns Index or -1 if the character not found.
|
|
399
419
|
*/
|
|
400
420
|
static findLastNonWhitespaceCharacter(pattern) {
|
|
401
421
|
for (let i = pattern.length - 1; i >= 0; i -= 1) {
|
|
@@ -408,9 +428,10 @@ class StringUtils {
|
|
|
408
428
|
/**
|
|
409
429
|
* Finds the next whitespace character in the pattern.
|
|
410
430
|
*
|
|
411
|
-
* @param pattern Pattern to search in
|
|
412
|
-
* @param start Start index
|
|
413
|
-
*
|
|
431
|
+
* @param pattern Pattern to search in.
|
|
432
|
+
* @param start Start index.
|
|
433
|
+
*
|
|
434
|
+
* @returns Index of the next whitespace character or the length of the pattern if not found.
|
|
414
435
|
*/
|
|
415
436
|
static findNextWhitespaceCharacter(pattern, start = 0) {
|
|
416
437
|
for (let i = start; i < pattern.length; i += 1) {
|
|
@@ -423,10 +444,11 @@ class StringUtils {
|
|
|
423
444
|
/**
|
|
424
445
|
* Escapes a specified character in the string.
|
|
425
446
|
*
|
|
426
|
-
* @param pattern
|
|
427
|
-
* @param character
|
|
428
|
-
* @param escapeCharacter
|
|
429
|
-
*
|
|
447
|
+
* @param pattern Input string.
|
|
448
|
+
* @param character Character to escape.
|
|
449
|
+
* @param escapeCharacter Escape character (optional).
|
|
450
|
+
*
|
|
451
|
+
* @returns Escaped string.
|
|
430
452
|
*/
|
|
431
453
|
static escapeCharacter(pattern, character, escapeCharacter = ESCAPE_CHARACTER) {
|
|
432
454
|
let result = EMPTY;
|
|
@@ -441,9 +463,10 @@ class StringUtils {
|
|
|
441
463
|
/**
|
|
442
464
|
* Searches for the next non-whitespace character in the source pattern.
|
|
443
465
|
*
|
|
444
|
-
* @param pattern Pattern to search
|
|
445
|
-
* @param start Start index
|
|
446
|
-
*
|
|
466
|
+
* @param pattern Pattern to search.
|
|
467
|
+
* @param start Start index.
|
|
468
|
+
*
|
|
469
|
+
* @returns Index of the next non-whitespace character or the length of the pattern.
|
|
447
470
|
*/
|
|
448
471
|
static skipWS(pattern, start = 0) {
|
|
449
472
|
let i = start;
|
|
@@ -455,9 +478,10 @@ class StringUtils {
|
|
|
455
478
|
/**
|
|
456
479
|
* Searches for the previous non-whitespace character in the source pattern.
|
|
457
480
|
*
|
|
458
|
-
* @param pattern Pattern to search
|
|
459
|
-
* @param start Start index
|
|
460
|
-
*
|
|
481
|
+
* @param pattern Pattern to search.
|
|
482
|
+
* @param start Start index.
|
|
483
|
+
*
|
|
484
|
+
* @returns Index of the previous non-whitespace character or -1.
|
|
461
485
|
*/
|
|
462
486
|
static skipWSBack(pattern, start = pattern.length - 1) {
|
|
463
487
|
let i = start;
|
|
@@ -469,7 +493,8 @@ class StringUtils {
|
|
|
469
493
|
/**
|
|
470
494
|
* Checks if the given character is a new line character.
|
|
471
495
|
*
|
|
472
|
-
* @param char Character to check
|
|
496
|
+
* @param char Character to check.
|
|
497
|
+
*
|
|
473
498
|
* @returns `true` if the given character is a new line character, `false` otherwise.
|
|
474
499
|
*/
|
|
475
500
|
static isEOL(char) {
|
|
@@ -478,18 +503,20 @@ class StringUtils {
|
|
|
478
503
|
/**
|
|
479
504
|
* Splits a string along newline characters.
|
|
480
505
|
*
|
|
481
|
-
* @param input
|
|
482
|
-
*
|
|
506
|
+
* @param input Input string.
|
|
507
|
+
*
|
|
508
|
+
* @returns Splitted string.
|
|
483
509
|
*/
|
|
484
510
|
static splitStringByNewLines(input) {
|
|
485
511
|
return input.split(/\r?\n/);
|
|
486
512
|
}
|
|
487
513
|
/**
|
|
488
|
-
* Splits a string by new lines and stores the new line type for each line
|
|
514
|
+
* Splits a string by new lines and stores the new line type for each line.
|
|
515
|
+
*
|
|
516
|
+
* @param input The input string to be split.
|
|
489
517
|
*
|
|
490
|
-
* @param input The input string to be split
|
|
491
518
|
* @returns An array of tuples, where each tuple contains a line of the input string and its
|
|
492
|
-
* corresponding new line type ("lf", "crlf", or "cr")
|
|
519
|
+
* corresponding new line type ("lf", "crlf", or "cr").
|
|
493
520
|
*/
|
|
494
521
|
static splitStringByNewLinesEx(input) {
|
|
495
522
|
// Array to store the tuples of line and new line type
|
|
@@ -527,10 +554,11 @@ class StringUtils {
|
|
|
527
554
|
return result;
|
|
528
555
|
}
|
|
529
556
|
/**
|
|
530
|
-
* Merges an array of tuples (line, newLineType) into a single string
|
|
557
|
+
* Merges an array of tuples (line, newLineType) into a single string.
|
|
531
558
|
*
|
|
532
|
-
* @param input The array of tuples to be merged
|
|
533
|
-
*
|
|
559
|
+
* @param input The array of tuples to be merged.
|
|
560
|
+
*
|
|
561
|
+
* @returns A single string containing the lines and new line characters from the input array.
|
|
534
562
|
*/
|
|
535
563
|
static mergeStringByNewLines(input) {
|
|
536
564
|
let result = EMPTY;
|
|
@@ -555,11 +583,13 @@ class StringUtils {
|
|
|
555
583
|
return result;
|
|
556
584
|
}
|
|
557
585
|
/**
|
|
558
|
-
* Helper method to parse a raw string as a number
|
|
586
|
+
* Helper method to parse a raw string as a number.
|
|
587
|
+
*
|
|
588
|
+
* @param raw Raw string to parse.
|
|
559
589
|
*
|
|
560
|
-
* @
|
|
561
|
-
*
|
|
562
|
-
* @throws If the raw string can't be parsed as a number
|
|
590
|
+
* @returns Parsed number.
|
|
591
|
+
*
|
|
592
|
+
* @throws If the raw string can't be parsed as a number.
|
|
563
593
|
*/
|
|
564
594
|
static parseNumber(raw) {
|
|
565
595
|
const result = parseInt(raw, 10);
|
|
@@ -571,8 +601,9 @@ class StringUtils {
|
|
|
571
601
|
/**
|
|
572
602
|
* Checks if the given value is a string.
|
|
573
603
|
*
|
|
574
|
-
* @param value Value to check
|
|
575
|
-
*
|
|
604
|
+
* @param value Value to check.
|
|
605
|
+
*
|
|
606
|
+
* @returns `true` if the value is a string, `false` otherwise.
|
|
576
607
|
*/
|
|
577
608
|
static isString(value) {
|
|
578
609
|
return typeof value === 'string';
|
|
@@ -580,9 +611,10 @@ class StringUtils {
|
|
|
580
611
|
/**
|
|
581
612
|
* Escapes the given characters in the input string.
|
|
582
613
|
*
|
|
583
|
-
* @param input Input string
|
|
584
|
-
* @param characters Characters to escape (by default, no characters are escaped)
|
|
585
|
-
*
|
|
614
|
+
* @param input Input string.
|
|
615
|
+
* @param characters Characters to escape (by default, no characters are escaped).
|
|
616
|
+
*
|
|
617
|
+
* @returns Escaped string.
|
|
586
618
|
*/
|
|
587
619
|
static escapeCharacters(input, characters = new Set()) {
|
|
588
620
|
let result = EMPTY;
|
|
@@ -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
|
|
@@ -28,6 +28,7 @@ const isNull = (value) => {
|
|
|
28
28
|
* Checks whether the given value is a string.
|
|
29
29
|
*
|
|
30
30
|
* @param value Value to check.
|
|
31
|
+
*
|
|
31
32
|
* @returns `true` if the value is a string, `false` otherwise.
|
|
32
33
|
*/
|
|
33
34
|
const isString = (value) => {
|
|
@@ -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,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
|
package/dist/validator/index.js
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
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
7
|
import { sprintf } from 'sprintf-js';
|
|
8
|
-
import { UNDERSCORE, NEWLINE, SPACE } from '../utils/constants.js';
|
|
9
|
-
import { VALIDATION_ERROR_PREFIX, SOURCE_DATA_ERROR_PREFIX } from './constants.js';
|
|
10
|
-
import { getInvalidValidationResult, getValueRequiredValidationResult } from './helpers.js';
|
|
11
|
-
import { validateValue } from './value.js';
|
|
12
8
|
import { modifiersCompatibilityTable } from '../compatibility-tables/modifiers.js';
|
|
13
9
|
import '../compatibility-tables/redirects.js';
|
|
14
10
|
import '../compatibility-tables/scriptlets.js';
|
|
@@ -21,7 +17,11 @@ import '../compatibility-tables/schemas/platform.js';
|
|
|
21
17
|
import { hasPlatformMultipleProducts, getHumanReadablePlatformName, isGenericPlatform } from '../compatibility-tables/utils/platform-helpers.js';
|
|
22
18
|
import '../compatibility-tables/schemas/resource-type.js';
|
|
23
19
|
import '../compatibility-tables/utils/resource-type-helpers.js';
|
|
20
|
+
import { UNDERSCORE, NEWLINE, SPACE } from '../utils/constants.js';
|
|
24
21
|
import { isValidNoopModifier } from '../utils/noop-modifier.js';
|
|
22
|
+
import { VALIDATION_ERROR_PREFIX, SOURCE_DATA_ERROR_PREFIX } from './constants.js';
|
|
23
|
+
import { getInvalidValidationResult, getValueRequiredValidationResult } from './helpers.js';
|
|
24
|
+
import { validateValue } from './value.js';
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
* @file Validator for modifiers.
|
|
@@ -104,7 +104,7 @@ const validateForSpecificProduct = (platform, modifier, isException) => {
|
|
|
104
104
|
* TODO: consider to return `{ valid: true, warn: 'Modifier value may be specified' }` (???)
|
|
105
105
|
* for $stealth modifier without a value
|
|
106
106
|
* but only after the extension will support value for $stealth:
|
|
107
|
-
* https://github.com/AdguardTeam/AdguardBrowserExtension/issues/2107
|
|
107
|
+
* https://github.com/AdguardTeam/AdguardBrowserExtension/issues/2107.
|
|
108
108
|
*/
|
|
109
109
|
if (!specificBlockerData.valueFormat) {
|
|
110
110
|
throw new Error(`${SOURCE_DATA_ERROR_PREFIX.NO_VALUE_FORMAT_FOR_ASSIGNABLE}: '${modifierName}'`);
|
|
@@ -145,10 +145,10 @@ class ModifierValidator {
|
|
|
145
145
|
* @param isException Whether the modifier is used in exception rule, default to false.
|
|
146
146
|
* Needed to check whether the modifier is allowed only in blocking or exception rules.
|
|
147
147
|
*
|
|
148
|
+
* @returns Result of modifier validation.
|
|
149
|
+
*
|
|
148
150
|
* @note For single product: specific platforms use exact lookup, generic platforms use first match.
|
|
149
151
|
* If multiple products are specified (e.g., AdgAny | UboAny), validation is skipped and returns valid.
|
|
150
|
-
*
|
|
151
|
-
* @returns Result of modifier validation.
|
|
152
152
|
*/
|
|
153
153
|
validate = (platforms, modifier, isException = false) => {
|
|
154
154
|
// special case: handle noop modifier which may be used as multiple underscores (not just one)
|
package/dist/validator/value.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
|
|
@@ -9,13 +9,13 @@ import { AppListParser } from '../parser/misc/app-list-parser.js';
|
|
|
9
9
|
import { DomainListParser } from '../parser/misc/domain-list-parser.js';
|
|
10
10
|
import { MethodListParser } from '../parser/misc/method-list-parser.js';
|
|
11
11
|
import { StealthOptionListParser } from '../parser/misc/stealth-option-list-parser.js';
|
|
12
|
+
import { defaultParserOptions } from '../parser/options.js';
|
|
13
|
+
import { BACKSLASH, COMMA, SEMICOLON, SPACE, PIPE, EQUALS, WILDCARD, OPEN_PARENTHESIS, CLOSE_PARENTHESIS, DOT } from '../utils/constants.js';
|
|
12
14
|
import { DomainUtils } from '../utils/domain.js';
|
|
13
15
|
import { QuoteUtils, QuoteType } from '../utils/quotes.js';
|
|
14
|
-
import { BACKSLASH, COMMA, SEMICOLON, SPACE, PIPE, EQUALS, WILDCARD, OPEN_PARENTHESIS, CLOSE_PARENTHESIS, DOT } from '../utils/constants.js';
|
|
15
|
-
import { getValueRequiredValidationResult, getInvalidValidationResult } from './helpers.js';
|
|
16
|
-
import { SOURCE_DATA_ERROR_PREFIX, VALIDATION_ERROR_PREFIX, REFERRER_POLICY_DIRECTIVES, ALLOWED_CSP_DIRECTIVES, ALLOWED_PERMISSION_DIRECTIVES, EMPTY_PERMISSIONS_ALLOWLIST, PERMISSIONS_TOKEN_SELF, ALLOWED_METHODS, ALLOWED_STEALTH_OPTIONS, APP_NAME_ALLOWED_CHARS } from './constants.js';
|
|
17
|
-
import { defaultParserOptions } from '../parser/options.js';
|
|
18
16
|
import { isString } from '../utils/type-guards.js';
|
|
17
|
+
import { SOURCE_DATA_ERROR_PREFIX, VALIDATION_ERROR_PREFIX, REFERRER_POLICY_DIRECTIVES, ALLOWED_CSP_DIRECTIVES, ALLOWED_PERMISSION_DIRECTIVES, EMPTY_PERMISSIONS_ALLOWLIST, PERMISSIONS_TOKEN_SELF, ALLOWED_METHODS, ALLOWED_STEALTH_OPTIONS, APP_NAME_ALLOWED_CHARS } from './constants.js';
|
|
18
|
+
import { getValueRequiredValidationResult, getInvalidValidationResult } from './helpers.js';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Pre-defined available validators for modifiers with custom `value_format`.
|
|
@@ -382,7 +382,7 @@ const validatePermissionAllowlistOrigins = (allowlistChunks, directive, modifier
|
|
|
382
382
|
continue;
|
|
383
383
|
}
|
|
384
384
|
/**
|
|
385
|
-
* 'self' should be checked case-insensitively
|
|
385
|
+
* 'self' should be checked case-insensitively.
|
|
386
386
|
*
|
|
387
387
|
* @see {@link https://w3c.github.io/webappsec-permissions-policy/#algo-parse-policy-directive}
|
|
388
388
|
*
|
package/dist/version.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
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { version } from './package.json.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @file AGTree version
|
|
10
|
+
* @file AGTree version.
|
|
11
11
|
*/
|
|
12
12
|
// ! Notice:
|
|
13
13
|
// Don't export version from package.json directly, because if you run
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adguard/agtree",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Tool set for working with adblock filter lists",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"adblock",
|
|
@@ -90,9 +90,11 @@
|
|
|
90
90
|
"eslint": "8.57.1",
|
|
91
91
|
"eslint-config-airbnb-base": "15.0.0",
|
|
92
92
|
"eslint-config-airbnb-typescript": "^18.0.0",
|
|
93
|
+
"eslint-plugin-boundaries": "^5.0.1",
|
|
93
94
|
"eslint-plugin-import": "^2.29.0",
|
|
94
95
|
"eslint-plugin-import-newlines": "1.4.0",
|
|
95
96
|
"eslint-plugin-jsdoc": "^48.11.0",
|
|
97
|
+
"eslint-plugin-n": "^17.21.3",
|
|
96
98
|
"fs-extra": "^11.2.0",
|
|
97
99
|
"javascript-stringify": "^2.1.0",
|
|
98
100
|
"js-yaml": "^4.1.0",
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* AGTree v4.0.0 (build date: Wed, 21 Jan 2026 17:25:36 GMT)
|
|
3
|
-
* (c) 2026 Adguard Software Ltd.
|
|
4
|
-
* Released under the MIT license
|
|
5
|
-
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* @file Customized error for binary schema mismatch.
|
|
9
|
-
*/
|
|
10
|
-
const ERROR_NAME = 'BinarySchemaMismatchError';
|
|
11
|
-
/**
|
|
12
|
-
* Customized error for binary schema mismatch.
|
|
13
|
-
*/
|
|
14
|
-
class BinarySchemaMismatchError extends Error {
|
|
15
|
-
/**
|
|
16
|
-
* Expected schema version.
|
|
17
|
-
*/
|
|
18
|
-
expectedVersion;
|
|
19
|
-
/**
|
|
20
|
-
* Actual schema version.
|
|
21
|
-
*/
|
|
22
|
-
actualVersion;
|
|
23
|
-
/**
|
|
24
|
-
* Constructs a new `BinarySchemaMismatchError` instance.
|
|
25
|
-
*
|
|
26
|
-
* @param expectedVersion Expected schema version.
|
|
27
|
-
* @param actualVersion Actual schema version.
|
|
28
|
-
*/
|
|
29
|
-
constructor(expectedVersion, actualVersion) {
|
|
30
|
-
super(`Expected schema version ${expectedVersion}, but got ${actualVersion}`);
|
|
31
|
-
this.name = ERROR_NAME;
|
|
32
|
-
this.expectedVersion = expectedVersion;
|
|
33
|
-
this.actualVersion = actualVersion;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export { BinarySchemaMismatchError };
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Customized error for binary schema mismatch.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Customized error for binary schema mismatch.
|
|
6
|
-
*/
|
|
7
|
-
export declare class BinarySchemaMismatchError extends Error {
|
|
8
|
-
/**
|
|
9
|
-
* Expected schema version.
|
|
10
|
-
*/
|
|
11
|
-
expectedVersion: number;
|
|
12
|
-
/**
|
|
13
|
-
* Actual schema version.
|
|
14
|
-
*/
|
|
15
|
-
actualVersion: number;
|
|
16
|
-
/**
|
|
17
|
-
* Constructs a new `BinarySchemaMismatchError` instance.
|
|
18
|
-
*
|
|
19
|
-
* @param expectedVersion Expected schema version.
|
|
20
|
-
* @param actualVersion Actual schema version.
|
|
21
|
-
*/
|
|
22
|
-
constructor(expectedVersion: number, actualVersion: number);
|
|
23
|
-
}
|