@websolutespa/bom-next 3.0.0 → 3.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 (313) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/_virtual/_rolldown/runtime.js +24 -0
  3. package/dist/client/client.d.ts +9 -0
  4. package/dist/client/client.d.ts.map +1 -0
  5. package/dist/client/client.js +18 -0
  6. package/dist/client/client.js.map +1 -0
  7. package/dist/client/extra.d.ts +17 -0
  8. package/dist/client/extra.d.ts.map +1 -0
  9. package/dist/client/extra.js +13 -0
  10. package/dist/client/extra.js.map +1 -0
  11. package/dist/client/label.d.ts +15 -0
  12. package/dist/client/label.d.ts.map +1 -0
  13. package/dist/client/label.js +20 -0
  14. package/dist/client/label.js.map +1 -0
  15. package/dist/client/layout.d.ts +18 -0
  16. package/dist/client/layout.d.ts.map +1 -0
  17. package/dist/client/layout.js +13 -0
  18. package/dist/client/layout.js.map +1 -0
  19. package/dist/client/local.collection.d.ts +32 -0
  20. package/dist/client/local.collection.d.ts.map +1 -0
  21. package/dist/client/local.collection.js +49 -0
  22. package/dist/client/local.collection.js.map +1 -0
  23. package/dist/client/metadata.d.ts +43 -0
  24. package/dist/client/metadata.d.ts.map +1 -0
  25. package/dist/client/metadata.js +146 -0
  26. package/dist/client/metadata.js.map +1 -0
  27. package/dist/client/page.d.ts +404 -0
  28. package/dist/client/page.d.ts.map +1 -0
  29. package/dist/client/page.js +13 -0
  30. package/dist/client/page.js.map +1 -0
  31. package/dist/client/useApi.d.ts +21 -0
  32. package/dist/client/useApi.d.ts.map +1 -0
  33. package/dist/client/useApi.js +65 -0
  34. package/dist/client/useApi.js.map +1 -0
  35. package/dist/client/useCollectionApi.d.ts +21 -0
  36. package/dist/client/useCollectionApi.d.ts.map +1 -0
  37. package/dist/client/useCollectionApi.js +65 -0
  38. package/dist/client/useCollectionApi.js.map +1 -0
  39. package/dist/client/useExtra.d.ts +9 -0
  40. package/dist/client/useExtra.d.ts.map +1 -0
  41. package/dist/client/useExtra.js +13 -0
  42. package/dist/client/useExtra.js.map +1 -0
  43. package/dist/client/useHttp.d.ts +15 -0
  44. package/dist/client/useHttp.d.ts.map +1 -0
  45. package/dist/client/useHttp.js +70 -0
  46. package/dist/client/useHttp.js.map +1 -0
  47. package/dist/client/useLabel.d.ts +9 -0
  48. package/dist/client/useLabel.d.ts.map +1 -0
  49. package/dist/client/useLabel.js +13 -0
  50. package/dist/client/useLabel.js.map +1 -0
  51. package/dist/client/useLayout.d.ts +9 -0
  52. package/dist/client/useLayout.d.ts.map +1 -0
  53. package/dist/client/useLayout.js +13 -0
  54. package/dist/client/useLayout.js.map +1 -0
  55. package/dist/client/useLink.d.ts +7 -0
  56. package/dist/client/useLink.d.ts.map +1 -0
  57. package/dist/client/useLink.js +15 -0
  58. package/dist/client/useLink.js.map +1 -0
  59. package/dist/client/useMetaData.d.ts +9 -0
  60. package/dist/client/useMetaData.d.ts.map +1 -0
  61. package/dist/client/useMetaData.js +13 -0
  62. package/dist/client/useMetaData.js.map +1 -0
  63. package/dist/client/usePage.d.ts +394 -0
  64. package/dist/client/usePage.d.ts.map +1 -0
  65. package/dist/client/usePage.js +13 -0
  66. package/dist/client/usePage.js.map +1 -0
  67. package/dist/client/useUser.d.ts +9 -0
  68. package/dist/client/useUser.d.ts.map +1 -0
  69. package/dist/client/useUser.js +13 -0
  70. package/dist/client/useUser.js.map +1 -0
  71. package/dist/client/user.d.ts +20 -0
  72. package/dist/client/user.d.ts.map +1 -0
  73. package/dist/client/user.js +33 -0
  74. package/dist/client/user.js.map +1 -0
  75. package/dist/exports/client.d.ts +20 -0
  76. package/dist/exports/client.js +19 -5734
  77. package/dist/exports/instrumentation.d.ts +2 -0
  78. package/dist/exports/instrumentation.js +1 -24
  79. package/dist/exports/proxy.d.ts +5 -0
  80. package/dist/exports/proxy.js +4 -253
  81. package/dist/exports/server.d.ts +19 -0
  82. package/dist/exports/server.js +18 -1973
  83. package/dist/index.d.ts +18 -0
  84. package/dist/index.js +10 -200
  85. package/dist/instrumentation/client.d.ts +8 -0
  86. package/dist/instrumentation/client.d.ts.map +1 -0
  87. package/dist/instrumentation/client.js +15 -0
  88. package/dist/instrumentation/client.js.map +1 -0
  89. package/dist/instrumentation/sentry/capture.requestError.js +10 -0
  90. package/dist/instrumentation/sentry/capture.requestError.js.map +1 -0
  91. package/dist/instrumentation/sentry/capture.routerTransitionStart.js +7 -0
  92. package/dist/instrumentation/sentry/capture.routerTransitionStart.js.map +1 -0
  93. package/dist/{exports/instrumentation-DBO6QH4d.d.ts → instrumentation/server.d.ts} +2 -2
  94. package/dist/instrumentation/server.d.ts.map +1 -0
  95. package/dist/instrumentation/server.js +19 -0
  96. package/dist/instrumentation/server.js.map +1 -0
  97. package/dist/{types-BatUTdbZ.d.ts → instrumentation/types.d.ts} +2 -2
  98. package/dist/instrumentation/types.d.ts.map +1 -0
  99. package/dist/lib/breadcrumb.d.ts +15 -0
  100. package/dist/lib/breadcrumb.d.ts.map +1 -0
  101. package/dist/lib/breadcrumb.js +20 -0
  102. package/dist/lib/breadcrumb.js.map +1 -0
  103. package/dist/lib/const.d.ts +9 -0
  104. package/dist/lib/const.d.ts.map +1 -0
  105. package/dist/lib/const.js +9 -0
  106. package/dist/lib/const.js.map +1 -0
  107. package/dist/lib/http.d.ts +36 -0
  108. package/dist/lib/http.d.ts.map +1 -0
  109. package/dist/{http-_2M-UFRx.js → lib/http.js} +2 -2
  110. package/dist/lib/http.js.map +1 -0
  111. package/dist/lib/label.d.ts +16 -0
  112. package/dist/lib/label.d.ts.map +1 -0
  113. package/dist/lib/label.js +33 -0
  114. package/dist/lib/label.js.map +1 -0
  115. package/dist/lib/layout.defaults.d.ts +9 -0
  116. package/dist/lib/layout.defaults.d.ts.map +1 -0
  117. package/dist/lib/layout.defaults.js +161 -0
  118. package/dist/lib/layout.defaults.js.map +1 -0
  119. package/dist/lib/link.d.ts +9 -0
  120. package/dist/lib/link.d.ts.map +1 -0
  121. package/dist/lib/link.js +16 -0
  122. package/dist/lib/link.js.map +1 -0
  123. package/dist/lib/meta-data.d.ts +56 -0
  124. package/dist/lib/meta-data.d.ts.map +1 -0
  125. package/dist/lib/open-graph.d.ts +143 -0
  126. package/dist/lib/open-graph.d.ts.map +1 -0
  127. package/dist/lib/pagination.d.ts +27 -0
  128. package/dist/lib/pagination.d.ts.map +1 -0
  129. package/dist/lib/pagination.js +39 -0
  130. package/dist/lib/pagination.js.map +1 -0
  131. package/dist/lib/route.d.ts +17 -0
  132. package/dist/lib/route.d.ts.map +1 -0
  133. package/dist/{route-DzFwERQP.js → lib/route.js} +2 -2
  134. package/dist/lib/route.js.map +1 -0
  135. package/dist/lib/store.d.ts +27 -0
  136. package/dist/lib/store.d.ts.map +1 -0
  137. package/dist/{store-CJzqrHsl.js → lib/store.js} +2 -25
  138. package/dist/lib/store.js.map +1 -0
  139. package/dist/lib/structured-data.d.ts +9 -0
  140. package/dist/lib/structured-data.d.ts.map +1 -0
  141. package/dist/lib/twitter-card.d.ts +43 -0
  142. package/dist/lib/twitter-card.d.ts.map +1 -0
  143. package/dist/lib/utils.d.ts +13 -0
  144. package/dist/lib/utils.d.ts.map +1 -0
  145. package/dist/lib/utils.js +35 -0
  146. package/dist/lib/utils.js.map +1 -0
  147. package/dist/mock.d.ts +127 -0
  148. package/dist/mock.d.ts.map +1 -0
  149. package/dist/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.js +75 -0
  150. package/dist/node_modules/@selderee/plugin-htmlparser2/lib/hp2-builder.js.map +1 -0
  151. package/dist/node_modules/deepmerge/dist/cjs.js +86 -0
  152. package/dist/node_modules/deepmerge/dist/cjs.js.map +1 -0
  153. package/dist/node_modules/dom-serializer/lib/esm/foreignNames.js +105 -0
  154. package/dist/node_modules/dom-serializer/lib/esm/foreignNames.js.map +1 -0
  155. package/dist/node_modules/dom-serializer/lib/esm/index.js +146 -0
  156. package/dist/node_modules/dom-serializer/lib/esm/index.js.map +1 -0
  157. package/dist/node_modules/domelementtype/lib/esm/index.js +53 -0
  158. package/dist/node_modules/domelementtype/lib/esm/index.js.map +1 -0
  159. package/dist/node_modules/domhandler/lib/esm/index.js +130 -0
  160. package/dist/node_modules/domhandler/lib/esm/index.js.map +1 -0
  161. package/dist/node_modules/domhandler/lib/esm/node.js +307 -0
  162. package/dist/node_modules/domhandler/lib/esm/node.js.map +1 -0
  163. package/dist/node_modules/entities/lib/esm/decode.js +363 -0
  164. package/dist/node_modules/entities/lib/esm/decode.js.map +1 -0
  165. package/dist/node_modules/entities/lib/esm/decode_codepoint.js +59 -0
  166. package/dist/node_modules/entities/lib/esm/decode_codepoint.js.map +1 -0
  167. package/dist/node_modules/entities/lib/esm/escape.js +85 -0
  168. package/dist/node_modules/entities/lib/esm/escape.js.map +1 -0
  169. package/dist/node_modules/entities/lib/esm/generated/decode-data-html.js +6 -0
  170. package/dist/node_modules/entities/lib/esm/generated/decode-data-html.js.map +1 -0
  171. package/dist/node_modules/entities/lib/esm/generated/decode-data-xml.js +6 -0
  172. package/dist/node_modules/entities/lib/esm/generated/decode-data-xml.js.map +1 -0
  173. package/dist/node_modules/html-to-text/lib/html-to-text.js +1816 -0
  174. package/dist/node_modules/html-to-text/lib/html-to-text.js.map +1 -0
  175. package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/Parser.js +435 -0
  176. package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/Parser.js.map +1 -0
  177. package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/Tokenizer.js +736 -0
  178. package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/Tokenizer.js.map +1 -0
  179. package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/index.js +19 -0
  180. package/dist/node_modules/html-to-text/node_modules/htmlparser2/lib/esm/index.js.map +1 -0
  181. package/dist/node_modules/leac/lib/leac.js +101 -0
  182. package/dist/node_modules/leac/lib/leac.js.map +1 -0
  183. package/dist/node_modules/parseley/lib/parseley.js +310 -0
  184. package/dist/node_modules/parseley/lib/parseley.js.map +1 -0
  185. package/dist/node_modules/peberminta/lib/core.js +149 -0
  186. package/dist/node_modules/peberminta/lib/core.js.map +1 -0
  187. package/dist/node_modules/selderee/lib/selderee.js +319 -0
  188. package/dist/node_modules/selderee/lib/selderee.js.map +1 -0
  189. package/dist/proxy/protected-route.d.ts +9 -0
  190. package/dist/proxy/protected-route.d.ts.map +1 -0
  191. package/dist/proxy/protected-route.js +40 -0
  192. package/dist/proxy/protected-route.js.map +1 -0
  193. package/dist/proxy/proxy.d.ts +31 -0
  194. package/dist/proxy/proxy.d.ts.map +1 -0
  195. package/dist/proxy/proxy.js +49 -0
  196. package/dist/proxy/proxy.js.map +1 -0
  197. package/dist/proxy/route-auto-detection.d.ts +12 -0
  198. package/dist/proxy/route-auto-detection.d.ts.map +1 -0
  199. package/dist/proxy/route-auto-detection.js +82 -0
  200. package/dist/proxy/route-auto-detection.js.map +1 -0
  201. package/dist/proxy/route-proxy.d.ts +36 -0
  202. package/dist/proxy/route-proxy.d.ts.map +1 -0
  203. package/dist/proxy/route-proxy.js +103 -0
  204. package/dist/proxy/route-proxy.js.map +1 -0
  205. package/dist/server/context.d.ts +30 -0
  206. package/dist/server/context.d.ts.map +1 -0
  207. package/dist/server/context.js +106 -0
  208. package/dist/server/context.js.map +1 -0
  209. package/dist/server/handlers/auth.handler.d.ts +10 -0
  210. package/dist/server/handlers/auth.handler.d.ts.map +1 -0
  211. package/dist/server/handlers/auth.handler.js +29 -0
  212. package/dist/server/handlers/auth.handler.js.map +1 -0
  213. package/dist/server/handlers/captions.handler.d.ts +10 -0
  214. package/dist/server/handlers/captions.handler.d.ts.map +1 -0
  215. package/dist/server/handlers/captions.handler.js +33 -0
  216. package/dist/server/handlers/captions.handler.js.map +1 -0
  217. package/dist/server/handlers/collection.handler.d.ts +36 -0
  218. package/dist/server/handlers/collection.handler.d.ts.map +1 -0
  219. package/dist/server/handlers/collection.handler.js +166 -0
  220. package/dist/server/handlers/collection.handler.js.map +1 -0
  221. package/dist/server/handlers/error-response.js +24 -0
  222. package/dist/server/handlers/error-response.js.map +1 -0
  223. package/dist/server/handlers/index.handler.d.ts +9 -0
  224. package/dist/server/handlers/index.handler.d.ts.map +1 -0
  225. package/dist/server/handlers/index.handler.js +145 -0
  226. package/dist/server/handlers/index.handler.js.map +1 -0
  227. package/dist/server/handlers/preview.handler.d.ts +9 -0
  228. package/dist/server/handlers/preview.handler.d.ts.map +1 -0
  229. package/dist/server/handlers/preview.handler.js +15 -0
  230. package/dist/server/handlers/preview.handler.js.map +1 -0
  231. package/dist/server/handlers/registry.handler.d.ts +16 -0
  232. package/dist/server/handlers/registry.handler.d.ts.map +1 -0
  233. package/dist/server/handlers/registry.handler.js +260 -0
  234. package/dist/server/handlers/registry.handler.js.map +1 -0
  235. package/dist/server/handlers/route.handler.d.ts +20 -0
  236. package/dist/server/handlers/route.handler.d.ts.map +1 -0
  237. package/dist/server/handlers/route.handler.js +122 -0
  238. package/dist/server/handlers/route.handler.js.map +1 -0
  239. package/dist/server/handlers/sitemap.handler.d.ts +30 -0
  240. package/dist/server/handlers/sitemap.handler.d.ts.map +1 -0
  241. package/dist/server/handlers/sitemap.handler.js +338 -0
  242. package/dist/server/handlers/sitemap.handler.js.map +1 -0
  243. package/dist/server/handlers/static-params.handler.d.ts +24 -0
  244. package/dist/server/handlers/static-params.handler.d.ts.map +1 -0
  245. package/dist/server/handlers/static-params.handler.js +56 -0
  246. package/dist/server/handlers/static-params.handler.js.map +1 -0
  247. package/dist/server/handlers/vars.handler.d.ts +10 -0
  248. package/dist/server/handlers/vars.handler.d.ts.map +1 -0
  249. package/dist/server/handlers/vars.handler.js +159 -0
  250. package/dist/server/handlers/vars.handler.js.map +1 -0
  251. package/dist/server/layout.js +88 -0
  252. package/dist/server/layout.js.map +1 -0
  253. package/dist/server/lazy.d.ts +11 -0
  254. package/dist/server/lazy.d.ts.map +1 -0
  255. package/dist/server/lazy.js +33 -0
  256. package/dist/server/lazy.js.map +1 -0
  257. package/dist/server/local-api.d.ts +9 -0
  258. package/dist/server/local-api.d.ts.map +1 -0
  259. package/dist/server/local-api.js +60 -0
  260. package/dist/server/local-api.js.map +1 -0
  261. package/dist/server/metadata.d.ts +21 -0
  262. package/dist/server/metadata.d.ts.map +1 -0
  263. package/dist/server/metadata.js +20 -0
  264. package/dist/server/metadata.js.map +1 -0
  265. package/dist/server/mixer-payload.d.ts +63 -0
  266. package/dist/server/mixer-payload.d.ts.map +1 -0
  267. package/dist/server/mixer.d.ts +214 -0
  268. package/dist/server/mixer.d.ts.map +1 -0
  269. package/dist/server/mixer.js +355 -0
  270. package/dist/server/mixer.js.map +1 -0
  271. package/dist/server/page.d.ts +22 -0
  272. package/dist/server/page.d.ts.map +1 -0
  273. package/dist/server/page.js +57 -0
  274. package/dist/server/page.js.map +1 -0
  275. package/dist/server/utils.d.ts +12 -0
  276. package/dist/server/utils.d.ts.map +1 -0
  277. package/dist/{utils-YwteTbk7.js → server/utils.js} +3 -3
  278. package/dist/server/utils.js.map +1 -0
  279. package/dist/server/utmz.d.ts +9 -0
  280. package/dist/server/utmz.d.ts.map +1 -0
  281. package/dist/server/utmz.js +14 -0
  282. package/dist/server/utmz.js.map +1 -0
  283. package/dist/types.d.ts +136 -0
  284. package/dist/types.d.ts.map +1 -0
  285. package/package.json +1 -1
  286. package/src/index.ts +0 -1
  287. package/dist/exports/client-xcFJNcG7.d.ts +0 -979
  288. package/dist/exports/client-xcFJNcG7.d.ts.map +0 -1
  289. package/dist/exports/client.js.map +0 -1
  290. package/dist/exports/instrumentation-DBO6QH4d.d.ts.map +0 -1
  291. package/dist/exports/instrumentation.js.map +0 -1
  292. package/dist/exports/proxy-Cv7QFVci.d.ts +0 -71
  293. package/dist/exports/proxy-Cv7QFVci.d.ts.map +0 -1
  294. package/dist/exports/proxy.js.map +0 -1
  295. package/dist/exports/server-BHObJHJ6.d.ts +0 -402
  296. package/dist/exports/server-BHObJHJ6.d.ts.map +0 -1
  297. package/dist/exports/server.js.map +0 -1
  298. package/dist/http-_2M-UFRx.js.map +0 -1
  299. package/dist/index-CdYcvudT.d.ts +0 -4
  300. package/dist/index-CtfAJ0y7.d.ts +0 -499
  301. package/dist/index-CtfAJ0y7.d.ts.map +0 -1
  302. package/dist/index.js.map +0 -1
  303. package/dist/route-DzFwERQP.js.map +0 -1
  304. package/dist/store-CJzqrHsl.js.map +0 -1
  305. package/dist/types-BatUTdbZ.d.ts.map +0 -1
  306. package/dist/types-D29_snYY.d.ts +0 -191
  307. package/dist/types-D29_snYY.d.ts.map +0 -1
  308. package/dist/utils-Ca7xh5mm.js +0 -78
  309. package/dist/utils-Ca7xh5mm.js.map +0 -1
  310. package/dist/utils-YwteTbk7.js.map +0 -1
  311. /package/dist/{config.client-B8As5DY0.js → instrumentation/sentry/config.client.js} +0 -0
  312. /package/dist/{config.edge-B8As5DY0.js → instrumentation/sentry/config.edge.js} +0 -0
  313. /package/dist/{config.server-B8As5DY0.js → instrumentation/sentry/config.server.js} +0 -0
@@ -0,0 +1,736 @@
1
+ import decode_data_html_default from "../../../../../entities/lib/esm/generated/decode-data-html.js";
2
+ import decode_data_xml_default from "../../../../../entities/lib/esm/generated/decode-data-xml.js";
3
+ import { replaceCodePoint } from "../../../../../entities/lib/esm/decode_codepoint.js";
4
+ import { BinTrieFlags, determineBranch } from "../../../../../entities/lib/esm/decode.js";
5
+ //#region ../../node_modules/html-to-text/node_modules/htmlparser2/lib/esm/Tokenizer.js
6
+ var CharCodes;
7
+ (function(CharCodes) {
8
+ CharCodes[CharCodes["Tab"] = 9] = "Tab";
9
+ CharCodes[CharCodes["NewLine"] = 10] = "NewLine";
10
+ CharCodes[CharCodes["FormFeed"] = 12] = "FormFeed";
11
+ CharCodes[CharCodes["CarriageReturn"] = 13] = "CarriageReturn";
12
+ CharCodes[CharCodes["Space"] = 32] = "Space";
13
+ CharCodes[CharCodes["ExclamationMark"] = 33] = "ExclamationMark";
14
+ CharCodes[CharCodes["Number"] = 35] = "Number";
15
+ CharCodes[CharCodes["Amp"] = 38] = "Amp";
16
+ CharCodes[CharCodes["SingleQuote"] = 39] = "SingleQuote";
17
+ CharCodes[CharCodes["DoubleQuote"] = 34] = "DoubleQuote";
18
+ CharCodes[CharCodes["Dash"] = 45] = "Dash";
19
+ CharCodes[CharCodes["Slash"] = 47] = "Slash";
20
+ CharCodes[CharCodes["Zero"] = 48] = "Zero";
21
+ CharCodes[CharCodes["Nine"] = 57] = "Nine";
22
+ CharCodes[CharCodes["Semi"] = 59] = "Semi";
23
+ CharCodes[CharCodes["Lt"] = 60] = "Lt";
24
+ CharCodes[CharCodes["Eq"] = 61] = "Eq";
25
+ CharCodes[CharCodes["Gt"] = 62] = "Gt";
26
+ CharCodes[CharCodes["Questionmark"] = 63] = "Questionmark";
27
+ CharCodes[CharCodes["UpperA"] = 65] = "UpperA";
28
+ CharCodes[CharCodes["LowerA"] = 97] = "LowerA";
29
+ CharCodes[CharCodes["UpperF"] = 70] = "UpperF";
30
+ CharCodes[CharCodes["LowerF"] = 102] = "LowerF";
31
+ CharCodes[CharCodes["UpperZ"] = 90] = "UpperZ";
32
+ CharCodes[CharCodes["LowerZ"] = 122] = "LowerZ";
33
+ CharCodes[CharCodes["LowerX"] = 120] = "LowerX";
34
+ CharCodes[CharCodes["OpeningSquareBracket"] = 91] = "OpeningSquareBracket";
35
+ })(CharCodes || (CharCodes = {}));
36
+ /** All the states the tokenizer can be in. */
37
+ var State;
38
+ (function(State) {
39
+ State[State["Text"] = 1] = "Text";
40
+ State[State["BeforeTagName"] = 2] = "BeforeTagName";
41
+ State[State["InTagName"] = 3] = "InTagName";
42
+ State[State["InSelfClosingTag"] = 4] = "InSelfClosingTag";
43
+ State[State["BeforeClosingTagName"] = 5] = "BeforeClosingTagName";
44
+ State[State["InClosingTagName"] = 6] = "InClosingTagName";
45
+ State[State["AfterClosingTagName"] = 7] = "AfterClosingTagName";
46
+ State[State["BeforeAttributeName"] = 8] = "BeforeAttributeName";
47
+ State[State["InAttributeName"] = 9] = "InAttributeName";
48
+ State[State["AfterAttributeName"] = 10] = "AfterAttributeName";
49
+ State[State["BeforeAttributeValue"] = 11] = "BeforeAttributeValue";
50
+ State[State["InAttributeValueDq"] = 12] = "InAttributeValueDq";
51
+ State[State["InAttributeValueSq"] = 13] = "InAttributeValueSq";
52
+ State[State["InAttributeValueNq"] = 14] = "InAttributeValueNq";
53
+ State[State["BeforeDeclaration"] = 15] = "BeforeDeclaration";
54
+ State[State["InDeclaration"] = 16] = "InDeclaration";
55
+ State[State["InProcessingInstruction"] = 17] = "InProcessingInstruction";
56
+ State[State["BeforeComment"] = 18] = "BeforeComment";
57
+ State[State["CDATASequence"] = 19] = "CDATASequence";
58
+ State[State["InSpecialComment"] = 20] = "InSpecialComment";
59
+ State[State["InCommentLike"] = 21] = "InCommentLike";
60
+ State[State["BeforeSpecialS"] = 22] = "BeforeSpecialS";
61
+ State[State["SpecialStartSequence"] = 23] = "SpecialStartSequence";
62
+ State[State["InSpecialTag"] = 24] = "InSpecialTag";
63
+ State[State["BeforeEntity"] = 25] = "BeforeEntity";
64
+ State[State["BeforeNumericEntity"] = 26] = "BeforeNumericEntity";
65
+ State[State["InNamedEntity"] = 27] = "InNamedEntity";
66
+ State[State["InNumericEntity"] = 28] = "InNumericEntity";
67
+ State[State["InHexEntity"] = 29] = "InHexEntity";
68
+ })(State || (State = {}));
69
+ function isWhitespace(c) {
70
+ return c === CharCodes.Space || c === CharCodes.NewLine || c === CharCodes.Tab || c === CharCodes.FormFeed || c === CharCodes.CarriageReturn;
71
+ }
72
+ function isEndOfTagSection(c) {
73
+ return c === CharCodes.Slash || c === CharCodes.Gt || isWhitespace(c);
74
+ }
75
+ function isNumber(c) {
76
+ return c >= CharCodes.Zero && c <= CharCodes.Nine;
77
+ }
78
+ function isASCIIAlpha(c) {
79
+ return c >= CharCodes.LowerA && c <= CharCodes.LowerZ || c >= CharCodes.UpperA && c <= CharCodes.UpperZ;
80
+ }
81
+ function isHexDigit(c) {
82
+ return c >= CharCodes.UpperA && c <= CharCodes.UpperF || c >= CharCodes.LowerA && c <= CharCodes.LowerF;
83
+ }
84
+ var QuoteType;
85
+ (function(QuoteType) {
86
+ QuoteType[QuoteType["NoValue"] = 0] = "NoValue";
87
+ QuoteType[QuoteType["Unquoted"] = 1] = "Unquoted";
88
+ QuoteType[QuoteType["Single"] = 2] = "Single";
89
+ QuoteType[QuoteType["Double"] = 3] = "Double";
90
+ })(QuoteType || (QuoteType = {}));
91
+ /**
92
+ * Sequences used to match longer strings.
93
+ *
94
+ * We don't have `Script`, `Style`, or `Title` here. Instead, we re-use the *End
95
+ * sequences with an increased offset.
96
+ */
97
+ const Sequences = {
98
+ Cdata: new Uint8Array([
99
+ 67,
100
+ 68,
101
+ 65,
102
+ 84,
103
+ 65,
104
+ 91
105
+ ]),
106
+ CdataEnd: new Uint8Array([
107
+ 93,
108
+ 93,
109
+ 62
110
+ ]),
111
+ CommentEnd: new Uint8Array([
112
+ 45,
113
+ 45,
114
+ 62
115
+ ]),
116
+ ScriptEnd: new Uint8Array([
117
+ 60,
118
+ 47,
119
+ 115,
120
+ 99,
121
+ 114,
122
+ 105,
123
+ 112,
124
+ 116
125
+ ]),
126
+ StyleEnd: new Uint8Array([
127
+ 60,
128
+ 47,
129
+ 115,
130
+ 116,
131
+ 121,
132
+ 108,
133
+ 101
134
+ ]),
135
+ TitleEnd: new Uint8Array([
136
+ 60,
137
+ 47,
138
+ 116,
139
+ 105,
140
+ 116,
141
+ 108,
142
+ 101
143
+ ])
144
+ };
145
+ var Tokenizer = class {
146
+ constructor({ xmlMode = false, decodeEntities = true }, cbs) {
147
+ this.cbs = cbs;
148
+ /** The current state the tokenizer is in. */
149
+ this.state = State.Text;
150
+ /** The read buffer. */
151
+ this.buffer = "";
152
+ /** The beginning of the section that is currently being read. */
153
+ this.sectionStart = 0;
154
+ /** The index within the buffer that we are currently looking at. */
155
+ this.index = 0;
156
+ /** Some behavior, eg. when decoding entities, is done while we are in another state. This keeps track of the other state type. */
157
+ this.baseState = State.Text;
158
+ /** For special parsing behavior inside of script and style tags. */
159
+ this.isSpecial = false;
160
+ /** Indicates whether the tokenizer has been paused. */
161
+ this.running = true;
162
+ /** The offset of the current buffer. */
163
+ this.offset = 0;
164
+ this.currentSequence = void 0;
165
+ this.sequenceIndex = 0;
166
+ this.trieIndex = 0;
167
+ this.trieCurrent = 0;
168
+ /** For named entities, the index of the value. For numeric entities, the code point. */
169
+ this.entityResult = 0;
170
+ this.entityExcess = 0;
171
+ this.xmlMode = xmlMode;
172
+ this.decodeEntities = decodeEntities;
173
+ this.entityTrie = xmlMode ? decode_data_xml_default : decode_data_html_default;
174
+ }
175
+ reset() {
176
+ this.state = State.Text;
177
+ this.buffer = "";
178
+ this.sectionStart = 0;
179
+ this.index = 0;
180
+ this.baseState = State.Text;
181
+ this.currentSequence = void 0;
182
+ this.running = true;
183
+ this.offset = 0;
184
+ }
185
+ write(chunk) {
186
+ this.offset += this.buffer.length;
187
+ this.buffer = chunk;
188
+ this.parse();
189
+ }
190
+ end() {
191
+ if (this.running) this.finish();
192
+ }
193
+ pause() {
194
+ this.running = false;
195
+ }
196
+ resume() {
197
+ this.running = true;
198
+ if (this.index < this.buffer.length + this.offset) this.parse();
199
+ }
200
+ /**
201
+ * The current index within all of the written data.
202
+ */
203
+ getIndex() {
204
+ return this.index;
205
+ }
206
+ /**
207
+ * The start of the current section.
208
+ */
209
+ getSectionStart() {
210
+ return this.sectionStart;
211
+ }
212
+ stateText(c) {
213
+ if (c === CharCodes.Lt || !this.decodeEntities && this.fastForwardTo(CharCodes.Lt)) {
214
+ if (this.index > this.sectionStart) this.cbs.ontext(this.sectionStart, this.index);
215
+ this.state = State.BeforeTagName;
216
+ this.sectionStart = this.index;
217
+ } else if (this.decodeEntities && c === CharCodes.Amp) this.state = State.BeforeEntity;
218
+ }
219
+ stateSpecialStartSequence(c) {
220
+ const isEnd = this.sequenceIndex === this.currentSequence.length;
221
+ if (!(isEnd ? isEndOfTagSection(c) : (c | 32) === this.currentSequence[this.sequenceIndex])) this.isSpecial = false;
222
+ else if (!isEnd) {
223
+ this.sequenceIndex++;
224
+ return;
225
+ }
226
+ this.sequenceIndex = 0;
227
+ this.state = State.InTagName;
228
+ this.stateInTagName(c);
229
+ }
230
+ /** Look for an end tag. For <title> tags, also decode entities. */
231
+ stateInSpecialTag(c) {
232
+ if (this.sequenceIndex === this.currentSequence.length) {
233
+ if (c === CharCodes.Gt || isWhitespace(c)) {
234
+ const endOfText = this.index - this.currentSequence.length;
235
+ if (this.sectionStart < endOfText) {
236
+ const actualIndex = this.index;
237
+ this.index = endOfText;
238
+ this.cbs.ontext(this.sectionStart, endOfText);
239
+ this.index = actualIndex;
240
+ }
241
+ this.isSpecial = false;
242
+ this.sectionStart = endOfText + 2;
243
+ this.stateInClosingTagName(c);
244
+ return;
245
+ }
246
+ this.sequenceIndex = 0;
247
+ }
248
+ if ((c | 32) === this.currentSequence[this.sequenceIndex]) this.sequenceIndex += 1;
249
+ else if (this.sequenceIndex === 0) {
250
+ if (this.currentSequence === Sequences.TitleEnd) {
251
+ if (this.decodeEntities && c === CharCodes.Amp) this.state = State.BeforeEntity;
252
+ } else if (this.fastForwardTo(CharCodes.Lt)) this.sequenceIndex = 1;
253
+ } else this.sequenceIndex = Number(c === CharCodes.Lt);
254
+ }
255
+ stateCDATASequence(c) {
256
+ if (c === Sequences.Cdata[this.sequenceIndex]) {
257
+ if (++this.sequenceIndex === Sequences.Cdata.length) {
258
+ this.state = State.InCommentLike;
259
+ this.currentSequence = Sequences.CdataEnd;
260
+ this.sequenceIndex = 0;
261
+ this.sectionStart = this.index + 1;
262
+ }
263
+ } else {
264
+ this.sequenceIndex = 0;
265
+ this.state = State.InDeclaration;
266
+ this.stateInDeclaration(c);
267
+ }
268
+ }
269
+ /**
270
+ * When we wait for one specific character, we can speed things up
271
+ * by skipping through the buffer until we find it.
272
+ *
273
+ * @returns Whether the character was found.
274
+ */
275
+ fastForwardTo(c) {
276
+ while (++this.index < this.buffer.length + this.offset) if (this.buffer.charCodeAt(this.index - this.offset) === c) return true;
277
+ this.index = this.buffer.length + this.offset - 1;
278
+ return false;
279
+ }
280
+ /**
281
+ * Comments and CDATA end with `-->` and `]]>`.
282
+ *
283
+ * Their common qualities are:
284
+ * - Their end sequences have a distinct character they start with.
285
+ * - That character is then repeated, so we have to check multiple repeats.
286
+ * - All characters but the start character of the sequence can be skipped.
287
+ */
288
+ stateInCommentLike(c) {
289
+ if (c === this.currentSequence[this.sequenceIndex]) {
290
+ if (++this.sequenceIndex === this.currentSequence.length) {
291
+ if (this.currentSequence === Sequences.CdataEnd) this.cbs.oncdata(this.sectionStart, this.index, 2);
292
+ else this.cbs.oncomment(this.sectionStart, this.index, 2);
293
+ this.sequenceIndex = 0;
294
+ this.sectionStart = this.index + 1;
295
+ this.state = State.Text;
296
+ }
297
+ } else if (this.sequenceIndex === 0) {
298
+ if (this.fastForwardTo(this.currentSequence[0])) this.sequenceIndex = 1;
299
+ } else if (c !== this.currentSequence[this.sequenceIndex - 1]) this.sequenceIndex = 0;
300
+ }
301
+ /**
302
+ * HTML only allows ASCII alpha characters (a-z and A-Z) at the beginning of a tag name.
303
+ *
304
+ * XML allows a lot more characters here (@see https://www.w3.org/TR/REC-xml/#NT-NameStartChar).
305
+ * We allow anything that wouldn't end the tag.
306
+ */
307
+ isTagStartChar(c) {
308
+ return this.xmlMode ? !isEndOfTagSection(c) : isASCIIAlpha(c);
309
+ }
310
+ startSpecial(sequence, offset) {
311
+ this.isSpecial = true;
312
+ this.currentSequence = sequence;
313
+ this.sequenceIndex = offset;
314
+ this.state = State.SpecialStartSequence;
315
+ }
316
+ stateBeforeTagName(c) {
317
+ if (c === CharCodes.ExclamationMark) {
318
+ this.state = State.BeforeDeclaration;
319
+ this.sectionStart = this.index + 1;
320
+ } else if (c === CharCodes.Questionmark) {
321
+ this.state = State.InProcessingInstruction;
322
+ this.sectionStart = this.index + 1;
323
+ } else if (this.isTagStartChar(c)) {
324
+ const lower = c | 32;
325
+ this.sectionStart = this.index;
326
+ if (!this.xmlMode && lower === Sequences.TitleEnd[2]) this.startSpecial(Sequences.TitleEnd, 3);
327
+ else this.state = !this.xmlMode && lower === Sequences.ScriptEnd[2] ? State.BeforeSpecialS : State.InTagName;
328
+ } else if (c === CharCodes.Slash) this.state = State.BeforeClosingTagName;
329
+ else {
330
+ this.state = State.Text;
331
+ this.stateText(c);
332
+ }
333
+ }
334
+ stateInTagName(c) {
335
+ if (isEndOfTagSection(c)) {
336
+ this.cbs.onopentagname(this.sectionStart, this.index);
337
+ this.sectionStart = -1;
338
+ this.state = State.BeforeAttributeName;
339
+ this.stateBeforeAttributeName(c);
340
+ }
341
+ }
342
+ stateBeforeClosingTagName(c) {
343
+ if (isWhitespace(c)) {} else if (c === CharCodes.Gt) this.state = State.Text;
344
+ else {
345
+ this.state = this.isTagStartChar(c) ? State.InClosingTagName : State.InSpecialComment;
346
+ this.sectionStart = this.index;
347
+ }
348
+ }
349
+ stateInClosingTagName(c) {
350
+ if (c === CharCodes.Gt || isWhitespace(c)) {
351
+ this.cbs.onclosetag(this.sectionStart, this.index);
352
+ this.sectionStart = -1;
353
+ this.state = State.AfterClosingTagName;
354
+ this.stateAfterClosingTagName(c);
355
+ }
356
+ }
357
+ stateAfterClosingTagName(c) {
358
+ if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
359
+ this.state = State.Text;
360
+ this.baseState = State.Text;
361
+ this.sectionStart = this.index + 1;
362
+ }
363
+ }
364
+ stateBeforeAttributeName(c) {
365
+ if (c === CharCodes.Gt) {
366
+ this.cbs.onopentagend(this.index);
367
+ if (this.isSpecial) {
368
+ this.state = State.InSpecialTag;
369
+ this.sequenceIndex = 0;
370
+ } else this.state = State.Text;
371
+ this.baseState = this.state;
372
+ this.sectionStart = this.index + 1;
373
+ } else if (c === CharCodes.Slash) this.state = State.InSelfClosingTag;
374
+ else if (!isWhitespace(c)) {
375
+ this.state = State.InAttributeName;
376
+ this.sectionStart = this.index;
377
+ }
378
+ }
379
+ stateInSelfClosingTag(c) {
380
+ if (c === CharCodes.Gt) {
381
+ this.cbs.onselfclosingtag(this.index);
382
+ this.state = State.Text;
383
+ this.baseState = State.Text;
384
+ this.sectionStart = this.index + 1;
385
+ this.isSpecial = false;
386
+ } else if (!isWhitespace(c)) {
387
+ this.state = State.BeforeAttributeName;
388
+ this.stateBeforeAttributeName(c);
389
+ }
390
+ }
391
+ stateInAttributeName(c) {
392
+ if (c === CharCodes.Eq || isEndOfTagSection(c)) {
393
+ this.cbs.onattribname(this.sectionStart, this.index);
394
+ this.sectionStart = -1;
395
+ this.state = State.AfterAttributeName;
396
+ this.stateAfterAttributeName(c);
397
+ }
398
+ }
399
+ stateAfterAttributeName(c) {
400
+ if (c === CharCodes.Eq) this.state = State.BeforeAttributeValue;
401
+ else if (c === CharCodes.Slash || c === CharCodes.Gt) {
402
+ this.cbs.onattribend(QuoteType.NoValue, this.index);
403
+ this.state = State.BeforeAttributeName;
404
+ this.stateBeforeAttributeName(c);
405
+ } else if (!isWhitespace(c)) {
406
+ this.cbs.onattribend(QuoteType.NoValue, this.index);
407
+ this.state = State.InAttributeName;
408
+ this.sectionStart = this.index;
409
+ }
410
+ }
411
+ stateBeforeAttributeValue(c) {
412
+ if (c === CharCodes.DoubleQuote) {
413
+ this.state = State.InAttributeValueDq;
414
+ this.sectionStart = this.index + 1;
415
+ } else if (c === CharCodes.SingleQuote) {
416
+ this.state = State.InAttributeValueSq;
417
+ this.sectionStart = this.index + 1;
418
+ } else if (!isWhitespace(c)) {
419
+ this.sectionStart = this.index;
420
+ this.state = State.InAttributeValueNq;
421
+ this.stateInAttributeValueNoQuotes(c);
422
+ }
423
+ }
424
+ handleInAttributeValue(c, quote) {
425
+ if (c === quote || !this.decodeEntities && this.fastForwardTo(quote)) {
426
+ this.cbs.onattribdata(this.sectionStart, this.index);
427
+ this.sectionStart = -1;
428
+ this.cbs.onattribend(quote === CharCodes.DoubleQuote ? QuoteType.Double : QuoteType.Single, this.index);
429
+ this.state = State.BeforeAttributeName;
430
+ } else if (this.decodeEntities && c === CharCodes.Amp) {
431
+ this.baseState = this.state;
432
+ this.state = State.BeforeEntity;
433
+ }
434
+ }
435
+ stateInAttributeValueDoubleQuotes(c) {
436
+ this.handleInAttributeValue(c, CharCodes.DoubleQuote);
437
+ }
438
+ stateInAttributeValueSingleQuotes(c) {
439
+ this.handleInAttributeValue(c, CharCodes.SingleQuote);
440
+ }
441
+ stateInAttributeValueNoQuotes(c) {
442
+ if (isWhitespace(c) || c === CharCodes.Gt) {
443
+ this.cbs.onattribdata(this.sectionStart, this.index);
444
+ this.sectionStart = -1;
445
+ this.cbs.onattribend(QuoteType.Unquoted, this.index);
446
+ this.state = State.BeforeAttributeName;
447
+ this.stateBeforeAttributeName(c);
448
+ } else if (this.decodeEntities && c === CharCodes.Amp) {
449
+ this.baseState = this.state;
450
+ this.state = State.BeforeEntity;
451
+ }
452
+ }
453
+ stateBeforeDeclaration(c) {
454
+ if (c === CharCodes.OpeningSquareBracket) {
455
+ this.state = State.CDATASequence;
456
+ this.sequenceIndex = 0;
457
+ } else this.state = c === CharCodes.Dash ? State.BeforeComment : State.InDeclaration;
458
+ }
459
+ stateInDeclaration(c) {
460
+ if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
461
+ this.cbs.ondeclaration(this.sectionStart, this.index);
462
+ this.state = State.Text;
463
+ this.sectionStart = this.index + 1;
464
+ }
465
+ }
466
+ stateInProcessingInstruction(c) {
467
+ if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
468
+ this.cbs.onprocessinginstruction(this.sectionStart, this.index);
469
+ this.state = State.Text;
470
+ this.sectionStart = this.index + 1;
471
+ }
472
+ }
473
+ stateBeforeComment(c) {
474
+ if (c === CharCodes.Dash) {
475
+ this.state = State.InCommentLike;
476
+ this.currentSequence = Sequences.CommentEnd;
477
+ this.sequenceIndex = 2;
478
+ this.sectionStart = this.index + 1;
479
+ } else this.state = State.InDeclaration;
480
+ }
481
+ stateInSpecialComment(c) {
482
+ if (c === CharCodes.Gt || this.fastForwardTo(CharCodes.Gt)) {
483
+ this.cbs.oncomment(this.sectionStart, this.index, 0);
484
+ this.state = State.Text;
485
+ this.sectionStart = this.index + 1;
486
+ }
487
+ }
488
+ stateBeforeSpecialS(c) {
489
+ const lower = c | 32;
490
+ if (lower === Sequences.ScriptEnd[3]) this.startSpecial(Sequences.ScriptEnd, 4);
491
+ else if (lower === Sequences.StyleEnd[3]) this.startSpecial(Sequences.StyleEnd, 4);
492
+ else {
493
+ this.state = State.InTagName;
494
+ this.stateInTagName(c);
495
+ }
496
+ }
497
+ stateBeforeEntity(c) {
498
+ this.entityExcess = 1;
499
+ this.entityResult = 0;
500
+ if (c === CharCodes.Number) this.state = State.BeforeNumericEntity;
501
+ else if (c === CharCodes.Amp) {} else {
502
+ this.trieIndex = 0;
503
+ this.trieCurrent = this.entityTrie[0];
504
+ this.state = State.InNamedEntity;
505
+ this.stateInNamedEntity(c);
506
+ }
507
+ }
508
+ stateInNamedEntity(c) {
509
+ this.entityExcess += 1;
510
+ this.trieIndex = determineBranch(this.entityTrie, this.trieCurrent, this.trieIndex + 1, c);
511
+ if (this.trieIndex < 0) {
512
+ this.emitNamedEntity();
513
+ this.index--;
514
+ return;
515
+ }
516
+ this.trieCurrent = this.entityTrie[this.trieIndex];
517
+ const masked = this.trieCurrent & BinTrieFlags.VALUE_LENGTH;
518
+ if (masked) {
519
+ const valueLength = (masked >> 14) - 1;
520
+ if (!this.allowLegacyEntity() && c !== CharCodes.Semi) this.trieIndex += valueLength;
521
+ else {
522
+ const entityStart = this.index - this.entityExcess + 1;
523
+ if (entityStart > this.sectionStart) this.emitPartial(this.sectionStart, entityStart);
524
+ this.entityResult = this.trieIndex;
525
+ this.trieIndex += valueLength;
526
+ this.entityExcess = 0;
527
+ this.sectionStart = this.index + 1;
528
+ if (valueLength === 0) this.emitNamedEntity();
529
+ }
530
+ }
531
+ }
532
+ emitNamedEntity() {
533
+ this.state = this.baseState;
534
+ if (this.entityResult === 0) return;
535
+ switch ((this.entityTrie[this.entityResult] & BinTrieFlags.VALUE_LENGTH) >> 14) {
536
+ case 1:
537
+ this.emitCodePoint(this.entityTrie[this.entityResult] & ~BinTrieFlags.VALUE_LENGTH);
538
+ break;
539
+ case 2:
540
+ this.emitCodePoint(this.entityTrie[this.entityResult + 1]);
541
+ break;
542
+ case 3:
543
+ this.emitCodePoint(this.entityTrie[this.entityResult + 1]);
544
+ this.emitCodePoint(this.entityTrie[this.entityResult + 2]);
545
+ }
546
+ }
547
+ stateBeforeNumericEntity(c) {
548
+ if ((c | 32) === CharCodes.LowerX) {
549
+ this.entityExcess++;
550
+ this.state = State.InHexEntity;
551
+ } else {
552
+ this.state = State.InNumericEntity;
553
+ this.stateInNumericEntity(c);
554
+ }
555
+ }
556
+ emitNumericEntity(strict) {
557
+ const entityStart = this.index - this.entityExcess - 1;
558
+ if (entityStart + 2 + Number(this.state === State.InHexEntity) !== this.index) {
559
+ if (entityStart > this.sectionStart) this.emitPartial(this.sectionStart, entityStart);
560
+ this.sectionStart = this.index + Number(strict);
561
+ this.emitCodePoint(replaceCodePoint(this.entityResult));
562
+ }
563
+ this.state = this.baseState;
564
+ }
565
+ stateInNumericEntity(c) {
566
+ if (c === CharCodes.Semi) this.emitNumericEntity(true);
567
+ else if (isNumber(c)) {
568
+ this.entityResult = this.entityResult * 10 + (c - CharCodes.Zero);
569
+ this.entityExcess++;
570
+ } else {
571
+ if (this.allowLegacyEntity()) this.emitNumericEntity(false);
572
+ else this.state = this.baseState;
573
+ this.index--;
574
+ }
575
+ }
576
+ stateInHexEntity(c) {
577
+ if (c === CharCodes.Semi) this.emitNumericEntity(true);
578
+ else if (isNumber(c)) {
579
+ this.entityResult = this.entityResult * 16 + (c - CharCodes.Zero);
580
+ this.entityExcess++;
581
+ } else if (isHexDigit(c)) {
582
+ this.entityResult = this.entityResult * 16 + ((c | 32) - CharCodes.LowerA + 10);
583
+ this.entityExcess++;
584
+ } else {
585
+ if (this.allowLegacyEntity()) this.emitNumericEntity(false);
586
+ else this.state = this.baseState;
587
+ this.index--;
588
+ }
589
+ }
590
+ allowLegacyEntity() {
591
+ return !this.xmlMode && (this.baseState === State.Text || this.baseState === State.InSpecialTag);
592
+ }
593
+ /**
594
+ * Remove data that has already been consumed from the buffer.
595
+ */
596
+ cleanup() {
597
+ if (this.running && this.sectionStart !== this.index) {
598
+ if (this.state === State.Text || this.state === State.InSpecialTag && this.sequenceIndex === 0) {
599
+ this.cbs.ontext(this.sectionStart, this.index);
600
+ this.sectionStart = this.index;
601
+ } else if (this.state === State.InAttributeValueDq || this.state === State.InAttributeValueSq || this.state === State.InAttributeValueNq) {
602
+ this.cbs.onattribdata(this.sectionStart, this.index);
603
+ this.sectionStart = this.index;
604
+ }
605
+ }
606
+ }
607
+ shouldContinue() {
608
+ return this.index < this.buffer.length + this.offset && this.running;
609
+ }
610
+ /**
611
+ * Iterates through the buffer, calling the function corresponding to the current state.
612
+ *
613
+ * States that are more likely to be hit are higher up, as a performance improvement.
614
+ */
615
+ parse() {
616
+ while (this.shouldContinue()) {
617
+ const c = this.buffer.charCodeAt(this.index - this.offset);
618
+ switch (this.state) {
619
+ case State.Text:
620
+ this.stateText(c);
621
+ break;
622
+ case State.SpecialStartSequence:
623
+ this.stateSpecialStartSequence(c);
624
+ break;
625
+ case State.InSpecialTag:
626
+ this.stateInSpecialTag(c);
627
+ break;
628
+ case State.CDATASequence:
629
+ this.stateCDATASequence(c);
630
+ break;
631
+ case State.InAttributeValueDq:
632
+ this.stateInAttributeValueDoubleQuotes(c);
633
+ break;
634
+ case State.InAttributeName:
635
+ this.stateInAttributeName(c);
636
+ break;
637
+ case State.InCommentLike:
638
+ this.stateInCommentLike(c);
639
+ break;
640
+ case State.InSpecialComment:
641
+ this.stateInSpecialComment(c);
642
+ break;
643
+ case State.BeforeAttributeName:
644
+ this.stateBeforeAttributeName(c);
645
+ break;
646
+ case State.InTagName:
647
+ this.stateInTagName(c);
648
+ break;
649
+ case State.InClosingTagName:
650
+ this.stateInClosingTagName(c);
651
+ break;
652
+ case State.BeforeTagName:
653
+ this.stateBeforeTagName(c);
654
+ break;
655
+ case State.AfterAttributeName:
656
+ this.stateAfterAttributeName(c);
657
+ break;
658
+ case State.InAttributeValueSq:
659
+ this.stateInAttributeValueSingleQuotes(c);
660
+ break;
661
+ case State.BeforeAttributeValue:
662
+ this.stateBeforeAttributeValue(c);
663
+ break;
664
+ case State.BeforeClosingTagName:
665
+ this.stateBeforeClosingTagName(c);
666
+ break;
667
+ case State.AfterClosingTagName:
668
+ this.stateAfterClosingTagName(c);
669
+ break;
670
+ case State.BeforeSpecialS:
671
+ this.stateBeforeSpecialS(c);
672
+ break;
673
+ case State.InAttributeValueNq:
674
+ this.stateInAttributeValueNoQuotes(c);
675
+ break;
676
+ case State.InSelfClosingTag:
677
+ this.stateInSelfClosingTag(c);
678
+ break;
679
+ case State.InDeclaration:
680
+ this.stateInDeclaration(c);
681
+ break;
682
+ case State.BeforeDeclaration:
683
+ this.stateBeforeDeclaration(c);
684
+ break;
685
+ case State.BeforeComment:
686
+ this.stateBeforeComment(c);
687
+ break;
688
+ case State.InProcessingInstruction:
689
+ this.stateInProcessingInstruction(c);
690
+ break;
691
+ case State.InNamedEntity:
692
+ this.stateInNamedEntity(c);
693
+ break;
694
+ case State.BeforeEntity:
695
+ this.stateBeforeEntity(c);
696
+ break;
697
+ case State.InHexEntity:
698
+ this.stateInHexEntity(c);
699
+ break;
700
+ case State.InNumericEntity:
701
+ this.stateInNumericEntity(c);
702
+ break;
703
+ default: this.stateBeforeNumericEntity(c);
704
+ }
705
+ this.index++;
706
+ }
707
+ this.cleanup();
708
+ }
709
+ finish() {
710
+ if (this.state === State.InNamedEntity) this.emitNamedEntity();
711
+ if (this.sectionStart < this.index) this.handleTrailingData();
712
+ this.cbs.onend();
713
+ }
714
+ /** Handle any trailing data. */
715
+ handleTrailingData() {
716
+ const endIndex = this.buffer.length + this.offset;
717
+ if (this.state === State.InCommentLike) {
718
+ if (this.currentSequence === Sequences.CdataEnd) this.cbs.oncdata(this.sectionStart, endIndex, 0);
719
+ else this.cbs.oncomment(this.sectionStart, endIndex, 0);
720
+ } else if (this.state === State.InNumericEntity && this.allowLegacyEntity()) this.emitNumericEntity(false);
721
+ else if (this.state === State.InHexEntity && this.allowLegacyEntity()) this.emitNumericEntity(false);
722
+ else if (this.state === State.InTagName || this.state === State.BeforeAttributeName || this.state === State.BeforeAttributeValue || this.state === State.AfterAttributeName || this.state === State.InAttributeName || this.state === State.InAttributeValueSq || this.state === State.InAttributeValueDq || this.state === State.InAttributeValueNq || this.state === State.InClosingTagName) {} else this.cbs.ontext(this.sectionStart, endIndex);
723
+ }
724
+ emitPartial(start, endIndex) {
725
+ if (this.baseState !== State.Text && this.baseState !== State.InSpecialTag) this.cbs.onattribdata(start, endIndex);
726
+ else this.cbs.ontext(start, endIndex);
727
+ }
728
+ emitCodePoint(cp) {
729
+ if (this.baseState !== State.Text && this.baseState !== State.InSpecialTag) this.cbs.onattribentity(cp);
730
+ else this.cbs.ontextentity(cp);
731
+ }
732
+ };
733
+ //#endregion
734
+ export { QuoteType, Tokenizer as default };
735
+
736
+ //# sourceMappingURL=Tokenizer.js.map