@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,280 @@
1
+ /**
2
+ * @file Utility functions for string manipulation.
3
+ */
4
+ export declare const SINGLE_QUOTE_MARKER = "'";
5
+ export declare const DOUBLE_QUOTE_MARKER = "\"";
6
+ export type NewLineType = 'lf' | 'crlf' | 'cr';
7
+ export type NewLineSplit = [string, NewLineType | null][];
8
+ /**
9
+ * Utility functions for string manipulation.
10
+ */
11
+ export declare class StringUtils {
12
+ /**
13
+ * Finds the first occurrence of a character that:
14
+ * - isn't preceded by an escape character
15
+ *
16
+ * @param pattern - Source pattern
17
+ * @param searchedCharacter - Searched character
18
+ * @param start - Start index
19
+ * @param escapeCharacter - Escape character, \ by default
20
+ * @param end - End index (excluded)
21
+ * @returns Index or -1 if the character not found
22
+ */
23
+ static findNextUnescapedCharacter(pattern: string, searchedCharacter: string, start?: number, escapeCharacter?: string, end?: number): number;
24
+ /**
25
+ * Finds the first occurrence in backward direction of a character that isn't preceded by an escape character.
26
+ *
27
+ * @param pattern - Source pattern
28
+ * @param searchedCharacter - Searched character
29
+ * @param start - Start index
30
+ * @param escapeCharacter - Escape character, \ by default
31
+ * @param end - End index (Included)
32
+ * @returns Index or -1 if the character not found
33
+ */
34
+ static findNextUnescapedCharacterBackwards(pattern: string, searchedCharacter: string, start?: number, escapeCharacter?: string, end?: number): number;
35
+ /**
36
+ * Finds the last occurrence of a character that:
37
+ * - isn't preceded by an escape character
38
+ *
39
+ * @param pattern - Source pattern
40
+ * @param searchedCharacter - Searched character
41
+ * @param escapeCharacter - Escape character, \ by default
42
+ * @returns Index or -1 if the character not found
43
+ */
44
+ static findLastUnescapedCharacter(pattern: string, searchedCharacter: string, escapeCharacter?: string): number;
45
+ /**
46
+ * Finds the next occurrence of a character that:
47
+ * - isn't preceded by an escape character
48
+ * - isn't followed by the specified character
49
+ *
50
+ * @param pattern - Source pattern
51
+ * @param start - Start index
52
+ * @param searchedCharacter - Searched character
53
+ * @param notFollowedBy - Searched character not followed by this character
54
+ * @param escapeCharacter - Escape character, \ by default
55
+ * @returns Index or -1 if the character not found
56
+ */
57
+ static findNextUnescapedCharacterThatNotFollowedBy(pattern: string, start: number, searchedCharacter: string, notFollowedBy: string, escapeCharacter?: string): number;
58
+ /**
59
+ * Finds the last occurrence of a character that:
60
+ * - isn't preceded by an escape character
61
+ * - isn't followed by the specified character
62
+ *
63
+ * @param pattern - Source pattern
64
+ * @param searchedCharacter - Searched character
65
+ * @param notFollowedBy - Searched character not followed by this character
66
+ * @param escapeCharacter - Escape character, \ by default
67
+ * @returns Index or -1 if the character not found
68
+ */
69
+ static findLastUnescapedCharacterThatNotFollowedBy(pattern: string, searchedCharacter: string, notFollowedBy: string, escapeCharacter?: string): number;
70
+ /**
71
+ * Finds the next occurrence of a character that:
72
+ * - isn't part of any string literal ('literal' or "literal")
73
+ * - isn't part of any RegExp expression (/regexp/)
74
+ *
75
+ * @param pattern - Source pattern
76
+ * @param searchedCharacter - Searched character
77
+ * @param start - Start index
78
+ * @returns Index or -1 if the character not found
79
+ */
80
+ static findUnescapedNonStringNonRegexChar(pattern: string, searchedCharacter: string, start?: number): number;
81
+ /**
82
+ * Finds the next occurrence of a character that:
83
+ * - isn't part of any string literal ('literal' or "literal")
84
+ * - isn't preceded by an escape character
85
+ *
86
+ * @param pattern - Source pattern
87
+ * @param searchedCharacter - Searched character
88
+ * @param start - Start index
89
+ * @param escapeCharacter - Escape character, \ by default
90
+ * @returns Index or -1 if the character not found
91
+ */
92
+ static findNextUnquotedUnescapedCharacter(pattern: string, searchedCharacter: string, start?: number, escapeCharacter?: string): number;
93
+ /**
94
+ * Finds the next occurrence of a character that:
95
+ * - isn't "bracketed"
96
+ * - isn't preceded by an escape character
97
+ *
98
+ * @param pattern - Source pattern
99
+ * @param searchedCharacter - Searched character
100
+ * @param start - Start index
101
+ * @param escapeCharacter - Escape character, \ by default
102
+ * @param openBracket - Open bracket, ( by default
103
+ * @param closeBracket - Close bracket, ( by default
104
+ * @throws If the opening and closing brackets are the same
105
+ * @returns Index or -1 if the character not found
106
+ */
107
+ static findNextNotBracketedUnescapedCharacter(pattern: string, searchedCharacter: string, start?: number, escapeCharacter?: string, openBracket?: string, closeBracket?: string): number;
108
+ /**
109
+ * Splits the source pattern along characters that:
110
+ * - isn't part of any string literal ('literal' or "literal")
111
+ * - isn't preceded by an escape character
112
+ *
113
+ * @param pattern - Source pattern
114
+ * @param delimeterCharacter - Delimeter character
115
+ * @returns Splitted string
116
+ */
117
+ static splitStringByUnquotedUnescapedCharacter(pattern: string, delimeterCharacter: string): string[];
118
+ /**
119
+ * Splits the source pattern along characters that:
120
+ * - isn't part of any string literal ('literal' or "literal")
121
+ * - isn't part of any RegExp expression (/regexp/)
122
+ * - isn't preceded by an escape character
123
+ *
124
+ * @param pattern - Source pattern
125
+ * @param delimeterCharacter - Delimeter character
126
+ * @returns Splitted string
127
+ */
128
+ static splitStringByUnescapedNonStringNonRegexChar(pattern: string, delimeterCharacter: string): string[];
129
+ /**
130
+ * Splits the source pattern along characters that:
131
+ * - isn't preceded by an escape character
132
+ *
133
+ * @param pattern - Source pattern
134
+ * @param delimeterCharacter - Delimeter character
135
+ * @returns Splitted string
136
+ */
137
+ static splitStringByUnescapedCharacter(pattern: string, delimeterCharacter: string): string[];
138
+ /**
139
+ * Determines whether the given character is a space or tab character.
140
+ *
141
+ * @param char - The character to check.
142
+ * @returns true if the given character is a space or tab character, false otherwise.
143
+ */
144
+ static isWhitespace(char: string): boolean;
145
+ /**
146
+ * Checks if the given character is a digit.
147
+ *
148
+ * @param char The character to check.
149
+ * @returns `true` if the given character is a digit, `false` otherwise.
150
+ */
151
+ static isDigit(char: string): boolean;
152
+ /**
153
+ * Checks if the given character is a small letter.
154
+ *
155
+ * @param char The character to check.
156
+ * @returns `true` if the given character is a small letter, `false` otherwise.
157
+ */
158
+ static isSmallLetter(char: string): boolean;
159
+ /**
160
+ * Checks if the given character is a capital letter.
161
+ *
162
+ * @param char The character to check.
163
+ * @returns `true` if the given character is a capital letter, `false` otherwise.
164
+ */
165
+ static isCapitalLetter(char: string): boolean;
166
+ /**
167
+ * Checks if the given character is a letter (small or capital).
168
+ *
169
+ * @param char The character to check.
170
+ * @returns `true` if the given character is a letter, `false` otherwise.
171
+ */
172
+ static isLetter(char: string): boolean;
173
+ /**
174
+ * Checks if the given character is a letter or a digit.
175
+ *
176
+ * @param char Character to check
177
+ * @returns `true` if the given character is a letter or a digit, `false` otherwise.
178
+ */
179
+ static isAlphaNumeric(char: string): boolean;
180
+ /**
181
+ * Searches for the first non-whitespace character in the source pattern.
182
+ *
183
+ * @param pattern - Source pattern
184
+ * @param start - Start index
185
+ * @returns Index or -1 if the character not found
186
+ */
187
+ static findFirstNonWhitespaceCharacter(pattern: string, start?: number): number;
188
+ /**
189
+ * Searches for the last non-whitespace character in the source pattern.
190
+ *
191
+ * @param pattern - Source pattern
192
+ * @returns Index or -1 if the character not found
193
+ */
194
+ static findLastNonWhitespaceCharacter(pattern: string): number;
195
+ /**
196
+ * Finds the next whitespace character in the pattern.
197
+ *
198
+ * @param pattern Pattern to search in
199
+ * @param start Start index
200
+ * @returns Index of the next whitespace character or the length of the pattern if not found
201
+ */
202
+ static findNextWhitespaceCharacter(pattern: string, start?: number): number;
203
+ /**
204
+ * Escapes a specified character in the string.
205
+ *
206
+ * @param pattern - Input string
207
+ * @param character - Character to escape
208
+ * @param escapeCharacter - Escape character (optional)
209
+ * @returns Escaped string
210
+ */
211
+ static escapeCharacter(pattern: string, character: string, escapeCharacter?: string): string;
212
+ /**
213
+ * Searches for the next non-whitespace character in the source pattern.
214
+ *
215
+ * @param pattern Pattern to search
216
+ * @param start Start index
217
+ * @returns Index of the next non-whitespace character or the length of the pattern
218
+ */
219
+ static skipWS(pattern: string, start?: number): number;
220
+ /**
221
+ * Searches for the previous non-whitespace character in the source pattern.
222
+ *
223
+ * @param pattern Pattern to search
224
+ * @param start Start index
225
+ * @returns Index of the previous non-whitespace character or -1
226
+ */
227
+ static skipWSBack(pattern: string, start?: number): number;
228
+ /**
229
+ * Checks if the given character is a new line character.
230
+ *
231
+ * @param char Character to check
232
+ * @returns `true` if the given character is a new line character, `false` otherwise.
233
+ */
234
+ static isEOL(char: string): boolean;
235
+ /**
236
+ * Splits a string along newline characters.
237
+ *
238
+ * @param input - Input string
239
+ * @returns Splitted string
240
+ */
241
+ static splitStringByNewLines(input: string): string[];
242
+ /**
243
+ * Splits a string by new lines and stores the new line type for each line
244
+ *
245
+ * @param input The input string to be split
246
+ * @returns An array of tuples, where each tuple contains a line of the input string and its
247
+ * corresponding new line type ("lf", "crlf", or "cr")
248
+ */
249
+ static splitStringByNewLinesEx(input: string): NewLineSplit;
250
+ /**
251
+ * Merges an array of tuples (line, newLineType) into a single string
252
+ *
253
+ * @param input The array of tuples to be merged
254
+ * @returns A single string containing the lines and new line characters from the input array
255
+ */
256
+ static mergeStringByNewLines(input: NewLineSplit): string;
257
+ /**
258
+ * Helper method to parse a raw string as a number
259
+ *
260
+ * @param raw Raw string to parse
261
+ * @returns Parsed number
262
+ * @throws If the raw string can't be parsed as a number
263
+ */
264
+ static parseNumber(raw: string): number;
265
+ /**
266
+ * Checks if the given value is a string.
267
+ *
268
+ * @param value Value to check
269
+ * @returns `true` if the value is a string, `false` otherwise
270
+ */
271
+ static isString(value: unknown): value is string;
272
+ /**
273
+ * Escapes the given characters in the input string.
274
+ *
275
+ * @param input Input string
276
+ * @param characters Characters to escape (by default, no characters are escaped)
277
+ * @returns Escaped string
278
+ */
279
+ static escapeCharacters(input: string, characters?: Set<string>): string;
280
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @file Optimized utility for decoding strings from byte sequences.
3
+ */
4
+ /**
5
+ * Decodes a byte sequence into an UTF-8 string according to the WHATWG spec.
6
+ * Optimized for performance.
7
+ *
8
+ * @param buffer Buffer to read the bytes from.
9
+ * @param start Start offset in the buffer.
10
+ * @param end End offset in the buffer.
11
+ * @returns Decoded string.
12
+ * @see {@link https://encoding.spec.whatwg.org/#utf-8-decoder}
13
+ */
14
+ export declare const decodeTextPolyfill: (buffer: Uint8Array, start?: number, end?: number) => string;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @file Utility for encoding strings to byte sequences.
3
+ */
4
+ export interface TextEncoderPolyfillResult {
5
+ readonly written: number;
6
+ readonly read: number;
7
+ }
8
+ /**
9
+ * Encodes an UTF-8 string into a byte sequence according to the WHATWG spec.
10
+ *
11
+ * @param str String to encode.
12
+ * @param buffer Buffer to write the encoded bytes to.
13
+ * @returns Number of bytes written to the buffer.
14
+ * @see {@link https://encoding.spec.whatwg.org/#utf-8-encoder}
15
+ * @note Bytes written maybe larger than the string length, but never smaller.
16
+ * For example, the string '你好' has a length of 2, but its byte representation has a length of 6.
17
+ */
18
+ export declare const encodeIntoPolyfill: (str: string, buffer: Uint8Array) => TextEncoderPolyfillResult;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Checks whether the given value is undefined.
3
+ *
4
+ * @param value Value to check.
5
+ *
6
+ * @returns `true` if the value is 'undefined', `false` otherwise.
7
+ */
8
+ export declare const isUndefined: (value: unknown) => value is undefined;
9
+ /**
10
+ * Checks whether the given value is null.
11
+ *
12
+ * @param value Value to check.
13
+ *
14
+ * @returns `true` if the value is 'null', `false` otherwise.
15
+ */
16
+ export declare const isNull: (value: unknown) => value is null;
17
+ /**
18
+ * Checks whether the given value is a number.
19
+ *
20
+ * @param value Value to check.
21
+ *
22
+ * @returns `true` if the value is a number, `false` otherwise.
23
+ */
24
+ export declare const isNumber: (value: unknown) => value is number;
25
+ /**
26
+ * Checks whether the given value is an integer.
27
+ *
28
+ * @param value Value to check.
29
+ *
30
+ * @returns `true` if the value is an integer, `false` otherwise.
31
+ */
32
+ export declare const isInteger: (value: unknown) => value is number;
33
+ /**
34
+ * Checks whether the given value is a string.
35
+ *
36
+ * @param value Value to check.
37
+ * @returns `true` if the value is a string, `false` otherwise.
38
+ */
39
+ export declare const isString: (value: unknown) => value is string;
40
+ /**
41
+ * Checks whether the given value is an array of Uint8Arrays.
42
+ *
43
+ * @param value Value to check.
44
+ *
45
+ * @returns True if the value type is an array of Uint8Arrays.
46
+ */
47
+ export declare const isArrayOfUint8Arrays: (value: unknown) => value is Uint8Array[];
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Prefixes for different adblockers to describe the platform-specific modifiers data
3
+ * stored in the yaml files.
4
+ */
5
+ export declare const BLOCKER_PREFIX: {
6
+ AdGuard: string;
7
+ UblockOrigin: string;
8
+ AdblockPlus: string;
9
+ };
10
+ /**
11
+ * Set of all allowed characters for app name except the dot `.`.
12
+ */
13
+ export declare const APP_NAME_ALLOWED_CHARS: Set<string>;
14
+ /**
15
+ * Allowed methods for $method modifier.
16
+ *
17
+ * @see {@link https://adguard.app/kb/general/ad-filtering/create-own-filters/#method-modifier}
18
+ */
19
+ export declare const ALLOWED_METHODS: Set<string>;
20
+ /**
21
+ * Allowed stealth options for $stealth modifier.
22
+ *
23
+ * @see {@link https://adguard.app/kb/general/ad-filtering/create-own-filters/#stealth-modifier}
24
+ */
25
+ export declare const ALLOWED_STEALTH_OPTIONS: Set<string>;
26
+ /**
27
+ * Allowed CSP directives for $csp modifier.
28
+ *
29
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy#directives}
30
+ */
31
+ export declare const ALLOWED_CSP_DIRECTIVES: Set<string>;
32
+ /**
33
+ * Allowed directives for $permissions modifier.
34
+ *
35
+ * @see {@link https://adguard.app/kb/general/ad-filtering/create-own-filters/#permissions-modifier}
36
+ */
37
+ export declare const ALLOWED_PERMISSION_DIRECTIVES: Set<string>;
38
+ /**
39
+ * One of available tokens for $permission modifier value.
40
+ *
41
+ * @see {@link https://w3c.github.io/webappsec-permissions-policy/#structured-header-serialization}
42
+ */
43
+ export declare const PERMISSIONS_TOKEN_SELF = "self";
44
+ /**
45
+ * One of allowlist values for $permissions modifier.
46
+ *
47
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Permissions_Policy#allowlists}
48
+ */
49
+ export declare const EMPTY_PERMISSIONS_ALLOWLIST = "()";
50
+ /**
51
+ * Allowed directives for $referrerpolicy modifier.
52
+ *
53
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referrer-Policy}
54
+ */
55
+ export declare const REFERRER_POLICY_DIRECTIVES: Set<string>;
56
+ /**
57
+ * Prefixes for error messages used in modifier validation.
58
+ */
59
+ export declare const VALIDATION_ERROR_PREFIX: {
60
+ BLOCK_ONLY: string;
61
+ EXCEPTION_ONLY: string;
62
+ INVALID_CSP_DIRECTIVES: string;
63
+ INVALID_LIST_VALUES: string;
64
+ INVALID_NOOP: string;
65
+ INVALID_PERMISSION_DIRECTIVE: string;
66
+ INVALID_PERMISSION_ORIGINS: string;
67
+ INVALID_PERMISSION_ORIGIN_QUOTES: string;
68
+ INVALID_REFERRER_POLICY_DIRECTIVE: string;
69
+ MIXED_NEGATIONS: string;
70
+ NO_CSP_VALUE: string;
71
+ NO_CSP_DIRECTIVE_QUOTE: string;
72
+ NO_UNESCAPED_PERMISSION_COMMA: string;
73
+ NOT_EXISTENT: string;
74
+ NOT_NEGATABLE_MODIFIER: string;
75
+ NOT_NEGATABLE_VALUE: string;
76
+ NOT_SUPPORTED: string;
77
+ REMOVED: string;
78
+ VALUE_FORBIDDEN: string;
79
+ VALUE_INVALID: string;
80
+ VALUE_REQUIRED: string;
81
+ };
82
+ /**
83
+ * Prefixes for error messages related to issues in the source YAML files' data.
84
+ */
85
+ export declare const SOURCE_DATA_ERROR_PREFIX: {
86
+ INVALID_VALUE_FORMAT_REGEXP: string;
87
+ NO_DEPRECATION_MESSAGE: string;
88
+ NO_VALUE_FORMAT_FOR_ASSIGNABLE: string;
89
+ };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Result of modifier validation:
3
+ * - `{ valid: true }` for valid and _fully supported_ modifier;
4
+ * - `{ valid: true, warn: <deprecation notice> }` for valid
5
+ * and _still supported but deprecated_ modifier;
6
+ * - otherwise `{ valid: true, error: <invalidity reason> }`
7
+ */
8
+ export type ValidationResult = {
9
+ valid: boolean;
10
+ error?: string;
11
+ warn?: string;
12
+ };
13
+ /**
14
+ * Validates the noop modifier (i.e. only underscores).
15
+ *
16
+ * @param value Value of the modifier.
17
+ *
18
+ * @returns True if the modifier is valid, false otherwise.
19
+ */
20
+ export declare const isValidNoopModifier: (value: string) => boolean;
21
+ /**
22
+ * Returns invalid validation result with given error message.
23
+ *
24
+ * @param error Error message.
25
+ *
26
+ * @returns Validation result `{ valid: false, error }`.
27
+ */
28
+ export declare const getInvalidValidationResult: (error: string) => ValidationResult;
29
+ /**
30
+ * Returns invalid validation result which uses {@link VALIDATION_ERROR_PREFIX.VALUE_REQUIRED} as prefix
31
+ * and specifies the given `modifierName` in the error message.
32
+ *
33
+ * @param modifierName Modifier name.
34
+ *
35
+ * @returns Validation result `{ valid: false, error }`.
36
+ */
37
+ export declare const getValueRequiredValidationResult: (modifierName: string) => ValidationResult;
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @file Validator for modifiers.
3
+ */
4
+ import { type Modifier } from '../nodes';
5
+ import { AdblockSyntax } from '../utils/adblockers';
6
+ import { type ValidationResult } from './helpers';
7
+ /**
8
+ * Modifier validator class.
9
+ */
10
+ declare class ModifierValidator {
11
+ /**
12
+ * Simply checks whether the modifier exists in any adblocker.
13
+ *
14
+ * **Deprecated** and **removed** modifiers are considered as **existent**.
15
+ *
16
+ * @param modifier Already parsed modifier AST node.
17
+ *
18
+ * @returns True if modifier exists, false otherwise.
19
+ */
20
+ exists: (modifier: Modifier) => boolean;
21
+ /**
22
+ * Checks whether the given `modifier` is valid for specified `syntax`.
23
+ *
24
+ * For `Common` syntax it simply checks whether the modifier exists.
25
+ * For specific syntax the validation is more complex —
26
+ * deprecated, assignable, negatable and other requirements are checked.
27
+ *
28
+ * @param syntax Adblock syntax to check the modifier for.
29
+ * @param rawModifier Modifier AST node.
30
+ * @param isException Whether the modifier is used in exception rule, default to false.
31
+ * Needed to check whether the modifier is allowed only in blocking or exception rules.
32
+ *
33
+ * @returns Result of modifier validation.
34
+ */
35
+ validate: (syntax: AdblockSyntax, rawModifier: Modifier, isException?: boolean) => ValidationResult;
36
+ }
37
+ export declare const modifierValidator: ModifierValidator;
38
+ export {};
@@ -0,0 +1,12 @@
1
+ import { type Modifier } from '../nodes';
2
+ import { type ValidationResult } from './helpers';
3
+ /**
4
+ * Checks whether the value for given `modifier` is valid.
5
+ *
6
+ * @param modifier Modifier AST node.
7
+ * @param valueFormat Value format for the modifier.
8
+ * @param valueFormatFlags Optional; RegExp flags for the value format.
9
+ *
10
+ * @returns Validation result.
11
+ */
12
+ export declare const validateValue: (modifier: Modifier, valueFormat: string, valueFormatFlags?: string | null) => ValidationResult;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @file AGTree version
3
+ */
4
+ declare const AGTREE_VERSION: string;
5
+ export { AGTREE_VERSION };
@@ -0,0 +1,56 @@
1
+ /*
2
+ * AGTree v3.0.0-alpha.2 (build date: Tue, 17 Dec 2024 16:50:04 GMT)
3
+ * (c) 2024 Adguard Software Ltd.
4
+ * Released under the MIT license
5
+ * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
6
+ */
7
+ /**
8
+ * @file Possible adblock syntaxes are listed here.
9
+ */
10
+ /**
11
+ * Possible adblock syntaxes (supported by this library)
12
+ */
13
+ const AdblockSyntax = {
14
+ /**
15
+ * Common syntax, which is supported by more than one adblocker (or by all adblockers).
16
+ *
17
+ * We typically use this syntax when we cannot determine the concrete syntax of the rule,
18
+ * because the syntax is used by more than one adblocker natively.
19
+ *
20
+ * @example
21
+ * - `||example.org^$important` is a common syntax, since it is used by all adblockers natively, and
22
+ * we cannot determine at parsing level whether `important` is a valid option or not, and if it is valid,
23
+ * then which adblocker supports it.
24
+ */
25
+ Common: 'Common',
26
+ /**
27
+ * Adblock Plus syntax.
28
+ *
29
+ * @example
30
+ * - `example.org#$#abort-on-property-read alert` is an Adblock Plus syntax, since it is not used by any other
31
+ * adblockers directly (probably supported by some on-the-fly conversion, but this is not the native syntax).
32
+ * @see {@link https://adblockplus.org/}
33
+ */
34
+ Abp: 'AdblockPlus',
35
+ /**
36
+ * uBlock Origin syntax.
37
+ *
38
+ * @example
39
+ * - `example.com##+js(set, atob, noopFunc)` is an uBlock Origin syntax, since it is not used by any other
40
+ * adblockers directly (probably supported by some on-the-fly conversion, but this is not the native syntax).
41
+ * @see {@link https://github.com/gorhill/uBlock}
42
+ */
43
+ Ubo: 'UblockOrigin',
44
+ /**
45
+ * AdGuard syntax.
46
+ *
47
+ * @example
48
+ * - `example.org#%#//scriptlet("abort-on-property-read", "alert")` is an AdGuard syntax, since it is not used
49
+ * by any other adblockers directly (probably supported by some on-the-fly conversion, but this is not the native
50
+ * syntax).
51
+ * @see {@link https://adguard.com/}
52
+ */
53
+ Adg: 'AdGuard',
54
+ };
55
+
56
+ export { AdblockSyntax };
@@ -0,0 +1,17 @@
1
+ /*
2
+ * AGTree v3.0.0-alpha.2 (build date: Tue, 17 Dec 2024 16:50:04 GMT)
3
+ * (c) 2024 Adguard Software Ltd.
4
+ * Released under the MIT license
5
+ * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
6
+ */
7
+ /**
8
+ * @file Binary schema version.
9
+ */
10
+ /**
11
+ * Binary schema version.
12
+ * This version number is used to ensure that the binary format is compatible with the current library version.
13
+ * We increment this number if the serialized format changes in a way that is not backwards-compatible.
14
+ */
15
+ const BINARY_SCHEMA_VERSION = 1;
16
+
17
+ export { BINARY_SCHEMA_VERSION };