@adguard/agtree 3.3.0 → 3.4.0

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.
Files changed (263) hide show
  1. package/dist/ast-utils/clone.js +1 -1
  2. package/dist/ast-utils/modifiers.js +1 -1
  3. package/dist/ast-utils/network-rules.js +1 -1
  4. package/dist/ast-utils/scriptlets.js +1 -1
  5. package/dist/common/abp-snippet-injection-body-common.js +1 -1
  6. package/dist/common/agent-common.js +1 -1
  7. package/dist/common/ubo-selector-common.js +1 -1
  8. package/dist/compatibility-tables/base.js +2 -2
  9. package/dist/compatibility-tables/compatibility-table-data.js +1 -1
  10. package/dist/compatibility-tables/modifiers.js +4 -3
  11. package/dist/compatibility-tables/platforms.js +32 -30
  12. package/dist/compatibility-tables/redirects.js +11 -7
  13. package/dist/compatibility-tables/schemas/base.js +1 -1
  14. package/dist/compatibility-tables/schemas/modifier.js +1 -1
  15. package/dist/compatibility-tables/schemas/platform.js +57 -4
  16. package/dist/compatibility-tables/schemas/redirect.js +1 -1
  17. package/dist/compatibility-tables/schemas/resource-type.js +1 -1
  18. package/dist/compatibility-tables/schemas/scriptlet.js +1 -1
  19. package/dist/compatibility-tables/scriptlets.js +1 -1
  20. package/dist/compatibility-tables/utils/platform-helpers.js +290 -7
  21. package/dist/compatibility-tables/utils/resource-type-helpers.js +2 -2
  22. package/dist/compatibility-tables/utils/zod-camelcase.js +1 -1
  23. package/dist/converter/base-interfaces/base-converter.js +1 -1
  24. package/dist/converter/base-interfaces/conversion-result.js +1 -1
  25. package/dist/converter/base-interfaces/rule-converter-base.js +1 -1
  26. package/dist/converter/comment/index.js +1 -1
  27. package/dist/converter/cosmetic/css.js +1 -1
  28. package/dist/converter/cosmetic/element-hiding.js +1 -1
  29. package/dist/converter/cosmetic/header-removal.js +1 -1
  30. package/dist/converter/cosmetic/html.js +1 -1
  31. package/dist/converter/cosmetic/index.js +1 -1
  32. package/dist/converter/cosmetic/rule-modifiers/adg.js +1 -1
  33. package/dist/converter/cosmetic/rule-modifiers/ubo.js +2 -1
  34. package/dist/converter/cosmetic/scriptlet.js +1 -1
  35. package/dist/converter/css/index.js +2 -1
  36. package/dist/converter/data/css.js +1 -1
  37. package/dist/converter/filter-list.js +1 -1
  38. package/dist/converter/index.js +1 -1
  39. package/dist/converter/misc/network-rule-modifier.js +1 -1
  40. package/dist/converter/network/index.js +1 -1
  41. package/dist/converter/raw-filter-list.js +1 -1
  42. package/dist/converter/raw-rule.js +2 -1
  43. package/dist/converter/rule.js +1 -1
  44. package/dist/deserializer/base-deserializer.js +1 -1
  45. package/dist/deserializer/comment/agent-comment-deserializer.js +1 -1
  46. package/dist/deserializer/comment/agent-deserializer.js +1 -1
  47. package/dist/deserializer/comment/comment-rule-deserializer.js +1 -1
  48. package/dist/deserializer/comment/config-comment-deserializer.js +1 -1
  49. package/dist/deserializer/comment/hint-comment-deserializer.js +1 -1
  50. package/dist/deserializer/comment/hint-deserializer.js +1 -1
  51. package/dist/deserializer/comment/metadata-comment-deserializer.js +1 -1
  52. package/dist/deserializer/comment/pre-processor-comment-deserializer.js +1 -1
  53. package/dist/deserializer/comment/simple-comment-deserializer.js +1 -1
  54. package/dist/deserializer/cosmetic/cosmetic-rule-deserializer.js +1 -1
  55. package/dist/deserializer/cosmetic/css-injection-body-deserializer.js +1 -1
  56. package/dist/deserializer/cosmetic/element-hiding-body-deserializer.js +1 -1
  57. package/dist/deserializer/cosmetic/scriptlet-body/abp-snippet-injection-body-deserializer.js +1 -1
  58. package/dist/deserializer/cosmetic/scriptlet-body/adg-scriptlet-injection-body-deserializer.js +1 -1
  59. package/dist/deserializer/cosmetic/scriptlet-body/scriptlet-body-deserializer.js +1 -1
  60. package/dist/deserializer/cosmetic/scriptlet-body/ubo-scriptlet-injection-body-deserializer.js +1 -1
  61. package/dist/deserializer/empty-rule-deserializer.js +1 -1
  62. package/dist/deserializer/filterlist-deserializer.js +1 -1
  63. package/dist/deserializer/index.js +1 -1
  64. package/dist/deserializer/invalid-rule-deserializer.js +1 -1
  65. package/dist/deserializer/invalid-rule-error-node-deserializer.js +1 -1
  66. package/dist/deserializer/misc/domain-list-deserializer.js +1 -1
  67. package/dist/deserializer/misc/list-item-deserializer.js +1 -1
  68. package/dist/deserializer/misc/list-items-deserializer.js +1 -1
  69. package/dist/deserializer/misc/logical-expression-deserializer.js +1 -1
  70. package/dist/deserializer/misc/modifier-deserializer.js +1 -1
  71. package/dist/deserializer/misc/modifier-list-deserializer.js +1 -1
  72. package/dist/deserializer/misc/parameter-list-deserializer.js +1 -1
  73. package/dist/deserializer/misc/value-deserializer.js +1 -1
  74. package/dist/deserializer/network/host-rule-deserializer.js +1 -1
  75. package/dist/deserializer/network/hostname-list-deserializer.js +1 -1
  76. package/dist/deserializer/network/network-rule-deserializer.js +1 -1
  77. package/dist/deserializer/rule-deserializer.js +1 -1
  78. package/dist/deserializer/syntax-deserialization-map.js +1 -1
  79. package/dist/errors/adblock-syntax-error.js +1 -1
  80. package/dist/errors/binary-schema-mismatch-error.js +1 -1
  81. package/dist/errors/not-implemented-error.js +1 -1
  82. package/dist/errors/rule-conversion-error.js +1 -1
  83. package/dist/generator/base-generator.js +1 -1
  84. package/dist/generator/comment/agent-comment-generator.js +1 -1
  85. package/dist/generator/comment/agent-generator.js +1 -1
  86. package/dist/generator/comment/comment-rule-generator.js +1 -1
  87. package/dist/generator/comment/config-comment-generator.js +1 -1
  88. package/dist/generator/comment/hint-comment-generator.js +1 -1
  89. package/dist/generator/comment/hint-generator.js +1 -1
  90. package/dist/generator/comment/metadata-comment-generator.js +1 -1
  91. package/dist/generator/comment/pre-processor-comment-generator.js +1 -1
  92. package/dist/generator/comment/simple-comment-generator.js +1 -1
  93. package/dist/generator/cosmetic/body/abp-snippet-injection-body-generator.js +1 -1
  94. package/dist/generator/cosmetic/body/adg-scriptlet-injection-body-generator.js +1 -1
  95. package/dist/generator/cosmetic/body/ubo-scriptlet-injection-body-generator.js +1 -1
  96. package/dist/generator/cosmetic/cosmetic-rule-body-generator.js +1 -1
  97. package/dist/generator/cosmetic/cosmetic-rule-generator.js +1 -1
  98. package/dist/generator/cosmetic/cosmetic-rule-pattern-generator.js +1 -1
  99. package/dist/generator/css/adg-css-injection-generator.js +1 -1
  100. package/dist/generator/filterlist-generator.js +1 -1
  101. package/dist/generator/index.js +1 -1
  102. package/dist/generator/misc/domain-list-generator.js +1 -1
  103. package/dist/generator/misc/list-items-generator.js +1 -1
  104. package/dist/generator/misc/logical-expression-generator.js +1 -1
  105. package/dist/generator/misc/modifier-generator.js +1 -1
  106. package/dist/generator/misc/modifier-list-generator.js +1 -1
  107. package/dist/generator/misc/parameter-list-generator.js +1 -1
  108. package/dist/generator/misc/value-generator.js +1 -1
  109. package/dist/generator/network/host-rule-generator.js +1 -1
  110. package/dist/generator/network/network-rule-generator.js +1 -1
  111. package/dist/generator/rule-generator.js +1 -1
  112. package/dist/index.js +4 -4
  113. package/dist/marshalling-utils/comment/agent-comment-common.js +1 -1
  114. package/dist/marshalling-utils/comment/agent-common.js +1 -1
  115. package/dist/marshalling-utils/comment/config-comment-common.js +1 -1
  116. package/dist/marshalling-utils/comment/hint-comment-common.js +1 -1
  117. package/dist/marshalling-utils/comment/hint-common.js +1 -1
  118. package/dist/marshalling-utils/comment/metadata-comment-common.js +1 -1
  119. package/dist/marshalling-utils/comment/pre-processor-comment-common.js +1 -1
  120. package/dist/marshalling-utils/comment/simple-comment-common.js +1 -1
  121. package/dist/marshalling-utils/cosmetic/body/abp-snippet-injection-body-common.js +1 -1
  122. package/dist/marshalling-utils/cosmetic/body/adg-scriptlet-injection-body-common.js +1 -1
  123. package/dist/marshalling-utils/cosmetic/body/css-injection-body-common.js +1 -1
  124. package/dist/marshalling-utils/cosmetic/body/element-hiding-body-common.js +1 -1
  125. package/dist/marshalling-utils/cosmetic/body/ubo-scriptlet-injection-body-common.js +1 -1
  126. package/dist/marshalling-utils/cosmetic/cosmetic-rule-common.js +1 -1
  127. package/dist/marshalling-utils/empty-rule-common.js +1 -1
  128. package/dist/marshalling-utils/filter-list-common.js +1 -1
  129. package/dist/marshalling-utils/invalid-rule-common.js +1 -1
  130. package/dist/marshalling-utils/invalid-rule-error-node-common.js +1 -1
  131. package/dist/marshalling-utils/misc/binary-type-common.js +1 -1
  132. package/dist/marshalling-utils/misc/domain-list-common.js +1 -1
  133. package/dist/marshalling-utils/misc/host-rule-common.js +1 -1
  134. package/dist/marshalling-utils/misc/hostname-list-common.js +1 -1
  135. package/dist/marshalling-utils/misc/list-item-common.js +1 -1
  136. package/dist/marshalling-utils/misc/logical-expression-common.js +1 -1
  137. package/dist/marshalling-utils/misc/modifier-common.js +1 -1
  138. package/dist/marshalling-utils/misc/modifier-list-common.js +1 -1
  139. package/dist/marshalling-utils/misc/parameter-list-common.js +1 -1
  140. package/dist/marshalling-utils/misc/value-common.js +1 -1
  141. package/dist/marshalling-utils/network/network-rule-common.js +1 -1
  142. package/dist/marshalling-utils/syntax-serialization-map.js +1 -1
  143. package/dist/nodes/index.js +1 -1
  144. package/dist/package.json.js +2 -2
  145. package/dist/parser/base-parser.js +1 -1
  146. package/dist/parser/comment/agent-comment-parser.js +1 -1
  147. package/dist/parser/comment/agent-parser.js +1 -1
  148. package/dist/parser/comment/comment-parser.js +1 -1
  149. package/dist/parser/comment/config-comment-parser.js +1 -1
  150. package/dist/parser/comment/hint-comment-parser.js +1 -1
  151. package/dist/parser/comment/hint-parser.js +1 -1
  152. package/dist/parser/comment/metadata-comment-parser.js +1 -1
  153. package/dist/parser/comment/preprocessor-parser.js +1 -1
  154. package/dist/parser/comment/simple-comment-parser.js +1 -1
  155. package/dist/parser/cosmetic/body/abp-snippet-injection-body-parser.js +1 -1
  156. package/dist/parser/cosmetic/body/adg-scriptlet-injection-body-parser.js +1 -1
  157. package/dist/parser/cosmetic/body/ubo-scriptlet-injection-body-parser.js +1 -1
  158. package/dist/parser/cosmetic/cosmetic-rule-parser.js +1 -1
  159. package/dist/parser/css/adg-css-injection-parser.js +1 -1
  160. package/dist/parser/css/balancing.js +1 -1
  161. package/dist/parser/css/constants.js +1 -1
  162. package/dist/parser/css/css-token-stream.js +1 -1
  163. package/dist/parser/css/ubo-selector-parser.js +1 -1
  164. package/dist/parser/filterlist-parser.js +1 -1
  165. package/dist/parser/index.js +1 -1
  166. package/dist/parser/misc/app-list-parser.js +1 -1
  167. package/dist/parser/misc/domain-list-parser.js +1 -1
  168. package/dist/parser/misc/list-items-parser.js +1 -1
  169. package/dist/parser/misc/logical-expression-parser.js +1 -1
  170. package/dist/parser/misc/method-list-parser.js +1 -1
  171. package/dist/parser/misc/modifier-list.js +1 -1
  172. package/dist/parser/misc/modifier-parser.js +1 -1
  173. package/dist/parser/misc/parameter-list-parser.js +1 -1
  174. package/dist/parser/misc/stealth-option-list-parser.js +1 -1
  175. package/dist/parser/misc/ubo-parameter-list-parser.js +1 -1
  176. package/dist/parser/misc/value-parser.js +1 -1
  177. package/dist/parser/network/host-rule-parser.js +1 -1
  178. package/dist/parser/network/network-rule-parser.js +1 -1
  179. package/dist/parser/options.js +1 -1
  180. package/dist/parser/rule-parser.js +1 -1
  181. package/dist/serializer/base-serializer.js +1 -1
  182. package/dist/serializer/comment/agent-comment-serializer.js +1 -1
  183. package/dist/serializer/comment/agent-serializer.js +1 -1
  184. package/dist/serializer/comment/comment-rule-serializer.js +1 -1
  185. package/dist/serializer/comment/config-comment-serializer.js +1 -1
  186. package/dist/serializer/comment/hint-comment-serializer.js +1 -1
  187. package/dist/serializer/comment/hint-serializer.js +1 -1
  188. package/dist/serializer/comment/metadata-comment-serializer.js +1 -1
  189. package/dist/serializer/comment/pre-processor-comment-serializer.js +1 -1
  190. package/dist/serializer/comment/simple-comment-serializer.js +1 -1
  191. package/dist/serializer/cosmetic/body/abp-snippet-injection-body-serializer.js +1 -1
  192. package/dist/serializer/cosmetic/body/adg-scriptlet-injection-body-serializer.js +1 -1
  193. package/dist/serializer/cosmetic/body/scriptlet-body-serializer.js +1 -1
  194. package/dist/serializer/cosmetic/body/ubo-scriptlet-injection-body-serializer.js +1 -1
  195. package/dist/serializer/cosmetic/cosmetic-rule-serializer.js +1 -1
  196. package/dist/serializer/cosmetic/css-injection-body-serializer.js +1 -1
  197. package/dist/serializer/cosmetic/element-hiding-body-serializer.js +1 -1
  198. package/dist/serializer/empty-rule-serializer.js +1 -1
  199. package/dist/serializer/filterlist-serializer.js +1 -1
  200. package/dist/serializer/index.js +1 -1
  201. package/dist/serializer/invalid-rule-error-node-serializer.js +1 -1
  202. package/dist/serializer/invalid-rule-serializer.js +1 -1
  203. package/dist/serializer/misc/domain-list-serializer.js +1 -1
  204. package/dist/serializer/misc/list-item-serializer.js +1 -1
  205. package/dist/serializer/misc/list-items-serializer.js +1 -1
  206. package/dist/serializer/misc/logical-expression-serializer.js +1 -1
  207. package/dist/serializer/misc/modifier-list-serializer.js +1 -1
  208. package/dist/serializer/misc/modifier-serializer.js +1 -1
  209. package/dist/serializer/misc/parameter-list-serializer.js +1 -1
  210. package/dist/serializer/misc/value-serializer.js +1 -1
  211. package/dist/serializer/network/host-rule-serializer.js +1 -1
  212. package/dist/serializer/network/hostname-list-serializer.js +1 -1
  213. package/dist/serializer/network/network-rule-serializer.js +1 -1
  214. package/dist/serializer/rule-serializer.js +1 -1
  215. package/dist/types/compatibility-tables/base.d.ts +11 -11
  216. package/dist/types/compatibility-tables/index.d.ts +3 -2
  217. package/dist/types/compatibility-tables/platforms.d.ts +67 -33
  218. package/dist/types/compatibility-tables/redirects.d.ts +3 -3
  219. package/dist/types/compatibility-tables/schemas/base.d.ts +1 -1
  220. package/dist/types/compatibility-tables/schemas/platform.d.ts +16 -5
  221. package/dist/types/compatibility-tables/utils/platform-helpers.d.ts +112 -3
  222. package/dist/types/compatibility-tables/utils/resource-type-helpers.d.ts +3 -3
  223. package/dist/types/index.d.ts +2 -2
  224. package/dist/types/utils/adblockers.d.ts +28 -0
  225. package/dist/types/utils/bit-count.d.ts +21 -0
  226. package/dist/types/utils/index.d.ts +2 -0
  227. package/dist/types/utils/noop-modifier.d.ts +8 -0
  228. package/dist/types/utils/storage-interface.d.ts +1 -1
  229. package/dist/types/utils/types.d.ts +21 -0
  230. package/dist/types/validator/constants.d.ts +0 -9
  231. package/dist/types/validator/helpers.d.ts +0 -8
  232. package/dist/types/validator/index.d.ts +10 -9
  233. package/dist/utils/adblockers.js +28 -5
  234. package/dist/utils/binary-schema-version.js +1 -1
  235. package/dist/utils/bit-count.js +37 -0
  236. package/dist/utils/byte-buffer.js +1 -1
  237. package/dist/utils/categorizer.js +1 -1
  238. package/dist/utils/clone.js +1 -1
  239. package/dist/utils/constants.js +1 -1
  240. package/dist/utils/cosmetic-rule-separator.js +1 -1
  241. package/dist/utils/deep-freeze.js +1 -1
  242. package/dist/utils/domain.js +1 -1
  243. package/dist/utils/error.js +1 -1
  244. package/dist/utils/index.js +2 -1
  245. package/dist/utils/input-byte-buffer.js +1 -1
  246. package/dist/utils/is-chromium.js +1 -1
  247. package/dist/utils/logical-expression.js +1 -1
  248. package/dist/utils/multi-value-map.js +1 -1
  249. package/dist/utils/noop-modifier.js +29 -0
  250. package/dist/utils/output-byte-buffer.js +1 -1
  251. package/dist/utils/position-provider.js +1 -1
  252. package/dist/utils/quotes.js +1 -1
  253. package/dist/utils/regexp.js +1 -1
  254. package/dist/utils/string.js +1 -1
  255. package/dist/utils/text-decoder-polyfill.js +1 -1
  256. package/dist/utils/text-encoder-polyfill.js +1 -1
  257. package/dist/utils/type-guards.js +1 -1
  258. package/dist/validator/constants.js +3 -13
  259. package/dist/validator/helpers.js +2 -13
  260. package/dist/validator/index.js +44 -48
  261. package/dist/validator/value.js +1 -1
  262. package/dist/version.js +1 -1
  263. package/package.json +1 -1
@@ -1,6 +1,30 @@
1
1
  /**
2
2
  * @file Possible adblock syntaxes are listed here.
3
3
  */
4
+ /**
5
+ * Adblock products (specific adblockers, excludes 'Common').
6
+ */
7
+ export declare const AdblockProduct: {
8
+ /**
9
+ * Adblock Plus.
10
+ *
11
+ * @see {@link https://adblockplus.org/}
12
+ */
13
+ readonly Abp: "AdblockPlus";
14
+ /**
15
+ * uBlock Origin.
16
+ *
17
+ * @see {@link https://github.com/gorhill/uBlock}
18
+ */
19
+ readonly Ubo: "UblockOrigin";
20
+ /**
21
+ * AdGuard.
22
+ *
23
+ * @see {@link https://adguard.com/}
24
+ */
25
+ readonly Adg: "AdGuard";
26
+ };
27
+ export type AdblockProduct = typeof AdblockProduct[keyof typeof AdblockProduct];
4
28
  /**
5
29
  * Possible adblock syntaxes (supported by this library)
6
30
  */
@@ -47,3 +71,7 @@ export declare const AdblockSyntax: {
47
71
  readonly Adg: "AdGuard";
48
72
  };
49
73
  export type AdblockSyntax = typeof AdblockSyntax[keyof typeof AdblockSyntax];
74
+ /**
75
+ * @deprecated Use AdblockProduct instead.
76
+ */
77
+ export type StrictAdblockSyntax = AdblockProduct;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @file Utility for counting set bits in numbers.
3
+ */
4
+ /**
5
+ * Counts the number of set bits (1s) in a 32-bit number using Hamming Weight (SWAR) method.
6
+ *
7
+ * This is a fast bit counting algorithm that uses SWAR (SIMD Within A Register) technique.
8
+ * It's significantly faster than string conversion methods and works in O(1) time.
9
+ *
10
+ * @param a Number to count bits in.
11
+ *
12
+ * @returns The number of bits set to 1.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * getBitCount(0); // 0
17
+ * getBitCount(7); // 3 (0b111)
18
+ * getBitCount(0xFF); // 8 (0b11111111)
19
+ * ```
20
+ */
21
+ export declare function getBitCount(a: number): number;
@@ -1,6 +1,8 @@
1
1
  export { ADG_SCRIPTLET_MASK, AGLINT_COMMAND_PREFIX, COMMA_DOMAIN_LIST_SEPARATOR, NEGATION_MARKER, HINT_MARKER, IF, INCLUDE, MODIFIERS_SEPARATOR, MODIFIER_ASSIGN_OPERATOR, PIPE_MODIFIER_SEPARATOR, NETWORK_RULE_EXCEPTION_MARKER, NETWORK_RULE_SEPARATOR, PREPROCESSOR_MARKER, SAFARI_CB_AFFINITY, UBO_SCRIPTLET_MASK, COMMA, PIPE, } from './constants.js';
2
2
  export { BINARY_SCHEMA_VERSION } from './binary-schema-version.js';
3
3
  export { AdblockSyntax } from './adblockers.js';
4
+ export { getBitCount } from './bit-count.js';
5
+ export { type ReadonlyRecord } from './types.js';
4
6
  export { type CosmeticRuleSeparatorFinderResult, CosmeticRuleSeparatorUtils } from './cosmetic-rule-separator.js';
5
7
  export { DomainUtils } from './domain.js';
6
8
  export { type VariableTable, LogicalExpressionUtils } from './logical-expression.js';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Validates the noop modifier (i.e. only underscores).
3
+ *
4
+ * @param value Value of the modifier.
5
+ *
6
+ * @returns True if the modifier is valid, false otherwise.
7
+ */
8
+ export declare const isValidNoopModifier: (value: string) => boolean;
@@ -9,7 +9,7 @@ export interface Storage<K = string, V = unknown> {
9
9
  * Writes the given data to the storage with the specified key.
10
10
  *
11
11
  * @param key The key to identify the data in the storage.
12
- * @param chunks The data to write to the storage.
12
+ * @param data The data to write to the storage.
13
13
  * @returns A promise that resolves when the write operation is complete.
14
14
  */
15
15
  set(key: K, data: V): Promise<void>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @file Common utility types.
3
+ */
4
+ /**
5
+ * Readonly record type - makes all properties of a record readonly.
6
+ *
7
+ * @template K Key type (string, number, or symbol).
8
+ * @template V Value type.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const config: ReadonlyRecord<string, number> = {
13
+ * timeout: 1000,
14
+ * retries: 3,
15
+ * };
16
+ * // config is readonly, cannot modify properties
17
+ * ```
18
+ */
19
+ export type ReadonlyRecord<K extends string | number | symbol, V> = {
20
+ readonly [P in K]: V;
21
+ };
@@ -1,12 +1,3 @@
1
- /**
2
- * Prefixes for different adblockers to describe the platform-specific modifiers data
3
- * stored in the yaml files.
4
- */
5
- export declare const BLOCKER_PREFIX: {
6
- AdGuard: string;
7
- UblockOrigin: string;
8
- AdblockPlus: string;
9
- };
10
1
  /**
11
2
  * Set of all allowed characters for app name except the dot `.`.
12
3
  */
@@ -10,14 +10,6 @@ export type ValidationResult = {
10
10
  error?: string;
11
11
  warn?: string;
12
12
  };
13
- /**
14
- * Validates the noop modifier (i.e. only underscores).
15
- *
16
- * @param value Value of the modifier.
17
- *
18
- * @returns True if the modifier is valid, false otherwise.
19
- */
20
- export declare const isValidNoopModifier: (value: string) => boolean;
21
13
  /**
22
14
  * Returns invalid validation result with given error message.
23
15
  *
@@ -2,8 +2,8 @@
2
2
  * @file Validator for modifiers.
3
3
  */
4
4
  import { type Modifier } from '../nodes/index.js';
5
- import { AdblockSyntax } from '../utils/adblockers.js';
6
5
  import { type ValidationResult } from './helpers.js';
6
+ import { type AnyPlatform } from '../compatibility-tables/index.js';
7
7
  /**
8
8
  * Modifier validator class.
9
9
  */
@@ -19,20 +19,21 @@ declare class ModifierValidator {
19
19
  */
20
20
  exists: (modifier: Modifier) => boolean;
21
21
  /**
22
- * Checks whether the given `modifier` is valid for specified `syntax`.
22
+ * Checks whether the given `modifier` is valid for specified `platforms`.
23
+ * It checks whether the modifier is supported by the product, deprecated, assignable, negatable, etc.
23
24
  *
24
- * For `Common` syntax it simply checks whether the modifier exists.
25
- * For specific syntax the validation is more complex
26
- * deprecated, assignable, negatable and other requirements are checked.
27
- *
28
- * @param syntax Adblock syntax to check the modifier for.
29
- * @param rawModifier Modifier AST node.
25
+ * @param platforms Platforms to check the modifier for. Can be a specific platform (e.g., AdgExtChrome)
26
+ * or a generic platform (e.g., AdgAny, UboExtChromium, or combination of multiple products).
27
+ * @param modifier Modifier AST node.
30
28
  * @param isException Whether the modifier is used in exception rule, default to false.
31
29
  * Needed to check whether the modifier is allowed only in blocking or exception rules.
32
30
  *
31
+ * @note For single product: specific platforms use exact lookup, generic platforms use first match.
32
+ * If multiple products are specified (e.g., AdgAny | UboAny), validation is skipped and returns valid.
33
+ *
33
34
  * @returns Result of modifier validation.
34
35
  */
35
- validate: (syntax: AdblockSyntax, rawModifier: Modifier, isException?: boolean) => ValidationResult;
36
+ validate: (platforms: AnyPlatform, modifier: Modifier, isException?: boolean) => ValidationResult;
36
37
  }
37
38
  export declare const modifierValidator: ModifierValidator;
38
39
  export {};
@@ -1,5 +1,5 @@
1
1
  /*
2
- * AGTree v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 Adguard Software Ltd.
4
4
  * Released under the MIT license
5
5
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -7,6 +7,29 @@
7
7
  /**
8
8
  * @file Possible adblock syntaxes are listed here.
9
9
  */
10
+ /**
11
+ * Adblock products (specific adblockers, excludes 'Common').
12
+ */
13
+ const AdblockProduct = {
14
+ /**
15
+ * Adblock Plus.
16
+ *
17
+ * @see {@link https://adblockplus.org/}
18
+ */
19
+ Abp: 'AdblockPlus',
20
+ /**
21
+ * uBlock Origin.
22
+ *
23
+ * @see {@link https://github.com/gorhill/uBlock}
24
+ */
25
+ Ubo: 'UblockOrigin',
26
+ /**
27
+ * AdGuard.
28
+ *
29
+ * @see {@link https://adguard.com/}
30
+ */
31
+ Adg: 'AdGuard',
32
+ };
10
33
  /**
11
34
  * Possible adblock syntaxes (supported by this library)
12
35
  */
@@ -31,7 +54,7 @@ const AdblockSyntax = {
31
54
  * adblockers directly (probably supported by some on-the-fly conversion, but this is not the native syntax).
32
55
  * @see {@link https://adblockplus.org/}
33
56
  */
34
- Abp: 'AdblockPlus',
57
+ Abp: AdblockProduct.Abp,
35
58
  /**
36
59
  * uBlock Origin syntax.
37
60
  *
@@ -40,7 +63,7 @@ const AdblockSyntax = {
40
63
  * adblockers directly (probably supported by some on-the-fly conversion, but this is not the native syntax).
41
64
  * @see {@link https://github.com/gorhill/uBlock}
42
65
  */
43
- Ubo: 'UblockOrigin',
66
+ Ubo: AdblockProduct.Ubo,
44
67
  /**
45
68
  * AdGuard syntax.
46
69
  *
@@ -50,7 +73,7 @@ const AdblockSyntax = {
50
73
  * syntax).
51
74
  * @see {@link https://adguard.com/}
52
75
  */
53
- Adg: 'AdGuard',
76
+ Adg: AdblockProduct.Adg,
54
77
  };
55
78
 
56
- export { AdblockSyntax };
79
+ export { AdblockProduct, AdblockSyntax };
@@ -1,5 +1,5 @@
1
1
  /*
2
- * AGTree v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 Adguard Software Ltd.
4
4
  * Released under the MIT license
5
5
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -0,0 +1,37 @@
1
+ /*
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
+ * (c) 2025 Adguard Software Ltd.
4
+ * Released under the MIT license
5
+ * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
6
+ */
7
+ /* eslint-disable no-param-reassign, no-bitwise */
8
+ /**
9
+ * @file Utility for counting set bits in numbers.
10
+ */
11
+ /**
12
+ * Counts the number of set bits (1s) in a 32-bit number using Hamming Weight (SWAR) method.
13
+ *
14
+ * This is a fast bit counting algorithm that uses SWAR (SIMD Within A Register) technique.
15
+ * It's significantly faster than string conversion methods and works in O(1) time.
16
+ *
17
+ * @param a Number to count bits in.
18
+ *
19
+ * @returns The number of bits set to 1.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * getBitCount(0); // 0
24
+ * getBitCount(7); // 3 (0b111)
25
+ * getBitCount(0xFF); // 8 (0b11111111)
26
+ * ```
27
+ */
28
+ function getBitCount(a) {
29
+ a -= ((a >>> 1) & 0x55555555);
30
+ a = (a & 0x33333333) + ((a >>> 2) & 0x33333333);
31
+ a = (a + (a >>> 4)) & 0x0F0F0F0F;
32
+ a += (a >>> 8);
33
+ a += (a >>> 16);
34
+ return a & 0x3F;
35
+ }
36
+
37
+ export { getBitCount };
@@ -1,5 +1,5 @@
1
1
  /*
2
- * AGTree v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 Adguard Software Ltd.
4
4
  * Released under the MIT license
5
5
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -7,6 +7,7 @@
7
7
  export { ADG_SCRIPTLET_MASK, AGLINT_COMMAND_PREFIX, COMMA, COMMA_DOMAIN_LIST_SEPARATOR, HINT_MARKER, IF, INCLUDE, MODIFIERS_SEPARATOR, MODIFIER_ASSIGN_OPERATOR, NEGATION_MARKER, NETWORK_RULE_EXCEPTION_MARKER, NETWORK_RULE_SEPARATOR, PIPE, PIPE_MODIFIER_SEPARATOR, PREPROCESSOR_MARKER, SAFARI_CB_AFFINITY, UBO_SCRIPTLET_MASK } from './constants.js';
8
8
  export { BINARY_SCHEMA_VERSION } from './binary-schema-version.js';
9
9
  export { AdblockSyntax } from './adblockers.js';
10
+ export { getBitCount } from './bit-count.js';
10
11
  export { CosmeticRuleSeparatorUtils } from './cosmetic-rule-separator.js';
11
12
  export { DomainUtils } from './domain.js';
12
13
  export { LogicalExpressionUtils } from './logical-expression.js';
@@ -1,5 +1,5 @@
1
1
  /*
2
- * AGTree v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 Adguard Software Ltd.
4
4
  * Released under the MIT license
5
5
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -0,0 +1,29 @@
1
+ /*
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
+ * (c) 2025 Adguard Software Ltd.
4
+ * Released under the MIT license
5
+ * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
6
+ */
7
+ import { UNDERSCORE } from './constants.js';
8
+
9
+ /**
10
+ * Validates the noop modifier (i.e. only underscores).
11
+ *
12
+ * @param value Value of the modifier.
13
+ *
14
+ * @returns True if the modifier is valid, false otherwise.
15
+ */
16
+ const isValidNoopModifier = (value) => {
17
+ const { length } = value;
18
+ if (length === 0) {
19
+ return false;
20
+ }
21
+ for (let i = 0; i < length; i += 1) {
22
+ if (value[i] !== UNDERSCORE) {
23
+ return false;
24
+ }
25
+ }
26
+ return true;
27
+ };
28
+
29
+ export { isValidNoopModifier };
@@ -1,5 +1,5 @@
1
1
  /*
2
- * AGTree v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 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 v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 Adguard Software Ltd.
4
4
  * Released under the MIT license
5
5
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
@@ -1,21 +1,11 @@
1
1
  /*
2
- * AGTree v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 Adguard Software Ltd.
4
4
  * Released under the MIT license
5
5
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
6
6
  */
7
- import { AdblockSyntax } from '../utils/adblockers.js';
8
7
  import { CAPITAL_LETTERS, SMALL_LETTERS, NUMBERS, UNDERSCORE, OPEN_PARENTHESIS, CLOSE_PARENTHESIS } from '../utils/constants.js';
9
8
 
10
- /**
11
- * Prefixes for different adblockers to describe the platform-specific modifiers data
12
- * stored in the yaml files.
13
- */
14
- const BLOCKER_PREFIX = {
15
- [AdblockSyntax.Adg]: 'adg_',
16
- [AdblockSyntax.Ubo]: 'ubo_',
17
- [AdblockSyntax.Abp]: 'abp_',
18
- };
19
9
  /**
20
10
  * Set of all allowed characters for app name except the dot `.`.
21
11
  */
@@ -192,7 +182,7 @@ const VALIDATION_ERROR_PREFIX = {
192
182
  NOT_EXISTENT: 'Non-existent modifier',
193
183
  NOT_NEGATABLE_MODIFIER: 'Non-negatable modifier',
194
184
  NOT_NEGATABLE_VALUE: 'Values cannot be negated for the modifier',
195
- NOT_SUPPORTED: 'The adblocker does not support the modifier',
185
+ NOT_SUPPORTED: '%s does not support the modifier',
196
186
  REMOVED: 'Removed and no longer supported modifier',
197
187
  VALUE_FORBIDDEN: 'Value is not allowed for the modifier',
198
188
  VALUE_INVALID: 'Value is invalid for the modifier',
@@ -207,4 +197,4 @@ const SOURCE_DATA_ERROR_PREFIX = {
207
197
  NO_VALUE_FORMAT_FOR_ASSIGNABLE: "Property 'value_format' should be specified for the assignable modifier",
208
198
  };
209
199
 
210
- export { ALLOWED_CSP_DIRECTIVES, ALLOWED_METHODS, ALLOWED_PERMISSION_DIRECTIVES, ALLOWED_STEALTH_OPTIONS, APP_NAME_ALLOWED_CHARS, BLOCKER_PREFIX, EMPTY_PERMISSIONS_ALLOWLIST, PERMISSIONS_TOKEN_SELF, REFERRER_POLICY_DIRECTIVES, SOURCE_DATA_ERROR_PREFIX, VALIDATION_ERROR_PREFIX };
200
+ export { ALLOWED_CSP_DIRECTIVES, ALLOWED_METHODS, ALLOWED_PERMISSION_DIRECTIVES, ALLOWED_STEALTH_OPTIONS, APP_NAME_ALLOWED_CHARS, EMPTY_PERMISSIONS_ALLOWLIST, PERMISSIONS_TOKEN_SELF, REFERRER_POLICY_DIRECTIVES, SOURCE_DATA_ERROR_PREFIX, VALIDATION_ERROR_PREFIX };
@@ -1,22 +1,11 @@
1
1
  /*
2
- * AGTree v3.3.0 (build date: Thu, 20 Nov 2025 14:22:17 GMT)
2
+ * AGTree v3.4.0 (build date: Fri, 28 Nov 2025 09:46:33 GMT)
3
3
  * (c) 2025 Adguard Software Ltd.
4
4
  * Released under the MIT license
5
5
  * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
6
6
  */
7
- import { UNDERSCORE } from '../utils/constants.js';
8
7
  import { VALIDATION_ERROR_PREFIX } from './constants.js';
9
8
 
10
- /**
11
- * Validates the noop modifier (i.e. only underscores).
12
- *
13
- * @param value Value of the modifier.
14
- *
15
- * @returns True if the modifier is valid, false otherwise.
16
- */
17
- const isValidNoopModifier = (value) => {
18
- return value.split('').every((char) => char === UNDERSCORE);
19
- };
20
9
  /**
21
10
  * Returns invalid validation result with given error message.
22
11
  *
@@ -42,4 +31,4 @@ const getValueRequiredValidationResult = (modifierName) => {
42
31
  return getInvalidValidationResult(`${VALIDATION_ERROR_PREFIX.VALUE_REQUIRED}: '${modifierName}'`);
43
32
  };
44
33
 
45
- export { getInvalidValidationResult, getValueRequiredValidationResult, isValidNoopModifier };
34
+ export { getInvalidValidationResult, getValueRequiredValidationResult };