@adguard/agtree 3.4.3 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (421) hide show
  1. package/dist/ast-utils/clone.js +2 -2
  2. package/dist/ast-utils/modifiers.js +2 -2
  3. package/dist/ast-utils/network-rules.js +2 -2
  4. package/dist/ast-utils/scriptlets.js +2 -2
  5. package/dist/common/abp-snippet-injection-body-common.js +2 -2
  6. package/dist/common/agent-common.js +2 -2
  7. package/dist/common/ubo-html-filtering-body-common.js +40 -0
  8. package/dist/common/ubo-selector-common.js +2 -2
  9. package/dist/compatibility-tables/base.js +2 -2
  10. package/dist/compatibility-tables/compatibility-table-data.js +2 -2
  11. package/dist/compatibility-tables/modifiers.js +2 -2
  12. package/dist/compatibility-tables/platforms.js +2 -2
  13. package/dist/compatibility-tables/redirects.js +2 -2
  14. package/dist/compatibility-tables/schemas/base.js +2 -2
  15. package/dist/compatibility-tables/schemas/modifier.js +2 -2
  16. package/dist/compatibility-tables/schemas/platform.js +2 -2
  17. package/dist/compatibility-tables/schemas/redirect.js +2 -2
  18. package/dist/compatibility-tables/schemas/resource-type.js +2 -2
  19. package/dist/compatibility-tables/schemas/scriptlet.js +2 -2
  20. package/dist/compatibility-tables/scriptlets.js +2 -2
  21. package/dist/compatibility-tables/utils/platform-helpers.js +2 -2
  22. package/dist/compatibility-tables/utils/resource-type-helpers.js +2 -2
  23. package/dist/compatibility-tables/utils/zod-camelcase.js +2 -2
  24. package/dist/converter/base-interfaces/base-converter.js +2 -2
  25. package/dist/converter/base-interfaces/conversion-result.js +2 -2
  26. package/dist/converter/base-interfaces/rule-converter-base.js +2 -2
  27. package/dist/converter/comment/index.js +2 -2
  28. package/dist/converter/cosmetic/css.js +2 -2
  29. package/dist/converter/cosmetic/element-hiding.js +2 -2
  30. package/dist/converter/cosmetic/header-removal.js +24 -42
  31. package/dist/converter/cosmetic/html.js +580 -438
  32. package/dist/converter/cosmetic/index.js +3 -2
  33. package/dist/converter/cosmetic/rule-modifiers/adg.js +2 -2
  34. package/dist/converter/cosmetic/rule-modifiers/ubo.js +2 -2
  35. package/dist/converter/cosmetic/scriptlet.js +2 -2
  36. package/dist/converter/css/index.js +3 -2
  37. package/dist/converter/data/css.js +32 -54
  38. package/dist/converter/filter-list.js +2 -2
  39. package/dist/converter/index.js +2 -2
  40. package/dist/converter/misc/network-rule-modifier.js +2 -2
  41. package/dist/converter/network/index.js +2 -2
  42. package/dist/converter/raw-filter-list.js +2 -2
  43. package/dist/converter/raw-rule.js +6 -3
  44. package/dist/converter/rule.js +2 -2
  45. package/dist/errors/adblock-syntax-error.js +2 -2
  46. package/dist/errors/binary-schema-mismatch-error.js +2 -2
  47. package/dist/errors/not-implemented-error.js +2 -2
  48. package/dist/errors/rule-conversion-error.js +2 -2
  49. package/dist/generator/base-generator.js +2 -2
  50. package/dist/generator/comment/agent-comment-generator.js +2 -2
  51. package/dist/generator/comment/agent-generator.js +2 -2
  52. package/dist/generator/comment/comment-rule-generator.js +2 -2
  53. package/dist/generator/comment/config-comment-generator.js +2 -2
  54. package/dist/generator/comment/hint-comment-generator.js +2 -2
  55. package/dist/generator/comment/hint-generator.js +2 -2
  56. package/dist/generator/comment/metadata-comment-generator.js +2 -2
  57. package/dist/generator/comment/pre-processor-comment-generator.js +2 -2
  58. package/dist/generator/comment/simple-comment-generator.js +2 -2
  59. package/dist/generator/cosmetic/cosmetic-rule-body-generator.js +21 -6
  60. package/dist/generator/cosmetic/cosmetic-rule-generator.js +2 -2
  61. package/dist/generator/cosmetic/cosmetic-rule-pattern-generator.js +2 -2
  62. package/dist/generator/cosmetic/html-filtering-body/adg-html-filtering-body-generator.js +38 -0
  63. package/dist/generator/cosmetic/html-filtering-body/html-filtering-body-generator.js +32 -0
  64. package/dist/generator/cosmetic/html-filtering-body/ubo-html-filtering-body-generator.js +65 -0
  65. package/dist/generator/cosmetic/{body → scriptlet-body}/abp-snippet-injection-body-generator.js +2 -2
  66. package/dist/generator/cosmetic/{body → scriptlet-body}/adg-scriptlet-injection-body-generator.js +2 -2
  67. package/dist/generator/cosmetic/{body → scriptlet-body}/ubo-scriptlet-injection-body-generator.js +2 -2
  68. package/dist/generator/cosmetic/selector/attribute-selector-generator.js +42 -0
  69. package/dist/generator/cosmetic/selector/class-selector-generator.js +26 -0
  70. package/dist/generator/cosmetic/selector/complex-selector-generator.js +71 -0
  71. package/dist/generator/cosmetic/selector/id-selector-generator.js +26 -0
  72. package/dist/generator/cosmetic/selector/pseudo-class-selector-generator.js +35 -0
  73. package/dist/generator/cosmetic/selector/selector-combinator-generator.js +30 -0
  74. package/dist/generator/cosmetic/selector/selector-list-generator.js +41 -0
  75. package/dist/generator/cosmetic/selector/type-selector-generator.js +25 -0
  76. package/dist/generator/css/adg-css-injection-generator.js +5 -6
  77. package/dist/generator/filterlist-generator.js +2 -2
  78. package/dist/generator/index.js +2 -2
  79. package/dist/generator/misc/domain-list-generator.js +2 -2
  80. package/dist/generator/misc/list-items-generator.js +2 -2
  81. package/dist/generator/misc/logical-expression-generator.js +2 -2
  82. package/dist/generator/misc/modifier-generator.js +2 -2
  83. package/dist/generator/misc/modifier-list-generator.js +2 -2
  84. package/dist/generator/misc/parameter-list-generator.js +2 -2
  85. package/dist/generator/misc/value-generator.js +2 -2
  86. package/dist/generator/network/host-rule-generator.js +2 -2
  87. package/dist/generator/network/network-rule-generator.js +2 -2
  88. package/dist/generator/rule-generator.js +2 -2
  89. package/dist/index.js +4 -14
  90. package/dist/nodes/index.js +2 -2
  91. package/dist/package.json.js +3 -3
  92. package/dist/parser/base-parser.js +2 -2
  93. package/dist/parser/comment/agent-comment-parser.js +2 -2
  94. package/dist/parser/comment/agent-parser.js +2 -2
  95. package/dist/parser/comment/comment-parser.js +2 -2
  96. package/dist/parser/comment/config-comment-parser.js +2 -2
  97. package/dist/parser/comment/hint-comment-parser.js +2 -2
  98. package/dist/parser/comment/hint-parser.js +2 -2
  99. package/dist/parser/comment/metadata-comment-parser.js +2 -2
  100. package/dist/parser/comment/preprocessor-parser.js +2 -2
  101. package/dist/parser/comment/simple-comment-parser.js +2 -2
  102. package/dist/parser/cosmetic/cosmetic-rule-parser.js +10 -21
  103. package/dist/parser/cosmetic/html-filtering-body/adg-html-filtering-body-parser.js +49 -0
  104. package/dist/parser/cosmetic/html-filtering-body/html-filtering-body-parser.js +70 -0
  105. package/dist/parser/cosmetic/html-filtering-body/ubo-html-filtering-body-parser.js +180 -0
  106. package/dist/parser/cosmetic/{body → scriptlet-body}/abp-snippet-injection-body-parser.js +2 -2
  107. package/dist/parser/cosmetic/{body → scriptlet-body}/adg-scriptlet-injection-body-parser.js +2 -2
  108. package/dist/parser/cosmetic/{body → scriptlet-body}/ubo-scriptlet-injection-body-parser.js +2 -2
  109. package/dist/parser/cosmetic/selector/handlers/attribute-selector-handler.js +206 -0
  110. package/dist/parser/cosmetic/selector/handlers/class-selector-handler.js +48 -0
  111. package/dist/parser/cosmetic/selector/handlers/complex-selector-handler.js +67 -0
  112. package/dist/parser/cosmetic/selector/handlers/compound-selector-handler.js +97 -0
  113. package/dist/parser/cosmetic/selector/handlers/id-selector-handler.js +42 -0
  114. package/dist/parser/cosmetic/selector/handlers/pseudo-class-selector-handler.js +128 -0
  115. package/dist/parser/cosmetic/selector/handlers/type-selector-handler.js +58 -0
  116. package/dist/parser/cosmetic/selector/selector-list-parser.js +164 -0
  117. package/dist/parser/css/adg-css-injection-parser.js +4 -5
  118. package/dist/parser/css/balancing.js +2 -2
  119. package/dist/parser/css/constants.js +2 -2
  120. package/dist/parser/css/css-token-stream.js +41 -4
  121. package/dist/parser/css/ubo-selector-parser.js +2 -2
  122. package/dist/parser/filterlist-parser.js +2 -2
  123. package/dist/parser/index.js +2 -2
  124. package/dist/parser/misc/app-list-parser.js +2 -2
  125. package/dist/parser/misc/domain-list-parser.js +2 -2
  126. package/dist/parser/misc/list-items-parser.js +2 -2
  127. package/dist/parser/misc/logical-expression-parser.js +2 -2
  128. package/dist/parser/misc/method-list-parser.js +2 -2
  129. package/dist/parser/misc/modifier-list.js +2 -2
  130. package/dist/parser/misc/modifier-parser.js +2 -2
  131. package/dist/parser/misc/parameter-list-parser.js +2 -2
  132. package/dist/parser/misc/stealth-option-list-parser.js +2 -2
  133. package/dist/parser/misc/ubo-parameter-list-parser.js +2 -2
  134. package/dist/parser/misc/value-parser.js +2 -2
  135. package/dist/parser/network/host-rule-parser.js +2 -2
  136. package/dist/parser/network/network-rule-parser.js +2 -2
  137. package/dist/parser/options.js +3 -2
  138. package/dist/parser/rule-parser.js +2 -2
  139. package/dist/types/common/ubo-html-filtering-body-common.d.ts +12 -0
  140. package/dist/types/compatibility-tables/compatibility-table-data.d.ts +3 -3
  141. package/dist/types/compatibility-tables/schemas/redirect.d.ts +1 -1
  142. package/dist/types/compatibility-tables/schemas/scriptlet.d.ts +2 -2
  143. package/dist/types/converter/cosmetic/html.d.ts +167 -42
  144. package/dist/types/converter/data/css.d.ts +18 -6
  145. package/dist/types/generator/cosmetic/html-filtering-body/adg-html-filtering-body-generator.d.ts +17 -0
  146. package/dist/types/generator/cosmetic/html-filtering-body/html-filtering-body-generator.d.ts +17 -0
  147. package/dist/types/generator/cosmetic/html-filtering-body/ubo-html-filtering-body-generator.d.ts +30 -0
  148. package/dist/types/generator/cosmetic/selector/attribute-selector-generator.d.ts +15 -0
  149. package/dist/types/generator/cosmetic/selector/class-selector-generator.d.ts +15 -0
  150. package/dist/types/generator/cosmetic/selector/complex-selector-generator.d.ts +17 -0
  151. package/dist/types/generator/cosmetic/selector/id-selector-generator.d.ts +15 -0
  152. package/dist/types/generator/cosmetic/selector/pseudo-class-selector-generator.d.ts +15 -0
  153. package/dist/types/generator/cosmetic/selector/selector-combinator-generator.d.ts +15 -0
  154. package/dist/types/generator/cosmetic/selector/selector-list-generator.d.ts +17 -0
  155. package/dist/types/generator/cosmetic/selector/type-selector-generator.d.ts +15 -0
  156. package/dist/types/generator/css/adg-css-injection-generator.d.ts +1 -1
  157. package/dist/types/index.d.ts +3 -13
  158. package/dist/types/nodes/index.d.ts +159 -3
  159. package/dist/types/parser/cosmetic/html-filtering-body/adg-html-filtering-body-parser.d.ts +35 -0
  160. package/dist/types/parser/cosmetic/html-filtering-body/html-filtering-body-parser.d.ts +39 -0
  161. package/dist/types/parser/cosmetic/html-filtering-body/ubo-html-filtering-body-parser.d.ts +63 -0
  162. package/dist/types/parser/cosmetic/selector/context.d.ts +42 -0
  163. package/dist/types/parser/cosmetic/selector/handlers/attribute-selector-handler.d.ts +35 -0
  164. package/dist/types/parser/cosmetic/selector/handlers/class-selector-handler.d.ts +15 -0
  165. package/dist/types/parser/cosmetic/selector/handlers/complex-selector-handler.d.ts +20 -0
  166. package/dist/types/parser/cosmetic/selector/handlers/compound-selector-handler.d.ts +25 -0
  167. package/dist/types/parser/cosmetic/selector/handlers/id-selector-handler.d.ts +15 -0
  168. package/dist/types/parser/cosmetic/selector/handlers/pseudo-class-selector-handler.d.ts +15 -0
  169. package/dist/types/parser/cosmetic/selector/handlers/type-selector-handler.d.ts +15 -0
  170. package/dist/types/parser/cosmetic/selector/selector-list-parser.d.ts +38 -0
  171. package/dist/types/parser/css/adg-css-injection-parser.d.ts +0 -2
  172. package/dist/types/parser/css/css-token-stream.d.ts +18 -0
  173. package/dist/types/parser/network/network-rule-parser.d.ts +1 -1
  174. package/dist/types/parser/options.d.ts +5 -0
  175. package/dist/types/utils/constants.d.ts +1 -0
  176. package/dist/types/utils/index.d.ts +0 -6
  177. package/dist/types/utils/quotes.d.ts +44 -0
  178. package/dist/types/utils/regexp.d.ts +24 -0
  179. package/dist/utils/adblockers.js +2 -2
  180. package/dist/utils/bit-count.js +2 -2
  181. package/dist/utils/categorizer.js +2 -2
  182. package/dist/utils/clone.js +2 -2
  183. package/dist/utils/constants.js +6 -9
  184. package/dist/utils/cosmetic-rule-separator.js +2 -2
  185. package/dist/utils/deep-freeze.js +2 -2
  186. package/dist/utils/domain.js +2 -2
  187. package/dist/utils/error.js +2 -2
  188. package/dist/utils/index.js +2 -8
  189. package/dist/utils/logical-expression.js +2 -2
  190. package/dist/utils/multi-value-map.js +2 -2
  191. package/dist/utils/noop-modifier.js +2 -2
  192. package/dist/utils/position-provider.js +2 -2
  193. package/dist/utils/quotes.js +163 -10
  194. package/dist/utils/regexp.js +31 -2
  195. package/dist/utils/string.js +2 -2
  196. package/dist/utils/type-guards.js +3 -13
  197. package/dist/validator/constants.js +2 -2
  198. package/dist/validator/helpers.js +2 -2
  199. package/dist/validator/index.js +2 -2
  200. package/dist/validator/value.js +2 -2
  201. package/dist/version.js +2 -2
  202. package/package.json +6 -14
  203. package/dist/deserializer/base-deserializer.js +0 -29
  204. package/dist/deserializer/comment/agent-comment-deserializer.js +0 -79
  205. package/dist/deserializer/comment/agent-deserializer.js +0 -65
  206. package/dist/deserializer/comment/comment-rule-deserializer.js +0 -54
  207. package/dist/deserializer/comment/config-comment-deserializer.js +0 -111
  208. package/dist/deserializer/comment/hint-comment-deserializer.js +0 -72
  209. package/dist/deserializer/comment/hint-deserializer.js +0 -85
  210. package/dist/deserializer/comment/metadata-comment-deserializer.js +0 -69
  211. package/dist/deserializer/comment/pre-processor-comment-deserializer.js +0 -112
  212. package/dist/deserializer/comment/simple-comment-deserializer.js +0 -65
  213. package/dist/deserializer/cosmetic/cosmetic-rule-deserializer.js +0 -131
  214. package/dist/deserializer/cosmetic/css-injection-body-deserializer.js +0 -56
  215. package/dist/deserializer/cosmetic/element-hiding-body-deserializer.js +0 -48
  216. package/dist/deserializer/cosmetic/scriptlet-body/abp-snippet-injection-body-deserializer.js +0 -39
  217. package/dist/deserializer/cosmetic/scriptlet-body/adg-scriptlet-injection-body-deserializer.js +0 -40
  218. package/dist/deserializer/cosmetic/scriptlet-body/scriptlet-body-deserializer.js +0 -54
  219. package/dist/deserializer/cosmetic/scriptlet-body/ubo-scriptlet-injection-body-deserializer.js +0 -38
  220. package/dist/deserializer/empty-rule-deserializer.js +0 -48
  221. package/dist/deserializer/filterlist-deserializer.js +0 -85
  222. package/dist/deserializer/index.js +0 -8
  223. package/dist/deserializer/invalid-rule-deserializer.js +0 -50
  224. package/dist/deserializer/invalid-rule-error-node-deserializer.js +0 -50
  225. package/dist/deserializer/misc/domain-list-deserializer.js +0 -64
  226. package/dist/deserializer/misc/list-item-deserializer.js +0 -69
  227. package/dist/deserializer/misc/list-items-deserializer.js +0 -30
  228. package/dist/deserializer/misc/logical-expression-deserializer.js +0 -196
  229. package/dist/deserializer/misc/modifier-deserializer.js +0 -87
  230. package/dist/deserializer/misc/modifier-list-deserializer.js +0 -61
  231. package/dist/deserializer/misc/parameter-list-deserializer.js +0 -64
  232. package/dist/deserializer/misc/value-deserializer.js +0 -50
  233. package/dist/deserializer/network/host-rule-deserializer.js +0 -67
  234. package/dist/deserializer/network/hostname-list-deserializer.js +0 -56
  235. package/dist/deserializer/network/network-rule-deserializer.js +0 -65
  236. package/dist/deserializer/rule-deserializer.js +0 -65
  237. package/dist/deserializer/syntax-deserialization-map.js +0 -21
  238. package/dist/marshalling-utils/comment/agent-comment-common.js +0 -21
  239. package/dist/marshalling-utils/comment/agent-common.js +0 -40
  240. package/dist/marshalling-utils/comment/config-comment-common.js +0 -54
  241. package/dist/marshalling-utils/comment/hint-comment-common.js +0 -22
  242. package/dist/marshalling-utils/comment/hint-common.js +0 -56
  243. package/dist/marshalling-utils/comment/metadata-comment-common.js +0 -41
  244. package/dist/marshalling-utils/comment/pre-processor-comment-common.js +0 -59
  245. package/dist/marshalling-utils/comment/simple-comment-common.js +0 -22
  246. package/dist/marshalling-utils/cosmetic/body/abp-snippet-injection-body-common.js +0 -61
  247. package/dist/marshalling-utils/cosmetic/body/adg-scriptlet-injection-body-common.js +0 -66
  248. package/dist/marshalling-utils/cosmetic/body/css-injection-body-common.js +0 -24
  249. package/dist/marshalling-utils/cosmetic/body/element-hiding-body-common.js +0 -21
  250. package/dist/marshalling-utils/cosmetic/body/ubo-scriptlet-injection-body-common.js +0 -114
  251. package/dist/marshalling-utils/cosmetic/cosmetic-rule-common.js +0 -46
  252. package/dist/marshalling-utils/empty-rule-common.js +0 -20
  253. package/dist/marshalling-utils/filter-list-common.js +0 -21
  254. package/dist/marshalling-utils/invalid-rule-common.js +0 -21
  255. package/dist/marshalling-utils/invalid-rule-error-node-common.js +0 -22
  256. package/dist/marshalling-utils/misc/binary-type-common.js +0 -54
  257. package/dist/marshalling-utils/misc/domain-list-common.js +0 -36
  258. package/dist/marshalling-utils/misc/host-rule-common.js +0 -24
  259. package/dist/marshalling-utils/misc/hostname-list-common.js +0 -21
  260. package/dist/marshalling-utils/misc/list-item-common.js +0 -22
  261. package/dist/marshalling-utils/misc/logical-expression-common.js +0 -83
  262. package/dist/marshalling-utils/misc/modifier-common.js +0 -231
  263. package/dist/marshalling-utils/misc/modifier-list-common.js +0 -21
  264. package/dist/marshalling-utils/misc/parameter-list-common.js +0 -21
  265. package/dist/marshalling-utils/misc/value-common.js +0 -22
  266. package/dist/marshalling-utils/network/network-rule-common.js +0 -24
  267. package/dist/marshalling-utils/syntax-serialization-map.js +0 -30
  268. package/dist/serializer/base-serializer.js +0 -29
  269. package/dist/serializer/comment/agent-comment-serializer.js +0 -74
  270. package/dist/serializer/comment/agent-serializer.js +0 -59
  271. package/dist/serializer/comment/comment-rule-serializer.js +0 -105
  272. package/dist/serializer/comment/config-comment-serializer.js +0 -82
  273. package/dist/serializer/comment/hint-comment-serializer.js +0 -65
  274. package/dist/serializer/comment/hint-serializer.js +0 -54
  275. package/dist/serializer/comment/metadata-comment-serializer.js +0 -73
  276. package/dist/serializer/comment/pre-processor-comment-serializer.js +0 -71
  277. package/dist/serializer/comment/simple-comment-serializer.js +0 -52
  278. package/dist/serializer/cosmetic/body/abp-snippet-injection-body-serializer.js +0 -36
  279. package/dist/serializer/cosmetic/body/adg-scriptlet-injection-body-serializer.js +0 -36
  280. package/dist/serializer/cosmetic/body/scriptlet-body-serializer.js +0 -50
  281. package/dist/serializer/cosmetic/body/ubo-scriptlet-injection-body-serializer.js +0 -36
  282. package/dist/serializer/cosmetic/cosmetic-rule-serializer.js +0 -120
  283. package/dist/serializer/cosmetic/css-injection-body-serializer.js +0 -51
  284. package/dist/serializer/cosmetic/element-hiding-body-serializer.js +0 -40
  285. package/dist/serializer/empty-rule-serializer.js +0 -37
  286. package/dist/serializer/filterlist-serializer.js +0 -45
  287. package/dist/serializer/index.js +0 -7
  288. package/dist/serializer/invalid-rule-error-node-serializer.js +0 -41
  289. package/dist/serializer/invalid-rule-serializer.js +0 -40
  290. package/dist/serializer/misc/domain-list-serializer.js +0 -64
  291. package/dist/serializer/misc/list-item-serializer.js +0 -58
  292. package/dist/serializer/misc/list-items-serializer.js +0 -29
  293. package/dist/serializer/misc/logical-expression-serializer.js +0 -136
  294. package/dist/serializer/misc/modifier-list-serializer.js +0 -58
  295. package/dist/serializer/misc/modifier-serializer.js +0 -49
  296. package/dist/serializer/misc/parameter-list-serializer.js +0 -52
  297. package/dist/serializer/misc/value-serializer.js +0 -50
  298. package/dist/serializer/network/host-rule-serializer.js +0 -70
  299. package/dist/serializer/network/hostname-list-serializer.js +0 -53
  300. package/dist/serializer/network/network-rule-serializer.js +0 -54
  301. package/dist/serializer/rule-serializer.js +0 -61
  302. package/dist/types/deserializer/base-deserializer.d.ts +0 -15
  303. package/dist/types/deserializer/comment/agent-comment-deserializer.d.ts +0 -34
  304. package/dist/types/deserializer/comment/agent-deserializer.d.ts +0 -25
  305. package/dist/types/deserializer/comment/comment-rule-deserializer.d.ts +0 -16
  306. package/dist/types/deserializer/comment/config-comment-deserializer.d.ts +0 -27
  307. package/dist/types/deserializer/comment/hint-comment-deserializer.d.ts +0 -24
  308. package/dist/types/deserializer/comment/hint-deserializer.d.ts +0 -26
  309. package/dist/types/deserializer/comment/metadata-comment-deserializer.d.ts +0 -26
  310. package/dist/types/deserializer/comment/pre-processor-comment-deserializer.d.ts +0 -29
  311. package/dist/types/deserializer/comment/simple-comment-deserializer.d.ts +0 -26
  312. package/dist/types/deserializer/cosmetic/cosmetic-rule-deserializer.d.ts +0 -18
  313. package/dist/types/deserializer/cosmetic/css-injection-body-deserializer.d.ts +0 -15
  314. package/dist/types/deserializer/cosmetic/element-hiding-body-deserializer.d.ts +0 -16
  315. package/dist/types/deserializer/cosmetic/scriptlet-body/abp-snippet-injection-body-deserializer.d.ts +0 -17
  316. package/dist/types/deserializer/cosmetic/scriptlet-body/adg-scriptlet-injection-body-deserializer.d.ts +0 -18
  317. package/dist/types/deserializer/cosmetic/scriptlet-body/scriptlet-body-deserializer.d.ts +0 -19
  318. package/dist/types/deserializer/cosmetic/scriptlet-body/ubo-scriptlet-injection-body-deserializer.d.ts +0 -17
  319. package/dist/types/deserializer/empty-rule-deserializer.d.ts +0 -16
  320. package/dist/types/deserializer/filterlist-deserializer.d.ts +0 -34
  321. package/dist/types/deserializer/index.d.ts +0 -2
  322. package/dist/types/deserializer/invalid-rule-deserializer.d.ts +0 -16
  323. package/dist/types/deserializer/invalid-rule-error-node-deserializer.d.ts +0 -16
  324. package/dist/types/deserializer/misc/domain-list-deserializer.d.ts +0 -15
  325. package/dist/types/deserializer/misc/list-item-deserializer.d.ts +0 -19
  326. package/dist/types/deserializer/misc/list-items-deserializer.d.ts +0 -16
  327. package/dist/types/deserializer/misc/logical-expression-deserializer.d.ts +0 -55
  328. package/dist/types/deserializer/misc/modifier-deserializer.d.ts +0 -18
  329. package/dist/types/deserializer/misc/modifier-list-deserializer.d.ts +0 -20
  330. package/dist/types/deserializer/misc/parameter-list-deserializer.d.ts +0 -18
  331. package/dist/types/deserializer/misc/value-deserializer.d.ts +0 -17
  332. package/dist/types/deserializer/network/host-rule-deserializer.d.ts +0 -18
  333. package/dist/types/deserializer/network/hostname-list-deserializer.d.ts +0 -15
  334. package/dist/types/deserializer/network/network-rule-deserializer.d.ts +0 -18
  335. package/dist/types/deserializer/rule-deserializer.d.ts +0 -17
  336. package/dist/types/deserializer/syntax-deserialization-map.d.ts +0 -2
  337. package/dist/types/marshalling-utils/comment/agent-comment-common.d.ts +0 -14
  338. package/dist/types/marshalling-utils/comment/agent-common.d.ts +0 -20
  339. package/dist/types/marshalling-utils/comment/config-comment-common.d.ts +0 -42
  340. package/dist/types/marshalling-utils/comment/hint-comment-common.d.ts +0 -15
  341. package/dist/types/marshalling-utils/comment/hint-common.d.ts +0 -33
  342. package/dist/types/marshalling-utils/comment/metadata-comment-common.d.ts +0 -21
  343. package/dist/types/marshalling-utils/comment/pre-processor-comment-common.d.ts +0 -37
  344. package/dist/types/marshalling-utils/comment/simple-comment-common.d.ts +0 -15
  345. package/dist/types/marshalling-utils/cosmetic/body/abp-snippet-injection-body-common.d.ts +0 -23
  346. package/dist/types/marshalling-utils/cosmetic/body/adg-scriptlet-injection-body-common.d.ts +0 -9
  347. package/dist/types/marshalling-utils/cosmetic/body/css-injection-body-common.d.ts +0 -17
  348. package/dist/types/marshalling-utils/cosmetic/body/element-hiding-body-common.d.ts +0 -14
  349. package/dist/types/marshalling-utils/cosmetic/body/ubo-scriptlet-injection-body-common.d.ts +0 -9
  350. package/dist/types/marshalling-utils/cosmetic/cosmetic-rule-common.d.ts +0 -28
  351. package/dist/types/marshalling-utils/empty-rule-common.d.ts +0 -13
  352. package/dist/types/marshalling-utils/filter-list-common.d.ts +0 -14
  353. package/dist/types/marshalling-utils/invalid-rule-common.d.ts +0 -14
  354. package/dist/types/marshalling-utils/invalid-rule-error-node-common.d.ts +0 -15
  355. package/dist/types/marshalling-utils/misc/binary-type-common.d.ts +0 -57
  356. package/dist/types/marshalling-utils/misc/domain-list-common.d.ts +0 -24
  357. package/dist/types/marshalling-utils/misc/host-rule-common.d.ts +0 -18
  358. package/dist/types/marshalling-utils/misc/hostname-list-common.d.ts +0 -14
  359. package/dist/types/marshalling-utils/misc/list-item-common.d.ts +0 -15
  360. package/dist/types/marshalling-utils/misc/logical-expression-common.d.ts +0 -47
  361. package/dist/types/marshalling-utils/misc/modifier-common.d.ts +0 -41
  362. package/dist/types/marshalling-utils/misc/modifier-list-common.d.ts +0 -14
  363. package/dist/types/marshalling-utils/misc/parameter-list-common.d.ts +0 -14
  364. package/dist/types/marshalling-utils/misc/value-common.d.ts +0 -15
  365. package/dist/types/marshalling-utils/network/network-rule-common.d.ts +0 -18
  366. package/dist/types/marshalling-utils/syntax-serialization-map.d.ts +0 -2
  367. package/dist/types/serializer/base-serializer.d.ts +0 -15
  368. package/dist/types/serializer/comment/agent-comment-serializer.d.ts +0 -34
  369. package/dist/types/serializer/comment/agent-serializer.d.ts +0 -15
  370. package/dist/types/serializer/comment/comment-rule-serializer.d.ts +0 -68
  371. package/dist/types/serializer/comment/config-comment-serializer.d.ts +0 -25
  372. package/dist/types/serializer/comment/hint-comment-serializer.d.ts +0 -23
  373. package/dist/types/serializer/comment/hint-serializer.d.ts +0 -24
  374. package/dist/types/serializer/comment/metadata-comment-serializer.d.ts +0 -25
  375. package/dist/types/serializer/comment/pre-processor-comment-serializer.d.ts +0 -28
  376. package/dist/types/serializer/comment/simple-comment-serializer.d.ts +0 -24
  377. package/dist/types/serializer/cosmetic/body/abp-snippet-injection-body-serializer.d.ts +0 -25
  378. package/dist/types/serializer/cosmetic/body/adg-scriptlet-injection-body-serializer.d.ts +0 -25
  379. package/dist/types/serializer/cosmetic/body/scriptlet-body-serializer.d.ts +0 -17
  380. package/dist/types/serializer/cosmetic/body/ubo-scriptlet-injection-body-serializer.d.ts +0 -25
  381. package/dist/types/serializer/cosmetic/cosmetic-rule-serializer.d.ts +0 -19
  382. package/dist/types/serializer/cosmetic/css-injection-body-serializer.d.ts +0 -15
  383. package/dist/types/serializer/cosmetic/element-hiding-body-serializer.d.ts +0 -15
  384. package/dist/types/serializer/empty-rule-serializer.d.ts +0 -15
  385. package/dist/types/serializer/filterlist-serializer.d.ts +0 -15
  386. package/dist/types/serializer/index.d.ts +0 -1
  387. package/dist/types/serializer/invalid-rule-error-node-serializer.d.ts +0 -15
  388. package/dist/types/serializer/invalid-rule-serializer.d.ts +0 -15
  389. package/dist/types/serializer/misc/domain-list-serializer.d.ts +0 -21
  390. package/dist/types/serializer/misc/list-item-serializer.d.ts +0 -16
  391. package/dist/types/serializer/misc/list-items-serializer.d.ts +0 -15
  392. package/dist/types/serializer/misc/logical-expression-serializer.d.ts +0 -52
  393. package/dist/types/serializer/misc/modifier-list-serializer.d.ts +0 -20
  394. package/dist/types/serializer/misc/modifier-serializer.d.ts +0 -18
  395. package/dist/types/serializer/misc/parameter-list-serializer.d.ts +0 -17
  396. package/dist/types/serializer/misc/value-serializer.d.ts +0 -17
  397. package/dist/types/serializer/network/host-rule-serializer.d.ts +0 -30
  398. package/dist/types/serializer/network/hostname-list-serializer.d.ts +0 -15
  399. package/dist/types/serializer/network/network-rule-serializer.d.ts +0 -18
  400. package/dist/types/serializer/rule-serializer.d.ts +0 -17
  401. package/dist/types/utils/binary-schema-version.d.ts +0 -9
  402. package/dist/types/utils/byte-buffer.d.ts +0 -54
  403. package/dist/types/utils/input-byte-buffer.d.ts +0 -146
  404. package/dist/types/utils/is-chromium.d.ts +0 -7
  405. package/dist/types/utils/output-byte-buffer.d.ts +0 -132
  406. package/dist/types/utils/storage-interface.d.ts +0 -23
  407. package/dist/types/utils/text-decoder-polyfill.d.ts +0 -14
  408. package/dist/types/utils/text-encoder-polyfill.d.ts +0 -18
  409. package/dist/utils/binary-schema-version.js +0 -17
  410. package/dist/utils/byte-buffer.js +0 -91
  411. package/dist/utils/input-byte-buffer.js +0 -266
  412. package/dist/utils/is-chromium.js +0 -20
  413. package/dist/utils/output-byte-buffer.js +0 -231
  414. package/dist/utils/text-decoder-polyfill.js +0 -107
  415. package/dist/utils/text-encoder-polyfill.js +0 -78
  416. /package/dist/types/generator/cosmetic/{body → scriptlet-body}/abp-snippet-injection-body-generator.d.ts +0 -0
  417. /package/dist/types/generator/cosmetic/{body → scriptlet-body}/adg-scriptlet-injection-body-generator.d.ts +0 -0
  418. /package/dist/types/generator/cosmetic/{body → scriptlet-body}/ubo-scriptlet-injection-body-generator.d.ts +0 -0
  419. /package/dist/types/parser/cosmetic/{body → scriptlet-body}/abp-snippet-injection-body-parser.d.ts +0 -0
  420. /package/dist/types/parser/cosmetic/{body → scriptlet-body}/adg-scriptlet-injection-body-parser.d.ts +0 -0
  421. /package/dist/types/parser/cosmetic/{body → scriptlet-body}/ubo-scriptlet-injection-body-parser.d.ts +0 -0
@@ -1,30 +0,0 @@
1
- import { type HostRule } from '../../nodes/index.js';
2
- import { type OutputByteBuffer } from '../../utils/output-byte-buffer.js';
3
- import { BaseSerializer } from '../base-serializer.js';
4
- /**
5
- * `HostRuleSerializer` is responsible for serializing hosts-like rules.
6
- *
7
- * HostRule is a structure for simple host-level rules (i.e. /etc/hosts syntax).
8
- * It also supports "just domain" syntax. In this case, the IP will be set to 0.0.0.0.
9
- *
10
- * Rules syntax looks like this:
11
- * ```text
12
- * IP_address canonical_hostname [aliases...]
13
- * ```
14
- *
15
- * @example
16
- * `192.168.1.13 bar.mydomain.org bar` -- ipv4
17
- * `ff02::1 ip6-allnodes` -- ipv6
18
- * `::1 localhost ip6-localhost ip6-loopback` -- ipv6 aliases
19
- * `example.org` -- "just domain" syntax
20
- * @see {@link http://man7.org/linux/man-pages/man5/hosts.5.html}
21
- */
22
- export declare class HostRuleSerializer extends BaseSerializer {
23
- /**
24
- * Serializes a host rule node to binary format.
25
- *
26
- * @param node Node to serialize.
27
- * @param buffer ByteBuffer for writing binary data.
28
- */
29
- static serialize(node: HostRule, buffer: OutputByteBuffer): void;
30
- }
@@ -1,15 +0,0 @@
1
- import { BaseSerializer } from '../base-serializer.js';
2
- import { type HostnameList } from '../../nodes/index.js';
3
- import type { OutputByteBuffer } from '../../utils/output-byte-buffer.js';
4
- /**
5
- * Serializer for hostname list nodes.
6
- */
7
- export declare class HostnameListSerializer extends BaseSerializer {
8
- /**
9
- * Serializes a hostname list node to binary format.
10
- *
11
- * @param node Node to serialize.
12
- * @param buffer ByteBuffer for writing binary data.
13
- */
14
- static serialize(node: HostnameList, buffer: OutputByteBuffer): void;
15
- }
@@ -1,18 +0,0 @@
1
- import { type NetworkRule } from '../../nodes/index.js';
2
- import { type OutputByteBuffer } from '../../utils/output-byte-buffer.js';
3
- import { BaseSerializer } from '../base-serializer.js';
4
- /**
5
- * `NetworkRuleSerializer` is responsible for serializing network rules.
6
- *
7
- * @see {@link https://kb.adguard.com/en/general/how-to-create-your-own-ad-filters#basic-rules}
8
- * @see {@link https://help.eyeo.com/adblockplus/how-to-write-filters#basic}
9
- */
10
- export declare class NetworkRuleSerializer extends BaseSerializer {
11
- /**
12
- * Serializes a network rule node to binary format.
13
- *
14
- * @param node Node to serialize.
15
- * @param buffer ByteBuffer for writing binary data.
16
- */
17
- static serialize(node: NetworkRule, buffer: OutputByteBuffer): void;
18
- }
@@ -1,17 +0,0 @@
1
- import { type AnyRule } from '../nodes/index.js';
2
- import { type OutputByteBuffer } from '../utils/output-byte-buffer.js';
3
- import { BaseSerializer } from './base-serializer.js';
4
- /**
5
- * `RuleSerializer` is responsible for serializing the rules.
6
- *
7
- * It automatically determines the category and syntax of the rule, so you can pass any kind of rule to it.
8
- */
9
- export declare class RuleSerializer extends BaseSerializer {
10
- /**
11
- * Serializes a rule node to binary format.
12
- *
13
- * @param node Node to serialize.
14
- * @param buffer ByteBuffer for writing binary data.
15
- */
16
- static serialize(node: AnyRule, buffer: OutputByteBuffer): void;
17
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * @file Binary schema version.
3
- */
4
- /**
5
- * Binary schema version.
6
- * This version number is used to ensure that the binary format is compatible with the current library version.
7
- * We increment this number if the serialized format changes in a way that is not backwards-compatible.
8
- */
9
- export declare const BINARY_SCHEMA_VERSION = 1;
@@ -1,54 +0,0 @@
1
- /**
2
- * @file Core ByteBuffer implementation for handling binary data in chunks.
3
- */
4
- /**
5
- * Core ByteBuffer implementation for handling binary data in chunks.
6
- * This class allows for efficient byte storage and manipulation by organizing data into chunks
7
- * and providing methods to read and write bytes.
8
- */
9
- export declare class ByteBuffer {
10
- /**
11
- * The size of each chunk in bytes (32 KB).
12
- */
13
- static readonly CHUNK_SIZE = 32768;
14
- /**
15
- * An array of Uint8Array chunks that make up the buffer.
16
- */
17
- protected chunks: Uint8Array[];
18
- /**
19
- * The total number of chunks in the buffer.
20
- */
21
- protected chunksLength: number;
22
- /**
23
- * Constructs a new ByteBuffer instance.
24
- *
25
- * @param chunks Optional array of chunks to initialize the ByteBuffer with.
26
- * @param cloneChunks Flag indicating if the chunks should be cloned. For performance reasons,
27
- * its default value is `false`. If the original chunks are guaranteed not to change,
28
- * leave this flag as `false` to avoid unnecessary copying.
29
- */
30
- constructor(chunks?: Uint8Array[], cloneChunks?: boolean);
31
- /**
32
- * Ensures that the buffer has enough capacity to accommodate a given position.
33
- * This method adjusts the `chunks` array size to ensure it can hold the specified position.
34
- *
35
- * @param position The position to ensure capacity for.
36
- */
37
- protected ensureCapacity(position: number): void;
38
- /**
39
- * Writes a byte to the buffer at the specified position.
40
- * If the position is outside of the buffer's current size, the buffer is resized to accommodate it.
41
- *
42
- * @param position The position at which to write the byte.
43
- * @param value The byte value to write (0-255).
44
- */
45
- protected writeByte(position: number, value: number): void;
46
- /**
47
- * Reads a byte from the specified position in the buffer.
48
- * Returns `undefined` if the position is outside of the buffer's current size.
49
- *
50
- * @param position The position from which to read the byte.
51
- * @returns The read byte value, or `undefined` if the position is out of bounds.
52
- */
53
- protected readByte(position: number): number | undefined;
54
- }
@@ -1,146 +0,0 @@
1
- /**
2
- * @file Input byte buffer for reading binary data.
3
- */
4
- import { ByteBuffer } from './byte-buffer.js';
5
- import { type Storage } from './storage-interface.js';
6
- /**
7
- * Input byte buffer for reading binary data.
8
- *
9
- * @note Internally, this class uses a {@link ByteBuffer} instance, just providing a convenient API for reading data.
10
- */
11
- export declare class InputByteBuffer extends ByteBuffer {
12
- /**
13
- * Current offset in the buffer for reading.
14
- */
15
- private offset;
16
- /**
17
- * Shared native decoder for decoding strings.
18
- */
19
- private readonly sharedNativeDecoder;
20
- /**
21
- * Flag indicating if the current environment is Chromium.
22
- * This is used for performance optimizations, because Chromium's TextEncoder/TextDecoder has a relatively
23
- * large marshalling overhead for small strings.
24
- */
25
- private readonly isChromium;
26
- /**
27
- * Constructs a new `InputByteBuffer` instance.
28
- *
29
- * @param chunks Array of chunks to initialize the ByteBuffer with.
30
- * @param cloneChunks Flag indicating if the chunks should be cloned. For performance reasons,
31
- * its default value is `false`. If the original chunks are guaranteed not to change,
32
- * leave this flag as `false` to avoid unnecessary copying.
33
- * @param initialOffset Initial offset in the buffer for reading.
34
- *
35
- * @throws If the specified chunks array is empty.
36
- * @throws If the binary schema version in the buffer is not equal to the expected version.
37
- * @throws If the initial offset is out of bounds.
38
- */
39
- constructor(chunks: Uint8Array[], cloneChunks?: boolean, initialOffset?: number);
40
- /**
41
- * Creates a new InputByteBuffer instance from a Storage instance by reading chunks from the storage.
42
- *
43
- * @param storage Storage instance.
44
- * @param key Key to read from the storage.
45
- * @returns New InputByteBuffer instance.
46
- * @note For performance reasons, chunks are passed by reference and not copied.
47
- */
48
- static createFromStorage(storage: Storage, key: string): Promise<InputByteBuffer>;
49
- /**
50
- * Reads a 8-bit unsigned integer from the buffer.
51
- *
52
- * @returns 8-bit unsigned integer from the buffer.
53
- */
54
- readUint8(): number;
55
- /**
56
- * Reads a 16-bit unsigned integer from the buffer.
57
- *
58
- * @returns 16-bit unsigned integer from the buffer.
59
- */
60
- readUint16(): number;
61
- /**
62
- * Reads a 32-bit unsigned integer from the buffer at the specified index.
63
- *
64
- * @param index Index to read the 32-bit unsigned integer from.
65
- *
66
- * @returns 32-bit unsigned integer from the buffer.
67
- */
68
- private readUint32FromIndex;
69
- /**
70
- * Reads a 32-bit unsigned integer from the buffer.
71
- *
72
- * @returns 32-bit unsigned integer from the buffer.
73
- */
74
- readUint32(): number;
75
- /**
76
- * Reads schema version from the buffer.
77
- *
78
- * @returns 32-bit unsigned integer from the buffer.
79
- * @note Schema version is always stored at the beginning of the buffer.
80
- */
81
- readSchemaVersion(): number;
82
- /**
83
- * Reads a 32-bit signed integer from the buffer.
84
- *
85
- * @returns 32-bit signed integer from the buffer.
86
- */
87
- readInt32(): number;
88
- /**
89
- * Reads an optimized unsigned integer from the buffer.
90
- * 'Optimized' means that the integer is stored in a variable number of bytes, depending on its value,
91
- * so that smaller numbers occupy less space.
92
- *
93
- * @returns Decoded unsigned integer from the buffer.
94
- */
95
- readOptimizedUint(): number;
96
- /**
97
- * Reads a string from the buffer.
98
- *
99
- * @returns Decoded string from the buffer.
100
- */
101
- readString(): string;
102
- /**
103
- * Reads a 8-bit unsigned integer from the buffer without advancing the offset.
104
- *
105
- * @returns 8-bit unsigned integer from the buffer.
106
- */
107
- peekUint8(): number;
108
- /**
109
- * Helper method for asserting the next 8-bit unsigned integer in the buffer.
110
- *
111
- * @param value Expected value.
112
- * @throws If the next value in the buffer is not equal to the expected value.
113
- */
114
- assertUint8(value: number): void;
115
- /**
116
- * Creates a new `InputByteBuffer` instance with the given initial offset.
117
- *
118
- * @param initialOffset Initial offset for the new buffer.
119
- * @param cloneChunks Flag indicating if the chunks should be cloned. For performance reasons,
120
- * its default value is `false`. If the original chunks are guaranteed not to change,
121
- * leave this flag as `false` to avoid unnecessary copying.
122
- *
123
- * @returns New `InputByteBuffer` instance with the given initial offset.
124
- *
125
- * @note This method is useful if you want to read some data from a specific index.
126
- */
127
- createCopyWithOffset(initialOffset: number, cloneChunks?: boolean): InputByteBuffer;
128
- /**
129
- * Gets the current offset in the buffer for reading.
130
- *
131
- * @returns Current offset in the buffer for reading.
132
- */
133
- get currentOffset(): number;
134
- /**
135
- * Gets the capacity of the buffer.
136
- *
137
- * @returns Capacity of the buffer.
138
- */
139
- get capacity(): number;
140
- /**
141
- * Gets the chunks of the buffer.
142
- *
143
- * @returns Chunks of the buffer.
144
- */
145
- getChunks(): Uint8Array[];
146
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * A simple function to check if the current browser is Chromium-based.
3
- *
4
- * @returns `true` if the current browser is Chromium-based, `false` otherwise.
5
- * @see {@link https://stackoverflow.com/a/62797156}
6
- */
7
- export declare const isChromium: () => boolean;
@@ -1,132 +0,0 @@
1
- import { ByteBuffer } from './byte-buffer.js';
2
- import { type Storage } from './storage-interface.js';
3
- /**
4
- * Output byte buffer for writing binary data.
5
- *
6
- * @note Internally, this class uses a {@link ByteBuffer} instance, just providing a convenient API for reading data.
7
- */
8
- export declare class OutputByteBuffer extends ByteBuffer {
9
- /**
10
- * Current offset in the buffer for writing.
11
- */
12
- private offset;
13
- /**
14
- * Size of the shared buffer for encoding strings in bytes.
15
- * This is a divisor of ByteBuffer.CHUNK_SIZE and experience shows that this value works optimally.
16
- * This is sufficient for most strings that occur in filter lists (we checked average string length in popular
17
- * filter lists).
18
- */
19
- private static readonly ENCODER_BUFFER_SIZE;
20
- /**
21
- * Length threshold for using a shared buffer for encoding strings.
22
- * This temp buffer is needed because we write the short strings in it
23
- * (so there is no need to constantly allocate a new buffer).
24
- * The reason for dividing ENCODER_BUFFER_SIZE by 4 is to ensure that the encoded string fits in the buffer,
25
- * if we also take into account the worst possible case (each character is encoded with 4 bytes).
26
- */
27
- private static readonly SHORT_STRING_THRESHOLD;
28
- /**
29
- * Represents the maximum value that can be written as a 'storage optimized' unsigned integer.
30
- * 0x1FFFFFFF means 29 bits — 32 bits minus 3 bits — because the last bit in each byte is a flag indicating
31
- * if there are more bytes (except for the last byte).
32
- */
33
- static MAX_OPTIMIZED_UINT: number;
34
- /**
35
- * Shared buffer for encoding strings.
36
- */
37
- private readonly sharedBuffer;
38
- /**
39
- * Shared native encoder for encoding strings.
40
- */
41
- private readonly sharedNativeEncoder;
42
- /**
43
- * Flag indicating if the current environment is Chromium.
44
- * This is used for performance optimizations, because Chromium's TextEncoder/TextDecoder has a relatively
45
- * large marshalling overhead for small strings.
46
- */
47
- private readonly isChromium;
48
- /**
49
- * Constructs a new OutputByteBuffer instance.
50
- */
51
- constructor();
52
- /**
53
- * Writes a 8-bit unsigned integer to the buffer.
54
- *
55
- * @param value Value to write.
56
- * @returns Number of bytes written to the buffer.
57
- */
58
- writeUint8(value: number): number;
59
- /**
60
- * Writes a 16-bit unsigned integer to the buffer.
61
- *
62
- * @param value Value to write.
63
- * @returns Number of bytes written to the buffer.
64
- */
65
- writeUint16(value: number): number;
66
- /**
67
- * Writes a 32-bit unsigned integer to the buffer at a specific index.
68
- *
69
- * @param value Value to write.
70
- * @param index Index to write the value to.
71
- * @returns Number of bytes written to the buffer.
72
- */
73
- private writeUint32ToIndex;
74
- /**
75
- * Writes a 32-bit unsigned integer to the buffer.
76
- *
77
- * @param value Value to write.
78
- * @returns Number of bytes written to the buffer.
79
- */
80
- writeUint32(value: number): number;
81
- /**
82
- * Writes a 32-bit signed integer to the buffer.
83
- *
84
- * @param value Value to write.
85
- * @returns Number of bytes written to the buffer.
86
- */
87
- writeInt32(value: number): number;
88
- /**
89
- * Writes a Uint8Array to the byte buffer.
90
- *
91
- * @param buffer Buffer to write.
92
- */
93
- private writeBuffer;
94
- /**
95
- * Writes a string to the buffer.
96
- *
97
- * @param value Value to write.
98
- * @returns Number of bytes written to the buffer.
99
- */
100
- writeString(value: string): number;
101
- /**
102
- * Writes chunks to the storage.
103
- *
104
- * @param storage Storage to write the chunks to.
105
- * @param key Key to write the chunks to.
106
- * @note For performance reasons, chunks are passed by reference and not copied.
107
- * @throws If the storage write operation throws.
108
- */
109
- writeChunksToStorage(storage: Storage, key: string): Promise<void>;
110
- /**
111
- * Writes an 'optimized' unsigned integer to the buffer.
112
- * 'Optimized' means smaller storage usage for smaller numbers.
113
- * Except for the last byte, each byte's most significant bit is a flag indicating if there are more bytes.
114
- *
115
- * @param value Value to write.
116
- * @returns Number of bytes written to the buffer.
117
- * @throws If the value exceeds the 29-bit limit.
118
- */
119
- writeOptimizedUint(value: number): number;
120
- /**
121
- * Gets the current offset in the buffer for writing.
122
- *
123
- * @returns Current offset in the buffer for writing.
124
- */
125
- get currentOffset(): number;
126
- /**
127
- * Gets the chunks of the buffer.
128
- *
129
- * @returns Chunks of the buffer.
130
- */
131
- getChunks(): Uint8Array[];
132
- }
@@ -1,23 +0,0 @@
1
- /**
2
- * @file Represents a storage interface for reading and writing data.
3
- */
4
- /**
5
- * Represents a storage interface for reading and writing data.
6
- */
7
- export interface Storage<K = string, V = unknown> {
8
- /**
9
- * Writes the given data to the storage with the specified key.
10
- *
11
- * @param key The key to identify the data in the storage.
12
- * @param data The data to write to the storage.
13
- * @returns A promise that resolves when the write operation is complete.
14
- */
15
- set(key: K, data: V): Promise<void>;
16
- /**
17
- * Reads the data from the storage with the specified key.
18
- *
19
- * @param key The key to identify the data in the storage.
20
- * @returns A promise that resolves with the data read from the storage.
21
- */
22
- get(key: K): Promise<V | undefined>;
23
- }
@@ -1,14 +0,0 @@
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;
@@ -1,18 +0,0 @@
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;
@@ -1,17 +0,0 @@
1
- /*
2
- * AGTree v3.4.3 (build date: Thu, 11 Dec 2025 13:43:19 GMT)
3
- * (c) 2025 Adguard Software Ltd.
4
- * Released under the MIT license
5
- * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
6
- */
7
- /**
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 };
@@ -1,91 +0,0 @@
1
- /*
2
- * AGTree v3.4.3 (build date: Thu, 11 Dec 2025 13:43:19 GMT)
3
- * (c) 2025 Adguard Software Ltd.
4
- * Released under the MIT license
5
- * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
6
- */
7
- /* eslint-disable no-bitwise */
8
- /**
9
- * @file Core ByteBuffer implementation for handling binary data in chunks.
10
- */
11
- /**
12
- * Core ByteBuffer implementation for handling binary data in chunks.
13
- * This class allows for efficient byte storage and manipulation by organizing data into chunks
14
- * and providing methods to read and write bytes.
15
- */
16
- class ByteBuffer {
17
- /**
18
- * The size of each chunk in bytes (32 KB).
19
- */
20
- // ! IMPORTANT: If you ever change this value, make sure to update optimized bitwise operations in the code.
21
- static CHUNK_SIZE = 32768; // 32 * 1024
22
- /**
23
- * An array of Uint8Array chunks that make up the buffer.
24
- */
25
- chunks;
26
- /**
27
- * The total number of chunks in the buffer.
28
- */
29
- chunksLength;
30
- /**
31
- * Constructs a new ByteBuffer instance.
32
- *
33
- * @param chunks Optional array of chunks to initialize the ByteBuffer with.
34
- * @param cloneChunks Flag indicating if the chunks should be cloned. For performance reasons,
35
- * its default value is `false`. If the original chunks are guaranteed not to change,
36
- * leave this flag as `false` to avoid unnecessary copying.
37
- */
38
- constructor(chunks, cloneChunks = false) {
39
- const chunksToUse = chunks ?? [];
40
- this.chunks = cloneChunks ? chunksToUse.map((chunk) => new Uint8Array(chunk)) : chunksToUse;
41
- this.chunksLength = chunks?.length ?? 0;
42
- }
43
- /**
44
- * Ensures that the buffer has enough capacity to accommodate a given position.
45
- * This method adjusts the `chunks` array size to ensure it can hold the specified position.
46
- *
47
- * @param position The position to ensure capacity for.
48
- */
49
- ensureCapacity(position) {
50
- // same as Math.floor(position / chunk size), just optimized for the 32 KB chunk size
51
- const requiredChunkIndex = position >>> 0x000F;
52
- for (let i = this.chunksLength; i <= requiredChunkIndex; i += 1) {
53
- this.chunks.push(new Uint8Array(ByteBuffer.CHUNK_SIZE));
54
- this.chunksLength += 1;
55
- }
56
- }
57
- /**
58
- * Writes a byte to the buffer at the specified position.
59
- * If the position is outside of the buffer's current size, the buffer is resized to accommodate it.
60
- *
61
- * @param position The position at which to write the byte.
62
- * @param value The byte value to write (0-255).
63
- */
64
- writeByte(position, value) {
65
- // same as Math.floor(position / chunk size), just optimized for the 32 KB chunk size
66
- const chunkIndex = position >>> 0x000F;
67
- // same as position % chunk size, just optimized for the 32 KB chunk size
68
- const chunkOffset = position & 0x7FFF;
69
- if (chunkIndex >= this.chunksLength) {
70
- this.ensureCapacity(position);
71
- }
72
- this.chunks[chunkIndex][chunkOffset] = value;
73
- }
74
- /**
75
- * Reads a byte from the specified position in the buffer.
76
- * Returns `undefined` if the position is outside of the buffer's current size.
77
- *
78
- * @param position The position from which to read the byte.
79
- * @returns The read byte value, or `undefined` if the position is out of bounds.
80
- */
81
- readByte(position) {
82
- const chunkIndex = position >>> 0x000F;
83
- const chunkOffset = position & 0x7FFF;
84
- if (chunkIndex >= this.chunksLength) {
85
- return undefined;
86
- }
87
- return this.chunks[chunkIndex][chunkOffset];
88
- }
89
- }
90
-
91
- export { ByteBuffer };