@adguard/agtree 2.2.0 → 3.0.0-alpha.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.
Files changed (495) hide show
  1. package/README.md +1 -1
  2. package/dist/ast-utils/clone.js +61 -0
  3. package/dist/ast-utils/modifiers.js +53 -0
  4. package/dist/ast-utils/network-rules.js +41 -0
  5. package/dist/ast-utils/scriptlets.js +87 -0
  6. package/dist/common/abp-snippet-injection-body-common.js +23 -0
  7. package/dist/common/agent-common.js +56 -0
  8. package/dist/common/ubo-selector-common.js +17 -0
  9. package/dist/compatibility-tables/base.js +262 -0
  10. package/dist/compatibility-tables/compatibility-table-data.js +11 -0
  11. package/dist/compatibility-tables/modifiers.js +55 -0
  12. package/dist/compatibility-tables/platforms.js +76 -0
  13. package/dist/compatibility-tables/redirects.js +100 -0
  14. package/dist/compatibility-tables/schemas/base.js +111 -0
  15. package/dist/compatibility-tables/schemas/modifier.js +129 -0
  16. package/dist/compatibility-tables/schemas/platform.js +69 -0
  17. package/dist/compatibility-tables/schemas/redirect.js +29 -0
  18. package/dist/compatibility-tables/schemas/resource-type.js +36 -0
  19. package/dist/compatibility-tables/schemas/scriptlet.js +79 -0
  20. package/dist/compatibility-tables/scriptlets.js +28 -0
  21. package/dist/compatibility-tables/utils/platform-helpers.js +105 -0
  22. package/dist/compatibility-tables/utils/resource-type-helpers.js +61 -0
  23. package/dist/compatibility-tables/utils/zod-camelcase.js +25 -0
  24. package/dist/converter/base-interfaces/base-converter.js +59 -0
  25. package/dist/converter/base-interfaces/conversion-result.js +38 -0
  26. package/dist/converter/base-interfaces/rule-converter-base.js +60 -0
  27. package/dist/converter/comment/index.js +54 -0
  28. package/dist/converter/cosmetic/css.js +69 -0
  29. package/dist/converter/cosmetic/element-hiding.js +62 -0
  30. package/dist/converter/cosmetic/header-removal.js +123 -0
  31. package/dist/converter/cosmetic/html.js +379 -0
  32. package/dist/converter/cosmetic/index.js +118 -0
  33. package/dist/converter/cosmetic/rule-modifiers/adg.js +79 -0
  34. package/dist/converter/cosmetic/scriptlet.js +354 -0
  35. package/dist/converter/css/index.js +188 -0
  36. package/dist/converter/data/css.js +126 -0
  37. package/dist/converter/filter-list.js +88 -0
  38. package/dist/converter/index.js +8 -0
  39. package/dist/converter/misc/network-rule-modifier.js +311 -0
  40. package/dist/converter/network/index.js +99 -0
  41. package/dist/converter/raw-filter-list.js +56 -0
  42. package/dist/converter/rule.js +81 -0
  43. package/dist/deserializer/base-deserializer.js +29 -0
  44. package/dist/deserializer/comment/agent-comment-deserializer.js +79 -0
  45. package/dist/deserializer/comment/agent-deserializer.js +65 -0
  46. package/dist/deserializer/comment/comment-rule-deserializer.js +54 -0
  47. package/dist/deserializer/comment/config-comment-deserializer.js +111 -0
  48. package/dist/deserializer/comment/hint-comment-deserializer.js +72 -0
  49. package/dist/deserializer/comment/hint-deserializer.js +85 -0
  50. package/dist/deserializer/comment/metadata-comment-deserializer.js +69 -0
  51. package/dist/deserializer/comment/pre-processor-comment-deserializer.js +112 -0
  52. package/dist/deserializer/comment/simple-comment-deserializer.js +65 -0
  53. package/dist/deserializer/cosmetic/cosmetic-rule-deserializer.js +131 -0
  54. package/dist/deserializer/cosmetic/css-injection-body-deserializer.js +56 -0
  55. package/dist/deserializer/cosmetic/element-hiding-body-deserializer.js +48 -0
  56. package/dist/deserializer/cosmetic/scriptlet-body/abp-snippet-injection-body-deserializer.js +39 -0
  57. package/dist/deserializer/cosmetic/scriptlet-body/adg-scriptlet-injection-body-deserializer.js +40 -0
  58. package/dist/deserializer/cosmetic/scriptlet-body/scriptlet-body-deserializer.js +54 -0
  59. package/dist/deserializer/cosmetic/scriptlet-body/ubo-scriptlet-injection-body-deserializer.js +38 -0
  60. package/dist/deserializer/empty-rule-deserializer.js +48 -0
  61. package/dist/deserializer/filterlist-deserializer.js +85 -0
  62. package/dist/deserializer/index.js +8 -0
  63. package/dist/deserializer/invalid-rule-deserializer.js +50 -0
  64. package/dist/deserializer/invalid-rule-error-node-deserializer.js +50 -0
  65. package/dist/deserializer/misc/domain-list-deserializer.js +64 -0
  66. package/dist/deserializer/misc/list-item-deserializer.js +69 -0
  67. package/dist/deserializer/misc/list-items-deserializer.js +30 -0
  68. package/dist/deserializer/misc/logical-expression-deserializer.js +196 -0
  69. package/dist/deserializer/misc/modifier-deserializer.js +87 -0
  70. package/dist/deserializer/misc/modifier-list-deserializer.js +61 -0
  71. package/dist/deserializer/misc/parameter-list-deserializer.js +64 -0
  72. package/dist/deserializer/misc/value-deserializer.js +50 -0
  73. package/dist/deserializer/network/host-rule-deserializer.js +67 -0
  74. package/dist/deserializer/network/hostname-list-deserializer.js +56 -0
  75. package/dist/deserializer/network/network-rule-deserializer.js +65 -0
  76. package/dist/deserializer/rule-deserializer.js +65 -0
  77. package/dist/deserializer/syntax-deserialization-map.js +21 -0
  78. package/dist/errors/adblock-syntax-error.js +39 -0
  79. package/dist/errors/binary-schema-mismatch-error.js +37 -0
  80. package/dist/errors/not-implemented-error.js +31 -0
  81. package/dist/errors/rule-conversion-error.js +26 -0
  82. package/dist/generator/base-generator.js +27 -0
  83. package/dist/generator/comment/agent-comment-generator.js +31 -0
  84. package/dist/generator/comment/agent-generator.js +36 -0
  85. package/dist/generator/comment/comment-rule-generator.js +47 -0
  86. package/dist/generator/comment/config-comment-generator.js +45 -0
  87. package/dist/generator/comment/hint-comment-generator.js +28 -0
  88. package/dist/generator/comment/hint-generator.js +33 -0
  89. package/dist/generator/comment/metadata-comment-generator.js +33 -0
  90. package/dist/generator/comment/pre-processor-comment-generator.js +48 -0
  91. package/dist/generator/comment/simple-comment-generator.js +29 -0
  92. package/dist/generator/cosmetic/body/abp-snippet-injection-body-generator.js +38 -0
  93. package/dist/generator/cosmetic/body/adg-scriptlet-injection-body-generator.js +43 -0
  94. package/dist/generator/cosmetic/body/ubo-scriptlet-injection-body-generator.js +45 -0
  95. package/dist/generator/cosmetic/cosmetic-rule-body-generator.js +94 -0
  96. package/dist/generator/cosmetic/cosmetic-rule-generator.js +54 -0
  97. package/dist/generator/cosmetic/cosmetic-rule-pattern-generator.js +42 -0
  98. package/dist/generator/css/adg-css-injection-generator.js +42 -0
  99. package/dist/generator/filterlist-generator.js +67 -0
  100. package/dist/generator/index.js +9 -0
  101. package/dist/generator/misc/domain-list-generator.js +26 -0
  102. package/dist/generator/misc/list-items-generator.js +39 -0
  103. package/dist/generator/misc/logical-expression-generator.js +48 -0
  104. package/dist/generator/misc/modifier-generator.js +34 -0
  105. package/dist/generator/misc/modifier-list-generator.js +29 -0
  106. package/dist/generator/misc/parameter-list-generator.js +41 -0
  107. package/dist/generator/misc/value-generator.js +24 -0
  108. package/dist/generator/network/host-rule-generator.js +39 -0
  109. package/dist/generator/network/network-rule-generator.js +38 -0
  110. package/dist/generator/rule-generator.js +65 -0
  111. package/dist/index.js +70 -0
  112. package/dist/marshalling-utils/comment/agent-comment-common.js +21 -0
  113. package/dist/marshalling-utils/comment/agent-common.js +40 -0
  114. package/dist/marshalling-utils/comment/config-comment-common.js +54 -0
  115. package/dist/marshalling-utils/comment/hint-comment-common.js +22 -0
  116. package/dist/marshalling-utils/comment/hint-common.js +56 -0
  117. package/dist/marshalling-utils/comment/metadata-comment-common.js +41 -0
  118. package/dist/marshalling-utils/comment/pre-processor-comment-common.js +59 -0
  119. package/dist/marshalling-utils/comment/simple-comment-common.js +22 -0
  120. package/dist/marshalling-utils/cosmetic/body/abp-snippet-injection-body-common.js +61 -0
  121. package/dist/marshalling-utils/cosmetic/body/adg-scriptlet-injection-body-common.js +66 -0
  122. package/dist/marshalling-utils/cosmetic/body/css-injection-body-common.js +24 -0
  123. package/dist/marshalling-utils/cosmetic/body/element-hiding-body-common.js +21 -0
  124. package/dist/marshalling-utils/cosmetic/body/ubo-scriptlet-injection-body-common.js +114 -0
  125. package/dist/marshalling-utils/cosmetic/cosmetic-rule-common.js +48 -0
  126. package/dist/marshalling-utils/empty-rule-common.js +20 -0
  127. package/dist/marshalling-utils/filter-list-common.js +21 -0
  128. package/dist/marshalling-utils/invalid-rule-common.js +21 -0
  129. package/dist/marshalling-utils/invalid-rule-error-node-common.js +22 -0
  130. package/dist/marshalling-utils/misc/binary-type-common.js +66 -0
  131. package/dist/marshalling-utils/misc/domain-list-common.js +36 -0
  132. package/dist/marshalling-utils/misc/host-rule-common.js +25 -0
  133. package/dist/marshalling-utils/misc/hostname-list-common.js +21 -0
  134. package/dist/marshalling-utils/misc/list-item-common.js +22 -0
  135. package/dist/marshalling-utils/misc/logical-expression-common.js +83 -0
  136. package/dist/marshalling-utils/misc/modifier-common.js +231 -0
  137. package/dist/marshalling-utils/misc/modifier-list-common.js +21 -0
  138. package/dist/marshalling-utils/misc/parameter-list-common.js +21 -0
  139. package/dist/marshalling-utils/misc/value-common.js +22 -0
  140. package/dist/marshalling-utils/network/network-rule-common.js +25 -0
  141. package/dist/marshalling-utils/syntax-serialization-map.js +30 -0
  142. package/dist/nodes/index.js +168 -0
  143. package/dist/package.json.js +9 -0
  144. package/dist/parser/base-parser.js +30 -0
  145. package/dist/parser/comment/agent-comment-parser.js +119 -0
  146. package/dist/parser/comment/agent-parser.js +110 -0
  147. package/dist/parser/comment/comment-parser.js +108 -0
  148. package/dist/parser/comment/config-comment-parser.js +137 -0
  149. package/dist/parser/comment/hint-comment-parser.js +117 -0
  150. package/dist/parser/comment/hint-parser.js +129 -0
  151. package/dist/parser/comment/metadata-comment-parser.js +129 -0
  152. package/dist/parser/comment/preprocessor-parser.js +199 -0
  153. package/dist/parser/comment/simple-comment-parser.js +106 -0
  154. package/dist/parser/cosmetic/body/abp-snippet-injection-body-parser.js +79 -0
  155. package/dist/parser/cosmetic/body/adg-scriptlet-injection-body-parser.js +149 -0
  156. package/dist/parser/cosmetic/body/ubo-scriptlet-injection-body-parser.js +110 -0
  157. package/dist/parser/cosmetic/cosmetic-rule-parser.js +453 -0
  158. package/dist/parser/css/adg-css-injection-parser.js +208 -0
  159. package/dist/parser/css/balancing.js +94 -0
  160. package/dist/parser/css/constants.js +18 -0
  161. package/dist/parser/css/css-token-stream.js +343 -0
  162. package/dist/parser/css/ubo-selector-parser.js +369 -0
  163. package/dist/parser/filterlist-parser.js +102 -0
  164. package/dist/parser/index.js +12 -0
  165. package/dist/parser/misc/app-list-parser.js +45 -0
  166. package/dist/parser/misc/domain-list-parser.js +52 -0
  167. package/dist/parser/misc/list-items-parser.js +116 -0
  168. package/dist/parser/misc/logical-expression-parser.js +279 -0
  169. package/dist/parser/misc/method-list-parser.js +46 -0
  170. package/dist/parser/misc/modifier-list.js +70 -0
  171. package/dist/parser/misc/modifier-parser.js +89 -0
  172. package/dist/parser/misc/parameter-list-parser.js +75 -0
  173. package/dist/parser/misc/stealth-option-list-parser.js +46 -0
  174. package/dist/parser/misc/ubo-parameter-list-parser.js +149 -0
  175. package/dist/parser/misc/value-parser.js +37 -0
  176. package/dist/parser/network/host-rule-parser.js +130 -0
  177. package/dist/parser/network/network-rule-parser.js +117 -0
  178. package/dist/parser/options.js +23 -0
  179. package/dist/parser/rule-parser.js +192 -0
  180. package/dist/serializer/base-serializer.js +29 -0
  181. package/dist/serializer/comment/agent-comment-serializer.js +74 -0
  182. package/dist/serializer/comment/agent-serializer.js +59 -0
  183. package/dist/serializer/comment/comment-rule-serializer.js +105 -0
  184. package/dist/serializer/comment/config-comment-serializer.js +82 -0
  185. package/dist/serializer/comment/hint-comment-serializer.js +65 -0
  186. package/dist/serializer/comment/hint-serializer.js +54 -0
  187. package/dist/serializer/comment/metadata-comment-serializer.js +73 -0
  188. package/dist/serializer/comment/pre-processor-comment-serializer.js +71 -0
  189. package/dist/serializer/comment/simple-comment-serializer.js +52 -0
  190. package/dist/serializer/cosmetic/body/abp-snippet-injection-body-serializer.js +36 -0
  191. package/dist/serializer/cosmetic/body/adg-scriptlet-injection-body-serializer.js +36 -0
  192. package/dist/serializer/cosmetic/body/scriptlet-body-serializer.js +50 -0
  193. package/dist/serializer/cosmetic/body/ubo-scriptlet-injection-body-serializer.js +36 -0
  194. package/dist/serializer/cosmetic/cosmetic-rule-serializer.js +120 -0
  195. package/dist/serializer/cosmetic/css-injection-body-serializer.js +51 -0
  196. package/dist/serializer/cosmetic/element-hiding-body-serializer.js +40 -0
  197. package/dist/serializer/empty-rule-serializer.js +37 -0
  198. package/dist/serializer/filterlist-serializer.js +45 -0
  199. package/dist/serializer/index.js +7 -0
  200. package/dist/serializer/invalid-rule-error-node-serializer.js +41 -0
  201. package/dist/serializer/invalid-rule-serializer.js +40 -0
  202. package/dist/serializer/misc/domain-list-serializer.js +64 -0
  203. package/dist/serializer/misc/list-item-serializer.js +58 -0
  204. package/dist/serializer/misc/list-items-serializer.js +29 -0
  205. package/dist/serializer/misc/logical-expression-serializer.js +136 -0
  206. package/dist/serializer/misc/modifier-list-serializer.js +58 -0
  207. package/dist/serializer/misc/modifier-serializer.js +49 -0
  208. package/dist/serializer/misc/parameter-list-serializer.js +52 -0
  209. package/dist/serializer/misc/value-serializer.js +50 -0
  210. package/dist/serializer/network/host-rule-serializer.js +70 -0
  211. package/dist/serializer/network/hostname-list-serializer.js +53 -0
  212. package/dist/serializer/network/network-rule-serializer.js +54 -0
  213. package/dist/serializer/rule-serializer.js +61 -0
  214. package/dist/types/ast-utils/clone.d.ts +26 -0
  215. package/dist/types/ast-utils/filter-list.d.ts +11 -0
  216. package/dist/types/ast-utils/modifiers.d.ts +20 -0
  217. package/dist/types/ast-utils/network-rules.d.ts +15 -0
  218. package/dist/types/ast-utils/scriptlets.d.ts +52 -0
  219. package/dist/types/common/abp-snippet-injection-body-common.d.ts +15 -0
  220. package/dist/types/common/agent-common.d.ts +10 -0
  221. package/dist/types/common/ubo-selector-common.d.ts +10 -0
  222. package/dist/types/compatibility-tables/base.d.ts +157 -0
  223. package/dist/types/compatibility-tables/compatibility-table-data.d.ts +68 -0
  224. package/dist/types/compatibility-tables/index.d.ts +13 -0
  225. package/dist/types/compatibility-tables/modifiers.d.ts +22 -0
  226. package/dist/types/compatibility-tables/platforms.d.ts +49 -0
  227. package/dist/types/compatibility-tables/redirects.d.ts +33 -0
  228. package/dist/types/compatibility-tables/schemas/base.d.ts +124 -0
  229. package/dist/types/compatibility-tables/schemas/index.d.ts +8 -0
  230. package/dist/types/compatibility-tables/schemas/modifier.d.ts +36 -0
  231. package/dist/types/compatibility-tables/schemas/platform.d.ts +16 -0
  232. package/dist/types/compatibility-tables/schemas/redirect.d.ts +25 -0
  233. package/dist/types/compatibility-tables/schemas/resource-type.d.ts +41 -0
  234. package/dist/types/compatibility-tables/schemas/scriptlet.d.ts +31 -0
  235. package/dist/types/compatibility-tables/scriptlets.d.ts +15 -0
  236. package/dist/types/compatibility-tables/types.d.ts +34 -0
  237. package/dist/types/compatibility-tables/utils/platform-helpers.d.ts +44 -0
  238. package/dist/types/compatibility-tables/utils/resource-type-helpers.d.ts +20 -0
  239. package/dist/types/compatibility-tables/utils/zod-camelcase.d.ts +15 -0
  240. package/dist/types/converter/base-interfaces/base-converter.d.ts +42 -0
  241. package/dist/types/converter/base-interfaces/conversion-result.d.ts +43 -0
  242. package/dist/types/converter/base-interfaces/rule-converter-base.d.ts +44 -0
  243. package/dist/types/converter/comment/index.d.ts +23 -0
  244. package/dist/types/converter/cosmetic/css.d.ts +23 -0
  245. package/dist/types/converter/cosmetic/element-hiding.d.ts +23 -0
  246. package/dist/types/converter/cosmetic/header-removal.d.ts +37 -0
  247. package/dist/types/converter/cosmetic/html.d.ts +54 -0
  248. package/dist/types/converter/cosmetic/index.d.ts +33 -0
  249. package/dist/types/converter/cosmetic/rule-modifiers/adg.d.ts +21 -0
  250. package/dist/types/converter/cosmetic/scriptlet.d.ts +33 -0
  251. package/dist/types/converter/css/index.d.ts +40 -0
  252. package/dist/types/converter/data/css.d.ts +48 -0
  253. package/dist/types/converter/filter-list.d.ts +31 -0
  254. package/dist/types/converter/index.d.ts +5 -0
  255. package/dist/types/converter/misc/network-rule-modifier.d.ts +35 -0
  256. package/dist/types/converter/network/index.d.ts +33 -0
  257. package/dist/types/converter/raw-filter-list.d.ts +31 -0
  258. package/dist/types/converter/raw-rule.d.ts +28 -0
  259. package/dist/types/converter/rule.d.ts +37 -0
  260. package/dist/types/deserializer/base-deserializer.d.ts +15 -0
  261. package/dist/types/deserializer/comment/agent-comment-deserializer.d.ts +34 -0
  262. package/dist/types/deserializer/comment/agent-deserializer.d.ts +25 -0
  263. package/dist/types/deserializer/comment/comment-rule-deserializer.d.ts +16 -0
  264. package/dist/types/deserializer/comment/config-comment-deserializer.d.ts +27 -0
  265. package/dist/types/deserializer/comment/hint-comment-deserializer.d.ts +24 -0
  266. package/dist/types/deserializer/comment/hint-deserializer.d.ts +26 -0
  267. package/dist/types/deserializer/comment/metadata-comment-deserializer.d.ts +26 -0
  268. package/dist/types/deserializer/comment/pre-processor-comment-deserializer.d.ts +29 -0
  269. package/dist/types/deserializer/comment/simple-comment-deserializer.d.ts +26 -0
  270. package/dist/types/deserializer/cosmetic/cosmetic-rule-deserializer.d.ts +18 -0
  271. package/dist/types/deserializer/cosmetic/css-injection-body-deserializer.d.ts +15 -0
  272. package/dist/types/deserializer/cosmetic/element-hiding-body-deserializer.d.ts +16 -0
  273. package/dist/types/deserializer/cosmetic/scriptlet-body/abp-snippet-injection-body-deserializer.d.ts +17 -0
  274. package/dist/types/deserializer/cosmetic/scriptlet-body/adg-scriptlet-injection-body-deserializer.d.ts +18 -0
  275. package/dist/types/deserializer/cosmetic/scriptlet-body/scriptlet-body-deserializer.d.ts +19 -0
  276. package/dist/types/deserializer/cosmetic/scriptlet-body/ubo-scriptlet-injection-body-deserializer.d.ts +17 -0
  277. package/dist/types/deserializer/empty-rule-deserializer.d.ts +16 -0
  278. package/dist/types/deserializer/filterlist-deserializer.d.ts +34 -0
  279. package/dist/types/deserializer/index.d.ts +2 -0
  280. package/dist/types/deserializer/invalid-rule-deserializer.d.ts +16 -0
  281. package/dist/types/deserializer/invalid-rule-error-node-deserializer.d.ts +16 -0
  282. package/dist/types/deserializer/misc/domain-list-deserializer.d.ts +15 -0
  283. package/dist/types/deserializer/misc/list-item-deserializer.d.ts +19 -0
  284. package/dist/types/deserializer/misc/list-items-deserializer.d.ts +16 -0
  285. package/dist/types/deserializer/misc/logical-expression-deserializer.d.ts +55 -0
  286. package/dist/types/deserializer/misc/modifier-deserializer.d.ts +18 -0
  287. package/dist/types/deserializer/misc/modifier-list-deserializer.d.ts +20 -0
  288. package/dist/types/deserializer/misc/parameter-list-deserializer.d.ts +18 -0
  289. package/dist/types/deserializer/misc/value-deserializer.d.ts +17 -0
  290. package/dist/types/deserializer/network/host-rule-deserializer.d.ts +18 -0
  291. package/dist/types/deserializer/network/hostname-list-deserializer.d.ts +15 -0
  292. package/dist/types/deserializer/network/network-rule-deserializer.d.ts +18 -0
  293. package/dist/types/deserializer/rule-deserializer.d.ts +17 -0
  294. package/dist/types/deserializer/syntax-deserialization-map.d.ts +2 -0
  295. package/dist/types/errors/adblock-syntax-error.d.ts +25 -0
  296. package/dist/types/errors/binary-schema-mismatch-error.d.ts +23 -0
  297. package/dist/types/errors/not-implemented-error.d.ts +14 -0
  298. package/dist/types/errors/rule-conversion-error.d.ts +14 -0
  299. package/dist/types/generator/base-generator.d.ts +12 -0
  300. package/dist/types/generator/comment/agent-comment-generator.d.ts +14 -0
  301. package/dist/types/generator/comment/agent-generator.d.ts +15 -0
  302. package/dist/types/generator/comment/comment-rule-generator.d.ts +14 -0
  303. package/dist/types/generator/comment/config-comment-generator.d.ts +14 -0
  304. package/dist/types/generator/comment/hint-comment-generator.d.ts +14 -0
  305. package/dist/types/generator/comment/hint-generator.d.ts +14 -0
  306. package/dist/types/generator/comment/index.d.ts +1 -0
  307. package/dist/types/generator/comment/metadata-comment-generator.d.ts +14 -0
  308. package/dist/types/generator/comment/pre-processor-comment-generator.d.ts +14 -0
  309. package/dist/types/generator/comment/simple-comment-generator.d.ts +14 -0
  310. package/dist/types/generator/cosmetic/body/abp-snippet-injection-body-generator.d.ts +15 -0
  311. package/dist/types/generator/cosmetic/body/adg-scriptlet-injection-body-generator.d.ts +21 -0
  312. package/dist/types/generator/cosmetic/body/ubo-scriptlet-injection-body-generator.d.ts +21 -0
  313. package/dist/types/generator/cosmetic/cosmetic-rule-body-generator.d.ts +20 -0
  314. package/dist/types/generator/cosmetic/cosmetic-rule-generator.d.ts +28 -0
  315. package/dist/types/generator/cosmetic/cosmetic-rule-pattern-generator.d.ts +18 -0
  316. package/dist/types/generator/cosmetic/index.d.ts +1 -0
  317. package/dist/types/generator/css/adg-css-injection-generator.d.ts +15 -0
  318. package/dist/types/generator/css/ubo-selector-generator.d.ts +14 -0
  319. package/dist/types/generator/filterlist-generator.d.ts +18 -0
  320. package/dist/types/generator/index.d.ts +3 -0
  321. package/dist/types/generator/misc/domain-list-generator.d.ts +15 -0
  322. package/dist/types/generator/misc/list-items-generator.d.ts +25 -0
  323. package/dist/types/generator/misc/logical-expression-generator.d.ts +14 -0
  324. package/dist/types/generator/misc/modifier-generator.d.ts +14 -0
  325. package/dist/types/generator/misc/modifier-list-generator.d.ts +14 -0
  326. package/dist/types/generator/misc/parameter-list-generator.d.ts +15 -0
  327. package/dist/types/generator/misc/value-generator.d.ts +14 -0
  328. package/dist/types/generator/network/host-rule-generator.d.ts +14 -0
  329. package/dist/types/generator/network/index.d.ts +2 -0
  330. package/dist/types/generator/network/network-rule-generator.d.ts +14 -0
  331. package/dist/types/generator/rule-generator.d.ts +24 -0
  332. package/dist/types/index.d.ts +55 -0
  333. package/dist/types/marshalling-utils/comment/agent-comment-common.d.ts +14 -0
  334. package/dist/types/marshalling-utils/comment/agent-common.d.ts +20 -0
  335. package/dist/types/marshalling-utils/comment/config-comment-common.d.ts +42 -0
  336. package/dist/types/marshalling-utils/comment/hint-comment-common.d.ts +15 -0
  337. package/dist/types/marshalling-utils/comment/hint-common.d.ts +33 -0
  338. package/dist/types/marshalling-utils/comment/metadata-comment-common.d.ts +21 -0
  339. package/dist/types/marshalling-utils/comment/pre-processor-comment-common.d.ts +37 -0
  340. package/dist/types/marshalling-utils/comment/simple-comment-common.d.ts +15 -0
  341. package/dist/types/marshalling-utils/cosmetic/body/abp-snippet-injection-body-common.d.ts +23 -0
  342. package/dist/types/marshalling-utils/cosmetic/body/adg-scriptlet-injection-body-common.d.ts +9 -0
  343. package/dist/types/marshalling-utils/cosmetic/body/css-injection-body-common.d.ts +17 -0
  344. package/dist/types/marshalling-utils/cosmetic/body/element-hiding-body-common.d.ts +14 -0
  345. package/dist/types/marshalling-utils/cosmetic/body/ubo-scriptlet-injection-body-common.d.ts +9 -0
  346. package/dist/types/marshalling-utils/cosmetic/cosmetic-rule-common.d.ts +28 -0
  347. package/dist/types/marshalling-utils/empty-rule-common.d.ts +13 -0
  348. package/dist/types/marshalling-utils/filter-list-common.d.ts +14 -0
  349. package/dist/types/marshalling-utils/invalid-rule-common.d.ts +14 -0
  350. package/dist/types/marshalling-utils/invalid-rule-error-node-common.d.ts +15 -0
  351. package/dist/types/marshalling-utils/misc/binary-type-common.d.ts +57 -0
  352. package/dist/types/marshalling-utils/misc/domain-list-common.d.ts +24 -0
  353. package/dist/types/marshalling-utils/misc/host-rule-common.d.ts +18 -0
  354. package/dist/types/marshalling-utils/misc/hostname-list-common.d.ts +14 -0
  355. package/dist/types/marshalling-utils/misc/list-item-common.d.ts +15 -0
  356. package/dist/types/marshalling-utils/misc/logical-expression-common.d.ts +47 -0
  357. package/dist/types/marshalling-utils/misc/modifier-common.d.ts +41 -0
  358. package/dist/types/marshalling-utils/misc/modifier-list-common.d.ts +14 -0
  359. package/dist/types/marshalling-utils/misc/parameter-list-common.d.ts +14 -0
  360. package/dist/types/marshalling-utils/misc/value-common.d.ts +15 -0
  361. package/dist/types/marshalling-utils/network/network-rule-common.d.ts +18 -0
  362. package/dist/types/marshalling-utils/syntax-serialization-map.d.ts +2 -0
  363. package/dist/types/nodes/index.d.ts +1183 -0
  364. package/dist/types/parser/base-parser.d.ts +16 -0
  365. package/dist/types/parser/comment/agent-comment-parser.d.ts +42 -0
  366. package/dist/types/parser/comment/agent-parser.d.ts +33 -0
  367. package/dist/types/parser/comment/comment-parser.d.ts +76 -0
  368. package/dist/types/parser/comment/config-comment-parser.d.ts +31 -0
  369. package/dist/types/parser/comment/hint-comment-parser.d.ts +33 -0
  370. package/dist/types/parser/comment/hint-parser.d.ts +30 -0
  371. package/dist/types/parser/comment/metadata-comment-parser.d.ts +29 -0
  372. package/dist/types/parser/comment/preprocessor-parser.d.ts +43 -0
  373. package/dist/types/parser/comment/simple-comment-parser.d.ts +33 -0
  374. package/dist/types/parser/cosmetic/body/abp-snippet-injection-body-parser.d.ts +34 -0
  375. package/dist/types/parser/cosmetic/body/adg-scriptlet-injection-body-parser.d.ts +47 -0
  376. package/dist/types/parser/cosmetic/body/ubo-scriptlet-injection-body-parser.d.ts +44 -0
  377. package/dist/types/parser/cosmetic/cosmetic-rule-parser.d.ts +51 -0
  378. package/dist/types/parser/css/adg-css-injection-parser.d.ts +28 -0
  379. package/dist/types/parser/css/balancing.d.ts +36 -0
  380. package/dist/types/parser/css/constants.d.ts +10 -0
  381. package/dist/types/parser/css/css-token-stream.d.ts +210 -0
  382. package/dist/types/parser/css/ubo-selector-parser.d.ts +46 -0
  383. package/dist/types/parser/filterlist-parser.d.ts +29 -0
  384. package/dist/types/parser/index.d.ts +6 -0
  385. package/dist/types/parser/misc/app-list-parser.d.ts +22 -0
  386. package/dist/types/parser/misc/domain-list-parser.d.ts +26 -0
  387. package/dist/types/parser/misc/list-items-parser.d.ts +37 -0
  388. package/dist/types/parser/misc/logical-expression-parser.d.ts +42 -0
  389. package/dist/types/parser/misc/method-list-parser.d.ts +22 -0
  390. package/dist/types/parser/misc/modifier-list.d.ts +24 -0
  391. package/dist/types/parser/misc/modifier-parser.d.ts +21 -0
  392. package/dist/types/parser/misc/parameter-list-parser.d.ts +17 -0
  393. package/dist/types/parser/misc/stealth-option-list-parser.d.ts +22 -0
  394. package/dist/types/parser/misc/ubo-parameter-list-parser.d.ts +21 -0
  395. package/dist/types/parser/misc/value-parser.d.ts +18 -0
  396. package/dist/types/parser/network/host-rule-parser.d.ts +35 -0
  397. package/dist/types/parser/network/network-rule-parser.d.ts +31 -0
  398. package/dist/types/parser/options.d.ts +41 -0
  399. package/dist/types/parser/rule-parser.d.ts +78 -0
  400. package/dist/types/serializer/base-serializer.d.ts +15 -0
  401. package/dist/types/serializer/comment/agent-comment-serializer.d.ts +34 -0
  402. package/dist/types/serializer/comment/agent-serializer.d.ts +15 -0
  403. package/dist/types/serializer/comment/comment-rule-serializer.d.ts +68 -0
  404. package/dist/types/serializer/comment/config-comment-serializer.d.ts +25 -0
  405. package/dist/types/serializer/comment/hint-comment-serializer.d.ts +23 -0
  406. package/dist/types/serializer/comment/hint-serializer.d.ts +24 -0
  407. package/dist/types/serializer/comment/metadata-comment-serializer.d.ts +25 -0
  408. package/dist/types/serializer/comment/pre-processor-comment-serializer.d.ts +28 -0
  409. package/dist/types/serializer/comment/simple-comment-serializer.d.ts +24 -0
  410. package/dist/types/serializer/cosmetic/body/abp-snippet-injection-body-serializer.d.ts +25 -0
  411. package/dist/types/serializer/cosmetic/body/adg-scriptlet-injection-body-serializer.d.ts +25 -0
  412. package/dist/types/serializer/cosmetic/body/scriptlet-body-serializer.d.ts +17 -0
  413. package/dist/types/serializer/cosmetic/body/ubo-scriptlet-injection-body-serializer.d.ts +25 -0
  414. package/dist/types/serializer/cosmetic/cosmetic-rule-serializer.d.ts +19 -0
  415. package/dist/types/serializer/cosmetic/css-injection-body-serializer.d.ts +15 -0
  416. package/dist/types/serializer/cosmetic/element-hiding-body-serializer.d.ts +15 -0
  417. package/dist/types/serializer/empty-rule-serializer.d.ts +15 -0
  418. package/dist/types/serializer/filterlist-serializer.d.ts +15 -0
  419. package/dist/types/serializer/index.d.ts +1 -0
  420. package/dist/types/serializer/invalid-rule-error-node-serializer.d.ts +15 -0
  421. package/dist/types/serializer/invalid-rule-serializer.d.ts +15 -0
  422. package/dist/types/serializer/misc/domain-list-serializer.d.ts +21 -0
  423. package/dist/types/serializer/misc/list-item-serializer.d.ts +16 -0
  424. package/dist/types/serializer/misc/list-items-serializer.d.ts +15 -0
  425. package/dist/types/serializer/misc/logical-expression-serializer.d.ts +52 -0
  426. package/dist/types/serializer/misc/modifier-list-serializer.d.ts +20 -0
  427. package/dist/types/serializer/misc/modifier-serializer.d.ts +18 -0
  428. package/dist/types/serializer/misc/parameter-list-serializer.d.ts +17 -0
  429. package/dist/types/serializer/misc/value-serializer.d.ts +17 -0
  430. package/dist/types/serializer/network/host-rule-serializer.d.ts +30 -0
  431. package/dist/types/serializer/network/hostname-list-serializer.d.ts +15 -0
  432. package/dist/types/serializer/network/network-rule-serializer.d.ts +18 -0
  433. package/dist/types/serializer/rule-serializer.d.ts +17 -0
  434. package/dist/types/utils/adblockers.d.ts +49 -0
  435. package/dist/types/utils/binary-schema-version.d.ts +9 -0
  436. package/dist/types/utils/byte-buffer.d.ts +54 -0
  437. package/dist/types/utils/categorizer.d.ts +14 -0
  438. package/dist/types/utils/clone.d.ts +15 -0
  439. package/dist/types/utils/constants.d.ts +188 -0
  440. package/dist/types/utils/cosmetic-rule-separator.d.ts +45 -0
  441. package/dist/types/utils/deep-freeze.d.ts +13 -0
  442. package/dist/types/utils/domain.d.ts +29 -0
  443. package/dist/types/utils/error.d.ts +8 -0
  444. package/dist/types/utils/index.d.ts +15 -0
  445. package/dist/types/utils/input-byte-buffer.d.ts +146 -0
  446. package/dist/types/utils/is-chromium.d.ts +7 -0
  447. package/dist/types/utils/logical-expression.d.ts +45 -0
  448. package/dist/types/utils/multi-value-map.d.ts +16 -0
  449. package/dist/types/utils/output-byte-buffer.d.ts +132 -0
  450. package/dist/types/utils/position-provider.d.ts +46 -0
  451. package/dist/types/utils/quotes.d.ts +94 -0
  452. package/dist/types/utils/regexp.d.ts +54 -0
  453. package/dist/types/utils/storage-interface.d.ts +23 -0
  454. package/dist/types/utils/string.d.ts +280 -0
  455. package/dist/types/utils/text-decoder-polyfill.d.ts +14 -0
  456. package/dist/types/utils/text-encoder-polyfill.d.ts +18 -0
  457. package/dist/types/utils/type-guards.d.ts +47 -0
  458. package/dist/types/validator/constants.d.ts +89 -0
  459. package/dist/types/validator/helpers.d.ts +37 -0
  460. package/dist/types/validator/index.d.ts +38 -0
  461. package/dist/types/validator/value.d.ts +12 -0
  462. package/dist/types/version.d.ts +5 -0
  463. package/dist/utils/adblockers.js +56 -0
  464. package/dist/utils/binary-schema-version.js +17 -0
  465. package/dist/utils/byte-buffer.js +91 -0
  466. package/dist/utils/categorizer.js +44 -0
  467. package/dist/utils/clone.js +28 -0
  468. package/dist/utils/constants.js +249 -0
  469. package/dist/utils/cosmetic-rule-separator.js +127 -0
  470. package/dist/utils/deep-freeze.js +32 -0
  471. package/dist/utils/domain.js +59 -0
  472. package/dist/utils/error.js +49 -0
  473. package/dist/utils/index.js +21 -0
  474. package/dist/utils/input-byte-buffer.js +265 -0
  475. package/dist/utils/is-chromium.js +20 -0
  476. package/dist/utils/logical-expression.js +92 -0
  477. package/dist/utils/multi-value-map.js +33 -0
  478. package/dist/utils/output-byte-buffer.js +231 -0
  479. package/dist/utils/position-provider.js +73 -0
  480. package/dist/utils/quotes.js +214 -0
  481. package/dist/utils/regexp.js +176 -0
  482. package/dist/utils/string.js +559 -0
  483. package/dist/utils/text-decoder-polyfill.js +107 -0
  484. package/dist/utils/text-encoder-polyfill.js +78 -0
  485. package/dist/utils/type-guards.js +47 -0
  486. package/dist/validator/constants.js +210 -0
  487. package/dist/validator/helpers.js +45 -0
  488. package/dist/validator/index.js +174 -0
  489. package/dist/validator/value.js +568 -0
  490. package/dist/version.js +18 -0
  491. package/package.json +61 -39
  492. package/dist/agtree.d.ts +0 -4155
  493. package/dist/agtree.js +0 -15819
  494. package/dist/agtree.mjs +0 -15720
  495. package/dist/compatibility-table-data.js +0 -12782
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @file Converter for request header removal rules
3
+ */
4
+ import { type AnyRule } from '../../nodes';
5
+ import { RuleConverterBase } from '../base-interfaces/rule-converter-base';
6
+ import { type NodeConversionResult } from '../base-interfaces/conversion-result';
7
+ export declare const ERROR_MESSAGES: {
8
+ EMPTY_PARAMETER: string;
9
+ EXPECTED_END_OF_RULE: string;
10
+ MULTIPLE_DOMAINS_NOT_SUPPORTED: string;
11
+ };
12
+ /**
13
+ * Converter for request header removal rules
14
+ *
15
+ * @todo Implement `convertToUbo` (ABP currently doesn't support header removal rules)
16
+ */
17
+ export declare class HeaderRemovalRuleConverter extends RuleConverterBase {
18
+ /**
19
+ * Converts a header removal rule to AdGuard syntax, if possible.
20
+ *
21
+ * @param rule Rule node to convert
22
+ * @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
23
+ * the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
24
+ * If the rule was not converted, the result array will contain the original node with the same object reference
25
+ * @throws If the rule is invalid or cannot be converted
26
+ * @example
27
+ * If the input rule is:
28
+ * ```adblock
29
+ * example.com##^responseheader(header-name)
30
+ * ```
31
+ * The output will be:
32
+ * ```adblock
33
+ * ||example.com^$removeheader=header-name
34
+ * ```
35
+ */
36
+ static convertToAdg(rule: AnyRule): NodeConversionResult<AnyRule>;
37
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @file HTML filtering rule converter
3
+ */
4
+ import { type HtmlFilteringRule } from '../../nodes';
5
+ import { RuleConverterBase } from '../base-interfaces/rule-converter-base';
6
+ import { type NodeConversionResult } from '../base-interfaces/conversion-result';
7
+ export declare const ERROR_MESSAGES: {
8
+ ABP_NOT_SUPPORTED: string;
9
+ TAG_SHOULD_BE_FIRST_CHILD: string;
10
+ EXPECTED_BUT_GOT_WITH_VALUE: string;
11
+ INVALID_ATTRIBUTE_NAME: string;
12
+ INVALID_ATTRIBUTE_VALUE: string;
13
+ INVALID_FLAG: string;
14
+ INVALID_OPERATOR_FOR_ATTR: string;
15
+ VALUE_FOR_ATTR_SHOULD_BE_INT: string;
16
+ INVALID_PSEUDO_CLASS: string;
17
+ VALUE_FOR_PSEUDO_CLASS_SHOULD_BE_INT: string;
18
+ REGEXP_NOT_SUPPORTED: string;
19
+ ATTRIBUTE_SELECTOR_REQUIRES_VALUE: string;
20
+ INVALID_ATTRIBUTE_SELECTOR_OPERATOR: string;
21
+ VALUE_SHOULD_BE_SPECIFIED: string;
22
+ OPERATOR_SHOULD_BE_SPECIFIED: string;
23
+ UNEXPECTED_TOKEN_WITH_VALUE: string;
24
+ FLAGS_NOT_SUPPORTED: string;
25
+ };
26
+ /**
27
+ * HTML filtering rule converter class
28
+ *
29
+ * @todo Implement `convertToUbo` (ABP currently doesn't support HTML filtering rules)
30
+ */
31
+ export declare class HtmlRuleConverter extends RuleConverterBase {
32
+ /**
33
+ * Converts a HTML rule to AdGuard syntax, if possible. Also can be used to convert
34
+ * AdGuard rules to AdGuard syntax to validate them.
35
+ *
36
+ * _Note:_ uBlock Origin supports multiple selectors within a single rule, but AdGuard doesn't,
37
+ * so the following rule
38
+ * ```
39
+ * example.com##^div[attr1="value1"][attr2="value2"], script:has-text(value)
40
+ * ```
41
+ * will be converted to multiple AdGuard rules:
42
+ * ```
43
+ * example.com$$div[attr1="value1"][attr2="value2"][max-length="262144"]
44
+ * example.com$$script[tag-content="value"][max-length="262144"]
45
+ * ```
46
+ *
47
+ * @param rule Rule node to convert
48
+ * @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
49
+ * the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
50
+ * If the rule was not converted, the result array will contain the original node with the same object reference
51
+ * @throws If the rule is invalid or cannot be converted
52
+ */
53
+ static convertToAdg(rule: HtmlFilteringRule): NodeConversionResult<HtmlFilteringRule>;
54
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @file Cosmetic rule converter
3
+ */
4
+ import { type AnyCosmeticRule, type AnyRule } from '../../nodes';
5
+ import { RuleConverterBase } from '../base-interfaces/rule-converter-base';
6
+ import { type NodeConversionResult } from '../base-interfaces/conversion-result';
7
+ /**
8
+ * Cosmetic rule converter class (also known as "non-basic rule converter")
9
+ *
10
+ * @todo Implement `convertToUbo` and `convertToAbp`
11
+ */
12
+ export declare class CosmeticRuleConverter extends RuleConverterBase {
13
+ /**
14
+ * Converts a cosmetic rule to AdGuard syntax, if possible.
15
+ *
16
+ * @param rule Rule node to convert
17
+ * @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
18
+ * the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
19
+ * If the rule was not converted, the result array will contain the original node with the same object reference
20
+ * @throws If the rule is invalid or cannot be converted
21
+ */
22
+ static convertToAdg(rule: AnyCosmeticRule): NodeConversionResult<AnyRule>;
23
+ /**
24
+ * Converts a cosmetic rule to uBlock Origin syntax, if possible.
25
+ *
26
+ * @param rule Rule node to convert
27
+ * @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
28
+ * the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
29
+ * If the rule was not converted, the result array will contain the original node with the same object reference
30
+ * @throws If the rule is invalid or cannot be converted
31
+ */
32
+ static convertToUbo(rule: AnyCosmeticRule): NodeConversionResult<AnyRule>;
33
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @file Cosmetic rule modifier converter from uBO to ADG
3
+ */
4
+ import { type ModifierList } from '../../../nodes';
5
+ import { type ConversionResult } from '../../base-interfaces/conversion-result';
6
+ /**
7
+ * Helper class for converting cosmetic rule modifiers from uBO to ADG
8
+ */
9
+ export declare class AdgCosmeticRuleModifierConverter {
10
+ /**
11
+ * Converts a uBO cosmetic rule modifier list to ADG, if possible.
12
+ *
13
+ * @param modifierList Cosmetic rule modifier list node to convert
14
+ * @returns An object which follows the {@link ConversionResult} interface. Its `result` property contains
15
+ * the converted node, and its `isConverted` flag indicates whether the original node was converted.
16
+ * If the node was not converted, the result will contain the original node with the same object reference
17
+ * @throws If the modifier list cannot be converted
18
+ * @see {@link https://github.com/gorhill/uBlock/wiki/Procedural-cosmetic-filters#cosmetic-filter-operators}
19
+ */
20
+ static convertFromUbo(modifierList: ModifierList): ConversionResult<ModifierList>;
21
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @file Scriptlet injection rule converter
3
+ */
4
+ import { type ScriptletInjectionRule } from '../../nodes';
5
+ import { RuleConverterBase } from '../base-interfaces/rule-converter-base';
6
+ import { type NodeConversionResult } from '../base-interfaces/conversion-result';
7
+ /**
8
+ * Scriptlet injection rule converter class
9
+ *
10
+ * @todo Implement `convertToUbo` and `convertToAbp`
11
+ */
12
+ export declare class ScriptletRuleConverter extends RuleConverterBase {
13
+ /**
14
+ * Converts a scriptlet injection rule to AdGuard format, if possible.
15
+ *
16
+ * @param rule Rule node to convert
17
+ * @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
18
+ * the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
19
+ * If the rule was not converted, the result array will contain the original node with the same object reference
20
+ * @throws If the rule is invalid or cannot be converted
21
+ */
22
+ static convertToAdg(rule: ScriptletInjectionRule): NodeConversionResult<ScriptletInjectionRule>;
23
+ /**
24
+ * Converts a scriptlet injection rule to uBlock format, if possible.
25
+ *
26
+ * @param rule Rule node to convert
27
+ * @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
28
+ * the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
29
+ * If the rule was not converted, the result array will contain the original node with the same object reference
30
+ * @throws If the rule is invalid or cannot be converted
31
+ */
32
+ static convertToUbo(rule: ScriptletInjectionRule): NodeConversionResult<ScriptletInjectionRule>;
33
+ }
@@ -0,0 +1,40 @@
1
+ import { BaseConverter } from '../base-interfaces/base-converter';
2
+ import { type ConversionResult } from '../base-interfaces/conversion-result';
3
+ import { CssTokenStream } from '../../parser/css/css-token-stream';
4
+ export declare const ERROR_MESSAGES: {
5
+ INVALID_ATTRIBUTE_VALUE: string;
6
+ };
7
+ export declare const PseudoClasses: {
8
+ readonly AbpContains: "-abp-contains";
9
+ readonly AbpHas: "-abp-has";
10
+ readonly Contains: "contains";
11
+ readonly Has: "has";
12
+ readonly HasText: "has-text";
13
+ readonly MatchesCss: "matches-css";
14
+ readonly MatchesCssAfter: "matches-css-after";
15
+ readonly MatchesCssBefore: "matches-css-before";
16
+ readonly Not: "not";
17
+ };
18
+ export type PseudoClasses = typeof PseudoClasses[keyof typeof PseudoClasses];
19
+ export declare const PseudoElements: {
20
+ readonly After: "after";
21
+ readonly Before: "before";
22
+ };
23
+ export type PseudoElements = typeof PseudoElements[keyof typeof PseudoElements];
24
+ /**
25
+ * CSS selector converter
26
+ *
27
+ * @todo Implement `convertToUbo` and `convertToAbp`
28
+ */
29
+ export declare class CssSelectorConverter extends BaseConverter {
30
+ /**
31
+ * Converts Extended CSS elements to AdGuard-compatible ones
32
+ *
33
+ * @param selectorList Selector list to convert
34
+ * @returns An object which follows the {@link ConversionResult} interface. Its `result` property contains
35
+ * the converted node, and its `isConverted` flag indicates whether the original node was converted.
36
+ * If the node was not converted, the result will contain the original node with the same object reference
37
+ * @throws If the rule is invalid or incompatible
38
+ */
39
+ static convertToAdg(selectorList: string | CssTokenStream): ConversionResult<string>;
40
+ }
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @file Known CSS elements and attributes.
3
+ * TODO: Implement a compatibility table for Extended CSS
4
+ */
5
+ /**
6
+ * Legacy Extended CSS attribute prefix.
7
+ *
8
+ * @example
9
+ * ```css
10
+ * [-ext-<name>=...]
11
+ * ```
12
+ */
13
+ export declare const LEGACY_EXT_CSS_ATTRIBUTE_PREFIX = "-ext-";
14
+ /**
15
+ * ABP Extended CSS prefix.
16
+ *
17
+ * @example
18
+ * ```css
19
+ * [-abp-<name>=...]
20
+ * -abp-<name>(...)
21
+ * ```
22
+ */
23
+ export declare const ABP_EXT_CSS_PREFIX = "-abp";
24
+ /**
25
+ * Known _strict_ Extended CSS pseudo-classes. Please, keep this list sorted.
26
+ * Strict means that these pseudo-classes are not supported by any browser natively,
27
+ * and they always require Extended CSS libraries to work.
28
+ */
29
+ export declare const EXT_CSS_PSEUDO_CLASSES_STRICT: Set<string>;
30
+ /**
31
+ * _ALL_ known Extended CSS pseudo-classes. Please, keep this list sorted.
32
+ * It includes strict pseudo-classes and additional pseudo-classes that may be
33
+ * supported by some browsers natively.
34
+ */
35
+ export declare const EXT_CSS_PSEUDO_CLASSES: Set<string>;
36
+ /**
37
+ * Known legacy Extended CSS attributes. These attributes are deprecated and
38
+ * should be replaced with the corresponding pseudo-classes. In a long term,
39
+ * these attributes will be COMPLETELY removed from the Extended CSS syntax.
40
+ *
41
+ * Please, keep this list sorted.
42
+ */
43
+ export declare const EXT_CSS_LEGACY_ATTRIBUTES: Set<string>;
44
+ /**
45
+ * Known CSS functions that aren't allowed in CSS injection rules, because they
46
+ * able to load external resources. Please, keep this list sorted.
47
+ */
48
+ export declare const FORBIDDEN_CSS_FUNCTIONS: Set<string>;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @file Adblock filter list converter
3
+ */
4
+ import { type FilterList } from '../nodes';
5
+ import { type ConversionResult } from './base-interfaces/conversion-result';
6
+ import { BaseConverter } from './base-interfaces/base-converter';
7
+ /**
8
+ * Adblock filter list converter class
9
+ *
10
+ * This class just provides an extra layer on top of the {@link RuleConverter}
11
+ * and can be used to convert entire filter lists.
12
+ *
13
+ * @todo Implement `convertToUbo` and `convertToAbp`
14
+ * @todo Implement tolerant mode, which will allow to convert a filter list
15
+ * even if some of its rules are invalid
16
+ */
17
+ export declare class FilterListConverter extends BaseConverter {
18
+ /**
19
+ * Converts an adblock filter list to AdGuard format, if possible.
20
+ *
21
+ * @param filterListNode Filter list node to convert
22
+ * @param tolerant Indicates whether the converter should be tolerant to invalid rules. If enabled and a rule is
23
+ * invalid, it will be left as is. If disabled and a rule is invalid, the whole filter list will be failed.
24
+ * Defaults to `true`.
25
+ * @returns An object which follows the {@link ConversionResult} interface. Its `result` property contains
26
+ * the converted node, and its `isConverted` flag indicates whether the original node was converted.
27
+ * If the node was not converted, the result will contain the original node with the same object reference
28
+ * @throws If the filter list is invalid or cannot be converted (if the tolerant mode is disabled)
29
+ */
30
+ static convertToAdg(filterListNode: FilterList, tolerant?: boolean): ConversionResult<FilterList>;
31
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @file Converter entry point
3
+ */
4
+ export { RawFilterListConverter } from './raw-filter-list';
5
+ export { RuleConverter } from './rule';
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @file Network rule modifier list converter.
3
+ */
4
+ import { type ModifierList } from '../../nodes';
5
+ import { BaseConverter } from '../base-interfaces/base-converter';
6
+ import { type ConversionResult } from '../base-interfaces/conversion-result';
7
+ /**
8
+ * Helper class for converting network rule modifier lists.
9
+ *
10
+ * @todo Implement `convertToUbo` and `convertToAbp`
11
+ */
12
+ export declare class NetworkRuleModifierListConverter extends BaseConverter {
13
+ /**
14
+ * Converts a network rule modifier list to AdGuard format, if possible.
15
+ *
16
+ * @param modifierList Network rule modifier list node to convert
17
+ * @param isException If `true`, the rule is an exception rule
18
+ * @returns An object which follows the {@link ConversionResult} interface. Its `result` property contains
19
+ * the converted node, and its `isConverted` flag indicates whether the original node was converted.
20
+ * If the node was not converted, the result will contain the original node with the same object reference
21
+ * @throws If the conversion is not possible
22
+ */
23
+ static convertToAdg(modifierList: ModifierList, isException?: boolean): ConversionResult<ModifierList>;
24
+ /**
25
+ * Converts a network rule modifier list to uBlock format, if possible.
26
+ *
27
+ * @param modifierList Network rule modifier list node to convert
28
+ * @param isException If `true`, the rule is an exception rule
29
+ * @returns An object which follows the {@link ConversionResult} interface. Its `result` property contains
30
+ * the converted node, and its `isConverted` flag indicates whether the original node was converted.
31
+ * If the node was not converted, the result will contain the original node with the same object reference
32
+ * @throws If the conversion is not possible
33
+ */
34
+ static convertToUbo(modifierList: ModifierList, isException?: boolean): ConversionResult<ModifierList>;
35
+ }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @file Network rule converter
3
+ */
4
+ import { type NetworkRule, type AnyNetworkRule } from '../../nodes';
5
+ import { RuleConverterBase } from '../base-interfaces/rule-converter-base';
6
+ import { type NodeConversionResult } from '../base-interfaces/conversion-result';
7
+ /**
8
+ * Network rule converter class (also known as "basic rule converter")
9
+ *
10
+ * @todo Implement `convertToUbo` and `convertToAbp`
11
+ */
12
+ export declare class NetworkRuleConverter extends RuleConverterBase {
13
+ /**
14
+ * Converts a network rule to AdGuard format, if possible.
15
+ *
16
+ * @param rule Rule node to convert
17
+ * @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
18
+ * the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
19
+ * If the rule was not converted, the result array will contain the original node with the same object reference
20
+ * @throws If the rule is invalid or cannot be converted
21
+ */
22
+ static convertToAdg(rule: AnyNetworkRule): NodeConversionResult<NetworkRule>;
23
+ /**
24
+ * Converts a network rule to uBlock format, if possible.
25
+ *
26
+ * @param rule Rule node to convert
27
+ * @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
28
+ * the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
29
+ * If the rule was not converted, the result array will contain the original node with the same object reference
30
+ * @throws If the rule is invalid or cannot be converted
31
+ */
32
+ static convertToUbo(rule: AnyNetworkRule): NodeConversionResult<NetworkRule>;
33
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @file Filter list converter for raw filter lists
3
+ *
4
+ * Technically, this is a wrapper around `FilterListConverter` that works with nodes instead of strings.
5
+ */
6
+ import { type ConversionResult } from './base-interfaces/conversion-result';
7
+ import { BaseConverter } from './base-interfaces/base-converter';
8
+ /**
9
+ * Adblock filter list converter class.
10
+ *
11
+ * You can use this class to convert string-based filter lists, since most of the converters work with nodes.
12
+ * This class just provides an extra layer on top of the {@link FilterListConverter} and calls the parser/serializer
13
+ * before/after the conversion internally.
14
+ *
15
+ * @todo Implement `convertToUbo` and `convertToAbp`
16
+ */
17
+ export declare class RawFilterListConverter extends BaseConverter {
18
+ /**
19
+ * Converts an adblock filter list text to AdGuard format, if possible.
20
+ *
21
+ * @param rawFilterList Raw filter list text to convert
22
+ * @param tolerant Indicates whether the converter should be tolerant to invalid rules. If enabled and a rule is
23
+ * invalid, it will be left as is. If disabled and a rule is invalid, the whole filter list will be failed.
24
+ * Defaults to `true`.
25
+ * @returns An object which follows the {@link ConversionResult} interface. Its `result` property contains
26
+ * the array of converted filter list text, and its `isConverted` flag indicates whether the original rule was
27
+ * converted. If the rule was not converted, the original filter list text will be returned
28
+ * @throws If the filter list is invalid or cannot be converted (if the tolerant mode is disabled)
29
+ */
30
+ static convertToAdg(rawFilterList: string, tolerant?: boolean): ConversionResult<string>;
31
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @file Rule converter for raw rules
3
+ *
4
+ * Technically, this is a wrapper around `RuleConverter` that works with nodes instead of strings.
5
+ */
6
+ import { type ConversionResult } from './base-interfaces/conversion-result';
7
+ import { BaseConverter } from './base-interfaces/base-converter';
8
+ /**
9
+ * Adblock filtering rule converter class.
10
+ *
11
+ * You can use this class to convert string-based adblock rules, since most of the converters work with nodes.
12
+ * This class just provides an extra layer on top of the {@link RuleConverter} and calls the parser/serializer
13
+ * before/after the conversion internally.
14
+ *
15
+ * @todo Implement `convertToUbo` and `convertToAbp`
16
+ */
17
+ export declare class RawRuleConverter extends BaseConverter {
18
+ /**
19
+ * Converts an adblock filtering rule to AdGuard format, if possible.
20
+ *
21
+ * @param rawRule Raw rule text to convert
22
+ * @returns An object which follows the {@link ConversionResult} interface. Its `result` property contains
23
+ * the array of converted rule texts, and its `isConverted` flag indicates whether the original rule was converted.
24
+ * If the rule was not converted, the original rule text will be returned
25
+ * @throws If the rule is invalid or cannot be converted
26
+ */
27
+ static convertToAdg(rawRule: string): ConversionResult<string, string[]>;
28
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @file Adblock rule converter
3
+ *
4
+ * This file is the entry point for all rule converters
5
+ * which automatically detects the rule type and calls
6
+ * the corresponding "sub-converter".
7
+ */
8
+ import { type AnyRule } from '../nodes';
9
+ import { RuleConverterBase } from './base-interfaces/rule-converter-base';
10
+ import { type NodeConversionResult } from './base-interfaces/conversion-result';
11
+ /**
12
+ * Adblock filtering rule converter class
13
+ *
14
+ * @todo Implement `convertToUbo` and `convertToAbp`
15
+ */
16
+ export declare class RuleConverter extends RuleConverterBase {
17
+ /**
18
+ * Converts an adblock filtering rule to AdGuard format, if possible.
19
+ *
20
+ * @param rule Rule node to convert
21
+ * @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
22
+ * the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
23
+ * If the rule was not converted, the result array will contain the original node with the same object reference
24
+ * @throws If the rule is invalid or cannot be converted
25
+ */
26
+ static convertToAdg(rule: AnyRule): NodeConversionResult<AnyRule>;
27
+ /**
28
+ * Converts an adblock filtering rule to uBlock Origin format, if possible.
29
+ *
30
+ * @param rule Rule node to convert
31
+ * @returns An object which follows the {@link NodeConversionResult} interface. Its `result` property contains
32
+ * the array of converted rule nodes, and its `isConverted` flag indicates whether the original rule was converted.
33
+ * If the rule was not converted, the result array will contain the original node with the same object reference
34
+ * @throws If the rule is invalid or cannot be converted
35
+ */
36
+ static convertToUbo(rule: AnyRule): NodeConversionResult<AnyRule>;
37
+ }
@@ -0,0 +1,15 @@
1
+ import { type Node } from '../nodes';
2
+ import { type InputByteBuffer } from '../utils/input-byte-buffer';
3
+ /**
4
+ * Base class for deserializers. Each deserializer should extend this class.
5
+ */
6
+ export declare class BaseDeserializer {
7
+ /**
8
+ * Deserializes the AST node from a byte buffer.
9
+ *
10
+ * @param buffer Input byte buffer to read from.
11
+ * @param node Destination node to write to.
12
+ * @param args Additional, parser-specific arguments, if needed.
13
+ */
14
+ static deserialize(buffer: InputByteBuffer, node: Partial<Node>, ...args: unknown[]): void;
15
+ }
@@ -0,0 +1,34 @@
1
+ import { type AgentCommentRule } from '../../nodes';
2
+ import { type InputByteBuffer } from '../../utils/input-byte-buffer';
3
+ import { BaseDeserializer } from '../base-deserializer';
4
+ /**
5
+ * `AgentCommentDeserializer` is responsible for deserializing an Adblock agent comments.
6
+ * Adblock agent comment marks that the filter list is supposed to
7
+ * be used by the specified ad blockers.
8
+ *
9
+ * @example
10
+ * - ```adblock
11
+ * [AdGuard]
12
+ * ```
13
+ * - ```adblock
14
+ * [Adblock Plus 2.0]
15
+ * ```
16
+ * - ```adblock
17
+ * [uBlock Origin]
18
+ * ```
19
+ * - ```adblock
20
+ * [uBlock Origin 1.45.3]
21
+ * ```
22
+ * - ```adblock
23
+ * [Adblock Plus 2.0; AdGuard]
24
+ * ```
25
+ */
26
+ export declare class AgentCommentDeserializer extends BaseDeserializer {
27
+ /**
28
+ * Deserializes an agent list node from binary format.
29
+ *
30
+ * @param buffer ByteBuffer for reading binary data.
31
+ * @param node Destination node.
32
+ */
33
+ static deserialize(buffer: InputByteBuffer, node: Partial<AgentCommentRule>): void;
34
+ }
@@ -0,0 +1,25 @@
1
+ import { type Agent } from '../../nodes';
2
+ import { BaseDeserializer } from '../base-deserializer';
3
+ import { type InputByteBuffer } from '../../utils/input-byte-buffer';
4
+ /**
5
+ * `AgentDeserializer` is responsible for deserializing single adblock agent elements.
6
+ *
7
+ * @example
8
+ * If the adblock agent rule is
9
+ * ```adblock
10
+ * [Adblock Plus 2.0; AdGuard]
11
+ * ```
12
+ * then the adblock agents are `Adblock Plus 2.0` and `AdGuard`, and this
13
+ * class is responsible for parsing them. The rule itself is parsed by
14
+ * `AgentCommentSerializer`, which uses this class to parse single agents.
15
+ */
16
+ export declare class AgentDeserializer extends BaseDeserializer {
17
+ /**
18
+ * Deserializes an agent node from binary format.
19
+ *
20
+ * @param buffer ByteBuffer for reading binary data.
21
+ * @param node Destination node.
22
+ * @throws If the binary data is malformed.
23
+ */
24
+ static deserialize(buffer: InputByteBuffer, node: Partial<Agent>): void;
25
+ }
@@ -0,0 +1,16 @@
1
+ import { type AnyCommentRule } from '../../nodes';
2
+ import { BaseDeserializer } from '../base-deserializer';
3
+ import { type InputByteBuffer } from '../../utils/input-byte-buffer';
4
+ /**
5
+ * `CommentRuleDeserializer` is responsible for deserializing any comment-like adblock rules.
6
+ */
7
+ export declare class CommentRuleDeserializer extends BaseDeserializer {
8
+ /**
9
+ * Deserializes a comment rule node from binary format.
10
+ *
11
+ * @param buffer ByteBuffer for reading binary data.
12
+ * @param node Destination node.
13
+ * @throws If the binary data is malformed.
14
+ */
15
+ static deserialize(buffer: InputByteBuffer, node: Partial<AnyCommentRule>): void;
16
+ }
@@ -0,0 +1,27 @@
1
+ import { type ConfigCommentRule } from '../../nodes';
2
+ import { BaseDeserializer } from '../base-deserializer';
3
+ import { type InputByteBuffer } from '../../utils/input-byte-buffer';
4
+ /**
5
+ * `ConfigCommentDeserializer` is responsible for deserializing inline AGLint configuration rules.
6
+ * Generally, the idea is inspired by ESLint inline configuration comments.
7
+ *
8
+ * @see {@link https://eslint.org/docs/latest/user-guide/configuring/rules#using-configuration-comments}
9
+ */
10
+ export declare class ConfigCommentDeserializer extends BaseDeserializer {
11
+ /**
12
+ * Deserializes a metadata comment node from binary format.
13
+ *
14
+ * @param buffer ByteBuffer for reading binary data.
15
+ * @param node Destination node.
16
+ * @throws If the binary data is malformed.
17
+ */
18
+ private static deserializeConfigNode;
19
+ /**
20
+ * Deserializes a metadata comment node from binary format.
21
+ *
22
+ * @param buffer ByteBuffer for reading binary data.
23
+ * @param node Destination node.
24
+ * @throws If the binary data is malformed.
25
+ */
26
+ static deserialize(buffer: InputByteBuffer, node: Partial<ConfigCommentRule>): void;
27
+ }
@@ -0,0 +1,24 @@
1
+ import { type HintCommentRule } from '../../nodes';
2
+ import { BaseDeserializer } from '../base-deserializer';
3
+ import { type InputByteBuffer } from '../../utils/input-byte-buffer';
4
+ /**
5
+ * `HintCommentDeserializer` is responsible for deserializing AdGuard hint rules.
6
+ *
7
+ * @example
8
+ * The following hint rule
9
+ * ```adblock
10
+ * !+ NOT_OPTIMIZED PLATFORM(windows)
11
+ * ```
12
+ * contains two hints: `NOT_OPTIMIZED` and `PLATFORM`.
13
+ * @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#hints}
14
+ */
15
+ export declare class HintCommentDeserializer extends BaseDeserializer {
16
+ /**
17
+ * Deserializes a hint rule node from binary format.
18
+ *
19
+ * @param buffer ByteBuffer for reading binary data.
20
+ * @param node Destination node.
21
+ * @throws If the binary data is malformed.
22
+ */
23
+ static deserialize(buffer: InputByteBuffer, node: Partial<HintCommentRule>): void;
24
+ }
@@ -0,0 +1,26 @@
1
+ import { type Hint } from '../../nodes';
2
+ import { BaseDeserializer } from '../base-deserializer';
3
+ import { type InputByteBuffer } from '../../utils/input-byte-buffer';
4
+ export declare const getFrequentPlatformsDeserializationMap: () => Map<number, string>;
5
+ /**
6
+ * `HintDeserializer` is responsible for deserializing AdGuard hints.
7
+ *
8
+ * @example
9
+ * If the hint rule is
10
+ * ```adblock
11
+ * !+ NOT_OPTIMIZED PLATFORM(windows)
12
+ * ```
13
+ * then the hints are `NOT_OPTIMIZED` and `PLATFORM(windows)`, and this
14
+ * class is responsible for parsing them. The rule itself is parsed by
15
+ * the `HintRuleParser`, which uses this class to parse single hints.
16
+ */
17
+ export declare class HintDeserializer extends BaseDeserializer {
18
+ /**
19
+ * Deserializes a hint node from binary format.
20
+ *
21
+ * @param buffer ByteBuffer for reading binary data.
22
+ * @param node Destination node.
23
+ * @throws If the binary data is malformed.
24
+ */
25
+ static deserialize(buffer: InputByteBuffer, node: Partial<Hint>): void;
26
+ }