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