@mavogel/cdk-vscode-server 0.0.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 (439) hide show
  1. package/.jsii +4351 -0
  2. package/API.md +367 -0
  3. package/CONTRIBUTING.md +59 -0
  4. package/LICENSE +202 -0
  5. package/README.md +183 -0
  6. package/assets/installer/installer.lambda/index.js +112 -0
  7. package/assets/secret-retriever/secret-retriever.lambda/index.js +57 -0
  8. package/docs/img/vscode-server-ui-login-min.png +0 -0
  9. package/docs/img/vscode-server-ui-min.png +0 -0
  10. package/docs/img/vscode-server.drawio +108 -0
  11. package/docs/img/vscode-server.drawio-min.png +0 -0
  12. package/integ-tests/code-server login.html +48 -0
  13. package/integ-tests/functions/login-handler.ts +63 -0
  14. package/integ-tests/integ.al2023.ts +69 -0
  15. package/integ-tests/integ.al2023.ts.snapshot/IntegSetupVSCodeOnAl2023DefaultTestDeployAssert74D8F645.assets.json +32 -0
  16. package/integ-tests/integ.al2023.ts.snapshot/IntegSetupVSCodeOnAl2023DefaultTestDeployAssert74D8F645.template.json +337 -0
  17. package/integ-tests/integ.al2023.ts.snapshot/IntegTestStackAl2023.assets.json +110 -0
  18. package/integ-tests/integ.al2023.ts.snapshot/IntegTestStackAl2023.template.json +2459 -0
  19. package/integ-tests/integ.al2023.ts.snapshot/asset.23732f3d1982f7fb0da3bd6638a8107337bb767fea165b45eae12000a1dd67ce/index.js +6169 -0
  20. package/integ-tests/integ.al2023.ts.snapshot/asset.2819175352ad1ce0dae768e83fc328fb70fb5f10b4a8ff0ccbcb791f02b0716d/index.js +1 -0
  21. package/integ-tests/integ.al2023.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/cfn-response.js +1 -0
  22. package/integ-tests/integ.al2023.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/consts.js +1 -0
  23. package/integ-tests/integ.al2023.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/framework.js +3 -0
  24. package/integ-tests/integ.al2023.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/outbound.js +1 -0
  25. package/integ-tests/integ.al2023.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/util.js +1 -0
  26. package/integ-tests/integ.al2023.ts.snapshot/asset.512cf155ada4793b37a885c1aa6d9bb8f534e88bac6f63c69672d4d73df2decf.lambda/index.js +112 -0
  27. package/integ-tests/integ.al2023.ts.snapshot/asset.781ab0ab74634cdaf61539ab208ab777829ef07097ac21f95b9e15a3b1eedc1b.lambda/index.js +57 -0
  28. package/integ-tests/integ.al2023.ts.snapshot/asset.c504585dae89ce8e394d7744ccae054318e7d1aff14afb545438d173d51dc97d.bundle/index.js +30572 -0
  29. package/integ-tests/integ.al2023.ts.snapshot/asset.ce2f3595a340d6c519a65888ef97e3b9b64f053f83608e32cc28162e22d7d99a/index.js +1 -0
  30. package/integ-tests/integ.al2023.ts.snapshot/asset.ee7de53d64cc9d6248fa6aa550f92358f6c907b5efd6f3298aeab1b5e7ea358a/__entrypoint__.js +1 -0
  31. package/integ-tests/integ.al2023.ts.snapshot/asset.ee7de53d64cc9d6248fa6aa550f92358f6c907b5efd6f3298aeab1b5e7ea358a/index.js +1 -0
  32. package/integ-tests/integ.al2023.ts.snapshot/cdk.out +1 -0
  33. package/integ-tests/integ.al2023.ts.snapshot/integ.json +22 -0
  34. package/integ-tests/integ.al2023.ts.snapshot/manifest.json +510 -0
  35. package/integ-tests/integ.al2023.ts.snapshot/tree.json +2944 -0
  36. package/integ-tests/integ.ubuntu.ts +66 -0
  37. package/integ-tests/integ.ubuntu.ts.snapshot/IntegSetupVSCodeOnUbuntuDefaultTestDeployAssertFF8DF2C5.assets.json +32 -0
  38. package/integ-tests/integ.ubuntu.ts.snapshot/IntegSetupVSCodeOnUbuntuDefaultTestDeployAssertFF8DF2C5.template.json +337 -0
  39. package/integ-tests/integ.ubuntu.ts.snapshot/IntegTestStackUbuntu22.assets.json +110 -0
  40. package/integ-tests/integ.ubuntu.ts.snapshot/IntegTestStackUbuntu22.template.json +2477 -0
  41. package/integ-tests/integ.ubuntu.ts.snapshot/asset.23732f3d1982f7fb0da3bd6638a8107337bb767fea165b45eae12000a1dd67ce/index.js +6169 -0
  42. package/integ-tests/integ.ubuntu.ts.snapshot/asset.2819175352ad1ce0dae768e83fc328fb70fb5f10b4a8ff0ccbcb791f02b0716d/index.js +1 -0
  43. package/integ-tests/integ.ubuntu.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/cfn-response.js +1 -0
  44. package/integ-tests/integ.ubuntu.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/consts.js +1 -0
  45. package/integ-tests/integ.ubuntu.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/framework.js +3 -0
  46. package/integ-tests/integ.ubuntu.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/outbound.js +1 -0
  47. package/integ-tests/integ.ubuntu.ts.snapshot/asset.4dc48ffba382f93077a1e6824599bbd4ceb6f91eb3d9442eca3b85bdb1a20b1e/util.js +1 -0
  48. package/integ-tests/integ.ubuntu.ts.snapshot/asset.512cf155ada4793b37a885c1aa6d9bb8f534e88bac6f63c69672d4d73df2decf.lambda/index.js +112 -0
  49. package/integ-tests/integ.ubuntu.ts.snapshot/asset.781ab0ab74634cdaf61539ab208ab777829ef07097ac21f95b9e15a3b1eedc1b.lambda/index.js +57 -0
  50. package/integ-tests/integ.ubuntu.ts.snapshot/asset.c504585dae89ce8e394d7744ccae054318e7d1aff14afb545438d173d51dc97d.bundle/index.js +30572 -0
  51. package/integ-tests/integ.ubuntu.ts.snapshot/asset.ce2f3595a340d6c519a65888ef97e3b9b64f053f83608e32cc28162e22d7d99a/index.js +1 -0
  52. package/integ-tests/integ.ubuntu.ts.snapshot/asset.ee7de53d64cc9d6248fa6aa550f92358f6c907b5efd6f3298aeab1b5e7ea358a/__entrypoint__.js +1 -0
  53. package/integ-tests/integ.ubuntu.ts.snapshot/asset.ee7de53d64cc9d6248fa6aa550f92358f6c907b5efd6f3298aeab1b5e7ea358a/index.js +1 -0
  54. package/integ-tests/integ.ubuntu.ts.snapshot/cdk.out +1 -0
  55. package/integ-tests/integ.ubuntu.ts.snapshot/integ.json +22 -0
  56. package/integ-tests/integ.ubuntu.ts.snapshot/manifest.json +510 -0
  57. package/integ-tests/integ.ubuntu.ts.snapshot/tree.json +2962 -0
  58. package/lib/index.d.ts +1 -0
  59. package/lib/index.js +18 -0
  60. package/lib/installer/installer-function.d.ts +13 -0
  61. package/lib/installer/installer-function.js +23 -0
  62. package/lib/installer/installer.d.ts +64 -0
  63. package/lib/installer/installer.js +707 -0
  64. package/lib/installer/installer.lambda.d.ts +3 -0
  65. package/lib/installer/installer.lambda.js +94 -0
  66. package/lib/mappings.d.ts +2 -0
  67. package/lib/mappings.js +25 -0
  68. package/lib/prefixlist-retriever/prefixlist-retriever.d.ts +16 -0
  69. package/lib/prefixlist-retriever/prefixlist-retriever.js +56 -0
  70. package/lib/secret-retriever/secret-retriever-function.d.ts +13 -0
  71. package/lib/secret-retriever/secret-retriever-function.js +23 -0
  72. package/lib/secret-retriever/secret-retriever.d.ts +33 -0
  73. package/lib/secret-retriever/secret-retriever.js +72 -0
  74. package/lib/secret-retriever/secret-retriever.lambda.d.ts +2 -0
  75. package/lib/secret-retriever/secret-retriever.lambda.js +36 -0
  76. package/lib/vscode-server.d.ts +97 -0
  77. package/lib/vscode-server.js +417 -0
  78. package/node_modules/boolbase/README.md +10 -0
  79. package/node_modules/boolbase/index.js +8 -0
  80. package/node_modules/boolbase/package.json +23 -0
  81. package/node_modules/css-select/LICENSE +11 -0
  82. package/node_modules/css-select/README.md +264 -0
  83. package/node_modules/css-select/lib/attributes.d.ts +7 -0
  84. package/node_modules/css-select/lib/attributes.d.ts.map +1 -0
  85. package/node_modules/css-select/lib/attributes.js +236 -0
  86. package/node_modules/css-select/lib/attributes.js.map +1 -0
  87. package/node_modules/css-select/lib/compile.d.ts +13 -0
  88. package/node_modules/css-select/lib/compile.d.ts.map +1 -0
  89. package/node_modules/css-select/lib/compile.js +151 -0
  90. package/node_modules/css-select/lib/compile.js.map +1 -0
  91. package/node_modules/css-select/lib/esm/attributes.d.ts +7 -0
  92. package/node_modules/css-select/lib/esm/attributes.d.ts.map +1 -0
  93. package/node_modules/css-select/lib/esm/attributes.js +222 -0
  94. package/node_modules/css-select/lib/esm/attributes.js.map +1 -0
  95. package/node_modules/css-select/lib/esm/compile.d.ts +13 -0
  96. package/node_modules/css-select/lib/esm/compile.d.ts.map +1 -0
  97. package/node_modules/css-select/lib/esm/compile.js +115 -0
  98. package/node_modules/css-select/lib/esm/compile.js.map +1 -0
  99. package/node_modules/css-select/lib/esm/general.d.ts +3 -0
  100. package/node_modules/css-select/lib/esm/general.d.ts.map +1 -0
  101. package/node_modules/css-select/lib/esm/general.js +144 -0
  102. package/node_modules/css-select/lib/esm/general.js.map +1 -0
  103. package/node_modules/css-select/lib/esm/index.d.ts +50 -0
  104. package/node_modules/css-select/lib/esm/index.d.ts.map +1 -0
  105. package/node_modules/css-select/lib/esm/index.js +115 -0
  106. package/node_modules/css-select/lib/esm/index.js.map +1 -0
  107. package/node_modules/css-select/lib/esm/package.json +1 -0
  108. package/node_modules/css-select/lib/esm/pseudo-selectors/aliases.d.ts +5 -0
  109. package/node_modules/css-select/lib/esm/pseudo-selectors/aliases.d.ts.map +1 -0
  110. package/node_modules/css-select/lib/esm/pseudo-selectors/aliases.js +35 -0
  111. package/node_modules/css-select/lib/esm/pseudo-selectors/aliases.js.map +1 -0
  112. package/node_modules/css-select/lib/esm/pseudo-selectors/filters.d.ts +4 -0
  113. package/node_modules/css-select/lib/esm/pseudo-selectors/filters.d.ts.map +1 -0
  114. package/node_modules/css-select/lib/esm/pseudo-selectors/filters.js +143 -0
  115. package/node_modules/css-select/lib/esm/pseudo-selectors/filters.js.map +1 -0
  116. package/node_modules/css-select/lib/esm/pseudo-selectors/index.d.ts +8 -0
  117. package/node_modules/css-select/lib/esm/pseudo-selectors/index.d.ts.map +1 -0
  118. package/node_modules/css-select/lib/esm/pseudo-selectors/index.js +40 -0
  119. package/node_modules/css-select/lib/esm/pseudo-selectors/index.js.map +1 -0
  120. package/node_modules/css-select/lib/esm/pseudo-selectors/pseudos.d.ts +6 -0
  121. package/node_modules/css-select/lib/esm/pseudo-selectors/pseudos.d.ts.map +1 -0
  122. package/node_modules/css-select/lib/esm/pseudo-selectors/pseudos.js +79 -0
  123. package/node_modules/css-select/lib/esm/pseudo-selectors/pseudos.js.map +1 -0
  124. package/node_modules/css-select/lib/esm/pseudo-selectors/subselects.d.ts +9 -0
  125. package/node_modules/css-select/lib/esm/pseudo-selectors/subselects.d.ts.map +1 -0
  126. package/node_modules/css-select/lib/esm/pseudo-selectors/subselects.js +94 -0
  127. package/node_modules/css-select/lib/esm/pseudo-selectors/subselects.js.map +1 -0
  128. package/node_modules/css-select/lib/esm/sort.d.ts +12 -0
  129. package/node_modules/css-select/lib/esm/sort.d.ts.map +1 -0
  130. package/node_modules/css-select/lib/esm/sort.js +79 -0
  131. package/node_modules/css-select/lib/esm/sort.js.map +1 -0
  132. package/node_modules/css-select/lib/esm/types.d.ts +167 -0
  133. package/node_modules/css-select/lib/esm/types.d.ts.map +1 -0
  134. package/node_modules/css-select/lib/esm/types.js +2 -0
  135. package/node_modules/css-select/lib/esm/types.js.map +1 -0
  136. package/node_modules/css-select/lib/general.d.ts +3 -0
  137. package/node_modules/css-select/lib/general.d.ts.map +1 -0
  138. package/node_modules/css-select/lib/general.js +148 -0
  139. package/node_modules/css-select/lib/general.js.map +1 -0
  140. package/node_modules/css-select/lib/index.d.ts +50 -0
  141. package/node_modules/css-select/lib/index.d.ts.map +1 -0
  142. package/node_modules/css-select/lib/index.js +154 -0
  143. package/node_modules/css-select/lib/index.js.map +1 -0
  144. package/node_modules/css-select/lib/pseudo-selectors/aliases.d.ts +5 -0
  145. package/node_modules/css-select/lib/pseudo-selectors/aliases.d.ts.map +1 -0
  146. package/node_modules/css-select/lib/pseudo-selectors/aliases.js +34 -0
  147. package/node_modules/css-select/lib/pseudo-selectors/aliases.js.map +1 -0
  148. package/node_modules/css-select/lib/pseudo-selectors/filters.d.ts +4 -0
  149. package/node_modules/css-select/lib/pseudo-selectors/filters.d.ts.map +1 -0
  150. package/node_modules/css-select/lib/pseudo-selectors/filters.js +157 -0
  151. package/node_modules/css-select/lib/pseudo-selectors/filters.js.map +1 -0
  152. package/node_modules/css-select/lib/pseudo-selectors/index.d.ts +8 -0
  153. package/node_modules/css-select/lib/pseudo-selectors/index.d.ts.map +1 -0
  154. package/node_modules/css-select/lib/pseudo-selectors/index.js +46 -0
  155. package/node_modules/css-select/lib/pseudo-selectors/index.js.map +1 -0
  156. package/node_modules/css-select/lib/pseudo-selectors/pseudos.d.ts +6 -0
  157. package/node_modules/css-select/lib/pseudo-selectors/pseudos.d.ts.map +1 -0
  158. package/node_modules/css-select/lib/pseudo-selectors/pseudos.js +93 -0
  159. package/node_modules/css-select/lib/pseudo-selectors/pseudos.js.map +1 -0
  160. package/node_modules/css-select/lib/pseudo-selectors/subselects.d.ts +9 -0
  161. package/node_modules/css-select/lib/pseudo-selectors/subselects.d.ts.map +1 -0
  162. package/node_modules/css-select/lib/pseudo-selectors/subselects.js +112 -0
  163. package/node_modules/css-select/lib/pseudo-selectors/subselects.js.map +1 -0
  164. package/node_modules/css-select/lib/sort.d.ts +12 -0
  165. package/node_modules/css-select/lib/sort.d.ts.map +1 -0
  166. package/node_modules/css-select/lib/sort.js +84 -0
  167. package/node_modules/css-select/lib/sort.js.map +1 -0
  168. package/node_modules/css-select/lib/types.d.ts +167 -0
  169. package/node_modules/css-select/lib/types.d.ts.map +1 -0
  170. package/node_modules/css-select/lib/types.js +3 -0
  171. package/node_modules/css-select/lib/types.js.map +1 -0
  172. package/node_modules/css-select/package.json +81 -0
  173. package/node_modules/css-what/LICENSE +11 -0
  174. package/node_modules/css-what/lib/commonjs/index.d.ts +4 -0
  175. package/node_modules/css-what/lib/commonjs/index.d.ts.map +1 -0
  176. package/node_modules/css-what/lib/commonjs/index.js +23 -0
  177. package/node_modules/css-what/lib/commonjs/parse.d.ts +20 -0
  178. package/node_modules/css-what/lib/commonjs/parse.d.ts.map +1 -0
  179. package/node_modules/css-what/lib/commonjs/parse.js +425 -0
  180. package/node_modules/css-what/lib/commonjs/stringify.d.ts +8 -0
  181. package/node_modules/css-what/lib/commonjs/stringify.d.ts.map +1 -0
  182. package/node_modules/css-what/lib/commonjs/stringify.js +138 -0
  183. package/node_modules/css-what/lib/commonjs/types.d.ts +70 -0
  184. package/node_modules/css-what/lib/commonjs/types.d.ts.map +1 -0
  185. package/node_modules/css-what/lib/commonjs/types.js +42 -0
  186. package/node_modules/css-what/lib/es/index.d.ts +4 -0
  187. package/node_modules/css-what/lib/es/index.d.ts.map +1 -0
  188. package/node_modules/css-what/lib/es/index.js +3 -0
  189. package/node_modules/css-what/lib/es/parse.d.ts +20 -0
  190. package/node_modules/css-what/lib/es/parse.d.ts.map +1 -0
  191. package/node_modules/css-what/lib/es/parse.js +420 -0
  192. package/node_modules/css-what/lib/es/stringify.d.ts +8 -0
  193. package/node_modules/css-what/lib/es/stringify.d.ts.map +1 -0
  194. package/node_modules/css-what/lib/es/stringify.js +126 -0
  195. package/node_modules/css-what/lib/es/types.d.ts +70 -0
  196. package/node_modules/css-what/lib/es/types.d.ts.map +1 -0
  197. package/node_modules/css-what/lib/es/types.js +39 -0
  198. package/node_modules/css-what/package.json +59 -0
  199. package/node_modules/css-what/readme.md +69 -0
  200. package/node_modules/dom-serializer/LICENSE +11 -0
  201. package/node_modules/dom-serializer/README.md +109 -0
  202. package/node_modules/dom-serializer/lib/esm/foreignNames.d.ts +3 -0
  203. package/node_modules/dom-serializer/lib/esm/foreignNames.d.ts.map +1 -0
  204. package/node_modules/dom-serializer/lib/esm/foreignNames.js +100 -0
  205. package/node_modules/dom-serializer/lib/esm/index.d.ts +52 -0
  206. package/node_modules/dom-serializer/lib/esm/index.d.ts.map +1 -0
  207. package/node_modules/dom-serializer/lib/esm/index.js +190 -0
  208. package/node_modules/dom-serializer/lib/esm/package.json +1 -0
  209. package/node_modules/dom-serializer/lib/foreignNames.d.ts +3 -0
  210. package/node_modules/dom-serializer/lib/foreignNames.d.ts.map +1 -0
  211. package/node_modules/dom-serializer/lib/foreignNames.js +103 -0
  212. package/node_modules/dom-serializer/lib/index.d.ts +52 -0
  213. package/node_modules/dom-serializer/lib/index.d.ts.map +1 -0
  214. package/node_modules/dom-serializer/lib/index.js +229 -0
  215. package/node_modules/dom-serializer/package.json +69 -0
  216. package/node_modules/domelementtype/LICENSE +11 -0
  217. package/node_modules/domelementtype/lib/esm/index.d.ts +48 -0
  218. package/node_modules/domelementtype/lib/esm/index.d.ts.map +1 -0
  219. package/node_modules/domelementtype/lib/esm/index.js +51 -0
  220. package/node_modules/domelementtype/lib/esm/package.json +1 -0
  221. package/node_modules/domelementtype/lib/index.d.ts +48 -0
  222. package/node_modules/domelementtype/lib/index.d.ts.map +1 -0
  223. package/node_modules/domelementtype/lib/index.js +55 -0
  224. package/node_modules/domelementtype/package.json +54 -0
  225. package/node_modules/domelementtype/readme.md +1 -0
  226. package/node_modules/domhandler/LICENSE +11 -0
  227. package/node_modules/domhandler/lib/esm/index.d.ts +76 -0
  228. package/node_modules/domhandler/lib/esm/index.d.ts.map +1 -0
  229. package/node_modules/domhandler/lib/esm/index.js +146 -0
  230. package/node_modules/domhandler/lib/esm/node.d.ts +245 -0
  231. package/node_modules/domhandler/lib/esm/node.d.ts.map +1 -0
  232. package/node_modules/domhandler/lib/esm/node.js +338 -0
  233. package/node_modules/domhandler/lib/esm/package.json +1 -0
  234. package/node_modules/domhandler/lib/index.d.ts +76 -0
  235. package/node_modules/domhandler/lib/index.d.ts.map +1 -0
  236. package/node_modules/domhandler/lib/index.js +165 -0
  237. package/node_modules/domhandler/lib/node.d.ts +245 -0
  238. package/node_modules/domhandler/lib/node.d.ts.map +1 -0
  239. package/node_modules/domhandler/lib/node.js +474 -0
  240. package/node_modules/domhandler/package.json +73 -0
  241. package/node_modules/domhandler/readme.md +92 -0
  242. package/node_modules/domutils/LICENSE +11 -0
  243. package/node_modules/domutils/lib/esm/feeds.d.ts +71 -0
  244. package/node_modules/domutils/lib/esm/feeds.d.ts.map +1 -0
  245. package/node_modules/domutils/lib/esm/feeds.js +183 -0
  246. package/node_modules/domutils/lib/esm/feeds.js.map +1 -0
  247. package/node_modules/domutils/lib/esm/helpers.d.ts +59 -0
  248. package/node_modules/domutils/lib/esm/helpers.d.ts.map +1 -0
  249. package/node_modules/domutils/lib/esm/helpers.js +136 -0
  250. package/node_modules/domutils/lib/esm/helpers.js.map +1 -0
  251. package/node_modules/domutils/lib/esm/index.d.ts +10 -0
  252. package/node_modules/domutils/lib/esm/index.d.ts.map +1 -0
  253. package/node_modules/domutils/lib/esm/index.js +10 -0
  254. package/node_modules/domutils/lib/esm/index.js.map +1 -0
  255. package/node_modules/domutils/lib/esm/legacy.d.ts +79 -0
  256. package/node_modules/domutils/lib/esm/legacy.d.ts.map +1 -0
  257. package/node_modules/domutils/lib/esm/legacy.js +152 -0
  258. package/node_modules/domutils/lib/esm/legacy.js.map +1 -0
  259. package/node_modules/domutils/lib/esm/manipulation.d.ts +49 -0
  260. package/node_modules/domutils/lib/esm/manipulation.d.ts.map +1 -0
  261. package/node_modules/domutils/lib/esm/manipulation.js +134 -0
  262. package/node_modules/domutils/lib/esm/manipulation.js.map +1 -0
  263. package/node_modules/domutils/lib/esm/package.json +1 -0
  264. package/node_modules/domutils/lib/esm/querying.d.ts +64 -0
  265. package/node_modules/domutils/lib/esm/querying.d.ts.map +1 -0
  266. package/node_modules/domutils/lib/esm/querying.js +142 -0
  267. package/node_modules/domutils/lib/esm/querying.js.map +1 -0
  268. package/node_modules/domutils/lib/esm/stringify.d.ts +46 -0
  269. package/node_modules/domutils/lib/esm/stringify.d.ts.map +1 -0
  270. package/node_modules/domutils/lib/esm/stringify.js +81 -0
  271. package/node_modules/domutils/lib/esm/stringify.js.map +1 -0
  272. package/node_modules/domutils/lib/esm/traversal.d.ts +67 -0
  273. package/node_modules/domutils/lib/esm/traversal.d.ts.map +1 -0
  274. package/node_modules/domutils/lib/esm/traversal.js +112 -0
  275. package/node_modules/domutils/lib/esm/traversal.js.map +1 -0
  276. package/node_modules/domutils/lib/feeds.d.ts +71 -0
  277. package/node_modules/domutils/lib/feeds.d.ts.map +1 -0
  278. package/node_modules/domutils/lib/feeds.js +190 -0
  279. package/node_modules/domutils/lib/feeds.js.map +1 -0
  280. package/node_modules/domutils/lib/helpers.d.ts +59 -0
  281. package/node_modules/domutils/lib/helpers.d.ts.map +1 -0
  282. package/node_modules/domutils/lib/helpers.js +142 -0
  283. package/node_modules/domutils/lib/helpers.js.map +1 -0
  284. package/node_modules/domutils/lib/index.d.ts +10 -0
  285. package/node_modules/domutils/lib/index.d.ts.map +1 -0
  286. package/node_modules/domutils/lib/index.js +33 -0
  287. package/node_modules/domutils/lib/index.js.map +1 -0
  288. package/node_modules/domutils/lib/legacy.d.ts +79 -0
  289. package/node_modules/domutils/lib/legacy.d.ts.map +1 -0
  290. package/node_modules/domutils/lib/legacy.js +168 -0
  291. package/node_modules/domutils/lib/legacy.js.map +1 -0
  292. package/node_modules/domutils/lib/manipulation.d.ts +49 -0
  293. package/node_modules/domutils/lib/manipulation.d.ts.map +1 -0
  294. package/node_modules/domutils/lib/manipulation.js +142 -0
  295. package/node_modules/domutils/lib/manipulation.js.map +1 -0
  296. package/node_modules/domutils/lib/querying.d.ts +64 -0
  297. package/node_modules/domutils/lib/querying.d.ts.map +1 -0
  298. package/node_modules/domutils/lib/querying.js +155 -0
  299. package/node_modules/domutils/lib/querying.js.map +1 -0
  300. package/node_modules/domutils/lib/stringify.d.ts +46 -0
  301. package/node_modules/domutils/lib/stringify.d.ts.map +1 -0
  302. package/node_modules/domutils/lib/stringify.js +91 -0
  303. package/node_modules/domutils/lib/stringify.js.map +1 -0
  304. package/node_modules/domutils/lib/traversal.d.ts +67 -0
  305. package/node_modules/domutils/lib/traversal.d.ts.map +1 -0
  306. package/node_modules/domutils/lib/traversal.js +125 -0
  307. package/node_modules/domutils/lib/traversal.js.map +1 -0
  308. package/node_modules/domutils/package.json +79 -0
  309. package/node_modules/domutils/readme.md +31 -0
  310. package/node_modules/entities/LICENSE +11 -0
  311. package/node_modules/entities/lib/decode.d.ts +211 -0
  312. package/node_modules/entities/lib/decode.d.ts.map +1 -0
  313. package/node_modules/entities/lib/decode.js +536 -0
  314. package/node_modules/entities/lib/decode.js.map +1 -0
  315. package/node_modules/entities/lib/decode_codepoint.d.ts +19 -0
  316. package/node_modules/entities/lib/decode_codepoint.d.ts.map +1 -0
  317. package/node_modules/entities/lib/decode_codepoint.js +76 -0
  318. package/node_modules/entities/lib/decode_codepoint.js.map +1 -0
  319. package/node_modules/entities/lib/encode.d.ts +22 -0
  320. package/node_modules/entities/lib/encode.d.ts.map +1 -0
  321. package/node_modules/entities/lib/encode.js +77 -0
  322. package/node_modules/entities/lib/encode.js.map +1 -0
  323. package/node_modules/entities/lib/escape.d.ts +43 -0
  324. package/node_modules/entities/lib/escape.d.ts.map +1 -0
  325. package/node_modules/entities/lib/escape.js +122 -0
  326. package/node_modules/entities/lib/escape.js.map +1 -0
  327. package/node_modules/entities/lib/esm/decode.d.ts +211 -0
  328. package/node_modules/entities/lib/esm/decode.d.ts.map +1 -0
  329. package/node_modules/entities/lib/esm/decode.js +496 -0
  330. package/node_modules/entities/lib/esm/decode.js.map +1 -0
  331. package/node_modules/entities/lib/esm/decode_codepoint.d.ts +19 -0
  332. package/node_modules/entities/lib/esm/decode_codepoint.d.ts.map +1 -0
  333. package/node_modules/entities/lib/esm/decode_codepoint.js +71 -0
  334. package/node_modules/entities/lib/esm/decode_codepoint.js.map +1 -0
  335. package/node_modules/entities/lib/esm/encode.d.ts +22 -0
  336. package/node_modules/entities/lib/esm/encode.d.ts.map +1 -0
  337. package/node_modules/entities/lib/esm/encode.js +69 -0
  338. package/node_modules/entities/lib/esm/encode.js.map +1 -0
  339. package/node_modules/entities/lib/esm/escape.d.ts +43 -0
  340. package/node_modules/entities/lib/esm/escape.d.ts.map +1 -0
  341. package/node_modules/entities/lib/esm/escape.js +116 -0
  342. package/node_modules/entities/lib/esm/escape.js.map +1 -0
  343. package/node_modules/entities/lib/esm/generated/decode-data-html.d.ts +3 -0
  344. package/node_modules/entities/lib/esm/generated/decode-data-html.d.ts.map +1 -0
  345. package/node_modules/entities/lib/esm/generated/decode-data-html.js +7 -0
  346. package/node_modules/entities/lib/esm/generated/decode-data-html.js.map +1 -0
  347. package/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts +3 -0
  348. package/node_modules/entities/lib/esm/generated/decode-data-xml.d.ts.map +1 -0
  349. package/node_modules/entities/lib/esm/generated/decode-data-xml.js +7 -0
  350. package/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +1 -0
  351. package/node_modules/entities/lib/esm/generated/encode-html.d.ts +8 -0
  352. package/node_modules/entities/lib/esm/generated/encode-html.d.ts.map +1 -0
  353. package/node_modules/entities/lib/esm/generated/encode-html.js +10 -0
  354. package/node_modules/entities/lib/esm/generated/encode-html.js.map +1 -0
  355. package/node_modules/entities/lib/esm/index.d.ts +96 -0
  356. package/node_modules/entities/lib/esm/index.d.ts.map +1 -0
  357. package/node_modules/entities/lib/esm/index.js +99 -0
  358. package/node_modules/entities/lib/esm/index.js.map +1 -0
  359. package/node_modules/entities/lib/esm/package.json +1 -0
  360. package/node_modules/entities/lib/generated/decode-data-html.d.ts +3 -0
  361. package/node_modules/entities/lib/generated/decode-data-html.d.ts.map +1 -0
  362. package/node_modules/entities/lib/generated/decode-data-html.js +9 -0
  363. package/node_modules/entities/lib/generated/decode-data-html.js.map +1 -0
  364. package/node_modules/entities/lib/generated/decode-data-xml.d.ts +3 -0
  365. package/node_modules/entities/lib/generated/decode-data-xml.d.ts.map +1 -0
  366. package/node_modules/entities/lib/generated/decode-data-xml.js +9 -0
  367. package/node_modules/entities/lib/generated/decode-data-xml.js.map +1 -0
  368. package/node_modules/entities/lib/generated/encode-html.d.ts +8 -0
  369. package/node_modules/entities/lib/generated/encode-html.d.ts.map +1 -0
  370. package/node_modules/entities/lib/generated/encode-html.js +12 -0
  371. package/node_modules/entities/lib/generated/encode-html.js.map +1 -0
  372. package/node_modules/entities/lib/index.d.ts +96 -0
  373. package/node_modules/entities/lib/index.d.ts.map +1 -0
  374. package/node_modules/entities/lib/index.js +126 -0
  375. package/node_modules/entities/lib/index.js.map +1 -0
  376. package/node_modules/entities/package.json +90 -0
  377. package/node_modules/entities/readme.md +122 -0
  378. package/node_modules/he/LICENSE-MIT.txt +20 -0
  379. package/node_modules/he/README.md +379 -0
  380. package/node_modules/he/bin/he +148 -0
  381. package/node_modules/he/he.js +345 -0
  382. package/node_modules/he/man/he.1 +78 -0
  383. package/node_modules/he/package.json +58 -0
  384. package/node_modules/node-html-parser/CHANGELOG.md +137 -0
  385. package/node_modules/node-html-parser/LICENSE +7 -0
  386. package/node_modules/node-html-parser/README.md +365 -0
  387. package/node_modules/node-html-parser/dist/back.d.ts +1 -0
  388. package/node_modules/node-html-parser/dist/back.js +6 -0
  389. package/node_modules/node-html-parser/dist/index.d.ts +20 -0
  390. package/node_modules/node-html-parser/dist/index.js +32 -0
  391. package/node_modules/node-html-parser/dist/main.js +1646 -0
  392. package/node_modules/node-html-parser/dist/matcher.d.ts +6 -0
  393. package/node_modules/node-html-parser/dist/matcher.js +106 -0
  394. package/node_modules/node-html-parser/dist/nodes/comment.d.ts +20 -0
  395. package/node_modules/node-html-parser/dist/nodes/comment.js +57 -0
  396. package/node_modules/node-html-parser/dist/nodes/html.d.ts +240 -0
  397. package/node_modules/node-html-parser/dist/nodes/html.js +1218 -0
  398. package/node_modules/node-html-parser/dist/nodes/node.d.ts +24 -0
  399. package/node_modules/node-html-parser/dist/nodes/node.js +52 -0
  400. package/node_modules/node-html-parser/dist/nodes/text.d.ts +44 -0
  401. package/node_modules/node-html-parser/dist/nodes/text.js +144 -0
  402. package/node_modules/node-html-parser/dist/nodes/type.d.ts +6 -0
  403. package/node_modules/node-html-parser/dist/nodes/type.js +9 -0
  404. package/node_modules/node-html-parser/dist/parse.d.ts +1 -0
  405. package/node_modules/node-html-parser/dist/parse.js +5 -0
  406. package/node_modules/node-html-parser/dist/valid.d.ts +6 -0
  407. package/node_modules/node-html-parser/dist/valid.js +13 -0
  408. package/node_modules/node-html-parser/dist/void-tag.d.ts +7 -0
  409. package/node_modules/node-html-parser/dist/void-tag.js +29 -0
  410. package/node_modules/node-html-parser/package.json +114 -0
  411. package/node_modules/nth-check/LICENSE +11 -0
  412. package/node_modules/nth-check/README.md +136 -0
  413. package/node_modules/nth-check/lib/compile.d.ts +55 -0
  414. package/node_modules/nth-check/lib/compile.d.ts.map +1 -0
  415. package/node_modules/nth-check/lib/compile.js +121 -0
  416. package/node_modules/nth-check/lib/compile.js.map +1 -0
  417. package/node_modules/nth-check/lib/esm/compile.d.ts +55 -0
  418. package/node_modules/nth-check/lib/esm/compile.d.ts.map +1 -0
  419. package/node_modules/nth-check/lib/esm/compile.js +113 -0
  420. package/node_modules/nth-check/lib/esm/compile.js.map +1 -0
  421. package/node_modules/nth-check/lib/esm/index.d.ts +59 -0
  422. package/node_modules/nth-check/lib/esm/index.d.ts.map +1 -0
  423. package/node_modules/nth-check/lib/esm/index.js +63 -0
  424. package/node_modules/nth-check/lib/esm/index.js.map +1 -0
  425. package/node_modules/nth-check/lib/esm/package.json +1 -0
  426. package/node_modules/nth-check/lib/esm/parse.d.ts +9 -0
  427. package/node_modules/nth-check/lib/esm/parse.d.ts.map +1 -0
  428. package/node_modules/nth-check/lib/esm/parse.js +73 -0
  429. package/node_modules/nth-check/lib/esm/parse.js.map +1 -0
  430. package/node_modules/nth-check/lib/index.d.ts +59 -0
  431. package/node_modules/nth-check/lib/index.d.ts.map +1 -0
  432. package/node_modules/nth-check/lib/index.js +70 -0
  433. package/node_modules/nth-check/lib/index.js.map +1 -0
  434. package/node_modules/nth-check/lib/parse.d.ts +9 -0
  435. package/node_modules/nth-check/lib/parse.d.ts.map +1 -0
  436. package/node_modules/nth-check/lib/parse.js +77 -0
  437. package/node_modules/nth-check/lib/parse.js.map +1 -0
  438. package/node_modules/nth-check/package.json +78 -0
  439. package/package.json +154 -0
@@ -0,0 +1,152 @@
1
+ import { isTag, isText } from "domhandler";
2
+ import { filter, findOne } from "./querying.js";
3
+ /**
4
+ * A map of functions to check nodes against.
5
+ */
6
+ const Checks = {
7
+ tag_name(name) {
8
+ if (typeof name === "function") {
9
+ return (elem) => isTag(elem) && name(elem.name);
10
+ }
11
+ else if (name === "*") {
12
+ return isTag;
13
+ }
14
+ return (elem) => isTag(elem) && elem.name === name;
15
+ },
16
+ tag_type(type) {
17
+ if (typeof type === "function") {
18
+ return (elem) => type(elem.type);
19
+ }
20
+ return (elem) => elem.type === type;
21
+ },
22
+ tag_contains(data) {
23
+ if (typeof data === "function") {
24
+ return (elem) => isText(elem) && data(elem.data);
25
+ }
26
+ return (elem) => isText(elem) && elem.data === data;
27
+ },
28
+ };
29
+ /**
30
+ * Returns a function to check whether a node has an attribute with a particular
31
+ * value.
32
+ *
33
+ * @param attrib Attribute to check.
34
+ * @param value Attribute value to look for.
35
+ * @returns A function to check whether the a node has an attribute with a
36
+ * particular value.
37
+ */
38
+ function getAttribCheck(attrib, value) {
39
+ if (typeof value === "function") {
40
+ return (elem) => isTag(elem) && value(elem.attribs[attrib]);
41
+ }
42
+ return (elem) => isTag(elem) && elem.attribs[attrib] === value;
43
+ }
44
+ /**
45
+ * Returns a function that returns `true` if either of the input functions
46
+ * returns `true` for a node.
47
+ *
48
+ * @param a First function to combine.
49
+ * @param b Second function to combine.
50
+ * @returns A function taking a node and returning `true` if either of the input
51
+ * functions returns `true` for the node.
52
+ */
53
+ function combineFuncs(a, b) {
54
+ return (elem) => a(elem) || b(elem);
55
+ }
56
+ /**
57
+ * Returns a function that executes all checks in `options` and returns `true`
58
+ * if any of them match a node.
59
+ *
60
+ * @param options An object describing nodes to look for.
61
+ * @returns A function that executes all checks in `options` and returns `true`
62
+ * if any of them match a node.
63
+ */
64
+ function compileTest(options) {
65
+ const funcs = Object.keys(options).map((key) => {
66
+ const value = options[key];
67
+ return Object.prototype.hasOwnProperty.call(Checks, key)
68
+ ? Checks[key](value)
69
+ : getAttribCheck(key, value);
70
+ });
71
+ return funcs.length === 0 ? null : funcs.reduce(combineFuncs);
72
+ }
73
+ /**
74
+ * Checks whether a node matches the description in `options`.
75
+ *
76
+ * @category Legacy Query Functions
77
+ * @param options An object describing nodes to look for.
78
+ * @param node The element to test.
79
+ * @returns Whether the element matches the description in `options`.
80
+ */
81
+ export function testElement(options, node) {
82
+ const test = compileTest(options);
83
+ return test ? test(node) : true;
84
+ }
85
+ /**
86
+ * Returns all nodes that match `options`.
87
+ *
88
+ * @category Legacy Query Functions
89
+ * @param options An object describing nodes to look for.
90
+ * @param nodes Nodes to search through.
91
+ * @param recurse Also consider child nodes.
92
+ * @param limit Maximum number of nodes to return.
93
+ * @returns All nodes that match `options`.
94
+ */
95
+ export function getElements(options, nodes, recurse, limit = Infinity) {
96
+ const test = compileTest(options);
97
+ return test ? filter(test, nodes, recurse, limit) : [];
98
+ }
99
+ /**
100
+ * Returns the node with the supplied ID.
101
+ *
102
+ * @category Legacy Query Functions
103
+ * @param id The unique ID attribute value to look for.
104
+ * @param nodes Nodes to search through.
105
+ * @param recurse Also consider child nodes.
106
+ * @returns The node with the supplied ID.
107
+ */
108
+ export function getElementById(id, nodes, recurse = true) {
109
+ if (!Array.isArray(nodes))
110
+ nodes = [nodes];
111
+ return findOne(getAttribCheck("id", id), nodes, recurse);
112
+ }
113
+ /**
114
+ * Returns all nodes with the supplied `tagName`.
115
+ *
116
+ * @category Legacy Query Functions
117
+ * @param tagName Tag name to search for.
118
+ * @param nodes Nodes to search through.
119
+ * @param recurse Also consider child nodes.
120
+ * @param limit Maximum number of nodes to return.
121
+ * @returns All nodes with the supplied `tagName`.
122
+ */
123
+ export function getElementsByTagName(tagName, nodes, recurse = true, limit = Infinity) {
124
+ return filter(Checks["tag_name"](tagName), nodes, recurse, limit);
125
+ }
126
+ /**
127
+ * Returns all nodes with the supplied `className`.
128
+ *
129
+ * @category Legacy Query Functions
130
+ * @param className Class name to search for.
131
+ * @param nodes Nodes to search through.
132
+ * @param recurse Also consider child nodes.
133
+ * @param limit Maximum number of nodes to return.
134
+ * @returns All nodes with the supplied `className`.
135
+ */
136
+ export function getElementsByClassName(className, nodes, recurse = true, limit = Infinity) {
137
+ return filter(getAttribCheck("class", className), nodes, recurse, limit);
138
+ }
139
+ /**
140
+ * Returns all nodes with the supplied `type`.
141
+ *
142
+ * @category Legacy Query Functions
143
+ * @param type Element type to look for.
144
+ * @param nodes Nodes to search through.
145
+ * @param recurse Also consider child nodes.
146
+ * @param limit Maximum number of nodes to return.
147
+ * @returns All nodes with the supplied `type`.
148
+ */
149
+ export function getElementsByTagType(type, nodes, recurse = true, limit = Infinity) {
150
+ return filter(Checks["tag_type"](type), nodes, recurse, limit);
151
+ }
152
+ //# sourceMappingURL=legacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"legacy.js","sourceRoot":"https://raw.githubusercontent.com/fb55/domutils/0ab8bcf1ecfc70dfc93291a4cb2496578ac25e9c/src/","sources":["legacy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAoB,MAAM,YAAY,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAqBhD;;GAEG;AACH,MAAM,MAAM,GA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import type { ChildNode, ParentNode } from "domhandler";
2
+ /**
3
+ * Remove an element from the dom
4
+ *
5
+ * @category Manipulation
6
+ * @param elem The element to be removed
7
+ */
8
+ export declare function removeElement(elem: ChildNode): void;
9
+ /**
10
+ * Replace an element in the dom
11
+ *
12
+ * @category Manipulation
13
+ * @param elem The element to be replaced
14
+ * @param replacement The element to be added
15
+ */
16
+ export declare function replaceElement(elem: ChildNode, replacement: ChildNode): void;
17
+ /**
18
+ * Append a child to an element.
19
+ *
20
+ * @category Manipulation
21
+ * @param parent The element to append to.
22
+ * @param child The element to be added as a child.
23
+ */
24
+ export declare function appendChild(parent: ParentNode, child: ChildNode): void;
25
+ /**
26
+ * Append an element after another.
27
+ *
28
+ * @category Manipulation
29
+ * @param elem The element to append after.
30
+ * @param next The element be added.
31
+ */
32
+ export declare function append(elem: ChildNode, next: ChildNode): void;
33
+ /**
34
+ * Prepend a child to an element.
35
+ *
36
+ * @category Manipulation
37
+ * @param parent The element to prepend before.
38
+ * @param child The element to be added as a child.
39
+ */
40
+ export declare function prependChild(parent: ParentNode, child: ChildNode): void;
41
+ /**
42
+ * Prepend an element before another.
43
+ *
44
+ * @category Manipulation
45
+ * @param elem The element to prepend before.
46
+ * @param prev The element be added.
47
+ */
48
+ export declare function prepend(elem: ChildNode, prev: ChildNode): void;
49
+ //# sourceMappingURL=manipulation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manipulation.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/domutils/0ab8bcf1ecfc70dfc93291a4cb2496578ac25e9c/src/","sources":["manipulation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAcnD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,GAAG,IAAI,CAiB5E;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAatE;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI,CAoB7D;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI,CAavE;AAED;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI,CAiB9D"}
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Remove an element from the dom
3
+ *
4
+ * @category Manipulation
5
+ * @param elem The element to be removed
6
+ */
7
+ export function removeElement(elem) {
8
+ if (elem.prev)
9
+ elem.prev.next = elem.next;
10
+ if (elem.next)
11
+ elem.next.prev = elem.prev;
12
+ if (elem.parent) {
13
+ const childs = elem.parent.children;
14
+ const childsIndex = childs.lastIndexOf(elem);
15
+ if (childsIndex >= 0) {
16
+ childs.splice(childsIndex, 1);
17
+ }
18
+ }
19
+ elem.next = null;
20
+ elem.prev = null;
21
+ elem.parent = null;
22
+ }
23
+ /**
24
+ * Replace an element in the dom
25
+ *
26
+ * @category Manipulation
27
+ * @param elem The element to be replaced
28
+ * @param replacement The element to be added
29
+ */
30
+ export function replaceElement(elem, replacement) {
31
+ const prev = (replacement.prev = elem.prev);
32
+ if (prev) {
33
+ prev.next = replacement;
34
+ }
35
+ const next = (replacement.next = elem.next);
36
+ if (next) {
37
+ next.prev = replacement;
38
+ }
39
+ const parent = (replacement.parent = elem.parent);
40
+ if (parent) {
41
+ const childs = parent.children;
42
+ childs[childs.lastIndexOf(elem)] = replacement;
43
+ elem.parent = null;
44
+ }
45
+ }
46
+ /**
47
+ * Append a child to an element.
48
+ *
49
+ * @category Manipulation
50
+ * @param parent The element to append to.
51
+ * @param child The element to be added as a child.
52
+ */
53
+ export function appendChild(parent, child) {
54
+ removeElement(child);
55
+ child.next = null;
56
+ child.parent = parent;
57
+ if (parent.children.push(child) > 1) {
58
+ const sibling = parent.children[parent.children.length - 2];
59
+ sibling.next = child;
60
+ child.prev = sibling;
61
+ }
62
+ else {
63
+ child.prev = null;
64
+ }
65
+ }
66
+ /**
67
+ * Append an element after another.
68
+ *
69
+ * @category Manipulation
70
+ * @param elem The element to append after.
71
+ * @param next The element be added.
72
+ */
73
+ export function append(elem, next) {
74
+ removeElement(next);
75
+ const { parent } = elem;
76
+ const currNext = elem.next;
77
+ next.next = currNext;
78
+ next.prev = elem;
79
+ elem.next = next;
80
+ next.parent = parent;
81
+ if (currNext) {
82
+ currNext.prev = next;
83
+ if (parent) {
84
+ const childs = parent.children;
85
+ childs.splice(childs.lastIndexOf(currNext), 0, next);
86
+ }
87
+ }
88
+ else if (parent) {
89
+ parent.children.push(next);
90
+ }
91
+ }
92
+ /**
93
+ * Prepend a child to an element.
94
+ *
95
+ * @category Manipulation
96
+ * @param parent The element to prepend before.
97
+ * @param child The element to be added as a child.
98
+ */
99
+ export function prependChild(parent, child) {
100
+ removeElement(child);
101
+ child.parent = parent;
102
+ child.prev = null;
103
+ if (parent.children.unshift(child) !== 1) {
104
+ const sibling = parent.children[1];
105
+ sibling.prev = child;
106
+ child.next = sibling;
107
+ }
108
+ else {
109
+ child.next = null;
110
+ }
111
+ }
112
+ /**
113
+ * Prepend an element before another.
114
+ *
115
+ * @category Manipulation
116
+ * @param elem The element to prepend before.
117
+ * @param prev The element be added.
118
+ */
119
+ export function prepend(elem, prev) {
120
+ removeElement(prev);
121
+ const { parent } = elem;
122
+ if (parent) {
123
+ const childs = parent.children;
124
+ childs.splice(childs.indexOf(elem), 0, prev);
125
+ }
126
+ if (elem.prev) {
127
+ elem.prev.next = prev;
128
+ }
129
+ prev.parent = parent;
130
+ prev.prev = elem.prev;
131
+ prev.next = elem;
132
+ elem.prev = prev;
133
+ }
134
+ //# sourceMappingURL=manipulation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manipulation.js","sourceRoot":"https://raw.githubusercontent.com/fb55/domutils/0ab8bcf1ecfc70dfc93291a4cb2496578ac25e9c/src/","sources":["manipulation.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,IAAe;IACzC,IAAI,IAAI,CAAC,IAAI;QAAE,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IAC1C,IAAI,IAAI,CAAC,IAAI;QAAE,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IAE1C,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;QACpC,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,WAAW,IAAI,CAAC,EAAE,CAAC;YACnB,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;QAClC,CAAC;IACL,CAAC;IACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;AACvB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,IAAe,EAAE,WAAsB;IAClE,MAAM,IAAI,GAAG,CAAC,WAAW,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,IAAI,IAAI,EAAE,CAAC;QACP,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC5B,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,WAAW,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,IAAI,IAAI,EAAE,CAAC;QACP,IAAI,CAA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I,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACrB,CAAC"}
@@ -0,0 +1 @@
1
+ {"type":"module"}
@@ -0,0 +1,64 @@
1
+ import { Element, AnyNode, ParentNode } from "domhandler";
2
+ /**
3
+ * Search a node and its children for nodes passing a test function. If `node` is not an array, it will be wrapped in one.
4
+ *
5
+ * @category Querying
6
+ * @param test Function to test nodes on.
7
+ * @param node Node to search. Will be included in the result set if it matches.
8
+ * @param recurse Also consider child nodes.
9
+ * @param limit Maximum number of nodes to return.
10
+ * @returns All nodes passing `test`.
11
+ */
12
+ export declare function filter(test: (elem: AnyNode) => boolean, node: AnyNode | AnyNode[], recurse?: boolean, limit?: number): AnyNode[];
13
+ /**
14
+ * Search an array of nodes and their children for nodes passing a test function.
15
+ *
16
+ * @category Querying
17
+ * @param test Function to test nodes on.
18
+ * @param nodes Array of nodes to search.
19
+ * @param recurse Also consider child nodes.
20
+ * @param limit Maximum number of nodes to return.
21
+ * @returns All nodes passing `test`.
22
+ */
23
+ export declare function find(test: (elem: AnyNode) => boolean, nodes: AnyNode[] | ParentNode, recurse: boolean, limit: number): AnyNode[];
24
+ /**
25
+ * Finds the first element inside of an array that matches a test function. This is an alias for `Array.prototype.find`.
26
+ *
27
+ * @category Querying
28
+ * @param test Function to test nodes on.
29
+ * @param nodes Array of nodes to search.
30
+ * @returns The first node in the array that passes `test`.
31
+ * @deprecated Use `Array.prototype.find` directly.
32
+ */
33
+ export declare function findOneChild<T>(test: (elem: T) => boolean, nodes: T[]): T | undefined;
34
+ /**
35
+ * Finds one element in a tree that passes a test.
36
+ *
37
+ * @category Querying
38
+ * @param test Function to test nodes on.
39
+ * @param nodes Node or array of nodes to search.
40
+ * @param recurse Also consider child nodes.
41
+ * @returns The first node that passes `test`.
42
+ */
43
+ export declare function findOne(test: (elem: Element) => boolean, nodes: AnyNode[] | ParentNode, recurse?: boolean): Element | null;
44
+ /**
45
+ * Checks if a tree of nodes contains at least one node passing a test.
46
+ *
47
+ * @category Querying
48
+ * @param test Function to test nodes on.
49
+ * @param nodes Array of nodes to search.
50
+ * @returns Whether a tree of nodes contains at least one node passing the test.
51
+ */
52
+ export declare function existsOne(test: (elem: Element) => boolean, nodes: AnyNode[] | ParentNode): boolean;
53
+ /**
54
+ * Search an array of nodes and their children for elements passing a test function.
55
+ *
56
+ * Same as `find`, but limited to elements and with less options, leading to reduced complexity.
57
+ *
58
+ * @category Querying
59
+ * @param test Function to test nodes on.
60
+ * @param nodes Array of nodes to search.
61
+ * @returns All nodes passing `test`.
62
+ */
63
+ export declare function findAll(test: (elem: Element) => boolean, nodes: AnyNode[] | ParentNode): Element[];
64
+ //# sourceMappingURL=querying.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"querying.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/domutils/0ab8bcf1ecfc70dfc93291a4cb2496578ac25e9c/src/","sources":["querying.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE9E;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAClB,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,EAChC,IAAI,EAAE,OAAO,GAAG,OAAO,EAAE,EACzB,OAAO,UAAO,EACd,KAAK,GAAE,MAAiB,GACzB,OAAO,EAAE,CAEX;AAED;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAChB,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,EAChC,KAAK,EAAE,OAAO,EAAE,GAAG,UAAU,EAC7B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,GACd,OAAO,EAAE,CAuCX;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC1B,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,EAC1B,KAAK,EAAE,CAAC,EAAE,GACX,CAAC,GAAG,SAAS,CAEf;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CACnB,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,EAChC,KAAK,EAAE,OAAO,EAAE,GAAG,UAAU,EAC7B,OAAO,UAAO,GACf,OAAO,GAAG,IAAI,CAchB;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACrB,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,EAChC,KAAK,EAAE,OAAO,EAAE,GAAG,UAAU,GAC9B,OAAO,CAMT;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CACnB,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,EAChC,KAAK,EAAE,OAAO,EAAE,GAAG,UAAU,GAC9B,OAAO,EAAE,CA4BX"}
@@ -0,0 +1,142 @@
1
+ import { isTag, hasChildren } from "domhandler";
2
+ /**
3
+ * Search a node and its children for nodes passing a test function. If `node` is not an array, it will be wrapped in one.
4
+ *
5
+ * @category Querying
6
+ * @param test Function to test nodes on.
7
+ * @param node Node to search. Will be included in the result set if it matches.
8
+ * @param recurse Also consider child nodes.
9
+ * @param limit Maximum number of nodes to return.
10
+ * @returns All nodes passing `test`.
11
+ */
12
+ export function filter(test, node, recurse = true, limit = Infinity) {
13
+ return find(test, Array.isArray(node) ? node : [node], recurse, limit);
14
+ }
15
+ /**
16
+ * Search an array of nodes and their children for nodes passing a test function.
17
+ *
18
+ * @category Querying
19
+ * @param test Function to test nodes on.
20
+ * @param nodes Array of nodes to search.
21
+ * @param recurse Also consider child nodes.
22
+ * @param limit Maximum number of nodes to return.
23
+ * @returns All nodes passing `test`.
24
+ */
25
+ export function find(test, nodes, recurse, limit) {
26
+ const result = [];
27
+ /** Stack of the arrays we are looking at. */
28
+ const nodeStack = [Array.isArray(nodes) ? nodes : [nodes]];
29
+ /** Stack of the indices within the arrays. */
30
+ const indexStack = [0];
31
+ for (;;) {
32
+ // First, check if the current array has any more elements to look at.
33
+ if (indexStack[0] >= nodeStack[0].length) {
34
+ // If we have no more arrays to look at, we are done.
35
+ if (indexStack.length === 1) {
36
+ return result;
37
+ }
38
+ // Otherwise, remove the current array from the stack.
39
+ nodeStack.shift();
40
+ indexStack.shift();
41
+ // Loop back to the start to continue with the next array.
42
+ continue;
43
+ }
44
+ const elem = nodeStack[0][indexStack[0]++];
45
+ if (test(elem)) {
46
+ result.push(elem);
47
+ if (--limit <= 0)
48
+ return result;
49
+ }
50
+ if (recurse && hasChildren(elem) && elem.children.length > 0) {
51
+ /*
52
+ * Add the children to the stack. We are depth-first, so this is
53
+ * the next array we look at.
54
+ */
55
+ indexStack.unshift(0);
56
+ nodeStack.unshift(elem.children);
57
+ }
58
+ }
59
+ }
60
+ /**
61
+ * Finds the first element inside of an array that matches a test function. This is an alias for `Array.prototype.find`.
62
+ *
63
+ * @category Querying
64
+ * @param test Function to test nodes on.
65
+ * @param nodes Array of nodes to search.
66
+ * @returns The first node in the array that passes `test`.
67
+ * @deprecated Use `Array.prototype.find` directly.
68
+ */
69
+ export function findOneChild(test, nodes) {
70
+ return nodes.find(test);
71
+ }
72
+ /**
73
+ * Finds one element in a tree that passes a test.
74
+ *
75
+ * @category Querying
76
+ * @param test Function to test nodes on.
77
+ * @param nodes Node or array of nodes to search.
78
+ * @param recurse Also consider child nodes.
79
+ * @returns The first node that passes `test`.
80
+ */
81
+ export function findOne(test, nodes, recurse = true) {
82
+ const searchedNodes = Array.isArray(nodes) ? nodes : [nodes];
83
+ for (let i = 0; i < searchedNodes.length; i++) {
84
+ const node = searchedNodes[i];
85
+ if (isTag(node) && test(node)) {
86
+ return node;
87
+ }
88
+ if (recurse && hasChildren(node) && node.children.length > 0) {
89
+ const found = findOne(test, node.children, true);
90
+ if (found)
91
+ return found;
92
+ }
93
+ }
94
+ return null;
95
+ }
96
+ /**
97
+ * Checks if a tree of nodes contains at least one node passing a test.
98
+ *
99
+ * @category Querying
100
+ * @param test Function to test nodes on.
101
+ * @param nodes Array of nodes to search.
102
+ * @returns Whether a tree of nodes contains at least one node passing the test.
103
+ */
104
+ export function existsOne(test, nodes) {
105
+ return (Array.isArray(nodes) ? nodes : [nodes]).some((node) => (isTag(node) && test(node)) ||
106
+ (hasChildren(node) && existsOne(test, node.children)));
107
+ }
108
+ /**
109
+ * Search an array of nodes and their children for elements passing a test function.
110
+ *
111
+ * Same as `find`, but limited to elements and with less options, leading to reduced complexity.
112
+ *
113
+ * @category Querying
114
+ * @param test Function to test nodes on.
115
+ * @param nodes Array of nodes to search.
116
+ * @returns All nodes passing `test`.
117
+ */
118
+ export function findAll(test, nodes) {
119
+ const result = [];
120
+ const nodeStack = [Array.isArray(nodes) ? nodes : [nodes]];
121
+ const indexStack = [0];
122
+ for (;;) {
123
+ if (indexStack[0] >= nodeStack[0].length) {
124
+ if (nodeStack.length === 1) {
125
+ return result;
126
+ }
127
+ // Otherwise, remove the current array from the stack.
128
+ nodeStack.shift();
129
+ indexStack.shift();
130
+ // Loop back to the start to continue with the next array.
131
+ continue;
132
+ }
133
+ const elem = nodeStack[0][indexStack[0]++];
134
+ if (isTag(elem) && test(elem))
135
+ result.push(elem);
136
+ if (hasChildren(elem) && elem.children.length > 0) {
137
+ indexStack.unshift(0);
138
+ nodeStack.unshift(elem.children);
139
+ }
140
+ }
141
+ }
142
+ //# sourceMappingURL=querying.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"querying.js","sourceRoot":"https://raw.githubusercontent.com/fb55/domutils/0ab8bcf1ecfc70dfc93291a4cb2496578ac25e9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AC;QAE3C,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC;YAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEjD,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAChD,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACtB,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACrC,CAAC;IACL,CAAC;AACL,CAAC"}
@@ -0,0 +1,46 @@
1
+ import { AnyNode } from "domhandler";
2
+ import { DomSerializerOptions } from "dom-serializer";
3
+ /**
4
+ * @category Stringify
5
+ * @deprecated Use the `dom-serializer` module directly.
6
+ * @param node Node to get the outer HTML of.
7
+ * @param options Options for serialization.
8
+ * @returns `node`'s outer HTML.
9
+ */
10
+ export declare function getOuterHTML(node: AnyNode | ArrayLike<AnyNode>, options?: DomSerializerOptions): string;
11
+ /**
12
+ * @category Stringify
13
+ * @deprecated Use the `dom-serializer` module directly.
14
+ * @param node Node to get the inner HTML of.
15
+ * @param options Options for serialization.
16
+ * @returns `node`'s inner HTML.
17
+ */
18
+ export declare function getInnerHTML(node: AnyNode, options?: DomSerializerOptions): string;
19
+ /**
20
+ * Get a node's inner text. Same as `textContent`, but inserts newlines for `<br>` tags. Ignores comments.
21
+ *
22
+ * @category Stringify
23
+ * @deprecated Use `textContent` instead.
24
+ * @param node Node to get the inner text of.
25
+ * @returns `node`'s inner text.
26
+ */
27
+ export declare function getText(node: AnyNode | AnyNode[]): string;
28
+ /**
29
+ * Get a node's text content. Ignores comments.
30
+ *
31
+ * @category Stringify
32
+ * @param node Node to get the text content of.
33
+ * @returns `node`'s text content.
34
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent}
35
+ */
36
+ export declare function textContent(node: AnyNode | AnyNode[]): string;
37
+ /**
38
+ * Get a node's inner text, ignoring `<script>` and `<style>` tags. Ignores comments.
39
+ *
40
+ * @category Stringify
41
+ * @param node Node to get the inner text of.
42
+ * @returns `node`'s inner text.
43
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Node/innerText}
44
+ */
45
+ export declare function innerText(node: AnyNode | AnyNode[]): string;
46
+ //# sourceMappingURL=stringify.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stringify.d.ts","sourceRoot":"https://raw.githubusercontent.com/fb55/domutils/0ab8bcf1ecfc70dfc93291a4cb2496578ac25e9c/src/","sources":["stringify.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,OAAO,EAEV,MAAM,YAAY,CAAC;AACpB,OAAmB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAGlE;;;;;;GAMG;AACH,wBAAgB,YAAY,CACxB,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC,OAAO,CAAC,EAClC,OAAO,CAAC,EAAE,oBAAoB,GAC/B,MAAM,CAER;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CACxB,IAAI,EAAE,OAAO,EACb,OAAO,CAAC,EAAE,oBAAoB,GAC/B,MAAM,CAIR;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,EAAE,GAAG,MAAM,CAMzD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,EAAE,GAAG,MAAM,CAO7D;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,EAAE,GAAG,MAAM,CAO3D"}