@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,1646 @@
1
+ var __importDefault = (this && this.__importDefault) || function (mod) {
2
+ return (mod && mod.__esModule) ? mod : { "default": mod };
3
+ };
4
+ var __extends = (this && this.__extends) || (function () {
5
+ var extendStatics = function (d, b) {
6
+ extendStatics = Object.setPrototypeOf ||
7
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
8
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
9
+ return extendStatics(d, b);
10
+ };
11
+ return function (d, b) {
12
+ if (typeof b !== "function" && b !== null)
13
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
14
+ extendStatics(d, b);
15
+ function __() { this.constructor = d; }
16
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17
+ };
18
+ })();
19
+ var __assign = (this && this.__assign) || function () {
20
+ __assign = Object.assign || function(t) {
21
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
22
+ s = arguments[i];
23
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
24
+ t[p] = s[p];
25
+ }
26
+ return t;
27
+ };
28
+ return __assign.apply(this, arguments);
29
+ };
30
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
31
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
32
+ if (ar || !(i in from)) {
33
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
34
+ ar[i] = from[i];
35
+ }
36
+ }
37
+ return to.concat(ar || Array.prototype.slice.call(from));
38
+ };
39
+ define("back", ["require", "exports"], function (require, exports) {
40
+ "use strict";
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ function arr_back(arr) {
43
+ return arr[arr.length - 1];
44
+ }
45
+ exports.default = arr_back;
46
+ });
47
+ define("nodes/type", ["require", "exports"], function (require, exports) {
48
+ "use strict";
49
+ Object.defineProperty(exports, "__esModule", { value: true });
50
+ var NodeType;
51
+ (function (NodeType) {
52
+ NodeType[NodeType["ELEMENT_NODE"] = 1] = "ELEMENT_NODE";
53
+ NodeType[NodeType["TEXT_NODE"] = 3] = "TEXT_NODE";
54
+ NodeType[NodeType["COMMENT_NODE"] = 8] = "COMMENT_NODE";
55
+ })(NodeType || (NodeType = {}));
56
+ exports.default = NodeType;
57
+ });
58
+ define("nodes/node", ["require", "exports", "he"], function (require, exports, he_1) {
59
+ "use strict";
60
+ Object.defineProperty(exports, "__esModule", { value: true });
61
+ /**
62
+ * Node Class as base class for TextNode and HTMLElement.
63
+ */
64
+ var Node = /** @class */ (function () {
65
+ function Node(parentNode, range) {
66
+ if (parentNode === void 0) { parentNode = null; }
67
+ this.parentNode = parentNode;
68
+ this.childNodes = [];
69
+ Object.defineProperty(this, 'range', {
70
+ enumerable: false,
71
+ writable: true,
72
+ configurable: true,
73
+ value: range !== null && range !== void 0 ? range : [-1, -1]
74
+ });
75
+ }
76
+ /**
77
+ * Remove current node
78
+ */
79
+ Node.prototype.remove = function () {
80
+ var _this = this;
81
+ if (this.parentNode) {
82
+ var children = this.parentNode.childNodes;
83
+ this.parentNode.childNodes = children.filter(function (child) {
84
+ return _this !== child;
85
+ });
86
+ this.parentNode = null;
87
+ }
88
+ return this;
89
+ };
90
+ Object.defineProperty(Node.prototype, "innerText", {
91
+ get: function () {
92
+ return this.rawText;
93
+ },
94
+ enumerable: false,
95
+ configurable: true
96
+ });
97
+ Object.defineProperty(Node.prototype, "textContent", {
98
+ get: function () {
99
+ return (0, he_1.decode)(this.rawText);
100
+ },
101
+ set: function (val) {
102
+ this.rawText = (0, he_1.encode)(val);
103
+ },
104
+ enumerable: false,
105
+ configurable: true
106
+ });
107
+ return Node;
108
+ }());
109
+ exports.default = Node;
110
+ });
111
+ define("matcher", ["require", "exports", "nodes/type"], function (require, exports, type_1) {
112
+ "use strict";
113
+ Object.defineProperty(exports, "__esModule", { value: true });
114
+ type_1 = __importDefault(type_1);
115
+ function isTag(node) {
116
+ return node && node.nodeType === type_1.default.ELEMENT_NODE;
117
+ }
118
+ function getAttributeValue(elem, name) {
119
+ return isTag(elem) ? elem.getAttribute(name) : undefined;
120
+ }
121
+ function getName(elem) {
122
+ return ((elem && elem.rawTagName) || '').toLowerCase();
123
+ }
124
+ function getChildren(node) {
125
+ return node && node.childNodes;
126
+ }
127
+ function getParent(node) {
128
+ return node ? node.parentNode : null;
129
+ }
130
+ function getText(node) {
131
+ return node.text;
132
+ }
133
+ function removeSubsets(nodes) {
134
+ var idx = nodes.length;
135
+ var node;
136
+ var ancestor;
137
+ var replace;
138
+ // Check if each node (or one of its ancestors) is already contained in the
139
+ // array.
140
+ while (--idx > -1) {
141
+ node = ancestor = nodes[idx];
142
+ // Temporarily remove the node under consideration
143
+ nodes[idx] = null;
144
+ replace = true;
145
+ while (ancestor) {
146
+ if (nodes.indexOf(ancestor) > -1) {
147
+ replace = false;
148
+ nodes.splice(idx, 1);
149
+ break;
150
+ }
151
+ ancestor = getParent(ancestor);
152
+ }
153
+ // If the node has been found to be unique, re-insert it.
154
+ if (replace) {
155
+ nodes[idx] = node;
156
+ }
157
+ }
158
+ return nodes;
159
+ }
160
+ function existsOne(test, elems) {
161
+ return elems.some(function (elem) {
162
+ return isTag(elem) ? test(elem) || existsOne(test, getChildren(elem)) : false;
163
+ });
164
+ }
165
+ function getSiblings(node) {
166
+ var parent = getParent(node);
167
+ return parent ? getChildren(parent) : [];
168
+ }
169
+ function hasAttrib(elem, name) {
170
+ return getAttributeValue(elem, name) !== undefined;
171
+ }
172
+ function findOne(test, elems) {
173
+ var elem = null;
174
+ for (var i = 0, l = elems === null || elems === void 0 ? void 0 : elems.length; i < l && !elem; i++) {
175
+ var el = elems[i];
176
+ if (test(el)) {
177
+ elem = el;
178
+ }
179
+ else {
180
+ var childs = getChildren(el);
181
+ if (childs && childs.length > 0) {
182
+ elem = findOne(test, childs);
183
+ }
184
+ }
185
+ }
186
+ return elem;
187
+ }
188
+ function findAll(test, nodes) {
189
+ var result = [];
190
+ for (var i = 0, j = nodes.length; i < j; i++) {
191
+ if (!isTag(nodes[i]))
192
+ continue;
193
+ if (test(nodes[i]))
194
+ result.push(nodes[i]);
195
+ var childs = getChildren(nodes[i]);
196
+ if (childs)
197
+ result = result.concat(findAll(test, childs));
198
+ }
199
+ return result;
200
+ }
201
+ exports.default = {
202
+ isTag: isTag,
203
+ getAttributeValue: getAttributeValue,
204
+ getName: getName,
205
+ getChildren: getChildren,
206
+ getParent: getParent,
207
+ getText: getText,
208
+ removeSubsets: removeSubsets,
209
+ existsOne: existsOne,
210
+ getSiblings: getSiblings,
211
+ hasAttrib: hasAttrib,
212
+ findOne: findOne,
213
+ findAll: findAll
214
+ };
215
+ });
216
+ define("void-tag", ["require", "exports"], function (require, exports) {
217
+ "use strict";
218
+ Object.defineProperty(exports, "__esModule", { value: true });
219
+ var VoidTag = /** @class */ (function () {
220
+ function VoidTag(addClosingSlash, tags) {
221
+ if (addClosingSlash === void 0) { addClosingSlash = false; }
222
+ this.addClosingSlash = addClosingSlash;
223
+ if (Array.isArray(tags)) {
224
+ this.voidTags = tags.reduce(function (set, tag) {
225
+ return set.add(tag.toLowerCase()).add(tag.toUpperCase()).add(tag);
226
+ }, new Set());
227
+ }
228
+ else {
229
+ this.voidTags = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'].reduce(function (set, tag) {
230
+ return set.add(tag.toLowerCase()).add(tag.toUpperCase()).add(tag);
231
+ }, new Set());
232
+ }
233
+ }
234
+ VoidTag.prototype.formatNode = function (tag, attrs, innerHTML) {
235
+ var addClosingSlash = this.addClosingSlash;
236
+ var closingSpace = (addClosingSlash && attrs && !attrs.endsWith(' ')) ? ' ' : '';
237
+ var closingSlash = addClosingSlash ? "".concat(closingSpace, "/") : '';
238
+ return this.isVoidElement(tag.toLowerCase()) ? "<".concat(tag).concat(attrs).concat(closingSlash, ">") : "<".concat(tag).concat(attrs, ">").concat(innerHTML, "</").concat(tag, ">");
239
+ };
240
+ VoidTag.prototype.isVoidElement = function (tag) {
241
+ return this.voidTags.has(tag);
242
+ };
243
+ return VoidTag;
244
+ }());
245
+ exports.default = VoidTag;
246
+ });
247
+ define("nodes/text", ["require", "exports", "he", "nodes/node", "nodes/type"], function (require, exports, he_2, node_1, type_2) {
248
+ "use strict";
249
+ Object.defineProperty(exports, "__esModule", { value: true });
250
+ node_1 = __importDefault(node_1);
251
+ type_2 = __importDefault(type_2);
252
+ /**
253
+ * TextNode to contain a text element in DOM tree.
254
+ * @param {string} value [description]
255
+ */
256
+ var TextNode = /** @class */ (function (_super) {
257
+ __extends(TextNode, _super);
258
+ function TextNode(rawText, parentNode, range) {
259
+ if (parentNode === void 0) { parentNode = null; }
260
+ var _this = _super.call(this, parentNode, range) || this;
261
+ /**
262
+ * Node Type declaration.
263
+ * @type {Number}
264
+ */
265
+ _this.nodeType = type_2.default.TEXT_NODE;
266
+ _this.rawTagName = '';
267
+ _this._rawText = rawText;
268
+ return _this;
269
+ }
270
+ TextNode.prototype.clone = function () {
271
+ return new TextNode(this._rawText, null);
272
+ };
273
+ Object.defineProperty(TextNode.prototype, "rawText", {
274
+ get: function () {
275
+ return this._rawText;
276
+ },
277
+ /**
278
+ * Set rawText and invalidate trimmed caches
279
+ */
280
+ set: function (text) {
281
+ this._rawText = text;
282
+ this._trimmedRawText = void 0;
283
+ this._trimmedText = void 0;
284
+ },
285
+ enumerable: false,
286
+ configurable: true
287
+ });
288
+ Object.defineProperty(TextNode.prototype, "trimmedRawText", {
289
+ /**
290
+ * Returns raw text with all whitespace trimmed except single leading/trailing non-breaking space
291
+ */
292
+ get: function () {
293
+ if (this._trimmedRawText !== undefined)
294
+ return this._trimmedRawText;
295
+ this._trimmedRawText = trimText(this.rawText);
296
+ return this._trimmedRawText;
297
+ },
298
+ enumerable: false,
299
+ configurable: true
300
+ });
301
+ Object.defineProperty(TextNode.prototype, "trimmedText", {
302
+ /**
303
+ * Returns text with all whitespace trimmed except single leading/trailing non-breaking space
304
+ */
305
+ get: function () {
306
+ if (this._trimmedText !== undefined)
307
+ return this._trimmedText;
308
+ this._trimmedText = trimText(this.text);
309
+ return this._trimmedText;
310
+ },
311
+ enumerable: false,
312
+ configurable: true
313
+ });
314
+ Object.defineProperty(TextNode.prototype, "text", {
315
+ /**
316
+ * Get unescaped text value of current node and its children.
317
+ * @return {string} text content
318
+ */
319
+ get: function () {
320
+ return (0, he_2.decode)(this.rawText);
321
+ },
322
+ enumerable: false,
323
+ configurable: true
324
+ });
325
+ Object.defineProperty(TextNode.prototype, "isWhitespace", {
326
+ /**
327
+ * Detect if the node contains only white space.
328
+ * @return {boolean}
329
+ */
330
+ get: function () {
331
+ return /^(\s|&nbsp;)*$/.test(this.rawText);
332
+ },
333
+ enumerable: false,
334
+ configurable: true
335
+ });
336
+ TextNode.prototype.toString = function () {
337
+ return this.rawText;
338
+ };
339
+ return TextNode;
340
+ }(node_1.default));
341
+ exports.default = TextNode;
342
+ /**
343
+ * Trim whitespace except single leading/trailing non-breaking space
344
+ */
345
+ function trimText(text) {
346
+ var i = 0;
347
+ var startPos;
348
+ var endPos;
349
+ while (i >= 0 && i < text.length) {
350
+ if (/\S/.test(text[i])) {
351
+ if (startPos === undefined) {
352
+ startPos = i;
353
+ i = text.length;
354
+ }
355
+ else {
356
+ endPos = i;
357
+ i = void 0;
358
+ }
359
+ }
360
+ if (startPos === undefined)
361
+ i++;
362
+ else
363
+ i--;
364
+ }
365
+ if (startPos === undefined)
366
+ startPos = 0;
367
+ if (endPos === undefined)
368
+ endPos = text.length - 1;
369
+ var hasLeadingSpace = startPos > 0 && /[^\S\r\n]/.test(text[startPos - 1]);
370
+ var hasTrailingSpace = endPos < (text.length - 1) && /[^\S\r\n]/.test(text[endPos + 1]);
371
+ return (hasLeadingSpace ? ' ' : '') + text.slice(startPos, endPos + 1) + (hasTrailingSpace ? ' ' : '');
372
+ }
373
+ });
374
+ define("nodes/html", ["require", "exports", "css-select", "he", "back", "matcher", "void-tag", "nodes/comment", "nodes/node", "nodes/text", "nodes/type"], function (require, exports, css_select_1, he_3, back_1, matcher_1, void_tag_1, comment_1, node_2, text_1, type_3) {
375
+ "use strict";
376
+ Object.defineProperty(exports, "__esModule", { value: true });
377
+ exports.parse = exports.base_parse = void 0;
378
+ he_3 = __importDefault(he_3);
379
+ back_1 = __importDefault(back_1);
380
+ matcher_1 = __importDefault(matcher_1);
381
+ void_tag_1 = __importDefault(void_tag_1);
382
+ comment_1 = __importDefault(comment_1);
383
+ node_2 = __importDefault(node_2);
384
+ text_1 = __importDefault(text_1);
385
+ type_3 = __importDefault(type_3);
386
+ function decode(val) {
387
+ // clone string
388
+ return JSON.parse(JSON.stringify(he_3.default.decode(val)));
389
+ }
390
+ // https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
391
+ var Htags = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hgroup'];
392
+ var Dtags = ['details', 'dialog', 'dd', 'div', 'dt'];
393
+ var Ftags = ['fieldset', 'figcaption', 'figure', 'footer', 'form'];
394
+ var tableTags = ['table', 'td', 'tr'];
395
+ var htmlTags = ['address', 'article', 'aside', 'blockquote', 'br', 'hr', 'li', 'main', 'nav', 'ol', 'p', 'pre', 'section', 'ul'];
396
+ var kBlockElements = new Set();
397
+ function addToKBlockElement() {
398
+ var args = [];
399
+ for (var _i = 0; _i < arguments.length; _i++) {
400
+ args[_i] = arguments[_i];
401
+ }
402
+ var addToSet = function (array) {
403
+ for (var index = 0; index < array.length; index++) {
404
+ var element = array[index];
405
+ kBlockElements.add(element);
406
+ kBlockElements.add(element.toUpperCase());
407
+ }
408
+ };
409
+ for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
410
+ var arg = args_1[_a];
411
+ addToSet(arg);
412
+ }
413
+ }
414
+ addToKBlockElement(Htags, Dtags, Ftags, tableTags, htmlTags);
415
+ var DOMTokenList = /** @class */ (function () {
416
+ function DOMTokenList(valuesInit, afterUpdate) {
417
+ if (valuesInit === void 0) { valuesInit = []; }
418
+ if (afterUpdate === void 0) { afterUpdate = function () { return null; }; }
419
+ this._set = new Set(valuesInit);
420
+ this._afterUpdate = afterUpdate;
421
+ }
422
+ DOMTokenList.prototype._validate = function (c) {
423
+ if (/\s/.test(c)) {
424
+ throw new Error("DOMException in DOMTokenList.add: The token '".concat(c, "' contains HTML space characters, which are not valid in tokens."));
425
+ }
426
+ };
427
+ DOMTokenList.prototype.add = function (c) {
428
+ this._validate(c);
429
+ this._set.add(c);
430
+ this._afterUpdate(this); // eslint-disable-line @typescript-eslint/no-unsafe-call
431
+ };
432
+ DOMTokenList.prototype.replace = function (c1, c2) {
433
+ this._validate(c2);
434
+ this._set.delete(c1);
435
+ this._set.add(c2);
436
+ this._afterUpdate(this); // eslint-disable-line @typescript-eslint/no-unsafe-call
437
+ };
438
+ DOMTokenList.prototype.remove = function (c) {
439
+ this._set.delete(c) && this._afterUpdate(this); // eslint-disable-line @typescript-eslint/no-unsafe-call
440
+ };
441
+ DOMTokenList.prototype.toggle = function (c) {
442
+ this._validate(c);
443
+ if (this._set.has(c))
444
+ this._set.delete(c);
445
+ else
446
+ this._set.add(c);
447
+ this._afterUpdate(this); // eslint-disable-line @typescript-eslint/no-unsafe-call
448
+ };
449
+ DOMTokenList.prototype.contains = function (c) {
450
+ return this._set.has(c);
451
+ };
452
+ Object.defineProperty(DOMTokenList.prototype, "length", {
453
+ get: function () {
454
+ return this._set.size;
455
+ },
456
+ enumerable: false,
457
+ configurable: true
458
+ });
459
+ DOMTokenList.prototype.values = function () {
460
+ return this._set.values();
461
+ };
462
+ Object.defineProperty(DOMTokenList.prototype, "value", {
463
+ get: function () {
464
+ return Array.from(this._set.values());
465
+ },
466
+ enumerable: false,
467
+ configurable: true
468
+ });
469
+ DOMTokenList.prototype.toString = function () {
470
+ return Array.from(this._set.values()).join(' ');
471
+ };
472
+ return DOMTokenList;
473
+ }());
474
+ /**
475
+ * HTMLElement, which contains a set of children.
476
+ *
477
+ * Note: this is a minimalist implementation, no complete tree
478
+ * structure provided (no parentNode, nextSibling,
479
+ * previousSibling etc).
480
+ * @class HTMLElement
481
+ * @extends {Node}
482
+ */
483
+ var HTMLElement = /** @class */ (function (_super) {
484
+ __extends(HTMLElement, _super);
485
+ /**
486
+ * Creates an instance of HTMLElement.
487
+ * @param keyAttrs id and class attribute
488
+ * @param [rawAttrs] attributes in string
489
+ *
490
+ * @memberof HTMLElement
491
+ */
492
+ function HTMLElement(tagName, keyAttrs, rawAttrs, parentNode, range, voidTag, _parseOptions) {
493
+ if (rawAttrs === void 0) { rawAttrs = ''; }
494
+ if (parentNode === void 0) { parentNode = null; }
495
+ if (voidTag === void 0) { voidTag = new void_tag_1.default(); }
496
+ if (_parseOptions === void 0) { _parseOptions = {}; }
497
+ var _this = _super.call(this, parentNode, range) || this;
498
+ _this.rawAttrs = rawAttrs;
499
+ _this.voidTag = voidTag;
500
+ /**
501
+ * Node Type declaration.
502
+ */
503
+ _this.nodeType = type_3.default.ELEMENT_NODE;
504
+ _this.rawTagName = tagName;
505
+ _this.rawAttrs = rawAttrs || '';
506
+ _this.id = keyAttrs.id || '';
507
+ _this.childNodes = [];
508
+ _this._parseOptions = _parseOptions;
509
+ _this.classList = new DOMTokenList(keyAttrs.class ? keyAttrs.class.split(/\s+/) : [], function (classList) { return _this.setAttribute('class', classList.toString()); } // eslint-disable-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
510
+ );
511
+ if (keyAttrs.id) {
512
+ if (!rawAttrs) {
513
+ _this.rawAttrs = "id=\"".concat(keyAttrs.id, "\"");
514
+ }
515
+ }
516
+ if (keyAttrs.class) {
517
+ if (!rawAttrs) {
518
+ var cls = "class=\"".concat(_this.classList.toString(), "\"");
519
+ if (_this.rawAttrs) {
520
+ _this.rawAttrs += " ".concat(cls);
521
+ }
522
+ else {
523
+ _this.rawAttrs = cls;
524
+ }
525
+ }
526
+ }
527
+ return _this;
528
+ }
529
+ /**
530
+ * Quote attribute values
531
+ * @param attr attribute value
532
+ * @returns {string} quoted value
533
+ */
534
+ HTMLElement.prototype.quoteAttribute = function (attr) {
535
+ if (attr == null) {
536
+ return 'null';
537
+ }
538
+ return JSON.stringify(attr.replace(/"/g, '&quot;')).replace(/\\t/g, '\t').replace(/\\n/g, '\n').replace(/\\r/g, '\r').replace(/\\/g, '');
539
+ };
540
+ /**
541
+ * Remove Child element from childNodes array
542
+ * @param {HTMLElement} node node to remove
543
+ */
544
+ HTMLElement.prototype.removeChild = function (node) {
545
+ this.childNodes = this.childNodes.filter(function (child) {
546
+ return child !== node;
547
+ });
548
+ return this;
549
+ };
550
+ /**
551
+ * Exchanges given child with new child
552
+ * @param {HTMLElement} oldNode node to exchange
553
+ * @param {HTMLElement} newNode new node
554
+ */
555
+ HTMLElement.prototype.exchangeChild = function (oldNode, newNode) {
556
+ var children = this.childNodes;
557
+ this.childNodes = children.map(function (child) {
558
+ if (child === oldNode) {
559
+ return newNode;
560
+ }
561
+ return child;
562
+ });
563
+ return this;
564
+ };
565
+ Object.defineProperty(HTMLElement.prototype, "tagName", {
566
+ get: function () {
567
+ return this.rawTagName ? this.rawTagName.toUpperCase() : this.rawTagName;
568
+ },
569
+ set: function (newname) {
570
+ this.rawTagName = newname.toLowerCase();
571
+ },
572
+ enumerable: false,
573
+ configurable: true
574
+ });
575
+ Object.defineProperty(HTMLElement.prototype, "localName", {
576
+ get: function () {
577
+ return this.rawTagName.toLowerCase();
578
+ },
579
+ enumerable: false,
580
+ configurable: true
581
+ });
582
+ Object.defineProperty(HTMLElement.prototype, "isVoidElement", {
583
+ get: function () {
584
+ return this.voidTag.isVoidElement(this.localName);
585
+ },
586
+ enumerable: false,
587
+ configurable: true
588
+ });
589
+ Object.defineProperty(HTMLElement.prototype, "rawText", {
590
+ /**
591
+ * Get escpaed (as-it) text value of current node and its children.
592
+ * @return {string} text content
593
+ */
594
+ get: function () {
595
+ // https://github.com/taoqf/node-html-parser/issues/249
596
+ if (/^br$/i.test(this.rawTagName)) {
597
+ return '\n';
598
+ }
599
+ return this.childNodes.reduce(function (pre, cur) {
600
+ return (pre += cur.rawText);
601
+ }, '');
602
+ },
603
+ enumerable: false,
604
+ configurable: true
605
+ });
606
+ Object.defineProperty(HTMLElement.prototype, "textContent", {
607
+ get: function () {
608
+ return decode(this.rawText);
609
+ },
610
+ set: function (val) {
611
+ var content = [new text_1.default(val, this)];
612
+ this.childNodes = content;
613
+ },
614
+ enumerable: false,
615
+ configurable: true
616
+ });
617
+ Object.defineProperty(HTMLElement.prototype, "text", {
618
+ /**
619
+ * Get unescaped text value of current node and its children.
620
+ * @return {string} text content
621
+ */
622
+ get: function () {
623
+ return decode(this.rawText);
624
+ },
625
+ enumerable: false,
626
+ configurable: true
627
+ });
628
+ Object.defineProperty(HTMLElement.prototype, "structuredText", {
629
+ /**
630
+ * Get structured Text (with '\n' etc.)
631
+ * @return {string} structured text
632
+ */
633
+ get: function () {
634
+ var currentBlock = [];
635
+ var blocks = [currentBlock];
636
+ function dfs(node) {
637
+ if (node.nodeType === type_3.default.ELEMENT_NODE) {
638
+ if (kBlockElements.has(node.rawTagName)) {
639
+ if (currentBlock.length > 0) {
640
+ blocks.push((currentBlock = []));
641
+ }
642
+ node.childNodes.forEach(dfs);
643
+ if (currentBlock.length > 0) {
644
+ blocks.push((currentBlock = []));
645
+ }
646
+ }
647
+ else {
648
+ node.childNodes.forEach(dfs);
649
+ }
650
+ }
651
+ else if (node.nodeType === type_3.default.TEXT_NODE) {
652
+ if (node.isWhitespace) {
653
+ // Whitespace node, postponed output
654
+ currentBlock.prependWhitespace = true;
655
+ }
656
+ else {
657
+ var text = node.trimmedText;
658
+ if (currentBlock.prependWhitespace) {
659
+ text = " ".concat(text);
660
+ currentBlock.prependWhitespace = false;
661
+ }
662
+ currentBlock.push(text);
663
+ }
664
+ }
665
+ }
666
+ dfs(this);
667
+ return blocks
668
+ .map(function (block) {
669
+ return block.join('').replace(/\s{2,}/g, ' '); // Normalize each line's whitespace
670
+ })
671
+ .join('\n')
672
+ .replace(/\s+$/, ''); // trimRight;
673
+ },
674
+ enumerable: false,
675
+ configurable: true
676
+ });
677
+ HTMLElement.prototype.toString = function () {
678
+ var tag = this.rawTagName;
679
+ if (tag) {
680
+ var attrs = this.rawAttrs ? " ".concat(this.rawAttrs) : '';
681
+ return this.voidTag.formatNode(tag, attrs, this.innerHTML);
682
+ }
683
+ return this.innerHTML;
684
+ };
685
+ Object.defineProperty(HTMLElement.prototype, "innerHTML", {
686
+ get: function () {
687
+ return this.childNodes
688
+ .map(function (child) {
689
+ return child.toString();
690
+ })
691
+ .join('');
692
+ },
693
+ set: function (content) {
694
+ var r = parse(content, this._parseOptions);
695
+ var nodes = r.childNodes.length ? r.childNodes : [new text_1.default(content, this)];
696
+ resetParent(nodes, this);
697
+ resetParent(this.childNodes, null);
698
+ this.childNodes = nodes;
699
+ },
700
+ enumerable: false,
701
+ configurable: true
702
+ });
703
+ HTMLElement.prototype.set_content = function (content, options) {
704
+ if (options === void 0) { options = {}; }
705
+ if (content instanceof node_2.default) {
706
+ content = [content];
707
+ }
708
+ else if (typeof content == 'string') {
709
+ options = __assign(__assign({}, this._parseOptions), options);
710
+ var r = parse(content, options);
711
+ content = r.childNodes.length ? r.childNodes : [new text_1.default(r.innerHTML, this)];
712
+ }
713
+ resetParent(this.childNodes, null);
714
+ resetParent(content, this);
715
+ this.childNodes = content;
716
+ return this;
717
+ };
718
+ HTMLElement.prototype.replaceWith = function () {
719
+ var _this = this;
720
+ var nodes = [];
721
+ for (var _i = 0; _i < arguments.length; _i++) {
722
+ nodes[_i] = arguments[_i];
723
+ }
724
+ var parent = this.parentNode;
725
+ var content = nodes
726
+ .map(function (node) {
727
+ if (node instanceof node_2.default) {
728
+ return [node];
729
+ }
730
+ else if (typeof node == 'string') {
731
+ var r = parse(node, _this._parseOptions);
732
+ return r.childNodes.length ? r.childNodes : [new text_1.default(node, _this)];
733
+ }
734
+ return [];
735
+ })
736
+ .flat();
737
+ var idx = parent.childNodes.findIndex(function (child) {
738
+ return child === _this;
739
+ });
740
+ resetParent([this], null);
741
+ parent.childNodes = __spreadArray(__spreadArray(__spreadArray([], parent.childNodes.slice(0, idx), true), resetParent(content, parent), true), parent.childNodes.slice(idx + 1), true);
742
+ return this;
743
+ };
744
+ Object.defineProperty(HTMLElement.prototype, "outerHTML", {
745
+ get: function () {
746
+ return this.toString();
747
+ },
748
+ enumerable: false,
749
+ configurable: true
750
+ });
751
+ /**
752
+ * Trim element from right (in block) after seeing pattern in a TextNode.
753
+ * @param {RegExp} pattern pattern to find
754
+ * @return {HTMLElement} reference to current node
755
+ */
756
+ HTMLElement.prototype.trimRight = function (pattern) {
757
+ for (var i = 0; i < this.childNodes.length; i++) {
758
+ var childNode = this.childNodes[i];
759
+ if (childNode.nodeType === type_3.default.ELEMENT_NODE) {
760
+ childNode.trimRight(pattern);
761
+ }
762
+ else {
763
+ var index = childNode.rawText.search(pattern);
764
+ if (index > -1) {
765
+ childNode.rawText = childNode.rawText.substr(0, index);
766
+ // trim all following nodes.
767
+ this.childNodes.length = i + 1;
768
+ }
769
+ }
770
+ }
771
+ return this;
772
+ };
773
+ Object.defineProperty(HTMLElement.prototype, "structure", {
774
+ /**
775
+ * Get DOM structure
776
+ * @return {string} structure
777
+ */
778
+ get: function () {
779
+ var res = [];
780
+ var indention = 0;
781
+ function write(str) {
782
+ res.push(' '.repeat(indention) + str);
783
+ }
784
+ function dfs(node) {
785
+ var idStr = node.id ? "#".concat(node.id) : '';
786
+ var classStr = node.classList.length ? ".".concat(node.classList.value.join('.')) : ''; // eslint-disable-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unsafe-call
787
+ write("".concat(node.rawTagName).concat(idStr).concat(classStr));
788
+ indention++;
789
+ node.childNodes.forEach(function (childNode) {
790
+ if (childNode.nodeType === type_3.default.ELEMENT_NODE) {
791
+ dfs(childNode);
792
+ }
793
+ else if (childNode.nodeType === type_3.default.TEXT_NODE) {
794
+ if (!childNode.isWhitespace) {
795
+ write('#text');
796
+ }
797
+ }
798
+ });
799
+ indention--;
800
+ }
801
+ dfs(this);
802
+ return res.join('\n');
803
+ },
804
+ enumerable: false,
805
+ configurable: true
806
+ });
807
+ /**
808
+ * Remove whitespaces in this sub tree.
809
+ * @return {HTMLElement} pointer to this
810
+ */
811
+ HTMLElement.prototype.removeWhitespace = function () {
812
+ var _this = this;
813
+ var o = 0;
814
+ this.childNodes.forEach(function (node) {
815
+ if (node.nodeType === type_3.default.TEXT_NODE) {
816
+ if (node.isWhitespace) {
817
+ return;
818
+ }
819
+ node.rawText = node.trimmedRawText;
820
+ }
821
+ else if (node.nodeType === type_3.default.ELEMENT_NODE) {
822
+ node.removeWhitespace();
823
+ }
824
+ _this.childNodes[o++] = node;
825
+ });
826
+ this.childNodes.length = o;
827
+ return this;
828
+ };
829
+ /**
830
+ * Query CSS selector to find matching nodes.
831
+ * @param {string} selector Simplified CSS selector
832
+ * @return {HTMLElement[]} matching elements
833
+ */
834
+ HTMLElement.prototype.querySelectorAll = function (selector) {
835
+ return (0, css_select_1.selectAll)(selector, this, {
836
+ xmlMode: true,
837
+ adapter: matcher_1.default,
838
+ });
839
+ };
840
+ /**
841
+ * Query CSS Selector to find matching node.
842
+ * @param {string} selector Simplified CSS selector
843
+ * @return {(HTMLElement|null)} matching node
844
+ */
845
+ HTMLElement.prototype.querySelector = function (selector) {
846
+ return (0, css_select_1.selectOne)(selector, this, {
847
+ xmlMode: true,
848
+ adapter: matcher_1.default,
849
+ });
850
+ };
851
+ /**
852
+ * find elements by their tagName
853
+ * @param {string} tagName the tagName of the elements to select
854
+ */
855
+ HTMLElement.prototype.getElementsByTagName = function (tagName) {
856
+ var upperCasedTagName = tagName.toUpperCase();
857
+ var re = [];
858
+ var stack = [];
859
+ var currentNodeReference = this;
860
+ var index = 0;
861
+ // index turns to undefined once the stack is empty and the first condition occurs
862
+ // which happens once all relevant children are searched through
863
+ while (index !== undefined) {
864
+ var child = void 0;
865
+ // make it work with sparse arrays
866
+ do {
867
+ child = currentNodeReference.childNodes[index++];
868
+ } while (index < currentNodeReference.childNodes.length && child === undefined);
869
+ // if the child does not exist we move on with the last provided index (which belongs to the parentNode)
870
+ if (child === undefined) {
871
+ currentNodeReference = currentNodeReference.parentNode;
872
+ index = stack.pop();
873
+ continue;
874
+ }
875
+ if (child.nodeType === type_3.default.ELEMENT_NODE) {
876
+ // https://developer.mozilla.org/en-US/docs/Web/API/Element/getElementsByTagName#syntax
877
+ if (tagName === '*' || child.tagName === upperCasedTagName)
878
+ re.push(child);
879
+ // if children are existing push the current status to the stack and keep searching for elements in the level below
880
+ if (child.childNodes.length > 0) {
881
+ stack.push(index);
882
+ currentNodeReference = child;
883
+ index = 0;
884
+ }
885
+ }
886
+ }
887
+ return re;
888
+ };
889
+ /**
890
+ * find element by it's id
891
+ * @param {string} id the id of the element to select
892
+ * @returns {HTMLElement | null} the element with the given id or null if not found
893
+ */
894
+ HTMLElement.prototype.getElementById = function (id) {
895
+ var stack = [];
896
+ var currentNodeReference = this;
897
+ var index = 0;
898
+ // index turns to undefined once the stack is empty and the first condition occurs
899
+ // which happens once all relevant children are searched through
900
+ while (index !== undefined) {
901
+ var child = void 0;
902
+ // make it work with sparse arrays
903
+ do {
904
+ child = currentNodeReference.childNodes[index++];
905
+ } while (index < currentNodeReference.childNodes.length && child === undefined);
906
+ // if the child does not exist we move on with the last provided index (which belongs to the parentNode)
907
+ if (child === undefined) {
908
+ currentNodeReference = currentNodeReference.parentNode;
909
+ index = stack.pop();
910
+ continue;
911
+ }
912
+ if (child.nodeType === type_3.default.ELEMENT_NODE) {
913
+ if (child.id === id) {
914
+ return child;
915
+ }
916
+ ;
917
+ // if children are existing push the current status to the stack and keep searching for elements in the level below
918
+ if (child.childNodes.length > 0) {
919
+ stack.push(index);
920
+ currentNodeReference = child;
921
+ index = 0;
922
+ }
923
+ }
924
+ }
925
+ return null;
926
+ };
927
+ /**
928
+ * traverses the Element and its parents (heading toward the document root) until it finds a node that matches the provided selector string. Will return itself or the matching ancestor. If no such element exists, it returns null.
929
+ * @param selector a DOMString containing a selector list
930
+ * @returns {HTMLElement | null} the element with the given id or null if not found
931
+ */
932
+ HTMLElement.prototype.closest = function (selector) {
933
+ var mapChild = new Map();
934
+ var el = this;
935
+ var old = null;
936
+ function findOne(test, elems) {
937
+ var elem = null;
938
+ for (var i = 0, l = elems.length; i < l && !elem; i++) {
939
+ var el_1 = elems[i];
940
+ if (test(el_1)) {
941
+ elem = el_1;
942
+ }
943
+ else {
944
+ var child = mapChild.get(el_1);
945
+ if (child) {
946
+ elem = findOne(test, [child]);
947
+ }
948
+ }
949
+ }
950
+ return elem;
951
+ }
952
+ while (el) {
953
+ mapChild.set(el, old);
954
+ old = el;
955
+ el = el.parentNode;
956
+ }
957
+ el = this;
958
+ while (el) {
959
+ var e = (0, css_select_1.selectOne)(selector, el, {
960
+ xmlMode: true,
961
+ adapter: __assign(__assign({}, matcher_1.default), { getChildren: function (node) {
962
+ var child = mapChild.get(node);
963
+ return child && [child];
964
+ }, getSiblings: function (node) {
965
+ return [node];
966
+ }, findOne: findOne, findAll: function () {
967
+ return [];
968
+ } }),
969
+ });
970
+ if (e) {
971
+ return e;
972
+ }
973
+ el = el.parentNode;
974
+ }
975
+ return null;
976
+ };
977
+ /**
978
+ * Append a child node to childNodes
979
+ * @param {Node} node node to append
980
+ * @return {Node} node appended
981
+ */
982
+ HTMLElement.prototype.appendChild = function (node) {
983
+ // remove the node from it's parent
984
+ node.remove();
985
+ this.childNodes.push(node);
986
+ node.parentNode = this;
987
+ return node;
988
+ };
989
+ Object.defineProperty(HTMLElement.prototype, "firstChild", {
990
+ /**
991
+ * Get first child node
992
+ * @return {Node | undefined} first child node; or undefined if none
993
+ */
994
+ get: function () {
995
+ return this.childNodes[0];
996
+ },
997
+ enumerable: false,
998
+ configurable: true
999
+ });
1000
+ Object.defineProperty(HTMLElement.prototype, "lastChild", {
1001
+ /**
1002
+ * Get last child node
1003
+ * @return {Node | undefined} last child node; or undefined if none
1004
+ */
1005
+ get: function () {
1006
+ return (0, back_1.default)(this.childNodes);
1007
+ },
1008
+ enumerable: false,
1009
+ configurable: true
1010
+ });
1011
+ Object.defineProperty(HTMLElement.prototype, "attrs", {
1012
+ /**
1013
+ * Get attributes
1014
+ * @access private
1015
+ * @return {Object} parsed and unescaped attributes
1016
+ */
1017
+ get: function () {
1018
+ if (this._attrs) {
1019
+ return this._attrs;
1020
+ }
1021
+ this._attrs = {};
1022
+ var attrs = this.rawAttributes;
1023
+ for (var key in attrs) {
1024
+ var val = attrs[key] || '';
1025
+ this._attrs[key.toLowerCase()] = decode(val);
1026
+ }
1027
+ return this._attrs;
1028
+ },
1029
+ enumerable: false,
1030
+ configurable: true
1031
+ });
1032
+ Object.defineProperty(HTMLElement.prototype, "attributes", {
1033
+ get: function () {
1034
+ var ret_attrs = {};
1035
+ var attrs = this.rawAttributes;
1036
+ for (var key in attrs) {
1037
+ var val = attrs[key] || '';
1038
+ ret_attrs[key] = decode(val);
1039
+ }
1040
+ return ret_attrs;
1041
+ },
1042
+ enumerable: false,
1043
+ configurable: true
1044
+ });
1045
+ Object.defineProperty(HTMLElement.prototype, "rawAttributes", {
1046
+ /**
1047
+ * Get escaped (as-is) attributes
1048
+ * @return {Object} parsed attributes
1049
+ */
1050
+ get: function () {
1051
+ if (this._rawAttrs) {
1052
+ return this._rawAttrs;
1053
+ }
1054
+ var attrs = {};
1055
+ if (this.rawAttrs) {
1056
+ var re = /([a-zA-Z()[\]#@$.?:][a-zA-Z0-9-_:()[\]#]*)(?:\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+))?/g;
1057
+ var match = void 0;
1058
+ while ((match = re.exec(this.rawAttrs))) {
1059
+ var key = match[1];
1060
+ var val = match[2] || null;
1061
+ if (val && (val[0] === "'" || val[0] === "\""))
1062
+ val = val.slice(1, val.length - 1);
1063
+ attrs[key] = attrs[key] || val;
1064
+ }
1065
+ }
1066
+ this._rawAttrs = attrs;
1067
+ return attrs;
1068
+ },
1069
+ enumerable: false,
1070
+ configurable: true
1071
+ });
1072
+ HTMLElement.prototype.removeAttribute = function (key) {
1073
+ var _this = this;
1074
+ var attrs = this.rawAttributes;
1075
+ delete attrs[key];
1076
+ // Update this.attribute
1077
+ if (this._attrs) {
1078
+ delete this._attrs[key];
1079
+ }
1080
+ // Update rawString
1081
+ this.rawAttrs = Object.keys(attrs)
1082
+ .map(function (name) {
1083
+ var val = _this.quoteAttribute(attrs[name]);
1084
+ if (val === 'null' || val === '""')
1085
+ return name;
1086
+ return "".concat(name, "=").concat(val);
1087
+ })
1088
+ .join(' ');
1089
+ // Update this.id
1090
+ if (key === 'id') {
1091
+ this.id = '';
1092
+ }
1093
+ return this;
1094
+ };
1095
+ HTMLElement.prototype.hasAttribute = function (key) {
1096
+ return key.toLowerCase() in this.attrs;
1097
+ };
1098
+ /**
1099
+ * Get an attribute
1100
+ * @return {string | undefined} value of the attribute; or undefined if not exist
1101
+ */
1102
+ HTMLElement.prototype.getAttribute = function (key) {
1103
+ return this.attrs[key.toLowerCase()];
1104
+ };
1105
+ /**
1106
+ * Set an attribute value to the HTMLElement
1107
+ * @param {string} key The attribute name
1108
+ * @param {string} value The value to set, or null / undefined to remove an attribute
1109
+ */
1110
+ HTMLElement.prototype.setAttribute = function (key, value) {
1111
+ var _this = this;
1112
+ if (arguments.length < 2) {
1113
+ throw new Error("Failed to execute 'setAttribute' on 'Element'");
1114
+ }
1115
+ var k2 = key.toLowerCase();
1116
+ var attrs = this.rawAttributes;
1117
+ for (var k in attrs) {
1118
+ if (k.toLowerCase() === k2) {
1119
+ key = k;
1120
+ break;
1121
+ }
1122
+ }
1123
+ attrs[key] = String(value);
1124
+ // update this.attrs
1125
+ if (this._attrs) {
1126
+ this._attrs[k2] = decode(attrs[key]);
1127
+ }
1128
+ // Update rawString
1129
+ this.rawAttrs = Object.keys(attrs)
1130
+ .map(function (name) {
1131
+ var val = _this.quoteAttribute(attrs[name]);
1132
+ if (val === 'null' || val === '""')
1133
+ return name;
1134
+ return "".concat(name, "=").concat(val);
1135
+ })
1136
+ .join(' ');
1137
+ // Update this.id
1138
+ if (key === 'id') {
1139
+ this.id = value;
1140
+ }
1141
+ return this;
1142
+ };
1143
+ /**
1144
+ * Replace all the attributes of the HTMLElement by the provided attributes
1145
+ * @param {Attributes} attributes the new attribute set
1146
+ */
1147
+ HTMLElement.prototype.setAttributes = function (attributes) {
1148
+ var _this = this;
1149
+ // Invalidate current this.attributes
1150
+ if (this._attrs) {
1151
+ delete this._attrs;
1152
+ }
1153
+ // Invalidate current this.rawAttributes
1154
+ if (this._rawAttrs) {
1155
+ delete this._rawAttrs;
1156
+ }
1157
+ // Update rawString
1158
+ this.rawAttrs = Object.keys(attributes)
1159
+ .map(function (name) {
1160
+ var val = attributes[name];
1161
+ if (val === 'null' || val === '""')
1162
+ return name;
1163
+ return "".concat(name, "=").concat(_this.quoteAttribute(String(val)));
1164
+ })
1165
+ .join(' ');
1166
+ return this;
1167
+ };
1168
+ HTMLElement.prototype.insertAdjacentHTML = function (where, html) {
1169
+ var _a, _b, _c;
1170
+ var _this = this;
1171
+ if (arguments.length < 2) {
1172
+ throw new Error('2 arguments required');
1173
+ }
1174
+ var p = parse(html, this._parseOptions);
1175
+ if (where === 'afterend') {
1176
+ var idx = this.parentNode.childNodes.findIndex(function (child) {
1177
+ return child === _this;
1178
+ });
1179
+ resetParent(p.childNodes, this.parentNode);
1180
+ (_a = this.parentNode.childNodes).splice.apply(_a, __spreadArray([idx + 1, 0], p.childNodes, false));
1181
+ }
1182
+ else if (where === 'afterbegin') {
1183
+ resetParent(p.childNodes, this);
1184
+ (_b = this.childNodes).unshift.apply(_b, p.childNodes);
1185
+ }
1186
+ else if (where === 'beforeend') {
1187
+ p.childNodes.forEach(function (n) {
1188
+ _this.appendChild(n);
1189
+ });
1190
+ }
1191
+ else if (where === 'beforebegin') {
1192
+ var idx = this.parentNode.childNodes.findIndex(function (child) {
1193
+ return child === _this;
1194
+ });
1195
+ resetParent(p.childNodes, this.parentNode);
1196
+ (_c = this.parentNode.childNodes).splice.apply(_c, __spreadArray([idx, 0], p.childNodes, false));
1197
+ }
1198
+ else {
1199
+ throw new Error("The value provided ('".concat(where, "') is not one of 'beforebegin', 'afterbegin', 'beforeend', or 'afterend'"));
1200
+ }
1201
+ return this;
1202
+ // if (!where || html === undefined || html === null) {
1203
+ // return;
1204
+ // }
1205
+ };
1206
+ Object.defineProperty(HTMLElement.prototype, "nextSibling", {
1207
+ get: function () {
1208
+ if (this.parentNode) {
1209
+ var children = this.parentNode.childNodes;
1210
+ var i = 0;
1211
+ while (i < children.length) {
1212
+ var child = children[i++];
1213
+ if (this === child)
1214
+ return children[i] || null;
1215
+ }
1216
+ return null;
1217
+ }
1218
+ },
1219
+ enumerable: false,
1220
+ configurable: true
1221
+ });
1222
+ Object.defineProperty(HTMLElement.prototype, "nextElementSibling", {
1223
+ get: function () {
1224
+ if (this.parentNode) {
1225
+ var children = this.parentNode.childNodes;
1226
+ var i = 0;
1227
+ var find = false;
1228
+ while (i < children.length) {
1229
+ var child = children[i++];
1230
+ if (find) {
1231
+ if (child instanceof HTMLElement) {
1232
+ return child || null;
1233
+ }
1234
+ }
1235
+ else if (this === child) {
1236
+ find = true;
1237
+ }
1238
+ }
1239
+ return null;
1240
+ }
1241
+ },
1242
+ enumerable: false,
1243
+ configurable: true
1244
+ });
1245
+ Object.defineProperty(HTMLElement.prototype, "previousSibling", {
1246
+ get: function () {
1247
+ if (this.parentNode) {
1248
+ var children = this.parentNode.childNodes;
1249
+ var i = children.length;
1250
+ while (i > 0) {
1251
+ var child = children[--i];
1252
+ if (this === child)
1253
+ return children[i - 1] || null;
1254
+ }
1255
+ return null;
1256
+ }
1257
+ },
1258
+ enumerable: false,
1259
+ configurable: true
1260
+ });
1261
+ Object.defineProperty(HTMLElement.prototype, "previousElementSibling", {
1262
+ get: function () {
1263
+ if (this.parentNode) {
1264
+ var children = this.parentNode.childNodes;
1265
+ var i = children.length;
1266
+ var find = false;
1267
+ while (i > 0) {
1268
+ var child = children[--i];
1269
+ if (find) {
1270
+ if (child instanceof HTMLElement) {
1271
+ return child || null;
1272
+ }
1273
+ }
1274
+ else if (this === child) {
1275
+ find = true;
1276
+ }
1277
+ }
1278
+ return null;
1279
+ }
1280
+ },
1281
+ enumerable: false,
1282
+ configurable: true
1283
+ });
1284
+ Object.defineProperty(HTMLElement.prototype, "classNames", {
1285
+ get: function () {
1286
+ return this.classList.toString();
1287
+ },
1288
+ enumerable: false,
1289
+ configurable: true
1290
+ });
1291
+ /**
1292
+ * Clone this Node
1293
+ */
1294
+ HTMLElement.prototype.clone = function () {
1295
+ return parse(this.toString(), this._parseOptions).firstChild;
1296
+ };
1297
+ return HTMLElement;
1298
+ }(node_2.default));
1299
+ exports.default = HTMLElement;
1300
+ // https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
1301
+ var kMarkupPattern = /<!--[\s\S]*?-->|<(\/?)([a-zA-Z][-.:0-9_a-zA-Z]*)((?:\s+[^>]*?(?:(?:'[^']*')|(?:"[^"]*"))?)*)\s*(\/?)>/g;
1302
+ var kAttributePattern = /(?:^|\s)(id|class)\s*=\s*((?:'[^']*')|(?:"[^"]*")|\S+)/gi;
1303
+ var kElementsClosedByOpening = {
1304
+ li: { li: true, LI: true },
1305
+ LI: { li: true, LI: true },
1306
+ p: { p: true, div: true, P: true, DIV: true },
1307
+ P: { p: true, div: true, P: true, DIV: true },
1308
+ b: { div: true, DIV: true },
1309
+ B: { div: true, DIV: true },
1310
+ td: { td: true, th: true, TD: true, TH: true },
1311
+ TD: { td: true, th: true, TD: true, TH: true },
1312
+ th: { td: true, th: true, TD: true, TH: true },
1313
+ TH: { td: true, th: true, TD: true, TH: true },
1314
+ h1: { h1: true, H1: true },
1315
+ H1: { h1: true, H1: true },
1316
+ h2: { h2: true, H2: true },
1317
+ H2: { h2: true, H2: true },
1318
+ h3: { h3: true, H3: true },
1319
+ H3: { h3: true, H3: true },
1320
+ h4: { h4: true, H4: true },
1321
+ H4: { h4: true, H4: true },
1322
+ h5: { h5: true, H5: true },
1323
+ H5: { h5: true, H5: true },
1324
+ h6: { h6: true, H6: true },
1325
+ H6: { h6: true, H6: true },
1326
+ };
1327
+ var kElementsClosedByClosing = {
1328
+ li: { ul: true, ol: true, UL: true, OL: true },
1329
+ LI: { ul: true, ol: true, UL: true, OL: true },
1330
+ a: { div: true, DIV: true },
1331
+ A: { div: true, DIV: true },
1332
+ b: { div: true, DIV: true },
1333
+ B: { div: true, DIV: true },
1334
+ i: { div: true, DIV: true },
1335
+ I: { div: true, DIV: true },
1336
+ p: { div: true, DIV: true },
1337
+ P: { div: true, DIV: true },
1338
+ td: { tr: true, table: true, TR: true, TABLE: true },
1339
+ TD: { tr: true, table: true, TR: true, TABLE: true },
1340
+ th: { tr: true, table: true, TR: true, TABLE: true },
1341
+ TH: { tr: true, table: true, TR: true, TABLE: true },
1342
+ };
1343
+ var frameflag = 'documentfragmentcontainer';
1344
+ /**
1345
+ * Parses HTML and returns a root element
1346
+ * Parse a chuck of HTML source.
1347
+ * @param {string} data html
1348
+ * @return {HTMLElement} root element
1349
+ */
1350
+ function base_parse(data, options) {
1351
+ var _a, _b;
1352
+ if (options === void 0) { options = {}; }
1353
+ var voidTag = new void_tag_1.default((_a = options === null || options === void 0 ? void 0 : options.voidTag) === null || _a === void 0 ? void 0 : _a.closingSlash, (_b = options === null || options === void 0 ? void 0 : options.voidTag) === null || _b === void 0 ? void 0 : _b.tags);
1354
+ var elements = options.blockTextElements || {
1355
+ script: true,
1356
+ noscript: true,
1357
+ style: true,
1358
+ pre: true,
1359
+ };
1360
+ var element_names = Object.keys(elements);
1361
+ var kBlockTextElements = element_names.map(function (it) { return new RegExp("^".concat(it, "$"), 'i'); });
1362
+ var kIgnoreElements = element_names.filter(function (it) { return Boolean(elements[it]); }).map(function (it) { return new RegExp("^".concat(it, "$"), 'i'); });
1363
+ function element_should_be_ignore(tag) {
1364
+ return kIgnoreElements.some(function (it) { return it.test(tag); });
1365
+ }
1366
+ function is_block_text_element(tag) {
1367
+ return kBlockTextElements.some(function (it) { return it.test(tag); });
1368
+ }
1369
+ var createRange = function (startPos, endPos) { return [startPos - frameFlagOffset, endPos - frameFlagOffset]; };
1370
+ var root = new HTMLElement(null, {}, '', null, [0, data.length], voidTag, options);
1371
+ var currentParent = root;
1372
+ var stack = [root];
1373
+ var lastTextPos = -1;
1374
+ var noNestedTagIndex = undefined;
1375
+ var match;
1376
+ // https://github.com/taoqf/node-html-parser/issues/38
1377
+ data = "<".concat(frameflag, ">").concat(data, "</").concat(frameflag, ">");
1378
+ var lowerCaseTagName = options.lowerCaseTagName, fixNestedATags = options.fixNestedATags;
1379
+ var dataEndPos = data.length - (frameflag.length + 2);
1380
+ var frameFlagOffset = frameflag.length + 2;
1381
+ while ((match = kMarkupPattern.exec(data))) {
1382
+ // Note: Object destructuring here consistently tests as higher performance than array destructuring
1383
+ // eslint-disable-next-line prefer-const
1384
+ var matchText = match[0], leadingSlash = match[1], tagName = match[2], attributes = match[3], closingSlash = match[4];
1385
+ var matchLength = matchText.length;
1386
+ var tagStartPos = kMarkupPattern.lastIndex - matchLength;
1387
+ var tagEndPos = kMarkupPattern.lastIndex;
1388
+ // Add TextNode if content
1389
+ if (lastTextPos > -1) {
1390
+ if (lastTextPos + matchLength < tagEndPos) {
1391
+ var text = data.substring(lastTextPos, tagStartPos);
1392
+ currentParent.appendChild(new text_1.default(text, currentParent, createRange(lastTextPos, tagStartPos)));
1393
+ }
1394
+ }
1395
+ lastTextPos = kMarkupPattern.lastIndex;
1396
+ // https://github.com/taoqf/node-html-parser/issues/38
1397
+ // Skip frameflag node
1398
+ if (tagName === frameflag)
1399
+ continue;
1400
+ // Handle comments
1401
+ if (matchText[1] === '!') {
1402
+ if (options.comment) {
1403
+ // Only keep what is in between <!-- and -->
1404
+ var text = data.substring(tagStartPos + 4, tagEndPos - 3);
1405
+ currentParent.appendChild(new comment_1.default(text, currentParent, createRange(tagStartPos, tagEndPos)));
1406
+ }
1407
+ continue;
1408
+ }
1409
+ /* -- Handle tag matching -- */
1410
+ // Fix tag casing if necessary
1411
+ if (lowerCaseTagName)
1412
+ tagName = tagName.toLowerCase();
1413
+ // Handle opening tags (ie. <this> not </that>)
1414
+ if (!leadingSlash) {
1415
+ /* Populate attributes */
1416
+ var attrs = {};
1417
+ for (var attMatch = void 0; (attMatch = kAttributePattern.exec(attributes));) {
1418
+ var key = attMatch[1], val = attMatch[2];
1419
+ var isQuoted = val[0] === "'" || val[0] === "\"";
1420
+ attrs[key.toLowerCase()] = isQuoted ? val.slice(1, val.length - 1) : val;
1421
+ }
1422
+ var parentTagName = currentParent.rawTagName;
1423
+ if (!closingSlash && kElementsClosedByOpening[parentTagName]) {
1424
+ if (kElementsClosedByOpening[parentTagName][tagName]) {
1425
+ stack.pop();
1426
+ currentParent = (0, back_1.default)(stack);
1427
+ }
1428
+ }
1429
+ // Prevent nested A tags by terminating the last A and starting a new one : see issue #144
1430
+ if (fixNestedATags && (tagName === 'a' || tagName === 'A')) {
1431
+ if (noNestedTagIndex !== undefined) {
1432
+ stack.splice(noNestedTagIndex);
1433
+ currentParent = (0, back_1.default)(stack);
1434
+ }
1435
+ noNestedTagIndex = stack.length;
1436
+ }
1437
+ var tagEndPos_1 = kMarkupPattern.lastIndex;
1438
+ var tagStartPos_1 = tagEndPos_1 - matchLength;
1439
+ currentParent = currentParent.appendChild(
1440
+ // Initialize range (end position updated later for closed tags)
1441
+ new HTMLElement(tagName, attrs, attributes.slice(1), null, createRange(tagStartPos_1, tagEndPos_1), voidTag, options));
1442
+ stack.push(currentParent);
1443
+ if (is_block_text_element(tagName)) {
1444
+ // Find closing tag
1445
+ var closeMarkup = "</".concat(tagName, ">");
1446
+ var closeIndex = lowerCaseTagName
1447
+ ? data.toLocaleLowerCase().indexOf(closeMarkup, kMarkupPattern.lastIndex)
1448
+ : data.indexOf(closeMarkup, kMarkupPattern.lastIndex);
1449
+ var textEndPos = closeIndex === -1 ? dataEndPos : closeIndex;
1450
+ if (element_should_be_ignore(tagName)) {
1451
+ var text = data.substring(tagEndPos_1, textEndPos);
1452
+ if (text.length > 0 && /\S/.test(text)) {
1453
+ currentParent.appendChild(new text_1.default(text, currentParent, createRange(tagEndPos_1, textEndPos)));
1454
+ }
1455
+ }
1456
+ if (closeIndex === -1) {
1457
+ lastTextPos = kMarkupPattern.lastIndex = data.length + 1;
1458
+ }
1459
+ else {
1460
+ lastTextPos = kMarkupPattern.lastIndex = closeIndex + closeMarkup.length;
1461
+ // Cause to be treated as self-closing, because no close found
1462
+ leadingSlash = '/';
1463
+ }
1464
+ }
1465
+ }
1466
+ // Handle closing tags or self-closed elements (ie </tag> or <br>)
1467
+ if (leadingSlash || closingSlash || voidTag.isVoidElement(tagName)) {
1468
+ while (true) {
1469
+ if (noNestedTagIndex != null && (tagName === 'a' || tagName === 'A'))
1470
+ noNestedTagIndex = undefined;
1471
+ if (currentParent.rawTagName === tagName) {
1472
+ // Update range end for closed tag
1473
+ currentParent.range[1] = createRange(-1, Math.max(lastTextPos, tagEndPos))[1];
1474
+ stack.pop();
1475
+ currentParent = (0, back_1.default)(stack);
1476
+ break;
1477
+ }
1478
+ else {
1479
+ var parentTagName = currentParent.tagName;
1480
+ // Trying to close current tag, and move on
1481
+ if (kElementsClosedByClosing[parentTagName]) {
1482
+ if (kElementsClosedByClosing[parentTagName][tagName]) {
1483
+ stack.pop();
1484
+ currentParent = (0, back_1.default)(stack);
1485
+ continue;
1486
+ }
1487
+ }
1488
+ // Use aggressive strategy to handle unmatching markups.
1489
+ break;
1490
+ }
1491
+ }
1492
+ }
1493
+ }
1494
+ return stack;
1495
+ }
1496
+ exports.base_parse = base_parse;
1497
+ /**
1498
+ * Parses HTML and returns a root element
1499
+ * Parse a chuck of HTML source.
1500
+ */
1501
+ function parse(data, options) {
1502
+ if (options === void 0) { options = {}; }
1503
+ var stack = base_parse(data, options);
1504
+ var root = stack[0];
1505
+ var _loop_1 = function () {
1506
+ // Handle each error elements.
1507
+ var last = stack.pop();
1508
+ var oneBefore = (0, back_1.default)(stack);
1509
+ if (last.parentNode && last.parentNode.parentNode) {
1510
+ if (last.parentNode === oneBefore && last.tagName === oneBefore.tagName) {
1511
+ // Pair error case <h3> <h3> handle : Fixes to <h3> </h3>
1512
+ // this is wrong, becouse this will put the H3 outside the current right position which should be inside the current Html Element, see issue 152 for more info
1513
+ if (options.parseNoneClosedTags !== true) {
1514
+ oneBefore.removeChild(last);
1515
+ last.childNodes.forEach(function (child) {
1516
+ oneBefore.parentNode.appendChild(child);
1517
+ });
1518
+ stack.pop();
1519
+ }
1520
+ }
1521
+ else {
1522
+ // Single error <div> <h3> </div> handle: Just removes <h3>
1523
+ // Why remove? this is already a HtmlElement and the missing <H3> is already added in this case. see issue 152 for more info
1524
+ // eslint-disable-next-line no-lonely-if
1525
+ if (options.parseNoneClosedTags !== true) {
1526
+ oneBefore.removeChild(last);
1527
+ last.childNodes.forEach(function (child) {
1528
+ oneBefore.appendChild(child);
1529
+ });
1530
+ }
1531
+ }
1532
+ }
1533
+ else {
1534
+ // If it's final element just skip.
1535
+ }
1536
+ };
1537
+ while (stack.length > 1) {
1538
+ _loop_1();
1539
+ }
1540
+ // response.childNodes.forEach((node) => {
1541
+ // if (node instanceof HTMLElement) {
1542
+ // node.parentNode = null;
1543
+ // }
1544
+ // });
1545
+ return root;
1546
+ }
1547
+ exports.parse = parse;
1548
+ function resetParent(nodes, parent) {
1549
+ return nodes.map(function (node) {
1550
+ node.parentNode = parent;
1551
+ return node;
1552
+ });
1553
+ }
1554
+ });
1555
+ define("nodes/comment", ["require", "exports", "nodes/node", "nodes/type"], function (require, exports, node_3, type_4) {
1556
+ "use strict";
1557
+ Object.defineProperty(exports, "__esModule", { value: true });
1558
+ node_3 = __importDefault(node_3);
1559
+ type_4 = __importDefault(type_4);
1560
+ var CommentNode = /** @class */ (function (_super) {
1561
+ __extends(CommentNode, _super);
1562
+ function CommentNode(rawText, parentNode, range, rawTagName) {
1563
+ if (parentNode === void 0) { parentNode = null; }
1564
+ if (rawTagName === void 0) { rawTagName = '!--'; }
1565
+ var _this = _super.call(this, parentNode, range) || this;
1566
+ _this.rawText = rawText;
1567
+ _this.rawTagName = rawTagName;
1568
+ /**
1569
+ * Node Type declaration.
1570
+ * @type {Number}
1571
+ */
1572
+ _this.nodeType = type_4.default.COMMENT_NODE;
1573
+ return _this;
1574
+ }
1575
+ CommentNode.prototype.clone = function () {
1576
+ return new CommentNode(this.rawText, null, undefined, this.rawTagName);
1577
+ };
1578
+ Object.defineProperty(CommentNode.prototype, "text", {
1579
+ /**
1580
+ * Get unescaped text value of current node and its children.
1581
+ * @return {string} text content
1582
+ */
1583
+ get: function () {
1584
+ return this.rawText;
1585
+ },
1586
+ enumerable: false,
1587
+ configurable: true
1588
+ });
1589
+ CommentNode.prototype.toString = function () {
1590
+ return "<!--".concat(this.rawText, "-->");
1591
+ };
1592
+ return CommentNode;
1593
+ }(node_3.default));
1594
+ exports.default = CommentNode;
1595
+ });
1596
+ define("parse", ["require", "exports", "nodes/html"], function (require, exports, html_1) {
1597
+ "use strict";
1598
+ Object.defineProperty(exports, "__esModule", { value: true });
1599
+ exports.default = void 0;
1600
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return html_1.parse; } });
1601
+ });
1602
+ define("valid", ["require", "exports", "nodes/html"], function (require, exports, html_2) {
1603
+ "use strict";
1604
+ Object.defineProperty(exports, "__esModule", { value: true });
1605
+ /**
1606
+ * Parses HTML and returns a root element
1607
+ * Parse a chuck of HTML source.
1608
+ */
1609
+ function valid(data, options) {
1610
+ if (options === void 0) { options = {}; }
1611
+ var stack = (0, html_2.base_parse)(data, options);
1612
+ return Boolean(stack.length === 1);
1613
+ }
1614
+ exports.default = valid;
1615
+ });
1616
+ define("index", ["require", "exports", "nodes/comment", "nodes/html", "nodes/node", "nodes/text", "nodes/type", "parse", "valid"], function (require, exports, comment_2, html_3, node_4, text_2, type_5, parse_1, valid_1) {
1617
+ "use strict";
1618
+ Object.defineProperty(exports, "__esModule", { value: true });
1619
+ exports.NodeType = exports.TextNode = exports.Node = exports.valid = exports.CommentNode = exports.HTMLElement = exports.parse = void 0;
1620
+ comment_2 = __importDefault(comment_2);
1621
+ html_3 = __importDefault(html_3);
1622
+ node_4 = __importDefault(node_4);
1623
+ text_2 = __importDefault(text_2);
1624
+ type_5 = __importDefault(type_5);
1625
+ parse_1 = __importDefault(parse_1);
1626
+ valid_1 = __importDefault(valid_1);
1627
+ exports.CommentNode = comment_2.default;
1628
+ exports.HTMLElement = html_3.default;
1629
+ exports.Node = node_4.default;
1630
+ exports.TextNode = text_2.default;
1631
+ exports.NodeType = type_5.default;
1632
+ exports.valid = valid_1.default;
1633
+ function parse(data, options) {
1634
+ if (options === void 0) { options = {}; }
1635
+ return (0, parse_1.default)(data, options);
1636
+ }
1637
+ exports.default = parse;
1638
+ exports.parse = parse;
1639
+ parse.parse = parse_1.default;
1640
+ parse.HTMLElement = html_3.default;
1641
+ parse.CommentNode = comment_2.default;
1642
+ parse.valid = valid_1.default;
1643
+ parse.Node = node_4.default;
1644
+ parse.TextNode = text_2.default;
1645
+ parse.NodeType = type_5.default;
1646
+ });