@peculiar/certificates-viewer 4.3.1 → 4.3.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 (362) hide show
  1. package/components/attribute-certificate-viewer.js +5 -5
  2. package/components/attribute-certificate-viewer.js.map +1 -1
  3. package/components/attribute.js +1 -1
  4. package/components/certificate-chain-viewer.js +66 -0
  5. package/components/certificate-chain-viewer.js.map +1 -0
  6. package/components/certificate-viewer.js +5 -5
  7. package/components/certificate-viewer.js.map +1 -1
  8. package/components/circular-progress.js +3 -3
  9. package/components/crl-viewer.js +5 -5
  10. package/components/crl-viewer.js.map +1 -1
  11. package/components/download.js +185 -45
  12. package/components/download.js.map +1 -1
  13. package/components/highlight-words.js +1 -1
  14. package/components/index2.js +1 -1
  15. package/components/issuer_name.js +1 -1
  16. package/components/miscellaneous.js +1 -1
  17. package/components/miscellaneous.js.map +1 -1
  18. package/components/peculiar-certificate-chain-viewer.d.ts +11 -0
  19. package/components/peculiar-certificate-chain-viewer.js +11 -0
  20. package/components/peculiar-certificate-chain-viewer.js.map +1 -0
  21. package/components/peculiar-certificate-decoder.js +105 -19
  22. package/components/peculiar-certificate-decoder.js.map +1 -1
  23. package/components/peculiar-certificates-viewer.js +2 -2
  24. package/components/peculiar-certificates-viewer.js.map +1 -1
  25. package/components/peculiar-text-hider.js +1 -1
  26. package/components/pkcs10_certificate_request.js +5 -5
  27. package/components/pkcs10_certificate_request.js.map +1 -1
  28. package/components/subject_name.js +1 -1
  29. package/dist/cjs/{actions-789906f5.js → actions-64ce3326.js} +2 -2
  30. package/dist/cjs/{actions-789906f5.js.map → actions-64ce3326.js.map} +1 -1
  31. package/dist/cjs/{arrow_top-76e4261e.js → arrow_top-b9b9f280.js} +2 -2
  32. package/dist/cjs/{arrow_top-76e4261e.js.map → arrow_top-b9b9f280.js.map} +1 -1
  33. package/dist/cjs/{button-87086210.js → button-61bb8305.js} +2 -2
  34. package/dist/cjs/{button-87086210.js.map → button-61bb8305.js.map} +1 -1
  35. package/dist/cjs/{certification_request-ad267278.js → certification_request-393a843d.js} +207 -65
  36. package/dist/cjs/certification_request-393a843d.js.map +1 -0
  37. package/dist/cjs/{cross-bd099933.js → cross-3aeffd04.js} +2 -2
  38. package/dist/cjs/{cross-bd099933.js.map → cross-3aeffd04.js.map} +1 -1
  39. package/dist/cjs/{download-820d66ba.js → download-c2836546.js} +2 -2
  40. package/dist/cjs/{download-820d66ba.js.map → download-c2836546.js.map} +1 -1
  41. package/dist/cjs/index-484a84a0.js +2113 -0
  42. package/dist/cjs/index-484a84a0.js.map +1 -0
  43. package/dist/cjs/index.cjs.js +9 -9
  44. package/dist/cjs/{link-a3d3799d.js → link-dad7195a.js} +3 -3
  45. package/dist/cjs/{link-a3d3799d.js.map → link-dad7195a.js.map} +1 -1
  46. package/dist/cjs/loader.cjs.js +2 -2
  47. package/dist/cjs/{miscellaneous-67439e59.js → miscellaneous-ca06fb81.js} +6 -6
  48. package/dist/cjs/{miscellaneous-67439e59.js.map → miscellaneous-ca06fb81.js.map} +1 -1
  49. package/dist/cjs/{peculiar-attribute-certificate-viewer_3.cjs.entry.js → peculiar-attribute-certificate-viewer_4.cjs.entry.js} +40 -9
  50. package/dist/cjs/peculiar-attribute-certificate-viewer_4.cjs.entry.js.map +1 -0
  51. package/dist/cjs/peculiar-button-menu_3.cjs.entry.js +7 -7
  52. package/dist/cjs/peculiar-certificate-decoder.cjs.entry.js +101 -21
  53. package/dist/cjs/peculiar-certificate-decoder.cjs.entry.js.map +1 -1
  54. package/dist/cjs/peculiar-certificate-viewer.cjs.entry.js +7 -7
  55. package/dist/cjs/peculiar-certificates-viewer.cjs.entry.js +8 -8
  56. package/dist/cjs/peculiar-certificates-viewer.cjs.entry.js.map +1 -1
  57. package/dist/cjs/peculiar-text-hider.cjs.entry.js +4 -4
  58. package/dist/cjs/peculiar.cjs.js +10 -10
  59. package/dist/cjs/peculiar.cjs.js.map +1 -1
  60. package/dist/cjs/{pkcs10_certificate_request-64898c88.js → pkcs10_certificate_request-56990e4f.js} +6 -6
  61. package/dist/cjs/pkcs10_certificate_request-56990e4f.js.map +1 -0
  62. package/dist/cjs/{x509_certificate-4b0894c2.js → x509_certificate-d162984c.js} +6 -6
  63. package/dist/cjs/x509_certificate-d162984c.js.map +1 -0
  64. package/dist/cjs/{x509_crl-fc8d41a1.js → x509_crl-13322e13.js} +11 -11
  65. package/dist/cjs/x509_crl-13322e13.js.map +1 -0
  66. package/dist/collection/collection-manifest.json +3 -2
  67. package/dist/collection/components/attribute-certificate-viewer/attribute-certificate-viewer.js +14 -0
  68. package/dist/collection/components/attribute-certificate-viewer/attribute-certificate-viewer.js.map +1 -1
  69. package/dist/collection/components/button-menu/button-menu.js +2 -0
  70. package/dist/collection/components/button-menu/button-menu.js.map +1 -1
  71. package/dist/collection/components/certificate-chain-viewer/certificate-chain-viewer.css +1019 -0
  72. package/dist/collection/components/certificate-chain-viewer/certificate-chain-viewer.js +101 -0
  73. package/dist/collection/components/certificate-chain-viewer/certificate-chain-viewer.js.map +1 -0
  74. package/dist/collection/components/certificate-decoder/certificate-decoder.css +1 -4
  75. package/dist/collection/components/certificate-decoder/certificate-decoder.js +40 -18
  76. package/dist/collection/components/certificate-decoder/certificate-decoder.js.map +1 -1
  77. package/dist/collection/components/certificate-details-parts/miscellaneous.js.map +1 -1
  78. package/dist/collection/components/certificate-viewer/certificate-viewer.js +16 -0
  79. package/dist/collection/components/certificate-viewer/certificate-viewer.js.map +1 -1
  80. package/dist/collection/components/certificates-viewer/certificates-viewer.js +9 -1
  81. package/dist/collection/components/certificates-viewer/certificates-viewer.js.map +1 -1
  82. package/dist/collection/components/circular-progress/circular-progress.js +7 -3
  83. package/dist/collection/components/circular-progress/circular-progress.js.map +1 -1
  84. package/dist/collection/components/crl-viewer/crl-viewer.js +12 -0
  85. package/dist/collection/components/crl-viewer/crl-viewer.js.map +1 -1
  86. package/dist/collection/components/csr-viewer/csr-viewer.js +10 -0
  87. package/dist/collection/components/csr-viewer/csr-viewer.js.map +1 -1
  88. package/dist/collection/components/highlight-words/highlight-words.js +3 -1
  89. package/dist/collection/components/highlight-words/highlight-words.js.map +1 -1
  90. package/dist/collection/components/text-hider/text-hider.js +1 -1
  91. package/dist/collection/crypto/index.js +1 -0
  92. package/dist/collection/crypto/index.js.map +1 -1
  93. package/dist/collection/crypto/pem_converter.js +169 -0
  94. package/dist/collection/crypto/pem_converter.js.map +1 -0
  95. package/dist/collection/crypto/pkcs10_certificate_request.js +6 -5
  96. package/dist/collection/crypto/pkcs10_certificate_request.js.map +1 -1
  97. package/dist/collection/crypto/utils.js +18 -21
  98. package/dist/collection/crypto/utils.js.map +1 -1
  99. package/dist/collection/crypto/x509_attribute_certificate.js +6 -5
  100. package/dist/collection/crypto/x509_attribute_certificate.js.map +1 -1
  101. package/dist/collection/crypto/x509_certificate.js +6 -5
  102. package/dist/collection/crypto/x509_certificate.js.map +1 -1
  103. package/dist/collection/crypto/x509_certificates.js +69 -0
  104. package/dist/collection/crypto/x509_certificates.js.map +1 -0
  105. package/dist/collection/crypto/x509_crl.js +6 -5
  106. package/dist/collection/crypto/x509_crl.js.map +1 -1
  107. package/dist/collection/utils/index.js +0 -2
  108. package/dist/collection/utils/index.js.map +1 -1
  109. package/dist/collection/www-copy/index.js +123 -121
  110. package/dist/esm/{actions-aebcbc9d.js → actions-2e39a3b9.js} +2 -2
  111. package/dist/esm/{actions-aebcbc9d.js.map → actions-2e39a3b9.js.map} +1 -1
  112. package/dist/esm/{arrow_top-aee1ee02.js → arrow_top-72c7543a.js} +2 -2
  113. package/dist/esm/{arrow_top-aee1ee02.js.map → arrow_top-72c7543a.js.map} +1 -1
  114. package/dist/esm/{button-a2fabf9a.js → button-e0909687.js} +2 -2
  115. package/dist/esm/{button-a2fabf9a.js.map → button-e0909687.js.map} +1 -1
  116. package/dist/esm/{certification_request-a4699dcf.js → certification_request-714bd438.js} +186 -46
  117. package/dist/esm/certification_request-714bd438.js.map +1 -0
  118. package/dist/esm/{cross-1377606f.js → cross-0c62835f.js} +2 -2
  119. package/dist/esm/{cross-1377606f.js.map → cross-0c62835f.js.map} +1 -1
  120. package/dist/esm/{download-14dc1047.js → download-5686d86f.js} +2 -2
  121. package/dist/esm/{download-14dc1047.js.map → download-5686d86f.js.map} +1 -1
  122. package/dist/esm/index-38365508.js +2084 -0
  123. package/dist/esm/index-38365508.js.map +1 -0
  124. package/dist/esm/index.js +9 -9
  125. package/dist/esm/{link-7e4e9060.js → link-09718951.js} +3 -3
  126. package/dist/esm/{link-7e4e9060.js.map → link-09718951.js.map} +1 -1
  127. package/dist/esm/loader.js +3 -3
  128. package/dist/esm/{miscellaneous-ba1fd2bd.js → miscellaneous-0657d00e.js} +6 -6
  129. package/dist/esm/{miscellaneous-ba1fd2bd.js.map → miscellaneous-0657d00e.js.map} +1 -1
  130. package/dist/esm/{peculiar-attribute-certificate-viewer_3.entry.js → peculiar-attribute-certificate-viewer_4.entry.js} +40 -10
  131. package/dist/esm/peculiar-attribute-certificate-viewer_4.entry.js.map +1 -0
  132. package/dist/esm/peculiar-button-menu_3.entry.js +7 -7
  133. package/dist/esm/peculiar-certificate-decoder.entry.js +101 -21
  134. package/dist/esm/peculiar-certificate-decoder.entry.js.map +1 -1
  135. package/dist/esm/peculiar-certificate-viewer.entry.js +7 -7
  136. package/dist/esm/peculiar-certificates-viewer.entry.js +8 -8
  137. package/dist/esm/peculiar-certificates-viewer.entry.js.map +1 -1
  138. package/dist/esm/peculiar-text-hider.entry.js +4 -4
  139. package/dist/esm/peculiar.js +11 -11
  140. package/dist/esm/peculiar.js.map +1 -1
  141. package/dist/esm/{pkcs10_certificate_request-785a4794.js → pkcs10_certificate_request-d3871050.js} +6 -6
  142. package/dist/esm/pkcs10_certificate_request-d3871050.js.map +1 -0
  143. package/dist/esm/{x509_certificate-05a23c0e.js → x509_certificate-d0d0c5c1.js} +6 -6
  144. package/dist/esm/x509_certificate-d0d0c5c1.js.map +1 -0
  145. package/dist/esm/{x509_crl-26081461.js → x509_crl-e837f4c3.js} +11 -11
  146. package/dist/esm/x509_crl-e837f4c3.js.map +1 -0
  147. package/dist/esm-es5/{actions-aebcbc9d.js → actions-2e39a3b9.js} +2 -2
  148. package/dist/esm-es5/{actions-aebcbc9d.js.map → actions-2e39a3b9.js.map} +1 -1
  149. package/dist/esm-es5/app-globals-5e9b67e0.js.map +1 -1
  150. package/dist/esm-es5/{arrow_top-aee1ee02.js → arrow_top-72c7543a.js} +2 -2
  151. package/dist/esm-es5/{arrow_top-aee1ee02.js.map → arrow_top-72c7543a.js.map} +1 -1
  152. package/dist/esm-es5/{button-a2fabf9a.js → button-e0909687.js} +2 -2
  153. package/dist/esm-es5/{button-a2fabf9a.js.map → button-e0909687.js.map} +1 -1
  154. package/dist/esm-es5/{certification_request-a4699dcf.js → certification_request-714bd438.js} +19 -12
  155. package/dist/esm-es5/certification_request-714bd438.js.map +1 -0
  156. package/dist/esm-es5/{cross-1377606f.js → cross-0c62835f.js} +2 -2
  157. package/dist/esm-es5/{cross-1377606f.js.map → cross-0c62835f.js.map} +1 -1
  158. package/dist/esm-es5/{download-14dc1047.js → download-5686d86f.js} +2 -2
  159. package/dist/esm-es5/{download-14dc1047.js.map → download-5686d86f.js.map} +1 -1
  160. package/dist/esm-es5/index-38365508.js +6 -0
  161. package/dist/esm-es5/index-38365508.js.map +1 -0
  162. package/dist/esm-es5/index.js +1 -1
  163. package/dist/esm-es5/index.js.map +1 -1
  164. package/dist/esm-es5/{link-7e4e9060.js → link-09718951.js} +3 -3
  165. package/dist/esm-es5/{link-7e4e9060.js.map → link-09718951.js.map} +1 -1
  166. package/dist/esm-es5/loader.js +2 -2
  167. package/dist/esm-es5/loader.js.map +1 -1
  168. package/dist/esm-es5/{miscellaneous-ba1fd2bd.js → miscellaneous-0657d00e.js} +2 -2
  169. package/dist/esm-es5/{miscellaneous-ba1fd2bd.js.map → miscellaneous-0657d00e.js.map} +1 -1
  170. package/dist/esm-es5/peculiar-attribute-certificate-viewer_4.entry.js +110 -0
  171. package/dist/esm-es5/peculiar-attribute-certificate-viewer_4.entry.js.map +1 -0
  172. package/dist/esm-es5/peculiar-button-menu_3.entry.js +1 -1
  173. package/dist/esm-es5/peculiar-button-menu_3.entry.js.map +1 -1
  174. package/dist/esm-es5/peculiar-certificate-decoder.entry.js +2 -2
  175. package/dist/esm-es5/peculiar-certificate-decoder.entry.js.map +1 -1
  176. package/dist/esm-es5/peculiar-certificate-viewer.entry.js +1 -1
  177. package/dist/esm-es5/peculiar-certificate-viewer.entry.js.map +1 -1
  178. package/dist/esm-es5/peculiar-certificates-viewer.entry.js +2 -2
  179. package/dist/esm-es5/peculiar-certificates-viewer.entry.js.map +1 -1
  180. package/dist/esm-es5/peculiar-text-hider.entry.js +1 -1
  181. package/dist/esm-es5/peculiar-text-hider.entry.js.map +1 -1
  182. package/dist/esm-es5/peculiar.js +2 -2
  183. package/dist/esm-es5/peculiar.js.map +1 -1
  184. package/dist/esm-es5/{pkcs10_certificate_request-785a4794.js → pkcs10_certificate_request-d3871050.js} +3 -3
  185. package/dist/esm-es5/pkcs10_certificate_request-d3871050.js.map +1 -0
  186. package/dist/esm-es5/read_file-bb0b1450.js.map +1 -1
  187. package/dist/esm-es5/x509_certificate-d0d0c5c1.js +12 -0
  188. package/dist/esm-es5/x509_certificate-d0d0c5c1.js.map +1 -0
  189. package/dist/esm-es5/x509_crl-e837f4c3.js +19 -0
  190. package/dist/esm-es5/x509_crl-e837f4c3.js.map +1 -0
  191. package/dist/peculiar/index.esm.js +1 -1
  192. package/dist/peculiar/index.esm.js.map +1 -1
  193. package/dist/peculiar/{p-5a662d6f.system.js → p-02529999.system.js} +2 -2
  194. package/dist/peculiar/{p-5a662d6f.system.js.map → p-02529999.system.js.map} +1 -1
  195. package/dist/peculiar/{p-9263e7ee.system.entry.js → p-04228f9c.system.entry.js} +3 -3
  196. package/dist/peculiar/{p-9263e7ee.system.entry.js.map → p-04228f9c.system.entry.js.map} +1 -1
  197. package/dist/peculiar/{p-1566ad92.system.entry.js → p-12bc3ebc.system.entry.js} +2 -2
  198. package/dist/peculiar/{p-1566ad92.system.entry.js.map → p-12bc3ebc.system.entry.js.map} +1 -1
  199. package/dist/peculiar/{p-afbd1c8e.entry.js → p-161f7f97.entry.js} +2 -2
  200. package/dist/peculiar/{p-afbd1c8e.entry.js.map → p-161f7f97.entry.js.map} +1 -1
  201. package/dist/peculiar/p-25a532a3.js.map +1 -1
  202. package/dist/peculiar/p-32cf293c.system.js +5 -0
  203. package/dist/peculiar/p-32cf293c.system.js.map +1 -0
  204. package/dist/peculiar/{p-2bc2abea.system.js → p-35cd359e.system.js} +2 -2
  205. package/dist/peculiar/{p-2bc2abea.system.js.map → p-35cd359e.system.js.map} +1 -1
  206. package/dist/peculiar/p-39bbe0b9.system.entry.js +5 -0
  207. package/dist/peculiar/{p-b5389885.system.entry.js.map → p-39bbe0b9.system.entry.js.map} +1 -1
  208. package/dist/peculiar/p-41eacbcd.system.entry.js +111 -0
  209. package/dist/peculiar/p-41eacbcd.system.entry.js.map +1 -0
  210. package/dist/peculiar/p-47b7dd9e.entry.js +110 -0
  211. package/dist/peculiar/p-47b7dd9e.entry.js.map +1 -0
  212. package/dist/peculiar/{p-8bbee8f4.system.js → p-4ee5beee.system.js} +2 -2
  213. package/dist/peculiar/{p-8bbee8f4.system.js.map → p-4ee5beee.system.js.map} +1 -1
  214. package/dist/peculiar/p-55303453.system.js.map +1 -1
  215. package/dist/peculiar/{p-ae91d778.js → p-562652dd.js} +2 -2
  216. package/dist/peculiar/{p-ae91d778.js.map → p-562652dd.js.map} +1 -1
  217. package/dist/peculiar/p-5b4db88b.system.js +5 -0
  218. package/dist/peculiar/p-5b4db88b.system.js.map +1 -0
  219. package/dist/peculiar/{p-e4ad4f13.system.entry.js → p-67452b74.system.entry.js} +2 -2
  220. package/dist/peculiar/{p-e4ad4f13.system.entry.js.map → p-67452b74.system.entry.js.map} +1 -1
  221. package/dist/peculiar/p-684b7f0f.system.js +142 -0
  222. package/dist/peculiar/p-684b7f0f.system.js.map +1 -0
  223. package/dist/peculiar/{p-bafd67f3.entry.js → p-6eb92f5a.entry.js} +2 -2
  224. package/dist/peculiar/{p-bafd67f3.entry.js.map → p-6eb92f5a.entry.js.map} +1 -1
  225. package/dist/peculiar/p-8dd6d1ee.entry.js +5 -0
  226. package/dist/peculiar/p-8dd6d1ee.entry.js.map +1 -0
  227. package/dist/peculiar/{p-a9487007.js → p-90c3a063.js} +2 -2
  228. package/dist/peculiar/{p-a9487007.js.map → p-90c3a063.js.map} +1 -1
  229. package/dist/peculiar/{p-6e2ad7eb.js → p-90f461c0.js} +13 -13
  230. package/dist/peculiar/{p-6e2ad7eb.js.map → p-90f461c0.js.map} +1 -1
  231. package/dist/peculiar/{p-99efefea.js → p-92f9641a.js} +2 -2
  232. package/dist/peculiar/{p-99efefea.js.map → p-92f9641a.js.map} +1 -1
  233. package/dist/peculiar/p-93e299aa.system.entry.js +5 -0
  234. package/dist/peculiar/p-93e299aa.system.entry.js.map +1 -0
  235. package/dist/peculiar/p-9987b899.js +19 -0
  236. package/dist/peculiar/{p-4bc5ddbe.js.map → p-9987b899.js.map} +1 -1
  237. package/dist/peculiar/p-9b64adaa.system.js +13 -0
  238. package/dist/peculiar/p-9b64adaa.system.js.map +1 -0
  239. package/dist/peculiar/{p-243244af.system.js → p-9ca02302.system.js} +2 -2
  240. package/dist/peculiar/{p-243244af.system.js.map → p-9ca02302.system.js.map} +1 -1
  241. package/dist/peculiar/p-a1adb881.js +6 -0
  242. package/dist/peculiar/p-a1adb881.js.map +1 -0
  243. package/dist/peculiar/{p-eea904d7.system.js → p-a3054d6e.system.js} +2 -2
  244. package/dist/peculiar/{p-eea904d7.system.js.map → p-a3054d6e.system.js.map} +1 -1
  245. package/dist/peculiar/{p-32807e5e.js → p-a55fd6f1.js} +19 -12
  246. package/dist/peculiar/p-a55fd6f1.js.map +1 -0
  247. package/dist/peculiar/p-a87e1a0e.js +12 -0
  248. package/dist/peculiar/{p-e6a6e602.js.map → p-a87e1a0e.js.map} +1 -1
  249. package/dist/peculiar/p-a9ea6c79.system.js +20 -0
  250. package/dist/peculiar/p-a9ea6c79.system.js.map +1 -0
  251. package/dist/peculiar/{p-67e82386.entry.js → p-b01c70cf.entry.js} +3 -3
  252. package/dist/peculiar/{p-67e82386.entry.js.map → p-b01c70cf.entry.js.map} +1 -1
  253. package/dist/peculiar/p-b5674f82.js +19 -0
  254. package/dist/peculiar/p-b5674f82.js.map +1 -0
  255. package/dist/peculiar/{p-27ca6743.js → p-ba3dfc03.js} +2 -2
  256. package/dist/peculiar/{p-27ca6743.js.map → p-ba3dfc03.js.map} +1 -1
  257. package/dist/peculiar/p-bc91996c.system.js +6 -0
  258. package/dist/peculiar/p-bc91996c.system.js.map +1 -0
  259. package/dist/peculiar/p-c2995a63.system.js.map +1 -1
  260. package/dist/peculiar/p-c5d3333c.system.js +19 -0
  261. package/dist/peculiar/p-c5d3333c.system.js.map +1 -0
  262. package/dist/peculiar/p-cb8a0b79.js +19 -0
  263. package/dist/peculiar/p-cb8a0b79.js.map +1 -0
  264. package/dist/peculiar/{p-c241e4ba.system.js → p-d46670fa.system.js} +2 -2
  265. package/dist/peculiar/{p-c241e4ba.system.js.map → p-d46670fa.system.js.map} +1 -1
  266. package/dist/peculiar/{p-9712b827.system.js → p-d9145ee8.system.js} +2 -2
  267. package/dist/peculiar/{p-9712b827.system.js.map → p-d9145ee8.system.js.map} +1 -1
  268. package/dist/peculiar/p-dac867e8.js.map +1 -1
  269. package/dist/peculiar/p-f456fe47.js +12 -0
  270. package/dist/peculiar/p-f456fe47.js.map +1 -0
  271. package/dist/peculiar/p-f6ec61db.entry.js +5 -0
  272. package/dist/peculiar/{p-713563fb.entry.js.map → p-f6ec61db.entry.js.map} +1 -1
  273. package/dist/peculiar/peculiar.esm.js +1 -1
  274. package/dist/peculiar/peculiar.esm.js.map +1 -1
  275. package/dist/peculiar/peculiar.js +1 -1
  276. package/dist/types/components/certificate-chain-viewer/certificate-chain-viewer.d.ts +21 -0
  277. package/dist/types/components/certificate-decoder/certificate-decoder.d.ts +5 -4
  278. package/dist/types/components/certificate-details-parts/miscellaneous.d.ts +2 -2
  279. package/dist/types/components/typography/typography.d.ts +0 -1
  280. package/dist/types/components.d.ts +33 -4
  281. package/dist/types/crypto/index.d.ts +1 -0
  282. package/dist/types/crypto/pem_converter.d.ts +71 -0
  283. package/dist/types/crypto/pkcs10_certificate_request.d.ts +2 -2
  284. package/dist/types/crypto/utils.d.ts +7 -3
  285. package/dist/types/crypto/x509_attribute_certificate.d.ts +2 -2
  286. package/dist/types/crypto/x509_certificate.d.ts +2 -2
  287. package/dist/types/crypto/x509_certificates.d.ts +9 -0
  288. package/dist/types/crypto/x509_crl.d.ts +2 -2
  289. package/dist/types/stencil-public-runtime.d.ts +9 -10
  290. package/dist/types/utils/index.d.ts +0 -2
  291. package/hydrate/index.d.ts +36 -12
  292. package/hydrate/index.js +25131 -15090
  293. package/hydrate/index.mjs +34931 -0
  294. package/hydrate/package.json +7 -1
  295. package/loader/cdn.js +1 -1
  296. package/loader/index.cjs.js +1 -1
  297. package/loader/index.d.ts +3 -0
  298. package/loader/index.es2017.js +1 -1
  299. package/loader/index.js +1 -1
  300. package/package.json +13 -10
  301. package/dist/cjs/certification_request-ad267278.js.map +0 -1
  302. package/dist/cjs/index-e2ae280a.js +0 -2730
  303. package/dist/cjs/index-e2ae280a.js.map +0 -1
  304. package/dist/cjs/peculiar-attribute-certificate-viewer_3.cjs.entry.js.map +0 -1
  305. package/dist/cjs/pkcs10_certificate_request-64898c88.js.map +0 -1
  306. package/dist/cjs/x509_certificate-4b0894c2.js.map +0 -1
  307. package/dist/cjs/x509_crl-fc8d41a1.js.map +0 -1
  308. package/dist/collection/utils/validator.js +0 -25
  309. package/dist/collection/utils/validator.js.map +0 -1
  310. package/dist/esm/certification_request-a4699dcf.js.map +0 -1
  311. package/dist/esm/index-ae188432.js +0 -2701
  312. package/dist/esm/index-ae188432.js.map +0 -1
  313. package/dist/esm/peculiar-attribute-certificate-viewer_3.entry.js.map +0 -1
  314. package/dist/esm/pkcs10_certificate_request-785a4794.js.map +0 -1
  315. package/dist/esm/x509_certificate-05a23c0e.js.map +0 -1
  316. package/dist/esm/x509_crl-26081461.js.map +0 -1
  317. package/dist/esm-es5/certification_request-a4699dcf.js.map +0 -1
  318. package/dist/esm-es5/index-ae188432.js +0 -6
  319. package/dist/esm-es5/index-ae188432.js.map +0 -1
  320. package/dist/esm-es5/peculiar-attribute-certificate-viewer_3.entry.js +0 -110
  321. package/dist/esm-es5/peculiar-attribute-certificate-viewer_3.entry.js.map +0 -1
  322. package/dist/esm-es5/pkcs10_certificate_request-785a4794.js.map +0 -1
  323. package/dist/esm-es5/x509_certificate-05a23c0e.js +0 -12
  324. package/dist/esm-es5/x509_certificate-05a23c0e.js.map +0 -1
  325. package/dist/esm-es5/x509_crl-26081461.js +0 -19
  326. package/dist/esm-es5/x509_crl-26081461.js.map +0 -1
  327. package/dist/peculiar/p-32807e5e.js.map +0 -1
  328. package/dist/peculiar/p-3cb79cd9.js +0 -6
  329. package/dist/peculiar/p-3cb79cd9.js.map +0 -1
  330. package/dist/peculiar/p-4bc5ddbe.js +0 -19
  331. package/dist/peculiar/p-5d1d4a96.entry.js +0 -110
  332. package/dist/peculiar/p-5d1d4a96.entry.js.map +0 -1
  333. package/dist/peculiar/p-713563fb.entry.js +0 -5
  334. package/dist/peculiar/p-7ddd9a82.system.js +0 -19
  335. package/dist/peculiar/p-7ddd9a82.system.js.map +0 -1
  336. package/dist/peculiar/p-821bdcdc.system.js +0 -6
  337. package/dist/peculiar/p-821bdcdc.system.js.map +0 -1
  338. package/dist/peculiar/p-8393399a.system.js +0 -5
  339. package/dist/peculiar/p-8393399a.system.js.map +0 -1
  340. package/dist/peculiar/p-98e3a016.system.js +0 -13
  341. package/dist/peculiar/p-98e3a016.system.js.map +0 -1
  342. package/dist/peculiar/p-9ad547d2.system.entry.js +0 -5
  343. package/dist/peculiar/p-9ad547d2.system.entry.js.map +0 -1
  344. package/dist/peculiar/p-a1a48332.system.js +0 -5
  345. package/dist/peculiar/p-a1a48332.system.js.map +0 -1
  346. package/dist/peculiar/p-ab5a4988.js +0 -12
  347. package/dist/peculiar/p-ab5a4988.js.map +0 -1
  348. package/dist/peculiar/p-ae44c2b0.system.js +0 -20
  349. package/dist/peculiar/p-ae44c2b0.system.js.map +0 -1
  350. package/dist/peculiar/p-b5389885.system.entry.js +0 -5
  351. package/dist/peculiar/p-cd1b1876.entry.js +0 -5
  352. package/dist/peculiar/p-cd1b1876.entry.js.map +0 -1
  353. package/dist/peculiar/p-d5ba4fc2.js +0 -19
  354. package/dist/peculiar/p-d5ba4fc2.js.map +0 -1
  355. package/dist/peculiar/p-e37e4df2.system.js +0 -135
  356. package/dist/peculiar/p-e37e4df2.system.js.map +0 -1
  357. package/dist/peculiar/p-e6a6e602.js +0 -12
  358. package/dist/peculiar/p-f8c91ee4.js +0 -19
  359. package/dist/peculiar/p-f8c91ee4.js.map +0 -1
  360. package/dist/peculiar/p-f9c07207.system.entry.js +0 -111
  361. package/dist/peculiar/p-f9c07207.system.entry.js.map +0 -1
  362. package/dist/types/utils/validator.d.ts +0 -10
@@ -1,2730 +0,0 @@
1
- /*!
2
- * © Peculiar Ventures https://peculiarventures.com/ - MIT License
3
- */
4
- 'use strict';
5
-
6
- function _interopNamespace(e) {
7
- if (e && e.__esModule) return e;
8
- var n = Object.create(null);
9
- if (e) {
10
- Object.keys(e).forEach(function (k) {
11
- if (k !== 'default') {
12
- var d = Object.getOwnPropertyDescriptor(e, k);
13
- Object.defineProperty(n, k, d.get ? d : {
14
- enumerable: true,
15
- get: function () {
16
- return e[k];
17
- }
18
- });
19
- }
20
- });
21
- }
22
- n['default'] = e;
23
- return Object.freeze(n);
24
- }
25
-
26
- const NAMESPACE = 'peculiar';
27
- const BUILD = /* peculiar */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: true, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: true, element: false, event: true, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: true, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: false, mode: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: false, propNumber: true, propString: true, reflect: true, scoped: true, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, slot: true, slotChildNodesFix: false, slotRelocation: true, state: true, style: true, svg: true, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: true, watchCallback: true };
28
-
29
- /**
30
- * Virtual DOM patching algorithm based on Snabbdom by
31
- * Simon Friis Vindum (@paldepind)
32
- * Licensed under the MIT License
33
- * https://github.com/snabbdom/snabbdom/blob/master/LICENSE
34
- *
35
- * Modified for Stencil's renderer and slot projection
36
- */
37
- let scopeId;
38
- let contentRef;
39
- let hostTagName;
40
- let useNativeShadowDom = false;
41
- let checkSlotFallbackVisibility = false;
42
- let checkSlotRelocate = false;
43
- let isSvgMode = false;
44
- let queuePending = false;
45
- const createTime = (fnName, tagName = '') => {
46
- {
47
- return () => {
48
- return;
49
- };
50
- }
51
- };
52
- const uniqueTime = (key, measureText) => {
53
- {
54
- return () => {
55
- return;
56
- };
57
- }
58
- };
59
- const CONTENT_REF_ID = 'r';
60
- const ORG_LOCATION_ID = 'o';
61
- const SLOT_NODE_ID = 's';
62
- const TEXT_NODE_ID = 't';
63
- const HYDRATE_ID = 's-id';
64
- const HYDRATED_STYLE_ID = 'sty-id';
65
- const HYDRATE_CHILD_ID = 'c-id';
66
- const HYDRATED_CSS = '{visibility:hidden}.hydrated{visibility:inherit}';
67
- /**
68
- * Constant for styles to be globally applied to `slot-fb` elements for pseudo-slot behavior.
69
- *
70
- * Two cascading rules must be used instead of a `:not()` selector due to Stencil browser
71
- * support as of Stencil v4.
72
- */
73
- const SLOT_FB_CSS = 'slot-fb{display:contents}slot-fb[hidden]{display:none}';
74
- const XLINK_NS = 'http://www.w3.org/1999/xlink';
75
- /**
76
- * Default style mode id
77
- */
78
- /**
79
- * Reusable empty obj/array
80
- * Don't add values to these!!
81
- */
82
- const EMPTY_OBJ = {};
83
- /**
84
- * Namespaces
85
- */
86
- const SVG_NS = 'http://www.w3.org/2000/svg';
87
- const HTML_NS = 'http://www.w3.org/1999/xhtml';
88
- const isDef = (v) => v != null;
89
- /**
90
- * Check whether a value is a 'complex type', defined here as an object or a
91
- * function.
92
- *
93
- * @param o the value to check
94
- * @returns whether it's a complex type or not
95
- */
96
- const isComplexType = (o) => {
97
- // https://jsperf.com/typeof-fn-object/5
98
- o = typeof o;
99
- return o === 'object' || o === 'function';
100
- };
101
- /**
102
- * Helper method for querying a `meta` tag that contains a nonce value
103
- * out of a DOM's head.
104
- *
105
- * @param doc The DOM containing the `head` to query against
106
- * @returns The content of the meta tag representing the nonce value, or `undefined` if no tag
107
- * exists or the tag has no content.
108
- */
109
- function queryNonceMetaTagContent(doc) {
110
- var _a, _b, _c;
111
- return (_c = (_b = (_a = doc.head) === null || _a === void 0 ? void 0 : _a.querySelector('meta[name="csp-nonce"]')) === null || _b === void 0 ? void 0 : _b.getAttribute('content')) !== null && _c !== void 0 ? _c : undefined;
112
- }
113
- /**
114
- * Production h() function based on Preact by
115
- * Jason Miller (@developit)
116
- * Licensed under the MIT License
117
- * https://github.com/developit/preact/blob/master/LICENSE
118
- *
119
- * Modified for Stencil's compiler and vdom
120
- */
121
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, child?: d.ChildType): d.VNode;
122
- // export function h(nodeName: string | d.FunctionalComponent, vnodeData: d.PropsType, ...children: d.ChildType[]): d.VNode;
123
- const h = (nodeName, vnodeData, ...children) => {
124
- let child = null;
125
- let key = null;
126
- let slotName = null;
127
- let simple = false;
128
- let lastSimple = false;
129
- const vNodeChildren = [];
130
- const walk = (c) => {
131
- for (let i = 0; i < c.length; i++) {
132
- child = c[i];
133
- if (Array.isArray(child)) {
134
- walk(child);
135
- }
136
- else if (child != null && typeof child !== 'boolean') {
137
- if ((simple = typeof nodeName !== 'function' && !isComplexType(child))) {
138
- child = String(child);
139
- }
140
- if (simple && lastSimple) {
141
- // If the previous child was simple (string), we merge both
142
- vNodeChildren[vNodeChildren.length - 1].$text$ += child;
143
- }
144
- else {
145
- // Append a new vNode, if it's text, we create a text vNode
146
- vNodeChildren.push(simple ? newVNode(null, child) : child);
147
- }
148
- lastSimple = simple;
149
- }
150
- }
151
- };
152
- walk(children);
153
- if (vnodeData) {
154
- if (vnodeData.key) {
155
- key = vnodeData.key;
156
- }
157
- if (vnodeData.name) {
158
- slotName = vnodeData.name;
159
- }
160
- // normalize class / className attributes
161
- {
162
- const classData = vnodeData.className || vnodeData.class;
163
- if (classData) {
164
- vnodeData.class =
165
- typeof classData !== 'object'
166
- ? classData
167
- : Object.keys(classData)
168
- .filter((k) => classData[k])
169
- .join(' ');
170
- }
171
- }
172
- }
173
- if (typeof nodeName === 'function') {
174
- // nodeName is a functional component
175
- return nodeName(vnodeData === null ? {} : vnodeData, vNodeChildren, vdomFnUtils);
176
- }
177
- const vnode = newVNode(nodeName, null);
178
- vnode.$attrs$ = vnodeData;
179
- if (vNodeChildren.length > 0) {
180
- vnode.$children$ = vNodeChildren;
181
- }
182
- {
183
- vnode.$key$ = key;
184
- }
185
- {
186
- vnode.$name$ = slotName;
187
- }
188
- return vnode;
189
- };
190
- /**
191
- * A utility function for creating a virtual DOM node from a tag and some
192
- * possible text content.
193
- *
194
- * @param tag the tag for this element
195
- * @param text possible text content for the node
196
- * @returns a newly-minted virtual DOM node
197
- */
198
- const newVNode = (tag, text) => {
199
- const vnode = {
200
- $flags$: 0,
201
- $tag$: tag,
202
- $text$: text,
203
- $elm$: null,
204
- $children$: null,
205
- };
206
- {
207
- vnode.$attrs$ = null;
208
- }
209
- {
210
- vnode.$key$ = null;
211
- }
212
- {
213
- vnode.$name$ = null;
214
- }
215
- return vnode;
216
- };
217
- const Host = {};
218
- /**
219
- * Check whether a given node is a Host node or not
220
- *
221
- * @param node the virtual DOM node to check
222
- * @returns whether it's a Host node or not
223
- */
224
- const isHost = (node) => node && node.$tag$ === Host;
225
- /**
226
- * Implementation of {@link d.FunctionalUtilities} for Stencil's VDom.
227
- *
228
- * Note that these functions convert from {@link d.VNode} to
229
- * {@link d.ChildNode} to give functional component developers a friendly
230
- * interface.
231
- */
232
- const vdomFnUtils = {
233
- forEach: (children, cb) => children.map(convertToPublic).forEach(cb),
234
- map: (children, cb) => children.map(convertToPublic).map(cb).map(convertToPrivate),
235
- };
236
- /**
237
- * Convert a {@link d.VNode} to a {@link d.ChildNode} in order to present a
238
- * friendlier public interface (hence, 'convertToPublic').
239
- *
240
- * @param node the virtual DOM node to convert
241
- * @returns a converted child node
242
- */
243
- const convertToPublic = (node) => ({
244
- vattrs: node.$attrs$,
245
- vchildren: node.$children$,
246
- vkey: node.$key$,
247
- vname: node.$name$,
248
- vtag: node.$tag$,
249
- vtext: node.$text$,
250
- });
251
- /**
252
- * Convert a {@link d.ChildNode} back to an equivalent {@link d.VNode} in
253
- * order to use the resulting object in the virtual DOM. The initial object was
254
- * likely created as part of presenting a public API, so converting it back
255
- * involved making it 'private' again (hence, `convertToPrivate`).
256
- *
257
- * @param node the child node to convert
258
- * @returns a converted virtual DOM node
259
- */
260
- const convertToPrivate = (node) => {
261
- if (typeof node.vtag === 'function') {
262
- const vnodeData = Object.assign({}, node.vattrs);
263
- if (node.vkey) {
264
- vnodeData.key = node.vkey;
265
- }
266
- if (node.vname) {
267
- vnodeData.name = node.vname;
268
- }
269
- return h(node.vtag, vnodeData, ...(node.vchildren || []));
270
- }
271
- const vnode = newVNode(node.vtag, node.vtext);
272
- vnode.$attrs$ = node.vattrs;
273
- vnode.$children$ = node.vchildren;
274
- vnode.$key$ = node.vkey;
275
- vnode.$name$ = node.vname;
276
- return vnode;
277
- };
278
- /**
279
- * Entrypoint of the client-side hydration process. Facilitates calls to hydrate the
280
- * document and all its nodes.
281
- *
282
- * This process will also reconstruct the shadow root and slot DOM nodes for components using shadow DOM.
283
- *
284
- * @param hostElm The element to hydrate.
285
- * @param tagName The element's tag name.
286
- * @param hostId The host ID assigned to the element by the server.
287
- * @param hostRef The host reference for the element.
288
- */
289
- const initializeClientHydrate = (hostElm, tagName, hostId, hostRef) => {
290
- const endHydrate = createTime('hydrateClient', tagName);
291
- const shadowRoot = hostElm.shadowRoot;
292
- const childRenderNodes = [];
293
- const slotNodes = [];
294
- const shadowRootNodes = shadowRoot ? [] : null;
295
- const vnode = (hostRef.$vnode$ = newVNode(tagName, null));
296
- if (!plt.$orgLocNodes$) {
297
- initializeDocumentHydrate(doc.body, (plt.$orgLocNodes$ = new Map()));
298
- }
299
- hostElm[HYDRATE_ID] = hostId;
300
- hostElm.removeAttribute(HYDRATE_ID);
301
- clientHydrate(vnode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, hostElm, hostId);
302
- childRenderNodes.map((c) => {
303
- const orgLocationId = c.$hostId$ + '.' + c.$nodeId$;
304
- const orgLocationNode = plt.$orgLocNodes$.get(orgLocationId);
305
- const node = c.$elm$;
306
- // Put the node back in its original location since the native Shadow DOM
307
- // can handle rendering it its correct location now
308
- if (orgLocationNode && supportsShadow && orgLocationNode['s-en'] === '') {
309
- orgLocationNode.parentNode.insertBefore(node, orgLocationNode.nextSibling);
310
- }
311
- if (!shadowRoot) {
312
- node['s-hn'] = tagName;
313
- if (orgLocationNode) {
314
- node['s-ol'] = orgLocationNode;
315
- node['s-ol']['s-nr'] = node;
316
- }
317
- }
318
- plt.$orgLocNodes$.delete(orgLocationId);
319
- });
320
- if (shadowRoot) {
321
- shadowRootNodes.map((shadowRootNode) => {
322
- if (shadowRootNode) {
323
- shadowRoot.appendChild(shadowRootNode);
324
- }
325
- });
326
- }
327
- endHydrate();
328
- };
329
- /**
330
- * Recursively constructs the virtual node tree for a host element and its children.
331
- * The tree is constructed by parsing the annotations set on the nodes by the server.
332
- *
333
- * In addition to constructing the vNode tree, we also track information about the node's
334
- * descendants like which are slots, which should exist in the shadow root, and which
335
- * are nodes that should be rendered as children of the parent node.
336
- *
337
- * @param parentVNode The vNode representing the parent node.
338
- * @param childRenderNodes An array of all child nodes in the parent's node tree.
339
- * @param slotNodes An array of all slot nodes in the parent's node tree.
340
- * @param shadowRootNodes An array all nodes that should be rendered in the shadow root in the parent's node tree.
341
- * @param hostElm The parent element.
342
- * @param node The node to construct the vNode tree for.
343
- * @param hostId The host ID assigned to the element by the server.
344
- */
345
- const clientHydrate = (parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node, hostId) => {
346
- let childNodeType;
347
- let childIdSplt;
348
- let childVNode;
349
- let i;
350
- if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
351
- childNodeType = node.getAttribute(HYDRATE_CHILD_ID);
352
- if (childNodeType) {
353
- // got the node data from the element's attribute
354
- // `${hostId}.${nodeId}.${depth}.${index}`
355
- childIdSplt = childNodeType.split('.');
356
- if (childIdSplt[0] === hostId || childIdSplt[0] === '0') {
357
- childVNode = {
358
- $flags$: 0,
359
- $hostId$: childIdSplt[0],
360
- $nodeId$: childIdSplt[1],
361
- $depth$: childIdSplt[2],
362
- $index$: childIdSplt[3],
363
- $tag$: node.tagName.toLowerCase(),
364
- $elm$: node,
365
- $attrs$: null,
366
- $children$: null,
367
- $key$: null,
368
- $name$: null,
369
- $text$: null,
370
- };
371
- childRenderNodes.push(childVNode);
372
- node.removeAttribute(HYDRATE_CHILD_ID);
373
- // this is a new child vnode
374
- // so ensure its parent vnode has the vchildren array
375
- if (!parentVNode.$children$) {
376
- parentVNode.$children$ = [];
377
- }
378
- // add our child vnode to a specific index of the vnode's children
379
- parentVNode.$children$[childVNode.$index$] = childVNode;
380
- // this is now the new parent vnode for all the next child checks
381
- parentVNode = childVNode;
382
- if (shadowRootNodes && childVNode.$depth$ === '0') {
383
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
384
- }
385
- }
386
- }
387
- // recursively drill down, end to start so we can remove nodes
388
- for (i = node.childNodes.length - 1; i >= 0; i--) {
389
- clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.childNodes[i], hostId);
390
- }
391
- if (node.shadowRoot) {
392
- // keep drilling down through the shadow root nodes
393
- for (i = node.shadowRoot.childNodes.length - 1; i >= 0; i--) {
394
- clientHydrate(parentVNode, childRenderNodes, slotNodes, shadowRootNodes, hostElm, node.shadowRoot.childNodes[i], hostId);
395
- }
396
- }
397
- }
398
- else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
399
- // `${COMMENT_TYPE}.${hostId}.${nodeId}.${depth}.${index}`
400
- childIdSplt = node.nodeValue.split('.');
401
- if (childIdSplt[1] === hostId || childIdSplt[1] === '0') {
402
- // comment node for either the host id or a 0 host id
403
- childNodeType = childIdSplt[0];
404
- childVNode = {
405
- $flags$: 0,
406
- $hostId$: childIdSplt[1],
407
- $nodeId$: childIdSplt[2],
408
- $depth$: childIdSplt[3],
409
- $index$: childIdSplt[4],
410
- $elm$: node,
411
- $attrs$: null,
412
- $children$: null,
413
- $key$: null,
414
- $name$: null,
415
- $tag$: null,
416
- $text$: null,
417
- };
418
- if (childNodeType === TEXT_NODE_ID) {
419
- childVNode.$elm$ = node.nextSibling;
420
- if (childVNode.$elm$ && childVNode.$elm$.nodeType === 3 /* NODE_TYPE.TextNode */) {
421
- childVNode.$text$ = childVNode.$elm$.textContent;
422
- childRenderNodes.push(childVNode);
423
- // remove the text comment since it's no longer needed
424
- node.remove();
425
- if (!parentVNode.$children$) {
426
- parentVNode.$children$ = [];
427
- }
428
- parentVNode.$children$[childVNode.$index$] = childVNode;
429
- if (shadowRootNodes && childVNode.$depth$ === '0') {
430
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
431
- }
432
- }
433
- }
434
- else if (childVNode.$hostId$ === hostId) {
435
- // this comment node is specifically for this host id
436
- if (childNodeType === SLOT_NODE_ID) {
437
- // `${SLOT_NODE_ID}.${hostId}.${nodeId}.${depth}.${index}.${slotName}`;
438
- childVNode.$tag$ = 'slot';
439
- if (childIdSplt[5]) {
440
- node['s-sn'] = childVNode.$name$ = childIdSplt[5];
441
- }
442
- else {
443
- node['s-sn'] = '';
444
- }
445
- node['s-sr'] = true;
446
- if (shadowRootNodes) {
447
- // browser support shadowRoot and this is a shadow dom component
448
- // create an actual slot element
449
- childVNode.$elm$ = doc.createElement(childVNode.$tag$);
450
- if (childVNode.$name$) {
451
- // add the slot name attribute
452
- childVNode.$elm$.setAttribute('name', childVNode.$name$);
453
- }
454
- // insert the new slot element before the slot comment
455
- node.parentNode.insertBefore(childVNode.$elm$, node);
456
- // remove the slot comment since it's not needed for shadow
457
- node.remove();
458
- if (childVNode.$depth$ === '0') {
459
- shadowRootNodes[childVNode.$index$] = childVNode.$elm$;
460
- }
461
- }
462
- slotNodes.push(childVNode);
463
- if (!parentVNode.$children$) {
464
- parentVNode.$children$ = [];
465
- }
466
- parentVNode.$children$[childVNode.$index$] = childVNode;
467
- }
468
- else if (childNodeType === CONTENT_REF_ID) {
469
- // `${CONTENT_REF_ID}.${hostId}`;
470
- if (shadowRootNodes) {
471
- // remove the content ref comment since it's not needed for shadow
472
- node.remove();
473
- }
474
- else {
475
- hostElm['s-cr'] = node;
476
- node['s-cn'] = true;
477
- }
478
- }
479
- }
480
- }
481
- }
482
- else if (parentVNode && parentVNode.$tag$ === 'style') {
483
- const vnode = newVNode(null, node.textContent);
484
- vnode.$elm$ = node;
485
- vnode.$index$ = '0';
486
- parentVNode.$children$ = [vnode];
487
- }
488
- };
489
- /**
490
- * Recursively locate any comments representing an original location for a node in a node's
491
- * children or shadowRoot children.
492
- *
493
- * @param node The node to search.
494
- * @param orgLocNodes A map of the original location annotation and the current node being searched.
495
- */
496
- const initializeDocumentHydrate = (node, orgLocNodes) => {
497
- if (node.nodeType === 1 /* NODE_TYPE.ElementNode */) {
498
- let i = 0;
499
- for (; i < node.childNodes.length; i++) {
500
- initializeDocumentHydrate(node.childNodes[i], orgLocNodes);
501
- }
502
- if (node.shadowRoot) {
503
- for (i = 0; i < node.shadowRoot.childNodes.length; i++) {
504
- initializeDocumentHydrate(node.shadowRoot.childNodes[i], orgLocNodes);
505
- }
506
- }
507
- }
508
- else if (node.nodeType === 8 /* NODE_TYPE.CommentNode */) {
509
- const childIdSplt = node.nodeValue.split('.');
510
- if (childIdSplt[0] === ORG_LOCATION_ID) {
511
- orgLocNodes.set(childIdSplt[1] + '.' + childIdSplt[2], node);
512
- node.nodeValue = '';
513
- // useful to know if the original location is
514
- // the root light-dom of a shadow dom component
515
- node['s-en'] = childIdSplt[3];
516
- }
517
- }
518
- };
519
- /**
520
- * Parse a new property value for a given property type.
521
- *
522
- * While the prop value can reasonably be expected to be of `any` type as far as TypeScript's type checker is concerned,
523
- * it is not safe to assume that the string returned by evaluating `typeof propValue` matches:
524
- * 1. `any`, the type given to `propValue` in the function signature
525
- * 2. the type stored from `propType`.
526
- *
527
- * This function provides the capability to parse/coerce a property's value to potentially any other JavaScript type.
528
- *
529
- * Property values represented in TSX preserve their type information. In the example below, the number 0 is passed to
530
- * a component. This `propValue` will preserve its type information (`typeof propValue === 'number'`). Note that is
531
- * based on the type of the value being passed in, not the type declared of the class member decorated with `@Prop`.
532
- * ```tsx
533
- * <my-cmp prop-val={0}></my-cmp>
534
- * ```
535
- *
536
- * HTML prop values on the other hand, will always a string
537
- *
538
- * @param propValue the new value to coerce to some type
539
- * @param propType the type of the prop, expressed as a binary number
540
- * @returns the parsed/coerced value
541
- */
542
- const parsePropertyValue = (propValue, propType) => {
543
- // ensure this value is of the correct prop type
544
- if (propValue != null && !isComplexType(propValue)) {
545
- if (propType & 4 /* MEMBER_FLAGS.Boolean */) {
546
- // per the HTML spec, any string value means it is a boolean true value
547
- // but we'll cheat here and say that the string "false" is the boolean false
548
- return propValue === 'false' ? false : propValue === '' || !!propValue;
549
- }
550
- if (propType & 2 /* MEMBER_FLAGS.Number */) {
551
- // force it to be a number
552
- return parseFloat(propValue);
553
- }
554
- if (propType & 1 /* MEMBER_FLAGS.String */) {
555
- // could have been passed as a number or boolean
556
- // but we still want it as a string
557
- return String(propValue);
558
- }
559
- // redundant return here for better minification
560
- return propValue;
561
- }
562
- // not sure exactly what type we want
563
- // so no need to change to a different type
564
- return propValue;
565
- };
566
- const getElement = (ref) => (getHostRef(ref).$hostElement$ );
567
- const createEvent = (ref, name, flags) => {
568
- const elm = getElement(ref);
569
- return {
570
- emit: (detail) => {
571
- return emitEvent(elm, name, {
572
- bubbles: !!(flags & 4 /* EVENT_FLAGS.Bubbles */),
573
- composed: !!(flags & 2 /* EVENT_FLAGS.Composed */),
574
- cancelable: !!(flags & 1 /* EVENT_FLAGS.Cancellable */),
575
- detail,
576
- });
577
- },
578
- };
579
- };
580
- /**
581
- * Helper function to create & dispatch a custom Event on a provided target
582
- * @param elm the target of the Event
583
- * @param name the name to give the custom Event
584
- * @param opts options for configuring a custom Event
585
- * @returns the custom Event
586
- */
587
- const emitEvent = (elm, name, opts) => {
588
- const ev = plt.ce(name, opts);
589
- elm.dispatchEvent(ev);
590
- return ev;
591
- };
592
- const rootAppliedStyles = /*@__PURE__*/ new WeakMap();
593
- const registerStyle = (scopeId, cssText, allowCS) => {
594
- let style = styles.get(scopeId);
595
- if (supportsConstructableStylesheets && allowCS) {
596
- style = (style || new CSSStyleSheet());
597
- if (typeof style === 'string') {
598
- style = cssText;
599
- }
600
- else {
601
- style.replaceSync(cssText);
602
- }
603
- }
604
- else {
605
- style = cssText;
606
- }
607
- styles.set(scopeId, style);
608
- };
609
- const addStyle = (styleContainerNode, cmpMeta, mode) => {
610
- var _a;
611
- const scopeId = getScopeId(cmpMeta);
612
- const style = styles.get(scopeId);
613
- // if an element is NOT connected then getRootNode() will return the wrong root node
614
- // so the fallback is to always use the document for the root node in those cases
615
- styleContainerNode = styleContainerNode.nodeType === 11 /* NODE_TYPE.DocumentFragment */ ? styleContainerNode : doc;
616
- if (style) {
617
- if (typeof style === 'string') {
618
- styleContainerNode = styleContainerNode.head || styleContainerNode;
619
- let appliedStyles = rootAppliedStyles.get(styleContainerNode);
620
- let styleElm;
621
- if (!appliedStyles) {
622
- rootAppliedStyles.set(styleContainerNode, (appliedStyles = new Set()));
623
- }
624
- if (!appliedStyles.has(scopeId)) {
625
- if (styleContainerNode.host &&
626
- (styleElm = styleContainerNode.querySelector(`[${HYDRATED_STYLE_ID}="${scopeId}"]`))) {
627
- // This is only happening on native shadow-dom, do not needs CSS var shim
628
- styleElm.innerHTML = style;
629
- }
630
- else {
631
- styleElm = doc.createElement('style');
632
- styleElm.innerHTML = style;
633
- // Apply CSP nonce to the style tag if it exists
634
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
635
- if (nonce != null) {
636
- styleElm.setAttribute('nonce', nonce);
637
- }
638
- styleContainerNode.insertBefore(styleElm, styleContainerNode.querySelector('link'));
639
- }
640
- // Add styles for `slot-fb` elements if we're using slots outside the Shadow DOM
641
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
642
- styleElm.innerHTML += SLOT_FB_CSS;
643
- }
644
- if (appliedStyles) {
645
- appliedStyles.add(scopeId);
646
- }
647
- }
648
- }
649
- else if (!styleContainerNode.adoptedStyleSheets.includes(style)) {
650
- styleContainerNode.adoptedStyleSheets = [...styleContainerNode.adoptedStyleSheets, style];
651
- }
652
- }
653
- return scopeId;
654
- };
655
- const attachStyles = (hostRef) => {
656
- const cmpMeta = hostRef.$cmpMeta$;
657
- const elm = hostRef.$hostElement$;
658
- const flags = cmpMeta.$flags$;
659
- const endAttachStyles = createTime('attachStyles', cmpMeta.$tagName$);
660
- const scopeId = addStyle(elm.shadowRoot ? elm.shadowRoot : elm.getRootNode(), cmpMeta);
661
- if (flags & 10 /* CMP_FLAGS.needsScopedEncapsulation */) {
662
- // only required when we're NOT using native shadow dom (slot)
663
- // or this browser doesn't support native shadow dom
664
- // and this host element was NOT created with SSR
665
- // let's pick out the inner content for slot projection
666
- // create a node to represent where the original
667
- // content was first placed, which is useful later on
668
- // DOM WRITE!!
669
- elm['s-sc'] = scopeId;
670
- elm.classList.add(scopeId + '-h');
671
- if (flags & 2 /* CMP_FLAGS.scopedCssEncapsulation */) {
672
- elm.classList.add(scopeId + '-s');
673
- }
674
- }
675
- endAttachStyles();
676
- };
677
- const getScopeId = (cmp, mode) => 'sc-' + (cmp.$tagName$);
678
- const convertScopedToShadow = (css) => css.replace(/\/\*!@([^\/]+)\*\/[^\{]+\{/g, '$1{');
679
- /**
680
- * Production setAccessor() function based on Preact by
681
- * Jason Miller (@developit)
682
- * Licensed under the MIT License
683
- * https://github.com/developit/preact/blob/master/LICENSE
684
- *
685
- * Modified for Stencil's compiler and vdom
686
- */
687
- /**
688
- * When running a VDom render set properties present on a VDom node onto the
689
- * corresponding HTML element.
690
- *
691
- * Note that this function has special functionality for the `class`,
692
- * `style`, `key`, and `ref` attributes, as well as event handlers (like
693
- * `onClick`, etc). All others are just passed through as-is.
694
- *
695
- * @param elm the HTMLElement onto which attributes should be set
696
- * @param memberName the name of the attribute to set
697
- * @param oldValue the old value for the attribute
698
- * @param newValue the new value for the attribute
699
- * @param isSvg whether we're in an svg context or not
700
- * @param flags bitflags for Vdom variables
701
- */
702
- const setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags) => {
703
- if (oldValue !== newValue) {
704
- let isProp = isMemberInElement(elm, memberName);
705
- let ln = memberName.toLowerCase();
706
- if (memberName === 'class') {
707
- const classList = elm.classList;
708
- const oldClasses = parseClassList(oldValue);
709
- const newClasses = parseClassList(newValue);
710
- classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
711
- classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
712
- }
713
- else if (memberName === 'style') {
714
- // update style attribute, css properties and values
715
- {
716
- for (const prop in oldValue) {
717
- if (!newValue || newValue[prop] == null) {
718
- if (prop.includes('-')) {
719
- elm.style.removeProperty(prop);
720
- }
721
- else {
722
- elm.style[prop] = '';
723
- }
724
- }
725
- }
726
- }
727
- for (const prop in newValue) {
728
- if (!oldValue || newValue[prop] !== oldValue[prop]) {
729
- if (prop.includes('-')) {
730
- elm.style.setProperty(prop, newValue[prop]);
731
- }
732
- else {
733
- elm.style[prop] = newValue[prop];
734
- }
735
- }
736
- }
737
- }
738
- else if (memberName === 'key')
739
- ;
740
- else if (memberName === 'ref') {
741
- // minifier will clean this up
742
- if (newValue) {
743
- newValue(elm);
744
- }
745
- }
746
- else if ((!isProp ) &&
747
- memberName[0] === 'o' &&
748
- memberName[1] === 'n') {
749
- // Event Handlers
750
- // so if the member name starts with "on" and the 3rd characters is
751
- // a capital letter, and it's not already a member on the element,
752
- // then we're assuming it's an event listener
753
- if (memberName[2] === '-') {
754
- // on- prefixed events
755
- // allows to be explicit about the dom event to listen without any magic
756
- // under the hood:
757
- // <my-cmp on-click> // listens for "click"
758
- // <my-cmp on-Click> // listens for "Click"
759
- // <my-cmp on-ionChange> // listens for "ionChange"
760
- // <my-cmp on-EVENTS> // listens for "EVENTS"
761
- memberName = memberName.slice(3);
762
- }
763
- else if (isMemberInElement(win, ln)) {
764
- // standard event
765
- // the JSX attribute could have been "onMouseOver" and the
766
- // member name "onmouseover" is on the window's prototype
767
- // so let's add the listener "mouseover", which is all lowercased
768
- memberName = ln.slice(2);
769
- }
770
- else {
771
- // custom event
772
- // the JSX attribute could have been "onMyCustomEvent"
773
- // so let's trim off the "on" prefix and lowercase the first character
774
- // and add the listener "myCustomEvent"
775
- // except for the first character, we keep the event name case
776
- memberName = ln[2] + memberName.slice(3);
777
- }
778
- if (oldValue || newValue) {
779
- // Need to account for "capture" events.
780
- // If the event name ends with "Capture", we'll update the name to remove
781
- // the "Capture" suffix and make sure the event listener is setup to handle the capture event.
782
- const capture = memberName.endsWith(CAPTURE_EVENT_SUFFIX);
783
- // Make sure we only replace the last instance of "Capture"
784
- memberName = memberName.replace(CAPTURE_EVENT_REGEX, '');
785
- if (oldValue) {
786
- plt.rel(elm, memberName, oldValue, capture);
787
- }
788
- if (newValue) {
789
- plt.ael(elm, memberName, newValue, capture);
790
- }
791
- }
792
- }
793
- else {
794
- // Set property if it exists and it's not a SVG
795
- const isComplex = isComplexType(newValue);
796
- if ((isProp || (isComplex && newValue !== null)) && !isSvg) {
797
- try {
798
- if (!elm.tagName.includes('-')) {
799
- const n = newValue == null ? '' : newValue;
800
- // Workaround for Safari, moving the <input> caret when re-assigning the same valued
801
- if (memberName === 'list') {
802
- isProp = false;
803
- }
804
- else if (oldValue == null || elm[memberName] != n) {
805
- elm[memberName] = n;
806
- }
807
- }
808
- else {
809
- elm[memberName] = newValue;
810
- }
811
- }
812
- catch (e) {
813
- /**
814
- * in case someone tries to set a read-only property, e.g. "namespaceURI", we just ignore it
815
- */
816
- }
817
- }
818
- /**
819
- * Need to manually update attribute if:
820
- * - memberName is not an attribute
821
- * - if we are rendering the host element in order to reflect attribute
822
- * - if it's a SVG, since properties might not work in <svg>
823
- * - if the newValue is null/undefined or 'false'.
824
- */
825
- let xlink = false;
826
- {
827
- if (ln !== (ln = ln.replace(/^xlink\:?/, ''))) {
828
- memberName = ln;
829
- xlink = true;
830
- }
831
- }
832
- if (newValue == null || newValue === false) {
833
- if (newValue !== false || elm.getAttribute(memberName) === '') {
834
- if (xlink) {
835
- elm.removeAttributeNS(XLINK_NS, memberName);
836
- }
837
- else {
838
- elm.removeAttribute(memberName);
839
- }
840
- }
841
- }
842
- else if ((!isProp || flags & 4 /* VNODE_FLAGS.isHost */ || isSvg) && !isComplex) {
843
- newValue = newValue === true ? '' : newValue;
844
- if (xlink) {
845
- elm.setAttributeNS(XLINK_NS, memberName, newValue);
846
- }
847
- else {
848
- elm.setAttribute(memberName, newValue);
849
- }
850
- }
851
- }
852
- }
853
- };
854
- const parseClassListRegex = /\s/;
855
- /**
856
- * Parsed a string of classnames into an array
857
- * @param value className string, e.g. "foo bar baz"
858
- * @returns list of classes, e.g. ["foo", "bar", "baz"]
859
- */
860
- const parseClassList = (value) => (!value ? [] : value.split(parseClassListRegex));
861
- const CAPTURE_EVENT_SUFFIX = 'Capture';
862
- const CAPTURE_EVENT_REGEX = new RegExp(CAPTURE_EVENT_SUFFIX + '$');
863
- const updateElement = (oldVnode, newVnode, isSvgMode, memberName) => {
864
- // if the element passed in is a shadow root, which is a document fragment
865
- // then we want to be adding attrs/props to the shadow root's "host" element
866
- // if it's not a shadow root, then we add attrs/props to the same element
867
- const elm = newVnode.$elm$.nodeType === 11 /* NODE_TYPE.DocumentFragment */ && newVnode.$elm$.host
868
- ? newVnode.$elm$.host
869
- : newVnode.$elm$;
870
- const oldVnodeAttrs = (oldVnode && oldVnode.$attrs$) || EMPTY_OBJ;
871
- const newVnodeAttrs = newVnode.$attrs$ || EMPTY_OBJ;
872
- {
873
- // remove attributes no longer present on the vnode by setting them to undefined
874
- for (memberName in oldVnodeAttrs) {
875
- if (!(memberName in newVnodeAttrs)) {
876
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], undefined, isSvgMode, newVnode.$flags$);
877
- }
878
- }
879
- }
880
- // add new & update changed attributes
881
- for (memberName in newVnodeAttrs) {
882
- setAccessor(elm, memberName, oldVnodeAttrs[memberName], newVnodeAttrs[memberName], isSvgMode, newVnode.$flags$);
883
- }
884
- };
885
- /**
886
- * Create a DOM Node corresponding to one of the children of a given VNode.
887
- *
888
- * @param oldParentVNode the parent VNode from the previous render
889
- * @param newParentVNode the parent VNode from the current render
890
- * @param childIndex the index of the VNode, in the _new_ parent node's
891
- * children, for which we will create a new DOM node
892
- * @param parentElm the parent DOM node which our new node will be a child of
893
- * @returns the newly created node
894
- */
895
- const createElm = (oldParentVNode, newParentVNode, childIndex, parentElm) => {
896
- var _a;
897
- // tslint:disable-next-line: prefer-const
898
- const newVNode = newParentVNode.$children$[childIndex];
899
- let i = 0;
900
- let elm;
901
- let childNode;
902
- let oldVNode;
903
- if (!useNativeShadowDom) {
904
- // remember for later we need to check to relocate nodes
905
- checkSlotRelocate = true;
906
- if (newVNode.$tag$ === 'slot') {
907
- if (scopeId) {
908
- // scoped css needs to add its scoped id to the parent element
909
- parentElm.classList.add(scopeId + '-s');
910
- }
911
- newVNode.$flags$ |= newVNode.$children$
912
- ? // slot element has fallback content
913
- 2 /* VNODE_FLAGS.isSlotFallback */
914
- : // slot element does not have fallback content
915
- 1 /* VNODE_FLAGS.isSlotReference */;
916
- }
917
- }
918
- if (newVNode.$text$ !== null) {
919
- // create text node
920
- elm = newVNode.$elm$ = doc.createTextNode(newVNode.$text$);
921
- }
922
- else if (newVNode.$flags$ & 1 /* VNODE_FLAGS.isSlotReference */) {
923
- // create a slot reference node
924
- elm = newVNode.$elm$ =
925
- doc.createTextNode('');
926
- }
927
- else {
928
- if (!isSvgMode) {
929
- isSvgMode = newVNode.$tag$ === 'svg';
930
- }
931
- // create element
932
- elm = newVNode.$elm$ = (doc.createElementNS(isSvgMode ? SVG_NS : HTML_NS, newVNode.$flags$ & 2 /* VNODE_FLAGS.isSlotFallback */
933
- ? 'slot-fb'
934
- : newVNode.$tag$)
935
- );
936
- if (isSvgMode && newVNode.$tag$ === 'foreignObject') {
937
- isSvgMode = false;
938
- }
939
- // add css classes, attrs, props, listeners, etc.
940
- {
941
- updateElement(null, newVNode, isSvgMode);
942
- }
943
- if (isDef(scopeId) && elm['s-si'] !== scopeId) {
944
- // if there is a scopeId and this is the initial render
945
- // then let's add the scopeId as a css class
946
- elm.classList.add((elm['s-si'] = scopeId));
947
- }
948
- if (newVNode.$children$) {
949
- for (i = 0; i < newVNode.$children$.length; ++i) {
950
- // create the node
951
- childNode = createElm(oldParentVNode, newVNode, i, elm);
952
- // return node could have been null
953
- if (childNode) {
954
- // append our new node
955
- elm.appendChild(childNode);
956
- }
957
- }
958
- }
959
- {
960
- if (newVNode.$tag$ === 'svg') {
961
- // Only reset the SVG context when we're exiting <svg> element
962
- isSvgMode = false;
963
- }
964
- else if (elm.tagName === 'foreignObject') {
965
- // Reenter SVG context when we're exiting <foreignObject> element
966
- isSvgMode = true;
967
- }
968
- }
969
- }
970
- // This needs to always happen so we can hide nodes that are projected
971
- // to another component but don't end up in a slot
972
- elm['s-hn'] = hostTagName;
973
- {
974
- if (newVNode.$flags$ & (2 /* VNODE_FLAGS.isSlotFallback */ | 1 /* VNODE_FLAGS.isSlotReference */)) {
975
- // remember the content reference comment
976
- elm['s-sr'] = true;
977
- // remember the content reference comment
978
- elm['s-cr'] = contentRef;
979
- // remember the slot name, or empty string for default slot
980
- elm['s-sn'] = newVNode.$name$ || '';
981
- // remember the ref callback function
982
- elm['s-rf'] = (_a = newVNode.$attrs$) === null || _a === void 0 ? void 0 : _a.ref;
983
- // check if we've got an old vnode for this slot
984
- oldVNode = oldParentVNode && oldParentVNode.$children$ && oldParentVNode.$children$[childIndex];
985
- if (oldVNode && oldVNode.$tag$ === newVNode.$tag$ && oldParentVNode.$elm$) {
986
- {
987
- // we've got an old slot vnode and the wrapper is being replaced
988
- // so let's move the old slot content back to its original location
989
- putBackInOriginalLocation(oldParentVNode.$elm$, false);
990
- }
991
- }
992
- }
993
- }
994
- return elm;
995
- };
996
- const putBackInOriginalLocation = (parentElm, recursive) => {
997
- plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
998
- const oldSlotChildNodes = Array.from(parentElm.childNodes);
999
- if (parentElm['s-sr'] && BUILD.experimentalSlotFixes) {
1000
- let node = parentElm;
1001
- while ((node = node.nextSibling)) {
1002
- if (node && node['s-sn'] === parentElm['s-sn'] && node['s-sh'] === hostTagName) {
1003
- oldSlotChildNodes.push(node);
1004
- }
1005
- }
1006
- }
1007
- for (let i = oldSlotChildNodes.length - 1; i >= 0; i--) {
1008
- const childNode = oldSlotChildNodes[i];
1009
- if (childNode['s-hn'] !== hostTagName && childNode['s-ol']) {
1010
- // and relocate it back to it's original location
1011
- parentReferenceNode(childNode).insertBefore(childNode, referenceNode(childNode));
1012
- // remove the old original location comment entirely
1013
- // later on the patch function will know what to do
1014
- // and move this to the correct spot if need be
1015
- childNode['s-ol'].remove();
1016
- childNode['s-ol'] = undefined;
1017
- // Reset so we can correctly move the node around again.
1018
- childNode['s-sh'] = undefined;
1019
- checkSlotRelocate = true;
1020
- }
1021
- if (recursive) {
1022
- putBackInOriginalLocation(childNode, recursive);
1023
- }
1024
- }
1025
- plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1026
- };
1027
- /**
1028
- * Create DOM nodes corresponding to a list of {@link d.Vnode} objects and
1029
- * add them to the DOM in the appropriate place.
1030
- *
1031
- * @param parentElm the DOM node which should be used as a parent for the new
1032
- * DOM nodes
1033
- * @param before a child of the `parentElm` which the new children should be
1034
- * inserted before (optional)
1035
- * @param parentVNode the parent virtual DOM node
1036
- * @param vnodes the new child virtual DOM nodes to produce DOM nodes for
1037
- * @param startIdx the index in the child virtual DOM nodes at which to start
1038
- * creating DOM nodes (inclusive)
1039
- * @param endIdx the index in the child virtual DOM nodes at which to stop
1040
- * creating DOM nodes (inclusive)
1041
- */
1042
- const addVnodes = (parentElm, before, parentVNode, vnodes, startIdx, endIdx) => {
1043
- let containerElm = ((parentElm['s-cr'] && parentElm['s-cr'].parentNode) || parentElm);
1044
- let childNode;
1045
- if (containerElm.shadowRoot && containerElm.tagName === hostTagName) {
1046
- containerElm = containerElm.shadowRoot;
1047
- }
1048
- for (; startIdx <= endIdx; ++startIdx) {
1049
- if (vnodes[startIdx]) {
1050
- childNode = createElm(null, parentVNode, startIdx, parentElm);
1051
- if (childNode) {
1052
- vnodes[startIdx].$elm$ = childNode;
1053
- containerElm.insertBefore(childNode, referenceNode(before) );
1054
- }
1055
- }
1056
- }
1057
- };
1058
- /**
1059
- * Remove the DOM elements corresponding to a list of {@link d.VNode} objects.
1060
- * This can be used to, for instance, clean up after a list of children which
1061
- * should no longer be shown.
1062
- *
1063
- * This function also handles some of Stencil's slot relocation logic.
1064
- *
1065
- * @param vnodes a list of virtual DOM nodes to remove
1066
- * @param startIdx the index at which to start removing nodes (inclusive)
1067
- * @param endIdx the index at which to stop removing nodes (inclusive)
1068
- */
1069
- const removeVnodes = (vnodes, startIdx, endIdx) => {
1070
- for (let index = startIdx; index <= endIdx; ++index) {
1071
- const vnode = vnodes[index];
1072
- if (vnode) {
1073
- const elm = vnode.$elm$;
1074
- nullifyVNodeRefs(vnode);
1075
- if (elm) {
1076
- {
1077
- // we're removing this element
1078
- // so it's possible we need to show slot fallback content now
1079
- checkSlotFallbackVisibility = true;
1080
- if (elm['s-ol']) {
1081
- // remove the original location comment
1082
- elm['s-ol'].remove();
1083
- }
1084
- else {
1085
- // it's possible that child nodes of the node
1086
- // that's being removed are slot nodes
1087
- putBackInOriginalLocation(elm, true);
1088
- }
1089
- }
1090
- // remove the vnode's element from the dom
1091
- elm.remove();
1092
- }
1093
- }
1094
- }
1095
- };
1096
- /**
1097
- * Reconcile the children of a new VNode with the children of an old VNode by
1098
- * traversing the two collections of children, identifying nodes that are
1099
- * conserved or changed, calling out to `patch` to make any necessary
1100
- * updates to the DOM, and rearranging DOM nodes as needed.
1101
- *
1102
- * The algorithm for reconciling children works by analyzing two 'windows' onto
1103
- * the two arrays of children (`oldCh` and `newCh`). We keep track of the
1104
- * 'windows' by storing start and end indices and references to the
1105
- * corresponding array entries. Initially the two 'windows' are basically equal
1106
- * to the entire array, but we progressively narrow the windows until there are
1107
- * no children left to update by doing the following:
1108
- *
1109
- * 1. Skip any `null` entries at the beginning or end of the two arrays, so
1110
- * that if we have an initial array like the following we'll end up dealing
1111
- * only with a window bounded by the highlighted elements:
1112
- *
1113
- * [null, null, VNode1 , ... , VNode2, null, null]
1114
- * ^^^^^^ ^^^^^^
1115
- *
1116
- * 2. Check to see if the elements at the head and tail positions are equal
1117
- * across the windows. This will basically detect elements which haven't
1118
- * been added, removed, or changed position, i.e. if you had the following
1119
- * VNode elements (represented as HTML):
1120
- *
1121
- * oldVNode: `<div><p><span>HEY</span></p></div>`
1122
- * newVNode: `<div><p><span>THERE</span></p></div>`
1123
- *
1124
- * Then when comparing the children of the `<div>` tag we check the equality
1125
- * of the VNodes corresponding to the `<p>` tags and, since they are the
1126
- * same tag in the same position, we'd be able to avoid completely
1127
- * re-rendering the subtree under them with a new DOM element and would just
1128
- * call out to `patch` to handle reconciling their children and so on.
1129
- *
1130
- * 3. Check, for both windows, to see if the element at the beginning of the
1131
- * window corresponds to the element at the end of the other window. This is
1132
- * a heuristic which will let us identify _some_ situations in which
1133
- * elements have changed position, for instance it _should_ detect that the
1134
- * children nodes themselves have not changed but merely moved in the
1135
- * following example:
1136
- *
1137
- * oldVNode: `<div><element-one /><element-two /></div>`
1138
- * newVNode: `<div><element-two /><element-one /></div>`
1139
- *
1140
- * If we find cases like this then we also need to move the concrete DOM
1141
- * elements corresponding to the moved children to write the re-order to the
1142
- * DOM.
1143
- *
1144
- * 4. Finally, if VNodes have the `key` attribute set on them we check for any
1145
- * nodes in the old children which have the same key as the first element in
1146
- * our window on the new children. If we find such a node we handle calling
1147
- * out to `patch`, moving relevant DOM nodes, and so on, in accordance with
1148
- * what we find.
1149
- *
1150
- * Finally, once we've narrowed our 'windows' to the point that either of them
1151
- * collapse (i.e. they have length 0) we then handle any remaining VNode
1152
- * insertion or deletion that needs to happen to get a DOM state that correctly
1153
- * reflects the new child VNodes. If, for instance, after our window on the old
1154
- * children has collapsed we still have more nodes on the new children that
1155
- * we haven't dealt with yet then we need to add them, or if the new children
1156
- * collapse but we still have unhandled _old_ children then we need to make
1157
- * sure the corresponding DOM nodes are removed.
1158
- *
1159
- * @param parentElm the node into which the parent VNode is rendered
1160
- * @param oldCh the old children of the parent node
1161
- * @param newVNode the new VNode which will replace the parent
1162
- * @param newCh the new children of the parent node
1163
- * @param isInitialRender whether or not this is the first render of the vdom
1164
- */
1165
- const updateChildren = (parentElm, oldCh, newVNode, newCh, isInitialRender = false) => {
1166
- let oldStartIdx = 0;
1167
- let newStartIdx = 0;
1168
- let idxInOld = 0;
1169
- let i = 0;
1170
- let oldEndIdx = oldCh.length - 1;
1171
- let oldStartVnode = oldCh[0];
1172
- let oldEndVnode = oldCh[oldEndIdx];
1173
- let newEndIdx = newCh.length - 1;
1174
- let newStartVnode = newCh[0];
1175
- let newEndVnode = newCh[newEndIdx];
1176
- let node;
1177
- let elmToMove;
1178
- while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
1179
- if (oldStartVnode == null) {
1180
- // VNode might have been moved left
1181
- oldStartVnode = oldCh[++oldStartIdx];
1182
- }
1183
- else if (oldEndVnode == null) {
1184
- oldEndVnode = oldCh[--oldEndIdx];
1185
- }
1186
- else if (newStartVnode == null) {
1187
- newStartVnode = newCh[++newStartIdx];
1188
- }
1189
- else if (newEndVnode == null) {
1190
- newEndVnode = newCh[--newEndIdx];
1191
- }
1192
- else if (isSameVnode(oldStartVnode, newStartVnode, isInitialRender)) {
1193
- // if the start nodes are the same then we should patch the new VNode
1194
- // onto the old one, and increment our `newStartIdx` and `oldStartIdx`
1195
- // indices to reflect that. We don't need to move any DOM Nodes around
1196
- // since things are matched up in order.
1197
- patch(oldStartVnode, newStartVnode, isInitialRender);
1198
- oldStartVnode = oldCh[++oldStartIdx];
1199
- newStartVnode = newCh[++newStartIdx];
1200
- }
1201
- else if (isSameVnode(oldEndVnode, newEndVnode, isInitialRender)) {
1202
- // likewise, if the end nodes are the same we patch new onto old and
1203
- // decrement our end indices, and also likewise in this case we don't
1204
- // need to move any DOM Nodes.
1205
- patch(oldEndVnode, newEndVnode, isInitialRender);
1206
- oldEndVnode = oldCh[--oldEndIdx];
1207
- newEndVnode = newCh[--newEndIdx];
1208
- }
1209
- else if (isSameVnode(oldStartVnode, newEndVnode, isInitialRender)) {
1210
- // case: "Vnode moved right"
1211
- //
1212
- // We've found that the last node in our window on the new children is
1213
- // the same VNode as the _first_ node in our window on the old children
1214
- // we're dealing with now. Visually, this is the layout of these two
1215
- // nodes:
1216
- //
1217
- // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1218
- // ^^^^^^^^^^^
1219
- // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1220
- // ^^^^^^^^^^^^^
1221
- //
1222
- // In this situation we need to patch `newEndVnode` onto `oldStartVnode`
1223
- // and move the DOM element for `oldStartVnode`.
1224
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1225
- putBackInOriginalLocation(oldStartVnode.$elm$.parentNode, false);
1226
- }
1227
- patch(oldStartVnode, newEndVnode, isInitialRender);
1228
- // We need to move the element for `oldStartVnode` into a position which
1229
- // will be appropriate for `newEndVnode`. For this we can use
1230
- // `.insertBefore` and `oldEndVnode.$elm$.nextSibling`. If there is a
1231
- // sibling for `oldEndVnode.$elm$` then we want to move the DOM node for
1232
- // `oldStartVnode` between `oldEndVnode` and it's sibling, like so:
1233
- //
1234
- // <old-start-node />
1235
- // <some-intervening-node />
1236
- // <old-end-node />
1237
- // <!-- -> <-- `oldStartVnode.$elm$` should be inserted here
1238
- // <next-sibling />
1239
- //
1240
- // If instead `oldEndVnode.$elm$` has no sibling then we just want to put
1241
- // the node for `oldStartVnode` at the end of the children of
1242
- // `parentElm`. Luckily, `Node.nextSibling` will return `null` if there
1243
- // aren't any siblings, and passing `null` to `Node.insertBefore` will
1244
- // append it to the children of the parent element.
1245
- parentElm.insertBefore(oldStartVnode.$elm$, oldEndVnode.$elm$.nextSibling);
1246
- oldStartVnode = oldCh[++oldStartIdx];
1247
- newEndVnode = newCh[--newEndIdx];
1248
- }
1249
- else if (isSameVnode(oldEndVnode, newStartVnode, isInitialRender)) {
1250
- // case: "Vnode moved left"
1251
- //
1252
- // We've found that the first node in our window on the new children is
1253
- // the same VNode as the _last_ node in our window on the old children.
1254
- // Visually, this is the layout of these two nodes:
1255
- //
1256
- // newCh: [..., newStartVnode , ... , newEndVnode , ...]
1257
- // ^^^^^^^^^^^^^
1258
- // oldCh: [..., oldStartVnode , ... , oldEndVnode , ...]
1259
- // ^^^^^^^^^^^
1260
- //
1261
- // In this situation we need to patch `newStartVnode` onto `oldEndVnode`
1262
- // (which will handle updating any changed attributes, reconciling their
1263
- // children etc) but we also need to move the DOM node to which
1264
- // `oldEndVnode` corresponds.
1265
- if ((oldStartVnode.$tag$ === 'slot' || newEndVnode.$tag$ === 'slot')) {
1266
- putBackInOriginalLocation(oldEndVnode.$elm$.parentNode, false);
1267
- }
1268
- patch(oldEndVnode, newStartVnode, isInitialRender);
1269
- // We've already checked above if `oldStartVnode` and `newStartVnode` are
1270
- // the same node, so since we're here we know that they are not. Thus we
1271
- // can move the element for `oldEndVnode` _before_ the element for
1272
- // `oldStartVnode`, leaving `oldStartVnode` to be reconciled in the
1273
- // future.
1274
- parentElm.insertBefore(oldEndVnode.$elm$, oldStartVnode.$elm$);
1275
- oldEndVnode = oldCh[--oldEndIdx];
1276
- newStartVnode = newCh[++newStartIdx];
1277
- }
1278
- else {
1279
- // Here we do some checks to match up old and new nodes based on the
1280
- // `$key$` attribute, which is set by putting a `key="my-key"` attribute
1281
- // in the JSX for a DOM element in the implementation of a Stencil
1282
- // component.
1283
- //
1284
- // First we check to see if there are any nodes in the array of old
1285
- // children which have the same key as the first node in the new
1286
- // children.
1287
- idxInOld = -1;
1288
- {
1289
- for (i = oldStartIdx; i <= oldEndIdx; ++i) {
1290
- if (oldCh[i] && oldCh[i].$key$ !== null && oldCh[i].$key$ === newStartVnode.$key$) {
1291
- idxInOld = i;
1292
- break;
1293
- }
1294
- }
1295
- }
1296
- if (idxInOld >= 0) {
1297
- // We found a node in the old children which matches up with the first
1298
- // node in the new children! So let's deal with that
1299
- elmToMove = oldCh[idxInOld];
1300
- if (elmToMove.$tag$ !== newStartVnode.$tag$) {
1301
- // the tag doesn't match so we'll need a new DOM element
1302
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, idxInOld, parentElm);
1303
- }
1304
- else {
1305
- patch(elmToMove, newStartVnode, isInitialRender);
1306
- // invalidate the matching old node so that we won't try to update it
1307
- // again later on
1308
- oldCh[idxInOld] = undefined;
1309
- node = elmToMove.$elm$;
1310
- }
1311
- newStartVnode = newCh[++newStartIdx];
1312
- }
1313
- else {
1314
- // We either didn't find an element in the old children that matches
1315
- // the key of the first new child OR the build is not using `key`
1316
- // attributes at all. In either case we need to create a new element
1317
- // for the new node.
1318
- node = createElm(oldCh && oldCh[newStartIdx], newVNode, newStartIdx, parentElm);
1319
- newStartVnode = newCh[++newStartIdx];
1320
- }
1321
- if (node) {
1322
- // if we created a new node then handle inserting it to the DOM
1323
- {
1324
- parentReferenceNode(oldStartVnode.$elm$).insertBefore(node, referenceNode(oldStartVnode.$elm$));
1325
- }
1326
- }
1327
- }
1328
- }
1329
- if (oldStartIdx > oldEndIdx) {
1330
- // we have some more new nodes to add which don't match up with old nodes
1331
- addVnodes(parentElm, newCh[newEndIdx + 1] == null ? null : newCh[newEndIdx + 1].$elm$, newVNode, newCh, newStartIdx, newEndIdx);
1332
- }
1333
- else if (newStartIdx > newEndIdx) {
1334
- // there are nodes in the `oldCh` array which no longer correspond to nodes
1335
- // in the new array, so lets remove them (which entails cleaning up the
1336
- // relevant DOM nodes)
1337
- removeVnodes(oldCh, oldStartIdx, oldEndIdx);
1338
- }
1339
- };
1340
- /**
1341
- * Compare two VNodes to determine if they are the same
1342
- *
1343
- * **NB**: This function is an equality _heuristic_ based on the available
1344
- * information set on the two VNodes and can be misleading under certain
1345
- * circumstances. In particular, if the two nodes do not have `key` attrs
1346
- * (available under `$key$` on VNodes) then the function falls back on merely
1347
- * checking that they have the same tag.
1348
- *
1349
- * So, in other words, if `key` attrs are not set on VNodes which may be
1350
- * changing order within a `children` array or something along those lines then
1351
- * we could obtain a false negative and then have to do needless re-rendering
1352
- * (i.e. we'd say two VNodes aren't equal when in fact they should be).
1353
- *
1354
- * @param leftVNode the first VNode to check
1355
- * @param rightVNode the second VNode to check
1356
- * @param isInitialRender whether or not this is the first render of the vdom
1357
- * @returns whether they're equal or not
1358
- */
1359
- const isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
1360
- // compare if two vnode to see if they're "technically" the same
1361
- // need to have the same element tag, and same key to be the same
1362
- if (leftVNode.$tag$ === rightVNode.$tag$) {
1363
- if (leftVNode.$tag$ === 'slot') {
1364
- return leftVNode.$name$ === rightVNode.$name$;
1365
- }
1366
- // this will be set if JSX tags in the build have `key` attrs set on them
1367
- // we only want to check this if we're not on the first render since on
1368
- // first render `leftVNode.$key$` will always be `null`, so we can be led
1369
- // astray and, for instance, accidentally delete a DOM node that we want to
1370
- // keep around.
1371
- if (!isInitialRender) {
1372
- return leftVNode.$key$ === rightVNode.$key$;
1373
- }
1374
- return true;
1375
- }
1376
- return false;
1377
- };
1378
- const referenceNode = (node) => {
1379
- // this node was relocated to a new location in the dom
1380
- // because of some other component's slot
1381
- // but we still have an html comment in place of where
1382
- // it's original location was according to it's original vdom
1383
- return (node && node['s-ol']) || node;
1384
- };
1385
- const parentReferenceNode = (node) => (node['s-ol'] ? node['s-ol'] : node).parentNode;
1386
- /**
1387
- * Handle reconciling an outdated VNode with a new one which corresponds to
1388
- * it. This function handles flushing updates to the DOM and reconciling the
1389
- * children of the two nodes (if any).
1390
- *
1391
- * @param oldVNode an old VNode whose DOM element and children we want to update
1392
- * @param newVNode a new VNode representing an updated version of the old one
1393
- * @param isInitialRender whether or not this is the first render of the vdom
1394
- */
1395
- const patch = (oldVNode, newVNode, isInitialRender = false) => {
1396
- const elm = (newVNode.$elm$ = oldVNode.$elm$);
1397
- const oldChildren = oldVNode.$children$;
1398
- const newChildren = newVNode.$children$;
1399
- const tag = newVNode.$tag$;
1400
- const text = newVNode.$text$;
1401
- let defaultHolder;
1402
- if (text === null) {
1403
- {
1404
- // test if we're rendering an svg element, or still rendering nodes inside of one
1405
- // only add this to the when the compiler sees we're using an svg somewhere
1406
- isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
1407
- }
1408
- {
1409
- if (tag === 'slot' && !useNativeShadowDom) ;
1410
- else {
1411
- // either this is the first render of an element OR it's an update
1412
- // AND we already know it's possible it could have changed
1413
- // this updates the element's css classes, attrs, props, listeners, etc.
1414
- updateElement(oldVNode, newVNode, isSvgMode);
1415
- }
1416
- }
1417
- if (oldChildren !== null && newChildren !== null) {
1418
- // looks like there's child vnodes for both the old and new vnodes
1419
- // so we need to call `updateChildren` to reconcile them
1420
- updateChildren(elm, oldChildren, newVNode, newChildren, isInitialRender);
1421
- }
1422
- else if (newChildren !== null) {
1423
- // no old child vnodes, but there are new child vnodes to add
1424
- if (oldVNode.$text$ !== null) {
1425
- // the old vnode was text, so be sure to clear it out
1426
- elm.textContent = '';
1427
- }
1428
- // add the new vnode children
1429
- addVnodes(elm, null, newVNode, newChildren, 0, newChildren.length - 1);
1430
- }
1431
- else if (oldChildren !== null) {
1432
- // no new child vnodes, but there are old child vnodes to remove
1433
- removeVnodes(oldChildren, 0, oldChildren.length - 1);
1434
- }
1435
- if (isSvgMode && tag === 'svg') {
1436
- isSvgMode = false;
1437
- }
1438
- }
1439
- else if ((defaultHolder = elm['s-cr'])) {
1440
- // this element has slotted content
1441
- defaultHolder.parentNode.textContent = text;
1442
- }
1443
- else if (oldVNode.$text$ !== text) {
1444
- // update the text content for the text only vnode
1445
- // and also only if the text is different than before
1446
- elm.data = text;
1447
- }
1448
- };
1449
- /**
1450
- * Adjust the `.hidden` property as-needed on any nodes in a DOM subtree which
1451
- * are slot fallbacks nodes.
1452
- *
1453
- * A slot fallback node should be visible by default. Then, it should be
1454
- * conditionally hidden if:
1455
- *
1456
- * - it has a sibling with a `slot` property set to its slot name or if
1457
- * - it is a default fallback slot node, in which case we hide if it has any
1458
- * content
1459
- *
1460
- * @param elm the element of interest
1461
- */
1462
- const updateFallbackSlotVisibility = (elm) => {
1463
- const childNodes = elm.childNodes;
1464
- for (const childNode of childNodes) {
1465
- if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1466
- if (childNode['s-sr']) {
1467
- // this is a slot fallback node
1468
- // get the slot name for this slot reference node
1469
- const slotName = childNode['s-sn'];
1470
- // by default always show a fallback slot node
1471
- // then hide it if there are other slots in the light dom
1472
- childNode.hidden = false;
1473
- // we need to check all of its sibling nodes in order to see if
1474
- // `childNode` should be hidden
1475
- for (const siblingNode of childNodes) {
1476
- // Don't check the node against itself
1477
- if (siblingNode !== childNode) {
1478
- if (siblingNode['s-hn'] !== childNode['s-hn'] || slotName !== '') {
1479
- // this sibling node is from a different component OR is a named
1480
- // fallback slot node
1481
- if (siblingNode.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
1482
- (slotName === siblingNode.getAttribute('slot') || slotName === siblingNode['s-sn'])) {
1483
- childNode.hidden = true;
1484
- break;
1485
- }
1486
- }
1487
- else {
1488
- // this is a default fallback slot node
1489
- // any element or text node (with content)
1490
- // should hide the default fallback slot node
1491
- if (siblingNode.nodeType === 1 /* NODE_TYPE.ElementNode */ ||
1492
- (siblingNode.nodeType === 3 /* NODE_TYPE.TextNode */ && siblingNode.textContent.trim() !== '')) {
1493
- childNode.hidden = true;
1494
- break;
1495
- }
1496
- }
1497
- }
1498
- }
1499
- }
1500
- // keep drilling down
1501
- updateFallbackSlotVisibility(childNode);
1502
- }
1503
- }
1504
- };
1505
- /**
1506
- * Component-global information about nodes which are either currently being
1507
- * relocated or will be shortly.
1508
- */
1509
- const relocateNodes = [];
1510
- /**
1511
- * Mark the contents of a slot for relocation via adding references to them to
1512
- * the {@link relocateNodes} data structure. The actual work of relocating them
1513
- * will then be handled in {@link renderVdom}.
1514
- *
1515
- * @param elm a render node whose child nodes need to be relocated
1516
- */
1517
- const markSlotContentForRelocation = (elm) => {
1518
- // tslint:disable-next-line: prefer-const
1519
- let node;
1520
- let hostContentNodes;
1521
- let j;
1522
- for (const childNode of elm.childNodes) {
1523
- // we need to find child nodes which are slot references so we can then try
1524
- // to match them up with nodes that need to be relocated
1525
- if (childNode['s-sr'] && (node = childNode['s-cr']) && node.parentNode) {
1526
- // first get the content reference comment node ('s-cr'), then we get
1527
- // its parent, which is where all the host content is now
1528
- hostContentNodes = node.parentNode.childNodes;
1529
- const slotName = childNode['s-sn'];
1530
- // iterate through all the nodes under the location where the host was
1531
- // originally rendered
1532
- for (j = hostContentNodes.length - 1; j >= 0; j--) {
1533
- node = hostContentNodes[j];
1534
- // check that the node is not a content reference node or a node
1535
- // reference and then check that the host name does not match that of
1536
- // childNode.
1537
- // In addition, check that the slot either has not already been relocated, or
1538
- // that its current location's host is not childNode's host. This is essentially
1539
- // a check so that we don't try to relocate (and then hide) a node that is already
1540
- // where it should be.
1541
- if (!node['s-cn'] &&
1542
- !node['s-nr'] &&
1543
- node['s-hn'] !== childNode['s-hn'] &&
1544
- (!BUILD.experimentalSlotFixes )) {
1545
- // if `node` is located in the slot that `childNode` refers to (via the
1546
- // `'s-sn'` property) then we need to relocate it from it's current spot
1547
- // (under the host element parent) to the right slot location
1548
- if (isNodeLocatedInSlot(node, slotName)) {
1549
- // it's possible we've already decided to relocate this node
1550
- let relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1551
- // made some changes to slots
1552
- // let's make sure we also double check
1553
- // fallbacks are correctly hidden or shown
1554
- checkSlotFallbackVisibility = true;
1555
- // ensure that the slot-name attr is correct
1556
- node['s-sn'] = node['s-sn'] || slotName;
1557
- if (relocateNodeData) {
1558
- relocateNodeData.$nodeToRelocate$['s-sh'] = childNode['s-hn'];
1559
- // we marked this node for relocation previously but didn't find
1560
- // out the slot reference node to which it needs to be relocated
1561
- // so write it down now!
1562
- relocateNodeData.$slotRefNode$ = childNode;
1563
- }
1564
- else {
1565
- node['s-sh'] = childNode['s-hn'];
1566
- // add to our list of nodes to relocate
1567
- relocateNodes.push({
1568
- $slotRefNode$: childNode,
1569
- $nodeToRelocate$: node,
1570
- });
1571
- }
1572
- if (node['s-sr']) {
1573
- relocateNodes.map((relocateNode) => {
1574
- if (isNodeLocatedInSlot(relocateNode.$nodeToRelocate$, node['s-sn'])) {
1575
- relocateNodeData = relocateNodes.find((r) => r.$nodeToRelocate$ === node);
1576
- if (relocateNodeData && !relocateNode.$slotRefNode$) {
1577
- relocateNode.$slotRefNode$ = relocateNodeData.$slotRefNode$;
1578
- }
1579
- }
1580
- });
1581
- }
1582
- }
1583
- else if (!relocateNodes.some((r) => r.$nodeToRelocate$ === node)) {
1584
- // the node is not found within the slot (`childNode`) that we're
1585
- // currently looking at, so we stick it into `relocateNodes` to
1586
- // handle later. If we never find a home for this element then
1587
- // we'll need to hide it
1588
- relocateNodes.push({
1589
- $nodeToRelocate$: node,
1590
- });
1591
- }
1592
- }
1593
- }
1594
- }
1595
- // if we're dealing with any type of element (capable of itself being a
1596
- // slot reference or containing one) then we recur
1597
- if (childNode.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1598
- markSlotContentForRelocation(childNode);
1599
- }
1600
- }
1601
- };
1602
- /**
1603
- * Check whether a node is located in a given named slot.
1604
- *
1605
- * @param nodeToRelocate the node of interest
1606
- * @param slotName the slot name to check
1607
- * @returns whether the node is located in the slot or not
1608
- */
1609
- const isNodeLocatedInSlot = (nodeToRelocate, slotName) => {
1610
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1611
- if (nodeToRelocate.getAttribute('slot') === null && slotName === '') {
1612
- // if the node doesn't have a slot attribute, and the slot we're checking
1613
- // is not a named slot, then we assume the node should be within the slot
1614
- return true;
1615
- }
1616
- if (nodeToRelocate.getAttribute('slot') === slotName) {
1617
- return true;
1618
- }
1619
- return false;
1620
- }
1621
- if (nodeToRelocate['s-sn'] === slotName) {
1622
- return true;
1623
- }
1624
- return slotName === '';
1625
- };
1626
- /**
1627
- * 'Nullify' any VDom `ref` callbacks on a VDom node or its children by calling
1628
- * them with `null`. This signals that the DOM element corresponding to the VDom
1629
- * node has been removed from the DOM.
1630
- *
1631
- * @param vNode a virtual DOM node
1632
- */
1633
- const nullifyVNodeRefs = (vNode) => {
1634
- {
1635
- vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
1636
- vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
1637
- }
1638
- };
1639
- /**
1640
- * The main entry point for Stencil's virtual DOM-based rendering engine
1641
- *
1642
- * Given a {@link d.HostRef} container and some virtual DOM nodes, this
1643
- * function will handle creating a virtual DOM tree with a single root, patching
1644
- * the current virtual DOM tree onto an old one (if any), dealing with slot
1645
- * relocation, and reflecting attributes.
1646
- *
1647
- * @param hostRef data needed to root and render the virtual DOM tree, such as
1648
- * the DOM node into which it should be rendered.
1649
- * @param renderFnResults the virtual DOM nodes to be rendered
1650
- * @param isInitialLoad whether or not this is the first call after page load
1651
- */
1652
- const renderVdom = (hostRef, renderFnResults, isInitialLoad = false) => {
1653
- var _a, _b, _c, _d;
1654
- const hostElm = hostRef.$hostElement$;
1655
- const cmpMeta = hostRef.$cmpMeta$;
1656
- const oldVNode = hostRef.$vnode$ || newVNode(null, null);
1657
- // if `renderFnResults` is a Host node then we can use it directly. If not,
1658
- // we need to call `h` again to wrap the children of our component in a
1659
- // 'dummy' Host node (well, an empty vnode) since `renderVdom` assumes
1660
- // implicitly that the top-level vdom node is 1) an only child and 2)
1661
- // contains attrs that need to be set on the host element.
1662
- const rootVnode = isHost(renderFnResults) ? renderFnResults : h(null, null, renderFnResults);
1663
- hostTagName = hostElm.tagName;
1664
- if (cmpMeta.$attrsToReflect$) {
1665
- rootVnode.$attrs$ = rootVnode.$attrs$ || {};
1666
- cmpMeta.$attrsToReflect$.map(([propName, attribute]) => (rootVnode.$attrs$[attribute] = hostElm[propName]));
1667
- }
1668
- // On the first render and *only* on the first render we want to check for
1669
- // any attributes set on the host element which are also set on the vdom
1670
- // node. If we find them, we override the value on the VDom node attrs with
1671
- // the value from the host element, which allows developers building apps
1672
- // with Stencil components to override e.g. the `role` attribute on a
1673
- // component even if it's already set on the `Host`.
1674
- if (isInitialLoad && rootVnode.$attrs$) {
1675
- for (const key of Object.keys(rootVnode.$attrs$)) {
1676
- // We have a special implementation in `setAccessor` for `style` and
1677
- // `class` which reconciles values coming from the VDom with values
1678
- // already present on the DOM element, so we don't want to override those
1679
- // attributes on the VDom tree with values from the host element if they
1680
- // are present.
1681
- //
1682
- // Likewise, `ref` and `key` are special internal values for the Stencil
1683
- // runtime and we don't want to override those either.
1684
- if (hostElm.hasAttribute(key) && !['key', 'ref', 'style', 'class'].includes(key)) {
1685
- rootVnode.$attrs$[key] = hostElm[key];
1686
- }
1687
- }
1688
- }
1689
- rootVnode.$tag$ = null;
1690
- rootVnode.$flags$ |= 4 /* VNODE_FLAGS.isHost */;
1691
- hostRef.$vnode$ = rootVnode;
1692
- rootVnode.$elm$ = oldVNode.$elm$ = (hostElm.shadowRoot || hostElm );
1693
- {
1694
- scopeId = hostElm['s-sc'];
1695
- }
1696
- useNativeShadowDom = (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) !== 0;
1697
- {
1698
- contentRef = hostElm['s-cr'];
1699
- // always reset
1700
- checkSlotFallbackVisibility = false;
1701
- }
1702
- // synchronous patch
1703
- patch(oldVNode, rootVnode, isInitialLoad);
1704
- {
1705
- // while we're moving nodes around existing nodes, temporarily disable
1706
- // the disconnectCallback from working
1707
- plt.$flags$ |= 1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1708
- if (checkSlotRelocate) {
1709
- markSlotContentForRelocation(rootVnode.$elm$);
1710
- for (const relocateData of relocateNodes) {
1711
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1712
- if (!nodeToRelocate['s-ol']) {
1713
- // add a reference node marking this node's original location
1714
- // keep a reference to this node for later lookups
1715
- const orgLocationNode = doc.createTextNode('');
1716
- orgLocationNode['s-nr'] = nodeToRelocate;
1717
- nodeToRelocate.parentNode.insertBefore((nodeToRelocate['s-ol'] = orgLocationNode), nodeToRelocate);
1718
- }
1719
- }
1720
- for (const relocateData of relocateNodes) {
1721
- const nodeToRelocate = relocateData.$nodeToRelocate$;
1722
- const slotRefNode = relocateData.$slotRefNode$;
1723
- if (slotRefNode) {
1724
- const parentNodeRef = slotRefNode.parentNode;
1725
- // When determining where to insert content, the most simple case would be
1726
- // to relocate the node immediately following the slot reference node. We do this
1727
- // by getting a reference to the node immediately following the slot reference node
1728
- // since we will use `insertBefore` to manipulate the DOM.
1729
- //
1730
- // If there is no node immediately following the slot reference node, then we will just
1731
- // end up appending the node as the last child of the parent.
1732
- let insertBeforeNode = slotRefNode.nextSibling;
1733
- // If the node we're currently planning on inserting the new node before is an element,
1734
- // we need to do some additional checks to make sure we're inserting the node in the correct order.
1735
- // The use case here would be that we have multiple nodes being relocated to the same slot. So, we want
1736
- // to make sure they get inserted into their new home in the same order they were declared in their original location.
1737
- //
1738
- // TODO(STENCIL-914): Remove `experimentalSlotFixes` check
1739
- {
1740
- let orgLocationNode = (_a = nodeToRelocate['s-ol']) === null || _a === void 0 ? void 0 : _a.previousSibling;
1741
- while (orgLocationNode) {
1742
- let refNode = (_b = orgLocationNode['s-nr']) !== null && _b !== void 0 ? _b : null;
1743
- if (refNode && refNode['s-sn'] === nodeToRelocate['s-sn'] && parentNodeRef === refNode.parentNode) {
1744
- refNode = refNode.nextSibling;
1745
- if (!refNode || !refNode['s-nr']) {
1746
- insertBeforeNode = refNode;
1747
- break;
1748
- }
1749
- }
1750
- orgLocationNode = orgLocationNode.previousSibling;
1751
- }
1752
- }
1753
- if ((!insertBeforeNode && parentNodeRef !== nodeToRelocate.parentNode) ||
1754
- nodeToRelocate.nextSibling !== insertBeforeNode) {
1755
- // we've checked that it's worth while to relocate
1756
- // since that the node to relocate
1757
- // has a different next sibling or parent relocated
1758
- if (nodeToRelocate !== insertBeforeNode) {
1759
- if (!nodeToRelocate['s-hn'] && nodeToRelocate['s-ol']) {
1760
- // probably a component in the index.html that doesn't have its hostname set
1761
- nodeToRelocate['s-hn'] = nodeToRelocate['s-ol'].parentNode.nodeName;
1762
- }
1763
- // Add it back to the dom but in its new home
1764
- // If we get to this point and `insertBeforeNode` is `null`, that means
1765
- // we're just going to append the node as the last child of the parent. Passing
1766
- // `null` as the second arg here will trigger that behavior.
1767
- parentNodeRef.insertBefore(nodeToRelocate, insertBeforeNode);
1768
- // Reset the `hidden` value back to what it was defined as originally
1769
- // This solves a problem where a `slot` is dynamically rendered and `hidden` may have
1770
- // been set on content originally, but now it has a slot to go to so it should have
1771
- // the value it was defined as having in the DOM, not what we overrode it to.
1772
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1773
- nodeToRelocate.hidden = (_c = nodeToRelocate['s-ih']) !== null && _c !== void 0 ? _c : false;
1774
- }
1775
- }
1776
- }
1777
- nodeToRelocate && typeof slotRefNode['s-rf'] === 'function' && slotRefNode['s-rf'](nodeToRelocate);
1778
- }
1779
- else {
1780
- // this node doesn't have a slot home to go to, so let's hide it
1781
- if (nodeToRelocate.nodeType === 1 /* NODE_TYPE.ElementNode */) {
1782
- // Store the initial value of `hidden` so we can reset it later when
1783
- // moving nodes around.
1784
- if (isInitialLoad) {
1785
- nodeToRelocate['s-ih'] = (_d = nodeToRelocate.hidden) !== null && _d !== void 0 ? _d : false;
1786
- }
1787
- nodeToRelocate.hidden = true;
1788
- }
1789
- }
1790
- }
1791
- }
1792
- if (checkSlotFallbackVisibility) {
1793
- updateFallbackSlotVisibility(rootVnode.$elm$);
1794
- }
1795
- // done moving nodes around
1796
- // allow the disconnect callback to work again
1797
- plt.$flags$ &= ~1 /* PLATFORM_FLAGS.isTmpDisconnected */;
1798
- // always reset
1799
- relocateNodes.length = 0;
1800
- }
1801
- // Clear the content ref so we don't create a memory leak
1802
- contentRef = undefined;
1803
- };
1804
- const attachToAncestor = (hostRef, ancestorComponent) => {
1805
- if (ancestorComponent && !hostRef.$onRenderResolve$ && ancestorComponent['s-p']) {
1806
- ancestorComponent['s-p'].push(new Promise((r) => (hostRef.$onRenderResolve$ = r)));
1807
- }
1808
- };
1809
- const scheduleUpdate = (hostRef, isInitialLoad) => {
1810
- {
1811
- hostRef.$flags$ |= 16 /* HOST_FLAGS.isQueuedForUpdate */;
1812
- }
1813
- if (hostRef.$flags$ & 4 /* HOST_FLAGS.isWaitingForChildren */) {
1814
- hostRef.$flags$ |= 512 /* HOST_FLAGS.needsRerender */;
1815
- return;
1816
- }
1817
- attachToAncestor(hostRef, hostRef.$ancestorComponent$);
1818
- // there is no ancestor component or the ancestor component
1819
- // has already fired off its lifecycle update then
1820
- // fire off the initial update
1821
- const dispatch = () => dispatchHooks(hostRef, isInitialLoad);
1822
- return writeTask(dispatch) ;
1823
- };
1824
- /**
1825
- * Dispatch initial-render and update lifecycle hooks, enqueuing calls to
1826
- * component lifecycle methods like `componentWillLoad` as well as
1827
- * {@link updateComponent}, which will kick off the virtual DOM re-render.
1828
- *
1829
- * @param hostRef a reference to a host DOM node
1830
- * @param isInitialLoad whether we're on the initial load or not
1831
- * @returns an empty Promise which is used to enqueue a series of operations for
1832
- * the component
1833
- */
1834
- const dispatchHooks = (hostRef, isInitialLoad) => {
1835
- const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
1836
- const instance = hostRef.$lazyInstance$ ;
1837
- // We're going to use this variable together with `enqueue` to implement a
1838
- // little promise-based queue. We start out with it `undefined`. When we add
1839
- // the first function to the queue we'll set this variable to be that
1840
- // function's return value. When we attempt to add subsequent values to the
1841
- // queue we'll check that value and, if it was a `Promise`, we'll then chain
1842
- // the new function off of that `Promise` using `.then()`. This will give our
1843
- // queue two nice properties:
1844
- //
1845
- // 1. If all functions added to the queue are synchronous they'll be called
1846
- // synchronously right away.
1847
- // 2. If all functions added to the queue are asynchronous they'll all be
1848
- // called in order after `dispatchHooks` exits.
1849
- let maybePromise;
1850
- if (isInitialLoad) {
1851
- {
1852
- // If `componentWillLoad` returns a `Promise` then we want to wait on
1853
- // whatever's going on in that `Promise` before we launch into
1854
- // rendering the component, doing other lifecycle stuff, etc. So
1855
- // in that case we assign the returned promise to the variable we
1856
- // declared above to hold a possible 'queueing' Promise
1857
- maybePromise = safeCall(instance, 'componentWillLoad');
1858
- }
1859
- }
1860
- endSchedule();
1861
- return enqueue(maybePromise, () => updateComponent(hostRef, instance, isInitialLoad));
1862
- };
1863
- /**
1864
- * This function uses a Promise to implement a simple first-in, first-out queue
1865
- * of functions to be called.
1866
- *
1867
- * The queue is ordered on the basis of the first argument. If it's
1868
- * `undefined`, then nothing is on the queue yet, so the provided function can
1869
- * be called synchronously (although note that this function may return a
1870
- * `Promise`). The idea is that then the return value of that enqueueing
1871
- * operation is kept around, so that if it was a `Promise` then subsequent
1872
- * functions can be enqueued by calling this function again with that `Promise`
1873
- * as the first argument.
1874
- *
1875
- * @param maybePromise either a `Promise` which should resolve before the next function is called or an 'empty' sentinel
1876
- * @param fn a function to enqueue
1877
- * @returns either a `Promise` or the return value of the provided function
1878
- */
1879
- const enqueue = (maybePromise, fn) => isPromisey(maybePromise) ? maybePromise.then(fn) : fn();
1880
- /**
1881
- * Check that a value is a `Promise`. To check, we first see if the value is an
1882
- * instance of the `Promise` global. In a few circumstances, in particular if
1883
- * the global has been overwritten, this is could be misleading, so we also do
1884
- * a little 'duck typing' check to see if the `.then` property of the value is
1885
- * defined and a function.
1886
- *
1887
- * @param maybePromise it might be a promise!
1888
- * @returns whether it is or not
1889
- */
1890
- const isPromisey = (maybePromise) => maybePromise instanceof Promise ||
1891
- (maybePromise && maybePromise.then && typeof maybePromise.then === 'function');
1892
- /**
1893
- * Update a component given reference to its host elements and so on.
1894
- *
1895
- * @param hostRef an object containing references to the element's host node,
1896
- * VDom nodes, and other metadata
1897
- * @param instance a reference to the underlying host element where it will be
1898
- * rendered
1899
- * @param isInitialLoad whether or not this function is being called as part of
1900
- * the first render cycle
1901
- */
1902
- const updateComponent = async (hostRef, instance, isInitialLoad) => {
1903
- var _a;
1904
- const elm = hostRef.$hostElement$;
1905
- const endUpdate = createTime('update', hostRef.$cmpMeta$.$tagName$);
1906
- const rc = elm['s-rc'];
1907
- if (isInitialLoad) {
1908
- // DOM WRITE!
1909
- attachStyles(hostRef);
1910
- }
1911
- const endRender = createTime('render', hostRef.$cmpMeta$.$tagName$);
1912
- {
1913
- callRender(hostRef, instance, elm, isInitialLoad);
1914
- }
1915
- if (rc) {
1916
- // ok, so turns out there are some child host elements
1917
- // waiting on this parent element to load
1918
- // let's fire off all update callbacks waiting
1919
- rc.map((cb) => cb());
1920
- elm['s-rc'] = undefined;
1921
- }
1922
- endRender();
1923
- endUpdate();
1924
- {
1925
- const childrenPromises = (_a = elm['s-p']) !== null && _a !== void 0 ? _a : [];
1926
- const postUpdate = () => postUpdateComponent(hostRef);
1927
- if (childrenPromises.length === 0) {
1928
- postUpdate();
1929
- }
1930
- else {
1931
- Promise.all(childrenPromises).then(postUpdate);
1932
- hostRef.$flags$ |= 4 /* HOST_FLAGS.isWaitingForChildren */;
1933
- childrenPromises.length = 0;
1934
- }
1935
- }
1936
- };
1937
- /**
1938
- * Handle making the call to the VDom renderer with the proper context given
1939
- * various build variables
1940
- *
1941
- * @param hostRef an object containing references to the element's host node,
1942
- * VDom nodes, and other metadata
1943
- * @param instance a reference to the underlying host element where it will be
1944
- * rendered
1945
- * @param elm the Host element for the component
1946
- * @param isInitialLoad whether or not this function is being called as part of
1947
- * @returns an empty promise
1948
- */
1949
- const callRender = (hostRef, instance, elm, isInitialLoad) => {
1950
- try {
1951
- /**
1952
- * minification optimization: `allRenderFn` is `true` if all components have a `render`
1953
- * method, so we can call the method immediately. If not, check before calling it.
1954
- */
1955
- instance = instance.render() ;
1956
- {
1957
- hostRef.$flags$ &= ~16 /* HOST_FLAGS.isQueuedForUpdate */;
1958
- }
1959
- {
1960
- hostRef.$flags$ |= 2 /* HOST_FLAGS.hasRendered */;
1961
- }
1962
- {
1963
- {
1964
- // looks like we've got child nodes to render into this host element
1965
- // or we need to update the css class/attrs on the host element
1966
- // DOM WRITE!
1967
- {
1968
- renderVdom(hostRef, instance, isInitialLoad);
1969
- }
1970
- }
1971
- }
1972
- }
1973
- catch (e) {
1974
- consoleError(e, hostRef.$hostElement$);
1975
- }
1976
- return null;
1977
- };
1978
- const postUpdateComponent = (hostRef) => {
1979
- const tagName = hostRef.$cmpMeta$.$tagName$;
1980
- const elm = hostRef.$hostElement$;
1981
- const endPostUpdate = createTime('postUpdate', tagName);
1982
- const instance = hostRef.$lazyInstance$ ;
1983
- const ancestorComponent = hostRef.$ancestorComponent$;
1984
- if (!(hostRef.$flags$ & 64 /* HOST_FLAGS.hasLoadedComponent */)) {
1985
- hostRef.$flags$ |= 64 /* HOST_FLAGS.hasLoadedComponent */;
1986
- {
1987
- // DOM WRITE!
1988
- addHydratedFlag(elm);
1989
- }
1990
- {
1991
- safeCall(instance, 'componentDidLoad');
1992
- }
1993
- endPostUpdate();
1994
- {
1995
- hostRef.$onReadyResolve$(elm);
1996
- if (!ancestorComponent) {
1997
- appDidLoad();
1998
- }
1999
- }
2000
- }
2001
- else {
2002
- {
2003
- safeCall(instance, 'componentDidUpdate');
2004
- }
2005
- endPostUpdate();
2006
- }
2007
- // load events fire from bottom to top
2008
- // the deepest elements load first then bubbles up
2009
- {
2010
- if (hostRef.$onRenderResolve$) {
2011
- hostRef.$onRenderResolve$();
2012
- hostRef.$onRenderResolve$ = undefined;
2013
- }
2014
- if (hostRef.$flags$ & 512 /* HOST_FLAGS.needsRerender */) {
2015
- nextTick(() => scheduleUpdate(hostRef, false));
2016
- }
2017
- hostRef.$flags$ &= ~(4 /* HOST_FLAGS.isWaitingForChildren */ | 512 /* HOST_FLAGS.needsRerender */);
2018
- }
2019
- // ( •_•)
2020
- // ( •_•)>⌐■-■
2021
- // (⌐■_■)
2022
- };
2023
- const appDidLoad = (who) => {
2024
- // on appload
2025
- // we have finish the first big initial render
2026
- {
2027
- addHydratedFlag(doc.documentElement);
2028
- }
2029
- nextTick(() => emitEvent(win, 'appload', { detail: { namespace: NAMESPACE } }));
2030
- };
2031
- /**
2032
- * Allows to safely call a method, e.g. `componentDidLoad`, on an instance,
2033
- * e.g. custom element node. If a build figures out that e.g. no component
2034
- * has a `componentDidLoad` method, the instance method gets removed from the
2035
- * output bundle and this function returns `undefined`.
2036
- * @param instance any object that may or may not contain methods
2037
- * @param method method name
2038
- * @param arg single arbitrary argument
2039
- * @returns result of method call if it exists, otherwise `undefined`
2040
- */
2041
- const safeCall = (instance, method, arg) => {
2042
- if (instance && instance[method]) {
2043
- try {
2044
- return instance[method](arg);
2045
- }
2046
- catch (e) {
2047
- consoleError(e);
2048
- }
2049
- }
2050
- return undefined;
2051
- };
2052
- const addHydratedFlag = (elm) => elm.classList.add('hydrated')
2053
- ;
2054
- const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propName);
2055
- const setValue = (ref, propName, newVal, cmpMeta) => {
2056
- // check our new property value against our internal value
2057
- const hostRef = getHostRef(ref);
2058
- const elm = hostRef.$hostElement$ ;
2059
- const oldVal = hostRef.$instanceValues$.get(propName);
2060
- const flags = hostRef.$flags$;
2061
- const instance = hostRef.$lazyInstance$ ;
2062
- newVal = parsePropertyValue(newVal, cmpMeta.$members$[propName][0]);
2063
- // explicitly check for NaN on both sides, as `NaN === NaN` is always false
2064
- const areBothNaN = Number.isNaN(oldVal) && Number.isNaN(newVal);
2065
- const didValueChange = newVal !== oldVal && !areBothNaN;
2066
- if ((!(flags & 8 /* HOST_FLAGS.isConstructingInstance */) || oldVal === undefined) && didValueChange) {
2067
- // gadzooks! the property's value has changed!!
2068
- // set our new value!
2069
- hostRef.$instanceValues$.set(propName, newVal);
2070
- if (instance) {
2071
- // get an array of method names of watch functions to call
2072
- if (cmpMeta.$watchers$ && flags & 128 /* HOST_FLAGS.isWatchReady */) {
2073
- const watchMethods = cmpMeta.$watchers$[propName];
2074
- if (watchMethods) {
2075
- // this instance is watching for when this property changed
2076
- watchMethods.map((watchMethodName) => {
2077
- try {
2078
- // fire off each of the watch methods that are watching this property
2079
- instance[watchMethodName](newVal, oldVal, propName);
2080
- }
2081
- catch (e) {
2082
- consoleError(e, elm);
2083
- }
2084
- });
2085
- }
2086
- }
2087
- if ((flags & (2 /* HOST_FLAGS.hasRendered */ | 16 /* HOST_FLAGS.isQueuedForUpdate */)) === 2 /* HOST_FLAGS.hasRendered */) {
2088
- // looks like this value actually changed, so we've got work to do!
2089
- // but only if we've already rendered, otherwise just chill out
2090
- // queue that we need to do an update, but don't worry about queuing
2091
- // up millions cuz this function ensures it only runs once
2092
- scheduleUpdate(hostRef, false);
2093
- }
2094
- }
2095
- }
2096
- };
2097
- /**
2098
- * Attach a series of runtime constructs to a compiled Stencil component
2099
- * constructor, including getters and setters for the `@Prop` and `@State`
2100
- * decorators, callbacks for when attributes change, and so on.
2101
- *
2102
- * @param Cstr the constructor for a component that we need to process
2103
- * @param cmpMeta metadata collected previously about the component
2104
- * @param flags a number used to store a series of bit flags
2105
- * @returns a reference to the same constructor passed in (but now mutated)
2106
- */
2107
- const proxyComponent = (Cstr, cmpMeta, flags) => {
2108
- var _a;
2109
- const prototype = Cstr.prototype;
2110
- if (cmpMeta.$members$) {
2111
- if (Cstr.watchers) {
2112
- cmpMeta.$watchers$ = Cstr.watchers;
2113
- }
2114
- // It's better to have a const than two Object.entries()
2115
- const members = Object.entries(cmpMeta.$members$);
2116
- members.map(([memberName, [memberFlags]]) => {
2117
- if ((memberFlags & 31 /* MEMBER_FLAGS.Prop */ ||
2118
- ((flags & 2 /* PROXY_FLAGS.proxyState */) && memberFlags & 32 /* MEMBER_FLAGS.State */))) {
2119
- // proxyComponent - prop
2120
- Object.defineProperty(prototype, memberName, {
2121
- get() {
2122
- // proxyComponent, get value
2123
- return getValue(this, memberName);
2124
- },
2125
- set(newValue) {
2126
- // proxyComponent, set value
2127
- setValue(this, memberName, newValue, cmpMeta);
2128
- },
2129
- configurable: true,
2130
- enumerable: true,
2131
- });
2132
- }
2133
- });
2134
- if ((flags & 1 /* PROXY_FLAGS.isElementConstructor */)) {
2135
- const attrNameToPropName = new Map();
2136
- prototype.attributeChangedCallback = function (attrName, oldValue, newValue) {
2137
- plt.jmp(() => {
2138
- var _a;
2139
- const propName = attrNameToPropName.get(attrName);
2140
- // In a web component lifecycle the attributeChangedCallback runs prior to connectedCallback
2141
- // in the case where an attribute was set inline.
2142
- // ```html
2143
- // <my-component some-attribute="some-value"></my-component>
2144
- // ```
2145
- //
2146
- // There is an edge case where a developer sets the attribute inline on a custom element and then
2147
- // programmatically changes it before it has been upgraded as shown below:
2148
- //
2149
- // ```html
2150
- // <!-- this component has _not_ been upgraded yet -->
2151
- // <my-component id="test" some-attribute="some-value"></my-component>
2152
- // <script>
2153
- // // grab non-upgraded component
2154
- // el = document.querySelector("#test");
2155
- // el.someAttribute = "another-value";
2156
- // // upgrade component
2157
- // customElements.define('my-component', MyComponent);
2158
- // </script>
2159
- // ```
2160
- // In this case if we do not un-shadow here and use the value of the shadowing property, attributeChangedCallback
2161
- // will be called with `newValue = "some-value"` and will set the shadowed property (this.someAttribute = "another-value")
2162
- // to the value that was set inline i.e. "some-value" from above example. When
2163
- // the connectedCallback attempts to un-shadow it will use "some-value" as the initial value rather than "another-value"
2164
- //
2165
- // The case where the attribute was NOT set inline but was not set programmatically shall be handled/un-shadowed
2166
- // by connectedCallback as this attributeChangedCallback will not fire.
2167
- //
2168
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2169
- //
2170
- // TODO(STENCIL-16) we should think about whether or not we actually want to be reflecting the attributes to
2171
- // properties here given that this goes against best practices outlined here
2172
- // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy
2173
- if (this.hasOwnProperty(propName)) {
2174
- newValue = this[propName];
2175
- delete this[propName];
2176
- }
2177
- else if (prototype.hasOwnProperty(propName) &&
2178
- typeof this[propName] === 'number' &&
2179
- this[propName] == newValue) {
2180
- // if the propName exists on the prototype of `Cstr`, this update may be a result of Stencil using native
2181
- // APIs to reflect props as attributes. Calls to `setAttribute(someElement, propName)` will result in
2182
- // `propName` to be converted to a `DOMString`, which may not be what we want for other primitive props.
2183
- return;
2184
- }
2185
- else if (propName == null) {
2186
- // At this point we should know this is not a "member", so we can treat it like watching an attribute
2187
- // on a vanilla web component
2188
- const hostRef = getHostRef(this);
2189
- const flags = hostRef === null || hostRef === void 0 ? void 0 : hostRef.$flags$;
2190
- // We only want to trigger the callback(s) if:
2191
- // 1. The instance is ready
2192
- // 2. The watchers are ready
2193
- // 3. The value has changed
2194
- if (flags &&
2195
- !(flags & 8 /* HOST_FLAGS.isConstructingInstance */) &&
2196
- flags & 128 /* HOST_FLAGS.isWatchReady */ &&
2197
- newValue !== oldValue) {
2198
- const instance = hostRef.$lazyInstance$ ;
2199
- const entry = (_a = cmpMeta.$watchers$) === null || _a === void 0 ? void 0 : _a[attrName];
2200
- entry === null || entry === void 0 ? void 0 : entry.forEach((callbackName) => {
2201
- if (instance[callbackName] != null) {
2202
- instance[callbackName].call(instance, newValue, oldValue, attrName);
2203
- }
2204
- });
2205
- }
2206
- return;
2207
- }
2208
- this[propName] = newValue === null && typeof this[propName] === 'boolean' ? false : newValue;
2209
- });
2210
- };
2211
- // Create an array of attributes to observe
2212
- // This list in comprised of all strings used within a `@Watch()` decorator
2213
- // on a component as well as any Stencil-specific "members" (`@Prop()`s and `@State()`s).
2214
- // As such, there is no way to guarantee type-safety here that a user hasn't entered
2215
- // an invalid attribute.
2216
- Cstr.observedAttributes = Array.from(new Set([
2217
- ...Object.keys((_a = cmpMeta.$watchers$) !== null && _a !== void 0 ? _a : {}),
2218
- ...members
2219
- .filter(([_, m]) => m[0] & 15 /* MEMBER_FLAGS.HasAttribute */)
2220
- .map(([propName, m]) => {
2221
- var _a;
2222
- const attrName = m[1] || propName;
2223
- attrNameToPropName.set(attrName, propName);
2224
- if (m[0] & 512 /* MEMBER_FLAGS.ReflectAttr */) {
2225
- (_a = cmpMeta.$attrsToReflect$) === null || _a === void 0 ? void 0 : _a.push([propName, attrName]);
2226
- }
2227
- return attrName;
2228
- }),
2229
- ]));
2230
- }
2231
- }
2232
- return Cstr;
2233
- };
2234
- /**
2235
- * Initialize a Stencil component given a reference to its host element, its
2236
- * runtime bookkeeping data structure, runtime metadata about the component,
2237
- * and (optionally) an HMR version ID.
2238
- *
2239
- * @param elm a host element
2240
- * @param hostRef the element's runtime bookkeeping object
2241
- * @param cmpMeta runtime metadata for the Stencil component
2242
- * @param hmrVersionId an (optional) HMR version ID
2243
- */
2244
- const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId) => {
2245
- let Cstr;
2246
- // initializeComponent
2247
- if ((hostRef.$flags$ & 32 /* HOST_FLAGS.hasInitializedComponent */) === 0) {
2248
- // Let the runtime know that the component has been initialized
2249
- hostRef.$flags$ |= 32 /* HOST_FLAGS.hasInitializedComponent */;
2250
- const bundleId = cmpMeta.$lazyBundleId$;
2251
- if (bundleId) {
2252
- // lazy loaded components
2253
- // request the component's implementation to be
2254
- // wired up with the host element
2255
- Cstr = loadModule(cmpMeta);
2256
- if (Cstr.then) {
2257
- // Await creates a micro-task avoid if possible
2258
- const endLoad = uniqueTime();
2259
- Cstr = await Cstr;
2260
- endLoad();
2261
- }
2262
- if (!Cstr.isProxied) {
2263
- // we've never proxied this Constructor before
2264
- // let's add the getters/setters to its prototype before
2265
- // the first time we create an instance of the implementation
2266
- {
2267
- cmpMeta.$watchers$ = Cstr.watchers;
2268
- }
2269
- proxyComponent(Cstr, cmpMeta, 2 /* PROXY_FLAGS.proxyState */);
2270
- Cstr.isProxied = true;
2271
- }
2272
- const endNewInstance = createTime('createInstance', cmpMeta.$tagName$);
2273
- // ok, time to construct the instance
2274
- // but let's keep track of when we start and stop
2275
- // so that the getters/setters don't incorrectly step on data
2276
- {
2277
- hostRef.$flags$ |= 8 /* HOST_FLAGS.isConstructingInstance */;
2278
- }
2279
- // construct the lazy-loaded component implementation
2280
- // passing the hostRef is very important during
2281
- // construction in order to directly wire together the
2282
- // host element and the lazy-loaded instance
2283
- try {
2284
- new Cstr(hostRef);
2285
- }
2286
- catch (e) {
2287
- consoleError(e);
2288
- }
2289
- {
2290
- hostRef.$flags$ &= ~8 /* HOST_FLAGS.isConstructingInstance */;
2291
- }
2292
- {
2293
- hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */;
2294
- }
2295
- endNewInstance();
2296
- }
2297
- else {
2298
- // sync constructor component
2299
- Cstr = elm.constructor;
2300
- // wait for the CustomElementRegistry to mark the component as ready before setting `isWatchReady`. Otherwise,
2301
- // watchers may fire prematurely if `customElements.get()`/`customElements.whenDefined()` resolves _before_
2302
- // Stencil has completed instantiating the component.
2303
- customElements.whenDefined(cmpMeta.$tagName$).then(() => (hostRef.$flags$ |= 128 /* HOST_FLAGS.isWatchReady */));
2304
- }
2305
- if (Cstr.style) {
2306
- // this component has styles but we haven't registered them yet
2307
- let style = Cstr.style;
2308
- const scopeId = getScopeId(cmpMeta);
2309
- if (!styles.has(scopeId)) {
2310
- const endRegisterStyles = createTime('registerStyles', cmpMeta.$tagName$);
2311
- registerStyle(scopeId, style, !!(cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */));
2312
- endRegisterStyles();
2313
- }
2314
- }
2315
- }
2316
- // we've successfully created a lazy instance
2317
- const ancestorComponent = hostRef.$ancestorComponent$;
2318
- const schedule = () => scheduleUpdate(hostRef, true);
2319
- if (ancestorComponent && ancestorComponent['s-rc']) {
2320
- // this is the initial load and this component it has an ancestor component
2321
- // but the ancestor component has NOT fired its will update lifecycle yet
2322
- // so let's just cool our jets and wait for the ancestor to continue first
2323
- // this will get fired off when the ancestor component
2324
- // finally gets around to rendering its lazy self
2325
- // fire off the initial update
2326
- ancestorComponent['s-rc'].push(schedule);
2327
- }
2328
- else {
2329
- schedule();
2330
- }
2331
- };
2332
- const fireConnectedCallback = (instance) => {
2333
- };
2334
- const connectedCallback = (elm) => {
2335
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2336
- const hostRef = getHostRef(elm);
2337
- const cmpMeta = hostRef.$cmpMeta$;
2338
- const endConnected = createTime('connectedCallback', cmpMeta.$tagName$);
2339
- if (!(hostRef.$flags$ & 1 /* HOST_FLAGS.hasConnected */)) {
2340
- // first time this component has connected
2341
- hostRef.$flags$ |= 1 /* HOST_FLAGS.hasConnected */;
2342
- let hostId;
2343
- {
2344
- hostId = elm.getAttribute(HYDRATE_ID);
2345
- if (hostId) {
2346
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2347
- const scopeId = addStyle(elm.shadowRoot, cmpMeta);
2348
- elm.classList.remove(scopeId + '-h', scopeId + '-s');
2349
- }
2350
- initializeClientHydrate(elm, cmpMeta.$tagName$, hostId, hostRef);
2351
- }
2352
- }
2353
- if (!hostId) {
2354
- // initUpdate
2355
- // if the slot polyfill is required we'll need to put some nodes
2356
- // in here to act as original content anchors as we move nodes around
2357
- // host element has been connected to the DOM
2358
- if ((// TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
2359
- cmpMeta.$flags$ & (4 /* CMP_FLAGS.hasSlotRelocation */ | 8 /* CMP_FLAGS.needsShadowDomShim */))) {
2360
- setContentReference(elm);
2361
- }
2362
- }
2363
- {
2364
- // find the first ancestor component (if there is one) and register
2365
- // this component as one of the actively loading child components for its ancestor
2366
- let ancestorComponent = elm;
2367
- while ((ancestorComponent = ancestorComponent.parentNode || ancestorComponent.host)) {
2368
- // climb up the ancestors looking for the first
2369
- // component that hasn't finished its lifecycle update yet
2370
- if ((ancestorComponent.nodeType === 1 /* NODE_TYPE.ElementNode */ &&
2371
- ancestorComponent.hasAttribute('s-id') &&
2372
- ancestorComponent['s-p']) ||
2373
- ancestorComponent['s-p']) {
2374
- // we found this components first ancestor component
2375
- // keep a reference to this component's ancestor component
2376
- attachToAncestor(hostRef, (hostRef.$ancestorComponent$ = ancestorComponent));
2377
- break;
2378
- }
2379
- }
2380
- }
2381
- // Lazy properties
2382
- // https://developers.google.com/web/fundamentals/web-components/best-practices#lazy-properties
2383
- if (cmpMeta.$members$) {
2384
- Object.entries(cmpMeta.$members$).map(([memberName, [memberFlags]]) => {
2385
- if (memberFlags & 31 /* MEMBER_FLAGS.Prop */ && elm.hasOwnProperty(memberName)) {
2386
- const value = elm[memberName];
2387
- delete elm[memberName];
2388
- elm[memberName] = value;
2389
- }
2390
- });
2391
- }
2392
- {
2393
- initializeComponent(elm, hostRef, cmpMeta);
2394
- }
2395
- }
2396
- else {
2397
- // fire off connectedCallback() on component instance
2398
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) ;
2399
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
2400
- hostRef.$onReadyPromise$.then(() => fireConnectedCallback());
2401
- }
2402
- }
2403
- endConnected();
2404
- }
2405
- };
2406
- const setContentReference = (elm) => {
2407
- // only required when we're NOT using native shadow dom (slot)
2408
- // or this browser doesn't support native shadow dom
2409
- // and this host element was NOT created with SSR
2410
- // let's pick out the inner content for slot projection
2411
- // create a node to represent where the original
2412
- // content was first placed, which is useful later on
2413
- const contentRefElm = (elm['s-cr'] = doc.createComment(''));
2414
- contentRefElm['s-cn'] = true;
2415
- elm.insertBefore(contentRefElm, elm.firstChild);
2416
- };
2417
- const disconnectInstance = (instance) => {
2418
- {
2419
- safeCall(instance, 'disconnectedCallback');
2420
- }
2421
- };
2422
- const disconnectedCallback = async (elm) => {
2423
- if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
2424
- const hostRef = getHostRef(elm);
2425
- if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$lazyInstance$) {
2426
- disconnectInstance(hostRef.$lazyInstance$);
2427
- }
2428
- else if (hostRef === null || hostRef === void 0 ? void 0 : hostRef.$onReadyPromise$) {
2429
- hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$));
2430
- }
2431
- }
2432
- };
2433
- const bootstrapLazy = (lazyBundles, options = {}) => {
2434
- var _a;
2435
- const endBootstrap = createTime();
2436
- const cmpTags = [];
2437
- const exclude = options.exclude || [];
2438
- const customElements = win.customElements;
2439
- const head = doc.head;
2440
- const metaCharset = /*@__PURE__*/ head.querySelector('meta[charset]');
2441
- const dataStyles = /*@__PURE__*/ doc.createElement('style');
2442
- const deferredConnectedCallbacks = [];
2443
- const styles = /*@__PURE__*/ doc.querySelectorAll(`[${HYDRATED_STYLE_ID}]`);
2444
- let appLoadFallback;
2445
- let isBootstrapping = true;
2446
- let i = 0;
2447
- Object.assign(plt, options);
2448
- plt.$resourcesUrl$ = new URL(options.resourcesUrl || './', doc.baseURI).href;
2449
- {
2450
- // If the app is already hydrated there is not point to disable the
2451
- // async queue. This will improve the first input delay
2452
- plt.$flags$ |= 2 /* PLATFORM_FLAGS.appLoaded */;
2453
- }
2454
- {
2455
- for (; i < styles.length; i++) {
2456
- registerStyle(styles[i].getAttribute(HYDRATED_STYLE_ID), convertScopedToShadow(styles[i].innerHTML), true);
2457
- }
2458
- }
2459
- let hasSlotRelocation = false;
2460
- lazyBundles.map((lazyBundle) => {
2461
- lazyBundle[1].map((compactMeta) => {
2462
- var _a;
2463
- const cmpMeta = {
2464
- $flags$: compactMeta[0],
2465
- $tagName$: compactMeta[1],
2466
- $members$: compactMeta[2],
2467
- $listeners$: compactMeta[3],
2468
- };
2469
- // Check if we are using slots outside the shadow DOM in this component.
2470
- // We'll use this information later to add styles for `slot-fb` elements
2471
- if (cmpMeta.$flags$ & 4 /* CMP_FLAGS.hasSlotRelocation */) {
2472
- hasSlotRelocation = true;
2473
- }
2474
- {
2475
- cmpMeta.$members$ = compactMeta[2];
2476
- }
2477
- {
2478
- cmpMeta.$attrsToReflect$ = [];
2479
- }
2480
- {
2481
- cmpMeta.$watchers$ = (_a = compactMeta[4]) !== null && _a !== void 0 ? _a : {};
2482
- }
2483
- const tagName = cmpMeta.$tagName$;
2484
- const HostElement = class extends HTMLElement {
2485
- // StencilLazyHost
2486
- constructor(self) {
2487
- // @ts-ignore
2488
- super(self);
2489
- self = this;
2490
- registerHost(self, cmpMeta);
2491
- if (cmpMeta.$flags$ & 1 /* CMP_FLAGS.shadowDomEncapsulation */) {
2492
- // this component is using shadow dom
2493
- // and this browser supports shadow dom
2494
- // add the read-only property "shadowRoot" to the host element
2495
- // adding the shadow root build conditionals to minimize runtime
2496
- {
2497
- {
2498
- self.attachShadow({ mode: 'open' });
2499
- }
2500
- }
2501
- }
2502
- }
2503
- connectedCallback() {
2504
- if (appLoadFallback) {
2505
- clearTimeout(appLoadFallback);
2506
- appLoadFallback = null;
2507
- }
2508
- if (isBootstrapping) {
2509
- // connectedCallback will be processed once all components have been registered
2510
- deferredConnectedCallbacks.push(this);
2511
- }
2512
- else {
2513
- plt.jmp(() => connectedCallback(this));
2514
- }
2515
- }
2516
- disconnectedCallback() {
2517
- plt.jmp(() => disconnectedCallback(this));
2518
- }
2519
- componentOnReady() {
2520
- return getHostRef(this).$onReadyPromise$;
2521
- }
2522
- };
2523
- cmpMeta.$lazyBundleId$ = lazyBundle[0];
2524
- if (!exclude.includes(tagName) && !customElements.get(tagName)) {
2525
- cmpTags.push(tagName);
2526
- customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1 /* PROXY_FLAGS.isElementConstructor */));
2527
- }
2528
- });
2529
- });
2530
- // Only bother generating CSS if we have components
2531
- // TODO(STENCIL-1118): Add test cases for CSS content based on conditionals
2532
- if (cmpTags.length > 0) {
2533
- // Add styles for `slot-fb` elements if any of our components are using slots outside the Shadow DOM
2534
- if (hasSlotRelocation) {
2535
- dataStyles.textContent += SLOT_FB_CSS;
2536
- }
2537
- // Add hydration styles
2538
- {
2539
- dataStyles.textContent += cmpTags + HYDRATED_CSS;
2540
- }
2541
- // If we have styles, add them to the DOM
2542
- if (dataStyles.innerHTML.length) {
2543
- dataStyles.setAttribute('data-styles', '');
2544
- // Apply CSP nonce to the style tag if it exists
2545
- const nonce = (_a = plt.$nonce$) !== null && _a !== void 0 ? _a : queryNonceMetaTagContent(doc);
2546
- if (nonce != null) {
2547
- dataStyles.setAttribute('nonce', nonce);
2548
- }
2549
- // Insert the styles into the document head
2550
- // NOTE: this _needs_ to happen last so we can ensure the nonce (and other attributes) are applied
2551
- head.insertBefore(dataStyles, metaCharset ? metaCharset.nextSibling : head.firstChild);
2552
- }
2553
- }
2554
- // Process deferred connectedCallbacks now all components have been registered
2555
- isBootstrapping = false;
2556
- if (deferredConnectedCallbacks.length) {
2557
- deferredConnectedCallbacks.map((host) => host.connectedCallback());
2558
- }
2559
- else {
2560
- {
2561
- plt.jmp(() => (appLoadFallback = setTimeout(appDidLoad, 30)));
2562
- }
2563
- }
2564
- // Fallback appLoad event
2565
- endBootstrap();
2566
- };
2567
- /**
2568
- * Assigns the given value to the nonce property on the runtime platform object.
2569
- * During runtime, this value is used to set the nonce attribute on all dynamically created script and style tags.
2570
- * @param nonce The value to be assigned to the platform nonce property.
2571
- * @returns void
2572
- */
2573
- const setNonce = (nonce) => (plt.$nonce$ = nonce);
2574
- /**
2575
- * A WeakMap mapping runtime component references to their corresponding host reference
2576
- * instances.
2577
- *
2578
- * **Note**: If we're in an HMR context we need to store a reference to this
2579
- * value on `window` in order to maintain the mapping of {@link d.RuntimeRef}
2580
- * to {@link d.HostRef} across HMR updates.
2581
- *
2582
- * This is necessary because when HMR updates for a component are processed by
2583
- * the browser-side dev server client the JS bundle for that component is
2584
- * re-fetched. Since the module containing {@link hostRefs} is included in
2585
- * that bundle, if we do not store a reference to it the new iteration of the
2586
- * component will not have access to the previous hostRef map, leading to a
2587
- * bug where the new version of the component cannot properly initialize.
2588
- */
2589
- const hostRefs = new WeakMap();
2590
- /**
2591
- * Given a {@link d.RuntimeRef} retrieve the corresponding {@link d.HostRef}
2592
- *
2593
- * @param ref the runtime ref of interest
2594
- * @returns the Host reference (if found) or undefined
2595
- */
2596
- const getHostRef = (ref) => hostRefs.get(ref);
2597
- /**
2598
- * Register a lazy instance with the {@link hostRefs} object so it's
2599
- * corresponding {@link d.HostRef} can be retrieved later.
2600
- *
2601
- * @param lazyInstance the lazy instance of interest
2602
- * @param hostRef that instances `HostRef` object
2603
- * @returns a reference to the host ref WeakMap
2604
- */
2605
- const registerInstance = (lazyInstance, hostRef) => hostRefs.set((hostRef.$lazyInstance$ = lazyInstance), hostRef);
2606
- /**
2607
- * Register a host element for a Stencil component, setting up various metadata
2608
- * and callbacks based on {@link BUILD} flags as well as the component's runtime
2609
- * metadata.
2610
- *
2611
- * @param hostElement the host element to register
2612
- * @param cmpMeta runtime metadata for that component
2613
- * @returns a reference to the host ref WeakMap
2614
- */
2615
- const registerHost = (hostElement, cmpMeta) => {
2616
- const hostRef = {
2617
- $flags$: 0,
2618
- $hostElement$: hostElement,
2619
- $cmpMeta$: cmpMeta,
2620
- $instanceValues$: new Map(),
2621
- };
2622
- {
2623
- hostRef.$onReadyPromise$ = new Promise((r) => (hostRef.$onReadyResolve$ = r));
2624
- hostElement['s-p'] = [];
2625
- hostElement['s-rc'] = [];
2626
- }
2627
- return hostRefs.set(hostElement, hostRef);
2628
- };
2629
- const isMemberInElement = (elm, memberName) => memberName in elm;
2630
- const consoleError = (e, el) => (0, console.error)(e, el);
2631
- const cmpModules = /*@__PURE__*/ new Map();
2632
- const loadModule = (cmpMeta, hostRef, hmrVersionId) => {
2633
- // loadModuleImport
2634
- const exportName = cmpMeta.$tagName$.replace(/-/g, '_');
2635
- const bundleId = cmpMeta.$lazyBundleId$;
2636
- const module = cmpModules.get(bundleId) ;
2637
- if (module) {
2638
- return module[exportName];
2639
- }
2640
- /*!__STENCIL_STATIC_IMPORT_SWITCH__*/
2641
- return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require(
2642
- /* @vite-ignore */
2643
- /* webpackInclude: /\.entry\.js$/ */
2644
- /* webpackExclude: /\.system\.entry\.js$/ */
2645
- /* webpackMode: "lazy" */
2646
- `./${bundleId}.entry.js${''}`)); }).then((importedModule) => {
2647
- {
2648
- cmpModules.set(bundleId, importedModule);
2649
- }
2650
- return importedModule[exportName];
2651
- }, consoleError);
2652
- };
2653
- const styles = /*@__PURE__*/ new Map();
2654
- const win = typeof window !== 'undefined' ? window : {};
2655
- const doc = win.document || { head: {} };
2656
- const plt = {
2657
- $flags$: 0,
2658
- $resourcesUrl$: '',
2659
- jmp: (h) => h(),
2660
- raf: (h) => requestAnimationFrame(h),
2661
- ael: (el, eventName, listener, opts) => el.addEventListener(eventName, listener, opts),
2662
- rel: (el, eventName, listener, opts) => el.removeEventListener(eventName, listener, opts),
2663
- ce: (eventName, opts) => new CustomEvent(eventName, opts),
2664
- };
2665
- const supportsShadow =
2666
- // TODO(STENCIL-854): Remove code related to legacy shadowDomShim field
2667
- true;
2668
- const promiseResolve = (v) => Promise.resolve(v);
2669
- const supportsConstructableStylesheets = /*@__PURE__*/ (() => {
2670
- try {
2671
- new CSSStyleSheet();
2672
- return typeof new CSSStyleSheet().replaceSync === 'function';
2673
- }
2674
- catch (e) { }
2675
- return false;
2676
- })()
2677
- ;
2678
- const queueDomReads = [];
2679
- const queueDomWrites = [];
2680
- const queueTask = (queue, write) => (cb) => {
2681
- queue.push(cb);
2682
- if (!queuePending) {
2683
- queuePending = true;
2684
- if (write && plt.$flags$ & 4 /* PLATFORM_FLAGS.queueSync */) {
2685
- nextTick(flush);
2686
- }
2687
- else {
2688
- plt.raf(flush);
2689
- }
2690
- }
2691
- };
2692
- const consume = (queue) => {
2693
- for (let i = 0; i < queue.length; i++) {
2694
- try {
2695
- queue[i](performance.now());
2696
- }
2697
- catch (e) {
2698
- consoleError(e);
2699
- }
2700
- }
2701
- queue.length = 0;
2702
- };
2703
- const flush = () => {
2704
- // always force a bunch of medium callbacks to run, but still have
2705
- // a throttle on how many can run in a certain time
2706
- // DOM READS!!!
2707
- consume(queueDomReads);
2708
- // DOM WRITES!!!
2709
- {
2710
- consume(queueDomWrites);
2711
- if ((queuePending = queueDomReads.length > 0)) {
2712
- // still more to do yet, but we've run out of time
2713
- // let's let this thing cool off and try again in the next tick
2714
- plt.raf(flush);
2715
- }
2716
- }
2717
- };
2718
- const nextTick = (cb) => promiseResolve().then(cb);
2719
- const writeTask = /*@__PURE__*/ queueTask(queueDomWrites, true);
2720
-
2721
- exports.Host = Host;
2722
- exports.bootstrapLazy = bootstrapLazy;
2723
- exports.createEvent = createEvent;
2724
- exports.getElement = getElement;
2725
- exports.h = h;
2726
- exports.promiseResolve = promiseResolve;
2727
- exports.registerInstance = registerInstance;
2728
- exports.setNonce = setNonce;
2729
-
2730
- //# sourceMappingURL=index-e2ae280a.js.map