@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,1183 @@
1
+ import { type AdblockSyntax } from '../utils/adblockers';
2
+ import { type COMMA_DOMAIN_LIST_SEPARATOR, type PIPE_MODIFIER_SEPARATOR } from '../utils/constants';
3
+ export declare const OperatorValue: {
4
+ readonly Not: "!";
5
+ readonly And: "&&";
6
+ readonly Or: "||";
7
+ };
8
+ export type OperatorValue = typeof OperatorValue[keyof typeof OperatorValue];
9
+ /**
10
+ * Represents possible new line types.
11
+ */
12
+ export type NewLine = 'crlf' | 'lf' | 'cr';
13
+ /**
14
+ * Represents any kind of logical expression node.
15
+ */
16
+ export type AnyExpressionNode = ExpressionVariableNode | ExpressionOperatorNode | ExpressionParenthesisNode;
17
+ /**
18
+ * Represents any kind of adblock rule.
19
+ */
20
+ export type AnyRule = EmptyRule | AnyCommentRule | AnyCosmeticRule | AnyNetworkRule | InvalidRule;
21
+ /**
22
+ * Represents any comment-like adblock rule.
23
+ */
24
+ export type AnyCommentRule = AgentCommentRule | CommentRule | ConfigCommentRule | HintCommentRule | MetadataCommentRule | PreProcessorCommentRule;
25
+ /**
26
+ * Represents any cosmetic adblock rule.
27
+ */
28
+ export type AnyCosmeticRule = CssInjectionRule | ElementHidingRule | ScriptletInjectionRule | HtmlFilteringRule | JsInjectionRule;
29
+ /**
30
+ * Represents any network adblock rule.
31
+ */
32
+ export type AnyNetworkRule = NetworkRule | HostRule;
33
+ /**
34
+ * Represents the different comment markers that can be used in an adblock rule.
35
+ *
36
+ * @example
37
+ * - If the rule is `! This is just a comment`, then the marker will be `!`.
38
+ * - If the rule is `# This is just a comment`, then the marker will be `#`.
39
+ */
40
+ export declare const CommentMarker: {
41
+ /**
42
+ * Regular comment marker. It is supported by all ad blockers.
43
+ */
44
+ readonly Regular: "!";
45
+ /**
46
+ * Hashmark comment marker. It is supported by uBlock Origin and AdGuard,
47
+ * and also used in hosts files.
48
+ */
49
+ readonly Hashmark: "#";
50
+ };
51
+ export type CommentMarker = typeof CommentMarker[keyof typeof CommentMarker];
52
+ /**
53
+ * Represents the main categories that an adblock rule can belong to.
54
+ * Of course, these include additional subcategories.
55
+ */
56
+ export declare const RuleCategory: {
57
+ /**
58
+ * Empty "rules" that are only containing whitespaces. These rules are handled just for convenience.
59
+ */
60
+ readonly Empty: "Empty";
61
+ /**
62
+ * Syntactically invalid rules (tolerant mode only).
63
+ */
64
+ readonly Invalid: "Invalid";
65
+ /**
66
+ * Comment rules, such as comment rules, metadata rules, preprocessor rules, etc.
67
+ */
68
+ readonly Comment: "Comment";
69
+ /**
70
+ * Cosmetic rules, such as element hiding rules, CSS rules, scriptlet rules, HTML rules, and JS rules.
71
+ */
72
+ readonly Cosmetic: "Cosmetic";
73
+ /**
74
+ * Network rules, such as basic network rules, header remover network rules, redirect network rules,
75
+ * response header filtering rules, etc.
76
+ */
77
+ readonly Network: "Network";
78
+ };
79
+ export type RuleCategory = typeof RuleCategory[keyof typeof RuleCategory];
80
+ /**
81
+ * Represents similar types of modifiers values
82
+ * which may be separated by a comma `,` (only for DomainList) or a pipe `|`.
83
+ */
84
+ export declare const ListNodeType: {
85
+ readonly Unknown: "Unknown";
86
+ readonly AppList: "AppList";
87
+ readonly DomainList: "DomainList";
88
+ readonly MethodList: "MethodList";
89
+ readonly StealthOptionList: "StealthOptionList";
90
+ };
91
+ export type ListNodeType = typeof ListNodeType[keyof typeof ListNodeType];
92
+ /**
93
+ * Represents child items for {@link ListNodeType}.
94
+ */
95
+ export declare const ListItemNodeType: {
96
+ readonly Unknown: "Unknown";
97
+ readonly App: "App";
98
+ readonly Domain: "Domain";
99
+ readonly Method: "Method";
100
+ readonly StealthOption: "StealthOption";
101
+ };
102
+ export type ListItemNodeType = typeof ListItemNodeType[keyof typeof ListItemNodeType];
103
+ /**
104
+ * Represents possible comment types.
105
+ */
106
+ export declare const CommentRuleType: {
107
+ readonly AgentCommentRule: "AgentCommentRule";
108
+ readonly CommentRule: "CommentRule";
109
+ readonly ConfigCommentRule: "ConfigCommentRule";
110
+ readonly HintCommentRule: "HintCommentRule";
111
+ readonly MetadataCommentRule: "MetadataCommentRule";
112
+ readonly PreProcessorCommentRule: "PreProcessorCommentRule";
113
+ };
114
+ export type CommentRuleType = typeof CommentRuleType[keyof typeof CommentRuleType];
115
+ /**
116
+ * Represents possible cosmetic rule types.
117
+ */
118
+ export declare const CosmeticRuleType: {
119
+ readonly ElementHidingRule: "ElementHidingRule";
120
+ readonly CssInjectionRule: "CssInjectionRule";
121
+ readonly ScriptletInjectionRule: "ScriptletInjectionRule";
122
+ readonly HtmlFilteringRule: "HtmlFilteringRule";
123
+ readonly JsInjectionRule: "JsInjectionRule";
124
+ };
125
+ export type CosmeticRuleType = typeof CosmeticRuleType[keyof typeof CosmeticRuleType];
126
+ /**
127
+ * Represents possible cosmetic rule separators.
128
+ */
129
+ export declare const CosmeticRuleSeparator: {
130
+ /**
131
+ * @see {@link https://help.eyeo.com/adblockplus/how-to-write-filters#elemhide_basic}
132
+ */
133
+ readonly ElementHiding: "##";
134
+ /**
135
+ * @see {@link https://help.eyeo.com/adblockplus/how-to-write-filters#elemhide_basic}
136
+ */
137
+ readonly ElementHidingException: "#@#";
138
+ /**
139
+ * @see {@link https://help.eyeo.com/adblockplus/how-to-write-filters#elemhide_basic}
140
+ */
141
+ readonly ExtendedElementHiding: "#?#";
142
+ /**
143
+ * @see {@link https://help.eyeo.com/adblockplus/how-to-write-filters#elemhide_basic}
144
+ */
145
+ readonly ExtendedElementHidingException: "#@?#";
146
+ /**
147
+ * @see {@link https://help.eyeo.com/adblockplus/how-to-write-filters#elemhide_basic}
148
+ */
149
+ readonly AbpSnippet: "#$#";
150
+ /**
151
+ * @see {@link https://help.eyeo.com/adblockplus/how-to-write-filters#elemhide_basic}
152
+ */
153
+ readonly AbpSnippetException: "#@$#";
154
+ /**
155
+ * @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#cosmetic-css-rules}
156
+ */
157
+ readonly AdgCssInjection: "#$#";
158
+ /**
159
+ * @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#cosmetic-css-rules}
160
+ */
161
+ readonly AdgCssInjectionException: "#@$#";
162
+ /**
163
+ * @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#cosmetic-css-rules}
164
+ */
165
+ readonly AdgExtendedCssInjection: "#$?#";
166
+ /**
167
+ * @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#cosmetic-css-rules}
168
+ */
169
+ readonly AdgExtendedCssInjectionException: "#@$?#";
170
+ /**
171
+ * @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#scriptlets}
172
+ */
173
+ readonly AdgJsInjection: "#%#";
174
+ /**
175
+ * @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#scriptlets}
176
+ */
177
+ readonly AdgJsInjectionException: "#@%#";
178
+ /**
179
+ * @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#html-filtering-rules}
180
+ */
181
+ readonly AdgHtmlFiltering: "$$";
182
+ /**
183
+ * @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#html-filtering-rules}
184
+ */
185
+ readonly AdgHtmlFilteringException: "$@$";
186
+ };
187
+ export type CosmeticRuleSeparator = typeof CosmeticRuleSeparator[keyof typeof CosmeticRuleSeparator];
188
+ /**
189
+ * Represents a basic node in the AST.
190
+ */
191
+ export interface Node {
192
+ /**
193
+ * The type of the node. Every node should have a type.
194
+ */
195
+ type: string;
196
+ /**
197
+ * Optionally the raw representation of the node in the source code.
198
+ */
199
+ raw?: string;
200
+ /**
201
+ * Start offset of the node.
202
+ */
203
+ start?: number;
204
+ /**
205
+ * End offset of the node.
206
+ */
207
+ end?: number;
208
+ }
209
+ /**
210
+ * Represents a location in the source code.
211
+ */
212
+ export interface Location {
213
+ /**
214
+ * Zero-based index of the first character of the parsed source region.
215
+ */
216
+ offset: number;
217
+ /**
218
+ * One-based line index of the first character of the parsed source region.
219
+ */
220
+ line: number;
221
+ /**
222
+ * One-based column index of the first character of the parsed source region.
223
+ */
224
+ column: number;
225
+ }
226
+ /**
227
+ * Represents a location range in the source code.
228
+ */
229
+ export interface LocationRange {
230
+ /**
231
+ * The start location of the node.
232
+ */
233
+ start: Location;
234
+ /**
235
+ * The end location of the node.
236
+ */
237
+ end: Location;
238
+ }
239
+ /**
240
+ * Default location for AST nodes.
241
+ */
242
+ export declare const defaultLocation: Location;
243
+ /**
244
+ * Represents a basic value node in the AST.
245
+ */
246
+ export interface Value<T = string> extends Node {
247
+ type: 'Value';
248
+ /**
249
+ * Value of the node.
250
+ */
251
+ value: T;
252
+ }
253
+ /**
254
+ * Represents a raw value node.
255
+ */
256
+ export interface Raw extends Node {
257
+ type: 'Raw';
258
+ /**
259
+ * Value of the node.
260
+ */
261
+ value: string;
262
+ }
263
+ /**
264
+ * Represents a list of parameters.
265
+ */
266
+ export interface ParameterList extends Node {
267
+ type: 'ParameterList';
268
+ /**
269
+ * List of values
270
+ *
271
+ * @note `null` values are allowed in the list, they represent empty parameters.
272
+ */
273
+ children: (Value | null)[];
274
+ }
275
+ /**
276
+ * Represents a logical expression variable node in the AST.
277
+ */
278
+ export interface ExpressionVariableNode extends Node {
279
+ type: 'Variable';
280
+ name: string;
281
+ }
282
+ /**
283
+ * Represents a logical expression operator node in the AST.
284
+ */
285
+ export interface ExpressionOperatorNode extends Node {
286
+ type: 'Operator';
287
+ operator: OperatorValue;
288
+ left: AnyExpressionNode;
289
+ right?: AnyExpressionNode;
290
+ }
291
+ /**
292
+ * Represents a logical expression parenthesis node in the AST.
293
+ */
294
+ export interface ExpressionParenthesisNode extends Node {
295
+ type: 'Parenthesis';
296
+ expression: AnyExpressionNode;
297
+ }
298
+ /**
299
+ * Represents a filter list (list of rules).
300
+ */
301
+ export interface FilterList extends Node {
302
+ type: 'FilterList';
303
+ /**
304
+ * List of rules
305
+ */
306
+ children: AnyRule[];
307
+ }
308
+ /**
309
+ * Represents a basic adblock rule. Every adblock rule should extend this interface.
310
+ * We don't use this interface directly, so we don't specify the `type` property.
311
+ */
312
+ export interface RuleBase extends Node {
313
+ /**
314
+ * Syntax of the adblock rule. If we are not able to determine the syntax of the rule,
315
+ * we should use `AdblockSyntax.Common` as the value.
316
+ */
317
+ syntax: AdblockSyntax;
318
+ /**
319
+ * Category of the adblock rule
320
+ */
321
+ category: RuleCategory;
322
+ /**
323
+ * Raw data of the rule
324
+ */
325
+ raws?: {
326
+ /**
327
+ * Original rule text
328
+ */
329
+ text?: string;
330
+ /**
331
+ * Newline character used in the rule (if any)
332
+ */
333
+ nl?: NewLine;
334
+ };
335
+ }
336
+ export interface InvalidRuleError extends Node {
337
+ type: 'InvalidRuleError';
338
+ /**
339
+ * Error name
340
+ */
341
+ name: string;
342
+ /**
343
+ * Error message
344
+ */
345
+ message: string;
346
+ }
347
+ /**
348
+ * Represents an invalid rule (used by tolerant mode).
349
+ */
350
+ export interface InvalidRule extends RuleBase {
351
+ type: 'InvalidRule';
352
+ /**
353
+ * Category of the adblock rule
354
+ */
355
+ category: typeof RuleCategory.Invalid;
356
+ /**
357
+ * Raw rule text
358
+ */
359
+ raw: string;
360
+ /**
361
+ * Error details
362
+ */
363
+ error: InvalidRuleError;
364
+ }
365
+ /**
366
+ * Represents an "empty rule" (practically an empty line)
367
+ */
368
+ export interface EmptyRule extends RuleBase {
369
+ /**
370
+ * Type of the adblock rule (should be always present)
371
+ */
372
+ type: 'EmptyRule';
373
+ /**
374
+ * Category of the adblock rule
375
+ */
376
+ category: typeof RuleCategory.Empty;
377
+ }
378
+ /**
379
+ * Represents the basic comment rule interface.
380
+ */
381
+ export interface CommentBase extends RuleBase {
382
+ category: typeof RuleCategory.Comment;
383
+ type: CommentRuleType;
384
+ }
385
+ /**
386
+ * Represents a simple comment.
387
+ *
388
+ * @example
389
+ * Example rules:
390
+ * - ```adblock
391
+ * ! This is just a comment
392
+ * ```
393
+ * - ```adblock
394
+ * # This is just a comment
395
+ * ```
396
+ */
397
+ export interface CommentRule extends CommentBase {
398
+ type: typeof CommentRuleType.CommentRule;
399
+ /**
400
+ * Comment marker.
401
+ *
402
+ * @example
403
+ * - If the rule is `! This is just a comment`, then the marker will be `!`.
404
+ * - If the rule is `# This is just a comment`, then the marker will be `#`.
405
+ */
406
+ marker: Value;
407
+ /**
408
+ * Comment text.
409
+ *
410
+ * @example
411
+ * If the rule is `! This is just a comment`, then the text will be `This is just a comment`.
412
+ */
413
+ text: Value;
414
+ }
415
+ /**
416
+ * Represents a metadata comment rule. This is a special comment that specifies
417
+ * the name and value of the metadata header.
418
+ *
419
+ * @example
420
+ * For example, in the case of
421
+ * ```adblock
422
+ * ! Title: My List
423
+ * ```
424
+ * the name of the header is `Title`, and the value is `My List`.
425
+ */
426
+ export interface MetadataCommentRule extends CommentBase {
427
+ type: typeof CommentRuleType.MetadataCommentRule;
428
+ /**
429
+ * Comment marker.
430
+ */
431
+ marker: Value;
432
+ /**
433
+ * Metadata header name.
434
+ */
435
+ header: Value;
436
+ /**
437
+ * Metadata header value (always should present).
438
+ */
439
+ value: Value;
440
+ }
441
+ /**
442
+ * Represents an AGLint configuration node.
443
+ *
444
+ * Used within config comments.
445
+ *
446
+ * @example
447
+ * ```adblock
448
+ * ! aglint "rule-1": ["warn", { "option1": "value1" }], "rule-2": "off"
449
+ * ! ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
450
+ * ```
451
+ */
452
+ export interface ConfigNode extends Node {
453
+ type: 'ConfigNode';
454
+ value: object;
455
+ }
456
+ /**
457
+ * Represents an inline linter configuration comment.
458
+ *
459
+ * @example
460
+ * For example, if the comment is
461
+ * ```adblock
462
+ * ! aglint-disable some-rule another-rule
463
+ * ```
464
+ * then the command is `aglint-disable` and its params is `["some-rule", "another-rule"]`.
465
+ */
466
+ export interface ConfigCommentRule extends CommentBase {
467
+ category: typeof RuleCategory.Comment;
468
+ type: typeof CommentRuleType.ConfigCommentRule;
469
+ /**
470
+ * The marker for the comment. It can be `!` or `#`. It is always the first non-whitespace character in the comment.
471
+ */
472
+ marker: Value;
473
+ /**
474
+ * The command for the comment. It is always begins with the `aglint` prefix.
475
+ *
476
+ * @example
477
+ * ```adblock
478
+ * ! aglint-disable-next-line
479
+ * ```
480
+ */
481
+ command: Value;
482
+ /**
483
+ * Params for the command. Can be a rule configuration object or a list of rule names.
484
+ *
485
+ * @example
486
+ * For the following comment:
487
+ * ```adblock
488
+ * ! aglint-disable some-rule another-rule
489
+ * ```
490
+ * the params would be `["some-rule", "another-rule"]`.
491
+ */
492
+ params?: ConfigNode | ParameterList;
493
+ /**
494
+ * Config comment text. The idea is generally the same as in ESLint.
495
+ *
496
+ * @example
497
+ * You can use the following syntax to specify a comment for a config comment:
498
+ * `! aglint-enable -- this is the comment`
499
+ */
500
+ comment?: Value;
501
+ }
502
+ /**
503
+ * Represents a preprocessor comment.
504
+ *
505
+ * @example
506
+ * For example, if the comment is
507
+ * ```adblock
508
+ * !#if (adguard)
509
+ * ```
510
+ * then the directive's name is `if` and its value is `(adguard)`.
511
+ *
512
+ * In such a case, the parameters must be submitted for further parsing and validation, as this parser only handles
513
+ * the general syntax.
514
+ */
515
+ export interface PreProcessorCommentRule extends CommentBase {
516
+ category: typeof RuleCategory.Comment;
517
+ type: typeof CommentRuleType.PreProcessorCommentRule;
518
+ /**
519
+ * Name of the directive
520
+ */
521
+ name: Value;
522
+ /**
523
+ * Params (optional)
524
+ */
525
+ params?: Value | ParameterList | AnyExpressionNode;
526
+ }
527
+ /**
528
+ * Represents an adblock agent.
529
+ */
530
+ export interface Agent extends Node {
531
+ type: 'Agent';
532
+ /**
533
+ * Adblock name.
534
+ */
535
+ adblock: Value;
536
+ /**
537
+ * Adblock version (if specified).
538
+ */
539
+ version?: Value;
540
+ /**
541
+ * Needed for network rules modifier validation.
542
+ */
543
+ syntax: AdblockSyntax;
544
+ }
545
+ /**
546
+ * Represents an agent comment rule.
547
+ *
548
+ * @example
549
+ * - ```adblock
550
+ * [Adblock Plus 2.0]
551
+ * ```
552
+ * - ```adblock
553
+ * [uBlock Origin 1.16.4; AdGuard 1.0]
554
+ * ```
555
+ */
556
+ export interface AgentCommentRule extends RuleBase {
557
+ category: typeof RuleCategory.Comment;
558
+ type: typeof CommentRuleType.AgentCommentRule;
559
+ /**
560
+ * Agent list.
561
+ */
562
+ children: Agent[];
563
+ }
564
+ /**
565
+ * Represents a hint.
566
+ *
567
+ * @example
568
+ * ```adblock
569
+ * !+ PLATFORM(windows, mac)
570
+ * ```
571
+ * the name would be `PLATFORM` and the params would be `["windows", "mac"]`.
572
+ */
573
+ export interface Hint extends Node {
574
+ type: 'Hint';
575
+ /**
576
+ * Hint name.
577
+ *
578
+ * @example
579
+ * For `PLATFORM(windows, mac)` the name would be `PLATFORM`.
580
+ */
581
+ name: Value;
582
+ /**
583
+ * Hint parameters.
584
+ *
585
+ * @example
586
+ * For `PLATFORM(windows, mac)` the params would be `["windows", "mac"]`.
587
+ */
588
+ params?: ParameterList;
589
+ }
590
+ /**
591
+ * Represents a hint comment rule.
592
+ *
593
+ * There can be several hints in a hint rule.
594
+ *
595
+ * @example
596
+ * If the rule is
597
+ * ```adblock
598
+ * !+ NOT_OPTIMIZED PLATFORM(windows)
599
+ * ```
600
+ * then there are two hint members: `NOT_OPTIMIZED` and `PLATFORM`.
601
+ */
602
+ export interface HintCommentRule extends RuleBase {
603
+ category: typeof RuleCategory.Comment;
604
+ type: typeof CommentRuleType.HintCommentRule;
605
+ /**
606
+ * Currently only AdGuard supports hints.
607
+ */
608
+ syntax: AdblockSyntax;
609
+ /**
610
+ * List of hints.
611
+ */
612
+ children: Hint[];
613
+ }
614
+ /**
615
+ * Represents a modifier list.
616
+ *
617
+ * @example
618
+ * If the rule is
619
+ * ```adblock
620
+ * some-rule$script,domain=example.com
621
+ * ```
622
+ * then the list of modifiers will be `script,domain=example.com`.
623
+ */
624
+ export interface ModifierList extends Node {
625
+ type: 'ModifierList';
626
+ /**
627
+ * List of modifiers.
628
+ */
629
+ children: Modifier[];
630
+ }
631
+ /**
632
+ * Represents a modifier.
633
+ *
634
+ * @example
635
+ * If the modifier is `third-party`, the value of the modifier property
636
+ * will be `third-party`, but the value will remain undefined.
637
+ *
638
+ * But if the modifier is `domain=example.com`, then the modifier property will be
639
+ * `domain` and the value property will be `example.com`.
640
+ */
641
+ export interface Modifier extends Node {
642
+ /**
643
+ * Modifier name
644
+ */
645
+ name: Value;
646
+ /**
647
+ * Is this modifier an exception? For example, `~third-party` is an exception
648
+ */
649
+ exception?: boolean;
650
+ /**
651
+ * Modifier value (optional)
652
+ */
653
+ value?: Value;
654
+ }
655
+ /**
656
+ * Represents the separator used for various modifier values.
657
+ *
658
+ * @example
659
+ * `||example.com^$app=com.test1.app|TestApp.exe`
660
+ */
661
+ export type PipeSeparator = typeof PIPE_MODIFIER_SEPARATOR;
662
+ /**
663
+ * Represents the separator used for basic rules domain list.
664
+ *
665
+ * @example
666
+ * `example.com,example.org###banner`
667
+ */
668
+ export type CommaSeparator = typeof COMMA_DOMAIN_LIST_SEPARATOR;
669
+ /**
670
+ * Represents the separator used in a domain list.
671
+ *
672
+ * @example
673
+ * - `,` — for the classic domain list,
674
+ * - `|` — for the $domain modifier value
675
+ */
676
+ export type DomainListSeparator = CommaSeparator | PipeSeparator;
677
+ /**
678
+ * Common interface for a list item of $app, $denyallow, $domain, $method
679
+ * which have similar syntax.
680
+ */
681
+ export interface ListItem<T extends ListItemNodeType> extends Node {
682
+ type: T;
683
+ /**
684
+ * Value of the node.
685
+ */
686
+ value: string;
687
+ /**
688
+ * If the value is an negated.
689
+ *
690
+ * @example
691
+ * `~example.com` is negated, but `example.com` is not. `~` is the exception marker here.
692
+ */
693
+ exception: boolean;
694
+ }
695
+ /**
696
+ * Represents an element of the app list — $app.
697
+ */
698
+ export type App = ListItem<typeof ListItemNodeType.App>;
699
+ /**
700
+ * Represents an element of the domain list — $domain, $denyallow.
701
+ */
702
+ export type Domain = ListItem<typeof ListItemNodeType.Domain>;
703
+ /**
704
+ * Represents an element of the method list — $method.
705
+ */
706
+ export type Method = ListItem<typeof ListItemNodeType.Method>;
707
+ /**
708
+ * Represents an element of the stealth option list — $stealth.
709
+ */
710
+ export type StealthOption = ListItem<typeof ListItemNodeType.StealthOption>;
711
+ /**
712
+ * Represents any list item.
713
+ */
714
+ export type AnyListItem = App | Domain | Method | StealthOption;
715
+ /**
716
+ * Represents a list of domains.
717
+ * Needed for $domain and $denyallow.
718
+ *
719
+ * @example
720
+ * `example.com,~example.net` or `example.com|~example.net`
721
+ */
722
+ export interface DomainList extends Node {
723
+ /**
724
+ * Type of the node. Basically, the idea is that each main AST part should have a type
725
+ */
726
+ type: typeof ListNodeType.DomainList;
727
+ /**
728
+ * Separator used in the domain list.
729
+ */
730
+ separator: DomainListSeparator;
731
+ /**
732
+ * List of domains
733
+ */
734
+ children: Domain[];
735
+ }
736
+ /**
737
+ * Represents a list of apps.
738
+ * Needed for $app.
739
+ *
740
+ * @example
741
+ * `Example.exe|com.example.osx`.
742
+ */
743
+ export interface AppList extends Node {
744
+ /**
745
+ * Type of the node. Basically, the idea is that each main AST part should have a type
746
+ */
747
+ type: typeof ListNodeType.AppList;
748
+ /**
749
+ * Separator used in the app list.
750
+ */
751
+ separator: PipeSeparator;
752
+ /**
753
+ * List of apps
754
+ */
755
+ children: App[];
756
+ }
757
+ /**
758
+ * Represents a list of methods.
759
+ * Needed for $method.
760
+ *
761
+ * @example
762
+ * `get|post|put`.
763
+ */
764
+ export interface MethodList extends Node {
765
+ /**
766
+ * Type of the node. Basically, the idea is that each main AST part should have a type
767
+ */
768
+ type: typeof ListNodeType.MethodList;
769
+ /**
770
+ * Separator used in the method list.
771
+ */
772
+ separator: PipeSeparator;
773
+ /**
774
+ * List of methods
775
+ */
776
+ children: Method[];
777
+ }
778
+ /**
779
+ * Represents a list of stealth options.
780
+ * Needed for $stealth.
781
+ *
782
+ * @example
783
+ * `referrer|ip`.
784
+ */
785
+ export interface StealthOptionList extends Node {
786
+ /**
787
+ * Type of the node. Basically, the idea is that each main AST part should have a type
788
+ */
789
+ type: typeof ListNodeType.StealthOptionList;
790
+ /**
791
+ * Separator used in the stealth option list.
792
+ */
793
+ separator: PipeSeparator;
794
+ /**
795
+ * List of stealth options
796
+ */
797
+ children: StealthOption[];
798
+ }
799
+ /**
800
+ * Represents a CSS injection body.
801
+ */
802
+ export interface CssInjectionRuleBody extends Node {
803
+ type: 'CssInjectionRuleBody';
804
+ /**
805
+ * Media query, if any.
806
+ *
807
+ * @example
808
+ *
809
+ * ```text
810
+ * @media (max-width: 768px) { ... }
811
+ * ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
812
+ * ```
813
+ */
814
+ mediaQueryList?: Value;
815
+ /**
816
+ * CSS selector list.
817
+ *
818
+ * @example
819
+ * section:has(> .ad) { display: none; }
820
+ * ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
821
+ * section:has(> .ad), article > p[advert] { display: none; }
822
+ * ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
823
+ */
824
+ selectorList: Value;
825
+ /**
826
+ * Declaration list.
827
+ *
828
+ * @example
829
+ * section:has(> .ad) { display: none; }
830
+ * ↑↑↑↑↑↑↑↑↑↑↑↑↑↑
831
+ * section:has(> .ad), article > p[advert] { display: none; }
832
+ * ↑↑↑↑↑↑↑↑↑↑↑↑↑↑
833
+ * div[ad] { padding-top: 10px; padding-bottom: 10px; }
834
+ * ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
835
+ */
836
+ declarationList?: Value;
837
+ /**
838
+ * Remove flag
839
+ */
840
+ remove?: boolean;
841
+ }
842
+ /**
843
+ * Represents an element hiding rule body. There can even be several selectors in a rule,
844
+ * but the best practice is to place the selectors in separate rules.
845
+ */
846
+ export interface ElementHidingRuleBody extends Node {
847
+ type: 'ElementHidingRuleBody';
848
+ /**
849
+ * Element hiding rule selector(s).
850
+ */
851
+ selectorList: Value;
852
+ }
853
+ /**
854
+ * Represents a scriptlet injection rule body.
855
+ */
856
+ export interface ScriptletInjectionRuleBody extends Node {
857
+ type: 'ScriptletInjectionRuleBody';
858
+ /**
859
+ * List of scriptlets (list of parameter lists).
860
+ */
861
+ children: ParameterList[];
862
+ }
863
+ /**
864
+ * Represents an HTML filtering rule body.
865
+ */
866
+ export interface HtmlFilteringRuleBody extends Node {
867
+ type: 'HtmlFilteringRuleBody';
868
+ /**
869
+ * HTML rule selector(s).
870
+ */
871
+ body: Value;
872
+ }
873
+ /**
874
+ * A generic representation of a cosmetic rule.
875
+ *
876
+ * Regarding the categories, there is only a difference in the body,
877
+ * all other properties can be defined at this level.
878
+ */
879
+ export interface CosmeticRule extends RuleBase {
880
+ category: typeof RuleCategory.Cosmetic;
881
+ type: CosmeticRuleType;
882
+ /**
883
+ * List of modifiers (optional)
884
+ */
885
+ modifiers?: ModifierList;
886
+ /**
887
+ * List of domains.
888
+ */
889
+ domains: DomainList;
890
+ /**
891
+ * Separator between pattern and body. For example, in the following rule:
892
+ * ```adblock
893
+ * example.com##.ads
894
+ * ```
895
+ * then the separator is `##`.
896
+ */
897
+ separator: Value;
898
+ /**
899
+ * If the rule is an exception. For example, in the following rule:
900
+ * ```adblock
901
+ * example.com#@#.ads
902
+ * ```
903
+ * then the rule is an exception and @ is the exception marker.
904
+ */
905
+ exception: boolean;
906
+ /**
907
+ * Body of the rule. It can be a CSS rule, an element hiding rule, a scriptlet rule, etc.
908
+ */
909
+ body: unknown;
910
+ }
911
+ /**
912
+ * Representation of an element hiding rule.
913
+ *
914
+ * Example rules:
915
+ * - ```adblock
916
+ * example.com##.ads
917
+ * ```
918
+ * - ```adblock
919
+ * example.com#@#.ads
920
+ * ```
921
+ * - ```adblock
922
+ * example.com#?#.ads:has(> .something)
923
+ * ```
924
+ * - ```adblock
925
+ * example.com#@?#.ads:has(> .something)
926
+ * ```
927
+ */
928
+ export interface ElementHidingRule extends CosmeticRule {
929
+ type: typeof CosmeticRuleType.ElementHidingRule;
930
+ body: ElementHidingRuleBody;
931
+ }
932
+ /**
933
+ * Representation of a CSS injection rule.
934
+ *
935
+ * Example rules (AdGuard):
936
+ * - ```adblock
937
+ * example.com#$#body { padding-top: 0 !important; }
938
+ * ```
939
+ * - ```adblock
940
+ * example.com#$#@media (min-width: 1024px) { body { padding-top: 0 !important; } }
941
+ * ```
942
+ * - ```adblock
943
+ * example.com#$?#@media (min-width: 1024px) { .something:has(.ads) { padding-top: 0 !important; } }
944
+ * ```
945
+ * - ```adblock
946
+ * example.com#$#.ads { remove: true; }
947
+ * ```
948
+ *
949
+ * Example rules (uBlock Origin):
950
+ * - ```adblock
951
+ * example.com##body:style(padding-top: 0 !important;)
952
+ * ```
953
+ * - ```adblock
954
+ * example.com##.ads:remove()
955
+ * ```
956
+ */
957
+ export interface CssInjectionRule extends CosmeticRule {
958
+ type: typeof CosmeticRuleType.CssInjectionRule;
959
+ body: CssInjectionRuleBody;
960
+ }
961
+ /**
962
+ * Representation of a scriptlet injection rule.
963
+ *
964
+ * Example rules (AdGuard):
965
+ * - ```adblock
966
+ * example.com#%#//scriptlet('scriptlet-name', 'arg0', 'arg1')
967
+ * ```
968
+ * - ```adblock
969
+ * example.com#@%#//scriptlet('scriptlet-name', 'arg0', 'arg1')
970
+ * ```
971
+ *
972
+ * Example rules (uBlock Origin):
973
+ * - ```adblock
974
+ * example.com##+js(scriptlet-name, arg0, arg1)
975
+ * ```
976
+ * - ```adblock
977
+ * example.com#@#+js(scriptlet-name, arg0, arg1)
978
+ * ```
979
+ *
980
+ * Example rules (Adblock Plus):
981
+ * - ```adblock
982
+ * example.com#$#scriptlet-name arg0 arg1
983
+ * ```
984
+ * - ```adblock
985
+ * example.com#@$#scriptlet-name arg0 arg1
986
+ * ```
987
+ * - ```adblock
988
+ * example.com#$#scriptlet0 arg00 arg01; scriptlet1 arg10 arg11
989
+ * ```
990
+ */
991
+ export interface ScriptletInjectionRule extends CosmeticRule {
992
+ type: typeof CosmeticRuleType.ScriptletInjectionRule;
993
+ body: ScriptletInjectionRuleBody;
994
+ }
995
+ /**
996
+ * Representation of a HTML filtering rule.
997
+ *
998
+ * Example rules (AdGuard):
999
+ * - ```adblock
1000
+ * example.com$$script[tag-content="detect"]
1001
+ * ```
1002
+ * - ```adblock
1003
+ * example.com$@$script[tag-content="detect"]
1004
+ * ```
1005
+ *
1006
+ * Example rules (uBlock Origin):
1007
+ * - ```adblock
1008
+ * example.com##^script:has-text(detect)
1009
+ * ```
1010
+ * - ```adblock
1011
+ * example.com#@#^script:has-text(detect)
1012
+ * ```
1013
+ */
1014
+ export interface HtmlFilteringRule extends CosmeticRule {
1015
+ type: typeof CosmeticRuleType.HtmlFilteringRule;
1016
+ body: Value;
1017
+ }
1018
+ /**
1019
+ * Representation of a JS injection rule.
1020
+ *
1021
+ * Example rules (AdGuard):
1022
+ * - ```adblock
1023
+ * example.com#%#let a = 2;
1024
+ * ```
1025
+ * - ```adblock
1026
+ * example.com#@%#let a = 2;
1027
+ * ```
1028
+ */
1029
+ export interface JsInjectionRule extends CosmeticRule {
1030
+ type: typeof CosmeticRuleType.JsInjectionRule;
1031
+ body: Value;
1032
+ }
1033
+ /**
1034
+ * Represents the different types of network rules.
1035
+ */
1036
+ export declare const NetworkRuleType: {
1037
+ readonly NetworkRule: "NetworkRule";
1038
+ readonly HostRule: "HostRule";
1039
+ };
1040
+ export type NetworkRuleType = typeof NetworkRuleType[keyof typeof NetworkRuleType];
1041
+ /**
1042
+ * Represents the common properties of network rules
1043
+ */
1044
+ export interface NetworkRuleBase extends RuleBase {
1045
+ /**
1046
+ * Category of the adblock rule.
1047
+ */
1048
+ category: typeof RuleCategory.Network;
1049
+ /**
1050
+ * Type of the network rule.
1051
+ */
1052
+ type: NetworkRuleType;
1053
+ /**
1054
+ * Syntax of the adblock rule. If we are not able to determine the syntax of the rule,
1055
+ * we should use `AdblockSyntax.Common` as the value.
1056
+ */
1057
+ syntax: AdblockSyntax;
1058
+ }
1059
+ /**
1060
+ * Represents the common properties of network rules
1061
+ */
1062
+ export interface NetworkRule extends NetworkRuleBase {
1063
+ /**
1064
+ * Type of the node.
1065
+ */
1066
+ type: typeof NetworkRuleType.NetworkRule;
1067
+ /**
1068
+ * If the rule is an exception rule. If the rule begins with `@@`, it means that it is an exception rule.
1069
+ *
1070
+ * @example
1071
+ * The following rule is an exception rule:
1072
+ * ```adblock
1073
+ * @@||example.org^
1074
+ * ```
1075
+ * since it begins with `@@`, which is the exception marker.
1076
+ *
1077
+ * But the following rule is not an exception rule:
1078
+ * ```adblock
1079
+ * ||example.org^
1080
+ * ```
1081
+ * since it does not begins with `@@`.
1082
+ */
1083
+ exception: boolean;
1084
+ /**
1085
+ * The rule pattern.
1086
+ *
1087
+ * @example
1088
+ * - Let's say we have the following rule:
1089
+ * ```adblock
1090
+ * ||example.org^
1091
+ * ```
1092
+ * then the pattern of this rule is `||example.org^`.
1093
+ * - But let's say we have the following rule:
1094
+ * ```adblock
1095
+ * ||example.org^$third-party,script
1096
+ * ```
1097
+ * then the pattern of this rule is also `||example.org^`.
1098
+ */
1099
+ pattern: Value;
1100
+ /**
1101
+ * The rule modifiers.
1102
+ *
1103
+ * @example
1104
+ * - Let's say we have the following rule:
1105
+ * ```adblock
1106
+ * ||example.org^$third-party
1107
+ * ```
1108
+ * then the modifiers of this rule are `["third-party"]`.
1109
+ */
1110
+ modifiers?: ModifierList;
1111
+ }
1112
+ /**
1113
+ * Represents a list of hostnames.
1114
+ */
1115
+ export interface HostnameList extends Node {
1116
+ /**
1117
+ * Type of the node.
1118
+ */
1119
+ type: 'HostnameList';
1120
+ /**
1121
+ * List of hostnames.
1122
+ */
1123
+ children: Value[];
1124
+ }
1125
+ /**
1126
+ * Represents the common properties of host rules.
1127
+ *
1128
+ * @see https://adguard-dns.io/kb/general/dns-filtering-syntax/#etc-hosts-syntax
1129
+ */
1130
+ export interface HostRule extends NetworkRuleBase {
1131
+ /**
1132
+ * Type of the node.
1133
+ */
1134
+ type: typeof NetworkRuleType.HostRule;
1135
+ /**
1136
+ * IP address. It can be an IPv4 or IPv6 address.
1137
+ *
1138
+ * @example
1139
+ * ```text
1140
+ * 127.0.0.1 example.com example.org
1141
+ * ↑↑↑↑↑↑↑↑↑
1142
+ * ```
1143
+ * @note If IP is not specified in the rule, it parsed as null IP: `0.0.0.0`.
1144
+ */
1145
+ ip: Value;
1146
+ /**
1147
+ * Hostnames.
1148
+ *
1149
+ * @example
1150
+ * ```text
1151
+ * 127.0.0.1 example.com example.org
1152
+ * ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
1153
+ * ```
1154
+ */
1155
+ hostnames: HostnameList;
1156
+ /**
1157
+ * Comment (optional).
1158
+ *
1159
+ * @example
1160
+ * ```text
1161
+ * 127.0.0.1 localhost # This is just a comment
1162
+ * ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
1163
+ * ```
1164
+ */
1165
+ comment?: Value;
1166
+ }
1167
+ /**
1168
+ * Interface for parsed uBO selector.
1169
+ */
1170
+ export interface UboSelector extends Node {
1171
+ /**
1172
+ * Node type.
1173
+ */
1174
+ type: 'UboSelector';
1175
+ /**
1176
+ * Selector string cleaned from uBO specific syntax.
1177
+ */
1178
+ selector: Value;
1179
+ /**
1180
+ * List of uBO modifiers applied to the selector.
1181
+ */
1182
+ modifiers?: ModifierList;
1183
+ }