@adguard/filters-compiler 3.2.3 → 3.2.5
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 +7 -0
- package/dist/build.txt +1 -1
- package/dist/index.cjs +13 -9
- package/dist/index.js +13 -9
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -10,6 +10,7 @@ It is used in [FiltersRegistry].
|
|
|
10
10
|
- [Filters metadata](#filters-metadata)
|
|
11
11
|
- [`@include` directive and its options](#include-directive)
|
|
12
12
|
- [Logging](#logging)
|
|
13
|
+
- [Additional resources](#additional-resources)
|
|
13
14
|
|
|
14
15
|
## Usage
|
|
15
16
|
|
|
@@ -261,5 +262,11 @@ The logger supports the following log levels:
|
|
|
261
262
|
|
|
262
263
|
The logger is initialized during compilation when a valid `logPath` is provided.
|
|
263
264
|
|
|
265
|
+
## Additional resources
|
|
266
|
+
|
|
267
|
+
- [AGENTS.md](AGENTS.md) — AI agent instructions and code guidelines
|
|
268
|
+
- [DEVELOPMENT.md](DEVELOPMENT.md) — Development environment setup guide
|
|
269
|
+
- [CHANGELOG.md](CHANGELOG.md) — Version history
|
|
270
|
+
|
|
264
271
|
[FiltersRegistry]: https://github.com/AdguardTeam/FiltersRegistry/
|
|
265
272
|
[filters-metadata]: https://github.com/AdguardTeam/FiltersRegistry/blob/master/README.md#filters-metadata
|
package/dist/build.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
version=3.2.
|
|
1
|
+
version=3.2.5
|
package/dist/index.cjs
CHANGED
|
@@ -770,10 +770,12 @@ class RuleValidator {
|
|
|
770
770
|
* Validates rule node.
|
|
771
771
|
*
|
|
772
772
|
* @param {AnyRule} ruleNode Rule node to validate.
|
|
773
|
+
* @param {string} [ruleText] Pre-generated rule text.
|
|
774
|
+
* If not provided, generated from rule node.
|
|
773
775
|
*
|
|
774
776
|
* @returns {ValidationResult} Validation result.
|
|
775
777
|
*/
|
|
776
|
-
static validate(ruleNode) {
|
|
778
|
+
static validate(ruleNode, ruleText) {
|
|
777
779
|
if (ruleNode.category === agtree.RuleCategory.Invalid) {
|
|
778
780
|
return RuleValidator.createValidationResult(
|
|
779
781
|
false,
|
|
@@ -785,23 +787,23 @@ class RuleValidator {
|
|
|
785
787
|
return RuleValidator.createValidationResult(true);
|
|
786
788
|
}
|
|
787
789
|
|
|
788
|
-
const
|
|
790
|
+
const text = ruleText ?? agtree.RuleGenerator.generate(ruleNode);
|
|
789
791
|
|
|
790
792
|
try {
|
|
791
793
|
// Validate cosmetic rules
|
|
792
794
|
if (ruleNode.category === agtree.RuleCategory.Cosmetic) {
|
|
793
795
|
// eslint-disable-next-line no-new
|
|
794
|
-
new tsurlfilter.CosmeticRule(
|
|
796
|
+
new tsurlfilter.CosmeticRule(text, 0);
|
|
795
797
|
return RuleValidator.createValidationResult(true);
|
|
796
798
|
}
|
|
797
799
|
|
|
798
800
|
// Validate network rules
|
|
799
|
-
const rule = new tsurlfilter.NetworkRule(
|
|
800
|
-
RuleValidator.validateRegexp(rule.getPattern(),
|
|
801
|
+
const rule = new tsurlfilter.NetworkRule(text, 0);
|
|
802
|
+
RuleValidator.validateRegexp(rule.getPattern(), text);
|
|
801
803
|
} catch (error) {
|
|
802
804
|
// TODO: add getErrorMessage as a helper
|
|
803
805
|
const message = error instanceof Error ? error.message : String(error);
|
|
804
|
-
const errorMessage = `Error: "${message}" in the rule: "${
|
|
806
|
+
const errorMessage = `Error: "${message}" in the rule: "${text}"`;
|
|
805
807
|
return RuleValidator.createValidationResult(false, errorMessage);
|
|
806
808
|
}
|
|
807
809
|
|
|
@@ -925,8 +927,9 @@ const validateAndFilterRules = (list, excluded, invalid = [], filterName) => {
|
|
|
925
927
|
|
|
926
928
|
for (let i = 0; i < convertedRuleNodes.length; i += 1) {
|
|
927
929
|
const convertedRuleNode = convertedRuleNodes[i];
|
|
930
|
+
const convertedRuleText = agtree.RuleGenerator.generate(convertedRuleNode);
|
|
928
931
|
|
|
929
|
-
let validationResult = RuleValidator.validate(convertedRuleNode);
|
|
932
|
+
let validationResult = RuleValidator.validate(convertedRuleNode, convertedRuleText);
|
|
930
933
|
|
|
931
934
|
// TODO: remove this checking when $header is fixed
|
|
932
935
|
// https://github.com/AdguardTeam/AdguardBrowserExtension/issues/2942
|
|
@@ -949,7 +952,7 @@ const validateAndFilterRules = (list, excluded, invalid = [], filterName) => {
|
|
|
949
952
|
return false;
|
|
950
953
|
}
|
|
951
954
|
|
|
952
|
-
const rule = tsurlfilter.RuleFactory.createRule(
|
|
955
|
+
const rule = tsurlfilter.RuleFactory.createRule(convertedRuleText);
|
|
953
956
|
|
|
954
957
|
// It is impossible to bundle jsdom into tsurlfilter, so we check if rules are valid in the compiler
|
|
955
958
|
if (rule instanceof tsurlfilter.CosmeticRule && rule.getType() === agtree.CosmeticRuleType.ElementHidingRule) {
|
|
@@ -1415,7 +1418,7 @@ const __dirname$4 = path$1.dirname(url.fileURLToPath((typeof document === 'undef
|
|
|
1415
1418
|
|
|
1416
1419
|
const RULES_SEPARATOR = '\r\n';
|
|
1417
1420
|
let filterIdsPool = [];
|
|
1418
|
-
|
|
1421
|
+
let metadataFilterIdsPool = [];
|
|
1419
1422
|
|
|
1420
1423
|
const OPTIMIZED_PLATFORMS_LIST = ['ext_safari', 'android', 'ios'];
|
|
1421
1424
|
|
|
@@ -2564,6 +2567,7 @@ const generate = async (filtersDir, platformsPath, whitelist, blacklist) => {
|
|
|
2564
2567
|
// reset af the end
|
|
2565
2568
|
// TODO: find out better way to reset
|
|
2566
2569
|
filterIdsPool = [];
|
|
2570
|
+
metadataFilterIdsPool = [];
|
|
2567
2571
|
};
|
|
2568
2572
|
|
|
2569
2573
|
const { log } = console;
|
package/dist/index.js
CHANGED
|
@@ -767,10 +767,12 @@ class RuleValidator {
|
|
|
767
767
|
* Validates rule node.
|
|
768
768
|
*
|
|
769
769
|
* @param {AnyRule} ruleNode Rule node to validate.
|
|
770
|
+
* @param {string} [ruleText] Pre-generated rule text.
|
|
771
|
+
* If not provided, generated from rule node.
|
|
770
772
|
*
|
|
771
773
|
* @returns {ValidationResult} Validation result.
|
|
772
774
|
*/
|
|
773
|
-
static validate(ruleNode) {
|
|
775
|
+
static validate(ruleNode, ruleText) {
|
|
774
776
|
if (ruleNode.category === RuleCategory.Invalid) {
|
|
775
777
|
return RuleValidator.createValidationResult(
|
|
776
778
|
false,
|
|
@@ -782,23 +784,23 @@ class RuleValidator {
|
|
|
782
784
|
return RuleValidator.createValidationResult(true);
|
|
783
785
|
}
|
|
784
786
|
|
|
785
|
-
const
|
|
787
|
+
const text = ruleText ?? RuleGenerator.generate(ruleNode);
|
|
786
788
|
|
|
787
789
|
try {
|
|
788
790
|
// Validate cosmetic rules
|
|
789
791
|
if (ruleNode.category === RuleCategory.Cosmetic) {
|
|
790
792
|
// eslint-disable-next-line no-new
|
|
791
|
-
new CosmeticRule(
|
|
793
|
+
new CosmeticRule(text, 0);
|
|
792
794
|
return RuleValidator.createValidationResult(true);
|
|
793
795
|
}
|
|
794
796
|
|
|
795
797
|
// Validate network rules
|
|
796
|
-
const rule = new NetworkRule(
|
|
797
|
-
RuleValidator.validateRegexp(rule.getPattern(),
|
|
798
|
+
const rule = new NetworkRule(text, 0);
|
|
799
|
+
RuleValidator.validateRegexp(rule.getPattern(), text);
|
|
798
800
|
} catch (error) {
|
|
799
801
|
// TODO: add getErrorMessage as a helper
|
|
800
802
|
const message = error instanceof Error ? error.message : String(error);
|
|
801
|
-
const errorMessage = `Error: "${message}" in the rule: "${
|
|
803
|
+
const errorMessage = `Error: "${message}" in the rule: "${text}"`;
|
|
802
804
|
return RuleValidator.createValidationResult(false, errorMessage);
|
|
803
805
|
}
|
|
804
806
|
|
|
@@ -922,8 +924,9 @@ const validateAndFilterRules = (list, excluded, invalid = [], filterName) => {
|
|
|
922
924
|
|
|
923
925
|
for (let i = 0; i < convertedRuleNodes.length; i += 1) {
|
|
924
926
|
const convertedRuleNode = convertedRuleNodes[i];
|
|
927
|
+
const convertedRuleText = RuleGenerator.generate(convertedRuleNode);
|
|
925
928
|
|
|
926
|
-
let validationResult = RuleValidator.validate(convertedRuleNode);
|
|
929
|
+
let validationResult = RuleValidator.validate(convertedRuleNode, convertedRuleText);
|
|
927
930
|
|
|
928
931
|
// TODO: remove this checking when $header is fixed
|
|
929
932
|
// https://github.com/AdguardTeam/AdguardBrowserExtension/issues/2942
|
|
@@ -946,7 +949,7 @@ const validateAndFilterRules = (list, excluded, invalid = [], filterName) => {
|
|
|
946
949
|
return false;
|
|
947
950
|
}
|
|
948
951
|
|
|
949
|
-
const rule = RuleFactory.createRule(
|
|
952
|
+
const rule = RuleFactory.createRule(convertedRuleText);
|
|
950
953
|
|
|
951
954
|
// It is impossible to bundle jsdom into tsurlfilter, so we check if rules are valid in the compiler
|
|
952
955
|
if (rule instanceof CosmeticRule && rule.getType() === CosmeticRuleType.ElementHidingRule) {
|
|
@@ -1412,7 +1415,7 @@ const __dirname$3 = path$1.dirname(fileURLToPath(import.meta.url));
|
|
|
1412
1415
|
|
|
1413
1416
|
const RULES_SEPARATOR = '\r\n';
|
|
1414
1417
|
let filterIdsPool = [];
|
|
1415
|
-
|
|
1418
|
+
let metadataFilterIdsPool = [];
|
|
1416
1419
|
|
|
1417
1420
|
const OPTIMIZED_PLATFORMS_LIST = ['ext_safari', 'android', 'ios'];
|
|
1418
1421
|
|
|
@@ -2561,6 +2564,7 @@ const generate = async (filtersDir, platformsPath, whitelist, blacklist) => {
|
|
|
2561
2564
|
// reset af the end
|
|
2562
2565
|
// TODO: find out better way to reset
|
|
2563
2566
|
filterIdsPool = [];
|
|
2567
|
+
metadataFilterIdsPool = [];
|
|
2564
2568
|
};
|
|
2565
2569
|
|
|
2566
2570
|
const { log } = console;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adguard/filters-compiler",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.5",
|
|
4
4
|
"description": "AdGuard filters compiler",
|
|
5
5
|
"homepage": "http://adguard.com",
|
|
6
6
|
"type": "module",
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
"node": ">=22"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@adguard/agtree": "^
|
|
21
|
+
"@adguard/agtree": "^4.0.2",
|
|
22
22
|
"@adguard/css-tokenizer": "^1.2.0",
|
|
23
23
|
"@adguard/ecss-tree": "^2.0.1",
|
|
24
24
|
"@eslint/css-tree": "3.6.6",
|
|
25
25
|
"@adguard/extended-css": "^2.1.1",
|
|
26
26
|
"@adguard/filters-downloader": "^2.4.0",
|
|
27
27
|
"@adguard/logger": "^2.0.0",
|
|
28
|
-
"@adguard/scriptlets": "^2.
|
|
29
|
-
"@adguard/tsurlfilter": "^
|
|
28
|
+
"@adguard/scriptlets": "^2.3.0",
|
|
29
|
+
"@adguard/tsurlfilter": "^4.0.3",
|
|
30
30
|
"ajv": "^8.17.1",
|
|
31
31
|
"child_process": ">=1.0.2",
|
|
32
32
|
"jsdom": "^21.1.1",
|