@adguard/agtree 4.0.1 → 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
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
* Simple deep freeze implementation.
|
|
9
9
|
* It freezes the object and all its properties recursively.
|
|
10
10
|
*
|
|
11
|
-
* @param object Object to freeze.
|
|
12
|
-
*
|
|
13
|
-
* @returns Frozen object.
|
|
14
|
-
*
|
|
15
11
|
* @template T Type of the object to freeze.
|
|
16
12
|
*
|
|
17
13
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze#deep_freezing}
|
|
14
|
+
*
|
|
15
|
+
* @param object Object to freeze.
|
|
16
|
+
*
|
|
17
|
+
* @returns Frozen object.
|
|
18
18
|
*/
|
|
19
19
|
const deepFreeze = (object) => {
|
|
20
20
|
// Retrieve the property names defined on object
|
package/dist/utils/domain.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
|
|
@@ -31,8 +31,9 @@ class DomainUtils {
|
|
|
31
31
|
/**
|
|
32
32
|
* Check if the input is a valid domain or hostname.
|
|
33
33
|
*
|
|
34
|
-
* @param domain Domain to check
|
|
35
|
-
*
|
|
34
|
+
* @param domain Domain to check.
|
|
35
|
+
*
|
|
36
|
+
* @returns `true` if the domain is valid, `false` otherwise.
|
|
36
37
|
*/
|
|
37
38
|
static isValidDomainOrHostname(domain) {
|
|
38
39
|
let domainToCheck = domain;
|
package/dist/utils/error.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
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* Checks if error has message.
|
|
9
9
|
*
|
|
10
10
|
* @param error Error object.
|
|
11
|
+
*
|
|
11
12
|
* @returns If param is error.
|
|
12
13
|
*/
|
|
13
14
|
function isErrorWithMessage(error) {
|
|
@@ -20,6 +21,7 @@ function isErrorWithMessage(error) {
|
|
|
20
21
|
* Converts error to the error with message.
|
|
21
22
|
*
|
|
22
23
|
* @param maybeError Possible error.
|
|
24
|
+
*
|
|
23
25
|
* @returns Error with message.
|
|
24
26
|
*/
|
|
25
27
|
function toErrorWithMessage(maybeError) {
|
package/dist/utils/index.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,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
|
|
@@ -21,8 +21,10 @@ class LogicalExpressionUtils {
|
|
|
21
21
|
/**
|
|
22
22
|
* Get all variables in the expression.
|
|
23
23
|
*
|
|
24
|
-
* @param node Logical expression node
|
|
25
|
-
*
|
|
24
|
+
* @param node Logical expression node.
|
|
25
|
+
*
|
|
26
|
+
* @returns List of variables in the expression (nodes).
|
|
27
|
+
*
|
|
26
28
|
* @example
|
|
27
29
|
* If the expression is `a && b || c`, the returned list will be
|
|
28
30
|
* nodes for `a`, `b`, and `c`.
|
|
@@ -45,9 +47,11 @@ class LogicalExpressionUtils {
|
|
|
45
47
|
* Evaluate the parsed logical expression. You'll need to provide a
|
|
46
48
|
* variable table.
|
|
47
49
|
*
|
|
48
|
-
* @param node Logical expression node
|
|
49
|
-
* @param table Variable table (key: variable name, value: boolean)
|
|
50
|
-
*
|
|
50
|
+
* @param node Logical expression node.
|
|
51
|
+
* @param table Variable table (key: variable name, value: boolean).
|
|
52
|
+
*
|
|
53
|
+
* @returns Evaluation result.
|
|
54
|
+
*
|
|
51
55
|
* @example
|
|
52
56
|
* If the expression is `a && b`, and the variable table is
|
|
53
57
|
* `{ a: true, b: false }`, the result will be `false`.
|
|
@@ -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,15 +10,15 @@ import { isUndefined } from './type-guards.js';
|
|
|
10
10
|
* A very simple map extension that allows to store multiple values for the same key
|
|
11
11
|
* by storing them in an array.
|
|
12
12
|
*
|
|
13
|
-
* @todo Add more methods if needed
|
|
13
|
+
* @todo Add more methods if needed.
|
|
14
14
|
*/
|
|
15
15
|
class MultiValueMap extends Map {
|
|
16
16
|
/**
|
|
17
17
|
* Adds a value to the map. If the key already exists, the value will be appended to the existing array,
|
|
18
18
|
* otherwise a new array will be created for the key.
|
|
19
19
|
*
|
|
20
|
-
* @param key Key to add
|
|
21
|
-
* @param values Value(s) to add
|
|
20
|
+
* @param key Key to add.
|
|
21
|
+
* @param values Value(s) to add.
|
|
22
22
|
*/
|
|
23
23
|
add(key, ...values) {
|
|
24
24
|
let currentValues = super.get(key);
|
|
@@ -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
|
|
@@ -55,6 +55,7 @@ class PositionProvider {
|
|
|
55
55
|
* Converts a character offset to a line and column position.
|
|
56
56
|
*
|
|
57
57
|
* @param offset The zero-based character offset in the source code.
|
|
58
|
+
*
|
|
58
59
|
* @returns A Position object containing the 1-based line and column number, or null if the offset is out of range.
|
|
59
60
|
*/
|
|
60
61
|
convertOffsetToPosition(offset) {
|
package/dist/utils/quotes.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,10 +7,10 @@
|
|
|
7
7
|
import { ESCAPE_CHARACTER, EMPTY, SINGLE_QUOTE, DOUBLE_QUOTE, BACKTICK_QUOTE, COMMA, SPACE, OPEN_PARENTHESIS, CLOSE_PARENTHESIS, OPEN_SQUARE_BRACKET, CLOSE_SQUARE_BRACKET } from './constants.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* @file Utility functions for working with quotes
|
|
10
|
+
* @file Utility functions for working with quotes.
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
|
-
* Set of all possible quote characters supported by the library
|
|
13
|
+
* Set of all possible quote characters supported by the library.
|
|
14
14
|
*/
|
|
15
15
|
const QUOTE_SET = new Set([
|
|
16
16
|
SINGLE_QUOTE,
|
|
@@ -18,36 +18,37 @@ const QUOTE_SET = new Set([
|
|
|
18
18
|
BACKTICK_QUOTE,
|
|
19
19
|
]);
|
|
20
20
|
/**
|
|
21
|
-
* Possible quote types for scriptlet parameters
|
|
21
|
+
* Possible quote types for scriptlet parameters.
|
|
22
22
|
*/
|
|
23
23
|
const QuoteType = {
|
|
24
24
|
/**
|
|
25
|
-
* No quotes at all
|
|
25
|
+
* No quotes at all.
|
|
26
26
|
*/
|
|
27
27
|
None: 'none',
|
|
28
28
|
/**
|
|
29
|
-
* Single quotes (`'`)
|
|
29
|
+
* Single quotes (`'`).
|
|
30
30
|
*/
|
|
31
31
|
Single: 'single',
|
|
32
32
|
/**
|
|
33
|
-
* Double quotes (`"`)
|
|
33
|
+
* Double quotes (`"`).
|
|
34
34
|
*/
|
|
35
35
|
Double: 'double',
|
|
36
36
|
/**
|
|
37
|
-
* Backtick quotes (`` ` ``)
|
|
37
|
+
* Backtick quotes (`` ` ``).
|
|
38
38
|
*/
|
|
39
39
|
Backtick: 'backtick',
|
|
40
40
|
};
|
|
41
41
|
/**
|
|
42
|
-
* Utility functions for working with quotes
|
|
42
|
+
* Utility functions for working with quotes.
|
|
43
43
|
*/
|
|
44
44
|
class QuoteUtils {
|
|
45
45
|
/**
|
|
46
|
-
* Escape all unescaped occurrences of the character
|
|
46
|
+
* Escape all unescaped occurrences of the character.
|
|
47
47
|
*
|
|
48
|
-
* @param string String to escape
|
|
49
|
-
* @param char Character to escape
|
|
50
|
-
*
|
|
48
|
+
* @param string String to escape.
|
|
49
|
+
* @param char Character to escape.
|
|
50
|
+
*
|
|
51
|
+
* @returns Escaped string.
|
|
51
52
|
*/
|
|
52
53
|
static escapeUnescapedOccurrences(string, char) {
|
|
53
54
|
let result = EMPTY;
|
|
@@ -60,11 +61,12 @@ class QuoteUtils {
|
|
|
60
61
|
return result;
|
|
61
62
|
}
|
|
62
63
|
/**
|
|
63
|
-
* Unescape all single escaped occurrences of the character
|
|
64
|
+
* Unescape all single escaped occurrences of the character.
|
|
65
|
+
*
|
|
66
|
+
* @param string String to unescape.
|
|
67
|
+
* @param char Character to unescape.
|
|
64
68
|
*
|
|
65
|
-
* @
|
|
66
|
-
* @param char Character to unescape
|
|
67
|
-
* @returns Unescaped string
|
|
69
|
+
* @returns Unescaped string.
|
|
68
70
|
*/
|
|
69
71
|
static unescapeSingleEscapedOccurrences(string, char) {
|
|
70
72
|
let result = EMPTY;
|
|
@@ -79,10 +81,11 @@ class QuoteUtils {
|
|
|
79
81
|
return result;
|
|
80
82
|
}
|
|
81
83
|
/**
|
|
82
|
-
* Get quote type of the string
|
|
84
|
+
* Get quote type of the string.
|
|
85
|
+
*
|
|
86
|
+
* @param string String to check.
|
|
83
87
|
*
|
|
84
|
-
* @
|
|
85
|
-
* @returns Quote type of the string
|
|
88
|
+
* @returns Quote type of the string.
|
|
86
89
|
*/
|
|
87
90
|
static getStringQuoteType(string) {
|
|
88
91
|
// Don't check 1-character strings to avoid false positives
|
|
@@ -100,11 +103,12 @@ class QuoteUtils {
|
|
|
100
103
|
return QuoteType.None;
|
|
101
104
|
}
|
|
102
105
|
/**
|
|
103
|
-
* Set quote type of the string
|
|
106
|
+
* Set quote type of the string.
|
|
104
107
|
*
|
|
105
|
-
* @param string String to set quote type of
|
|
106
|
-
* @param quoteType Quote type to set
|
|
107
|
-
*
|
|
108
|
+
* @param string String to set quote type of.
|
|
109
|
+
* @param quoteType Quote type to set.
|
|
110
|
+
*
|
|
111
|
+
* @returns String with the specified quote type.
|
|
108
112
|
*/
|
|
109
113
|
static setStringQuoteType(string, quoteType) {
|
|
110
114
|
const actualQuoteType = QuoteUtils.getStringQuoteType(string);
|
|
@@ -159,10 +163,11 @@ class QuoteUtils {
|
|
|
159
163
|
}
|
|
160
164
|
}
|
|
161
165
|
/**
|
|
162
|
-
* Removes bounding quotes from a string, if any
|
|
166
|
+
* Removes bounding quotes from a string, if any.
|
|
167
|
+
*
|
|
168
|
+
* @param string Input string.
|
|
163
169
|
*
|
|
164
|
-
* @
|
|
165
|
-
* @returns String without quotes
|
|
170
|
+
* @returns String without quotes.
|
|
166
171
|
*/
|
|
167
172
|
static removeQuotes(string) {
|
|
168
173
|
if (
|
|
@@ -178,8 +183,9 @@ class QuoteUtils {
|
|
|
178
183
|
* Removes bounding quotes from a string, if any, and unescapes the escaped quotes,
|
|
179
184
|
* like transforming `'abc\'def'` to `abc'def`.
|
|
180
185
|
*
|
|
181
|
-
* @param string Input string
|
|
182
|
-
*
|
|
186
|
+
* @param string Input string.
|
|
187
|
+
*
|
|
188
|
+
* @returns String without quotes.
|
|
183
189
|
*/
|
|
184
190
|
static removeQuotesAndUnescape(string) {
|
|
185
191
|
const quoteType = QuoteUtils.getStringQuoteType(string);
|
|
@@ -216,22 +222,22 @@ class QuoteUtils {
|
|
|
216
222
|
* Convert `""` to `\"` within strings inside of attribute selectors,
|
|
217
223
|
* because it is not compatible with the standard CSS syntax.
|
|
218
224
|
*
|
|
225
|
+
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#tag-content}
|
|
226
|
+
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#wildcard}
|
|
227
|
+
*
|
|
219
228
|
* @param selector CSS selector string.
|
|
220
229
|
*
|
|
221
230
|
* @returns Escaped CSS selector.
|
|
222
231
|
*
|
|
223
|
-
* @note In the legacy syntax, `""` is used to escape double quotes, but it cannot be used
|
|
224
|
-
* in the standard CSS syntax, so we use conversion functions to handle this.
|
|
225
|
-
* @note This function is intended to be used on whole attribute selector or whole selector strings.
|
|
226
|
-
*
|
|
227
|
-
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#tag-content}
|
|
228
|
-
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#wildcard}
|
|
229
|
-
*
|
|
230
232
|
* @example
|
|
231
233
|
* ```ts
|
|
232
234
|
* QuoteUtils.escapeAttributeDoubleQuotes('[attr="value with "" quotes"]');
|
|
233
235
|
* QuoteUtils.escapeAttributeDoubleQuotes('div[attr="value with "" quotes"] > span');
|
|
234
236
|
* ```
|
|
237
|
+
*
|
|
238
|
+
* @note In the legacy syntax, `""` is used to escape double quotes, but it cannot be used
|
|
239
|
+
* in the standard CSS syntax, so we use conversion functions to handle this.
|
|
240
|
+
* @note This function is intended to be used on whole attribute selector or whole selector strings.
|
|
235
241
|
*/
|
|
236
242
|
static escapeAttributeDoubleQuotes(selector) {
|
|
237
243
|
const nestingBlockPairs = new Map([
|
|
@@ -291,22 +297,22 @@ class QuoteUtils {
|
|
|
291
297
|
* Convert escaped double quotes `\"` to `""` within strings inside of attribute selectors,
|
|
292
298
|
* because it is not compatible with the standard CSS syntax.
|
|
293
299
|
*
|
|
300
|
+
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#tag-content}
|
|
301
|
+
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#wildcard}
|
|
302
|
+
*
|
|
294
303
|
* @param selector CSS selector string.
|
|
295
304
|
*
|
|
296
305
|
* @returns Unescaped CSS selector.
|
|
297
306
|
*
|
|
298
|
-
* @note In the legacy syntax, `""` is used to escape double quotes, but it cannot be used
|
|
299
|
-
* in the standard CSS syntax, so we use conversion functions to handle this.
|
|
300
|
-
* @note This function is intended to be used on whole attribute selector or whole selector strings.
|
|
301
|
-
*
|
|
302
|
-
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#tag-content}
|
|
303
|
-
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#wildcard}
|
|
304
|
-
*
|
|
305
307
|
* @example
|
|
306
308
|
* ```ts
|
|
307
309
|
* QuoteUtils.unescapeAttributeDoubleQuotes('[attr="value with \\" quotes"]');
|
|
308
310
|
* QuoteUtils.unescapeAttributeDoubleQuotes('div[attr="value with \\" quotes"] > span');
|
|
309
311
|
* ```
|
|
312
|
+
*
|
|
313
|
+
* @note In the legacy syntax, `""` is used to escape double quotes, but it cannot be used
|
|
314
|
+
* in the standard CSS syntax, so we use conversion functions to handle this.
|
|
315
|
+
* @note This function is intended to be used on whole attribute selector or whole selector strings.
|
|
310
316
|
*/
|
|
311
317
|
static unescapeAttributeDoubleQuotes(selector) {
|
|
312
318
|
const nestingBlockPairs = new Map([
|
package/dist/utils/regexp.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
|
|
@@ -8,7 +8,7 @@ import GlobToRegExp from 'glob-to-regexp';
|
|
|
8
8
|
import { CARET, ASTERISK, PIPE, DOT, CLOSE_CURLY_BRACKET, CLOSE_PARENTHESIS, CLOSE_SQUARE_BRACKET, DOLLAR_SIGN, ESCAPE_CHARACTER, OPEN_CURLY_BRACKET, OPEN_PARENTHESIS, OPEN_SQUARE_BRACKET, PLUS, QUESTION_MARK, SLASH, REGEX_MARKER, EMPTY } from './constants.js';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* @file Regular expression utilities
|
|
11
|
+
* @file Regular expression utilities.
|
|
12
12
|
*/
|
|
13
13
|
// Special RegExp constants
|
|
14
14
|
const REGEX_START = CARET; // '^'
|
|
@@ -25,7 +25,7 @@ const ADBLOCK_WILDCARD_REGEX = REGEX_ANY_CHARACTERS;
|
|
|
25
25
|
const REGEX_NEGATION_PREFIX = '^((?!';
|
|
26
26
|
const REGEX_NEGATION_SUFFIX = ').)*$';
|
|
27
27
|
/**
|
|
28
|
-
* Special RegExp symbols
|
|
28
|
+
* Special RegExp symbols.
|
|
29
29
|
*
|
|
30
30
|
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#special-escape
|
|
31
31
|
*/
|
|
@@ -47,7 +47,7 @@ const SPECIAL_REGEX_SYMBOLS = new Set([
|
|
|
47
47
|
SLASH,
|
|
48
48
|
]);
|
|
49
49
|
/**
|
|
50
|
-
* Utility functions for working with RegExp patterns
|
|
50
|
+
* Utility functions for working with RegExp patterns.
|
|
51
51
|
*/
|
|
52
52
|
class RegExpUtils {
|
|
53
53
|
/**
|
|
@@ -57,8 +57,9 @@ class RegExpUtils {
|
|
|
57
57
|
* Note: it does not perform a full validation of the pattern,
|
|
58
58
|
* it just checks if the string starts and ends with a slash.
|
|
59
59
|
*
|
|
60
|
-
* @param pattern
|
|
61
|
-
*
|
|
60
|
+
* @param pattern Pattern to check.
|
|
61
|
+
*
|
|
62
|
+
* @returns `true` if the string is a RegExp pattern, `false` otherwise.
|
|
62
63
|
*/
|
|
63
64
|
static isRegexPattern(pattern) {
|
|
64
65
|
const trimmedPattern = pattern.trim();
|
|
@@ -71,8 +72,9 @@ class RegExpUtils {
|
|
|
71
72
|
/**
|
|
72
73
|
* Checks whether a string is a negated RegExp pattern.
|
|
73
74
|
*
|
|
74
|
-
* @param pattern
|
|
75
|
-
*
|
|
75
|
+
* @param pattern Pattern to check.
|
|
76
|
+
*
|
|
77
|
+
* @returns `true` if the string is a negated RegExp pattern, `false` otherwise.
|
|
76
78
|
*/
|
|
77
79
|
static isNegatedRegexPattern(pattern) {
|
|
78
80
|
if (pattern.startsWith(REGEX_MARKER) && pattern.endsWith(REGEX_MARKER)) {
|
|
@@ -84,8 +86,9 @@ class RegExpUtils {
|
|
|
84
86
|
/**
|
|
85
87
|
* Removes negation from a RegExp pattern.
|
|
86
88
|
*
|
|
87
|
-
* @param pattern
|
|
88
|
-
*
|
|
89
|
+
* @param pattern RegExp pattern to remove negation from.
|
|
90
|
+
*
|
|
91
|
+
* @returns RegExp pattern without negation.
|
|
89
92
|
*/
|
|
90
93
|
static removeNegationFromRegexPattern(pattern) {
|
|
91
94
|
let result = pattern.trim();
|
|
@@ -103,8 +106,9 @@ class RegExpUtils {
|
|
|
103
106
|
*
|
|
104
107
|
* RegExp modifiers are not supported.
|
|
105
108
|
*
|
|
106
|
-
* @param pattern Pattern to negate (can be wrapped in slashes or not)
|
|
107
|
-
*
|
|
109
|
+
* @param pattern Pattern to negate (can be wrapped in slashes or not).
|
|
110
|
+
*
|
|
111
|
+
* @returns Negated RegExp pattern.
|
|
108
112
|
*/
|
|
109
113
|
static negateRegexPattern(pattern) {
|
|
110
114
|
let result = pattern.trim();
|
|
@@ -136,8 +140,9 @@ class RegExpUtils {
|
|
|
136
140
|
/**
|
|
137
141
|
* Ensures that a pattern is wrapped in slashes.
|
|
138
142
|
*
|
|
139
|
-
* @param pattern Pattern to ensure slashes for
|
|
140
|
-
*
|
|
143
|
+
* @param pattern Pattern to ensure slashes for.
|
|
144
|
+
*
|
|
145
|
+
* @returns Pattern with slashes.
|
|
141
146
|
*/
|
|
142
147
|
static ensureSlashes(pattern) {
|
|
143
148
|
let result = pattern;
|
|
@@ -151,11 +156,13 @@ class RegExpUtils {
|
|
|
151
156
|
}
|
|
152
157
|
/**
|
|
153
158
|
* Converts a basic adblock rule pattern to a RegExp pattern. Based on
|
|
154
|
-
* https://github.com/AdguardTeam/tsurlfilter/blob/9b26e0b4a0e30b87690bc60f7cf377d112c3085c/packages/tsurlfilter/src/rules/simple-regex.ts#L219
|
|
159
|
+
* https://github.com/AdguardTeam/tsurlfilter/blob/9b26e0b4a0e30b87690bc60f7cf377d112c3085c/packages/tsurlfilter/src/rules/simple-regex.ts#L219.
|
|
155
160
|
*
|
|
156
|
-
* @param pattern Pattern to convert
|
|
157
|
-
* @returns RegExp equivalent of the pattern
|
|
158
161
|
* @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#basic-rules}
|
|
162
|
+
*
|
|
163
|
+
* @param pattern Pattern to convert.
|
|
164
|
+
*
|
|
165
|
+
* @returns RegExp equivalent of the pattern.
|
|
159
166
|
*/
|
|
160
167
|
static patternToRegexp(pattern) {
|
|
161
168
|
const trimmed = pattern.trim();
|
|
@@ -222,7 +229,7 @@ class RegExpUtils {
|
|
|
222
229
|
* Creates a length-matching regular expression string: /^(?=.{min,max}$).*\/s
|
|
223
230
|
* Where:
|
|
224
231
|
* - (?=.{min,max}$) is a lookahead that ensures the string length is between min and max
|
|
225
|
-
* - .* matches any character (including newlines, due to the 's' flag)
|
|
232
|
+
* - .* matches any character (including newlines, due to the 's' flag).
|
|
226
233
|
*
|
|
227
234
|
* @param min Minimum length or `null` for no minimum (default to `0`).
|
|
228
235
|
* @param max Maximum length or `null` for no maximum (default to no maximum).
|